diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
| commit | 20ab467d76d78271006818d2baf4c9c8658d1f38 (patch) | |
| tree | 7a536111b5cc4e494ac75558aad5655dfc8ab964 /src/test | |
| parent | 48fb696753e267447f99914c7968d0b4ffb5c5dc (diff) | |
| download | postgresql-20ab467d76d78271006818d2baf4c9c8658d1f38.tar.gz | |
Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages.
This is per my earlier proposal. This commit includes all the basic
infrastructure, but locations are only tracked and reported for errors
involving column references, function calls, and operators. More could
be done later but this seems like a good set to start with. I've also
moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
which should make it available to more people --- even within psql this
is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
Diffstat (limited to 'src/test')
24 files changed, 213 insertions, 77 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 02723d62ec..6655e8b6d1 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -616,12 +616,20 @@ select * from atacc1; select * from atacc1 order by a; ERROR: column "a" does not exist +LINE 1: select * from atacc1 order by a; + ^ select * from atacc1 order by "........pg.dropped.1........"; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: select * from atacc1 order by "........pg.dropped.1........"... + ^ select * from atacc1 group by a; ERROR: column "a" does not exist +LINE 1: select * from atacc1 group by a; + ^ select * from atacc1 group by "........pg.dropped.1........"; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: select * from atacc1 group by "........pg.dropped.1........"... + ^ select atacc1.* from atacc1; b | c | d ---+---+--- @@ -630,8 +638,12 @@ select atacc1.* from atacc1; select a from atacc1; ERROR: column "a" does not exist +LINE 1: select a from atacc1; + ^ select atacc1.a from atacc1; ERROR: column atacc1.a does not exist +LINE 1: select atacc1.a from atacc1; + ^ select b,c,d from atacc1; b | c | d ---+---+--- @@ -640,25 +652,41 @@ select b,c,d from atacc1; select a,b,c,d from atacc1; ERROR: column "a" does not exist +LINE 1: select a,b,c,d from atacc1; + ^ select * from atacc1 where a = 1; ERROR: column "a" does not exist +LINE 1: select * from atacc1 where a = 1; + ^ select "........pg.dropped.1........" from atacc1; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: select "........pg.dropped.1........" from atacc1; + ^ select atacc1."........pg.dropped.1........" from atacc1; ERROR: column atacc1.........pg.dropped.1........ does not exist +LINE 1: select atacc1."........pg.dropped.1........" from atacc1; + ^ select "........pg.dropped.1........",b,c,d from atacc1; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: select "........pg.dropped.1........",b,c,d from atacc1; + ^ select * from atacc1 where "........pg.dropped.1........" = 1; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: select * from atacc1 where "........pg.dropped.1........" = ... + ^ -- UPDATEs update atacc1 set a = 3; ERROR: column "a" of relation "atacc1" does not exist update atacc1 set b = 2 where a = 3; ERROR: column "a" does not exist +LINE 1: update atacc1 set b = 2 where a = 3; + ^ update atacc1 set "........pg.dropped.1........" = 3; ERROR: column "........pg.dropped.1........" of relation "atacc1" does not exist update atacc1 set b = 2 where "........pg.dropped.1........" = 3; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: update atacc1 set b = 2 where "........pg.dropped.1........"... + ^ -- INSERTs insert into atacc1 values (10, 11, 12, 13); ERROR: INSERT has more expressions than target columns @@ -685,8 +713,12 @@ ERROR: column "........pg.dropped.1........" of relation "atacc1" does not exis -- DELETEs delete from atacc1 where a = 3; ERROR: column "a" does not exist +LINE 1: delete from atacc1 where a = 3; + ^ delete from atacc1 where "........pg.dropped.1........" = 3; ERROR: column "........pg.dropped.1........" does not exist +LINE 1: delete from atacc1 where "........pg.dropped.1........" = 3; + ^ delete from atacc1; -- try dropping a non-existent column, should fail alter table atacc1 drop bar; @@ -926,6 +958,8 @@ select f1 from c1; alter table c1 drop column f1; select f1 from c1; ERROR: column "f1" does not exist +LINE 1: select f1 from c1; + ^ drop table p1 cascade; NOTICE: drop cascades to table c1 create table p1 (f1 int, f2 int); @@ -937,6 +971,8 @@ alter table p1 drop column f1; -- c1.f1 is dropped now, since there is no local definition for it select f1 from c1; ERROR: column "f1" does not exist +LINE 1: select f1 from c1; + ^ drop table p1 cascade; NOTICE: drop cascades to table c1 create table p1 (f1 int, f2 int); @@ -1035,6 +1071,8 @@ select oid > 0, * from altstartwith; alter table altstartwith set without oids; select oid > 0, * from altstartwith; -- fails ERROR: column "oid" does not exist +LINE 1: select oid > 0, * from altstartwith; + ^ select * from altstartwith; col ----- @@ -1062,8 +1100,12 @@ alter table altwithoid set without oids; alter table altinhoid set without oids; select oid > 0, * from altwithoid; -- fails ERROR: column "oid" does not exist +LINE 1: select oid > 0, * from altwithoid; + ^ select oid > 0, * from altinhoid; -- fails ERROR: column "oid" does not exist +LINE 1: select oid > 0, * from altinhoid; + ^ select * from altwithoid; col ----- diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index 11b83ea993..17d073d37c 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -393,8 +393,12 @@ select 33.4 > all (array[1,2,3]); -- errors select 33 * any ('{1,2,3}'); ERROR: op ANY/ALL (array) requires operator to yield boolean +LINE 1: select 33 * any ('{1,2,3}'); + ^ select 33 * any (44); ERROR: op ANY/ALL (array) requires array on right side +LINE 1: select 33 * any (44); + ^ -- nulls select 33 = any (null::int[]); ?column? diff --git a/src/test/regress/expected/errors.out b/src/test/regress/expected/errors.out index 5e323c7e2c..8c97e4106b 100644 --- a/src/test/regress/expected/errors.out +++ b/src/test/regress/expected/errors.out @@ -19,7 +19,7 @@ select 1; -- missing relation name select; -ERROR: syntax error at or near ";" at character 7 +ERROR: syntax error at or near ";" LINE 1: select; ^ -- no such relation @@ -27,32 +27,40 @@ select * from nonesuch; ERROR: relation "nonesuch" does not exist -- missing target list select from pg_database; -ERROR: syntax error at or near "from" at character 8 +ERROR: syntax error at or near "from" LINE 1: select from pg_database; ^ -- bad name in target list select nonesuch from pg_database; ERROR: column "nonesuch" does not exist +LINE 1: select nonesuch from pg_database; + ^ -- bad attribute name on lhs of operator select * from pg_database where nonesuch = pg_database.datname; ERROR: column "nonesuch" does not exist +LINE 1: select * from pg_database where nonesuch = pg_database.datna... + ^ -- bad attribute name on rhs of operator select * from pg_database where pg_database.datname = nonesuch; ERROR: column "nonesuch" does not exist +LINE 1: ...ect * from pg_database where pg_database.datname = nonesuch; + ^ -- bad select distinct on syntax, distinct attribute missing select distinct on (foobar) from pg_database; -ERROR: syntax error at or near "from" at character 29 +ERROR: syntax error at or near "from" LINE 1: select distinct on (foobar) from pg_database; ^ -- bad select distinct on syntax, distinct attribute not in target list select distinct on (foobar) * from pg_database; ERROR: column "foobar" does not exist +LINE 1: select distinct on (foobar) * from pg_database; + ^ -- -- DELETE -- missing relation name (this had better not wildcard!) delete from; -ERROR: syntax error at or near ";" at character 12 +ERROR: syntax error at or near ";" LINE 1: delete from; ^ -- no such relation @@ -63,7 +71,7 @@ ERROR: relation "nonesuch" does not exist -- missing relation name (this had better not wildcard!) drop table; -ERROR: syntax error at or near ";" at character 11 +ERROR: syntax error at or near ";" LINE 1: drop table; ^ -- no such relation @@ -75,7 +83,7 @@ ERROR: table "nonesuch" does not exist -- relation renaming -- missing relation name alter table rename; -ERROR: syntax error at or near ";" at character 19 +ERROR: syntax error at or near ";" LINE 1: alter table rename; ^ -- no such relation @@ -131,12 +139,12 @@ ERROR: aggregate basetype must be specified -- missing index name drop index; -ERROR: syntax error at or near ";" at character 11 +ERROR: syntax error at or near ";" LINE 1: drop index; ^ -- bad index name drop index 314159; -ERROR: syntax error at or near "314159" at character 12 +ERROR: syntax error at or near "314159" LINE 1: drop index 314159; ^ -- no such index @@ -147,17 +155,17 @@ ERROR: index "nonesuch" does not exist -- missing aggregate name drop aggregate; -ERROR: syntax error at or near ";" at character 15 +ERROR: syntax error at or near ";" LINE 1: drop aggregate; ^ -- missing aggregate type drop aggregate newcnt1; -ERROR: syntax error at or near ";" at character 23 +ERROR: syntax error at or near ";" LINE 1: drop aggregate newcnt1; ^ -- bad aggregate name drop aggregate 314159 (int); -ERROR: syntax error at or near "314159" at character 16 +ERROR: syntax error at or near "314159" LINE 1: drop aggregate 314159 (int); ^ -- bad aggregate type @@ -174,12 +182,12 @@ ERROR: aggregate newcnt(real) does not exist -- missing function name drop function (); -ERROR: syntax error at or near "(" at character 15 +ERROR: syntax error at or near "(" LINE 1: drop function (); ^ -- bad function name drop function 314159(); -ERROR: syntax error at or near "314159" at character 15 +ERROR: syntax error at or near "314159" LINE 1: drop function 314159(); ^ -- no such function @@ -190,12 +198,12 @@ ERROR: function nonesuch() does not exist -- missing type name drop type; -ERROR: syntax error at or near ";" at character 10 +ERROR: syntax error at or near ";" LINE 1: drop type; ^ -- bad type name drop type 314159; -ERROR: syntax error at or near "314159" at character 11 +ERROR: syntax error at or near "314159" LINE 1: drop type 314159; ^ -- no such type @@ -206,32 +214,32 @@ ERROR: type "nonesuch" does not exist -- missing everything drop operator; -ERROR: syntax error at or near ";" at character 14 +ERROR: syntax error at or near ";" LINE 1: drop operator; ^ -- bad operator name drop operator equals; -ERROR: syntax error at or near ";" at character 21 +ERROR: syntax error at or near ";" LINE 1: drop operator equals; ^ -- missing type list drop operator ===; -ERROR: syntax error at or near ";" at character 18 +ERROR: syntax error at or near ";" LINE 1: drop operator ===; ^ -- missing parentheses drop operator int4, int4; -ERROR: syntax error at or near "," at character 19 +ERROR: syntax error at or near "," LINE 1: drop operator int4, int4; ^ -- missing operator name drop operator (int4, int4); -ERROR: syntax error at or near "(" at character 15 +ERROR: syntax error at or near "(" LINE 1: drop operator (int4, int4); ^ -- missing type list contents drop operator === (); -ERROR: syntax error at or near ")" at character 20 +ERROR: syntax error at or near ")" LINE 1: drop operator === (); ^ -- no such operator @@ -247,18 +255,18 @@ ERROR: missing argument HINT: Use NONE to denote the missing argument of a unary operator. -- no such type1 drop operator = ( , int4); -ERROR: syntax error at or near "," at character 19 +ERROR: syntax error at or near "," LINE 1: drop operator = ( , int4); ^ -- no such type1 drop operator = (nonesuch, int4); -ERROR: type nonesuch does not exist +ERROR: type "nonesuch" does not exist -- no such type2 drop operator = (int4, nonesuch); -ERROR: type nonesuch does not exist +ERROR: type "nonesuch" does not exist -- no such type2 drop operator = (int4, ); -ERROR: syntax error at or near ")" at character 24 +ERROR: syntax error at or near ")" LINE 1: drop operator = (int4, ); ^ -- @@ -266,12 +274,12 @@ LINE 1: drop operator = (int4, ); -- missing rule name drop rule; -ERROR: syntax error at or near ";" at character 10 +ERROR: syntax error at or near ";" LINE 1: drop rule; ^ -- bad rule name drop rule 314159; -ERROR: syntax error at or near "314159" at character 11 +ERROR: syntax error at or near "314159" LINE 1: drop rule 314159; ^ -- no such rule @@ -279,15 +287,15 @@ drop rule nonesuch on noplace; ERROR: relation "noplace" does not exist -- these postquel variants are no longer supported drop tuple rule nonesuch; -ERROR: syntax error at or near "tuple" at character 6 +ERROR: syntax error at or near "tuple" LINE 1: drop tuple rule nonesuch; ^ drop instance rule nonesuch on noplace; -ERROR: syntax error at or near "instance" at character 6 +ERROR: syntax error at or near "instance" LINE 1: drop instance rule nonesuch on noplace; ^ drop rewrite rule nonesuch; -ERROR: syntax error at or near "rewrite" at character 6 +ERROR: syntax error at or near "rewrite" LINE 1: drop rewrite rule nonesuch; ^ -- @@ -319,35 +327,35 @@ ERROR: division by zero -- Test psql's reporting of syntax error location -- xxx; -ERROR: syntax error at or near "xxx" at character 1 +ERROR: syntax error at or near "xxx" LINE 1: xxx; ^ CREATE foo; -ERROR: syntax error at or near "foo" at character 8 +ERROR: syntax error at or near "foo" LINE 1: CREATE foo; ^ CREATE TABLE ; -ERROR: syntax error at or near ";" at character 14 +ERROR: syntax error at or near ";" LINE 1: CREATE TABLE ; ^ CREATE TABLE \g -ERROR: syntax error at end of input at character 13 +ERROR: syntax error at end of input LINE 1: CREATE TABLE ^ INSERT INTO foo VALUES(123) foo; -ERROR: syntax error at or near "foo" at character 29 +ERROR: syntax error at or near "foo" LINE 1: INSERT INTO foo VALUES(123) foo; ^ INSERT INTO 123 VALUES(123); -ERROR: syntax error at or near "123" at character 13 +ERROR: syntax error at or near "123" LINE 1: INSERT INTO 123 ^ INSERT INTO foo VALUES(123) 123 ; -ERROR: syntax error at or near "123" at character 30 +ERROR: syntax error at or near "123" LINE 2: VALUES(123) 123 ^ -- with a tab @@ -355,24 +363,24 @@ CREATE TABLE foo (id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL); -ERROR: syntax error at or near "NUL" at character 94 +ERROR: syntax error at or near "NUL" LINE 3: id3 INTEGER NOT NUL, ^ -- long line to be truncated on the left CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL); -ERROR: syntax error at or near "NUL" at character 90 +ERROR: syntax error at or near "NUL" LINE 1: ...T NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, ^ -- long line to be truncated on the right CREATE TABLE foo( id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY); -ERROR: syntax error at or near "NUL" at character 35 +ERROR: syntax error at or near "NUL" LINE 2: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ... ^ -- long line to be truncated both ways CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL); -ERROR: syntax error at or near "NUL" at character 90 +ERROR: syntax error at or near "NUL" LINE 1: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I... ^ -- long line to be truncated on the left, many lines @@ -389,7 +397,7 @@ UNIQUE NOT NULL) ; -ERROR: syntax error at or near "NUL" at character 101 +ERROR: syntax error at or near "NUL" LINE 4: ...T NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, ^ -- long line to be truncated on the right, many lines @@ -399,7 +407,7 @@ TABLE foo( id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY) ; -ERROR: syntax error at or near "NUL" at character 47 +ERROR: syntax error at or near "NUL" LINE 5: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ... ^ -- long line to be truncated both ways, many lines @@ -412,7 +420,7 @@ INT4 UNIQUE NOT NULL, idx INT4 UNIQUE NOT NULL, idy INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, idz INT4 UNIQUE NOT NULL, idv INT4 UNIQUE NOT NULL); -ERROR: syntax error at or near "NUL" at character 157 +ERROR: syntax error at or near "NUL" LINE 7: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I... ^ -- more than 10 lines... @@ -438,7 +446,7 @@ INT4 UNIQUE NOT NULL); -ERROR: syntax error at or near "NUL" at character 190 +ERROR: syntax error at or near "NUL" LINE 16: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I... ^ -- Check that stack depth detection mechanism works and diff --git a/src/test/regress/expected/geometry.out b/src/test/regress/expected/geometry.out index bdb4aa5477..ef8f4ec793 100644 --- a/src/test/regress/expected/geometry.out +++ b/src/test/regress/expected/geometry.out @@ -105,6 +105,8 @@ SELECT '' AS one, p1.f1 SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection FROM LSEG_TBL l, POINT_TBL p; ERROR: operator does not exist: lseg # point +LINE 1: SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection + ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. -- closest point SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest diff --git a/src/test/regress/expected/geometry_1.out b/src/test/regress/expected/geometry_1.out index 2a61b34a7a..a60b91301a 100644 --- a/src/test/regress/expected/geometry_1.out +++ b/src/test/regress/expected/geometry_1.out @@ -105,6 +105,8 @@ SELECT '' AS one, p1.f1 SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection FROM LSEG_TBL l, POINT_TBL p; ERROR: operator does not exist: lseg # point +LINE 1: SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection + ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. -- closest point SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest diff --git a/src/test/regress/expected/geometry_2.out b/src/test/regress/expected/geometry_2.out index af3ee40840..3b864ffe77 100644 --- a/src/test/regress/expected/geometry_2.out +++ b/src/test/regress/expected/geometry_2.out @@ -105,6 +105,8 @@ SELECT '' AS one, p1.f1 SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection FROM LSEG_TBL l, POINT_TBL p; ERROR: operator does not exist: lseg # point +LINE 1: SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection + ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. -- closest point SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out index 392d1feedd..ea22c44386 100644 --- a/src/test/regress/expected/horology.out +++ b/src/test/regress/expected/horology.out @@ -306,6 +306,8 @@ SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time"; SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC"; ERROR: operator does not exist: date - time with time zone +LINE 1: SELECT date '1991-02-03' - time with time zone '04:05:06 UTC... + ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. -- -- timestamp, interval arithmetic diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 0a7c5605cd..b110f08130 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -337,6 +337,8 @@ SELECT '' AS "xxx", * SELECT '' AS "xxx", i, k, t FROM J1_TBL CROSS JOIN J2_TBL; ERROR: column reference "i" is ambiguous +LINE 1: SELECT '' AS "xxx", i, k, t + ^ -- resolve previous ambiguity by specifying the table name SELECT '' AS "xxx", t1.i, k, t FROM J1_TBL t1 CROSS JOIN J2_TBL t2; diff --git a/src/test/regress/expected/join_1.out b/src/test/regress/expected/join_1.out index 289ccb6c9f..172d6d6fe8 100644 --- a/src/test/regress/expected/join_1.out +++ b/src/test/regress/expected/join_1.out @@ -337,6 +337,8 @@ SELECT '' AS "xxx", * SELECT '' AS "xxx", i, k, t FROM J1_TBL CROSS JOIN J2_TBL; ERROR: column reference "i" is ambiguous +LINE 1: SELECT '' AS "xxx", i, k, t + ^ -- resolve previous ambiguity by specifying the table name SELECT '' AS "xxx", t1.i, k, t FROM J1_TBL t1 CROSS JOIN J2_TBL t2; diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 5617b6ef01..e72383bbb7 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -1747,7 +1747,7 @@ create function f1(in i int, out j int) returns int as $$ begin return i+1; end$$ language plpgsql; -ERROR: RETURN cannot have a parameter in function with OUT parameters at or near "i" at character 74 +ERROR: RETURN cannot have a parameter in function with OUT parameters at or near "i" LINE 3: return i+1; ^ create function f1(in i int, out j int) as $$ @@ -2323,11 +2323,11 @@ begin a := 10; return a; end$$ language plpgsql; -ERROR: syntax error at or near "Johnny" at character 1 -QUERY: Johnny Yuma -CONTEXT: SQL statement in PL/PgSQL function "bad_sql1" near line 4 +ERROR: syntax error at or near "Johnny" LINE 1: Johnny Yuma ^ +QUERY: Johnny Yuma +CONTEXT: SQL statement in PL/PgSQL function "bad_sql1" near line 4 create function bad_sql2() returns int as $$ declare r record; begin @@ -2336,27 +2336,27 @@ begin end loop; return 5; end;$$ language plpgsql; -ERROR: syntax error at or near "fought" at character 11 -QUERY: select I fought the law, the law won -CONTEXT: SQL statement in PL/PgSQL function "bad_sql2" near line 3 +ERROR: syntax error at or near "fought" LINE 1: select I fought the law, the law won ^ +QUERY: select I fought the law, the law won +CONTEXT: SQL statement in PL/PgSQL function "bad_sql2" near line 3 -- a RETURN expression is mandatory, except for void-returning -- functions, where it is not allowed create function missing_return_expr() returns int as $$ begin return ; end;$$ language plpgsql; -ERROR: syntax error at end of input at character 8 -QUERY: SELECT -CONTEXT: SQL statement in PL/PgSQL function "missing_return_expr" near line 2 +ERROR: syntax error at end of input LINE 1: SELECT ^ +QUERY: SELECT +CONTEXT: SQL statement in PL/PgSQL function "missing_return_expr" near line 2 create function void_return_expr() returns void as $$ begin return 5; end;$$ language plpgsql; -ERROR: RETURN cannot have a parameter in function returning void at or near "5" at character 72 +ERROR: RETURN cannot have a parameter in function returning void at or near "5" LINE 3: return 5; ^ -- VOID functions are allowed to omit RETURN @@ -2426,8 +2426,10 @@ end; $$ language plpgsql; -- blocks select excpt_test1(); ERROR: column "sqlstate" does not exist -CONTEXT: SQL statement "SELECT sqlstate" -PL/pgSQL function "excpt_test1" line 2 at raise +LINE 1: SELECT sqlstate + ^ +QUERY: SELECT sqlstate +CONTEXT: PL/pgSQL function "excpt_test1" line 2 at raise create function excpt_test2() returns void as $$ begin begin @@ -2439,8 +2441,10 @@ end; $$ language plpgsql; -- should fail select excpt_test2(); ERROR: column "sqlstate" does not exist -CONTEXT: SQL statement "SELECT sqlstate" -PL/pgSQL function "excpt_test2" line 4 at raise +LINE 1: SELECT sqlstate + ^ +QUERY: SELECT sqlstate +CONTEXT: PL/pgSQL function "excpt_test2" line 4 at raise create function excpt_test3() returns void as $$ begin begin @@ -2695,7 +2699,7 @@ begin end loop flbl1; end; $$ language plpgsql; -ERROR: no such label at or near "flbl1" at character 101 +ERROR: no such label at or near "flbl1" LINE 5: end loop flbl1; ^ -- should fail: end label does not match start label diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out index b2cb3c2f9a..902acba4c2 100644 --- a/src/test/regress/expected/prepare.out +++ b/src/test/regress/expected/prepare.out @@ -116,6 +116,8 @@ HINT: You will need to rewrite or cast the expression. -- invalid type PREPARE q4(nonexistenttype) AS SELECT $1; ERROR: type "nonexistenttype" does not exist +LINE 1: PREPARE q4(nonexistenttype) AS SELECT $1; + ^ -- create table as execute PREPARE q5(int, text) AS SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2; diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out index c6b1bfac39..5b4d9555ae 100644 --- a/src/test/regress/expected/rowtypes.out +++ b/src/test/regress/expected/rowtypes.out @@ -63,6 +63,8 @@ begin; set local add_missing_from = false; select f1, q.c1 from quadtable; -- fails, q is a table reference ERROR: missing FROM-clause entry for table "q" +LINE 1: select f1, q.c1 from quadtable; + ^ rollback; select f1, (q).c1, (qq.q).c1.i from quadtable qq; f1 | c1 | i @@ -199,6 +201,8 @@ select ROW('ABC','DEF') ~>=~ ROW('DEF','ABC') as false; select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail; ERROR: could not determine interpretation of row comparison operator ~~ +LINE 1: select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail; + ^ HINT: Row comparison operators must be associated with btree operator classes. -- Check row comparison with a subselect select unique1, unique2 from tenk1 diff --git a/src/test/regress/expected/select_implicit.out b/src/test/regress/expected/select_implicit.out index 4c8022d040..1ee7f9b735 100644 --- a/src/test/regress/expected/select_implicit.out +++ b/src/test/regress/expected/select_implicit.out @@ -121,6 +121,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b ORDER BY b; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b ORDER BY b; + ^ -- order w/ target under ambiguous condition -- failure NOT expected SELECT a, a FROM test_missing_target @@ -287,6 +289,8 @@ SELECT count(x.a) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b/2 ORDER BY b/2; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b/2 ORDER BY b/2; + ^ -- group w/ existing GROUP BY target under ambiguous condition SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a @@ -304,6 +308,8 @@ SELECT count(b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY x.b/2; ERROR: column reference "b" is ambiguous +LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar... + ^ -- group w/o existing GROUP BY target under ambiguous condition -- into a table SELECT count(x.b) INTO TABLE test_missing_target3 diff --git a/src/test/regress/expected/select_implicit_1.out b/src/test/regress/expected/select_implicit_1.out index 7e316ddbb7..85092ef046 100644 --- a/src/test/regress/expected/select_implicit_1.out +++ b/src/test/regress/expected/select_implicit_1.out @@ -121,6 +121,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b ORDER BY b; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b ORDER BY b; + ^ -- order w/ target under ambiguous condition -- failure NOT expected SELECT a, a FROM test_missing_target @@ -287,6 +289,8 @@ SELECT count(x.a) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b/2 ORDER BY b/2; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b/2 ORDER BY b/2; + ^ -- group w/ existing GROUP BY target under ambiguous condition SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a @@ -304,6 +308,8 @@ SELECT count(b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY x.b/2; ERROR: column reference "b" is ambiguous +LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar... + ^ -- group w/o existing GROUP BY target under ambiguous condition -- into a table SELECT count(x.b) INTO TABLE test_missing_target3 diff --git a/src/test/regress/expected/select_implicit_2.out b/src/test/regress/expected/select_implicit_2.out index b45197f2de..718eb09f05 100644 --- a/src/test/regress/expected/select_implicit_2.out +++ b/src/test/regress/expected/select_implicit_2.out @@ -121,6 +121,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b ORDER BY b; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b ORDER BY b; + ^ -- order w/ target under ambiguous condition -- failure NOT expected SELECT a, a FROM test_missing_target @@ -287,6 +289,8 @@ SELECT count(x.a) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY b/2 ORDER BY b/2; ERROR: column reference "b" is ambiguous +LINE 3: GROUP BY b/2 ORDER BY b/2; + ^ -- group w/ existing GROUP BY target under ambiguous condition SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a @@ -304,6 +308,8 @@ SELECT count(b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY x.b/2; ERROR: column reference "b" is ambiguous +LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar... + ^ -- group w/o existing GROUP BY target under ambiguous condition -- into a table SELECT count(x.b) INTO TABLE test_missing_target3 diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 6faf3c69ad..0c9b88ee8f 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -18,7 +18,7 @@ SELECT 'first line' ' - next line' /* this comment is not allowed here */ ' - third line' AS "Illegal comment within continuation"; -ERROR: syntax error at or near "' - third line'" at character 75 +ERROR: syntax error at or near "' - third line'" LINE 3: ' - third line' ^ -- @@ -927,17 +927,29 @@ show standard_conforming_strings; (1 row) select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; -WARNING: nonstandard use of escape in a string literal at character 8 +WARNING: nonstandard use of escape in a string literal +LINE 1: select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'a... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -WARNING: nonstandard use of escape in a string literal at character 23 +WARNING: nonstandard use of escape in a string literal +LINE 1: select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'a... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -WARNING: nonstandard use of escape in a string literal at character 40 +WARNING: nonstandard use of escape in a string literal +LINE 1: select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'a... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -WARNING: nonstandard use of escape in a string literal at character 59 +WARNING: nonstandard use of escape in a string literal +LINE 1: ...a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' ... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -WARNING: nonstandard use of escape in a string literal at character 76 +WARNING: nonstandard use of escape in a string literal +LINE 1: ...b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' ... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -WARNING: nonstandard use of escape in a string literal at character 93 +WARNING: nonstandard use of escape in a string literal +LINE 1: ...b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6... + ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- @@ -946,17 +958,29 @@ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. set standard_conforming_strings = off; select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; -WARNING: nonstandard use of \\ in a string literal at character 8 +WARNING: nonstandard use of \\ in a string literal +LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. -WARNING: nonstandard use of \\ in a string literal at character 24 +WARNING: nonstandard use of \\ in a string literal +LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. -WARNING: nonstandard use of \\ in a string literal at character 42 +WARNING: nonstandard use of \\ in a string literal +LINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. -WARNING: nonstandard use of \\ in a string literal at character 62 +WARNING: nonstandard use of \\ in a string literal +LINE 1: ...bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' ... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. -WARNING: nonstandard use of \\ in a string literal at character 80 +WARNING: nonstandard use of \\ in a string literal +LINE 1: ...'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd'... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. -WARNING: nonstandard use of \\ in a string literal at character 98 +WARNING: nonstandard use of \\ in a string literal +LINE 1: ...'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as ... + ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- diff --git a/src/test/regress/expected/time.out b/src/test/regress/expected/time.out index a562c29691..f85dcdbd7a 100644 --- a/src/test/regress/expected/time.out +++ b/src/test/regress/expected/time.out @@ -70,4 +70,6 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00'; -- where we do mixed-type arithmetic. - thomas 2000-12-02 SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL; ERROR: operator is not unique: time without time zone + time without time zone +LINE 1: SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL; + ^ HINT: Could not choose a best candidate operator. You may need to add explicit type casts. diff --git a/src/test/regress/expected/timetz.out b/src/test/regress/expected/timetz.out index 20a394a79a..cd330635af 100644 --- a/src/test/regress/expected/timetz.out +++ b/src/test/regress/expected/timetz.out @@ -77,4 +77,6 @@ SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00-07'; -- where we do mixed-type arithmetic. - thomas 2000-12-02 SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL; ERROR: operator does not exist: time with time zone + time with time zone +LINE 1: SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TI... + ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out index 047bba8f70..8d3be84d63 100644 --- a/src/test/regress/expected/transactions.out +++ b/src/test/regress/expected/transactions.out @@ -140,6 +140,8 @@ BEGIN; SAVEPOINT one; SELECT foo; ERROR: column "foo" does not exist +LINE 1: SELECT foo; + ^ ROLLBACK TO SAVEPOINT one; RELEASE SAVEPOINT one; SAVEPOINT two; @@ -188,6 +190,8 @@ BEGIN; INSERT INTO savepoints VALUES (5); SELECT foo; ERROR: column "foo" does not exist +LINE 1: SELECT foo; + ^ COMMIT; SELECT * FROM savepoints; a diff --git a/src/test/regress/expected/union.out b/src/test/regress/expected/union.out index d09d9a8164..abcbc9503a 100644 --- a/src/test/regress/expected/union.out +++ b/src/test/regress/expected/union.out @@ -405,6 +405,8 @@ ORDER BY q2,q1; -- This should fail, because q2 isn't a name of an EXCEPT output column SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1; ERROR: column "q2" does not exist +LINE 1: ... int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1... + ^ -- But this should work: SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))); q1 diff --git a/src/test/regress/expected/update.out b/src/test/regress/expected/update.out index 1ff7c8918f..9849e90539 100644 --- a/src/test/regress/expected/update.out +++ b/src/test/regress/expected/update.out @@ -45,6 +45,8 @@ BEGIN; SET LOCAL add_missing_from = false; UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10; ERROR: invalid reference to FROM-clause entry for table "update_test" +LINE 1: UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a... + ^ HINT: Perhaps you meant to reference the table alias "t". ROLLBACK; DROP TABLE update_test; diff --git a/src/test/regress/expected/without_oid.out b/src/test/regress/expected/without_oid.out index 5e46aa8ebe..c32daf815d 100644 --- a/src/test/regress/expected/without_oid.out +++ b/src/test/regress/expected/without_oid.out @@ -43,6 +43,8 @@ SELECT count(oid) FROM wi; -- should fail SELECT count(oid) FROM wo; ERROR: column "oid" does not exist +LINE 1: SELECT count(oid) FROM wo; + ^ VACUUM ANALYZE wi; VACUUM ANALYZE wo; SELECT min(relpages) < max(relpages), min(reltuples) - max(reltuples) @@ -76,6 +78,8 @@ SELECT count(oid) FROM create_table_test2; -- should fail SELECT count(oid) FROM create_table_test3; ERROR: column "oid" does not exist +LINE 1: SELECT count(oid) FROM create_table_test3; + ^ PREPARE table_source(int) AS SELECT a + b AS c1, a - b AS c2, $1 AS c3 FROM create_table_test; CREATE TABLE execute_with WITH OIDS AS EXECUTE table_source(1); @@ -89,6 +93,8 @@ SELECT count(oid) FROM execute_with; -- should fail SELECT count(oid) FROM execute_without; ERROR: column "oid" does not exist +LINE 1: SELECT count(oid) FROM execute_without; + ^ DROP TABLE create_table_test; DROP TABLE create_table_test2; DROP TABLE create_table_test3; diff --git a/src/test/regress/output/constraints.source b/src/test/regress/output/constraints.source index 5ba46c062f..e40c445014 100644 --- a/src/test/regress/output/constraints.source +++ b/src/test/regress/output/constraints.source @@ -45,14 +45,14 @@ SELECT '' AS four, * FROM DEFAULTEXPR_TBL; -- syntax errors -- test for extraneous comma CREATE TABLE error_tbl (i int DEFAULT (100, )); -ERROR: syntax error at or near ")" at character 45 +ERROR: syntax error at or near ")" LINE 1: CREATE TABLE error_tbl (i int DEFAULT (100, )); ^ -- this will fail because gram.y uses b_expr not a_expr for defaults, -- to avoid a shift/reduce conflict that arises from NOT NULL being -- part of the column definition syntax: CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)); -ERROR: syntax error at or near "IN" at character 43 +ERROR: syntax error at or near "IN" LINE 1: CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)); ^ -- this should work, however: diff --git a/src/test/regress/output/create_function_1.source b/src/test/regress/output/create_function_1.source index a3c506598f..e7fd46130f 100644 --- a/src/test/regress/output/create_function_1.source +++ b/src/test/regress/output/create_function_1.source @@ -55,7 +55,7 @@ DETAIL: Actual return type is "unknown". CONTEXT: SQL function "test1" CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL AS 'not even SQL'; -ERROR: syntax error at or near "not" at character 62 +ERROR: syntax error at or near "not" LINE 2: AS 'not even SQL'; ^ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL |
