postgresql/src/test/regress/expected/errors.out

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

448 lines
12 KiB
Plaintext
Raw Normal View History

2000-01-05 18:31:08 +01:00
--
2000-01-06 07:40:54 +01:00
-- ERRORS
2000-01-05 18:31:08 +01:00
--
-- bad in postquel, but ok in PostgreSQL
select 1;
?column?
----------
1
(1 row)
2000-01-05 18:31:08 +01:00
--
-- UNSUPPORTED STUFF
-- doesn't work
2000-01-05 18:31:08 +01:00
-- notify pg_class
--
--
-- SELECT
-- this used to be a syntax error, but now we allow an empty target list
select;
--
(1 row)
-- no such relation
1997-04-27 05:57:34 +02:00
select * from nonesuch;
ERROR: relation "nonesuch" does not exist
LINE 1: select * from nonesuch;
^
2000-01-05 18:31:08 +01:00
-- bad name in target list
select nonesuch from pg_database;
ERROR: column "nonesuch" does not exist
LINE 1: select nonesuch from pg_database;
^
-- empty distinct list isn't OK
select distinct from pg_database;
Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE. The newly added ON CONFLICT clause allows to specify an alternative to raising a unique or exclusion constraint violation error when inserting. ON CONFLICT refers to constraints that can either be specified using a inference clause (by specifying the columns of a unique constraint) or by naming a unique or exclusion constraint. DO NOTHING avoids the constraint violation, without touching the pre-existing row. DO UPDATE SET ... [WHERE ...] updates the pre-existing tuple, and has access to both the tuple proposed for insertion and the existing tuple; the optional WHERE clause can be used to prevent an update from being executed. The UPDATE SET and WHERE clauses have access to the tuple proposed for insertion using the "magic" EXCLUDED alias, and to the pre-existing tuple using the table name or its alias. This feature is often referred to as upsert. This is implemented using a new infrastructure called "speculative insertion". It is an optimistic variant of regular insertion that first does a pre-check for existing tuples and then attempts an insert. If a violating tuple was inserted concurrently, the speculatively inserted tuple is deleted and a new attempt is made. If the pre-check finds a matching tuple the alternative DO NOTHING or DO UPDATE action is taken. If the insertion succeeds without detecting a conflict, the tuple is deemed inserted. To handle the possible ambiguity between the excluded alias and a table named excluded, and for convenience with long relation names, INSERT INTO now can alias its target table. Bumps catversion as stored rules change. Author: Peter Geoghegan, with significant contributions from Heikki Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes. Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs, Dean Rasheed, Stephen Frost and many others.
2015-05-08 05:31:36 +02:00
ERROR: syntax error at or near "from"
LINE 1: select distinct from pg_database;
^
2000-01-05 18:31:08 +01:00
-- bad attribute name on lhs of operator
select * from pg_database where nonesuch = pg_database.datname;
ERROR: column "nonesuch" does not exist
LINE 1: select * from pg_database where nonesuch = pg_database.datna...
^
2000-01-05 18:31:08 +01:00
-- bad attribute name on rhs of operator
select * from pg_database where pg_database.datname = nonesuch;
ERROR: column "nonesuch" does not exist
LINE 1: ...ect * from pg_database where pg_database.datname = nonesuch;
^
-- bad attribute name in select distinct on
select distinct on (foobar) * from pg_database;
ERROR: column "foobar" does not exist
LINE 1: select distinct on (foobar) * from pg_database;
^
-- grouping with FOR UPDATE
select null from pg_database group by datname for update;
ERROR: FOR UPDATE is not allowed with GROUP BY clause
select null from pg_database group by grouping sets (()) for update;
ERROR: FOR UPDATE is not allowed with GROUP BY clause
2000-01-05 18:31:08 +01:00
--
-- DELETE
-- missing relation name (this had better not wildcard!)
2000-01-05 18:31:08 +01:00
delete from;
ERROR: syntax error at or near ";"
LINE 1: delete from;
^
-- no such relation
2000-01-05 18:31:08 +01:00
delete from nonesuch;
ERROR: relation "nonesuch" does not exist
LINE 1: delete from nonesuch;
^
2000-01-05 18:31:08 +01:00
--
-- DROP
-- missing relation name (this had better not wildcard!)
2000-01-05 18:31:08 +01:00
drop table;
ERROR: syntax error at or near ";"
LINE 1: drop table;
^
-- no such relation
2000-01-05 18:31:08 +01:00
drop table nonesuch;
ERROR: table "nonesuch" does not exist
2000-01-05 18:31:08 +01:00
--
-- ALTER TABLE
-- relation renaming
-- missing relation name
2000-01-05 18:31:08 +01:00
alter table rename;
ERROR: syntax error at or near ";"
LINE 1: alter table rename;
^
-- no such relation
2000-01-05 18:31:08 +01:00
alter table nonesuch rename to newnonesuch;
ERROR: relation "nonesuch" does not exist
-- no such relation
2000-01-05 18:31:08 +01:00
alter table nonesuch rename to stud_emp;
ERROR: relation "nonesuch" does not exist
-- conflict
alter table stud_emp rename to student;
ERROR: relation "student" already exists
-- self-conflict
2000-01-05 18:31:08 +01:00
alter table stud_emp rename to stud_emp;
ERROR: relation "stud_emp" already exists
-- attribute renaming
-- no such relation
2000-01-05 18:31:08 +01:00
alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
ERROR: relation "nonesuchrel" does not exist
-- no such attribute
2000-01-05 18:31:08 +01:00
alter table emp rename column nonesuchatt to newnonesuchatt;
ERROR: column "nonesuchatt" does not exist
-- conflict
2000-01-05 18:31:08 +01:00
alter table emp rename column salary to manager;
ERROR: column "manager" of relation "stud_emp" already exists
-- conflict
Remove WITH OIDS support, change oid catalog column visibility. Previously tables declared WITH OIDS, including a significant fraction of the catalog tables, stored the oid column not as a normal column, but as part of the tuple header. This special column was not shown by default, which was somewhat odd, as it's often (consider e.g. pg_class.oid) one of the more important parts of a row. Neither pg_dump nor COPY included the contents of the oid column by default. The fact that the oid column was not an ordinary column necessitated a significant amount of special case code to support oid columns. That already was painful for the existing, but upcoming work aiming to make table storage pluggable, would have required expanding and duplicating that "specialness" significantly. WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0). Remove it. Removing includes: - CREATE TABLE and ALTER TABLE syntax for declaring the table to be WITH OIDS has been removed (WITH (oids[ = true]) will error out) - pg_dump does not support dumping tables declared WITH OIDS and will issue a warning when dumping one (and ignore the oid column). - restoring an pg_dump archive with pg_restore will warn when restoring a table with oid contents (and ignore the oid column) - COPY will refuse to load binary dump that includes oids. - pg_upgrade will error out when encountering tables declared WITH OIDS, they have to be altered to remove the oid column first. - Functionality to access the oid of the last inserted row (like plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed. The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false) for CREATE TABLE) is still supported. While that requires a bit of support code, it seems unnecessary to break applications / dumps that do not use oids, and are explicit about not using them. The biggest user of WITH OID columns was postgres' catalog. This commit changes all 'magic' oid columns to be columns that are normally declared and stored. To reduce unnecessary query breakage all the newly added columns are still named 'oid', even if a table's column naming scheme would indicate 'reloid' or such. This obviously requires adapting a lot code, mostly replacing oid access via HeapTupleGetOid() with access to the underlying Form_pg_*->oid column. The bootstrap process now assigns oids for all oid columns in genbki.pl that do not have an explicit value (starting at the largest oid previously used), only oids assigned later by oids will be above FirstBootstrapObjectId. As the oid column now is a normal column the special bootstrap syntax for oids has been removed. Oids are not automatically assigned during insertion anymore, all backend code explicitly assigns oids with GetNewOidWithIndex(). For the rare case that insertions into the catalog via SQL are called for the new pg_nextoid() function can be used (which only works on catalog tables). The fact that oid columns on system tables are now normal columns means that they will be included in the set of columns expanded by * (i.e. SELECT * FROM pg_class will now include the table's oid, previously it did not). It'd not technically be hard to hide oid column by default, but that'd mean confusing behavior would either have to be carried forward forever, or it'd cause breakage down the line. While it's not unlikely that further adjustments are needed, the scope/invasiveness of the patch makes it worthwhile to get merge this now. It's painful to maintain externally, too complicated to commit after the code code freeze, and a dependency of a number of other patches. Catversion bump, for obvious reasons. Author: Andres Freund, with contributions by John Naylor Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
alter table emp rename column salary to ctid;
ERROR: column name "ctid" conflicts with a system column name
2000-01-05 18:31:08 +01:00
--
-- TRANSACTION STUFF
-- not in a xact
2000-01-05 18:31:08 +01:00
abort;
WARNING: there is no transaction in progress
-- not in a xact
2000-01-05 18:31:08 +01:00
end;
WARNING: there is no transaction in progress
2000-01-05 18:31:08 +01:00
--
-- CREATE AGGREGATE
-- sfunc/finalfunc type disagreement
create aggregate newavg2 (sfunc = int4pl,
1997-04-27 05:57:34 +02:00
basetype = int4,
stype = int4,
finalfunc = int2um,
initcond = '0');
ERROR: function int2um(integer) does not exist
2000-01-05 18:31:08 +01:00
-- left out basetype
create aggregate newcnt1 (sfunc = int4inc,
stype = int4,
initcond = '0');
ERROR: aggregate input type must be specified
2000-01-05 18:31:08 +01:00
--
-- DROP INDEX
-- missing index name
2000-01-05 18:31:08 +01:00
drop index;
ERROR: syntax error at or near ";"
LINE 1: drop index;
^
-- bad index name
2000-01-05 18:31:08 +01:00
drop index 314159;
ERROR: syntax error at or near "314159"
LINE 1: drop index 314159;
^
-- no such index
2000-01-05 18:31:08 +01:00
drop index nonesuch;
ERROR: index "nonesuch" does not exist
2000-01-05 18:31:08 +01:00
--
-- DROP AGGREGATE
-- missing aggregate name
2000-01-05 18:31:08 +01:00
drop aggregate;
ERROR: syntax error at or near ";"
LINE 1: drop aggregate;
^
2000-01-05 18:31:08 +01:00
-- missing aggregate type
drop aggregate newcnt1;
ERROR: syntax error at or near ";"
LINE 1: drop aggregate newcnt1;
^
-- bad aggregate name
drop aggregate 314159 (int);
ERROR: syntax error at or near "314159"
LINE 1: drop aggregate 314159 (int);
^
2000-01-05 18:31:08 +01:00
-- bad aggregate type
drop aggregate newcnt (nonesuch);
ERROR: type "nonesuch" does not exist
-- no such aggregate
drop aggregate nonesuch (int4);
ERROR: aggregate nonesuch(integer) does not exist
2000-01-05 18:31:08 +01:00
-- no such aggregate for type
drop aggregate newcnt (float4);
ERROR: aggregate newcnt(real) does not exist
2000-01-05 18:31:08 +01:00
--
-- DROP FUNCTION
-- missing function name
2000-01-05 18:31:08 +01:00
drop function ();
ERROR: syntax error at or near "("
LINE 1: drop function ();
^
-- bad function name
2000-01-05 18:31:08 +01:00
drop function 314159();
ERROR: syntax error at or near "314159"
LINE 1: drop function 314159();
^
-- no such function
2000-01-05 18:31:08 +01:00
drop function nonesuch();
ERROR: function nonesuch() does not exist
2000-01-05 18:31:08 +01:00
--
-- DROP TYPE
-- missing type name
2000-01-05 18:31:08 +01:00
drop type;
ERROR: syntax error at or near ";"
LINE 1: drop type;
^
-- bad type name
2000-01-05 18:31:08 +01:00
drop type 314159;
ERROR: syntax error at or near "314159"
LINE 1: drop type 314159;
^
-- no such type
2000-01-05 18:31:08 +01:00
drop type nonesuch;
ERROR: type "nonesuch" does not exist
2000-01-05 18:31:08 +01:00
--
-- DROP OPERATOR
-- missing everything
2000-01-05 18:31:08 +01:00
drop operator;
ERROR: syntax error at or near ";"
LINE 1: drop operator;
^
-- bad operator name
2000-01-05 18:31:08 +01:00
drop operator equals;
ERROR: syntax error at or near ";"
LINE 1: drop operator equals;
^
-- missing type list
2000-01-05 18:31:08 +01:00
drop operator ===;
ERROR: syntax error at or near ";"
LINE 1: drop operator ===;
^
-- missing parentheses
2000-01-05 18:31:08 +01:00
drop operator int4, int4;
ERROR: syntax error at or near ","
LINE 1: drop operator int4, int4;
^
-- missing operator name
2000-01-05 18:31:08 +01:00
drop operator (int4, int4);
ERROR: syntax error at or near "("
LINE 1: drop operator (int4, int4);
^
-- missing type list contents
2000-01-05 18:31:08 +01:00
drop operator === ();
ERROR: syntax error at or near ")"
LINE 1: drop operator === ();
^
-- no such operator
2000-01-05 18:31:08 +01:00
drop operator === (int4);
ERROR: missing argument
LINE 1: drop operator === (int4);
^
HINT: Use NONE to denote the missing argument of a unary operator.
-- no such operator by that name
2000-01-05 18:31:08 +01:00
drop operator === (int4, int4);
ERROR: operator does not exist: integer === integer
-- no such type1
2000-01-05 18:31:08 +01:00
drop operator = (nonesuch);
ERROR: missing argument
LINE 1: drop operator = (nonesuch);
^
HINT: Use NONE to denote the missing argument of a unary operator.
-- no such type1
2000-01-05 18:31:08 +01:00
drop operator = ( , int4);
ERROR: syntax error at or near ","
LINE 1: drop operator = ( , int4);
^
-- no such type1
2000-01-05 18:31:08 +01:00
drop operator = (nonesuch, int4);
ERROR: type "nonesuch" does not exist
-- no such type2
2000-01-05 18:31:08 +01:00
drop operator = (int4, nonesuch);
ERROR: type "nonesuch" does not exist
-- no such type2
2000-01-05 18:31:08 +01:00
drop operator = (int4, );
ERROR: syntax error at or near ")"
LINE 1: drop operator = (int4, );
^
2000-01-05 18:31:08 +01:00
--
-- DROP RULE
-- missing rule name
2000-01-05 18:31:08 +01:00
drop rule;
ERROR: syntax error at or near ";"
LINE 1: drop rule;
^
-- bad rule name
2000-01-05 18:31:08 +01:00
drop rule 314159;
ERROR: syntax error at or near "314159"
LINE 1: drop rule 314159;
^
-- no such rule
drop rule nonesuch on noplace;
ERROR: relation "noplace" does not exist
-- these postquel variants are no longer supported
2000-01-05 18:31:08 +01:00
drop tuple rule nonesuch;
ERROR: syntax error at or near "tuple"
LINE 1: drop tuple rule nonesuch;
^
drop instance rule nonesuch on noplace;
ERROR: syntax error at or near "instance"
LINE 1: drop instance rule nonesuch on noplace;
^
2000-01-05 18:31:08 +01:00
drop rewrite rule nonesuch;
ERROR: syntax error at or near "rewrite"
LINE 1: drop rewrite rule nonesuch;
^
--
-- Check that division-by-zero is properly caught.
--
select 1/0;
ERROR: division by zero
select 1::int8/0;
ERROR: division by zero
select 1/0::int8;
ERROR: division by zero
select 1::int2/0;
ERROR: division by zero
select 1/0::int2;
ERROR: division by zero
select 1::numeric/0;
ERROR: division by zero
select 1/0::numeric;
ERROR: division by zero
select 1::float8/0;
ERROR: division by zero
select 1/0::float8;
ERROR: division by zero
select 1::float4/0;
ERROR: division by zero
select 1/0::float4;
ERROR: division by zero
--
-- Test psql's reporting of syntax error location
--
xxx;
ERROR: syntax error at or near "xxx"
LINE 1: xxx;
^
CREATE foo;
ERROR: syntax error at or near "foo"
LINE 1: CREATE foo;
^
CREATE TABLE ;
ERROR: syntax error at or near ";"
LINE 1: CREATE TABLE ;
^
CREATE TABLE
\g
ERROR: syntax error at end of input
LINE 1: CREATE TABLE
^
INSERT INTO foo VALUES(123) foo;
ERROR: syntax error at or near "foo"
LINE 1: INSERT INTO foo VALUES(123) foo;
^
INSERT INTO 123
VALUES(123);
ERROR: syntax error at or near "123"
LINE 1: INSERT INTO 123
^
INSERT INTO foo
VALUES(123) 123
;
ERROR: syntax error at or near "123"
LINE 2: VALUES(123) 123
^
-- with a tab
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);
ERROR: syntax error at or near "NUL"
LINE 3: id3 INTEGER NOT NUL,
^
-- long line to be truncated on the left
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);
ERROR: syntax error at or near "NUL"
LINE 1: ...OT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
^
-- long line to be truncated on the right
CREATE TABLE foo(
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);
ERROR: syntax error at or near "NUL"
LINE 2: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ...
^
-- long line to be truncated both ways
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);
ERROR: syntax error at or near "NUL"
LINE 1: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
^
-- long line to be truncated on the left, many lines
CREATE
TEMPORARY
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)
;
ERROR: syntax error at or near "NUL"
LINE 4: ...OT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL,
^
-- long line to be truncated on the right, many lines
CREATE
TEMPORARY
TABLE
foo(
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)
;
ERROR: syntax error at or near "NUL"
LINE 5: id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQ...
^
-- long line to be truncated both ways, many lines
CREATE
TEMPORARY
TABLE
foo
(id
INT4
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,
idz INT4 UNIQUE NOT NULL,
idv INT4 UNIQUE NOT NULL);
ERROR: syntax error at or near "NUL"
LINE 7: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
^
-- more than 10 lines...
CREATE
TEMPORARY
TABLE
foo
(id
INT4
UNIQUE
NOT
NULL
,
idm
INT4
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,
idz INT4 UNIQUE NOT NULL,
idv
INT4
UNIQUE
NOT
NULL);
ERROR: syntax error at or near "NUL"
LINE 16: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
^