Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit941aa6a

Browse files
committed
Check the snapshot argument of index_beginscan and family
Passing a NULL snapshot (InvalidSnapshot) is going to work but only as longas the index can't find any matching rows. This can be confusing forthe extension authors, so add an explicit check for this argument. The checkis implemented with Assert() in order to avoid overhead in release builds.Reported-by: Sven KlemmDiscussion:https://postgr.es/m/CAJ7c6TPxitD4vbKyP-mpmC1XwyHdPPqvjLzm%2BVpB88h8LGgneQ%40mail.gmail.comAuthor: Aleksander AlekseevReviewed-by: Pavel Borisov
1 parenta7885c9 commit941aa6a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎src/backend/access/index/indexam.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ index_beginscan(Relation heapRelation,
209209
{
210210
IndexScanDescscan;
211211

212+
Assert(snapshot!=InvalidSnapshot);
213+
212214
scan=index_beginscan_internal(indexRelation,nkeys,norderbys,snapshot,NULL, false);
213215

214216
/*
@@ -237,6 +239,8 @@ index_beginscan_bitmap(Relation indexRelation,
237239
{
238240
IndexScanDescscan;
239241

242+
Assert(snapshot!=InvalidSnapshot);
243+
240244
scan=index_beginscan_internal(indexRelation,nkeys,0,snapshot,NULL, false);
241245

242246
/*
@@ -403,6 +407,8 @@ index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot)
403407
{
404408
Sizenbytes;
405409

410+
Assert(snapshot!=InvalidSnapshot);
411+
406412
RELATION_CHECKS;
407413

408414
nbytes= offsetof(ParallelIndexScanDescData,ps_snapshot_data);
@@ -437,6 +443,8 @@ index_parallelscan_initialize(Relation heapRelation, Relation indexRelation,
437443
{
438444
Sizeoffset;
439445

446+
Assert(snapshot!=InvalidSnapshot);
447+
440448
RELATION_CHECKS;
441449

442450
offset=add_size(offsetof(ParallelIndexScanDescData,ps_snapshot_data),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp