COPY TO regression with psql -c - Mailing list pgsql-bugs

From Zsolt Parragi
Subject COPY TO regression with psql -c
Date
Msg-id CAN4CZFPqa6c+u4uX5jJ8LANHTQ4dxM3m4_8G9WmX_A4-2wuv2A@mail.gmail.com
Whole thread
Responses Re: COPY TO regression with psql -c
List pgsql-bugs
Hello

The recent COPY ... FROM STDIN improvement caused a regression in COPY
TO ... FROM STDIN when used together with psql -c: it only considers
the first statement, so the copy fails if multiple commands are
specified. A very simple example is:

psql -c "SELECT 1; COPY t FROM STDIN;"

now fails with unexpected COPY_IN.

This is probably an uncommon use case, but it has a few legitimate
uses in scripts, such as:

gzip -dc data.csv.gz | psql -c 'TRUNCATE t; COPY t FROM STDIN WITH (FORMAT CSV)'

to (re)load a table's data.

I attached a proposed patch with a tap test case that showcases the issue.

Attachment

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19615: COVAR_POP / COVAR_SAMP / REGR_SXY return 0.0 instead of NaN
Next
From: Tom Lane
Date:
Subject: Re: BUG #19610: Database won't start if an unrelated process is exist