From b680ae4bdbf1c7fd78e6988bbe8f89e1e1b5db86 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 1 Aug 2009 19:59:41 +0000 Subject: 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 --- src/backend/access/common/indextuple.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/backend/access/common/indextuple.c') diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index cd3b88654bd..a49ec34a040 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.88 2009/06/11 14:48:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.89 2009/08/01 19:59:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -432,6 +432,27 @@ nocache_index_getattr(IndexTuple tup, return fetchatt(att[attnum], tp + off); } +/* + * Convert an index tuple into Datum/isnull arrays. + * + * The caller must allocate sufficient storage for the output arrays. + * (INDEX_MAX_KEYS entries should be enough.) + */ +void +index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, + Datum *values, bool *isnull) +{ + int i; + + /* Assert to protect callers who allocate fixed-size arrays */ + Assert(tupleDescriptor->natts <= INDEX_MAX_KEYS); + + for (i = 0; i < tupleDescriptor->natts; i++) + { + values[i] = index_getattr(tup, i + 1, tupleDescriptor, &isnull[i]); + } +} + /* * Create a palloc'd copy of an index tuple. */ -- cgit v1.2.3