mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +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:
@@ -1608,7 +1608,7 @@ brin_build_desc(Relation rel)
|
||||
opcInfoFn = index_getprocinfo(rel, keyno + 1, BRIN_PROCNUM_OPCINFO);
|
||||
|
||||
opcinfo[keyno] = (BrinOpcInfo *)
|
||||
DatumGetPointer(FunctionCall1(opcInfoFn, attr->atttypid));
|
||||
DatumGetPointer(FunctionCall1(opcInfoFn, ObjectIdGetDatum(attr->atttypid)));
|
||||
totalstored += opcinfo[keyno]->oi_nstored;
|
||||
}
|
||||
|
||||
@@ -2262,7 +2262,7 @@ add_values_to_range(Relation idxRel, BrinDesc *bdesc, BrinMemTuple *dtup,
|
||||
PointerGetDatum(bdesc),
|
||||
PointerGetDatum(bval),
|
||||
values[keyno],
|
||||
nulls[keyno]);
|
||||
BoolGetDatum(nulls[keyno]));
|
||||
/* if that returned true, we need to insert the updated tuple */
|
||||
modified |= DatumGetBool(result);
|
||||
|
||||
|
||||
@@ -540,7 +540,7 @@ brin_bloom_add_value(PG_FUNCTION_ARGS)
|
||||
BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
|
||||
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
|
||||
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();
|
||||
Oid colloid = PG_GET_COLLATION();
|
||||
FmgrInfo *hashFn;
|
||||
|
||||
@@ -66,7 +66,7 @@ brin_minmax_add_value(PG_FUNCTION_ARGS)
|
||||
BrinDesc *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
|
||||
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
|
||||
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();
|
||||
FmgrInfo *cmpFn;
|
||||
Datum compar;
|
||||
@@ -225,8 +225,8 @@ brin_minmax_union(PG_FUNCTION_ARGS)
|
||||
/* Adjust minimum, if B's min is less than A's min */
|
||||
finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
|
||||
BTLessStrategyNumber);
|
||||
needsadj = FunctionCall2Coll(finfo, colloid, col_b->bv_values[0],
|
||||
col_a->bv_values[0]);
|
||||
needsadj = DatumGetBool(FunctionCall2Coll(finfo, colloid, col_b->bv_values[0],
|
||||
col_a->bv_values[0]));
|
||||
if (needsadj)
|
||||
{
|
||||
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 */
|
||||
finfo = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
|
||||
BTGreaterStrategyNumber);
|
||||
needsadj = FunctionCall2Coll(finfo, colloid, col_b->bv_values[1],
|
||||
col_a->bv_values[1]);
|
||||
needsadj = DatumGetBool(FunctionCall2Coll(finfo, colloid, col_b->bv_values[1],
|
||||
col_a->bv_values[1]));
|
||||
if (needsadj)
|
||||
{
|
||||
if (!attr->attbyval)
|
||||
|
||||
@@ -1992,8 +1992,8 @@ brin_minmax_multi_distance_tid(PG_FUNCTION_ARGS)
|
||||
double da1,
|
||||
da2;
|
||||
|
||||
ItemPointer pa1 = (ItemPointer) PG_GETARG_DATUM(0);
|
||||
ItemPointer pa2 = (ItemPointer) PG_GETARG_DATUM(1);
|
||||
ItemPointer pa1 = (ItemPointer) PG_GETARG_POINTER(0);
|
||||
ItemPointer pa2 = (ItemPointer) PG_GETARG_POINTER(1);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
|
||||
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();
|
||||
Oid colloid = PG_GET_COLLATION();
|
||||
bool modified = false;
|
||||
|
||||
@@ -105,7 +105,7 @@ missing_hash(const void *key, Size keysize)
|
||||
{
|
||||
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
|
||||
|
||||
@@ -64,11 +64,11 @@ toast_compress_datum(Datum value, char cmethod)
|
||||
switch (cmethod)
|
||||
{
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user