Remove obsolete IndexIs* macros
authorPeter Eisentraut <peter_e@gmx.net>
Thu, 27 Dec 2018 09:07:46 +0000 (10:07 +0100)
committerPeter Eisentraut <peter_e@gmx.net>
Thu, 27 Dec 2018 09:07:46 +0000 (10:07 +0100)
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

14 files changed:
contrib/amcheck/verify_nbtree.c
contrib/tcn/tcn.c
src/backend/access/heap/tuptoaster.c
src/backend/catalog/index.c
src/backend/commands/cluster.c
src/backend/commands/indexcmds.c
src/backend/commands/matview.c
src/backend/commands/tablecmds.c
src/backend/commands/vacuum.c
src/backend/executor/execIndexing.c
src/backend/optimizer/util/plancat.c
src/backend/parser/parse_utilcmd.c
src/backend/utils/cache/relcache.c
src/include/catalog/pg_index.h

index 14ed31753fb54646f3dd3c4b18cb89f6cb0dbdfc..3624fa632ea6676f751b7547263df8dfbdc32e55 100644 (file)
@@ -289,7 +289,7 @@ btree_index_checkable(Relation rel)
                 errdetail("Index \"%s\" is associated with temporary relation.",
                           RelationGetRelationName(rel))));
 
-   if (!IndexIsValid(rel->rd_index))
+   if (!rel->rd_index->indisvalid)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot check index \"%s\"",
index 0c274322bd3b85a0b40f5dc6047e5c9f00a9c2d9..bcb29edb662a316e22c19fb01315207f772bbeb7 100644 (file)
@@ -136,7 +136,7 @@ triggered_change_notification(PG_FUNCTION_ARGS)
            elog(ERROR, "cache lookup failed for index %u", indexoid);
        index = (Form_pg_index) GETSTRUCT(indexTuple);
        /* we're only interested if it is the primary key and valid */
-       if (index->indisprimary && IndexIsValid(index))
+       if (index->indisprimary && index->indisvalid)
        {
            int         indnkeyatts = index->indnkeyatts;
 
index d1dad998d28c9053a262212ca301e30a5ffb544f..d26c081a1b0531e6a1ea888d5b1d025a675e6e44 100644 (file)
@@ -1667,7 +1667,7 @@ toast_save_datum(Relation rel, Datum value,
        for (i = 0; i < num_indexes; i++)
        {
            /* Only index relations marked as ready can be updated */
-           if (IndexIsReady(toastidxs[i]->rd_index))
+           if (toastidxs[i]->rd_index->indisready)
                index_insert(toastidxs[i], t_values, t_isnull,
                             &(toasttup->t_self),
                             toastrel,
index 8709e8c22c77edaf3ffbd2c677a5e22cb8231bff..c2ad944e04abc7e8a6c3b67c0aa878750b4578c6 100644 (file)
@@ -153,7 +153,7 @@ static void ResetReindexPending(void);
  *
  * Caller must have suitable lock on the relation.
  *
- * Note: we intentionally do not check IndexIsValid here; that's because this
+ * Note: we intentionally do not check indisvalid here; that's because this
  * is used to enforce the rule that there can be only one indisprimary index,
  * and we want that to be true even if said index is invalid.
  */
@@ -1792,7 +1792,7 @@ BuildIndexInfo(Relation index)
 
    /* other info */
    ii->ii_Unique = indexStruct->indisunique;
-   ii->ii_ReadyForInserts = IndexIsReady(indexStruct);
+   ii->ii_ReadyForInserts = indexStruct->indisready;
    /* assume not doing speculative insertion for now */
    ii->ii_UniqueOps = NULL;
    ii->ii_UniqueProcs = NULL;
index 610e425a566d5621784ff386df024fdc84959f56..6ae0debe152cf3236c4ae46f1c06502c79bdcb53 100644 (file)
@@ -470,7 +470,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMOD
     * might put recently-dead tuples out-of-order in the new table, and there
     * is little harm in that.)
     */
-   if (!IndexIsValid(OldIndex->rd_index))
+   if (!OldIndex->rd_index->indisvalid)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot cluster on invalid index \"%s\"",
@@ -545,7 +545,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
        else if (thisIndexOid == indexOid)
        {
            /* this was checked earlier, but let's be real sure */
-           if (!IndexIsValid(indexForm))
+           if (!indexForm->indisvalid)
                elog(ERROR, "cannot cluster on invalid index %u", indexOid);
            indexForm->indisclustered = true;
            CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);
index 6c06167fb2ae39e81e0cf64e6069cceb9e689dca..62ec387486e0a3c12c648d2f2fff7aa429a431ca 100644 (file)
@@ -224,7 +224,7 @@ CheckIndexCompatible(Oid oldId,
     */
    if (!(heap_attisnull(tuple, Anum_pg_index_indpred, NULL) &&
          heap_attisnull(tuple, Anum_pg_index_indexprs, NULL) &&
-         IndexIsValid(indexForm)))
+         indexForm->indisvalid))
    {
        ReleaseSysCache(tuple);
        return false;
@@ -976,7 +976,7 @@ DefineIndex(Oid relationId,
                            ConstraintSetParentConstraint(cldConstrOid,
                                                          createdConstraintId);
 
-                       if (!IndexIsValid(cldidx->rd_index))
+                       if (!cldidx->rd_index->indisvalid)
                            invalidate_parent = true;
 
                        found = true;
index a171ebabf8fb6d12ad5be4e6ebe77392133b3817..7605b302bb5c1608bab337730a2434e273b37f65 100644 (file)
@@ -870,7 +870,7 @@ is_usable_unique_index(Relation indexRel)
    if (indexStruct->indisunique &&
        indexStruct->indimmediate &&
        indexRel->rd_rel->relam == BTREE_AM_OID &&
-       IndexIsValid(indexStruct) &&
+       indexStruct->indisvalid &&
        RelationGetIndexPredicate(indexRel) == NIL &&
        indexStruct->indnatts > 0)
    {
index 936d7aa611eaddcf92f37a4d0d3907f5d618fc5d..c8c50e8c98979eff0abbc2c000b7703245f627f8 100644 (file)
@@ -8107,7 +8107,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
        if (!HeapTupleIsValid(indexTuple))
            elog(ERROR, "cache lookup failed for index %u", indexoid);
        indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
-       if (indexStruct->indisprimary && IndexIsValid(indexStruct))
+       if (indexStruct->indisprimary && indexStruct->indisvalid)
        {
            /*
             * Refuse to use a deferrable primary key.  This is per SQL spec,
@@ -8228,7 +8228,7 @@ transformFkeyCheckAttrs(Relation pkrel,
         */
        if (indexStruct->indnkeyatts == numattrs &&
            indexStruct->indisunique &&
-           IndexIsValid(indexStruct) &&
+           indexStruct->indisvalid &&
            heap_attisnull(indexTuple, Anum_pg_index_indpred, NULL) &&
            heap_attisnull(indexTuple, Anum_pg_index_indexprs, NULL))
        {
@@ -12461,7 +12461,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
                 errmsg("cannot use partial index \"%s\" as replica identity",
                        RelationGetRelationName(indexRel))));
    /* And neither are invalid indexes. */
-   if (!IndexIsValid(indexRel->rd_index))
+   if (!indexRel->rd_index->indisvalid)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot use invalid index \"%s\" as replica identity",
@@ -14996,7 +14996,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
            elog(ERROR, "cache lookup failed for index %u",
                 inhForm->inhrelid);
        indexForm = (Form_pg_index) GETSTRUCT(indTup);
-       if (IndexIsValid(indexForm))
+       if (indexForm->indisvalid)
            tuples += 1;
        ReleaseSysCache(indTup);
    }
index 25b3b0312c7c0e23fd1519b624c5b2d7f3a0df85..38d06b2173452743616802c73e99c8d3b92154ae 100644 (file)
@@ -1754,7 +1754,7 @@ vacuum_rel(Oid relid, RangeVar *relation, int options, VacuumParams *params)
  * specified kind of lock on each.  Return an array of Relation pointers for
  * the indexes into *Irel, and the number of indexes into *nindexes.
  *
- * We consider an index vacuumable if it is marked insertable (IndexIsReady).
+ * We consider an index vacuumable if it is marked insertable (indisready).
  * If it isn't, probably a CREATE INDEX CONCURRENTLY command failed early in
  * execution, and what we have is too corrupt to be processable.  We will
  * 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,
        Relation    indrel;
 
        indrel = index_open(indexoid, lockmode);
-       if (IndexIsReady(indrel->rd_index))
+       if (indrel->rd_index->indisready)
            (*Irel)[i++] = indrel;
        else
            index_close(indrel, lockmode);
index 8b35bb458de3992cde113a7dee8561d72f73a84d..bbd2726ceeba9c45c9b5bb2b8d3e9549ba4ebede 100644 (file)
@@ -184,7 +184,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
     * For each index, open the index relation and save pg_index info. We
     * acquire RowExclusiveLock, signifying we will update the index.
     *
-    * Note: we do this even if the index is not IndexIsReady; it's not worth
+    * Note: we do this even if the index is not indisready; it's not worth
     * the trouble to optimize for the case where it isn't.
     */
    i = 0;
index a570ac0aabe3223d5c4a04abf82a258fc2fe06ed..5790b62369cfde70e42e0895aadbda18cbcd5c04 100644 (file)
@@ -201,9 +201,9 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
             * queries.  Note that this is OK because the data structure we
             * are constructing is only used by the planner --- the executor
             * still needs to insert into "invalid" indexes, if they're marked
-            * IndexIsReady.
+            * indisready.
             */
-           if (!IndexIsValid(index))
+           if (!index->indisvalid)
            {
                index_close(indexRelation, NoLock);
                continue;
@@ -696,7 +696,7 @@ infer_arbiter_indexes(PlannerInfo *root)
        idxRel = index_open(indexoid, RowExclusiveLock);
        idxForm = idxRel->rd_index;
 
-       if (!IndexIsValid(idxForm))
+       if (!idxForm->indisvalid)
            goto next;
 
        /*
index 52582d0a13fb970fab81b4357a72dbd97d8444a7..807bb9bae21e6d3a26ae4a3d3665c5d9cb54b0a1 100644 (file)
@@ -1970,7 +1970,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
                            index_name, RelationGetRelationName(heap_rel)),
                     parser_errposition(cxt->pstate, constraint->location)));
 
-       if (!IndexIsValid(index_form))
+       if (!index_form->indisvalid)
            ereport(ERROR,
                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                     errmsg("index \"%s\" is not valid", index_name),
index c3071db1cdf90d1229b45f61885875037611d6f5..c88871fd3ce755de0fd3ff3ff7673a3e93b9268c 100644 (file)
@@ -4221,7 +4221,7 @@ RelationGetFKeyList(Relation relation)
  * so that we must recompute the index list on next request.  This handles
  * creation or deletion of an index.
  *
- * Indexes that are marked not IndexIsLive are omitted from the returned list.
+ * Indexes that are marked not indislive are omitted from the returned list.
  * Such indexes are expected to be dropped momentarily, and should not be
  * touched at all by any caller of this function.
  *
@@ -4288,7 +4288,7 @@ RelationGetIndexList(Relation relation)
         * HOT-safety decisions.  It's unsafe to touch such an index at all
         * since its catalog entries could disappear at any instant.
         */
-       if (!IndexIsLive(index))
+       if (!index->indislive)
            continue;
 
        /* Add index's OID to result list in the proper order */
@@ -4299,7 +4299,7 @@ RelationGetIndexList(Relation relation)
         * interesting for either oid indexes or replication identity indexes,
         * so don't check them.
         */
-       if (!IndexIsValid(index) || !index->indisunique ||
+       if (!index->indisvalid || !index->indisunique ||
            !index->indimmediate ||
            !heap_attisnull(htup, Anum_pg_index_indpred, NULL))
            continue;
index ebe8955bf3895223c2f016040c53760c9008bce2..a10c26b70acbda6c5479de686f2abe6095ad0802 100644 (file)
@@ -77,13 +77,4 @@ typedef FormData_pg_index *Form_pg_index;
 
 #endif                         /* EXPOSE_TO_CLIENT_CODE */
 
-/*
- * Use of these macros is recommended over direct examination of the state
- * flag columns where possible; this allows source code compatibility with
- * the hacky representation used in 9.2.
- */
-#define IndexIsValid(indexForm) ((indexForm)->indisvalid)
-#define IndexIsReady(indexForm) ((indexForm)->indisready)
-#define IndexIsLive(indexForm) ((indexForm)->indislive)
-
 #endif                         /* PG_INDEX_H */