1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Improve unique-constraint-violation error messages to include the exact

values being complained of.

In passing, also remove the arbitrary length limitation in the similar
error detail message for foreign key violations.

Itagaki Takahiro
This commit is contained in:
Tom Lane
2009-08-01 19:59:41 +00:00
parent 2487d872e0
commit b680ae4bdb
20 changed files with 173 additions and 41 deletions

View File

@ -271,10 +271,13 @@ SELECT name, 'A' = name AS t FROM try where name = 'A';
-- expected failures on duplicate key
INSERT INTO try (name) VALUES ('a');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(a) already exists.
INSERT INTO try (name) VALUES ('A');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(A) already exists.
INSERT INTO try (name) VALUES ('aB');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(aB) already exists.
-- Make sure that citext_smaller() and citext_lager() work properly.
SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
t

View File

@ -271,10 +271,13 @@ SELECT name, 'A' = name AS t FROM try where name = 'A';
-- expected failures on duplicate key
INSERT INTO try (name) VALUES ('a');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(a) already exists.
INSERT INTO try (name) VALUES ('A');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(A) already exists.
INSERT INTO try (name) VALUES ('aB');
ERROR: duplicate key value violates unique constraint "try_pkey"
DETAIL: Key (name)=(aB) already exists.
-- Make sure that citext_smaller() and citext_lager() work properly.
SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
t