Re: UTF-8 context of BYTEA datatype??

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: UTF-8 context of BYTEA datatype??
Дата
Msg-id 20060529120114.GC14432@svana.org
обсуждение исходный текст
Ответ на UTF-8 context of BYTEA datatype??  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Ответы Re: UTF-8 context of BYTEA datatype??  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Список pgsql-general
On Mon, May 29, 2006 at 01:35:58PM +0200, Rafal Pietrak wrote:
> The table is originally initialized with a set of IDs. Then I'm using
> perl-script to insert apropriate images by means of UPDATEing rows:
> --------------within my script called 'job'-------------------
>     my $db = DBI->connect('DBI:Pg:dbname=mydb') or die "DBI";
>     my $z = $db->prepare("UPDATE pics set img=? where id=?") or die
> "PREPARE";
>     my $rc = $z->execute($content, $FILEID) or die "EXEC";
> ---------------------
>
> But the result is somewhat unexpected:
> ---------------console output----------------------
> DBD::Pg::st execute failed: ERROR:  invalid byte sequence for encoding
> "UTF8": 0x89
> EXEC at ./job line 22, <> chunk 1.
> ---------------------------------
>
> How come the bytearea is *interpreted* as having encoding?

Actually, it's not the bytea type that is being interpreted, it's the
string you're sending to the server that is. Before you send bytea data
in a query string, you have to bytea encode it first. The DBD::Pg
manpage seems to suggest something like:

             $rv = $sth->bind_param($param_num, $bind_value,
                                    { pg_type => DBD::Pg::PG_BYTEA });

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: UTF-8 context of BYTEA datatype??
Следующее
От: Eci Souji
Дата:
Сообщение: Re: DB structure for logically similar objects in different