Skip to content

Commit ae4472c

Browse files
committed
Remove obsolete IndexIs* macros
Remove IndexIsValid(), IndexIsReady(), IndexIsLive() in favor of accessing the index structure directly. These macros haven't been used consistently, and the original reason of maintaining source compatibility with PostgreSQL 9.2 is gone. Discussion: https://www.postgresql.org/message-id/flat/d419147c-09d4-6196-5d9d-0234b230880a%402ndquadrant.com
1 parent 5c82830 commit ae4472c

File tree

14 files changed

+24
-33
lines changed

14 files changed

+24
-33
lines changed

contrib/amcheck/verify_nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ btree_index_checkable(Relation rel)
289289
errdetail("Index \"%s\" is associated with temporary relation.",
290290
RelationGetRelationName(rel))));
291291

292-
if (!IndexIsValid(rel->rd_index))
292+
if (!rel->rd_index->indisvalid)
293293
ereport(ERROR,
294294
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
295295
errmsg("cannot check index \"%s\"",

contrib/tcn/tcn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ triggered_change_notification(PG_FUNCTION_ARGS)
136136
elog(ERROR, "cache lookup failed for index %u", indexoid);
137137
index = (Form_pg_index) GETSTRUCT(indexTuple);
138138
/* we're only interested if it is the primary key and valid */
139-
if (index->indisprimary && IndexIsValid(index))
139+
if (index->indisprimary && index->indisvalid)
140140
{
141141
int indnkeyatts = index->indnkeyatts;
142142

src/backend/access/heap/tuptoaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ toast_save_datum(Relation rel, Datum value,
16671667
for (i = 0; i < num_indexes; i++)
16681668
{
16691669
/* Only index relations marked as ready can be updated */
1670-
if (IndexIsReady(toastidxs[i]->rd_index))
1670+
if (toastidxs[i]->rd_index->indisready)
16711671
index_insert(toastidxs[i], t_values, t_isnull,
16721672
&(toasttup->t_self),
16731673
toastrel,

src/backend/catalog/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void ResetReindexPending(void);
153153
*
154154
* Caller must have suitable lock on the relation.
155155
*
156-
* Note: we intentionally do not check IndexIsValid here; that's because this
156+
* Note: we intentionally do not check indisvalid here; that's because this
157157
* is used to enforce the rule that there can be only one indisprimary index,
158158
* and we want that to be true even if said index is invalid.
159159
*/
@@ -1792,7 +1792,7 @@ BuildIndexInfo(Relation index)
17921792

17931793
/* other info */
17941794
ii->ii_Unique = indexStruct->indisunique;
1795-
ii->ii_ReadyForInserts = IndexIsReady(indexStruct);
1795+
ii->ii_ReadyForInserts = indexStruct->indisready;
17961796
/* assume not doing speculative insertion for now */
17971797
ii->ii_UniqueOps = NULL;
17981798
ii->ii_UniqueProcs = NULL;

src/backend/commands/cluster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMOD
470470
* might put recently-dead tuples out-of-order in the new table, and there
471471
* is little harm in that.)
472472
*/
473-
if (!IndexIsValid(OldIndex->rd_index))
473+
if (!OldIndex->rd_index->indisvalid)
474474
ereport(ERROR,
475475
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
476476
errmsg("cannot cluster on invalid index \"%s\"",
@@ -545,7 +545,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
545545
else if (thisIndexOid == indexOid)
546546
{
547547
/* this was checked earlier, but let's be real sure */
548-
if (!IndexIsValid(indexForm))
548+
if (!indexForm->indisvalid)
549549
elog(ERROR, "cannot cluster on invalid index %u", indexOid);
550550
indexForm->indisclustered = true;
551551
CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);

src/backend/commands/indexcmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ CheckIndexCompatible(Oid oldId,
224224
*/
225225
if (!(heap_attisnull(tuple, Anum_pg_index_indpred, NULL) &&
226226
heap_attisnull(tuple, Anum_pg_index_indexprs, NULL) &&
227-
IndexIsValid(indexForm)))
227+
indexForm->indisvalid))
228228
{
229229
ReleaseSysCache(tuple);
230230
return false;
@@ -976,7 +976,7 @@ DefineIndex(Oid relationId,
976976
ConstraintSetParentConstraint(cldConstrOid,
977977
createdConstraintId);
978978

979-
if (!IndexIsValid(cldidx->rd_index))
979+
if (!cldidx->rd_index->indisvalid)
980980
invalidate_parent = true;
981981

982982
found = true;

src/backend/commands/matview.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ is_usable_unique_index(Relation indexRel)
870870
if (indexStruct->indisunique &&
871871
indexStruct->indimmediate &&
872872
indexRel->rd_rel->relam == BTREE_AM_OID &&
873-
IndexIsValid(indexStruct) &&
873+
indexStruct->indisvalid &&
874874
RelationGetIndexPredicate(indexRel) == NIL &&
875875
indexStruct->indnatts > 0)
876876
{

src/backend/commands/tablecmds.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8107,7 +8107,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
81078107
if (!HeapTupleIsValid(indexTuple))
81088108
elog(ERROR, "cache lookup failed for index %u", indexoid);
81098109
indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
8110-
if (indexStruct->indisprimary && IndexIsValid(indexStruct))
8110+
if (indexStruct->indisprimary && indexStruct->indisvalid)
81118111
{
81128112
/*
81138113
* Refuse to use a deferrable primary key. This is per SQL spec,
@@ -8228,7 +8228,7 @@ transformFkeyCheckAttrs(Relation pkrel,
82288228
*/
82298229
if (indexStruct->indnkeyatts == numattrs &&
82308230
indexStruct->indisunique &&
8231-
IndexIsValid(indexStruct) &&
8231+
indexStruct->indisvalid &&
82328232
heap_attisnull(indexTuple, Anum_pg_index_indpred, NULL) &&
82338233
heap_attisnull(indexTuple, Anum_pg_index_indexprs, NULL))
82348234
{
@@ -12461,7 +12461,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
1246112461
errmsg("cannot use partial index \"%s\" as replica identity",
1246212462
RelationGetRelationName(indexRel))));
1246312463
/* And neither are invalid indexes. */
12464-
if (!IndexIsValid(indexRel->rd_index))
12464+
if (!indexRel->rd_index->indisvalid)
1246512465
ereport(ERROR,
1246612466
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1246712467
errmsg("cannot use invalid index \"%s\" as replica identity",
@@ -14996,7 +14996,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
1499614996
elog(ERROR, "cache lookup failed for index %u",
1499714997
inhForm->inhrelid);
1499814998
indexForm = (Form_pg_index) GETSTRUCT(indTup);
14999-
if (IndexIsValid(indexForm))
14999+
if (indexForm->indisvalid)
1500015000
tuples += 1;
1500115001
ReleaseSysCache(indTup);
1500215002
}

src/backend/commands/vacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ vacuum_rel(Oid relid, RangeVar *relation, int options, VacuumParams *params)
17541754
* specified kind of lock on each. Return an array of Relation pointers for
17551755
* the indexes into *Irel, and the number of indexes into *nindexes.
17561756
*
1757-
* We consider an index vacuumable if it is marked insertable (IndexIsReady).
1757+
* We consider an index vacuumable if it is marked insertable (indisready).
17581758
* If it isn't, probably a CREATE INDEX CONCURRENTLY command failed early in
17591759
* execution, and what we have is too corrupt to be processable. We will
17601760
* vacuum even if the index isn't indisvalid; this is important because in a
@@ -1789,7 +1789,7 @@ vac_open_indexes(Relation relation, LOCKMODE lockmode,
17891789
Relation indrel;
17901790

17911791
indrel = index_open(indexoid, lockmode);
1792-
if (IndexIsReady(indrel->rd_index))
1792+
if (indrel->rd_index->indisready)
17931793
(*Irel)[i++] = indrel;
17941794
else
17951795
index_close(indrel, lockmode);

src/backend/executor/execIndexing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
184184
* For each index, open the index relation and save pg_index info. We
185185
* acquire RowExclusiveLock, signifying we will update the index.
186186
*
187-
* Note: we do this even if the index is not IndexIsReady; it's not worth
187+
* Note: we do this even if the index is not indisready; it's not worth
188188
* the trouble to optimize for the case where it isn't.
189189
*/
190190
i = 0;

0 commit comments

Comments
 (0)