Add missing Datum conversions

Add various missing conversions from and to Datum.  The previous code
mostly relied on implicit conversions or its own explicit casts
instead of using the correct DatumGet*() or *GetDatum() functions.

We think these omissions are harmless.  Some actual bugs that were
discovered during this process have been committed
separately (80c758a2e1, fd2ab03fea).

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org
This commit is contained in:
Peter Eisentraut 2025-08-08 22:05:05 +02:00
parent dcfc0f8912
commit ff89e182d4
45 changed files with 107 additions and 107 deletions

View File

@ -193,8 +193,8 @@ gbt_enum_ssup_cmp(Datum x, Datum y, SortSupport ssup)
return DatumGetInt32(CallerFInfoFunctionCall2(enum_cmp, return DatumGetInt32(CallerFInfoFunctionCall2(enum_cmp,
ssup->ssup_extra, ssup->ssup_extra,
InvalidOid, InvalidOid,
arg1->lower, ObjectIdGetDatum(arg1->lower),
arg2->lower)); ObjectIdGetDatum(arg2->lower)));
} }
Datum Datum

View File

@ -192,7 +192,7 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
*result = 0.0; *result = 0.0;
if (DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul))) if (DatumGetBool(DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul))))
{ {
*result += FLT_MIN; *result += FLT_MIN;
os = DatumGetNumeric(DirectFunctionCall2(numeric_div, os = DatumGetNumeric(DirectFunctionCall2(numeric_div,

View File

@ -119,38 +119,38 @@ gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
switch (tinfo->t) switch (tinfo->t)
{ {
case gbt_t_bool: case gbt_t_bool:
datum = BoolGetDatum(*(bool *) entry->key); datum = BoolGetDatum(*(bool *) DatumGetPointer(entry->key));
break; break;
case gbt_t_int2: case gbt_t_int2:
datum = Int16GetDatum(*(int16 *) entry->key); datum = Int16GetDatum(*(int16 *) DatumGetPointer(entry->key));
break; break;
case gbt_t_int4: case gbt_t_int4:
datum = Int32GetDatum(*(int32 *) entry->key); datum = Int32GetDatum(*(int32 *) DatumGetPointer(entry->key));
break; break;
case gbt_t_int8: case gbt_t_int8:
datum = Int64GetDatum(*(int64 *) entry->key); datum = Int64GetDatum(*(int64 *) DatumGetPointer(entry->key));
break; break;
case gbt_t_oid: case gbt_t_oid:
case gbt_t_enum: case gbt_t_enum:
datum = ObjectIdGetDatum(*(Oid *) entry->key); datum = ObjectIdGetDatum(*(Oid *) DatumGetPointer(entry->key));
break; break;
case gbt_t_float4: case gbt_t_float4:
datum = Float4GetDatum(*(float4 *) entry->key); datum = Float4GetDatum(*(float4 *) DatumGetPointer(entry->key));
break; break;
case gbt_t_float8: case gbt_t_float8:
datum = Float8GetDatum(*(float8 *) entry->key); datum = Float8GetDatum(*(float8 *) DatumGetPointer(entry->key));
break; break;
case gbt_t_date: case gbt_t_date:
datum = DateADTGetDatum(*(DateADT *) entry->key); datum = DateADTGetDatum(*(DateADT *) DatumGetPointer(entry->key));
break; break;
case gbt_t_time: case gbt_t_time:
datum = TimeADTGetDatum(*(TimeADT *) entry->key); datum = TimeADTGetDatum(*(TimeADT *) DatumGetPointer(entry->key));
break; break;
case gbt_t_ts: case gbt_t_ts:
datum = TimestampGetDatum(*(Timestamp *) entry->key); datum = TimestampGetDatum(*(Timestamp *) DatumGetPointer(entry->key));
break; break;
case gbt_t_cash: case gbt_t_cash:
datum = CashGetDatum(*(Cash *) entry->key); datum = CashGetDatum(*(Cash *) DatumGetPointer(entry->key));
break; break;
default: default:
datum = entry->key; datum = entry->key;

View File

@ -108,7 +108,7 @@ _int_overlap(PG_FUNCTION_ARGS)
CHECKARRVALID(a); CHECKARRVALID(a);
CHECKARRVALID(b); CHECKARRVALID(b);
if (ARRISEMPTY(a) || ARRISEMPTY(b)) if (ARRISEMPTY(a) || ARRISEMPTY(b))
return false; PG_RETURN_BOOL(false);
SORT(a); SORT(a);
SORT(b); SORT(b);

View File

@ -256,7 +256,7 @@ heap_page_items(PG_FUNCTION_ARGS)
nulls[11] = true; nulls[11] = true;
if (tuphdr->t_infomask & HEAP_HASOID_OLD) if (tuphdr->t_infomask & HEAP_HASOID_OLD)
values[12] = HeapTupleHeaderGetOidOld(tuphdr); values[12] = ObjectIdGetDatum(HeapTupleHeaderGetOidOld(tuphdr));
else else
nulls[12] = true; nulls[12] = true;

View File

@ -141,8 +141,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
*/ */
if (htsu == TM_BeingModified) if (htsu == TM_BeingModified)
{ {
values[Atnum_tid] = (char *) DirectFunctionCall1(tidout, values[Atnum_tid] = DatumGetCString(DirectFunctionCall1(tidout,
PointerGetDatum(&tuple->t_self)); PointerGetDatum(&tuple->t_self)));
values[Atnum_xmax] = palloc(NCHARS * sizeof(char)); values[Atnum_xmax] = palloc(NCHARS * sizeof(char));
snprintf(values[Atnum_xmax], NCHARS, "%u", xmax); snprintf(values[Atnum_xmax], NCHARS, "%u", xmax);

View File

@ -417,7 +417,7 @@ gseg_same(PG_FUNCTION_ARGS)
{ {
bool *result = (bool *) PG_GETARG_POINTER(2); bool *result = (bool *) PG_GETARG_POINTER(2);
if (DirectFunctionCall2(seg_same, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1))) if (DatumGetBool(DirectFunctionCall2(seg_same, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1))))
*result = true; *result = true;
else else
*result = false; *result = false;
@ -470,7 +470,7 @@ gseg_leaf_consistent(Datum key, Datum query, StrategyNumber strategy)
retval = DirectFunctionCall2(seg_contained, key, query); retval = DirectFunctionCall2(seg_contained, key, query);
break; break;
default: default:
retval = false; retval = BoolGetDatum(false);
} }
PG_RETURN_DATUM(retval); PG_RETURN_DATUM(retval);

View File

@ -1608,7 +1608,7 @@ brin_build_desc(Relation rel)
opcInfoFn = index_getprocinfo(rel, keyno + 1, BRIN_PROCNUM_OPCINFO); opcInfoFn = index_getprocinfo(rel, keyno + 1, BRIN_PROCNUM_OPCINFO);
opcinfo[keyno] = (BrinOpcInfo *) opcinfo[keyno] = (BrinOpcInfo *)
DatumGetPointer(FunctionCall1(opcInfoFn, attr->atttypid)); DatumGetPointer(FunctionCall1(opcInfoFn, ObjectIdGetDatum(attr->atttypid)));
totalstored += opcinfo[keyno]->oi_nstored; totalstored += opcinfo[keyno]->oi_nstored;
} }
@ -2262,7 +2262,7 @@ add_values_to_range(Relation idxRel, BrinDesc *bdesc, BrinMemTuple *dtup,
PointerGetDatum(bdesc), PointerGetDatum(bdesc),
PointerGetDatum(bval), PointerGetDatum(bval),
values[keyno], values[keyno],
nulls[keyno]); BoolGetDatum(nulls[keyno]));
/* if that returned true, we need to insert the updated tuple */ /* if that returned true, we need to insert the updated tuple */
modified |= DatumGetBool(result); modified |= DatumGetBool(result);

View File

@ -540,7 +540,7 @@ brin_bloom_add_value(PG_FUNCTION_ARGS)
BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0); BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1); BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
Datum newval = PG_GETARG_DATUM(2); Datum newval = PG_GETARG_DATUM(2);
bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_DATUM(3); bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_BOOL(3);
BloomOptions *opts = (BloomOptions *) PG_GET_OPCLASS_OPTIONS(); BloomOptions *opts = (BloomOptions *) PG_GET_OPCLASS_OPTIONS();
Oid colloid = PG_GET_COLLATION(); Oid colloid = PG_GET_COLLATION();
FmgrInfo *hashFn; FmgrInfo *hashFn;

View File

@ -66,7 +66,7 @@ brin_minmax_add_value(PG_FUNCTION_ARGS)
BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0); BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1); BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
Datum newval = PG_GETARG_DATUM(2); Datum newval = PG_GETARG_DATUM(2);
bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_DATUM(3); bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_BOOL(3);
Oid colloid = PG_GET_COLLATION(); Oid colloid = PG_GET_COLLATION();
FmgrInfo *cmpFn; FmgrInfo *cmpFn;
Datum compar; Datum compar;
@ -225,8 +225,8 @@ brin_minmax_union(PG_FUNCTION_ARGS)
/* Adjust minimum, if B's min is less than A's min */ /* Adjust minimum, if B's min is less than A's min */
finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid, finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
BTLessStrategyNumber); BTLessStrategyNumber);
needsadj = FunctionCall2Coll(finfo, colloid, col_b->bv_values[0], needsadj = DatumGetBool(FunctionCall2Coll(finfo, colloid, col_b->bv_values[0],
col_a->bv_values[0]); col_a->bv_values[0]));
if (needsadj) if (needsadj)
{ {
if (!attr->attbyval) if (!attr->attbyval)
@ -238,8 +238,8 @@ brin_minmax_union(PG_FUNCTION_ARGS)
/* Adjust maximum, if B's max is greater than A's max */ /* Adjust maximum, if B's max is greater than A's max */
finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid, finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
BTGreaterStrategyNumber); BTGreaterStrategyNumber);
needsadj = FunctionCall2Coll(finfo, colloid, col_b->bv_values[1], needsadj = DatumGetBool(FunctionCall2Coll(finfo, colloid, col_b->bv_values[1],
col_a->bv_values[1]); col_a->bv_values[1]));
if (needsadj) if (needsadj)
{ {
if (!attr->attbyval) if (!attr->attbyval)

View File

@ -1992,8 +1992,8 @@ brin_minmax_multi_distance_tid(PG_FUNCTION_ARGS)
double da1, double da1,
da2; da2;
ItemPointer pa1 = (ItemPointer) PG_GETARG_DATUM(0); ItemPointer pa1 = (ItemPointer) PG_GETARG_POINTER(0);
ItemPointer pa2 = (ItemPointer) PG_GETARG_DATUM(1); ItemPointer pa2 = (ItemPointer) PG_GETARG_POINTER(1);
/* /*
* We know the values are range boundaries, but the range may be collapsed * We know the values are range boundaries, but the range may be collapsed
@ -2414,7 +2414,7 @@ brin_minmax_multi_add_value(PG_FUNCTION_ARGS)
BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0); BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1); BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
Datum newval = PG_GETARG_DATUM(2); Datum newval = PG_GETARG_DATUM(2);
bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_DATUM(3); bool isnull PG_USED_FOR_ASSERTS_ONLY = PG_GETARG_BOOL(3);
MinMaxMultiOptions *opts = (MinMaxMultiOptions *) PG_GET_OPCLASS_OPTIONS(); MinMaxMultiOptions *opts = (MinMaxMultiOptions *) PG_GET_OPCLASS_OPTIONS();
Oid colloid = PG_GET_COLLATION(); Oid colloid = PG_GET_COLLATION();
bool modified = false; bool modified = false;

View File

@ -105,7 +105,7 @@ missing_hash(const void *key, Size keysize)
{ {
const missing_cache_key *entry = (missing_cache_key *) key; const missing_cache_key *entry = (missing_cache_key *) key;
return hash_bytes((const unsigned char *) entry->value, entry->len); return hash_bytes((const unsigned char *) DatumGetPointer(entry->value), entry->len);
} }
static int static int

View File

@ -64,11 +64,11 @@ toast_compress_datum(Datum value, char cmethod)
switch (cmethod) switch (cmethod)
{ {
case TOAST_PGLZ_COMPRESSION: case TOAST_PGLZ_COMPRESSION:
tmp = pglz_compress_datum((const struct varlena *) value); tmp = pglz_compress_datum((const struct varlena *) DatumGetPointer(value));
cmid = TOAST_PGLZ_COMPRESSION_ID; cmid = TOAST_PGLZ_COMPRESSION_ID;
break; break;
case TOAST_LZ4_COMPRESSION: case TOAST_LZ4_COMPRESSION:
tmp = lz4_compress_datum((const struct varlena *) value); tmp = lz4_compress_datum((const struct varlena *) DatumGetPointer(value));
cmid = TOAST_LZ4_COMPRESSION_ID; cmid = TOAST_LZ4_COMPRESSION_ID;
break; break;
default: default:

View File

@ -4283,8 +4283,8 @@ pg_identify_object(PG_FUNCTION_ARGS)
nspAttnum = get_object_attnum_namespace(address.classId); nspAttnum = get_object_attnum_namespace(address.classId);
if (nspAttnum != InvalidAttrNumber) if (nspAttnum != InvalidAttrNumber)
{ {
schema_oid = heap_getattr(objtup, nspAttnum, schema_oid = DatumGetObjectId(heap_getattr(objtup, nspAttnum,
RelationGetDescr(catalog), &isnull); RelationGetDescr(catalog), &isnull));
if (isnull) if (isnull)
elog(ERROR, "invalid null namespace in object %u/%u/%d", elog(ERROR, "invalid null namespace in object %u/%u/%d",
address.classId, address.objectId, address.objectSubId); address.classId, address.objectId, address.objectSubId);

View File

@ -1212,6 +1212,6 @@ oid_array_to_list(Datum datum)
deconstruct_array_builtin(array, OIDOID, &values, NULL, &nelems); deconstruct_array_builtin(array, OIDOID, &values, NULL, &nelems);
for (i = 0; i < nelems; i++) for (i = 0; i < nelems; i++)
result = lappend_oid(result, values[i]); result = lappend_oid(result, DatumGetObjectId(values[i]));
return result; return result;
} }

View File

@ -1001,7 +1001,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
ScanKeyInit(&key[0], ScanKeyInit(&key[0],
Anum_pg_class_relnamespace, Anum_pg_class_relnamespace,
BTEqualStrategyNumber, F_OIDEQ, BTEqualStrategyNumber, F_OIDEQ,
schemaid); ObjectIdGetDatum(schemaid));
/* get all the relations present in the specified schema */ /* get all the relations present in the specified schema */
scan = table_beginscan_catalog(classRel, 1, key); scan = table_beginscan_catalog(classRel, 1, key);

View File

@ -956,12 +956,12 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
shdep = (Form_pg_shdepend) GETSTRUCT(tup); shdep = (Form_pg_shdepend) GETSTRUCT(tup);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId); slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = ObjectIdGetDatum(shdep->classid);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid - 1] = shdep->objid; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid - 1] = ObjectIdGetDatum(shdep->objid);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid - 1] = shdep->objsubid; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid - 1] = Int32GetDatum(shdep->objsubid);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid - 1] = shdep->refclassid; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid - 1] = ObjectIdGetDatum(shdep->refclassid);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid - 1] = shdep->refobjid; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid - 1] = ObjectIdGetDatum(shdep->refobjid);
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype - 1] = shdep->deptype; slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype - 1] = CharGetDatum(shdep->deptype);
ExecStoreVirtualTuple(slot[slot_stored_count]); ExecStoreVirtualTuple(slot[slot_stored_count]);
slot_stored_count++; slot_stored_count++;

