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