Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Rename RelationData.rd_amroutine to rd_indam.
authorAndres Freund <andres@anarazel.de>
Tue, 22 Jan 2019 01:36:55 +0000 (17:36 -0800)
committerAndres Freund <andres@anarazel.de>
Tue, 22 Jan 2019 01:36:55 +0000 (17:36 -0800)
The upcoming table AM support makes rd_amroutine to generic, as its
only about index AMs. The new name makes that clear, and is shorter to
boot.

Author: Andres Freund
Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de

src/backend/access/index/indexam.c
src/backend/catalog/index.c
src/backend/commands/cluster.c
src/backend/commands/tablecmds.c
src/backend/executor/nodeIndexscan.c
src/backend/optimizer/util/plancat.c
src/backend/parser/parse_utilcmd.c
src/backend/utils/cache/relcache.c
src/include/utils/rel.h

index bb8379dc129aec17a0be0a4f03f1fb739fc1888c..4ad30186d974fda8b28e9dacdaf32ffbbc8d74a5 100644 (file)
@@ -98,7 +98,7 @@
 #define RELATION_CHECKS \
 ( \
    AssertMacro(RelationIsValid(indexRelation)), \
-   AssertMacro(PointerIsValid(indexRelation->rd_amroutine)), \
+   AssertMacro(PointerIsValid(indexRelation->rd_indam)), \
    AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \
 )
 
 ( \
    AssertMacro(IndexScanIsValid(scan)), \
    AssertMacro(RelationIsValid(scan->indexRelation)), \
-   AssertMacro(PointerIsValid(scan->indexRelation->rd_amroutine)) \
+   AssertMacro(PointerIsValid(scan->indexRelation->rd_indam)) \
 )
 
 #define CHECK_REL_PROCEDURE(pname) \
 do { \
-   if (indexRelation->rd_amroutine->pname == NULL) \
+   if (indexRelation->rd_indam->pname == NULL) \
        elog(ERROR, "function %s is not defined for index %s", \
             CppAsString(pname), RelationGetRelationName(indexRelation)); \
 } while(0)
 
 #define CHECK_SCAN_PROCEDURE(pname) \
 do { \
-   if (scan->indexRelation->rd_amroutine->pname == NULL) \
+   if (scan->indexRelation->rd_indam->pname == NULL) \
        elog(ERROR, "function %s is not defined for index %s", \
             CppAsString(pname), RelationGetRelationName(scan->indexRelation)); \
 } while(0)
@@ -203,14 +203,14 @@ index_insert(Relation indexRelation,
    RELATION_CHECKS;
    CHECK_REL_PROCEDURE(aminsert);
 
-   if (!(indexRelation->rd_amroutine->ampredlocks))
+   if (!(indexRelation->rd_indam->ampredlocks))
        CheckForSerializableConflictIn(indexRelation,
                                       (HeapTuple) NULL,
                                       InvalidBuffer);
 
-   return indexRelation->rd_amroutine->aminsert(indexRelation, values, isnull,
-                                                heap_t_ctid, heapRelation,
-                                                checkUnique, indexInfo);
+   return indexRelation->rd_indam->aminsert(indexRelation, values, isnull,
+                                            heap_t_ctid, heapRelation,
+                                            checkUnique, indexInfo);
 }
 
 /*
@@ -275,7 +275,7 @@ index_beginscan_internal(Relation indexRelation,
    RELATION_CHECKS;
    CHECK_REL_PROCEDURE(ambeginscan);
 
-   if (!(indexRelation->rd_amroutine->ampredlocks))
+   if (!(indexRelation->rd_indam->ampredlocks))
        PredicateLockRelation(indexRelation, snapshot);
 
    /*
@@ -286,8 +286,8 @@ index_beginscan_internal(Relation indexRelation,
    /*
     * Tell the AM to open a scan.
     */
-   scan = indexRelation->rd_amroutine->ambeginscan(indexRelation, nkeys,
-                                                   norderbys);
+   scan = indexRelation->rd_indam->ambeginscan(indexRelation, nkeys,
+                                               norderbys);
    /* Initialize information for parallel scan. */
    scan->parallel_scan = pscan;
    scan->xs_temp_snap = temp_snap;
@@ -329,8 +329,8 @@ index_rescan(IndexScanDesc scan,
 
    scan->kill_prior_tuple = false; /* for safety */
 
-   scan->indexRelation->rd_amroutine->amrescan(scan, keys, nkeys,
-                                               orderbys, norderbys);
+   scan->indexRelation->rd_indam->amrescan(scan, keys, nkeys,
+                                           orderbys, norderbys);
 }
 
 /* ----------------
@@ -351,7 +351,7 @@ index_endscan(IndexScanDesc scan)
    }
 
    /* End the AM's scan */
-   scan->indexRelation->rd_amroutine->amendscan(scan);
+   scan->indexRelation->rd_indam->amendscan(scan);
 
    /* Release index refcount acquired by index_beginscan */
    RelationDecrementReferenceCount(scan->indexRelation);
@@ -373,7 +373,7 @@ index_markpos(IndexScanDesc scan)
    SCAN_CHECKS;
    CHECK_SCAN_PROCEDURE(ammarkpos);
 
-   scan->indexRelation->rd_amroutine->ammarkpos(scan);
+   scan->indexRelation->rd_indam->ammarkpos(scan);
 }
 
 /* ----------------
@@ -404,7 +404,7 @@ index_restrpos(IndexScanDesc scan)
 
    scan->kill_prior_tuple = false; /* for safety */
 
-   scan->indexRelation->rd_amroutine->amrestrpos(scan);
+   scan->indexRelation->rd_indam->amrestrpos(scan);
 }
 
 /*
@@ -430,9 +430,9 @@ index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
     * AM-specific data needed.  (It's hard to believe that could work, but
     * it's easy enough to cater to it here.)
     */
-   if (indexRelation->rd_amroutine->amestimateparallelscan != NULL)
+   if (indexRelation->rd_indam->amestimateparallelscan != NULL)
        nbytes = add_size(nbytes,
-                         indexRelation->rd_amroutine->amestimateparallelscan());
+                         indexRelation->rd_indam->amestimateparallelscan());
 
    return nbytes;
 }
@@ -465,12 +465,12 @@ index_parallelscan_initialize(Relation heapRelation, Relation indexRelation,
    SerializeSnapshot(snapshot, target->ps_snapshot_data);
 
    /* aminitparallelscan is optional; assume no-op if not provided by AM */
-   if (indexRelation->rd_amroutine->aminitparallelscan != NULL)
+   if (indexRelation->rd_indam->aminitparallelscan != NULL)
    {
        void       *amtarget;
 
        amtarget = OffsetToPointer(target, offset);
-       indexRelation->rd_amroutine->aminitparallelscan(amtarget);
+       indexRelation->rd_indam->aminitparallelscan(amtarget);
    }
 }
 
@@ -484,8 +484,8 @@ index_parallelrescan(IndexScanDesc scan)
    SCAN_CHECKS;
 
    /* amparallelrescan is optional; assume no-op if not provided by AM */
-   if (scan->indexRelation->rd_amroutine->amparallelrescan != NULL)
-       scan->indexRelation->rd_amroutine->amparallelrescan(scan);
+   if (scan->indexRelation->rd_indam->amparallelrescan != NULL)
+       scan->indexRelation->rd_indam->amparallelrescan(scan);
 }
 
 /*
@@ -539,7 +539,7 @@ index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
     * scan->xs_recheck and possibly scan->xs_itup/scan->xs_hitup, though we
     * pay no attention to those fields here.
     */
-   found = scan->indexRelation->rd_amroutine->amgettuple(scan, direction);
+   found = scan->indexRelation->rd_indam->amgettuple(scan, direction);
 
    /* Reset kill flag immediately for safety */
    scan->kill_prior_tuple = false;
@@ -724,7 +724,7 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
    /*
     * have the am's getbitmap proc do all the work.
     */
-   ntids = scan->indexRelation->rd_amroutine->amgetbitmap(scan, bitmap);
+   ntids = scan->indexRelation->rd_indam->amgetbitmap(scan, bitmap);
 
    pgstat_count_index_tuples(scan->indexRelation, ntids);
 
@@ -751,8 +751,8 @@ index_bulk_delete(IndexVacuumInfo *info,
    RELATION_CHECKS;
    CHECK_REL_PROCEDURE(ambulkdelete);
 
-   return indexRelation->rd_amroutine->ambulkdelete(info, stats,
-                                                    callback, callback_state);
+   return indexRelation->rd_indam->ambulkdelete(info, stats,
+                                                callback, callback_state);
 }
 
 /* ----------------
@@ -770,7 +770,7 @@ index_vacuum_cleanup(IndexVacuumInfo *info,
    RELATION_CHECKS;
    CHECK_REL_PROCEDURE(amvacuumcleanup);
 
-   return indexRelation->rd_amroutine->amvacuumcleanup(info, stats);
+   return indexRelation->rd_indam->amvacuumcleanup(info, stats);
 }
 
 /* ----------------
@@ -786,10 +786,10 @@ index_can_return(Relation indexRelation, int attno)
    RELATION_CHECKS;
 
    /* amcanreturn is optional; assume false if not provided by AM */
-   if (indexRelation->rd_amroutine->amcanreturn == NULL)
+   if (indexRelation->rd_indam->amcanreturn == NULL)
        return false;
 