View File

@ -2021,8 +2021,8 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
elog(ERROR, "cache lookup failed for object %u/%u", elog(ERROR, "cache lookup failed for object %u/%u",
addr.classId, addr.objectId); addr.classId, addr.objectId);
schema_oid = schema_oid =
heap_getattr(objtup, nspAttnum, DatumGetObjectId(heap_getattr(objtup, nspAttnum,
RelationGetDescr(catalog), &isnull); RelationGetDescr(catalog), &isnull));
if (isnull) if (isnull)
elog(ERROR, elog(ERROR,
"invalid null namespace in object %u/%u/%d", "invalid null namespace in object %u/%u/%d",

View File

@ -638,7 +638,7 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
/* Check if name is used */ /* Check if name is used */
subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid, subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
MyDatabaseId, CStringGetDatum(stmt->subname)); ObjectIdGetDatum(MyDatabaseId), CStringGetDatum(stmt->subname));
if (OidIsValid(subid)) if (OidIsValid(subid))
{ {
ereport(ERROR, ereport(ERROR,
@ -1185,7 +1185,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
rel = table_open(SubscriptionRelationId, RowExclusiveLock); rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Fetch the existing tuple. */ /* Fetch the existing tuple. */
tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId, tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, ObjectIdGetDatum(MyDatabaseId),
CStringGetDatum(stmt->subname)); CStringGetDatum(stmt->subname));
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
@ -1808,7 +1808,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
*/ */
rel = table_open(SubscriptionRelationId, AccessExclusiveLock); rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
tup = SearchSysCache2(SUBSCRIPTIONNAME, MyDatabaseId, tup = SearchSysCache2(SUBSCRIPTIONNAME, ObjectIdGetDatum(MyDatabaseId),
CStringGetDatum(stmt->subname)); CStringGetDatum(stmt->subname));
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
@ -2193,7 +2193,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
rel = table_open(SubscriptionRelationId, RowExclusiveLock); rel = table_open(SubscriptionRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, MyDatabaseId, tup = SearchSysCacheCopy2(SUBSCRIPTIONNAME, ObjectIdGetDatum(MyDatabaseId),
CStringGetDatum(name)); CStringGetDatum(name));
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))

