Skip to content

Commit 665c3db

Browse files
committed
Mop-up for Datum conversion cleanups.
Fix a couple more places where an explicit Datum conversion is needed (not clear how we missed these in ff89e18 and previous commits). Replace the minority usage "(Datum) NULL" with "(Datum) 0". The former depends on the assumption that Datum is the same width as Pointer, the latter doesn't. Anyway consistency is a good thing. This is, I believe, the last of the notational mop-up needed before we can consider changing Datum to uint64 everywhere. It's also important cleanup for more aggressive ideas such as making Datum a struct. Discussion: https://postgr.es/m/1749799.1752797397@sss.pgh.pa.us Discussion: https://postgr.es/m/8246d7ff-f4b7-4363-913e-827dadfeb145@eisentraut.org
1 parent ff89e18 commit 665c3db

File tree

13 files changed

+17
-17
lines changed

13 files changed

+17
-17
lines changed

contrib/ltree/_ltree_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
8484
entry->rel, entry->page,
8585
entry->offset, false);
8686
}
87-
else if (!LTG_ISALLTRUE(entry->key))
87+
else if (!LTG_ISALLTRUE(DatumGetPointer(entry->key)))
8888
{
8989
int32 i;
9090
ltree_gist *key;

src/backend/catalog/pg_aggregate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ AggregateCreate(const char *aggName,
654654
for (i = 0; i < Natts_pg_aggregate; i++)
655655
{
656656
nulls[i] = false;
657-
values[i] = (Datum) NULL;
657+
values[i] = (Datum) 0;
658658
replaces[i] = true;
659659
}
660660
values[Anum_pg_aggregate_aggfnoid - 1] = ObjectIdGetDatum(procOid);

src/backend/catalog/pg_constraint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ CreateConstraintEntry(const char *constraintName,
179179
for (i = 0; i < Natts_pg_constraint; i++)
180180
{
181181
nulls[i] = false;
182-
values[i] = (Datum) NULL;
182+
values[i] = (Datum) 0;
183183
}
184184

185185
conOid = GetNewOidWithIndex(conDesc, ConstraintOidIndexId,

src/backend/catalog/pg_conversion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ConversionCreate(const char *conname, Oid connamespace,
8787
for (i = 0; i < Natts_pg_conversion; i++)
8888
{
8989
nulls[i] = false;
90-
values[i] = (Datum) NULL;
90+
values[i] = (Datum) 0;
9191
}
9292

9393
/* form a tuple */

src/backend/catalog/pg_namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
7676
for (i = 0; i < Natts_pg_namespace; i++)
7777
{
7878
nulls[i] = false;
79-
values[i] = (Datum) NULL;
79+
values[i] = (Datum) 0;
8080
}
8181

8282
nspoid = GetNewOidWithIndex(nspdesc, NamespaceOidIndexId,

src/backend/catalog/pg_operator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ OperatorShellMake(const char *operatorName,
225225
for (i = 0; i < Natts_pg_operator; ++i)
226226
{
227227
nulls[i] = false;
228-
values[i] = (Datum) NULL; /* redundant, but safe */
228+
values[i] = (Datum) 0; /* redundant, but safe */
229229
}
230230

231231
/*
@@ -453,7 +453,7 @@ OperatorCreate(const char *operatorName,
453453

454454
for (i = 0; i < Natts_pg_operator; ++i)
455455
{
456-
values[i] = (Datum) NULL;
456+
values[i] = (Datum) 0;
457457
replaces[i] = true;
458458
nulls[i] = false;
459459
}

src/backend/catalog/pg_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
8080
for (i = 0; i < Natts_pg_type; ++i)
8181
{
8282
nulls[i] = false;
83-
values[i] = (Datum) NULL; /* redundant, but safe */
83+
values[i] = (Datum) 0; /* redundant, but safe */
8484
}
8585

8686
/*

src/backend/executor/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
12581258
{
12591259
SPI_result = SPI_ERROR_NOATTRIBUTE;
12601260
*isnull = true;
1261-
return (Datum) NULL;
1261+
return (Datum) 0;
12621262
}
12631263

12641264
return heap_getattr(tuple, fnumber, tupdesc, isnull);

src/backend/nodes/readfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ readDatum(bool typbyval)
630630
}
631631
}
632632
else if (length <= 0)
633-
res = (Datum) NULL;
633+
res = (Datum) 0;
634634
else
635635
{
636636
s = (char *) palloc(length);

src/backend/utils/adt/jsonfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
20272027
{
20282028
/* a json null is an sql null in text mode */
20292029
nulls[1] = true;
2030-
values[1] = (Datum) NULL;
2030+
values[1] = (Datum) 0;
20312031
}
20322032
else
20332033
values[1] = PointerGetDatum(JsonbValueAsText(&v));
@@ -2266,7 +2266,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
22662266
{
22672267
/* a json null is an sql null in text mode */
22682268
nulls[0] = true;
2269-
values[0] = (Datum) NULL;
2269+
values[0] = (Datum) 0;
22702270
}
22712271
else
22722272
values[0] = PointerGetDatum(JsonbValueAsText(&v));
@@ -2389,7 +2389,7 @@ elements_array_element_end(void *state, bool isnull)
23892389
if (isnull && _state->normalize_results)
23902390
{
23912391
nulls[0] = true;
2392-
values[0] = (Datum) NULL;
2392+
values[0] = (Datum) 0;
23932393
}
23942394
else if (_state->next_scalar)
23952395
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy