1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +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:
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

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

View File

@@ -6365,8 +6365,8 @@ ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b)
static int
ts_ckpt_progress_comparator(Datum a, Datum b, void *arg)
{
CkptTsStatus *sa = (CkptTsStatus *) a;
CkptTsStatus *sb = (CkptTsStatus *) b;
CkptTsStatus *sa = (CkptTsStatus *) DatumGetPointer(a);
CkptTsStatus *sb = (CkptTsStatus *) DatumGetPointer(b);
/* we want a min-heap, so return 1 for the a < b */
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++)
{
values[0] = CStringGetTextDatum(ent->key);
values[1] = i;
values[1] = Int32GetDatum(i);
values[2] = Int64GetDatum(nodes[i] * os_page_size);
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.
*/
procptr = PointerGetDatum(proclocktag->myProc);
lockhash ^= ((uint32) procptr) << LOG2_NUM_LOCK_PARTITIONS;
lockhash ^= DatumGetUInt32(procptr) << LOG2_NUM_LOCK_PARTITIONS;
return lockhash;
}
@@ -610,7 +610,7 @@ ProcLockHashCode(const PROCLOCKTAG *proclocktag, uint32 hashcode)
* This must match proclock_hash()!
*/
procptr = PointerGetDatum(proclocktag->myProc);
lockhash ^= ((uint32) procptr) << LOG2_NUM_LOCK_PARTITIONS;
lockhash ^= DatumGetUInt32(procptr) << LOG2_NUM_LOCK_PARTITIONS;
return lockhash;
}