View File

@ -8985,7 +8985,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa
memset(repl_null, false, sizeof(repl_null)); memset(repl_null, false, sizeof(repl_null));
memset(repl_repl, false, sizeof(repl_repl)); memset(repl_repl, false, sizeof(repl_repl));
if (!newtarget_default) if (!newtarget_default)
repl_val[Anum_pg_attribute_attstattarget - 1] = newtarget; repl_val[Anum_pg_attribute_attstattarget - 1] = Int16GetDatum(newtarget);
else else
repl_null[Anum_pg_attribute_attstattarget - 1] = true; repl_null[Anum_pg_attribute_attstattarget - 1] = true;
repl_repl[Anum_pg_attribute_attstattarget - 1] = true; repl_repl[Anum_pg_attribute_attstattarget - 1] = true;

View File

@ -872,7 +872,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
CStringGetDatum(trigname)); CStringGetDatum(trigname));
values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid); values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid);
values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
values[Anum_pg_trigger_tgenabled - 1] = trigger_fires_when; values[Anum_pg_trigger_tgenabled - 1] = CharGetDatum(trigger_fires_when);
values[Anum_pg_trigger_tgisinternal - 1] = BoolGetDatum(isInternal); values[Anum_pg_trigger_tgisinternal - 1] = BoolGetDatum(isInternal);
values[Anum_pg_trigger_tgconstrrelid - 1] = ObjectIdGetDatum(constrrelid); values[Anum_pg_trigger_tgconstrrelid - 1] = ObjectIdGetDatum(constrrelid);
values[Anum_pg_trigger_tgconstrindid - 1] = ObjectIdGetDatum(indexOid); values[Anum_pg_trigger_tgconstrindid - 1] = ObjectIdGetDatum(indexOid);

