Re: Libpq: copy file to bytea column - Mailing list pgsql-general

From seiliki@so-net.net.tw
Subject Re: Libpq: copy file to bytea column
Date
Msg-id 20100308135159.EB4E7F4820A@m5.so-net.net.tw
Whole thread Raw
In response to Re: Libpq: copy file to bytea column  (seiliki@so-net.net.tw)
List pgsql-general
> What I can't understand is why PQputCopyData() encodes incoming character string, which was exported by "COPY ... TO
'/tmp/t'"SQL command under psql prompt, for bytea columns and refuse to accept or misinterpret zero value. 

As far as PQputCopyData() is concerned, server and/or client does not have to decode input character string for bytea
column,does they? My understanding is that all client or server need to do to import data to bytea column is
un-escapingall sets of \nnn (or \x000) character strings back to binary bytes and unconditionally store the result to
thetarget bytea column. 

Encoding/Decoding is required only by TEXT and (VAR)CHAR columns, isn't it?

Errors like the following ones should not occur to bytea columns, should they?

ERROR:  invalid byte sequence for encoding "UTF8": 0x00
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is
controlledby "client_encoding". 
CONTEXT:  COPY tablein, line 1: "abcd\011\000ABCDEFGH"
STATEMENT:  COPY tablein FROM STDIN

Regards,

CN

pgsql-general by date:

Previous
From: seiliki@so-net.net.tw
Date:
Subject: Re: Libpq: copy file to bytea column
Next
From: Devrim GÜNDÜZ
Date:
Subject: PostgreSQL RPM sets for 9.0 Alpha4 released