Re: COPY TO regression with psql -c

From: Christoph Berg <myon(at)debian(dot)org>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: COPY TO regression with psql -c
Date: 2026-08-12 08:37:18
Message-ID: anwwvl-fzGIbpk77@msg.df7cb.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: Zsolt Parragi
> psql -c "SELECT 1; COPY t FROM STDIN;"

The Debian package tests are also tripping over this. The test case
there is (in the encoding test file, hence the weird chars):

printf '���' | psql -qc "set client_encoding='iso-8859-5'; create table t (x varchar); copy t from stdin"
SET
CREATE TABLE
unexpected COPY_IN result, aborting connection

2026-08-12 10:31:46.434 CEST [77760] ERROR: unexpected EOF on client connection with an open transaction
2026-08-12 10:31:46.434 CEST [77760] CONTEXT: COPY t, line 1
2026-08-12 10:31:46.434 CEST [77760] STATEMENT: set client_encoding='iso-8859-5'; create table t (x varchar); copy t from stdin
2026-08-12 10:31:46.434 CEST [77760] LOG: could not send data to client: Broken pipe
2026-08-12 10:31:46.434 CEST [77760] STATEMENT: set client_encoding='iso-8859-5'; create table t (x varchar); copy t from stdin
2026-08-12 10:31:46.434 CEST [77760] FATAL: terminating connection because protocol synchronization was lost

> 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)'

I think that's a pretty common case. This "create and copy" is another example.

Christoph

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Holger Jakobs 2026-08-12 10:50:57 pg_upgrade from 17.10 to 18.4 on Ubuntu fails: Finding the real data directory for the target cluster sh: 1: (null)/postgres: not found
Previous Message Fujii Masao 2026-08-12 08:09:13 Re: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits