Re: BUG #19939: In a read-only transaction, a plain SELECT ... INTO is refused, but the same statement under EXPLAIN

From: Daniel Pedersen <daniel(dot)horsens(at)gmail(dot)com>
To: Lukas Fittl <lukas(at)fittl(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19939: In a read-only transaction, a plain SELECT ... INTO is refused, but the same statement under EXPLAIN
Date: 2026-11-26 08:11:20
Message-ID: CAGN6XQAbPmgjxRBc_WDQ9+Gb8uzCLQ2N=vV2-gfVUxrW6Sz8sA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Lukas,

Thanks for sharing the thread.

Yes, I've checked the thread, and it looks like it covers the same
underlying issue as my BUG #19939.

In particular, Chao Li explicitly mentions in his November 20 reply that he
discovered that EXPLAIN ANALYZE also behaves incorrectly in read-only
transactions, creating tables when it should not.

I'll follow the thread there.

Thanks again!

Best regards,
Daniel

On Wed, 25 Nov 2026 at 20:44, Lukas Fittl <lukas(at)fittl(dot)com> wrote:

> Hi,
>
> On Wed, Nov 25, 2026 at 9:55 AM PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
> > In a read-only transaction, a plain SELECT ... INTO is refused, but the
> same
> > statement under EXPLAIN ANALYZE runs. It creates the table, inserts the
> > rows, and the table remains after COMMIT.
> >
> > The documentation for SET TRANSACTION says that in a read-only
> transaction
> > "all CREATE, ALTER, and DROP commands" are disallowed, as well as
> "EXPLAIN
> > ANALYZE and EXECUTE if the command they would execute is among those
> listed"
> > (https://www.postgresql.org/docs/18/sql-set-transaction.html) SELECT
> ...
> > INTO is CREATE TABLE AS, so I expected EXPLAIN ANALYZE SELECT ... INTO
> to be
> > refused with the same error.
>
> Thanks for the report!
>
> I believe this is already being discussed in this mailing list thread
> on pgsql-hackers:
>
>
> https://www.postgresql.org/message-id/flat/CAN4CZFNz40w6BDC7nXzmoXVokwCJ%2B36spPOSZjEkq8%3D3OGWqsw%40mail.gmail.com
>
> Thanks,
> Lukas
>
> --
> Lukas Fittl
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-26 09:32:05 Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance
Previous Message Xuneng Zhou 2026-11-26 07:51:31 Re: Lost walsender wakeup stalls synchronous commits until the standby's next reply (16+)