You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
plpgsql: fix handling of annotations for DO blocks
This commit should fix for good annotations handling for DO blocks that
was recently attempted to be fixed in 3b8ab38.
(That commit is partially reversed too).
The general issue is that in the PLpgSQL parser we use an ephemeral SQL
parser instance to process SQL statements. However, when processing the
DO block stmts we need to preserve the annotations state between each
stmt. This is now achieved by extending the SQL parser infrastructure to
give an option to override the initial annotations index as well as keep
on reusing the counter across multiple stmts. This allows us to
correctly count the number of annotations that we need for the whole DO
block during the initial parsing, and then we use the allocated
annotations container to set the items in the optbuild.
Release note (bug fix): Previously, CockroachDB node could crash when
executing DO stmts when they contain user-defined types (possibly
non-existing) in non-default configuration (additional logging like the
one controlled via `sql.log.all_statements.enabled` cluster setting needed
to be enabled). This bug was introduced in 25.1 release and is now fixed.
require.Equal(t, `SELECT k FROM defaultdb.public.kv WHERE v != '_'; SELECT k FROM defaultdb.public.kv WHERE v = '_';`, mut.FunctionBody)
84
+
require.Equal(t, `SELECT k FROM defaultdb.public.kv WHERE v != '_'; SELECT k FROM defaultdb.public.kv WHERE v = '_'; SELECT k FROM defaultdb.public.kv WHERE e != '_'; SELECT k FROM defaultdb.public.kv WHERE e = '_';`, mut.FunctionBody)
81
85
})
82
86
83
87
t.Run("create function plpgsql", func(t*testing.T) {
@@ -87,8 +91,9 @@ $$`)
87
91
require.Equal(t, `DECLARE
88
92
x INT8 := _;
89
93
y STRING := '_';
94
+
z @100104;
90
95
BEGIN
91
-
SELECT k FROM defaultdb.public.kv WHERE v != '_';
96
+
SELECT k FROM defaultdb.public.kv WHERE (v != '_') AND (e != '_':::@100104);
0 commit comments