View File

@ -1058,10 +1058,10 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
memset(slot[slot_stored_count]->tts_isnull, false, memset(slot[slot_stored_count]->tts_isnull, false,
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool)); slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapcfg - 1] = cfgOid; slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapcfg - 1] = ObjectIdGetDatum(cfgOid);
slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_maptokentype - 1] = cfgmap->maptokentype; slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_maptokentype - 1] = Int32GetDatum(cfgmap->maptokentype);
slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapseqno - 1] = cfgmap->mapseqno; slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapseqno - 1] = Int32GetDatum(cfgmap->mapseqno);
slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapdict - 1] = cfgmap->mapdict; slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapdict - 1] = ObjectIdGetDatum(cfgmap->mapdict);
ExecStoreVirtualTuple(slot[slot_stored_count]); ExecStoreVirtualTuple(slot[slot_stored_count]);
slot_stored_count++; slot_stored_count++;

View File

@ -1924,7 +1924,7 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid roleid,
*/ */
if ((popt->specified & GRANT_ROLE_SPECIFIED_INHERIT) != 0) if ((popt->specified & GRANT_ROLE_SPECIFIED_INHERIT) != 0)
new_record[Anum_pg_auth_members_inherit_option - 1] = new_record[Anum_pg_auth_members_inherit_option - 1] =
popt->inherit; BoolGetDatum(popt->inherit);
else else
{ {
HeapTuple mrtup; HeapTuple mrtup;
@ -1935,14 +1935,14 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid roleid,
elog(ERROR, "cache lookup failed for role %u", memberid); elog(ERROR, "cache lookup failed for role %u", memberid);
mrform = (Form_pg_authid) GETSTRUCT(mrtup); mrform = (Form_pg_authid) GETSTRUCT(mrtup);
new_record[Anum_pg_auth_members_inherit_option - 1] = new_record[Anum_pg_auth_members_inherit_option - 1] =
mrform->rolinherit; BoolGetDatum(mrform->rolinherit);
ReleaseSysCache(mrtup); ReleaseSysCache(mrtup);
} }
/* get an OID for the new row and insert it */ /* get an OID for the new row and insert it */
objectId = GetNewOidWithIndex(pg_authmem_rel, AuthMemOidIndexId, objectId = GetNewOidWithIndex(pg_authmem_rel, AuthMemOidIndexId,
Anum_pg_auth_members_oid); Anum_pg_auth_members_oid);
new_record[Anum_pg_auth_members_oid - 1] = objectId; new_record[Anum_pg_auth_members_oid - 1] = ObjectIdGetDatum(objectId);
tuple = heap_form_tuple(pg_authmem_dsc, tuple = heap_form_tuple(pg_authmem_dsc,
new_record, new_record_nulls); new_record, new_record_nulls);
CatalogTupleInsert(pg_authmem_rel, tuple); CatalogTupleInsert(pg_authmem_rel, tuple);

View File

@ -4393,7 +4393,7 @@ ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op, ExprContext *eco
* is the equality function and we need not-equals. * is the equality function and we need not-equals.
*/ */
if (!inclause) if (!inclause)
result = !result; result = BoolGetDatum(!DatumGetBool(result));
} }
} }

View File

@ -339,7 +339,7 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
starel = table_open(StatisticRelationId, RowExclusiveLock); starel = table_open(StatisticRelationId, RowExclusiveLock);
statup = SearchSysCache3(STATRELATTINH, reloid, attnum, inherited); statup = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(reloid), Int16GetDatum(attnum), BoolGetDatum(inherited));
/* initialize from existing tuple if exists */ /* initialize from existing tuple if exists */
if (HeapTupleIsValid(statup)) if (HeapTupleIsValid(statup))
@ -895,9 +895,9 @@ init_empty_stats_tuple(Oid reloid, int16 attnum, bool inherited,
{ {
values[Anum_pg_statistic_stakind1 + slotnum - 1] = (Datum) 0; values[Anum_pg_statistic_stakind1 + slotnum - 1] = (Datum) 0;
nulls[Anum_pg_statistic_stakind1 + slotnum - 1] = false; nulls[Anum_pg_statistic_stakind1 + slotnum - 1] = false;
values[Anum_pg_statistic_staop1 + slotnum - 1] = InvalidOid; values[Anum_pg_statistic_staop1 + slotnum - 1] = ObjectIdGetDatum(InvalidOid);
nulls[Anum_pg_statistic_staop1 + slotnum - 1] = false; nulls[Anum_pg_statistic_staop1 + slotnum - 1] = false;
values[Anum_pg_statistic_stacoll1 + slotnum - 1] = InvalidOid; values[Anum_pg_statistic_stacoll1 + slotnum - 1] = ObjectIdGetDatum(InvalidOid);
nulls[Anum_pg_statistic_stacoll1 + slotnum - 1] = false; nulls[Anum_pg_statistic_stacoll1 + slotnum - 1] = false;
} }
} }

View File

@ -152,7 +152,7 @@ retry:
nulls[0] = false; nulls[0] = false;
/* column: IO's id */ /* column: IO's id */
values[1] = ioh_id; values[1] = UInt32GetDatum(ioh_id);
/* column: IO's generation */ /* column: IO's generation */
values[2] = Int64GetDatum(start_generation); values[2] = Int64GetDatum(start_generation);

View File

@ -6365,8 +6365,8 @@ ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b)
static int static int
ts_ckpt_progress_comparator(Datum a, Datum b, void *arg) ts_ckpt_progress_comparator(Datum a, Datum b, void *arg)
{ {
CkptTsStatus *sa = (CkptTsStatus *) a; CkptTsStatus *sa = (CkptTsStatus *) DatumGetPointer(a);
CkptTsStatus *sb = (CkptTsStatus *) b; CkptTsStatus *sb = (CkptTsStatus *) DatumGetPointer(b);
/* we want a min-heap, so return 1 for the a < b */ /* we want a min-heap, so return 1 for the a < b */
if (sa->progress < sb->progress) if (sa->progress < sb->progress)

View File

@ -714,7 +714,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
for (i = 0; i <= max_nodes; i++) for (i = 0; i <= max_nodes; i++)
{ {
values[0] = CStringGetTextDatum(ent->key); values[0] = CStringGetTextDatum(ent->key);
values[1] = i; values[1] = Int32GetDatum(i);
values[2] = Int64GetDatum(nodes[i] * os_page_size); values[2] = Int64GetDatum(nodes[i] * os_page_size);
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc,

View File

@ -589,7 +589,7 @@ proclock_hash(const void *key, Size keysize)
* intermediate variable to suppress cast-pointer-to-int warnings. * intermediate variable to suppress cast-pointer-to-int warnings.
*/ */
procptr = PointerGetDatum(proclocktag->myProc); procptr = PointerGetDatum(proclocktag->myProc);
lockhash ^= ((uint32) procptr) << LOG2_NUM_LOCK_PARTITIONS; lockhash ^= DatumGetUInt32(procptr) << LOG2_NUM_LOCK_PARTITIONS;
return lockhash; return lockhash;
} }
@ -610,7 +610,7 @@ ProcLockHashCode(const PROCLOCKTAG *proclocktag, uint32 hashcode)
* This must match proclock_hash()! * This must match proclock_hash()!
*/ */
procptr = PointerGetDatum(proclocktag->myProc); procptr = PointerGetDatum(proclocktag->myProc);
lockhash ^= ((uint32) procptr) << LOG2_NUM_LOCK_PARTITIONS; lockhash ^= DatumGetUInt32(procptr) << LOG2_NUM_LOCK_PARTITIONS;
return lockhash; return lockhash;
} }

View File

@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
len1 - VARHDRSZ) == 0); len1 - VARHDRSZ) == 0);
/* Only free memory if it's a copy made here. */ /* Only free memory if it's a copy made here. */
if ((Pointer) arg1val != (Pointer) value1) if ((Pointer) arg1val != DatumGetPointer(value1))
pfree(arg1val); pfree(arg1val);
if ((Pointer) arg2val != (Pointer) value2) if ((Pointer) arg2val != DatumGetPointer(value2))
pfree(arg2val); pfree(arg2val);
} }
} }
@ -355,7 +355,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen)
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ); result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
/* Only free memory if it's a copy made here. */ /* Only free memory if it's a copy made here. */
if ((Pointer) val != (Pointer) value) if ((Pointer) val != DatumGetPointer(value))
pfree(val); pfree(val);
} }
else if (typLen == -2) else if (typLen == -2)

View File

@ -1517,7 +1517,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
/* Convert numstr to Numeric with typmod */ /* Convert numstr to Numeric with typmod */
Assert(numstr != NULL); Assert(numstr != NULL);
noerr = DirectInputFunctionCallSafe(numeric_in, numstr, noerr = DirectInputFunctionCallSafe(numeric_in, numstr,
InvalidOid, dtypmod, InvalidOid, DatumGetInt32(dtypmod),
(Node *) &escontext, (Node *) &escontext,
&numdatum); &numdatum);

View File

@ -398,15 +398,15 @@ pg_lock_status(PG_FUNCTION_ARGS)
values[0] = CStringGetTextDatum(PredicateLockTagTypeNames[lockType]); values[0] = CStringGetTextDatum(PredicateLockTagTypeNames[lockType]);
/* lock target */ /* lock target */
values[1] = GET_PREDICATELOCKTARGETTAG_DB(*predTag); values[1] = ObjectIdGetDatum(GET_PREDICATELOCKTARGETTAG_DB(*predTag));
values[2] = GET_PREDICATELOCKTARGETTAG_RELATION(*predTag); values[2] = ObjectIdGetDatum(GET_PREDICATELOCKTARGETTAG_RELATION(*predTag));
if (lockType == PREDLOCKTAG_TUPLE) if (lockType == PREDLOCKTAG_TUPLE)
values[4] = GET_PREDICATELOCKTARGETTAG_OFFSET(*predTag); values[4] = UInt16GetDatum(GET_PREDICATELOCKTARGETTAG_OFFSET(*predTag));
else else
nulls[4] = true; nulls[4] = true;
if ((lockType == PREDLOCKTAG_TUPLE) || if ((lockType == PREDLOCKTAG_TUPLE) ||
(lockType == PREDLOCKTAG_PAGE)) (lockType == PREDLOCKTAG_PAGE))
values[3] = GET_PREDICATELOCKTARGETTAG_PAGE(*predTag); values[3] = UInt32GetDatum(GET_PREDICATELOCKTARGETTAG_PAGE(*predTag));
else else
nulls[3] = true; nulls[3] = true;

View File

