Re: postgres_fdw: Provide better emulation of READ COMMITTED behavior

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: postgres_fdw: Provide better emulation of READ COMMITTED behavior
Date: 2025-01-14 13:39:13
Message-ID: CA+TgmoZspyohOkZXy-hKzxQQ1jGF1dwY_2g1SyUEgWw1GP8iKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 7, 2024 at 4:03 AM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> On Fri, Dec 6, 2024 at 2:37 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > I have a hard time seeing how this would work if cursors are in use on
> > the main server. Say I do this:
> >
> > DECLARE foo CURSOR FOR SELECT * FROM ft1 UNION ALL SELECT * FROM ft2;
> > ...fetch some rows from cursor foo but few enough that we only scan ft1...
> > ...do something that causes a snapshot refresh like issue another query...
> > ...fetch more rows from cursor foo until we start scanning ft2...
>
> Good point! Maybe my explanation was not enough, but the proposed
> patch does not allow any query to do a snapshot refresh if such open
> cursors exist on the main server, so cursor foo is guaranteed to scan
> ft2 using the same snapshot that was used to scan ft1.

OK, I see. That does prevent the hazard I mentioned, but it also means
that the results returned by a query are dependent on whether there's
an unrelated cursor open, which seems unfortunate.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-01-14 13:40:46 Re: AIO v2.2
Previous Message Peter Eisentraut 2025-01-14 13:37:49 Re: Virtual generated columns