Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9691aa7

Browse files
committed
Fix style violations in syscache lookups.
Project style is to check the success of SearchSysCacheN and friendsby applying HeapTupleIsValid to the result. A tiny minority of callscreatively did it differently. Bring them into line with the rest.This is just cosmetic, since HeapTupleIsValid is indeed just a nullcheck at the moment ... but that may not be true forever, and in anycase it puts a mental burden on readers who may wonder why thesecall sites are not like the rest.Back-patch to v11 just to keep the branches in sync. (The bulk of theseerrors seem to have originated in v11 or v12, though a few are old.)Per searching to see if anyplace else had made the same errorrepaired in62148c3.
1 parent62148c3 commit9691aa7

File tree

9 files changed

+16
-18
lines changed

9 files changed

+16
-18
lines changed

‎src/backend/catalog/partition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ index_get_partition(Relation partition, Oid indexId)
164164
boolispartition;
165165

166166
tup=SearchSysCache1(RELOID,ObjectIdGetDatum(partIdx));
167-
if (!tup)
167+
if (!HeapTupleIsValid(tup))
168168
elog(ERROR,"cache lookup failed for relation %u",partIdx);
169169
classForm= (Form_pg_class)GETSTRUCT(tup);
170170
ispartition=classForm->relispartition;

‎src/backend/catalog/pg_publication.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
130130
boolresult;
131131

132132
tuple=SearchSysCache1(RELOID,ObjectIdGetDatum(relid));
133-
if (!tuple)
133+
if (!HeapTupleIsValid(tuple))
134134
PG_RETURN_NULL();
135135
result=is_publishable_class(relid, (Form_pg_class)GETSTRUCT(tuple));
136136
ReleaseSysCache(tuple);

‎src/backend/commands/indexcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ DefineIndex(Oid relationId,
12191219

12201220
tup=SearchSysCache1(INDEXRELID,
12211221
ObjectIdGetDatum(indexRelationId));
1222-
if (!tup)
1222+
if (!HeapTupleIsValid(tup))
12231223
elog(ERROR,"cache lookup failed for index %u",
12241224
indexRelationId);
12251225
newtup=heap_copytuple(tup);

‎src/backend/commands/opclasscmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
10711071

10721072
/* Fetch the operator definition */
10731073
optup=SearchSysCache1(OPEROID,ObjectIdGetDatum(member->object));
1074-
if (optup==NULL)
1074+
if (!HeapTupleIsValid(optup))
10751075
elog(ERROR,"cache lookup failed for operator %u",member->object);
10761076
opform= (Form_pg_operator)GETSTRUCT(optup);
10771077

@@ -1137,7 +1137,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
11371137

11381138
/* Fetch the procedure definition */
11391139
proctup=SearchSysCache1(PROCOID,ObjectIdGetDatum(member->object));
1140-
if (proctup==NULL)
1140+
if (!HeapTupleIsValid(proctup))
11411141
elog(ERROR,"cache lookup failed for function %u",member->object);
11421142
procform= (Form_pg_proc)GETSTRUCT(proctup);
11431143

‎src/backend/commands/operatorcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ AlterOperator(AlterOperatorStmt *stmt)
407407
oprId=LookupOperWithArgs(stmt->opername, false);
408408
catalog=table_open(OperatorRelationId,RowExclusiveLock);
409409
tup=SearchSysCacheCopy1(OPEROID,ObjectIdGetDatum(oprId));
410-
if (tup==NULL)
410+
if (!HeapTupleIsValid(tup))
411411
elog(ERROR,"cache lookup failed for operator %u",oprId);
412412
oprForm= (Form_pg_operator)GETSTRUCT(tup);
413413

‎src/backend/commands/statscmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ UpdateStatisticsForTypeChange(Oid statsOid, Oid relationOid, int attnum,
461461
boolreplaces[Natts_pg_statistic_ext];
462462

463463
oldtup=SearchSysCache1(STATEXTOID,ObjectIdGetDatum(statsOid));
464-
if (!oldtup)
464+
if (!HeapTupleIsValid(oldtup))
465465
elog(ERROR,"cache lookup failed for statistics object %u",statsOid);
466466

467467
/*

‎src/backend/commands/tablecmds.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8606,7 +8606,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
86068606
ListCell *cell;
86078607

86088608
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
8609-
if (!tuple)
8609+
if (!HeapTupleIsValid(tuple))
86108610
elog(ERROR, "cache lookup failed for constraint %u",
86118611
parentConstrOid);
86128612
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
@@ -8785,7 +8785,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
87858785

87868786
parentConstrTup = SearchSysCache1(CONSTROID,
87878787
ObjectIdGetDatum(parentConstrOid));
8788-
if (!parentConstrTup)
8788+
if (!HeapTupleIsValid(parentConstrTup))
87898789
elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid);
87908790
parentConstr = (Form_pg_constraint) GETSTRUCT(parentConstrTup);
87918791

@@ -8816,9 +8816,8 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk,
88168816
*/
88178817
partcontup = SearchSysCache1(CONSTROID,
88188818
ObjectIdGetDatum(fk->conoid));
8819-
if (!partcontup)
8820-
elog(ERROR, "cache lookup failed for constraint %u",
8821-
fk->conoid);
8819+
if (!HeapTupleIsValid(partcontup))
8820+
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
88228821
partConstr = (Form_pg_constraint) GETSTRUCT(partcontup);
88238822
if (OidIsValid(partConstr->conparentid) ||
88248823
!partConstr->convalidated ||
@@ -16001,7 +16000,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
1600116000
Constraint *fkconstraint;
1600216001

1600316002
contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid));
16004-
if (!contup)
16003+
if (!HeapTupleIsValid(contup))
1600516004
elog(ERROR, "cache lookup failed for constraint %u", fk->conoid);
1600616005
conform = (Form_pg_constraint) GETSTRUCT(contup);
1600716006

@@ -16346,9 +16345,8 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
1634616345

1634716346
indTup = SearchSysCache1(INDEXRELID,
1634816347
ObjectIdGetDatum(inhForm->inhrelid));
16349-
if (!indTup)
16350-
elog(ERROR, "cache lookup failed for index %u",
16351-
inhForm->inhrelid);
16348+
if (!HeapTupleIsValid(indTup))
16349+
elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid);
1635216350
indexForm = (Form_pg_index) GETSTRUCT(indTup);
1635316351
if (indexForm->indisvalid)
1635416352
tuples += 1;

‎src/backend/optimizer/util/appendinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
134134
HeapTuplenewtup;
135135

136136
newtup=SearchSysCacheAttName(new_relid,attname);
137-
if (!newtup)
137+
if (!HeapTupleIsValid(newtup))
138138
elog(ERROR,"could not find inherited attribute \"%s\" of relation \"%s\"",
139139
attname,RelationGetRelationName(newrelation));
140140
new_attno= ((Form_pg_attribute)GETSTRUCT(newtup))->attnum-1;

‎src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
13121312
inti;
13131313

13141314
htup=SearchSysCache1(STATEXTOID,ObjectIdGetDatum(statOid));
1315-
if (!htup)
1315+
if (!HeapTupleIsValid(htup))
13161316
elog(ERROR,"cache lookup failed for statistics object %u",statOid);
13171317
staForm= (Form_pg_statistic_ext)GETSTRUCT(htup);
13181318

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp