1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Clean up a few places where Datums were being treated as pointers (and vice

versa) without going through DatumGetPointer.

Gavin Sherry, with Feng Tian.
This commit is contained in:
Alvaro Herrera
2008-04-17 21:37:28 +00:00
parent 25e46a504b
commit 2f0f7b4bce
7 changed files with 56 additions and 54 deletions

View File

@@ -57,7 +57,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.120 2008/01/01 19:45:45 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.121 2008/04/17 21:37:28 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -890,7 +890,7 @@ heap_form_tuple(TupleDesc tupleDescriptor,
else if (att[i]->attlen == -1 &&
att[i]->attalign == 'd' &&
att[i]->attndims == 0 &&
!VARATT_IS_EXTENDED(values[i]))
!VARATT_IS_EXTENDED(DatumGetPointer(values[i])))
{
values[i] = toast_flatten_tuple_attribute(values[i],
att[i]->atttypid,
@@ -1001,7 +1001,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
else if (att[i]->attlen == -1 &&
att[i]->attalign == 'd' &&
att[i]->attndims == 0 &&
!VARATT_IS_EXTENDED(values[i]))
!VARATT_IS_EXTENDED(DatumGetPointer(values[i])))
{
values[i] = toast_flatten_tuple_attribute(values[i],
att[i]->atttypid,

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.85 2008/01/01 19:45:45 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.86 2008/04/17 21:37:28 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -73,7 +73,7 @@ index_form_tuple(TupleDesc tupleDescriptor,
* If value is stored EXTERNAL, must fetch it so we are not depending
* on outside storage. This should be improved someday.
*/
if (VARATT_IS_EXTERNAL(values[i]))
if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i])))
{
untoasted_values[i] =
PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)
@@ -85,8 +85,8 @@ index_form_tuple(TupleDesc tupleDescriptor,
* If value is above size target, and is of a compressible datatype,
* try to compress it in-line.
*/
if (!VARATT_IS_EXTENDED(untoasted_values[i]) &&
VARSIZE(untoasted_values[i]) > TOAST_INDEX_TARGET &&
if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) &&
VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET &&
(att->attstorage == 'x' || att->attstorage == 'm'))
{
Datum cvalue = toast_compress_datum(untoasted_values[i]);

View File

@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.101 2008/01/01 19:45:45 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.102 2008/04/17 21:37:28 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -340,7 +340,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
}
/* Clean up detoasted copy, if any */
if (attr != origattr)
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
pfree(DatumGetPointer(attr));
}
@@ -423,7 +423,7 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self)
pfree(outputstr);
/* Clean up detoasted copy, if any */
if (attr != origattr)
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
pfree(DatumGetPointer(attr));
}
@@ -537,7 +537,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
pfree(value);
/* Clean up detoasted copy, if any */
if (attr != origattr)
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
pfree(DatumGetPointer(attr));
}
printf("\t----\n");
@@ -627,7 +627,7 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
pfree(outputbytes);
/* Clean up detoasted copy, if any */
if (attr != origattr)
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
pfree(DatumGetPointer(attr));
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.9 2008/03/25 22:42:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.10 2008/04/17 21:37:28 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,7 @@ transformRelOptions(Datum oldOptions, List *defList,
astate = NULL;
/* Copy any oldOptions that aren't to be replaced */
if (oldOptions != (Datum) 0)
if (PointerIsValid(DatumGetPointer(oldOptions)))
{
ArrayType *array = DatumGetArrayTypeP(oldOptions);
Datum *oldoptions;
@@ -164,7 +164,7 @@ untransformRelOptions(Datum options)
int i;
/* Nothing to do if no options */
if (options == (Datum) 0)
if (!PointerIsValid(DatumGetPointer(options)))
return result;
array = DatumGetArrayTypeP(options);
@@ -220,7 +220,7 @@ parseRelOptions(Datum options, int numkeywords, const char *const * keywords,
MemSet(values, 0, numkeywords * sizeof(char *));
/* Done if no options */
if (options == (Datum) 0)
if (!PointerIsValid(DatumGetPointer(options)))
return;
array = DatumGetArrayTypeP(options);
@@ -349,7 +349,7 @@ index_reloptions(RegProcedure amoptions, Datum reloptions, bool validate)
Assert(RegProcedureIsValid(amoptions));
/* Assume function is strict */
if (reloptions == (Datum) 0)
if (!PointerIsValid(DatumGetPointer(reloptions)))
return NULL;
/* Can't use OidFunctionCallN because we might get a NULL result */