@ -2523,7 +2523,7 @@ multirange_adjacent_range(PG_FUNCTION_ARGS)
TypeCacheEntry *typcache; TypeCacheEntry *typcache;
if (RangeIsEmpty(r) || MultirangeIsEmpty(mr)) if (RangeIsEmpty(r) || MultirangeIsEmpty(mr))
return false; PG_RETURN_BOOL(false);
typcache = multirange_get_typcache(fcinfo, MultirangeTypeGetOid(mr)); typcache = multirange_get_typcache(fcinfo, MultirangeTypeGetOid(mr));
@ -2544,7 +2544,7 @@ multirange_adjacent_multirange(PG_FUNCTION_ARGS)
upper2; upper2;
if (MultirangeIsEmpty(mr1) || MultirangeIsEmpty(mr2)) if (MultirangeIsEmpty(mr1) || MultirangeIsEmpty(mr2))
return false; PG_RETURN_BOOL(false);
typcache = multirange_get_typcache(fcinfo, MultirangeTypeGetOid(mr1)); typcache = multirange_get_typcache(fcinfo, MultirangeTypeGetOid(mr1));
@ -2639,7 +2639,7 @@ multirange_cmp(PG_FUNCTION_ARGS)
Datum Datum
multirange_lt(PG_FUNCTION_ARGS) multirange_lt(PG_FUNCTION_ARGS)
{ {
int cmp = multirange_cmp(fcinfo); int cmp = DatumGetInt32(multirange_cmp(fcinfo));
PG_RETURN_BOOL(cmp < 0); PG_RETURN_BOOL(cmp < 0);
} }
@ -2647,7 +2647,7 @@ multirange_lt(PG_FUNCTION_ARGS)
Datum Datum
multirange_le(PG_FUNCTION_ARGS) multirange_le(PG_FUNCTION_ARGS)
{ {
int cmp = multirange_cmp(fcinfo); int cmp = DatumGetInt32(multirange_cmp(fcinfo));
PG_RETURN_BOOL(cmp <= 0); PG_RETURN_BOOL(cmp <= 0);
} }
@ -2655,7 +2655,7 @@ multirange_le(PG_FUNCTION_ARGS)
Datum Datum
multirange_ge(PG_FUNCTION_ARGS) multirange_ge(PG_FUNCTION_ARGS)
{ {
int cmp = multirange_cmp(fcinfo); int cmp = DatumGetInt32(multirange_cmp(fcinfo));
PG_RETURN_BOOL(cmp >= 0); PG_RETURN_BOOL(cmp >= 0);
} }
@ -2663,7 +2663,7 @@ multirange_ge(PG_FUNCTION_ARGS)
Datum Datum
multirange_gt(PG_FUNCTION_ARGS) multirange_gt(PG_FUNCTION_ARGS)
{ {
int cmp = multirange_cmp(fcinfo); int cmp = DatumGetInt32(multirange_cmp(fcinfo));
PG_RETURN_BOOL(cmp > 0); PG_RETURN_BOOL(cmp > 0);
} }

View File

@ -1356,7 +1356,7 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
Datum Datum
range_lt(PG_FUNCTION_ARGS) range_lt(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = DatumGetInt32(range_cmp(fcinfo));
PG_RETURN_BOOL(cmp < 0); PG_RETURN_BOOL(cmp < 0);
} }
@ -1364,7 +1364,7 @@ range_lt(PG_FUNCTION_ARGS)
Datum Datum
range_le(PG_FUNCTION_ARGS) range_le(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = DatumGetInt32(range_cmp(fcinfo));
PG_RETURN_BOOL(cmp <= 0); PG_RETURN_BOOL(cmp <= 0);
} }
@ -1372,7 +1372,7 @@ range_le(PG_FUNCTION_ARGS)
Datum Datum
range_ge(PG_FUNCTION_ARGS) range_ge(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = DatumGetInt32(range_cmp(fcinfo));
PG_RETURN_BOOL(cmp >= 0); PG_RETURN_BOOL(cmp >= 0);
} }
@ -1380,7 +1380,7 @@ range_ge(PG_FUNCTION_ARGS)
Datum Datum
range_gt(PG_FUNCTION_ARGS) range_gt(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = DatumGetInt32(range_cmp(fcinfo));
PG_RETURN_BOOL(cmp > 0); PG_RETURN_BOOL(cmp > 0);
} }

View File

@ -757,7 +757,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
* because it's range * because it's range
*/ */
previousCentroid = datumCopy(in->prefixDatum, false, -1); previousCentroid = datumCopy(in->prefixDatum, false, -1);
out->traversalValues[out->nNodes] = (void *) previousCentroid; out->traversalValues[out->nNodes] = DatumGetPointer(previousCentroid);
} }
out->nodeNumbers[out->nNodes] = i - 1; out->nodeNumbers[out->nNodes] = i - 1;
out->nNodes++; out->nNodes++;

View File

@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
if ((cmpresult == 0) && (len1 != len2)) if ((cmpresult == 0) && (len1 != len2))
cmpresult = (len1 < len2) ? -1 : 1; cmpresult = (len1 < len2) ? -1 : 1;
if ((Pointer) arg1val != (Pointer) values1[i1]) if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
pfree(arg1val); pfree(arg1val);
if ((Pointer) arg2val != (Pointer) values2[i2]) if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
pfree(arg2val); pfree(arg2val);
} }
else else

View File

@ -73,7 +73,7 @@ pg_isolation_test_session_is_blocked(PG_FUNCTION_ARGS)
* acquire heavyweight locks. * acquire heavyweight locks.
*/ */
blocking_pids_a = blocking_pids_a =
DatumGetArrayTypeP(DirectFunctionCall1(pg_blocking_pids, blocked_pid)); DatumGetArrayTypeP(DirectFunctionCall1(pg_blocking_pids, Int32GetDatum(blocked_pid)));
Assert(ARR_ELEMTYPE(blocking_pids_a) == INT4OID); Assert(ARR_ELEMTYPE(blocking_pids_a) == INT4OID);
Assert(!array_contains_nulls(blocking_pids_a)); Assert(!array_contains_nulls(blocking_pids_a));

View File