-   return indexRelation->rd_amroutine->amcanreturn(indexRelation, attno);
+   return indexRelation->rd_indam->amcanreturn(indexRelation, attno);
 }
 
 /* ----------------
@@ -827,7 +827,7 @@ index_getprocid(Relation irel,
    int         nproc;
    int         procindex;
 
-   nproc = irel->rd_amroutine->amsupport;
+   nproc = irel->rd_indam->amsupport;
 
    Assert(procnum > 0 && procnum <= (uint16) nproc);
 
@@ -861,7 +861,7 @@ index_getprocinfo(Relation irel,
    int         nproc;
    int         procindex;
 
-   nproc = irel->rd_amroutine->amsupport;
+   nproc = irel->rd_indam->amsupport;
 
    Assert(procnum > 0 && procnum <= (uint16) nproc);
 
index 7359600fd36303c709804ea797d9f221519dfcb9..5ca0b1eb9698e32828b42845670e4ba4bd97a2f5 100644 (file)
@@ -2248,9 +2248,9 @@ index_build(Relation heapRelation,
     * sanity checks
     */
    Assert(RelationIsValid(indexRelation));
-   Assert(PointerIsValid(indexRelation->rd_amroutine));
-   Assert(PointerIsValid(indexRelation->rd_amroutine->ambuild));
-   Assert(PointerIsValid(indexRelation->rd_amroutine->ambuildempty));
+   Assert(PointerIsValid(indexRelation->rd_indam));
+   Assert(PointerIsValid(indexRelation->rd_indam->ambuild));
+   Assert(PointerIsValid(indexRelation->rd_indam->ambuildempty));
 
    /*
     * Determine worker process details for parallel CREATE INDEX.  Currently,
@@ -2291,8 +2291,8 @@ index_build(Relation heapRelation,
    /*
     * Call the access method's build procedure
     */
-   stats = indexRelation->rd_amroutine->ambuild(heapRelation, indexRelation,
-                                                indexInfo);
+   stats = indexRelation->rd_indam->ambuild(heapRelation, indexRelation,
+                                            indexInfo);
    Assert(PointerIsValid(stats));
 
    /*
@@ -2307,7 +2307,7 @@ index_build(Relation heapRelation,
    {
        RelationOpenSmgr(indexRelation);
        smgrcreate(indexRelation->rd_smgr, INIT_FORKNUM, false);
-       indexRelation->rd_amroutine->ambuildempty(indexRelation);
+       indexRelation->rd_indam->ambuildempty(indexRelation);
    }
 
    /*
index 5c0f238c7e264f1852b122a8aa7ade99908846b0..ec1d6b6f119d8128621b2f3625ea7b403909752a 100644 (file)
@@ -444,7 +444,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMOD
                        RelationGetRelationName(OldHeap))));
 
    /* Index AM must allow clustering */
-   if (!OldIndex->rd_amroutine->amclusterable)
+   if (!OldIndex->rd_indam->amclusterable)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot cluster on index \"%s\" because access method does not support clustering",
index fbd2d101c190599cfb55c479b585396b8a045ddf..28a137bb537cdf2e119f669b191acd5736ac66de 100644 (file)
@@ -11121,7 +11121,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
            break;
        case RELKIND_INDEX:
        case RELKIND_PARTITIONED_INDEX:
-           (void) index_reloptions(rel->rd_amroutine->amoptions, newOptions, true);
+           (void) index_reloptions(rel->rd_indam->amoptions, newOptions, true);
            break;
        default:
            ereport(ERROR,
@@ -12876,7 +12876,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
                        RelationGetRelationName(indexRel),
                        RelationGetRelationName(rel))));
    /* The AM must support uniqueness, and the index must in fact be unique. */
