Libpq: copy file to bytea column

From: seiliki(at)so-net(dot)net(dot)tw
To: pgsql-general(at)postgresql(dot)org
Subject: Libpq: copy file to bytea column
Date: 2010-03-06 13:21:39
Message-ID: 20100306132146.43819F480CA@m5.so-net.net.tw
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 the server, 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian von Bidder 2010-03-06 13:55:28 Filesysstems
Previous Message Michael Wood 2010-03-06 11:52:43 Re: [NOVICE] How to find details of arguments in all functions in postgre - One solution