Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 346ed70

Browse files
committed
Rename RelationData.rd_amroutine to rd_indam.
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
1 parent ebcc7bf commit 346ed70

File tree

9 files changed

+52
-52
lines changed

9 files changed

+52
-52
lines changed

src/backend/access/index/indexam.c

+31-31
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,27 @@
9898
#define RELATION_CHECKS \
9999
( \
100100
AssertMacro(RelationIsValid(indexRelation)), \
101-
AssertMacro(PointerIsValid(indexRelation->rd_amroutine)), \
101+
AssertMacro(PointerIsValid(indexRelation->rd_indam)), \
102102
AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \
103103
)
104104

105105
#define SCAN_CHECKS \
106106
( \
107107
AssertMacro(IndexScanIsValid(scan)), \
108108
AssertMacro(RelationIsValid(scan->indexRelation)), \
109-
AssertMacro(PointerIsValid(scan->indexRelation->rd_amroutine)) \
109+
AssertMacro(PointerIsValid(scan->indexRelation->rd_indam)) \
110110
)
111111

112112
#define CHECK_REL_PROCEDURE(pname) \
113113
do { \
114-
if (indexRelation->rd_amroutine->pname == NULL) \
114+
if (indexRelation->rd_indam->pname == NULL) \
115115
elog(ERROR, "function %s is not defined for index %s", \
116116
CppAsString(pname), RelationGetRelationName(indexRelation)); \
117117
} while(0)
118118

119119
#define CHECK_SCAN_PROCEDURE(pname) \
120120
do { \
121-
if (scan->indexRelation->rd_amroutine->pname == NULL) \
121+
if (scan->indexRelation->rd_indam->pname == NULL) \
122122
elog(ERROR, "function %s is not defined for index %s", \
123123
CppAsString(pname), RelationGetRelationName(scan->indexRelation)); \
124124
} while(0)
@@ -203,14 +203,14 @@ index_insert(Relation indexRelation,
203203
RELATION_CHECKS;
204204
CHECK_REL_PROCEDURE(aminsert);
205205

206-
if (!(indexRelation->rd_amroutine->ampredlocks))
206+
if (!(indexRelation->rd_indam->ampredlocks))
207207
CheckForSerializableConflictIn(indexRelation,
208208
(HeapTuple) NULL,
209209
InvalidBuffer);
210210

211-
return indexRelation->rd_amroutine->aminsert(indexRelation, values, isnull,
212-
heap_t_ctid, heapRelation,
213-
checkUnique, indexInfo);
211+
return indexRelation->rd_indam->aminsert(indexRelation, values, isnull,
212+
heap_t_ctid, heapRelation,
213+
checkUnique, indexInfo);
214214
}
215215

216216
/*
@@ -275,7 +275,7 @@ index_beginscan_internal(Relation indexRelation,
275275
RELATION_CHECKS;
276276
CHECK_REL_PROCEDURE(ambeginscan);
277277

278-
if (!(indexRelation->rd_amroutine->ampredlocks))
278+
if (!(indexRelation->rd_indam->ampredlocks))
279279
PredicateLockRelation(indexRelation, snapshot);
280280

281281
/*
@@ -286,8 +286,8 @@ index_beginscan_internal(Relation indexRelation,
286286
/*
287287
* Tell the AM to open a scan.
288288
*/
289-
scan = indexRelation->rd_amroutine->ambeginscan(indexRelation, nkeys,
290-
norderbys);
289+
scan = indexRelation->rd_indam->ambeginscan(indexRelation, nkeys,
290+
norderbys);
291291
/* Initialize information for parallel scan. */
292292
scan->parallel_scan = pscan;
293293
scan->xs_temp_snap = temp_snap;
@@ -329,8 +329,8 @@ index_rescan(IndexScanDesc scan,
329329

330330
scan->kill_prior_tuple = false; /* for safety */
331331

332-
scan->indexRelation->rd_amroutine->amrescan(scan, keys, nkeys,
333-
orderbys, norderbys);
332+
scan->indexRelation->rd_indam->amrescan(scan, keys, nkeys,
333+
orderbys, norderbys);
334334
}
335335

336336
/* ----------------
@@ -351,7 +351,7 @@ index_endscan(IndexScanDesc scan)
351351
}
352352

353353
/* End the AM's scan */
354-
scan->indexRelation->rd_amroutine->amendscan(scan);
354+
scan->indexRelation->rd_indam->amendscan(scan);
355355

356356
/* Release index refcount acquired by index_beginscan */
357357
RelationDecrementReferenceCount(scan->indexRelation);
@@ -373,7 +373,7 @@ index_markpos(IndexScanDesc scan)
373373
SCAN_CHECKS;
374374
CHECK_SCAN_PROCEDURE(ammarkpos);
375375

376-
scan->indexRelation->rd_amroutine->ammarkpos(scan);
376+
scan->indexRelation->rd_indam->ammarkpos(scan);
377377
}
378378

379379
/* ----------------
@@ -404,7 +404,7 @@ index_restrpos(IndexScanDesc scan)
404404

405405
scan->kill_prior_tuple = false; /* for safety */
406406

407-
scan->indexRelation->rd_amroutine->amrestrpos(scan);
407+
scan->indexRelation->rd_indam->amrestrpos(scan);
408408
}
409409

410410
/*
@@ -430,9 +430,9 @@ index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
430430
* AM-specific data needed. (It's hard to believe that could work, but
431431
* it's easy enough to cater to it here.)
432432
*/
433-
if (indexRelation->rd_amroutine->amestimateparallelscan != NULL)
433+
if (indexRelation->rd_indam->amestimateparallelscan != NULL)
434434
nbytes = add_size(nbytes,
435-
indexRelation->rd_amroutine->amestimateparallelscan());
435+
indexRelation->rd_indam->amestimateparallelscan());
436436

437437
return nbytes;
438438
}
@@ -465,12 +465,12 @@ index_parallelscan_initialize(Relation heapRelation, Relation indexRelation,
465465
SerializeSnapshot(snapshot, target->ps_snapshot_data);
466466

467467
/* aminitparallelscan is optional; assume no-op if not provided by AM */
468-
if (indexRelation->rd_amroutine->aminitparallelscan != NULL)
468+
if (indexRelation->rd_indam->aminitparallelscan != NULL)
469469
{
470470
void *amtarget;
471471

472472
amtarget = OffsetToPointer(target, offset);
473-
indexRelation->rd_amroutine->aminitparallelscan(amtarget);
473+
indexRelation->rd_indam->aminitparallelscan(amtarget);
474474
}
475475
}
476476

@@ -484,8 +484,8 @@ index_parallelrescan(IndexScanDesc scan)
484484
SCAN_CHECKS;
485485

486486
/* amparallelrescan is optional; assume no-op if not provided by AM */
487-
if (scan->indexRelation->rd_amroutine->amparallelrescan != NULL)
488-
scan->indexRelation->rd_amroutine->amparallelrescan(scan);
487+
if (scan->indexRelation->rd_indam->amparallelrescan != NULL)
488+
scan->indexRelation->rd_indam->amparallelrescan(scan);
489489
}
490490

491491
/*
@@ -539,7 +539,7 @@ index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
539539
* scan->xs_recheck and possibly scan->xs_itup/scan->xs_hitup, though we
540540
* pay no attention to those fields here.
541541
*/
542-
found = scan->indexRelation->rd_amroutine->amgettuple(scan, direction);
542+
found = scan->indexRelation->rd_indam->amgettuple(scan, direction);
543543

544544
/* Reset kill flag immediately for safety */
545545
scan->kill_prior_tuple = false;
@@ -724,7 +724,7 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
724724
/*
725725
* have the am's getbitmap proc do all the work.
726726
*/
727-
ntids = scan->indexRelation->rd_amroutine->amgetbitmap(scan, bitmap);
727+
ntids = scan->indexRelation->rd_indam->amgetbitmap(scan, bitmap);
728728

729729
pgstat_count_index_tuples(scan->indexRelation, ntids);
730730

@@ -751,8 +751,8 @@ index_bulk_delete(IndexVacuumInfo *info,
751751
RELATION_CHECKS;
752752
CHECK_REL_PROCEDURE(ambulkdelete);
753753

754-
return indexRelation->rd_amroutine->ambulkdelete(info, stats,
755-
callback, callback_state);
754+
return indexRelation->rd_indam->ambulkdelete(info, stats,
755+
callback, callback_state);
756756
}
757757

758758
/* ----------------
@@ -770,7 +770,7 @@ index_vacuum_cleanup(IndexVacuumInfo *info,
770770
RELATION_CHECKS;
771771
CHECK_REL_PROCEDURE(amvacuumcleanup);
772772

773-
return indexRelation->rd_amroutine->amvacuumcleanup(info, stats);
773+
return indexRelation->rd_indam->amvacuumcleanup(info, stats);
774774
}
775775

776776
/* ----------------
@@ -786,10 +786,10 @@ index_can_return(Relation indexRelation, int attno)
786786
RELATION_CHECKS;
787787

788788
/* amcanreturn is optional; assume false if not provided by AM */
789-
if (indexRelation->rd_amroutine->amcanreturn == NULL)
789+
if (indexRelation->rd_indam->amcanreturn == NULL)
790790
return false;
791791

