mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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:
@ -130,7 +130,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
|
|||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||||
if (!tuple)
|
if (!HeapTupleIsValid(tuple))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
|
result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple));
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
@ -1069,7 +1069,7 @@ DefineIndex(Oid relationId,
|
|||||||
|
|
||||||
tup = SearchSysCache1(INDEXRELID,
|
tup = SearchSysCache1(INDEXRELID,
|
||||||
ObjectIdGetDatum(indexRelationId));
|
ObjectIdGetDatum(indexRelationId));
|
||||||
if (!tup)
|
if (!HeapTupleIsValid(tup))
|
||||||
elog(ERROR, "cache lookup failed for index %u",
|
elog(ERROR, "cache lookup failed for index %u",
|
||||||
indexRelationId);
|
indexRelationId);
|
||||||
newtup = heap_copytuple(tup);
|
newtup = heap_copytuple(tup);
|
||||||
|
@ -1057,7 +1057,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
|
|||||||
|
|
||||||
/* Fetch the operator definition */
|
/* Fetch the operator definition */
|
||||||
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
|
optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
|
||||||
if (optup == NULL)
|
if (!HeapTupleIsValid(optup))
|
||||||
elog(ERROR, "cache lookup failed for operator %u", member->object);
|
elog(ERROR, "cache lookup failed for operator %u", member->object);
|
||||||
opform = (Form_pg_operator) GETSTRUCT(optup);
|
opform = (Form_pg_operator) GETSTRUCT(optup);
|
||||||
|
|
||||||
@ -1123,7 +1123,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
|
|||||||
|
|
||||||
/* Fetch the procedure definition */
|
/* Fetch the procedure definition */
|
||||||
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
|
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
|
||||||
if (proctup == NULL)
|
if (!HeapTupleIsValid(proctup))
|
||||||
elog(ERROR, "cache lookup failed for function %u", member->object);
|
elog(ERROR, "cache lookup failed for function %u", member->object);
|
||||||
procform = (Form_pg_proc) GETSTRUCT(proctup);
|
procform = (Form_pg_proc) GETSTRUCT(proctup);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ AlterOperator(AlterOperatorStmt *stmt)
|
|||||||
oprId = LookupOperWithArgs(stmt->opername, false);
|
oprId = LookupOperWithArgs(stmt->opername, false);
|
||||||
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
|
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
|
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
|
||||||
if (tup == NULL)
|
if (!HeapTupleIsValid(tup))
|
||||||
elog(ERROR, "cache lookup failed for operator %u", oprId);
|
elog(ERROR, "cache lookup failed for operator %u", oprId);
|
||||||
oprForm = (Form_pg_operator) GETSTRUCT(tup);
|
oprForm = (Form_pg_operator) GETSTRUCT(tup);
|
||||||
|
|
||||||
|
@ -7926,7 +7926,7 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
|
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
|
||||||
if (!tuple)
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for constraint %u",
|
elog(ERROR, "cache lookup failed for constraint %u",
|
||||||
parentConstrOid);
|
parentConstrOid);
|
||||||
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
||||||
@ -7995,7 +7995,7 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
|
|||||||
*/
|
*/
|
||||||
partcontup = SearchSysCache1(CONSTROID,
|
partcontup = SearchSysCache1(CONSTROID,
|
||||||
ObjectIdGetDatum(fk->conoid));
|
ObjectIdGetDatum(fk->conoid));
|
||||||
if (!partcontup)
|
if (!HeapTupleIsValid(partcontup))
|
||||||
elog(ERROR, "cache lookup failed for constraint %u",
|
elog(ERROR, "cache lookup failed for constraint %u",
|
||||||
fk->conoid);
|
fk->conoid);
|
||||||
partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
|
partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
|
||||||
@ -15310,7 +15310,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
|
|||||||
Constraint *fkconstraint;
|
Constraint *fkconstraint;
|
||||||
|
|
||||||
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
|
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
|
||||||
if (!contup)
|
if (!HeapTupleIsValid(contup))
|
||||||
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
|
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
|
||||||
conform = (Form_pg_constraint) GETSTRUCT(contup);
|
conform = (Form_pg_constraint) GETSTRUCT(contup);
|
||||||
|
|
||||||
@ -15650,9 +15650,8 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
|
|||||||
|
|
||||||
indTup = SearchSysCache1(INDEXRELID,
|
indTup = SearchSysCache1(INDEXRELID,
|
||||||
ObjectIdGetDatum(inhForm->inhrelid));
|
ObjectIdGetDatum(inhForm->inhrelid));
|
||||||
if (!indTup)
|
if (!HeapTupleIsValid(indTup))
|
||||||
elog(ERROR, "cache lookup failed for index %u",
|
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
|
||||||
inhForm->inhrelid);
|
|
||||||
indexForm = (Form_pg_index) GETSTRUCT(indTup);
|
indexForm = (Form_pg_index) GETSTRUCT(indTup);
|
||||||
if (IndexIsValid(indexForm))
|
if (IndexIsValid(indexForm))
|
||||||
tuples += 1;
|
tuples += 1;
|
||||||
|
@ -1335,7 +1335,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
|
htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
|
||||||
if (!htup)
|
if (!HeapTupleIsValid(htup))
|
||||||
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
|
elog(ERROR, "cache lookup failed for statistics object %u", statOid);
|
||||||
staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
|
staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user