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