Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / test / regress / sql / errors.sql
blobcf634741601583f286143ce31e10295f73280355
1 --
2 -- ERRORS
3 --
5 -- bad in postquel, but ok in postsql
6 select 1;
9 --
10 -- UNSUPPORTED STUFF
12 -- doesn't work 
13 -- notify pg_class
17 -- SELECT
19 -- missing relation name 
20 select;
22 -- no such relation 
23 select * from nonesuch;
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;
32 -- bad attribute name on rhs of operator
33 select * from pg_database where pg_database.datname = nonesuch;
36 -- bad select distinct on syntax, distinct attribute missing
37 select distinct on (foobar) from pg_database;
40 -- bad select distinct on syntax, distinct attribute not in target list
41 select distinct on (foobar) * from pg_database;
45 -- DELETE
47 -- missing relation name (this had better not wildcard!) 
48 delete from;
50 -- no such relation 
51 delete from nonesuch;
55 -- DROP
57 -- missing relation name (this had better not wildcard!) 
58 drop table;
60 -- no such relation 
61 drop table nonesuch;
65 -- ALTER TABLE
67 -- relation renaming 
69 -- missing relation name 
70 alter table rename;
72 -- no such relation 
73 alter table nonesuch rename to newnonesuch;
75 -- no such relation 
76 alter table nonesuch rename to stud_emp;
78 -- conflict 
79 alter table stud_emp rename to aggtest;
81 -- self-conflict 
82 alter table stud_emp rename to stud_emp;
85 -- attribute renaming 
87 -- no such relation 
88 alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
90 -- no such attribute 
91 alter table emp rename column nonesuchatt to newnonesuchatt;
93 -- conflict 
94 alter table emp rename column salary to manager;
96 -- conflict 
97 alter table emp rename column salary to oid;
101 -- TRANSACTION STUFF
103 -- not in a xact 
104 abort;
106 -- not in a xact 
107 end;
111 -- CREATE AGGREGATE
113 -- sfunc/finalfunc type disagreement 
114 create aggregate newavg2 (sfunc = int4pl,
115                           basetype = int4,
116                           stype = int4,
117                           finalfunc = int2um,
118                           initcond = '0');
120 -- left out basetype
121 create aggregate newcnt1 (sfunc = int4inc,
122                           stype = int4,
123                           initcond = '0');
127 -- DROP INDEX
129 -- missing index name 
130 drop index;
132 -- bad index name 
133 drop index 314159;
135 -- no such index 
136 drop index nonesuch;
140 -- DROP AGGREGATE
142 -- missing aggregate name 
143 drop aggregate;
145 -- missing aggregate type
146 drop aggregate newcnt1;
148 -- bad aggregate name 
149 drop aggregate 314159 (int);
151 -- bad aggregate type
152 drop aggregate newcnt (nonesuch);
154 -- no such aggregate 
155 drop aggregate nonesuch (int4);
157 -- no such aggregate for type
158 drop aggregate newcnt (float4);
162 -- DROP FUNCTION
164 -- missing function name 
165 drop function ();
167 -- bad function name 
168 drop function 314159();
170 -- no such function 
171 drop function nonesuch();
175 -- DROP TYPE
177 -- missing type name 
178 drop type;
180 -- bad type name 
181 drop type 314159;
183 -- no such type 
184 drop type nonesuch;
188 -- DROP OPERATOR
190 -- missing everything 
191 drop operator;
193 -- bad operator name 
194 drop operator equals;
196 -- missing type list 
197 drop operator ===;
199 -- missing parentheses 
200 drop operator int4, int4;
202 -- missing operator name 
203 drop operator (int4, int4);
205 -- missing type list contents 
206 drop operator === ();
208 -- no such operator 
209 drop operator === (int4);
211 -- no such operator by that name 
212 drop operator === (int4, int4);
214 -- no such type1 
215 drop operator = (nonesuch);
217 -- no such type1 
218 drop operator = ( , int4);
220 -- no such type1 
221 drop operator = (nonesuch, int4);
223 -- no such type2 
224 drop operator = (int4, nonesuch);
226 -- no such type2 
227 drop operator = (int4, );
231 -- DROP RULE
233 -- missing rule name 
234 drop rule;
236 -- bad rule name 
237 drop rule 314159;
239 -- no such rule 
240 drop rule nonesuch on noplace;
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;
248 -- Check that division-by-zero is properly caught.
251 select 1/0;
253 select 1::int8/0;
255 select 1/0::int8;
257 select 1::int2/0;
259 select 1/0::int2;
261 select 1::numeric/0;
263 select 1/0::numeric;
265 select 1::float8/0;
267 select 1/0::float8;
269 select 1::float4/0;
271 select 1/0::float4;
275 -- Test psql's reporting of syntax error location
278 xxx;
280 CREATE foo;
282 CREATE TABLE ;
284 CREATE TABLE
287 INSERT INTO foo VALUES(123) foo;
289 INSERT INTO 123
290 VALUES(123);
292 INSERT INTO foo 
293 VALUES(123) 123
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);
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);
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);
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);
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)
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)
336 -- long line to be truncated both ways, many lines
337 CREATE 
338 TEMPORARY
339 TABLE 
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);
347 -- more than 10 lines...
348 CREATE 
349 TEMPORARY
350 TABLE 
352 (id 
353 INT4 
354 UNIQUE 
355 NOT 
356 NULL
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);
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();