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

From seiliki@so-net.net.tw
Subject Libpq: copy file to bytea column
Date
Msg-id 20100306132146.43819F480CA@m5.so-net.net.tw
Whole thread Raw
Responses Re: Libpq: copy file to bytea column  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
List pgsql-general
Hi!

The data types of tableout.c1 and tablein.c1 are both bytea. I first export tableout.c1 to a file:

db1=# COPY (SELECT c1 FROM tableout LIMIT 1) TO '/tmp/t';

Then I try to import the file to another table.

This works without flaw:

db1=# COPY tablein FROM '/tmp/t';

However, I get the following errors from log when calling libpq functions PQputCopyData() and PQputCopyEnd().

2010-03-06 20:47:42 CST ERROR:  invalid byte sequence for encoding "UTF8": 0x00
2010-03-06 20:47:42 CST HINT:  This error can also happen if the byte sequence does not match the encoding expected by
theserver, which is controlled by "client_encoding". 
2010-03-06 20:47:42 CST CONTEXT:  COPY in, line 1:
"TPF0\011Report\000\003Tag\002\365\016ExportFromPage\002\000\014ExportToPage\002\000\006Values\016..."
2010-03-06 20:47:42 CST STATEMENT:  COPY in FROM STDIN


Helps will be much appreciated!

CN

pgsql-general by date:

Previous
From: Michael Wood
Date:
Subject: Re: [NOVICE] How to find details of arguments in all functions in postgre - One solution
Next
From: Adrian von Bidder
Date:
Subject: Filesysstems