mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +03:00
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:
@@ -193,8 +193,8 @@ gbt_enum_ssup_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
return DatumGetInt32(CallerFInfoFunctionCall2(enum_cmp,
|
||||
ssup->ssup_extra,
|
||||
InvalidOid,
|
||||
arg1->lower,
|
||||
arg2->lower));
|
||||
ObjectIdGetDatum(arg1->lower),
|
||||
ObjectIdGetDatum(arg2->lower)));
|
||||
}
|
||||
|
||||
Datum
|
||||
|
@@ -192,7 +192,7 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
|
||||
|
||||
*result = 0.0;
|
||||
|
||||
if (DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul)))
|
||||
if (DatumGetBool(DirectFunctionCall2(numeric_gt, NumericGetDatum(ds), NumericGetDatum(nul))))
|
||||
{
|
||||
*result += FLT_MIN;
|
||||
os = DatumGetNumeric(DirectFunctionCall2(numeric_div,
|
||||
|
@@ -119,38 +119,38 @@ gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
|
||||
switch (tinfo->t)
|
||||
{
|
||||
case gbt_t_bool:
|
||||
datum = BoolGetDatum(*(bool *) entry->key);
|
||||
datum = BoolGetDatum(*(bool *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_int2:
|
||||
datum = Int16GetDatum(*(int16 *) entry->key);
|
||||
datum = Int16GetDatum(*(int16 *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_int4:
|
||||
datum = Int32GetDatum(*(int32 *) entry->key);
|
||||
datum = Int32GetDatum(*(int32 *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_int8:
|
||||
datum = Int64GetDatum(*(int64 *) entry->key);
|
||||
datum = Int64GetDatum(*(int64 *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_oid:
|
||||
case gbt_t_enum:
|
||||
datum = ObjectIdGetDatum(*(Oid *) entry->key);
|
||||
datum = ObjectIdGetDatum(*(Oid *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_float4:
|
||||
datum = Float4GetDatum(*(float4 *) entry->key);
|
||||
datum = Float4GetDatum(*(float4 *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_float8:
|
||||
datum = Float8GetDatum(*(float8 *) entry->key);
|
||||
datum = Float8GetDatum(*(float8 *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_date:
|
||||
datum = DateADTGetDatum(*(DateADT *) entry->key);
|
||||
datum = DateADTGetDatum(*(DateADT *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_time:
|
||||
datum = TimeADTGetDatum(*(TimeADT *) entry->key);
|
||||
datum = TimeADTGetDatum(*(TimeADT *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_ts:
|
||||
datum = TimestampGetDatum(*(Timestamp *) entry->key);
|
||||
datum = TimestampGetDatum(*(Timestamp *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
case gbt_t_cash:
|
||||
datum = CashGetDatum(*(Cash *) entry->key);
|
||||
datum = CashGetDatum(*(Cash *) DatumGetPointer(entry->key));
|
||||
break;
|
||||
default:
|
||||
datum = entry->key;
|
||||
|
Reference in New Issue
Block a user