Skip to content
Snippets Groups Projects
Commit 2aae35d0 authored by Tom Lane's avatar Tom Lane
Browse files

Mention the index name in 'could not create unique index' errors,

per suggestion from Rene Gollent.
parent b17b7fae
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.78 2007/09/01 18:47:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.79 2007/10/29 21:31:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2720,7 +2720,8 @@ comparetup_index(const SortTuple *a, const SortTuple *b, Tuplesortstate *state) ...@@ -2720,7 +2720,8 @@ comparetup_index(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2) if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNIQUE_VIOLATION), (errcode(ERRCODE_UNIQUE_VIOLATION),
errmsg("could not create unique index"), errmsg("could not create unique index \"%s\"",
RelationGetRelationName(state->indexRel)),
errdetail("Table contains duplicated values."))); errdetail("Table contains duplicated values.")));
/* /*
......
...@@ -417,7 +417,7 @@ insert into atacc1 (test) values (2); ...@@ -417,7 +417,7 @@ insert into atacc1 (test) values (2);
-- add a unique constraint (fails) -- add a unique constraint (fails)
alter table atacc1 add constraint atacc_test1 unique (test); alter table atacc1 add constraint atacc_test1 unique (test);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1" NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1"
ERROR: could not create unique index ERROR: could not create unique index "atacc_test1"
DETAIL: Table contains duplicated values. DETAIL: Table contains duplicated values.
insert into atacc1 (test) values (3); insert into atacc1 (test) values (3);
drop table atacc1; drop table atacc1;
...@@ -485,7 +485,7 @@ insert into atacc1 (test) values (2); ...@@ -485,7 +485,7 @@ insert into atacc1 (test) values (2);
-- add a primary key (fails) -- add a primary key (fails)
alter table atacc1 add constraint atacc_test1 primary key (test); alter table atacc1 add constraint atacc_test1 primary key (test);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1" NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
ERROR: could not create unique index ERROR: could not create unique index "atacc_test1"
DETAIL: Table contains duplicated values. DETAIL: Table contains duplicated values.
insert into atacc1 (test) values (3); insert into atacc1 (test) values (3);
drop table atacc1; drop table atacc1;
......
...@@ -389,7 +389,7 @@ INSERT INTO concur_heap VALUES ('b','x'); ...@@ -389,7 +389,7 @@ INSERT INTO concur_heap VALUES ('b','x');
ERROR: duplicate key value violates unique constraint "concur_index2" ERROR: duplicate key value violates unique constraint "concur_index2"
-- check if constraint is enforced properly at build time -- check if constraint is enforced properly at build time
CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap(f2); CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap(f2);
ERROR: could not create unique index ERROR: could not create unique index "concur_index3"
DETAIL: Table contains duplicated values. DETAIL: Table contains duplicated values.
-- test that expression indexes and partial indexes work concurrently -- test that expression indexes and partial indexes work concurrently
CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a'; CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment