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:45:53 +0000
Message-ID: <E1xJaNt-00000000DSz-2j8J@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
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1e707d32564497ed2478f4186b90d0821719957b
Modified Files
--------------
src/backend/commands/copyto.c | 19 +++++++++++++++++++
src/test/recovery/t/001_stream_rep.pl | 27 +++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
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: <E1xJaNt-00000000DSz-2j8J@gemulon.postgresql.org>
References: <E1xJaNt-00000000DSz-2j8J@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