-   if (!indexRel->rd_amroutine->amcanunique ||
+   if (!indexRel->rd_indam->amcanunique ||
        !indexRel->rd_index->indisunique)
        ereport(ERROR,
                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
index f255551786ed20aa4c077e378d08cd576a80d47f..cdf1ad09de341ac74011b4db4146e057fab8269f 100644 (file)
@@ -1527,7 +1527,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
 
            Assert(rightop != NULL);
 
-           if (index->rd_amroutine->amsearcharray)
+           if (index->rd_indam->amsearcharray)
            {
                /* Index AM will handle this like a simple operator */
                flags |= SK_SEARCHARRAY;
index ab35055c596a6d2e29520dd41760caeb00eb13c4..261492e6b7140aa2c0abf95eb719f197f7227603 100644 (file)
@@ -263,8 +263,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
 
            info->relam = indexRelation->rd_rel->relam;
 
-           /* We copy just the fields we need, not all of rd_amroutine */
-           amroutine = indexRelation->rd_amroutine;
+           /* We copy just the fields we need, not all of rd_indam */
+           amroutine = indexRelation->rd_indam;
            info->amcanorderbyop = amroutine->amcanorderbyop;
            info->amoptionalkey = amroutine->amoptionalkey;
            info->amsearcharray = amroutine->amsearcharray;
index 404569f7df402462e16ea4e8cdd3dc52a3e892c8..1084af2eedb47f8669a00a9f4b4268732de6f62e 100644 (file)
@@ -1504,7 +1504,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Oid heapRelid, Relation source_idx,
        iparam->nulls_ordering = SORTBY_NULLS_DEFAULT;
 
        /* Adjust options if necessary */
-       if (source_idx->rd_amroutine->amcanorder)
+       if (source_idx->rd_indam->amcanorder)
        {
            /*
             * If it supports sort ordering, copy DESC and NULLS opts. Don't
index 6ee06210087540da31d1204e77e3b4c16ba1a470..bcf4f104cf65f1bc9cf948cd69faef779f019a01 100644 (file)
@@ -426,7 +426,7 @@ AllocateRelationDesc(Form_pg_class relp)
  *
  * tuple is the real pg_class tuple (not rd_rel!) for relation
  *
- * Note: rd_rel and (if an index) rd_amroutine must be valid already
+ * Note: rd_rel and (if an index) rd_indam must be valid already
  */
 static void
 RelationParseRelOptions(Relation relation, HeapTuple tuple)
@@ -451,7 +451,7 @@ RelationParseRelOptions(Relation relation, HeapTuple tuple)
            break;
        case RELKIND_INDEX:
        case RELKIND_PARTITIONED_INDEX:
-           amoptsfn = relation->rd_amroutine->amoptions;
+           amoptsfn = relation->rd_indam->amoptions;
            break;
        default:
            return;
@@ -1331,7 +1331,7 @@ InitIndexAmRoutine(Relation relation)
    cached = (IndexAmRoutine *) MemoryContextAlloc(relation->rd_indexcxt,
                                                   sizeof(IndexAmRoutine));
    memcpy(cached, tmp, sizeof(IndexAmRoutine));
-   relation->rd_amroutine = cached;
+   relation->rd_indam = cached;
 
    pfree(tmp);
 }
@@ -1416,7 +1416,7 @@ RelationInitIndexAccessInfo(Relation relation)
    relation->rd_opcintype = (Oid *)
        MemoryContextAllocZero(indexcxt, indnkeyatts * sizeof(Oid));
 
-   amsupport = relation->rd_amroutine->amsupport;
+   amsupport = relation->rd_indam->amsupport;
    if (amsupport > 0)
    {
        int         nsupport = indnatts * amsupport;
@@ -5404,7 +5404,7 @@ load_relcache_init_file(bool shared)
            rel->rd_indoption = indoption;
 
            /* set up zeroed fmgr-info vector */
-           nsupport = relform->relnatts * rel->rd_amroutine->amsupport;
+           nsupport = relform->relnatts * rel->rd_indam->amsupport;
            rel->rd_supportinfo = (FmgrInfo *)
                MemoryContextAllocZero(indexcxt, nsupport * sizeof(FmgrInfo));
        }
@@ -5417,7 +5417,7 @@ load_relcache_init_file(bool shared)
            Assert(rel->rd_index == NULL);
            Assert(rel->rd_indextuple == NULL);
            Assert(rel->rd_indexcxt == NULL);
-           Assert(rel->rd_amroutine == NULL);
+           Assert(rel->rd_indam == NULL);
            Assert(rel->rd_opfamily == NULL);
            Assert(rel->rd_opcintype == NULL);
            Assert(rel->rd_support == NULL);
@@ -5695,7 +5695,7 @@ write_relcache_init_file(bool shared)
 
            /* next, write the vector of support procedure OIDs */
            write_item(rel->rd_support,
-                      relform->relnatts * (rel->rd_amroutine->amsupport * sizeof(RegProcedure)),
+                      relform->relnatts * (rel->rd_indam->amsupport * sizeof(RegProcedure)),
                       fp);
 
            /* next, write the vector of collation OIDs */
index ff0a3ea45cde42db7bf8156daeee2b9bca99d953..1d05465303916fe31b625f45cde6794e14caebc0 100644 (file)
@@ -147,7 +147,7 @@ typedef struct RelationData
    Oid         rd_amhandler;   /* OID of index AM's handler function */
    MemoryContext rd_indexcxt;  /* private memory cxt for this stuff */
    /* use "struct" here to avoid needing to include amapi.h: */
-   struct IndexAmRoutine *rd_amroutine;    /* index AM's API struct */
+   struct IndexAmRoutine *rd_indam;    /* index AM's API struct */
    Oid        *rd_opfamily;    /* OIDs of op families for each index col */
    Oid        *rd_opcintype;   /* OIDs of opclass declared input data types */
    RegProcedure *rd_support;   /* OIDs of support procedures */