pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reject COPY TO of unlogged tables during recovery.
Date: Wed, 21 Oct 2026 17:46:08 +0000
Message-ID: <E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org> (raw)

Reject COPY TO of unlogged tables during recovery.

Unlogged tables have no data on a standby, so reading one there must
fail. SELECT and COPY (SELECT ...) TO already report a clear error,
but COPY with a table name read the table directly and failed with a
low-level error instead:

ERROR:  could not open file "base/5/16384": No such file or directory

Check for this case in COPY TO and report the same error as SELECT. On
v19 and later, also check each partition when copying from a
partitioned table, so that an unlogged partition is reported too.

Backpatch to all supported versions, since the low-level error looks
like data corruption.

Author: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/b6d71815-d362-4579-bf07-73eca01aee6d@uni-muenster.de
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/044887b6081239122eaa3c18fc01a14f0a1ffb45

Modified Files
--------------
src/backend/commands/copyto.c         |  5 +++++
src/test/recovery/t/001_stream_rep.pl | 13 +++++++++++++
2 files changed, 18 insertions(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org>
Permalink:  ../E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: msawada@postgresql.org
  Subject: Re: pgsql: Reject COPY TO of unlogged tables during recovery.
  In-Reply-To: <E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org>
  References: <E1xJaO8-00000000DVV-3lYy@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox