pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix pg_dump --inserts mode for generated columns with dropped co
Date: Mon, 22 Nov 2021 20:26:05 +0000
Message-ID: <E1mpFt7-0000mo-8G@gemulon.postgresql.org> (raw)

Fix pg_dump --inserts mode for generated columns with dropped columns.

If a table contains a generated column that's preceded by a dropped
column, dumpTableData_insert failed to account for the dropped
column, and would emit DEFAULT placeholder(s) in the wrong column(s).
This resulted in failures at restore time.  The default COPY code path
did not have this bug, likely explaining why it wasn't noticed sooner.

While we're fixing this, we can be a little smarter about the
situation: (1) avoid unnecessarily fetching the values of generated
columns, (2) omit generated columns from the output, too, if we're
using --column-inserts.  While these modes aren't expected to be
as high-performance as the COPY path, we might as well be as
efficient as we can; it doesn't add much complexity.

Per report from Дмитрий Иванов.
Back-patch to v12 where generated columns came in.

Discussion: https://postgr.es/m/CAPL5KHrkBniyQt5e1rafm5DdXvbgiiqfEQEJ9GjtVzN71Jj5pA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0b126c6a4b00972f2f3533e1718bbe297e2851c2

Modified Files
--------------
src/bin/pg_dump/pg_dump.c        | 51 ++++++++++++++++++++++++-----
src/bin/pg_dump/t/002_pg_dump.pl | 69 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 111 insertions(+), 9 deletions(-)



view thread (4+ messages)

Message-ID: <E1mpFt7-0000mo-8G@gemulon.postgresql.org>
Permalink:  ../E1mpFt7-0000mo-8G@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mpFt7-0000mo-8G@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix pg_dump --inserts mode for generated columns with dropped co
  In-Reply-To: <E1mpFt7-0000mo-8G@gemulon.postgresql.org>
  References: <E1mpFt7-0000mo-8G@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