1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

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.
This commit is contained in:
Robert Haas
2010-01-10 04:26:36 +00:00
parent 8b9fa7a93a
commit 84b6d5f359
5 changed files with 36 additions and 109 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.109 2010/01/02 16:58:00 momjian Exp $
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.110 2010/01/10 04:26:36 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -763,7 +763,7 @@ extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
#define fastgetattr(tup, attnum, tupleDesc, isnull) \
( \
AssertMacro((attnum) > 0), \
(((isnull) != NULL) ? (*(isnull) = false) : (dummyret)NULL), \
(*(isnull) = false), \
HeapTupleNoNulls(tup) ? \
( \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
@@ -773,18 +773,18 @@ extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
(tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
) \
: \
nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
: \
( \
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
( \
(((isnull) != NULL) ? (*(isnull) = true) : (dummyret)NULL), \
(*(isnull) = true), \
(Datum)NULL \
) \
: \
( \
nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
) \
)
@@ -818,7 +818,7 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
( \
((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
( \
(((isnull) != NULL) ? (*(isnull) = true) : (dummyret)NULL), \
(*(isnull) = true), \
(Datum)NULL \
) \
: \
@@ -838,7 +838,7 @@ extern void heap_fill_tuple(TupleDesc tupleDesc,
uint16 *infomask, bits8 *bit);
extern bool heap_attisnull(HeapTuple tup, int attnum);
extern Datum nocachegetattr(HeapTuple tup, int attnum,
TupleDesc att, bool *isnull);
TupleDesc att);
extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
bool *isnull);
extern HeapTuple heap_copytuple(HeapTuple tuple);