Skip to content

Commit 1585ff7

Browse files
committed
Don't allow GetTransactionSnapshot() in logical decoding
A historic snapshot should only be used for catalog access, not general queries. We never call GetTransactionSnapshot() during logical decoding, which is good because it wouldn't be very sensible, so the code to deal with that was unreachable and untested. Turn it into an error, to avoid doing that in the future either. Discussion: https://www.postgresql.org/message-id/a868fe78-ddb4-4b0a-9b96-873d91d93cfd@iki.fi
1 parent 952365c commit 1585ff7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/backend/utils/time/snapmgr.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,12 @@ Snapshot
212212
GetTransactionSnapshot(void)
213213
{
214214
/*
215-
* Return historic snapshot if doing logical decoding. We'll never need a
216-
* non-historic transaction snapshot in this (sub-)transaction, so there's
217-
* no need to be careful to set one up for later calls to
218-
* GetTransactionSnapshot().
215+
* This should not be called while doing logical decoding. Historic
216+
* snapshots are only usable for catalog access, not for general-purpose
217+
* queries.
219218
*/
220219
if (HistoricSnapshotActive())
221-
{
222-
Assert(!FirstSnapshotSet);
223-
return HistoricSnapshot;
224-
}
220+
elog(ERROR, "cannot take query snapshot during logical decoding");
225221

226222
/* First call in transaction? */
227223
if (!FirstSnapshotSet)

0 commit comments

Comments
 (0)