Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns

Поиск
Список
Период
Сортировка
От Mario Splivalo
Тема Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns
Дата
Msg-id 49183EBD.7070807@megafon.hr
обсуждение исходный текст
Ответы Re: Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
I have this issue:

postgres=# select E'\xc5\x53\x94\x96\x83\x29';
ERROR:  invalid byte sequence for encoding "UTF8": 0xc553
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".
postgres=# show client_encoding ; client_encoding
----------------- UTF8
(1 row)

postgres=# show server_encoding ; server_encoding
----------------- UTF8
(1 row)

postgres=# select version();                                            version 

------------------------------------------------------------------------------------------------ PostgreSQL 8.3.5 on
i686-pc-linux-gnu,compiled by GCC gcc (GCC) 4.2.4 
 
(Ubuntu 4.2.4-1ubuntu3)
(1 row)




On postgres 8.2 this worked:

postgres=# select version();                                                    version 

----------------------------------------------------------------------------------------------------------------
PostgreSQL8.2.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 
 
20061115 (prerelease) (Debian 4.1.1-21)
(1 row)

postgres=# select E'\xc5\x53\x94\x96\x83\x29'; ?column?
---------- S)
(1 row)

postgres=# show client_encoding ; client_encoding
----------------- UTF8
(1 row)

postgres=# show server_encoding ; server_encoding
----------------- UTF8
(1 row)


I'm using the above mentioned string to store data into bytea column. I 
did pg_dump of the database on postgres 8.2, and then tried to restore 
it on postgres 8.3, and I got this error. The actuall line that produces 
error is like this:

INSERT INTO vpn_payins_bitfield (vpn_id, payload_pattern, encription, 
encription_key, charset, amount_width, shop_width, counter_width) VALUES 
(3, E'\\W*(\\w+)(?:\\W+(.*))?', 'RC4', 
E'\xc5\x53\x94\x96\x83\x29'::bytea, 'ABCDEGHIKLMOPTWX', 16, 8, 16);

The error is:
ERROR: invalid byte sequence for encoding "UTF8": 0xc553


Now, I see that I can type: "SELECT E'\xFF'" in pg8.2, but can't do that 
in pg8.3.

So, my question is, how do I specify hexadecimal value of C5 to be 
stored in bytea column, in an INSERT statement?
Mike


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

Предыдущее
От: "Sebastian Ritter"
Дата:
Сообщение: Re: Query optimizing
Следующее
От: Mario Splivalo
Дата:
Сообщение: Converting between UUID and VARCHAR