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.