792-
return indexRelation->rd_amroutine->amcanreturn(indexRelation, attno);
792+
return indexRelation->rd_indam->amcanreturn(indexRelation, attno);
793793
}
794794

795795
/* ----------------
@@ -827,7 +827,7 @@ index_getprocid(Relation irel,
827827
int nproc;
828828
int procindex;
829829

830-
nproc = irel->rd_amroutine->amsupport;
830+
nproc = irel->rd_indam->amsupport;
831831

832832
Assert(procnum > 0 && procnum <= (uint16) nproc);
833833

@@ -861,7 +861,7 @@ index_getprocinfo(Relation irel,
861861
int nproc;
862862
int procindex;
863863

864-
nproc = irel->rd_amroutine->amsupport;
864+
nproc = irel->rd_indam->amsupport;
865865

866866
Assert(procnum > 0 && procnum <= (uint16) nproc);
867867

src/backend/catalog/index.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -2248,9 +2248,9 @@ index_build(Relation heapRelation,
22482248
* sanity checks
22492249
*/
22502250
Assert(RelationIsValid(indexRelation));
2251-
Assert(PointerIsValid(indexRelation->rd_amroutine));
2252-
Assert(PointerIsValid(indexRelation->rd_amroutine->ambuild));
2253-
Assert(PointerIsValid(indexRelation->rd_amroutine->ambuildempty));
2251+
Assert(PointerIsValid(indexRelation->rd_indam));
2252+
Assert(PointerIsValid(indexRelation->rd_indam->ambuild));
2253+
Assert(PointerIsValid(indexRelation->rd_indam->ambuildempty));
22542254

22552255
/*
22562256
* Determine worker process details for parallel CREATE INDEX. Currently,
@@ -2291,8 +2291,8 @@ index_build(Relation heapRelation,
22912291
/*
22922292
* Call the access method's build procedure
22932293
*/
2294-
stats = indexRelation->rd_amroutine->ambuild(heapRelation, indexRelation,
2295-
indexInfo);
2294+
stats = indexRelation->rd_indam->ambuild(heapRelation, indexRelation,
2295+
indexInfo);
22962296
Assert(PointerIsValid(stats));
22972297