@ -86,7 +86,7 @@ relatt_cache_syshash(const void *key, Size keysize)
const AttoptCacheKey *ckey = key; const AttoptCacheKey *ckey = key;
Assert(keysize == sizeof(*ckey)); Assert(keysize == sizeof(*ckey));
return GetSysCacheHashValue2(ATTNUM, ckey->attrelid, ckey->attnum); return GetSysCacheHashValue2(ATTNUM, ObjectIdGetDatum(ckey->attrelid), Int32GetDatum(ckey->attnum));
} }
/* /*

View File

@ -3817,7 +3817,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
Oid oid; Oid oid;
oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid, oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
MyDatabaseId, CStringGetDatum(subname)); ObjectIdGetDatum(MyDatabaseId), CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok) if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),

View File

@ -6991,5 +6991,5 @@ ResOwnerReleaseRelation(Datum res)
Assert(rel->rd_refcnt > 0); Assert(rel->rd_refcnt > 0);
rel->rd_refcnt -= 1; rel->rd_refcnt -= 1;
RelationCloseCleanup((Relation) res); RelationCloseCleanup((Relation) DatumGetPointer(res));
} }

View File

@ -459,9 +459,9 @@ GetSysCacheOid(int cacheId,
tuple = SearchSysCache(cacheId, key1, key2, key3, key4); tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
return InvalidOid; return InvalidOid;
result = heap_getattr(tuple, oidcol, result = DatumGetObjectId(heap_getattr(tuple, oidcol,
SysCache[cacheId]->cc_tupdesc, SysCache[cacheId]->cc_tupdesc,
&isNull); &isNull));
Assert(!isNull); /* columns used as oids should never be NULL */ Assert(!isNull); /* columns used as oids should never be NULL */
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
return result; return result;

View File

@ -57,7 +57,7 @@ comparison_shim(Datum x, Datum y, SortSupport ssup)
if (extra->fcinfo.isnull) if (extra->fcinfo.isnull)
elog(ERROR, "function %u returned NULL", extra->flinfo.fn_oid); elog(ERROR, "function %u returned NULL", extra->flinfo.fn_oid);
return result; return DatumGetInt32(result);
} }
/* /*

View File

@ -865,7 +865,7 @@ tuplesort_putbrintuple(Tuplesortstate *state, BrinTuple *tuple, Size size)
memcpy(&bstup->tuple, tuple, size); memcpy(&bstup->tuple, tuple, size);
stup.tuple = bstup; stup.tuple = bstup;
stup.datum1 = tuple->bt_blkno; stup.datum1 = UInt32GetDatum(tuple->bt_blkno);
stup.isnull1 = false; stup.isnull1 = false;
/* GetMemoryChunkSpace is not supported for bump contexts */ /* GetMemoryChunkSpace is not supported for bump contexts */
@ -1836,7 +1836,7 @@ removeabbrev_index_brin(Tuplesortstate *state, SortTuple *stups, int count)
BrinSortTuple *tuple; BrinSortTuple *tuple;
tuple = stups[i].tuple; tuple = stups[i].tuple;
stups[i].datum1 = tuple->tuple.bt_blkno; stups[i].datum1 = UInt32GetDatum(tuple->tuple.bt_blkno);
} }
} }
@ -1893,7 +1893,7 @@ readtup_index_brin(Tuplesortstate *state, SortTuple *stup,
stup->tuple = tuple; stup->tuple = tuple;
/* set up first-column key value, which is block number */ /* set up first-column key value, which is block number */
stup->datum1 = tuple->tuple.bt_blkno; stup->datum1 = UInt32GetDatum(tuple->tuple.bt_blkno);
} }
/* /*

View File

@ -1453,7 +1453,7 @@ plperl_sv_to_literal(SV *sv, char *fqtypename)
check_spi_usage_allowed(); check_spi_usage_allowed();
typid = DirectFunctionCall1(regtypein, CStringGetDatum(fqtypename)); typid = DatumGetObjectId(DirectFunctionCall1(regtypein, CStringGetDatum(fqtypename)));
if (!OidIsValid(typid)) if (!OidIsValid(typid))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
@ -2569,13 +2569,13 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
TriggerData *trigdata = ((TriggerData *) fcinfo->context); TriggerData *trigdata = ((TriggerData *) fcinfo->context);
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
retval = (Datum) trigdata->tg_trigtuple; retval = PointerGetDatum(trigdata->tg_trigtuple);
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
retval = (Datum) trigdata->tg_newtuple; retval = PointerGetDatum(trigdata->tg_newtuple);
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event)) else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
retval = (Datum) trigdata->tg_trigtuple; retval = PointerGetDatum(trigdata->tg_trigtuple);
else if (TRIGGER_FIRED_BY_TRUNCATE(trigdata->tg_event)) else if (TRIGGER_FIRED_BY_TRUNCATE(trigdata->tg_event))
retval = (Datum) trigdata->tg_trigtuple; retval = PointerGetDatum(trigdata->tg_trigtuple);
else else
retval = (Datum) 0; /* can this happen? */ retval = (Datum) 0; /* can this happen? */
} }

View File

@ -727,7 +727,7 @@ PG_FUNCTION_INFO_V1(is_catalog_text_unique_index_oid);
Datum Datum
is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS) is_catalog_text_unique_index_oid(PG_FUNCTION_ARGS)
{ {
return IsCatalogTextUniqueIndexOid(PG_GETARG_OID(0)); return BoolGetDatum(IsCatalogTextUniqueIndexOid(PG_GETARG_OID(0)));
} }
PG_FUNCTION_INFO_V1(test_support_func); PG_FUNCTION_INFO_V1(test_support_func);