Skip to content

Commit 62a634a

Browse files
committed
Fix index_beginscan signature for PG18 compatibility
PG18 added an IndexScanInstrumentation parameter to index_beginscan. Add compatibility macro that handles the signature difference between PG versions and update all callers to use the new macro. postgres/postgres@0fbceae8 Show index search count in EXPLAIN ANALYZE, take 2.
1 parent 3439e40 commit 62a634a

7 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/chunk_adaptive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ minmax_heapscan(Relation rel, Oid atttype, AttrNumber attnum, Datum minmax[2])
184184
static MinMaxResult
185185
minmax_indexscan(Relation rel, Relation idxrel, AttrNumber attnum, Datum minmax[2])
186186
{
187-
IndexScanDesc scan = index_beginscan(rel, idxrel, GetTransactionSnapshot(), 0, 0);
187+
IndexScanDesc scan = index_beginscan_compat(rel, idxrel, GetTransactionSnapshot(), NULL, 0, 0);
188188
TupleTableSlot *slot = table_slot_create(rel, NULL);
189189
bool nulls[2] = { true, true };
190190
int i;

src/compat/compat.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,25 @@ pg_cmp_u32(uint32 a, uint32 b)
669669
#define i64abs(i) llabs(i)
670670
#endif
671671
#endif
672+
673+
/*
674+
* PG18 adds IndexScanInstrumentation parameter to index_beginscan
675+
* https://github.com/postgres/postgres/commit/0fbceae8
676+
*/
677+
#if PG18_LT
678+
#define index_beginscan_compat(heapRelation, \
679+
indexRelation, \
680+
snapshot, \
681+
instrument, \
682+
nkeys, \
683+
norderbys) \
684+
index_beginscan(heapRelation, indexRelation, snapshot, nkeys, norderbys)
685+
#else
686+
#define index_beginscan_compat(heapRelation, \
687+
indexRelation, \
688+
snapshot, \
689+
instrument, \
690+
nkeys, \
691+
norderbys) \
692+
index_beginscan(heapRelation, indexRelation, snapshot, instrument, nkeys, norderbys)
693+
#endif

src/scanner.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ index_scanner_beginscan(ScannerCtx *ctx)
9797
{
9898
InternalScannerCtx *ictx = &ctx->internal;
9999

100-
ictx->scan.index_scan =
101-
index_beginscan(ctx->tablerel, ctx->indexrel, ctx->snapshot, ctx->nkeys, ctx->norderbys);
100+
ictx->scan.index_scan = index_beginscan_compat(ctx->tablerel,
101+
ctx->indexrel,
102+
ctx->snapshot,
103+
NULL,
104+
ctx->nkeys,
105+
ctx->norderbys);
102106
ictx->scan.index_scan->xs_want_itup = ctx->want_itup;
103107
index_rescan(ictx->scan.index_scan, ctx->scankey, ctx->nkeys, NULL, ctx->norderbys);
104108
return ictx->scan;

tsl/src/compression/compression.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ compress_chunk(Oid in_table, Oid out_table, int insert_options)
475475
"using index \"%s\" to scan rows for converting to columnstore",
476476
get_rel_name(matched_index_rel->rd_id));
477477

478-
index_scan = index_beginscan(in_rel, matched_index_rel, GetTransactionSnapshot(), 0, 0);
478+
index_scan =
479+
index_beginscan_compat(in_rel, matched_index_rel, GetTransactionSnapshot(), NULL, 0, 0);
479480
slot = table_slot_create(in_rel, NULL);
480481
index_rescan(index_scan, NULL, 0, NULL, 0);
481482
report_reltuples = calculate_reltuples_to_report(in_rel->rd_rel->reltuples);

tsl/src/compression/compression_dml.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ decompress_batch_beginscan(Relation in_rel, Relation index_rel, Snapshot snapsho
464464

465465
if (index_rel)
466466
{
467-
scan->index_scan = index_beginscan(in_rel, index_rel, snapshot, num_scankeys, 0);
467+
scan->index_scan =
468+
index_beginscan_compat(in_rel, index_rel, snapshot, NULL, num_scankeys, 0);
468469
index_rescan(scan->index_scan, scankeys, num_scankeys, NULL, 0);
469470
scan->scan = NULL;
470471
}

tsl/src/compression/recompress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk)
324324

325325
HeapTuple compressed_tuple;
326326
IndexScanDesc index_scan =
327-
index_beginscan(compressed_chunk_rel, index_rel, snapshot, num_segmentby, 0);
327+
index_beginscan_compat(compressed_chunk_rel, index_rel, snapshot, NULL, num_segmentby, 0);
328328

329329
bool found_tuple = fetch_uncompressed_chunk_into_tuplesort(input_tuplesortstate,
330330
uncompressed_chunk_rel,

tsl/src/continuous_aggs/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ get_direct_view_oid(int32 mat_hypertable_id)
738738

739739
/* Prepare index scan */
740740
IndexScanDesc indexscan =
741-
index_beginscan(cagg_rel, cagg_idx_rel, GetTransactionSnapshot(), 1, 0);
741+
index_beginscan_compat(cagg_rel, cagg_idx_rel, GetTransactionSnapshot(), NULL, 1, 0);
742742
index_rescan(indexscan, scankeys, 1, NULL, 0);
743743

744744
/* Read tuple from relation */

0 commit comments

Comments
 (0)