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