On Wed, Sep 9, 2026 at 9:25 PM Sami Imseih <[email protected]> wrote:
>
> Hi,
>
> Thanks for the review.
>
> > BEGIN ISOLATION LEVEL READ COMMITTED;
> > DECLARE c CURSOR FOR SELECT 1;
> > WAIT FOR LSN '0/0';
> > -- ERROR: WAIT FOR must be called without an active or registered snapshot
> >
> > BEGIN ISOLATION LEVEL READ COMMITTED;
> > SELECT pg_export_snapshot();
> > WAIT FOR LSN '0/0';
> > -- ERROR: WAIT FOR must be called without an active or registered snapshot
>
> This means there is a bug in the ERROR message DETAIL. Thanks for pointing
> this out.
>
> ```
> postgres=# begin;
> BEGIN
> postgres=*# DECLARE c CURSOR FOR SELECT 1;
> DECLARE CURSOR
> postgres=*# WAIT FOR LSN '0/0' WITH (mode 'PRIMARY_FLUSH');
> ERROR:  WAIT FOR must be called without an active or registered snapshot
> DETAIL:  WAIT FOR cannot be executed within a transaction with an
> isolation level higher than READ COMMITTED.
> postgres=!#
> ```
>
> So I fixed this by first checking the isolation level and using "WAIT
> FOR cannot be executed ... READ COMMITTED"
> as the errmsg. The existing snapshot check must come after that.
>
> I also added tests to cover the three relevant cases: READ COMMITTED
> with a snapshot, and
> REPEATABLE READ both with and without a snapshot. The REPEATABLE
> READ-with-snapshot
> case was already covered, but its expected error message needed to be updated.
>
> The results looks like this:
>
> ```
> postgres=# BEGIN ISOLATION LEVEL REPEATABLE READ;
> BEGIN
> postgres=*# select 1;
>  ?column?
> ----------
>         1
> (1 row)
>
> postgres=*# WAIT FOR LSN '0/0' WITH (mode 'PRIMARY_FLUSH');
> ERROR:  WAIT FOR cannot be executed within a transaction with an
> isolation level higher than READ COMMITTED
> postgres=!#
> ```
>
> ```
> postgres=# BEGIN ISOLATION LEVEL REPEATABLE READ;
> BEGIN
> postgres=*# WAIT FOR LSN '0/0' WITH (mode 'PRIMARY_FLUSH');
> ERROR:  WAIT FOR cannot be executed within a transaction with an
> isolation level higher than READ COMMITTED
> postgres=!#
> ```
>
> ```
> postgres=# BEGIN;
> BEGIN
> postgres=*# DECLARE c CURSOR FOR SELECT 1;
> DECLARE CURSOR
> postgres=*#
> postgres=*# WAIT FOR LSN '0/0' WITH (mode 'PRIMARY_FLUSH');
> ERROR:  WAIT FOR must be called without an active or registered snapshot
> postgres=!#

V2 LGTM. Do you prefer to keep the snapshot and isolation-level checks
next to each other?

-- 
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.


Reply via email to