Fix style violations in syscache lookups.
Project style is to check the success of SearchSysCacheN and friends by applying HeapTupleIsValid to the result. A tiny minority of calls creatively did it differently. Bring them into line with the rest. This is just cosmetic, since HeapTupleIsValid is indeed just a null check at the moment ... but that may not be true forever, and in any case it puts a mental burden on readers who may wonder why these call sites are not like the rest. Back-patch to v11 just to keep the branches in sync. (The bulk of these errors seem to have originated in v11 or v12, though a few are old.) Per searching to see if anyplace else had made the same error repaired in 62148c352.
This commit is contained in:
parent
030ad0acfa
commit
000f557c31
@ -130,7 +130,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
|
||||
bool result;
|
||||
|
||||
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (!tuple)
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
PG_RETURN_NULL();
|
||||
result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
|
||||
ReleaseSysCache(tuple);
|
||||
|
@ -1069,7 +1069,7 @@ DefineIndex(Oid relationId,
|
||||
|
||||
tup = SearchSysCache1(INDEXRELID,
|
||||
ObjectIdGetDatum(indexRelationId));
|
||||
if (!tup)
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "cache lookup failed for index %u",
|
||||
indexRelationId);
|
||||
newtup = heap_copytuple(tup);
|
||||
|
@ -1057,7 +1057,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
|
||||
|
||||
/* Fetch the operator definition */
|
||||
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
|
||||
if (optup == NULL)
|
||||
if (!HeapTupleIsValid(optup))
|
||||
elog(ERROR, "cache lookup failed for operator %u", member->object);
|
||||
opform = (Form_pg_operator) GETSTRUCT(optup);
|
||||
|
||||
@ -1123,7 +1123,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
|
||||
|
||||
/* Fetch the procedure definition */
|
||||
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
|
||||
if (proctup == NULL)
|
||||
if (!HeapTupleIsValid(proctup))
|
||||
elog(ERROR, "cache lookup failed for function %u", member->object);
|
||||
procform = (Form_pg_proc) GETSTRUCT(proctup);
|
||||
|
||||
|
@ -407,7 +407,7 @@ AlterOperator(AlterOperatorStmt *stmt)
|
||||
oprId = LookupOperWithArgs(stmt->opername, false);
|
||||
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
|
||||
if (tup == NULL)
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "cache lookup failed for operator %u", oprId);
|
||||
oprForm = (Form_pg_operator) GETSTRUCT(tup);
|
||||
|
||||
|
@ -7926,7 +7926,7 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
|
||||
int i;
|
||||
|
||||
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
|
||||
if (!tuple)
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for constraint %u",
|
||||
parentConstrOid);
|
||||
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
||||
@ -7995,7 +7995,7 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
|
||||
*/
|
||||
partcontup = SearchSysCache1(CONSTROID,
|
||||
ObjectIdGetDatum(fk->conoid));
|
||||
if (!partcontup)
|
||||
if (!HeapTupleIsValid(partcontup))
|
||||
elog(ERROR, "cache lookup failed for constraint %u",
|
||||
fk->conoid);
|
||||
partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
|
||||
@ -15310,7 +15310,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
|
||||
Constraint *fkconstraint;
|
||||
|
||||
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
|
||||
if (!contup)
|
||||
if (!HeapTupleIsValid(contup))
|
||||
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
|
||||
conform = (Form_pg_constraint) GETSTRUCT(contup);
|
||||
|
||||
@ -15650,9 +15650,8 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
|
||||
|
||||
indTup = SearchSysCache1(INDEXRELID,
|
||||
ObjectIdGetDatum(inhForm->inhrelid));
|
||||
if (!indTup)
|
||||
elog(ERROR, "cache lookup failed for index %u",
|
||||
inhForm->inhrelid);
|
||||
if (!HeapTupleIsValid(indTup))
|
||||
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
|
||||
indexForm = (Form_pg_index) GETSTRUCT(indTup);
|
||||
if (IndexIsValid(indexForm))
|
||||
tuples += 1;
|
||||
|
@ -1335,7 +1335,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
|
||||
int i;
|
||||
|
||||
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
|
||||
if (!htup)
|
||||
if (!HeapTupleIsValid(htup))
|
||||
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
|
||||
staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user