Skip to content

COPY FROM STDIN doesn't work with \x-escape bytea values #167309

Description

@arp242

With the following file:

% cat a.sql
begin;
        create table tbl (b bytea);
        copy tbl from stdin;
\\xfefe
\.
        select b from tbl;
rollback;

PostgreSQL inserts it as bytea:

% psql -X 'postgres://pqgo@localhost/pqgo' <a.sql
BEGIN
CREATE TABLE
COPY 1
   b
--------
 \xfefe
(1 row)

ROLLBACK

But CockroachDB inserts it as a string:

% psql -X 'postgres://pqgo@localhost:26257/pqgo' <a.sql
BEGIN
CREATE TABLE
COPY 1
       b
----------------
 \x5c7866656665
(1 row)

ROLLBACK

\x5c7866656665 is \xfefe.

It looks like this was fixed a few years ago in #69640 (or something similar, anyway), so I think this ought to work?

This originally came up in the context of lib/pq#1304 – to reproduce it there you need to uncomment the pqtest.SkipCockroach and run:

% docker compose up -d cockroach
% PGPORT=26257 go test -run TestCopyInTypes

CockroachDB CCL v26.1.1 (x86_64-pc-linux-gnu, built 2026/03/04 12:08:22, go1.25.5)

Jira issue: CRDB-62373

Epic CRDB-62230

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an ownerv26.3.0-prerelease

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions