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