mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user