summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2021-01-04 16:52:00 +0000
committerTom Lane2021-01-04 16:52:00 +0000
commitc9d5298485b78a37923a23f9af9aa0ade06762db (patch)
tree4e7e39d4035be1dcea11809ab2c43ed69bc4d8c7 /src/test
parent844fe9f159a948377907a63d0ef3fb16dc51ce50 (diff)
Re-implement pl/pgsql's expression and assignment parsing.
Invent new RawParseModes that allow the core grammar to handle pl/pgsql expressions and assignments directly, and thereby get rid of a lot of hackery in pl/pgsql's parser. This moves a good deal of knowledge about pl/pgsql into the core code: notably, we have to invent a CoercionContext that matches pl/pgsql's (rather dubious) historical behavior for assignment coercions. That's getting away from the original idea of pl/pgsql as an arm's-length extension of the core, but really we crossed that bridge a long time ago. The main advantage of doing this is that we can now use the core parser to generate FieldStore and/or SubscriptingRef nodes to handle assignments to pl/pgsql variables that are records or arrays. That fixes a number of cases that had never been implemented in pl/pgsql assignment, such as nested records and array slicing, and it allows pl/pgsql assignment to support the datatype-specific subscripting behaviors introduced in commit c7aba7c14. There are cosmetic benefits too: when a syntax error occurs in a pl/pgsql expression, the error report no longer includes the confusing "SELECT" keyword that used to get prefixed to the expression text. Also, there seem to be some small speed gains. Discussion: https://postgr.es/m/4165684.1607707277@sss.pgh.pa.us
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/plpgsql.out36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index d55006d8c95..0c6c9ba1f59 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -1761,10 +1761,10 @@ select f1(42) as int, f1(4.5) as num;
select f1(point(3,4)); -- fail for lack of + operator
ERROR: operator does not exist: point + integer
-LINE 1: SELECT x + 1
- ^
+LINE 1: x + 1
+ ^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
-QUERY: SELECT x + 1
+QUERY: x + 1
CONTEXT: PL/pgSQL function f1(anyelement) line 3 at RETURN
drop function f1(x anyelement);
create function f1(x anyelement) returns anyarray as $$
@@ -2361,7 +2361,7 @@ begin
end $$ language plpgsql;
select namedparmcursor_test7();
ERROR: division by zero
-CONTEXT: SQL statement "SELECT 42/0 AS p1, 77 AS p2;"
+CONTEXT: SQL expression "42/0 AS p1, 77 AS p2"
PL/pgSQL function namedparmcursor_test7() line 6 at OPEN
-- check that line comments work correctly within the argument list (there
-- is some special handling of this case in the code: the newline after the
@@ -2574,9 +2574,9 @@ end; $$ language plpgsql;
-- blocks
select excpt_test1();
ERROR: column "sqlstate" does not exist
-LINE 1: SELECT sqlstate
- ^
-QUERY: SELECT sqlstate
+LINE 1: sqlstate
+ ^
+QUERY: sqlstate
CONTEXT: PL/pgSQL function excpt_test1() line 3 at RAISE
create function excpt_test2() returns void as $$
begin
@@ -2589,9 +2589,9 @@ end; $$ language plpgsql;
-- should fail
select excpt_test2();
ERROR: column "sqlstate" does not exist
-LINE 1: SELECT sqlstate
- ^
-QUERY: SELECT sqlstate
+LINE 1: sqlstate
+ ^
+QUERY: sqlstate
CONTEXT: PL/pgSQL function excpt_test2() line 5 at RAISE
create function excpt_test3() returns void as $$
begin
@@ -4467,11 +4467,11 @@ end
$$;
select fail();
ERROR: division by zero
-CONTEXT: SQL statement "SELECT 1/0"
+CONTEXT: SQL expression "1/0"
PL/pgSQL function fail() line 3 at RETURN
select fail();
ERROR: division by zero
-CONTEXT: SQL statement "SELECT 1/0"
+CONTEXT: SQL expression "1/0"
PL/pgSQL function fail() line 3 at RETURN
drop function fail();
-- Test handling of string literals.
@@ -4497,10 +4497,10 @@ HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
select strtest();
NOTICE: foo\bar!baz
WARNING: nonstandard use of \\ in a string literal
-LINE 1: SELECT 'foo\\bar\041baz'
- ^
+LINE 1: 'foo\\bar\041baz'
+ ^
HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
-QUERY: SELECT 'foo\\bar\041baz'
+QUERY: 'foo\\bar\041baz'
strtest
-------------
foo\bar!baz
@@ -5621,9 +5621,9 @@ ALTER TABLE alter_table_under_transition_tables
UPDATE alter_table_under_transition_tables
SET id = id;
ERROR: column "name" does not exist
-LINE 1: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d)
- ^
-QUERY: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d)
+LINE 1: (SELECT string_agg(id || '=' || name, ',') FROM d)
+ ^
+QUERY: (SELECT string_agg(id || '=' || name, ',') FROM d)
CONTEXT: PL/pgSQL function alter_table_under_transition_tables_upd_func() line 3 at RAISE
--
-- Test multiple reference to a transition table