pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of redundant options with COPY for "freeze" and "he
Date: Mon, 05 Oct 2020 00:46:28 +0000
Message-ID: <E1kPEe4-00054Z-Pb@gemulon.postgresql.org> (raw)

Fix handling of redundant options with COPY for "freeze" and "header"

The handling of those options was inconsistent, as the processing used
directly the value assigned to the option to check if it was redundant,
leading to patterns like this one to succeed (note that false is
specified first):
COPY hoge to '/path/to/file/' (header off, header on);

And the opposite would fail correctly (note that true is first here):
COPY hoge to '/path/to/file/' (header on, header off);

While on it, add some tests to check for all redundant patterns with the
options of COPY.  I have gone through the code and did not notice
similar mistakes for other commands.

"header" got it wrong since b63990c, and "freeze" was wrong from the
start as of 8de72b6.  No backpatch is done per the lack of complaints.

Reported-by: Rémi Lapeyre
Discussion: https://postgr.es/m/20200929072433.GA15570@paquier.xyz
Discussion: https://postgr.es/m/0B55BD07-83E4-439F-AACC-FA2D7CF50532@lenstra.fr

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/10c5291cc2c6497d5abe04dde7df649d898becc4

Modified Files
--------------
src/backend/commands/copy.c         |  8 +++++--
src/test/regress/expected/copy2.out | 47 +++++++++++++++++++++++++++++++++++++
src/test/regress/sql/copy2.sql      | 14 +++++++++++
3 files changed, 67 insertions(+), 2 deletions(-)



Message-ID: <E1kPEe4-00054Z-Pb@gemulon.postgresql.org>
Permalink:  ../E1kPEe4-00054Z-Pb@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kPEe4-00054Z-Pb@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: michael@paquier.xyz
  Subject: Re: pgsql: Fix handling of redundant options with COPY for "freeze" and "he
  In-Reply-To: <E1kPEe4-00054Z-Pb@gemulon.postgresql.org>
  References: <E1kPEe4-00054Z-Pb@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