22982298
/*
@@ -2307,7 +2307,7 @@ index_build(Relation heapRelation,
23072307
{
23082308
RelationOpenSmgr(indexRelation);
23092309
smgrcreate(indexRelation->rd_smgr, INIT_FORKNUM, false);
2310-
indexRelation->rd_amroutine->ambuildempty(indexRelation);
2310+
indexRelation->rd_indam->ambuildempty(indexRelation);
23112311
}
23122312

23132313
/*

src/backend/commands/cluster.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMOD
444444
RelationGetRelationName(OldHeap))));
445445

446446
/* Index AM must allow clustering */
447-
if (!OldIndex->rd_amroutine->amclusterable)
447+
if (!OldIndex->rd_indam->amclusterable)
448448
ereport(ERROR,
449449
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
450450
errmsg("cannot cluster on index \"%s\" because access method does not support clustering",

src/backend/commands/tablecmds.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -11121,7 +11121,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1112111121
break;
1112211122
case RELKIND_INDEX:
1112311123
case RELKIND_PARTITIONED_INDEX:
11124-
(void) index_reloptions(rel->rd_amroutine->amoptions, newOptions, true);
11124+
(void) index_reloptions(rel->rd_indam->amoptions, newOptions, true);
1112511125
break;
1112611126
default:
1112711127
ereport(ERROR,
@@ -12876,7 +12876,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
1287612876
RelationGetRelationName(indexRel),
1287712877
RelationGetRelationName(rel))));
1287812878
/* The AM must support uniqueness, and the index must in fact be unique. */
12879-
if (!indexRel->rd_amroutine->amcanunique ||
12879+
if (!indexRel->rd_indam->amcanunique ||
1288012880
!indexRel->rd_index->indisunique)
1288112881
ereport(ERROR,
1288212882
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

src/backend/executor/nodeIndexscan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
15271527

15281528
Assert(rightop != NULL);
15291529

1530-
if (index->rd_amroutine->amsearcharray)
1530+
if (index->rd_indam->amsearcharray)
15311531
{
15321532
/* Index AM will handle this like a simple operator */
15331533
flags |= SK_SEARCHARRAY;

src/backend/optimizer/util/plancat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
263263

264264
info->relam = indexRelation->rd_rel->relam;
265265

266-
/* We copy just the fields we need, not all of rd_amroutine */
267-
amroutine = indexRelation->rd_amroutine;
266+
/* We copy just the fields we need, not all of rd_indam */
267+
amroutine = indexRelation->rd_indam;
268268
info->amcanorderbyop = amroutine->amcanorderbyop;
269269
info->amoptionalkey = amroutine->amoptionalkey;
270270
info->amsearcharray = amroutine->amsearcharray;

src/backend/parser/parse_utilcmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Oid heapRelid, Relation source_idx,
15041504
iparam->nulls_ordering = SORTBY_NULLS_DEFAULT;
15051505

15061506
/* Adjust options if necessary */
1507-
if (source_idx->rd_amroutine->amcanorder)
1507+
if (source_idx->rd_indam->amcanorder)
15081508
{
15091509
/*
15101510
* If it supports sort ordering, copy DESC and NULLS opts. Don't

src/backend/utils/cache/relcache.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ AllocateRelationDesc(Form_pg_class relp)
426426
*
427427
* tuple is the real pg_class tuple (not rd_rel!) for relation
428428
*
429-
* Note: rd_rel and (if an index) rd_amroutine must be valid already
429+
* Note: rd_rel and (if an index) rd_indam must be valid already
430430
*/
431431
static void
432432
RelationParseRelOptions(Relation relation, HeapTuple tuple)
@@ -451,7 +451,7 @@ RelationParseRelOptions(Relation relation, HeapTuple tuple)
451451
break;
452452
case RELKIND_INDEX:
453453
case RELKIND_PARTITIONED_INDEX:
454-
amoptsfn = relation->rd_amroutine->amoptions;
454+
amoptsfn = relation->rd_indam->amoptions;
455455
break;
456456
default:
457457
return;
@@ -1331,7 +1331,7 @@ InitIndexAmRoutine(Relation relation)
13311331
cached = (IndexAmRoutine *) MemoryContextAlloc(relation->rd_indexcxt,
13321332
sizeof(IndexAmRoutine));
13331333
memcpy(cached, tmp, sizeof(IndexAmRoutine));
1334-
relation->rd_amroutine = cached;
1334+
relation->rd_indam = cached;
13351335

13361336
pfree(tmp);
13371337
}
@@ -1416,7 +1416,7 @@ RelationInitIndexAccessInfo(Relation relation)
14161416
relation->rd_opcintype = (Oid *)
14171417
MemoryContextAllocZero(indexcxt, indnkeyatts * sizeof(Oid));
14181418

1419-
amsupport = relation->rd_amroutine->amsupport;
1419+
amsupport = relation->rd_indam->amsupport;
14201420
if (amsupport > 0)
14211421
{
14221422
int nsupport = indnatts * amsupport;
@@ -5404,7 +5404,7 @@ load_relcache_init_file(bool shared)
54045404
rel->rd_indoption = indoption;
54055405

54065406
/* set up zeroed fmgr-info vector */
5407-
nsupport = relform->relnatts * rel->rd_amroutine->amsupport;
5407+
nsupport = relform->relnatts * rel->rd_indam->amsupport;
54085408
rel->rd_supportinfo = (FmgrInfo *)
54095409
MemoryContextAllocZero(indexcxt, nsupport * sizeof(FmgrInfo));
54105410
}
@@ -5417,7 +5417,7 @@ load_relcache_init_file(bool shared)
54175417
Assert(rel->rd_index == NULL);
54185418
Assert(rel->rd_indextuple == NULL);
54195419
Assert(rel->rd_indexcxt == NULL);
5420-
Assert(rel->rd_amroutine == NULL);
5420+
Assert(rel->rd_indam == NULL);
54215421
Assert(rel->rd_opfamily == NULL);
54225422
Assert(rel->rd_opcintype == NULL);
54235423
Assert(rel->rd_support == NULL);
@@ -5695,7 +5695,7 @@ write_relcache_init_file(bool shared)
56955695

56965696
/* next, write the vector of support procedure OIDs */
56975697
write_item(rel->rd_support,
5698-
relform->relnatts * (rel->rd_amroutine->amsupport * sizeof(RegProcedure)),
5698+
relform->relnatts * (rel->rd_indam->amsupport * sizeof(RegProcedure)),
56995699
fp);
57005700

57015701
/* next, write the vector of collation OIDs */

src/include/utils/rel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ typedef struct RelationData
147147
Oid rd_amhandler; /* OID of index AM's handler function */
148148
MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
149149
/* use "struct" here to avoid needing to include amapi.h: */
150-
struct IndexAmRoutine *rd_amroutine; /* index AM's API struct */
150+
struct IndexAmRoutine *rd_indam; /* index AM's API struct */
151151
Oid *rd_opfamily; /* OIDs of op families for each index col */
152152
Oid *rd_opcintype; /* OIDs of opclass declared input data types */
153153
RegProcedure *rd_support; /* OIDs of support procedures */

0 commit comments

Comments
 (0)