Skip to content

Commit 3cda080

Browse files
committed
pass indexRel to table_index_fetch_begin to detect index bridging for orioledb
1 parent 37370f8 commit 3cda080

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

src/backend/access/heap/heapam_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ heapam_free_rd_amcache(Relation rel)
105105
*/
106106

107107
static IndexFetchTableData *
108-
heapam_index_fetch_begin(Relation rel)
108+
heapam_index_fetch_begin(Relation rel, Relation index)
109109
{
110110
IndexFetchHeapData *hscan = palloc0(sizeof(IndexFetchHeapData));
111111

src/backend/access/index/indexam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ index_beginscan(Relation heapRelation,
340340
scan->xs_snapshot = snapshot;
341341

342342
/* prepare to fetch index matches from table */
343-
scan->xs_heapfetch = table_index_fetch_begin(heapRelation);
343+
scan->xs_heapfetch = table_index_fetch_begin(heapRelation, indexRelation);
344344

345345
return scan;
346346
}
@@ -628,7 +628,7 @@ index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys,
628628
scan->xs_snapshot = snapshot;
629629

630630
/* prepare to fetch index matches from table */
631-
scan->xs_heapfetch = table_index_fetch_begin(heaprel);
631+
scan->xs_heapfetch = table_index_fetch_begin(heaprel, indexrel);
632632

633633
return scan;
634634
}

src/backend/access/nbtree/nbtinsert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ _bt_check_unique(Relation rel, BTInsertState insertstate, Relation heapRel,
557557
* with optimizations like heap's HOT, we have just a single
558558
* index entry for the entire chain.
559559
*/
560-
else if (table_index_fetch_tuple_check(heapRel, &htid,
560+
else if (table_index_fetch_tuple_check(heapRel, rel, &htid,
561561
&SnapshotDirty,
562562
&all_dead))
563563
{
@@ -615,7 +615,7 @@ _bt_check_unique(Relation rel, BTInsertState insertstate, Relation heapRel,
615615
* entry.
616616
*/
617617
htid = itup->t_tid;
618-
if (table_index_fetch_tuple_check(heapRel, &htid,
618+
if (table_index_fetch_tuple_check(heapRel, rel, &htid,
619619
SnapshotSelf, NULL))
620620
{
621621
/* Normal case --- it's still live */

src/backend/access/table/tableam.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ table_beginscan_parallel(Relation relation, ParallelTableScanDesc pscan)
216216
*/
217217
bool
218218
table_index_fetch_tuple_check(Relation rel,
219+
Relation indexRel,
219220
ItemPointer tid,
220221
Snapshot snapshot,
221222
bool *all_dead)
@@ -226,7 +227,7 @@ table_index_fetch_tuple_check(Relation rel,
226227
bool found;
227228

228229
slot = table_slot_create(rel, NULL);
229-
scan = table_index_fetch_begin(rel);
230+
scan = table_index_fetch_begin(rel, indexRel);
230231
found = table_index_fetch_tuple(scan, PointerGetDatum(tid), snapshot, slot, &call_again,
231232
all_dead);
232233
table_index_fetch_end(scan);

src/backend/commands/constraint.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@ unique_key_recheck(PG_FUNCTION_ARGS)
130130
*/
131131
tmptidDatum = checktidDatum;
132132
{
133-
IndexFetchTableData *scan = table_index_fetch_begin(trigdata->tg_relation);
133+
IndexFetchTableData *scan;
134134
bool call_again = false;
135135

136+
indexRel = index_open(trigdata->tg_trigger->tgconstrindid, AccessShareLock);
137+
scan = table_index_fetch_begin(trigdata->tg_relation, indexRel);
138+
index_close(indexRel, AccessShareLock);
136139
if (!table_index_fetch_tuple(scan, tmptidDatum, SnapshotSelf, slot,
137140
&call_again, NULL))
138141
{

src/backend/executor/execIndexing.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
11141114
TupleTableSlot *existing_slot;
11151115
TupleTableSlot *save_scantuple;
11161116

1117+
11171118
if (indexInfo->ii_ExclusionOps)
11181119
{
11191120
constr_procs = indexInfo->ii_ExclusionProcs;

src/include/access/tableam.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ typedef struct TableAmRoutine
448448
*
449449
* Tuples for an index scan can then be fetched via index_fetch_tuple.
450450
*/
451-
struct IndexFetchTableData *(*index_fetch_begin) (Relation rel);
451+
struct IndexFetchTableData *(*index_fetch_begin) (Relation rel, Relation index);
452452

453453
/*
454454
* Reset index fetch. Typically this will release cross index fetch
@@ -1225,9 +1225,9 @@ table_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
12251225
* Tuples for an index scan can then be fetched via table_index_fetch_tuple().
12261226
*/
12271227
static inline IndexFetchTableData *
1228-
table_index_fetch_begin(Relation rel)
1228+
table_index_fetch_begin(Relation rel, Relation index)
12291229
{
1230-
return rel->rd_tableam->index_fetch_begin(rel);
1230+
return rel->rd_tableam->index_fetch_begin(rel, index);
12311231
}
12321232

12331233
/*
@@ -1300,6 +1300,7 @@ table_index_fetch_tuple(struct IndexFetchTableData *scan,
13001300
* unique index.
13011301
*/
13021302
extern bool table_index_fetch_tuple_check(Relation rel,
1303+
Relation indexRel,
13031304
ItemPointer tid,
13041305
Snapshot snapshot,
13051306
bool *all_dead);

0 commit comments

Comments
 (0)