1--
2-- ERRORS
3--
4-- bad in postquel, but ok in PostgreSQL
5select 1;
6 ?column?
7----------
8        1
9(1 row)
10
11--
12-- UNSUPPORTED STUFF
13-- doesn't work
14-- notify pg_class
15--
16--
17-- SELECT
18-- this used to be a syntax error, but now we allow an empty target list
19select;
20--
21(1 row)
22
23-- no such relation
24select * from nonesuch;
25ERROR:  relation "nonesuch" does not exist
26LINE 1: select * from nonesuch;
27                      ^
28-- bad name in target list
29select nonesuch from pg_database;
30ERROR:  column "nonesuch" does not exist
31LINE 1: select nonesuch from pg_database;
32               ^
33-- empty distinct list isn't OK
34select distinct from pg_database;
35ERROR:  syntax error at or near "from"
36LINE 1: select distinct from pg_database;
37                        ^
38-- bad attribute name on lhs of operator
39select * from pg_database where nonesuch = pg_database.datname;
40ERROR:  column "nonesuch" does not exist
41LINE 1: select * from pg_database where nonesuch = pg_database.datna...
42                                        ^
43-- bad attribute name on rhs of operator
44select * from pg_database where pg_database.datname = nonesuch;
45ERROR:  column "nonesuch" does not exist
46LINE 1: ...ect * from pg_database where pg_database.datname = nonesuch;
47                                                              ^
48-- bad attribute name in select distinct on
49select distinct on (foobar) * from pg_database;
50ERROR:  column "foobar" does not exist
51LINE 1: select distinct on (foobar) * from pg_database;
52                            ^
53-- grouping with FOR UPDATE
54select null from pg_database group by datname for update;
55ERROR:  FOR UPDATE is not allowed with GROUP BY clause
56select null from pg_database group by grouping sets (()) for update;
57ERROR:  FOR UPDATE is not allowed with GROUP BY clause
58--
59-- DELETE
60-- missing relation name (this had better not wildcard!)
61delete from;
62ERROR:  syntax error at or near ";"
63LINE 1: delete from;
64                   ^
65-- no such relation
66delete from nonesuch;
67ERROR:  relation "nonesuch" does not exist
68LINE 1: delete from nonesuch;
69                    ^
70--
71-- DROP
72-- missing relation name (this had better not wildcard!)
73drop table;
74ERROR:  syntax error at or near ";"
75LINE 1: drop table;
76                  ^
77-- no such relation
78drop table nonesuch;
79ERROR:  table "nonesuch" does not exist
80--
81-- ALTER TABLE
82-- relation renaming
83-- missing relation name
84alter table rename;
85ERROR:  syntax error at or near ";"
86LINE 1: alter table rename;
87                          ^
88-- no such relation
89alter table nonesuch rename to newnonesuch;
90ERROR:  relation "nonesuch" does not exist
91-- no such relation
92alter table nonesuch rename to stud_emp;
93ERROR:  relation "nonesuch" does not exist
94-- conflict
95alter table stud_emp rename to aggtest;
96ERROR:  relation "aggtest" already exists
97-- self-conflict
98alter table stud_emp rename to stud_emp;
99ERROR:  relation "stud_emp" already exists
100-- attribute renaming
101-- no such relation
102alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
103ERROR:  relation "nonesuchrel" does not exist
104-- no such attribute
105alter table emp rename column nonesuchatt to newnonesuchatt;
106ERROR:  column "nonesuchatt" does not exist
107-- conflict
108alter table emp rename column salary to manager;
109ERROR:  column "manager" of relation "stud_emp" already exists
110-- conflict
111alter table emp rename column salary to oid;
112ERROR:  column name "oid" conflicts with a system column name
113--
114-- TRANSACTION STUFF
115-- not in a xact
116abort;
117WARNING:  there is no transaction in progress
118-- not in a xact
119end;
120WARNING:  there is no transaction in progress
121--
122-- CREATE AGGREGATE
123-- sfunc/finalfunc type disagreement
124create aggregate newavg2 (sfunc = int4pl,
125			  basetype = int4,
126			  stype = int4,
127			  finalfunc = int2um,
128			  initcond = '0');
129ERROR:  function int2um(integer) does not exist
130-- left out basetype
131create aggregate newcnt1 (sfunc = int4inc,
132			  stype = int4,
133			  initcond = '0');
134ERROR:  aggregate input type must be specified
135--
136-- DROP INDEX
137-- missing index name
138drop index;
139ERROR:  syntax error at or near ";"
140LINE 1: drop index;
141                  ^
142-- bad index name
143drop index 314159;
144ERROR:  syntax error at or near "314159"
145LINE 1: drop index 314159;
146                   ^
147-- no such index
148drop index nonesuch;
149ERROR:  index "nonesuch" does not exist
150--
151-- DROP AGGREGATE
152-- missing aggregate name
153drop aggregate;
154ERROR:  syntax error at or near ";"
155LINE 1: drop aggregate;
156                      ^
157-- missing aggregate type
158drop aggregate newcnt1;
159ERROR:  syntax error at or near ";"
160LINE 1: drop aggregate newcnt1;
161                              ^
162-- bad aggregate name
163drop aggregate 314159 (int);
164ERROR:  syntax error at or near "314159"
165LINE 1: drop aggregate 314159 (int);
166                       ^
167-- bad aggregate type
168drop aggregate newcnt (nonesuch);
169ERROR:  type "nonesuch" does not exist
170-- no such aggregate
171drop aggregate nonesuch (int4);
172ERROR:  aggregate nonesuch(integer) does not exist
173-- no such aggregate for type
174drop aggregate newcnt (float4);
175ERROR:  aggregate newcnt(real) does not exist
176--
177-- DROP FUNCTION
178-- missing function name
179drop function ();
180ERROR:  syntax error at or near "("
181LINE 1: drop function ();
182                      ^
183-- bad function name
184drop function 314159();
185ERROR:  syntax error at or near "314159"
186LINE 1: drop function 314159();
187                      ^
188-- no such function
189drop function nonesuch();
190ERROR:  function nonesuch() does not exist
191--
192-- DROP TYPE
193-- missing type name
194drop type;
195ERROR:  syntax error at or near ";"
196LINE 1: drop type;
197                 ^
198-- bad type name
199drop type 314159;
200ERROR:  syntax error at or near "314159"
201LINE 1: drop type 314159;
202                  ^
203-- no such type
204drop type nonesuch;
205ERROR:  type "nonesuch" does not exist
206--
207-- DROP OPERATOR
208-- missing everything
209drop operator;
210ERROR:  syntax error at or near ";"
211LINE 1: drop operator;
212                     ^
213-- bad operator name
214drop operator equals;
215ERROR:  syntax error at or near ";"
216LINE 1: drop operator equals;
217                            ^
218-- missing type list
219drop operator ===;
220ERROR:  syntax error at or near ";"
221LINE 1: drop operator ===;
222                         ^
223-- missing parentheses
224drop operator int4, int4;
225ERROR:  syntax error at or near ","
226LINE 1: drop operator int4, int4;
227                          ^
228-- missing operator name
229drop operator (int4, int4);
230ERROR:  syntax error at or near "("
231LINE 1: drop operator (int4, int4);
232                      ^
233-- missing type list contents
234drop operator === ();
235ERROR:  syntax error at or near ")"
236LINE 1: drop operator === ();
237                           ^
238-- no such operator
239drop operator === (int4);
240ERROR:  missing argument
241LINE 1: drop operator === (int4);
242                               ^
243HINT:  Use NONE to denote the missing argument of a unary operator.
244-- no such operator by that name
245drop operator === (int4, int4);
246ERROR:  operator does not exist: integer === integer
247-- no such type1
248drop operator = (nonesuch);
249ERROR:  missing argument
250LINE 1: drop operator = (nonesuch);
251                                 ^
252HINT:  Use NONE to denote the missing argument of a unary operator.
253-- no such type1
254drop operator = ( , int4);
255ERROR:  syntax error at or near ","
256LINE 1: drop operator = ( , int4);
257                          ^
258-- no such type1
259drop operator = (nonesuch, int4);
260ERROR:  type "nonesuch" does not exist
261-- no such type2
262drop operator = (int4, nonesuch);
263ERROR:  type "nonesuch" does not exist
264-- no such type2
265drop operator = (int4, );
266ERROR:  syntax error at or near ")"
267LINE 1: drop operator = (int4, );
268                               ^
269--
270-- DROP RULE
271-- missing rule name
272drop rule;
273ERROR:  syntax error at or near ";"
274LINE 1: drop rule;
275                 ^
276-- bad rule name
277drop rule 314159;
278ERROR:  syntax error at or near "314159"
279LINE 1: drop rule 314159;
280                  ^
281-- no such rule
282drop rule nonesuch on noplace;
283ERROR:  relation "noplace" does not exist
284-- these postquel variants are no longer supported
285drop tuple rule nonesuch;
286ERROR:  syntax error at or near "tuple"
287LINE 1: drop tuple rule nonesuch;
288             ^
289drop instance rule nonesuch on noplace;
290ERROR:  syntax error at or near "instance"
291LINE 1: drop instance rule nonesuch on noplace;
292             ^
293drop rewrite rule nonesuch;
294ERROR:  syntax error at or near "rewrite"
295LINE 1: drop rewrite rule nonesuch;
296             ^
297--
298-- Check that division-by-zero is properly caught.
299--
300select 1/0;
301ERROR:  division by zero
302select 1::int8/0;
303ERROR:  division by zero
304select 1/0::int8;
305ERROR:  division by zero
306select 1::int2/0;
307ERROR:  division by zero
308select 1/0::int2;
309ERROR:  division by zero
310select 1::numeric/0;
311ERROR:  division by zero
312select 1/0::numeric;
313ERROR:  division by zero
314select 1::float8/0;
315ERROR:  division by zero
316select 1/0::float8;
317ERROR:  division by zero
318select 1::float4/0;
319ERROR:  division by zero
320select 1/0::float4;
321ERROR:  division by zero
322--
323-- Test psql's reporting of syntax error location
324--
325xxx;
326ERROR:  syntax error at or near "xxx"
327LINE 1: xxx;
328        ^
329CREATE foo;
330ERROR:  syntax error at or near "foo"
331LINE 1: CREATE foo;
332               ^
333CREATE TABLE ;
334ERROR:  syntax error at or near ";"
335LINE 1: CREATE TABLE ;
336                     ^
337CREATE TABLE
338\g
339ERROR:  syntax error at end of input
340LINE 1: CREATE TABLE
341                    ^
342INSERT INTO foo VALUES(123) foo;
343ERROR:  syntax error at or near "foo"
344LINE 1: INSERT INTO foo VALUES(123) foo;
345                                    ^
346INSERT INTO 123
347VALUES(123);
348ERROR:  syntax error at or near "123"
349LINE 1: INSERT INTO 123
350                    ^
351INSERT INTO foo
352VALUES(123) 123
353;
354ERROR:  syntax error at or near "123"
355LINE 2: VALUES(123) 123
356                    ^
357-- with a tab
358CREATE TABLE foo
359  (id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY,
360	id3 INTEGER NOT NUL,
361   id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL);
362ERROR:  syntax error at or near "NUL"
363LINE 3:  id3 INTEGER NOT NUL,
364                         ^
365-- long line to be truncated on the left
366CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
367id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL);
368ERROR:  syntax error at or near "NUL"
369LINE 1: ...OT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
370                                                                   ^
371-- long line to be truncated on the right
372CREATE TABLE foo(
373id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY);
374ERROR:  syntax error at or near "NUL"
375LINE 2: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ...
376                        ^
377-- long line to be truncated both ways
378CREATE 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);
379ERROR:  syntax error at or near "NUL"
380LINE 1: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
381                                                             ^
382-- long line to be truncated on the left, many lines
383CREATE
384TEMPORARY
385TABLE
386foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
387id4 INT4
388UNIQUE
389NOT
390NULL,
391id5 TEXT
392UNIQUE
393NOT
394NULL)
395;
396ERROR:  syntax error at or near "NUL"
397LINE 4: ...OT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
398                                                                   ^
399-- long line to be truncated on the right, many lines
400CREATE
401TEMPORARY
402TABLE
403foo(
404id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY)
405;
406ERROR:  syntax error at or near "NUL"
407LINE 5: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ...
408                        ^
409-- long line to be truncated both ways, many lines
410CREATE
411TEMPORARY
412TABLE
413foo
414(id
415INT4
416UNIQUE 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,
417idz INT4 UNIQUE NOT NULL,
418idv INT4 UNIQUE NOT NULL);
419ERROR:  syntax error at or near "NUL"
420LINE 7: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
421                                                             ^
422-- more than 10 lines...
423CREATE
424TEMPORARY
425TABLE
426foo
427(id
428INT4
429UNIQUE
430NOT
431NULL
432,
433idm
434INT4
435UNIQUE
436NOT
437NULL,
438idx 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,
439idz INT4 UNIQUE NOT NULL,
440idv
441INT4
442UNIQUE
443NOT
444NULL);
445ERROR:  syntax error at or near "NUL"
446LINE 16: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
447                                                              ^
448-- Check that stack depth detection mechanism works and
449-- max_stack_depth is not set too high
450create function infinite_recurse() returns int as
451'select infinite_recurse()' language sql;
452\set VERBOSITY terse
453select infinite_recurse();
454ERROR:  stack depth limit exceeded
455