pgsql: Fix tracking of psql script line numbers during \copy from anoth

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix tracking of psql script line numbers during \copy from anoth
Date: 2014-03-10 19:47:52
Message-ID: E1WN6Ay-000860-RM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix tracking of psql script line numbers during \copy from another place.

Commit 08146775acd8bfe0fcc509c71857abb928697171 changed do_copy() to
temporarily scribble on pset.cur_cmd_source. That was a mighty ugly bit of
code in any case, but in particular it broke handleCopyIn's ability to tell
whether it was reading from the current script source file (in which case
pset.lineno should be incremented for each line of COPY data), or from
someplace else (in which case it shouldn't). The former case still worked,
the latter not so much. The visible effect was that line numbers reported
for errors in a script file would be wrong if there were an earlier \copy
that was reading anything other than inline-in-the-script-file data.

To fix, introduce another pset field that holds the file do_copy wants the
COPY code to use. This is a little bit ugly, but less so than passing the
file down explicitly through several layers that aren't COPY-specific.

Extracted from a larger patch by Kumar Rajeev Rastogi; that patch also
changes printing of COPY command tags, which is not a bug fix and shouldn't
get back-patched. This particular idea was from a suggestion by Amit
Khandekar, if I'm reading the thread correctly.

Back-patch to 9.2 where the faulty code was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e85a5ffba8ae559b612b6fbc07acf1b16636887e

Modified Files
--------------
src/bin/psql/common.c | 21 ++++++++++++++++++---
src/bin/psql/copy.c | 15 ++++-----------
src/bin/psql/settings.h | 2 ++
src/bin/psql/startup.c | 1 +
4 files changed, 25 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-03-12 12:52:14 pgsql: In WAL replay, restore GIN metapage unconditionally to avoid tor
Previous Message Robert Haas 2014-03-10 18:06:28 pgsql: Allow dynamic shared memory segments to be kept until shutdown.