diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-01 19:59:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-01 19:59:41 +0000 |
commit | b680ae4bdbf1c7fd78e6988bbe8f89e1e1b5db86 (patch) | |
tree | c8a7f8bc0084a15ff3cdbb5b1b4476c69185ca80 /src/backend/access/common/indextuple.c | |
parent | 2487d872e025312e7c16f0dd772190c6787efeea (diff) | |
download | postgresql-b680ae4bdbf1c7fd78e6988bbe8f89e1e1b5db86.tar.gz postgresql-b680ae4bdbf1c7fd78e6988bbe8f89e1e1b5db86.zip |
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
Diffstat (limited to 'src/backend/access/common/indextuple.c')
-rw-r--r-- | src/backend/access/common/indextuple.c | 23 |
1 files changed, 22 insertions, 1 deletions
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 $ * *------------------------------------------------------------------------- */ @@ -433,6 +433,27 @@ nocache_index_getattr(IndexTuple tup, } /* + * 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. */ IndexTuple |