Check the snapshot argument of index_beginscan and family

Alexander Korotkov <akorotkov@postgresql.org>

Commit: 941aa6a6268a6a66f6895401aad6b5329111d412
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date: 2022-12-06T00:29:18Z
Releases: 16.0
Check the snapshot argument of index_beginscan and family

Passing a NULL snapshot (InvalidSnapshot) is going to work but only as long
as the index can't find any matching rows.  This can be confusing for
the extension authors, so add an explicit check for this argument.  The check
is implemented with Assert() in order to avoid overhead in release builds.

Reported-by: Sven Klemm
Discussion: https://postgr.es/m/CAJ7c6TPxitD4vbKyP-mpmC1XwyHdPPqvjLzm%2BVpB88h8LGgneQ%40mail.gmail.com
Author: Aleksander Alekseev
Reviewed-by: Pavel Borisov

Files

PathChange+/−
src/backend/access/index/indexam.c modified +8 −0

Discussion