pgsql: Fix tracking of psql script line numbers during \copy from anoth - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix tracking of psql script line numbers during \copy from anoth
Date
Msg-id E1WN6Ay-000865-UP@gemulon.postgresql.org
Whole thread Raw
List 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
------
REL9_2_STABLE

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

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


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix tracking of psql script line numbers during \copy from anoth
Next
From: Tom Lane
Date:
Subject: pgsql: Fix tracking of psql script line numbers during \copy from anoth