diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index bb8379dc12..4ad30186d9 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -98,7 +98,7 @@ #define RELATION_CHECKS \ ( \ AssertMacro(RelationIsValid(indexRelation)), \ - AssertMacro(PointerIsValid(indexRelation->rd_amroutine)), \ + AssertMacro(PointerIsValid(indexRelation->rd_indam)), \ AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \ ) @@ -106,19 +106,19 @@ ( \ 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); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 7359600fd3..5ca0b1eb96 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -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); } /* diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 5c0f238c7e..ec1d6b6f11 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -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", diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index fbd2d101c1..28a137bb53 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -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), diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index f255551786..cdf1ad09de 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -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; diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index ab35055c59..261492e6b7 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -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; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 404569f7df..1084af2eed 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -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 diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 6ee0621008..bcf4f104cf 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -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 */ diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index ff0a3ea45c..1d05465303 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -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 */