Skip to content

Commit 1b7e7ca

Browse files
committed
pass indexRel to table_index_fetch_begin to detect index bridging for orioledb
1 parent d2f3ddc commit 1b7e7ca

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
@@ -106,7 +106,7 @@ heapam_free_rd_amcache(Relation rel)
106106
*/
107107

108108
static IndexFetchTableData *
109-
heapam_index_fetch_begin(Relation rel)
109+
heapam_index_fetch_begin(Relation rel, Relation index)
110110
{
111111
IndexFetchHeapData *hscan = palloc0(sizeof(IndexFetchHeapData));
112112

src/backend/access/index/indexam.c

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

351351
/* prepare to fetch index matches from table */
352-
scan->xs_heapfetch = table_index_fetch_begin(heapRelation);
352+
scan->xs_heapfetch = table_index_fetch_begin(heapRelation, indexRelation);
353353

354354
return scan;
355355
}
@@ -635,7 +635,7 @@ index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys,
635635
scan->xs_snapshot = snapshot;
636636

637637
/* prepare to fetch index matches from table */
638-
scan->xs_heapfetch = table_index_fetch_begin(heaprel);
638+
scan->xs_heapfetch = table_index_fetch_begin(heaprel, indexrel);
639639

640640
return scan;
641641
}

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
@@ -207,6 +207,7 @@ table_beginscan_parallel(Relation relation, ParallelTableScanDesc pscan)
207207
*/
208208
bool
209209
table_index_fetch_tuple_check(Relation rel,
210+
Relation indexRel,
210211
ItemPointer tid,
211212
Snapshot snapshot,
212213
bool *all_dead)
@@ -217,7 +218,7 @@ table_index_fetch_tuple_check(Relation rel,
217218
bool found;
218219

219220
slot = table_slot_create(rel, NULL);
220-
scan = table_index_fetch_begin(rel);
221+
scan = table_index_fetch_begin(rel, indexRel);
221222
found = table_index_fetch_tuple(scan, PointerGetDatum(tid), snapshot, slot, &call_again,
222223
all_dead);
223224
table_index_fetch_end(scan);

src/backend/commands/constraint.c

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

134+
indexRel = index_open(trigdata->tg_trigger->tgconstrindid, AccessShareLock);
135+
scan = table_index_fetch_begin(trigdata->tg_relation, indexRel);
136+
index_close(indexRel, AccessShareLock);
134137
if (!table_index_fetch_tuple(scan, tmptidDatum, SnapshotSelf, slot,
135138
&call_again, NULL))
136139
{

src/backend/executor/execIndexing.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
11191119
TupleTableSlot *existing_slot;
11201120
TupleTableSlot *save_scantuple;
11211121

1122+
11221123
if (indexInfo->ii_ExclusionOps)
11231124
{
11241125
constr_procs = indexInfo->ii_ExclusionProcs;

src/include/access/tableam.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ typedef struct TableAmRoutine
456456
*
457457
* Tuples for an index scan can then be fetched via index_fetch_tuple.
458458
*/
459-
struct IndexFetchTableData *(*index_fetch_begin) (Relation rel);
459+
struct IndexFetchTableData *(*index_fetch_begin) (Relation rel, Relation index);
460460

461461
/*
462462
* Reset index fetch. Typically this will release cross index fetch
@@ -1230,9 +1230,9 @@ table_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
12301230
* Tuples for an index scan can then be fetched via table_index_fetch_tuple().
12311231
*/
12321232
static inline IndexFetchTableData *
1233-
table_index_fetch_begin(Relation rel)
1233+
table_index_fetch_begin(Relation rel, Relation index)
12341234
{
1235-
return rel->rd_tableam->index_fetch_begin(rel);
1235+
return rel->rd_tableam->index_fetch_begin(rel, index);
12361236
}
12371237

12381238
/*
@@ -1305,6 +1305,7 @@ table_index_fetch_tuple(struct IndexFetchTableData *scan,
13051305
* unique index.
13061306
*/
13071307
extern bool table_index_fetch_tuple_check(Relation rel,
1308+
Relation indexRel,
13081309
ItemPointer tid,
13091310
Snapshot snapshot,
13101311
bool *all_dead);

0 commit comments

Comments
 (0)