Re: SELECT d02name::bytea FROM ... && DBI::Pg

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: SELECT d02name::bytea FROM ... && DBI::Pg
Дата
Msg-id CA+bJJbx2q0ZrnC2NmF1uaGMfJ8HBfBh08cW4JH1wEV-ZDYvnPw@mail.gmail.com
обсуждение исходный текст
Ответ на SELECT d02name::bytea FROM ... && DBI::Pg  (Matthias Apitz <guru@unixarea.de>)
Ответы Re: SELECT d02name::bytea FROM ... && DBI::Pg
Список pgsql-general
Matthias:

On Thu, Oct 10, 2019 at 1:25 PM Matthias Apitz <guru@unixarea.de> wrote:
> I can SELECT && print a column in hex with:
> pos71=# select d02name::bytea from d02ben where d02bnr = '00001048313' ;
> ...
>  \x50c3a46461676f67697363686520486f6368736368756c65205765696e67617274656e2020 ...
>
> but when I use the same in Perl DBI::Pg with:
> $sth=$dbh->prepare( "select d02name::bytea from d02ben where d02bnr = '00001048313'");
...
> It prints the UTF-8 string and not the hex string:

May be because perl does not need the contents in hex DBI converts it
to a native string, which is very similar to a "bytea" inside the db (
not in the wire protocol, but it does a similar thing for numbers ).

Notice once you have a string in perl it is trivial to convert it to hex:
$ perl -e 'print(unpack("H*", "1234ABCD"),"\n")'
3132333441424344
$ perl -e 'print(unpack("H*", "día año"),"\n")'
64c3ad612061c3b16f

Francisco Olarte.



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

Предыдущее
От: Yessica Brinkmann
Дата:
Сообщение: Re: The connection to the server was lost. Attempting reset: Failed.
Следующее
От: Matthias Apitz
Дата:
Сообщение: Re: SELECT d02name::bytea FROM ... && DBI::Pg