Обсуждение: inserting non-printable character in varchar when CLIENT_ENCODING is SQL_ASCII
Hi all,
i get the following error when attempting to do what's described in the title:
mytest=> \copy "public"."mytable4" ("my_int", "my_string") FROM data.dump DELIMITER E'\t' NULL 'NULL' CSV HEADER
ERROR: unterminated CSV quoted field
CONTEXT: COPY mytable4, line 3: "54 "hello
a \great d"
I'm not necessarily trying to insert a \0, i'd actually like to be able to insert any byte without resorting to using a bytea. i understood that this was what SQL_ASCII was intended for!
http://www.postgresql.org/docs/8.4/interactive/sql-copy.html also states that the \NNN or \xNN format works but I was never able to actually work (it stores "\", then "N" then ...)
Any help would be greatly appreciated as i've already spent hours on that matter..!
Thanks a lot in advance,
Anthony
PS: some context that may help:
psql (8.4.7, server 8.3.11)
mytest=> SHOW SERVER_ENCODING;
SQL_ASCII
mytest=> SHOW CLIENT_ENCODING;
SQL_ASCII
mytest=> CREATE TABLE "public"."mytable4" (
"my_int" integer,
"my_string" character varying(64)
);
cat data.dump | od -c
0000000 m y _ i n t \t m y _ s t r i n g
0000020 \n 5 4 \t " h e l l o \0 w o r l d
0000040 " \n
i get the following error when attempting to do what's described in the title:
mytest=> \copy "public"."mytable4" ("my_int", "my_string") FROM data.dump DELIMITER E'\t' NULL 'NULL' CSV HEADER
ERROR: unterminated CSV quoted field
CONTEXT: COPY mytable4, line 3: "54 "hello
a \great d"
I'm not necessarily trying to insert a \0, i'd actually like to be able to insert any byte without resorting to using a bytea. i understood that this was what SQL_ASCII was intended for!
http://www.postgresql.org/docs/8.4/interactive/sql-copy.html also states that the \NNN or \xNN format works but I was never able to actually work (it stores "\", then "N" then ...)
Any help would be greatly appreciated as i've already spent hours on that matter..!
Thanks a lot in advance,
Anthony
PS: some context that may help:
psql (8.4.7, server 8.3.11)
mytest=> SHOW SERVER_ENCODING;
SQL_ASCII
mytest=> SHOW CLIENT_ENCODING;
SQL_ASCII
mytest=> CREATE TABLE "public"."mytable4" (
"my_int" integer,
"my_string" character varying(64)
);
cat data.dump | od -c
0000000 m y _ i n t \t m y _ s t r i n g
0000020 \n 5 4 \t " h e l l o \0 w o r l d
0000040 " \n