Literal NUL using COPY TO

Started by François Beausoleilover 13 years ago2 messagesgeneral
Jump to latest
#1François Beausoleil
francois@teksol.info

Can one use COPY TO stdout to output a literal NUL byte as the delimiter?

# \encoding
UTF8
# copy (select * from q limit 1) to stdout with (format csv, delimiter E'\000', header false);
ERROR: invalid byte sequence for encoding "UTF8": 0x00

# \encoding sql_ascii
# copy (select * from q limit 1) to stdout with (format csv, delimiter E'\000', header false);
ERROR: invalid byte sequence for encoding "UTF8": 0x00

The archives of this list don't seem to have anything interesting, and Google doesn't either.

Thanks!
François

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: François Beausoleil (#1)
Re: Literal NUL using COPY TO

=?iso-8859-1?Q?Fran=E7ois_Beausoleil?= <francois@teksol.info> writes:

Can one use COPY TO stdout to output a literal NUL byte as the delimiter?

No. Postgres doesn't allow embedded NULs in text strings in general.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general