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:
parent
25e46a504b
commit
2f0f7b4bce
@ -57,7 +57,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 &&
|
else if (att[i]->attlen == -1 &&
|
||||||
att[i]->attalign == 'd' &&
|
att[i]->attalign == 'd' &&
|
||||||
att[i]->attndims == 0 &&
|
att[i]->attndims == 0 &&
|
||||||
!VARATT_IS_EXTENDED(values[i]))
|
!VARATT_IS_EXTENDED(DatumGetPointer(values[i])))
|
||||||
{
|
{
|
||||||
values[i] = toast_flatten_tuple_attribute(values[i],
|
values[i] = toast_flatten_tuple_attribute(values[i],
|
||||||
att[i]->atttypid,
|
att[i]->atttypid,
|
||||||
@ -1001,7 +1001,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
|
|||||||
else if (att[i]->attlen == -1 &&
|
else if (att[i]->attlen == -1 &&
|
||||||
att[i]->attalign == 'd' &&
|
att[i]->attalign == 'd' &&
|
||||||
att[i]->attndims == 0 &&
|
att[i]->attndims == 0 &&
|
||||||
!VARATT_IS_EXTENDED(values[i]))
|
!VARATT_IS_EXTENDED(DatumGetPointer(values[i])))
|
||||||
{
|
{
|
||||||
values[i] = toast_flatten_tuple_attribute(values[i],
|
values[i] = toast_flatten_tuple_attribute(values[i],
|
||||||
att[i]->atttypid,
|
att[i]->atttypid,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* If value is stored EXTERNAL, must fetch it so we are not depending
|
||||||
* on outside storage. This should be improved someday.
|
* on outside storage. This should be improved someday.
|
||||||
*/
|
*/
|
||||||
if (VARATT_IS_EXTERNAL(values[i]))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(values[i])))
|
||||||
{
|
{
|
||||||
untoasted_values[i] =
|
untoasted_values[i] =
|
||||||
PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)
|
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,
|
* If value is above size target, and is of a compressible datatype,
|
||||||
* try to compress it in-line.
|
* try to compress it in-line.
|
||||||
*/
|
*/
|
||||||
if (!VARATT_IS_EXTENDED(untoasted_values[i]) &&
|
if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) &&
|
||||||
VARSIZE(untoasted_values[i]) > TOAST_INDEX_TARGET &&
|
VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET &&
|
||||||
(att->attstorage == 'x' || att->attstorage == 'm'))
|
(att->attstorage == 'x' || att->attstorage == 'm'))
|
||||||
{
|
{
|
||||||
Datum cvalue = toast_compress_datum(untoasted_values[i]);
|
Datum cvalue = toast_compress_datum(untoasted_values[i]);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 */
|
/* Clean up detoasted copy, if any */
|
||||||
if (attr != origattr)
|
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
|
||||||
pfree(DatumGetPointer(attr));
|
pfree(DatumGetPointer(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self)
|
|||||||
pfree(outputstr);
|
pfree(outputstr);
|
||||||
|
|
||||||
/* Clean up detoasted copy, if any */
|
/* Clean up detoasted copy, if any */
|
||||||
if (attr != origattr)
|
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
|
||||||
pfree(DatumGetPointer(attr));
|
pfree(DatumGetPointer(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
|
|||||||
pfree(value);
|
pfree(value);
|
||||||
|
|
||||||
/* Clean up detoasted copy, if any */
|
/* Clean up detoasted copy, if any */
|
||||||
if (attr != origattr)
|
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
|
||||||
pfree(DatumGetPointer(attr));
|
pfree(DatumGetPointer(attr));
|
||||||
}
|
}
|
||||||
printf("\t----\n");
|
printf("\t----\n");
|
||||||
@ -627,7 +627,7 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
|
|||||||
pfree(outputbytes);
|
pfree(outputbytes);
|
||||||
|
|
||||||
/* Clean up detoasted copy, if any */
|
/* Clean up detoasted copy, if any */
|
||||||
if (attr != origattr)
|
if (DatumGetPointer(attr) != DatumGetPointer(origattr))
|
||||||
pfree(DatumGetPointer(attr));
|
pfree(DatumGetPointer(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
astate = NULL;
|
||||||
|
|
||||||
/* Copy any oldOptions that aren't to be replaced */
|
/* Copy any oldOptions that aren't to be replaced */
|
||||||
if (oldOptions != (Datum) 0)
|
if (PointerIsValid(DatumGetPointer(oldOptions)))
|
||||||
{
|
{
|
||||||
ArrayType *array = DatumGetArrayTypeP(oldOptions);
|
ArrayType *array = DatumGetArrayTypeP(oldOptions);
|
||||||
Datum *oldoptions;
|
Datum *oldoptions;
|
||||||
@ -164,7 +164,7 @@ untransformRelOptions(Datum options)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Nothing to do if no options */
|
/* Nothing to do if no options */
|
||||||
if (options == (Datum) 0)
|
if (!PointerIsValid(DatumGetPointer(options)))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
array = DatumGetArrayTypeP(options);
|
array = DatumGetArrayTypeP(options);
|
||||||
@ -220,7 +220,7 @@ parseRelOptions(Datum options, int numkeywords, const char *const * keywords,
|
|||||||
MemSet(values, 0, numkeywords * sizeof(char *));
|
MemSet(values, 0, numkeywords * sizeof(char *));
|
||||||
|
|
||||||
/* Done if no options */
|
/* Done if no options */
|
||||||
if (options == (Datum) 0)
|
if (!PointerIsValid(DatumGetPointer(options)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
array = DatumGetArrayTypeP(options);
|
array = DatumGetArrayTypeP(options);
|
||||||
@ -349,7 +349,7 @@ index_reloptions(RegProcedure amoptions, Datum reloptions, bool validate)
|
|||||||
Assert(RegProcedureIsValid(amoptions));
|
Assert(RegProcedureIsValid(amoptions));
|
||||||
|
|
||||||
/* Assume function is strict */
|
/* Assume function is strict */
|
||||||
if (reloptions == (Datum) 0)
|
if (!PointerIsValid(DatumGetPointer(reloptions)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Can't use OidFunctionCallN because we might get a NULL result */
|
/* Can't use OidFunctionCallN because we might get a NULL result */
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.86 2008/04/12 23:14:21 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.87 2008/04/17 21:37:28 alvherre Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -383,7 +383,7 @@ toast_delete(Relation rel, HeapTuple oldtup)
|
|||||||
{
|
{
|
||||||
Datum value = toast_values[i];
|
Datum value = toast_values[i];
|
||||||
|
|
||||||
if (!toast_isnull[i] && VARATT_IS_EXTERNAL(value))
|
if (!toast_isnull[i] && VARATT_IS_EXTERNAL(PointerGetDatum(value)))
|
||||||
toast_delete_datum(rel, value);
|
toast_delete_datum(rel, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -615,9 +615,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
{
|
{
|
||||||
if (toast_action[i] != ' ')
|
if (toast_action[i] != ' ')
|
||||||
continue;
|
continue;
|
||||||
if (VARATT_IS_EXTERNAL(toast_values[i]))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(toast_values[i])))
|
||||||
continue; /* can't happen, toast_action would be 'p' */
|
continue; /* can't happen, toast_action would be 'p' */
|
||||||
if (VARATT_IS_COMPRESSED(toast_values[i]))
|
if (VARATT_IS_COMPRESSED(DatumGetPointer(toast_values[i])))
|
||||||
continue;
|
continue;
|
||||||
if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e')
|
if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e')
|
||||||
continue;
|
continue;
|
||||||
@ -647,7 +647,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
pfree(DatumGetPointer(old_value));
|
pfree(DatumGetPointer(old_value));
|
||||||
toast_values[i] = new_value;
|
toast_values[i] = new_value;
|
||||||
toast_free[i] = true;
|
toast_free[i] = true;
|
||||||
toast_sizes[i] = VARSIZE(toast_values[i]);
|
toast_sizes[i] = VARSIZE(DatumGetPointer(toast_values[i]));
|
||||||
need_change = true;
|
need_change = true;
|
||||||
need_free = true;
|
need_free = true;
|
||||||
}
|
}
|
||||||
@ -707,7 +707,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
{
|
{
|
||||||
if (toast_action[i] == 'p')
|
if (toast_action[i] == 'p')
|
||||||
continue;
|
continue;
|
||||||
if (VARATT_IS_EXTERNAL(toast_values[i]))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(toast_values[i])))
|
||||||
continue; /* can't happen, toast_action would be 'p' */
|
continue; /* can't happen, toast_action would be 'p' */
|
||||||
if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e')
|
if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e')
|
||||||
continue;
|
continue;
|
||||||
@ -756,9 +756,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
{
|
{
|
||||||
if (toast_action[i] != ' ')
|
if (toast_action[i] != ' ')
|
||||||
continue;
|
continue;
|
||||||
if (VARATT_IS_EXTERNAL(toast_values[i]))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(toast_values[i])))
|
||||||
continue; /* can't happen, toast_action would be 'p' */
|
continue; /* can't happen, toast_action would be 'p' */
|
||||||
if (VARATT_IS_COMPRESSED(toast_values[i]))
|
if (VARATT_IS_COMPRESSED(DatumGetPointer(toast_values[i])))
|
||||||
continue;
|
continue;
|
||||||
if (att[i]->attstorage != 'm')
|
if (att[i]->attstorage != 'm')
|
||||||
continue;
|
continue;
|
||||||
@ -786,7 +786,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
pfree(DatumGetPointer(old_value));
|
pfree(DatumGetPointer(old_value));
|
||||||
toast_values[i] = new_value;
|
toast_values[i] = new_value;
|
||||||
toast_free[i] = true;
|
toast_free[i] = true;
|
||||||
toast_sizes[i] = VARSIZE(toast_values[i]);
|
toast_sizes[i] = VARSIZE(DatumGetPointer(toast_values[i]));
|
||||||
need_change = true;
|
need_change = true;
|
||||||
need_free = true;
|
need_free = true;
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
|||||||
{
|
{
|
||||||
if (toast_action[i] == 'p')
|
if (toast_action[i] == 'p')
|
||||||
continue;
|
continue;
|
||||||
if (VARATT_IS_EXTERNAL(toast_values[i]))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(toast_values[i])))
|
||||||
continue; /* can't happen, toast_action would be 'p' */
|
continue; /* can't happen, toast_action would be 'p' */
|
||||||
if (att[i]->attstorage != 'm')
|
if (att[i]->attstorage != 'm')
|
||||||
continue;
|
continue;
|
||||||
@ -1070,10 +1070,10 @@ Datum
|
|||||||
toast_compress_datum(Datum value)
|
toast_compress_datum(Datum value)
|
||||||
{
|
{
|
||||||
struct varlena *tmp;
|
struct varlena *tmp;
|
||||||
int32 valsize = VARSIZE_ANY_EXHDR(value);
|
int32 valsize = VARSIZE_ANY_EXHDR(DatumGetPointer(value));
|
||||||
|
|
||||||
Assert(!VARATT_IS_EXTERNAL(value));
|
Assert(!VARATT_IS_EXTERNAL(DatumGetPointer(value)));
|
||||||
Assert(!VARATT_IS_COMPRESSED(value));
|
Assert(!VARATT_IS_COMPRESSED(DatumGetPointer(value)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No point in wasting a palloc cycle if value size is out of the
|
* No point in wasting a palloc cycle if value size is out of the
|
||||||
@ -1095,7 +1095,7 @@ toast_compress_datum(Datum value)
|
|||||||
* header byte and no padding if the value is short enough. So we insist
|
* header byte and no padding if the value is short enough. So we insist
|
||||||
* on a savings of more than 2 bytes to ensure we have a gain.
|
* on a savings of more than 2 bytes to ensure we have a gain.
|
||||||
*/
|
*/
|
||||||
if (pglz_compress(VARDATA_ANY(value), valsize,
|
if (pglz_compress(VARDATA_ANY(DatumGetPointer(value)), valsize,
|
||||||
(PGLZ_Header *) tmp, PGLZ_strategy_default) &&
|
(PGLZ_Header *) tmp, PGLZ_strategy_default) &&
|
||||||
VARSIZE(tmp) < valsize - 2)
|
VARSIZE(tmp) < valsize - 2)
|
||||||
{
|
{
|
||||||
@ -1141,6 +1141,7 @@ toast_save_datum(Relation rel, Datum value,
|
|||||||
int32 chunk_seq = 0;
|
int32 chunk_seq = 0;
|
||||||
char *data_p;
|
char *data_p;
|
||||||
int32 data_todo;
|
int32 data_todo;
|
||||||
|
Pointer dval = DatumGetPointer(value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the toast relation and its index. We can use the index to check
|
* Open the toast relation and its index. We can use the index to check
|
||||||
@ -1159,28 +1160,28 @@ toast_save_datum(Relation rel, Datum value,
|
|||||||
*
|
*
|
||||||
* va_extsize is the actual size of the data payload in the toast records.
|
* va_extsize is the actual size of the data payload in the toast records.
|
||||||
*/
|
*/
|
||||||
if (VARATT_IS_SHORT(value))
|
if (VARATT_IS_SHORT(dval))
|
||||||
{
|
{
|
||||||
data_p = VARDATA_SHORT(value);
|
data_p = VARDATA_SHORT(dval);
|
||||||
data_todo = VARSIZE_SHORT(value) - VARHDRSZ_SHORT;
|
data_todo = VARSIZE_SHORT(dval) - VARHDRSZ_SHORT;
|
||||||
toast_pointer.va_rawsize = data_todo + VARHDRSZ; /* as if not short */
|
toast_pointer.va_rawsize = data_todo + VARHDRSZ; /* as if not short */
|
||||||
toast_pointer.va_extsize = data_todo;
|
toast_pointer.va_extsize = data_todo;
|
||||||
}
|
}
|
||||||
else if (VARATT_IS_COMPRESSED(value))
|
else if (VARATT_IS_COMPRESSED(dval))
|
||||||
{
|
{
|
||||||
data_p = VARDATA(value);
|
data_p = VARDATA(dval);
|
||||||
data_todo = VARSIZE(value) - VARHDRSZ;
|
data_todo = VARSIZE(dval) - VARHDRSZ;
|
||||||
/* rawsize in a compressed datum is just the size of the payload */
|
/* rawsize in a compressed datum is just the size of the payload */
|
||||||
toast_pointer.va_rawsize = VARRAWSIZE_4B_C(value) + VARHDRSZ;
|
toast_pointer.va_rawsize = VARRAWSIZE_4B_C(dval) + VARHDRSZ;
|
||||||
toast_pointer.va_extsize = data_todo;
|
toast_pointer.va_extsize = data_todo;
|
||||||
/* Assert that the numbers look like it's compressed */
|
/* Assert that the numbers look like it's compressed */
|
||||||
Assert(VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer));
|
Assert(VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data_p = VARDATA(value);
|
data_p = VARDATA(dval);
|
||||||
data_todo = VARSIZE(value) - VARHDRSZ;
|
data_todo = VARSIZE(dval) - VARHDRSZ;
|
||||||
toast_pointer.va_rawsize = VARSIZE(value);
|
toast_pointer.va_rawsize = VARSIZE(dval);
|
||||||
toast_pointer.va_extsize = data_todo;
|
toast_pointer.va_extsize = data_todo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.114 2008/03/25 22:42:45 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.115 2008/04/17 21:37:28 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -827,7 +827,7 @@ fmgr_oldstyle(PG_FUNCTION_ARGS)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Datum) returnValue;
|
return PointerGetDatum(returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2008,7 +2008,7 @@ fmgr(Oid procedureId,...)
|
|||||||
flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS)));
|
flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS)));
|
||||||
va_start(pvar, procedureId);
|
va_start(pvar, procedureId);
|
||||||
for (i = 0; i < n_arguments; i++)
|
for (i = 0; i < n_arguments; i++)
|
||||||
fcinfo.arg[i] = (Datum) va_arg(pvar, char *);
|
fcinfo.arg[i] = PointerGetDatum(va_arg(pvar, char *));
|
||||||
va_end(pvar);
|
va_end(pvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2018,7 +2018,7 @@ fmgr(Oid procedureId,...)
|
|||||||
if (fcinfo.isnull)
|
if (fcinfo.isnull)
|
||||||
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
|
elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
|
||||||
|
|
||||||
return (char *) result;
|
return DatumGetPointer(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.209 2008/04/06 23:43:29 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.210 2008/04/17 21:37:28 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -409,7 +409,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
|
|||||||
* sure it is labeled with the caller-supplied tuple type.
|
* sure it is labeled with the caller-supplied tuple type.
|
||||||
*/
|
*/
|
||||||
estate.retval =
|
estate.retval =
|
||||||
PointerGetDatum(SPI_returntuple((HeapTuple) (estate.retval),
|
PointerGetDatum(SPI_returntuple((HeapTuple)DatumGetPointer(estate.retval),
|
||||||
tupdesc));
|
tupdesc));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -702,7 +702,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
|
|||||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||||
errmsg("returned tuple structure does not match table of trigger event")));
|
errmsg("returned tuple structure does not match table of trigger event")));
|
||||||
/* Copy tuple to upper executor memory */
|
/* Copy tuple to upper executor memory */
|
||||||
rettup = SPI_copytuple((HeapTuple) (estate.retval));
|
rettup = SPI_copytuple((HeapTuple) DatumGetPointer(estate.retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1956,7 +1956,7 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
|
|||||||
|
|
||||||
if (HeapTupleIsValid(rec->tup))
|
if (HeapTupleIsValid(rec->tup))
|
||||||
{
|
{
|
||||||
estate->retval = (Datum) rec->tup;
|
estate->retval = PointerGetDatum(rec->tup);
|
||||||
estate->rettupdesc = rec->tupdesc;
|
estate->rettupdesc = rec->tupdesc;
|
||||||
estate->retisnull = false;
|
estate->retisnull = false;
|
||||||
}
|
}
|
||||||
@ -1968,9 +1968,10 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
|
|||||||
PLpgSQL_row *row = (PLpgSQL_row *) retvar;
|
PLpgSQL_row *row = (PLpgSQL_row *) retvar;
|
||||||
|
|
||||||
Assert(row->rowtupdesc);
|
Assert(row->rowtupdesc);
|
||||||
estate->retval = (Datum) make_tuple_from_row(estate, row,
|
estate->retval =
|
||||||
row->rowtupdesc);
|
PointerGetDatum(make_tuple_from_row(estate, row,
|
||||||
if (estate->retval == (Datum) NULL) /* should not happen */
|
row->rowtupdesc));
|
||||||
|
if (DatumGetPointer(estate->retval) == NULL) /* should not happen */
|
||||||
elog(ERROR, "row not compatible with its own tupdesc");
|
elog(ERROR, "row not compatible with its own tupdesc");
|
||||||
estate->rettupdesc = row->rowtupdesc;
|
estate->rettupdesc = row->rowtupdesc;
|
||||||
estate->retisnull = false;
|
estate->retisnull = false;
|
||||||
@ -1991,7 +1992,7 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
|
|||||||
exec_run_select(estate, stmt->expr, 1, NULL);
|
exec_run_select(estate, stmt->expr, 1, NULL);
|
||||||
if (estate->eval_processed > 0)
|
if (estate->eval_processed > 0)
|
||||||
{
|
{
|
||||||
estate->retval = (Datum) estate->eval_tuptable->vals[0];
|
estate->retval = PointerGetDatum(estate->eval_tuptable->vals[0]);
|
||||||
estate->rettupdesc = estate->eval_tuptable->tupdesc;
|
estate->rettupdesc = estate->eval_tuptable->tupdesc;
|
||||||
estate->retisnull = false;
|
estate->retisnull = false;
|
||||||
}
|
}
|
||||||
@ -4998,7 +4999,7 @@ exec_set_found(PLpgSQL_execstate *estate, bool state)
|
|||||||
PLpgSQL_var *var;
|
PLpgSQL_var *var;
|
||||||
|
|
||||||
var = (PLpgSQL_var *) (estate->datums[estate->found_varno]);
|
var = (PLpgSQL_var *) (estate->datums[estate->found_varno]);
|
||||||
var->value = (Datum) state;
|
var->value = PointerGetDatum(state);
|
||||||
var->isnull = false;
|
var->isnull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user