diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-01-10 04:26:36 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-01-10 04:26:36 +0000 |
commit | 84b6d5f35941a0406210e7938d10c3cce4e11340 (patch) | |
tree | 23fa242445215cc5ff36b06ac9af3abeeca37e2e /src/backend/access/common/indextuple.c | |
parent | 8b9fa7a93ab32f670de9931c0e0f104befed64af (diff) | |
download | postgresql-84b6d5f35941a0406210e7938d10c3cce4e11340.tar.gz postgresql-84b6d5f35941a0406210e7938d10c3cce4e11340.zip |
Remove partial, broken support for NULL pointers when fetching attributes.
Previously, fastgetattr() and heap_getattr() tested their fourth argument
against a null pointer, but any attempt to use them with a literal-NULL
fourth argument evaluated to *(void *)0, resulting in a compiler error.
Remove these NULL tests to avoid leading future readers of this code to
believe that this has a chance of working. Also clean up related legacy
code in nocachegetattr(), heap_getsysattr(), and nocache_index_getattr().
The new coding standard is that any code which calls a getattr-type
function or macro which takes an isnull argument MUST pass a valid
boolean pointer. Per discussion with Bruce Momjian, Tom Lane, Alvaro
Herrera.
Diffstat (limited to 'src/backend/access/common/indextuple.c')
-rw-r--r-- | src/backend/access/common/indextuple.c | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 61d7f61997a..3ce377b8545 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.90 2010/01/02 16:57:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.91 2010/01/10 04:26:36 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -200,8 +200,7 @@ index_form_tuple(TupleDesc tupleDescriptor, Datum nocache_index_getattr(IndexTuple tup, int attnum, - TupleDesc tupleDesc, - bool *isnull) + TupleDesc tupleDesc) { Form_pg_attribute *att = tupleDesc->attrs; char *tp; /* ptr to data part of tuple */ @@ -210,8 +209,6 @@ nocache_index_getattr(IndexTuple tup, int data_off; /* tuple data offset */ int off; /* current offset within data */ - (void) isnull; /* not used */ - /* ---------------- * Three cases: * @@ -221,31 +218,11 @@ nocache_index_getattr(IndexTuple tup, * ---------------- */ -#ifdef IN_MACRO -/* This is handled in the macro */ - Assert(PointerIsValid(isnull)); - Assert(attnum > 0); - - *isnull = false; -#endif - data_off = IndexInfoFindDataOffset(tup->t_info); attnum--; - if (!IndexTupleHasNulls(tup)) - { -#ifdef IN_MACRO -/* This is handled in the macro */ - if (att[attnum]->attcacheoff >= 0) - { - return fetchatt(att[attnum], - (char *) tup + data_off + - att[attnum]->attcacheoff); - } -#endif - } - else + if (IndexTupleHasNulls(tup)) { /* * there's a null somewhere in the tuple @@ -256,16 +233,6 @@ nocache_index_getattr(IndexTuple tup, /* XXX "knows" t_bits are just after fixed tuple header! */ bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData)); -#ifdef IN_MACRO -/* This is handled in the macro */ - - if (att_isnull(attnum, bp)) - { - *isnull = true; - return (Datum) NULL; - } -#endif - /* * Now check to see if any preceding bits are null... */ |