1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Remove PointerIsValid()

This doesn't provide any value over the standard style of checking the
pointer directly or comparing against NULL.

Also remove related:
- AllocPointerIsValid() [unused]
- IndexScanIsValid() [had one user]
- HeapScanIsValid() [unused]
- InvalidRelation [unused]

Leaving HeapTupleIsValid(), ItemIdIsValid(), PortalIsValid(),
RelationIsValid for now, to reduce code churn.

Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/ad50ab6b-6f74-4603-b099-1cd6382fb13d%40eisentraut.org
Discussion: https://www.postgresql.org/message-id/CA+hUKG+NFKnr=K4oybwDvT35dW=VAjAAfiuLxp+5JeZSOV3nBg@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/bccf2803-5252-47c2-9ff0-340502d5bd1c@iki.fi
This commit is contained in:
Peter Eisentraut
2025-09-24 15:14:06 +02:00
parent 0fba25eb72
commit a5b35fcedb
37 changed files with 97 additions and 132 deletions

View File

@@ -1179,7 +1179,7 @@ transformRelOptions(Datum oldOptions, List *defList, const char *nameSpace,
astate = NULL;
/* Copy any oldOptions that aren't to be replaced */
if (PointerIsValid(DatumGetPointer(oldOptions)))
if (DatumGetPointer(oldOptions) != NULL)
{
ArrayType *array = DatumGetArrayTypeP(oldOptions);
Datum *oldoptions;
@@ -1357,7 +1357,7 @@ untransformRelOptions(Datum options)
int i;
/* Nothing to do if no options */
if (!PointerIsValid(DatumGetPointer(options)))
if (DatumGetPointer(options) == NULL)
return result;
array = DatumGetArrayTypeP(options);
@@ -1549,7 +1549,7 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
}
/* Done if no options */
if (PointerIsValid(DatumGetPointer(options)))
if (DatumGetPointer(options) != NULL)
parseRelOptionsInternal(options, validate, reloptions, numoptions);
*numrelopts = numoptions;
@@ -2092,7 +2092,7 @@ index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
Assert(amoptions != NULL);
/* Assume function is strict */
if (!PointerIsValid(DatumGetPointer(reloptions)))
if (DatumGetPointer(reloptions) == NULL)
return NULL;
return amoptions(reloptions, validate);

View File

@@ -474,8 +474,8 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
/*
* sanity checks
*/
Assert(PointerIsValid(src));
Assert(PointerIsValid(dst));
Assert(src);
Assert(dst);
Assert(srcAttno >= 1);
Assert(srcAttno <= src->natts);
Assert(dstAttno >= 1);
@@ -853,7 +853,7 @@ TupleDescInitEntry(TupleDesc desc,
/*
* sanity checks
*/
Assert(PointerIsValid(desc));
Assert(desc);
Assert(attributeNumber >= 1);
Assert(attributeNumber <= desc->natts);
Assert(attdim >= 0);
@@ -925,7 +925,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
Form_pg_attribute att;
/* sanity checks */
Assert(PointerIsValid(desc));
Assert(desc);
Assert(attributeNumber >= 1);
Assert(attributeNumber <= desc->natts);
Assert(attdim >= 0);
@@ -1030,7 +1030,7 @@ TupleDescInitEntryCollation(TupleDesc desc,
/*
* sanity checks
*/
Assert(PointerIsValid(desc));
Assert(desc);
Assert(attributeNumber >= 1);
Assert(attributeNumber <= desc->natts);

View File

@@ -75,7 +75,7 @@
#define RELATION_CHECKS \
do { \
Assert(RelationIsValid(indexRelation)); \
Assert(PointerIsValid(indexRelation->rd_indam)); \
Assert(indexRelation->rd_indam); \
if (unlikely(ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))) \
ereport(ERROR, \
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
@@ -85,9 +85,9 @@ do { \
#define SCAN_CHECKS \
( \
AssertMacro(IndexScanIsValid(scan)), \
AssertMacro(scan), \
AssertMacro(RelationIsValid(scan->indexRelation)), \
AssertMacro(PointerIsValid(scan->indexRelation->rd_indam)) \
AssertMacro(scan->indexRelation->rd_indam) \
)
#define CHECK_REL_PROCEDURE(pname) \

View File

@@ -4535,13 +4535,13 @@ ReleaseSavepoint(const char *name)
break;
}
for (target = s; PointerIsValid(target); target = target->parent)
for (target = s; target; target = target->parent)
{
if (PointerIsValid(target->name) && strcmp(target->name, name) == 0)
if (target->name && strcmp(target->name, name) == 0)
break;
}
if (!PointerIsValid(target))
if (!target)
ereport(ERROR,
(errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
errmsg("savepoint \"%s\" does not exist", name)));
@@ -4565,7 +4565,7 @@ ReleaseSavepoint(const char *name)
if (xact == target)
break;
xact = xact->parent;
Assert(PointerIsValid(xact));
Assert(xact);
}
}
@@ -4644,13 +4644,13 @@ RollbackToSavepoint(const char *name)
break;
}
for (target = s; PointerIsValid(target); target = target->parent)
for (target = s; target; target = target->parent)
{
if (PointerIsValid(target->name) && strcmp(target->name, name) == 0)
if (target->name && strcmp(target->name, name) == 0)
break;
}
if (!PointerIsValid(target))
if (!target)
ereport(ERROR,
(errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
errmsg("savepoint \"%s\" does not exist", name)));
@@ -4679,7 +4679,7 @@ RollbackToSavepoint(const char *name)
elog(FATAL, "RollbackToSavepoint: unexpected state %s",
BlockStateAsString(xact->blockState));
xact = xact->parent;
Assert(PointerIsValid(xact));
Assert(xact);
}
/* And mark the target as "restart pending" */
@@ -5700,7 +5700,7 @@ ShowTransactionStateRec(const char *str, TransactionState s)
ereport(DEBUG5,
(errmsg_internal("%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
s->name ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
(unsigned int) XidFromFullTransactionId(s->fullTransactionId),

View File

@@ -3014,9 +3014,9 @@ index_build(Relation heapRelation,
* sanity checks
*/
Assert(RelationIsValid(indexRelation));
Assert(PointerIsValid(indexRelation->rd_indam));
Assert(PointerIsValid(indexRelation->rd_indam->ambuild));
Assert(PointerIsValid(indexRelation->rd_indam->ambuildempty));
Assert(indexRelation->rd_indam);
Assert(indexRelation->rd_indam->ambuild);
Assert(indexRelation->rd_indam->ambuildempty);
/*
* Determine worker process details for parallel CREATE INDEX. Currently,
@@ -3077,7 +3077,7 @@ index_build(Relation heapRelation,
*/
stats = indexRelation->rd_indam->ambuild(heapRelation, indexRelation,
indexInfo);
Assert(PointerIsValid(stats));
Assert(stats);
/*
* If this is an unlogged index, we may need to write out an init fork for

View File

@@ -4849,7 +4849,7 @@ getObjectIdentityParts(const ObjectAddress *object,
* will be initialized in all cases inside the switch; but we do it anyway
* so that we can test below that no branch leaves it unset.
*/
Assert(PointerIsValid(objname) == PointerIsValid(objargs));
Assert((objname != NULL) == (objargs != NULL));
if (objname)
{
*objname = NIL;

View File

@@ -149,7 +149,7 @@ ProcedureCreate(const char *procedureName,
/*
* sanity checks
*/
Assert(PointerIsValid(prosrc));
Assert(prosrc);
parameterCount = parameterTypes->dim1;
if (parameterCount < 0 || parameterCount > FUNC_MAX_ARGS)

View File

@@ -66,7 +66,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
NameData name;
ObjectAddress address;
Assert(PointerIsValid(typeName));
Assert(typeName);
/*
* open pg_type

View File

@@ -632,7 +632,7 @@ CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt)
stmt->options,
fdwvalidator);
if (PointerIsValid(DatumGetPointer(fdwoptions)))
if (DatumGetPointer(fdwoptions) != NULL)
values[Anum_pg_foreign_data_wrapper_fdwoptions - 1] = fdwoptions;
else
nulls[Anum_pg_foreign_data_wrapper_fdwoptions - 1] = true;
@@ -783,7 +783,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt)
stmt->options,
fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
if (DatumGetPointer(datum) != NULL)
repl_val[Anum_pg_foreign_data_wrapper_fdwoptions - 1] = datum;
else
repl_null[Anum_pg_foreign_data_wrapper_fdwoptions - 1] = true;
@@ -943,7 +943,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(srvoptions)))
if (DatumGetPointer(srvoptions) != NULL)
values[Anum_pg_foreign_server_srvoptions - 1] = srvoptions;
else
nulls[Anum_pg_foreign_server_srvoptions - 1] = true;
@@ -1051,7 +1051,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
if (DatumGetPointer(datum) != NULL)
repl_val[Anum_pg_foreign_server_srvoptions - 1] = datum;
else
repl_null[Anum_pg_foreign_server_srvoptions - 1] = true;
@@ -1187,7 +1187,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(useoptions)))
if (DatumGetPointer(useoptions) != NULL)
values[Anum_pg_user_mapping_umoptions - 1] = useoptions;
else
nulls[Anum_pg_user_mapping_umoptions - 1] = true;
@@ -1301,7 +1301,7 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
if (DatumGetPointer(datum) != NULL)
repl_val[Anum_pg_user_mapping_umoptions - 1] = datum;
else
repl_null[Anum_pg_user_mapping_umoptions - 1] = true;
@@ -1464,7 +1464,7 @@ CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid)
stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(ftoptions)))
if (DatumGetPointer(ftoptions) != NULL)
values[Anum_pg_foreign_table_ftoptions - 1] = ftoptions;
else
nulls[Anum_pg_foreign_table_ftoptions - 1] = true;

View File

@@ -15995,7 +15995,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
if (DatumGetPointer(datum) != NULL)
repl_val[Anum_pg_attribute_attfdwoptions - 1] = datum;
else
repl_null[Anum_pg_attribute_attfdwoptions - 1] = true;
@@ -18673,7 +18673,7 @@ ATExecGenericOptions(Relation rel, List *options)
options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
if (DatumGetPointer(datum) != NULL)
repl_val[Anum_pg_foreign_table_ftoptions - 1] = datum;
else
repl_null[Anum_pg_foreign_table_ftoptions - 1] = true;

View File

@@ -363,7 +363,7 @@ outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
else
{
s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s))
if (!s)
appendStringInfoString(str, "0 [ ]");
else
{

View File

@@ -3107,7 +3107,7 @@ relation_needs_vacanalyze(Oid relid,
* vacuuming only, so don't vacuum (or analyze) anything that's not being
* forced.
*/
if (PointerIsValid(tabentry) && AutoVacuumingActive())
if (tabentry && AutoVacuumingActive())
{
float4 pcnt_unfrozen = 1;
float4 reltuples = classForm->reltuples;

View File

@@ -331,7 +331,7 @@ CleanupInvalidationState(int status, Datum arg)
ProcState *stateP;
int i;
Assert(PointerIsValid(segP));
Assert(segP);
LWLockAcquire(SInvalWriteLock, LW_EXCLUSIVE);

View File

@@ -298,7 +298,7 @@ inv_open(Oid lobjId, int flags, MemoryContext mcxt)
void
inv_close(LargeObjectDesc *obj_desc)
{
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
pfree(obj_desc);
}
@@ -344,7 +344,7 @@ inv_getsize(LargeObjectDesc *obj_desc)
SysScanDesc sd;
HeapTuple tuple;
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
open_lo_relation();
@@ -389,7 +389,7 @@ inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence)
{
int64 newoffset;
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
/*
* We allow seek/tell if you have either read or write permission, so no
@@ -436,7 +436,7 @@ inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence)
int64
inv_tell(LargeObjectDesc *obj_desc)
{
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
/*
* We allow seek/tell if you have either read or write permission, so no
@@ -459,7 +459,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
SysScanDesc sd;
HeapTuple tuple;
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
Assert(buf != NULL);
if ((obj_desc->flags & IFS_RDLOCK) == 0)
@@ -569,7 +569,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
bool replace[Natts_pg_largeobject];
CatalogIndexState indstate;
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
Assert(buf != NULL);
/* enforce writability because snapshot is probably wrong otherwise */
@@ -760,7 +760,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
bool replace[Natts_pg_largeobject];
CatalogIndexState indstate;
Assert(PointerIsValid(obj_desc));
Assert(obj_desc);
/* enforce writability because snapshot is probably wrong otherwise */
if ((obj_desc->flags & IFS_WRLOCK) == 0)

View File

@@ -5159,7 +5159,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type,
MemoryContext oldctx;
bloom_filter *bf = NULL;
Assert(OidIsValid(admin_of) == PointerIsValid(admin_role));
Assert(OidIsValid(admin_of) == (admin_role != NULL));
if (admin_role != NULL)
*admin_role = InvalidOid;

View File

@@ -4601,7 +4601,7 @@ array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState *mstate)
/*
* Sanity-check inputs --- caller should have got this right already
*/
Assert(PointerIsValid(arr));
Assert(arr);
if (slice_ndim < 0 || slice_ndim > ARR_NDIM(arr))
elog(ERROR, "invalid arguments to array_create_iterator");

View File

@@ -84,7 +84,7 @@ datumGetSize(Datum value, bool typByVal, int typLen)
/* It is a varlena datatype */
struct varlena *s = (struct varlena *) DatumGetPointer(value);
if (!PointerIsValid(s))
if (!s)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid Datum pointer")));
@@ -96,7 +96,7 @@ datumGetSize(Datum value, bool typByVal, int typLen)
/* It is a cstring datatype */
char *s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s))
if (!s)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid Datum pointer")));

View File

@@ -4895,7 +4895,7 @@ XmlTableSetColumnFilter(TableFuncScanState *state, const char *path, int colnum)
XmlTableBuilderData *xtCxt;
xmlChar *xstr;
Assert(PointerIsValid(path));
Assert(path);
xtCxt = GetXmlTableBuilderPrivateData(state, "XmlTableSetColumnFilter");

View File

@@ -2390,7 +2390,7 @@ PrepareToInvalidateCacheTuple(Relation relation,
*/
Assert(RelationIsValid(relation));
Assert(HeapTupleIsValid(tuple));
Assert(PointerIsValid(function));
Assert(function);
Assert(CacheHdr != NULL);
reloid = RelationGetRelid(relation);

View File

@@ -2896,7 +2896,7 @@ RelationForgetRelation(Oid rid)
RelationIdCacheLookup(rid, relation);
if (!PointerIsValid(relation))
if (!relation)
return; /* not in cache, nothing to do */
if (!RelationHasReferenceCountZero(relation))
@@ -2941,7 +2941,7 @@ RelationCacheInvalidateEntry(Oid relationId)
RelationIdCacheLookup(relationId, relation);
if (PointerIsValid(relation))
if (relation)
{
relcacheInvalsReceived++;
RelationFlushRelation(relation);

View File

@@ -131,7 +131,7 @@ InitCatalogCache(void)
cacheinfo[cacheId].nkeys,
cacheinfo[cacheId].key,
cacheinfo[cacheId].nbuckets);
if (!PointerIsValid(SysCache[cacheId]))
if (!SysCache[cacheId])
elog(ERROR, "could not initialize cache %u (%d)",
cacheinfo[cacheId].reloid, cacheId);
/* Accumulate data for OID lists, too */
@@ -211,8 +211,7 @@ SearchSysCache(int cacheId,
Datum key3,
Datum key4)
{
Assert(cacheId >= 0 && cacheId < SysCacheSize &&
PointerIsValid(SysCache[cacheId]));
Assert(cacheId >= 0 && cacheId < SysCacheSize && SysCache[cacheId]);
return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4);
}
@@ -221,8 +220,7 @@ HeapTuple
SearchSysCache1(int cacheId,
Datum key1)
{
Assert(cacheId >= 0 && cacheId < SysCacheSize &&
PointerIsValid(SysCache[cacheId]));
Assert(cacheId >= 0 && cacheId < SysCacheSize && SysCache[cacheId]);
Assert(SysCache[cacheId]->cc_nkeys == 1);
return SearchCatCache1(SysCache[cacheId], key1);
@@ -232,8 +230,7 @@ HeapTuple
SearchSysCache2(int cacheId,
Datum key1, Datum key2)
{
Assert(cacheId >= 0 && cacheId < SysCacheSize &&
PointerIsValid(SysCache[cacheId]));
Assert(cacheId >= 0 && cacheId < SysCacheSize && SysCache[cacheId]);
Assert(SysCache[cacheId]->cc_nkeys == 2);
return SearchCatCache2(SysCache[cacheId], key1, key2);
@@ -243,8 +240,7 @@ HeapTuple
SearchSysCache3(int cacheId,
Datum key1, Datum key2, Datum key3)
{
Assert(cacheId >= 0 && cacheId < SysCacheSize &&
PointerIsValid(SysCache[cacheId]));
Assert(cacheId >= 0 && cacheId < SysCacheSize && SysCache[cacheId]);
Assert(SysCache[cacheId]->cc_nkeys == 3);
return SearchCatCache3(SysCache[cacheId], key1, key2, key3);
@@ -254,8 +250,7 @@ HeapTuple
SearchSysCache4(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4)
{
Assert(cacheId >= 0 && cacheId < SysCacheSize &&
PointerIsValid(SysCache[cacheId]));
Assert(cacheId >= 0 && cacheId < SysCacheSize && SysCache[cacheId]);
Assert(SysCache[cacheId]->cc_nkeys == 4);
return SearchCatCache4(SysCache[cacheId], key1, key2, key3, key4);
@@ -607,13 +602,12 @@ SysCacheGetAttr(int cacheId, HeapTuple tup,
* valid (because the caller recently fetched the tuple via this same
* cache), but there are cases where we have to initialize the cache here.
*/
if (cacheId < 0 || cacheId >= SysCacheSize ||
!PointerIsValid(SysCache[cacheId]))
if (cacheId < 0 || cacheId >= SysCacheSize || !SysCache[cacheId])
elog(ERROR, "invalid cache ID: %d", cacheId);
if (!PointerIsValid(SysCache[cacheId]->cc_tupdesc))
if (!SysCache[cacheId]->cc_tupdesc)
{
InitCatCachePhase2(SysCache[cacheId], false);
Assert(PointerIsValid(SysCache[cacheId]->cc_tupdesc));
Assert(SysCache[cacheId]->cc_tupdesc);
}
return heap_getattr(tup, attributeNumber,
@@ -664,8 +658,7 @@ GetSysCacheHashValue(int cacheId,
Datum key3,
Datum key4)
{
if (cacheId < 0 || cacheId >= SysCacheSize ||
!PointerIsValid(SysCache[cacheId]))
if (cacheId < 0 || cacheId >= SysCacheSize || !SysCache[cacheId])
elog(ERROR, "invalid cache ID: %d", cacheId);
return GetCatCacheHashValue(SysCache[cacheId], key1, key2, key3, key4);
@@ -678,8 +671,7 @@ struct catclist *
SearchSysCacheList(int cacheId, int nkeys,
Datum key1, Datum key2, Datum key3)
{
if (cacheId < 0 || cacheId >= SysCacheSize ||
!PointerIsValid(SysCache[cacheId]))
if (cacheId < 0 || cacheId >= SysCacheSize || !SysCache[cacheId])
elog(ERROR, "invalid cache ID: %d", cacheId);
return SearchCatCacheList(SysCache[cacheId], nkeys,
@@ -701,7 +693,7 @@ SysCacheInvalidate(int cacheId, uint32 hashValue)
elog(ERROR, "invalid cache ID: %d", cacheId);
/* if this cache isn't initialized yet, no need to do anything */
if (!PointerIsValid(SysCache[cacheId]))
if (!SysCache[cacheId])
return;
CatCacheInvalidate(SysCache[cacheId], hashValue);

View File

@@ -32,8 +32,7 @@ ExceptionalCondition(const char *conditionName,
int lineNumber)
{
/* Report the failure on stderr (or local equivalent) */
if (!PointerIsValid(conditionName)
|| !PointerIsValid(fileName))
if (!conditionName || !fileName)
write_stderr("TRAP: ExceptionalCondition: bad arguments in PID %d\n",
(int) getpid());
else

View File

@@ -189,25 +189,19 @@ typedef struct AllocBlockData
char *endptr; /* end of space in this block */
} AllocBlockData;
/*
* AllocPointerIsValid
* True iff pointer is valid allocation pointer.
*/
#define AllocPointerIsValid(pointer) PointerIsValid(pointer)
/*
* AllocSetIsValid
* True iff set is valid allocation set.
*/
#define AllocSetIsValid(set) \
(PointerIsValid(set) && IsA(set, AllocSetContext))
((set) && IsA(set, AllocSetContext))
/*
* AllocBlockIsValid
* True iff block is valid block of allocation set.
*/
#define AllocBlockIsValid(block) \
(PointerIsValid(block) && AllocSetIsValid((block)->aset))
((block) && AllocSetIsValid((block)->aset))
/*
* We always store external chunks on a dedicated block. This makes fetching

View File

@@ -100,7 +100,7 @@ struct BumpBlock
* True iff set is valid bump context.
*/
#define BumpIsValid(set) \
(PointerIsValid(set) && IsA(set, BumpContext))
((set) && IsA(set, BumpContext))
/*
* We always store external chunks on a dedicated block. This makes fetching

View File

@@ -102,14 +102,14 @@ struct GenerationBlock
* True iff set is valid generation set.
*/
#define GenerationIsValid(set) \
(PointerIsValid(set) && IsA(set, GenerationContext))
((set) && IsA(set, GenerationContext))
/*
* GenerationBlockIsValid
* True iff block is valid block of generation set.
*/
#define GenerationBlockIsValid(block) \
(PointerIsValid(block) && GenerationIsValid((block)->context))
((block) && GenerationIsValid((block)->context))
/*
* GenerationBlockIsEmpty

View File

@@ -131,7 +131,7 @@ GetPortalByName(const char *name)
{
Portal portal;
if (PointerIsValid(name))
if (name)
PortalHashTableLookup(name, portal);
else
portal = NULL;
@@ -176,7 +176,7 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent)
{
Portal portal;
Assert(PointerIsValid(name));
Assert(name);
portal = GetPortalByName(name);
if (PortalIsValid(portal))
@@ -425,7 +425,7 @@ MarkPortalDone(Portal portal)
* aborted transaction, this is necessary, or we'd reach AtCleanup_Portals
* with the cleanup hook still unexecuted.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
portal->cleanup(portal);
portal->cleanup = NULL;
@@ -453,7 +453,7 @@ MarkPortalFailed(Portal portal)
* is necessary, or we'd reach AtCleanup_Portals with the cleanup hook
* still unexecuted.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
portal->cleanup(portal);
portal->cleanup = NULL;
@@ -497,7 +497,7 @@ PortalDrop(Portal portal, bool isTopCommit)
* Note: in most paths of control, this will have been done already in
* MarkPortalDone or MarkPortalFailed. We're just making sure.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
portal->cleanup(portal);
portal->cleanup = NULL;
@@ -823,7 +823,7 @@ AtAbort_Portals(void)
* Allow portalcmds.c to clean up the state it knows about, if we
* haven't already.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
portal->cleanup(portal);
portal->cleanup = NULL;
@@ -896,7 +896,7 @@ AtCleanup_Portals(void)
* We had better not call any user-defined code during cleanup, so if
* the cleanup hook hasn't been run yet, too bad; we'll just skip it.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name);
portal->cleanup = NULL;
@@ -1056,7 +1056,7 @@ AtSubAbort_Portals(SubTransactionId mySubid,
* Allow portalcmds.c to clean up the state it knows about, if we
* haven't already.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
portal->cleanup(portal);
portal->cleanup = NULL;
@@ -1115,7 +1115,7 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
* We had better not call any user-defined code during cleanup, so if
* the cleanup hook hasn't been run yet, too bad; we'll just skip it.
*/
if (PointerIsValid(portal->cleanup))
if (portal->cleanup)
{
elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name);
portal->cleanup = NULL;

View File

@@ -193,14 +193,14 @@ typedef struct SlabBlock
* SlabIsValid
* True iff set is a valid slab allocation set.
*/
#define SlabIsValid(set) (PointerIsValid(set) && IsA(set, SlabContext))
#define SlabIsValid(set) ((set) && IsA(set, SlabContext))
/*
* SlabBlockIsValid
* True iff block is a valid block of slab allocation set.
*/
#define SlabBlockIsValid(block) \
(PointerIsValid(block) && SlabIsValid((block)->slab))
((block) && SlabIsValid((block)->slab))
/*
* SlabBlocklistIndex