summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtinsert.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-08-01 20:59:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-08-01 20:59:17 +0000
commit527f0ae3fa48c3c3a8ba1bde19039545e88a52b6 (patch)
tree1438e03dee2e04a93846f206ee6c23c0cdefa810 /src/backend/access/nbtree/nbtinsert.c
parentb680ae4bdbf1c7fd78e6988bbe8f89e1e1b5db86 (diff)
Department of second thoughts: let's show the exact key during unique index
build failures, too. Refactor a bit more since that error message isn't spelled the same.
Diffstat (limited to 'src/backend/access/nbtree/nbtinsert.c')
-rw-r--r--src/backend/access/nbtree/nbtinsert.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index ee3d89fd066..dd3736ad8a9 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.172 2009/08/01 19:59:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.173 2009/08/01 20:59:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -365,7 +365,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
* This is a definite conflict. Break the tuple down
* into datums and report the error. But first, make
* sure we release the buffer locks we're holding ---
- * the error reporting code could make catalog accesses,
+ * BuildIndexValueDescription could make catalog accesses,
* which in the worst case might touch this same index
* and cause deadlocks.
*/
@@ -379,7 +379,13 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
index_deform_tuple(itup, RelationGetDescr(rel),
values, isnull);
- ReportUniqueViolation(rel, values, isnull);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNIQUE_VIOLATION),
+ errmsg("duplicate key value violates unique constraint \"%s\"",
+ RelationGetRelationName(rel)),
+ errdetail("Key %s already exists.",
+ BuildIndexValueDescription(rel,
+ values, isnull))));
}
}
else if (all_dead)