Re: The mysterious BLOB and bytea data types

Поиск
Список
Период
Сортировка
От Hugh Mandeville
Тема Re: The mysterious BLOB and bytea data types
Дата
Msg-id 9lhgeh$25ig$1@news.tht.net
обсуждение исходный текст
Ответ на The mysterious BLOB and bytea data types  ("Dr. Evil" <drevil@sidereal.kz>)
Список pgsql-general
i use bytea, it is easier than using the large object functions.  you have
to escape your binary data on the way in (to work in the query string) and
unescape it on the way out.
> If you are using Perl DBD::Pg, it's done for you automatically.


i believe these are the escape rules for bytea (binary  -  string):
    0  -  \\000
    \  -  \\\\
    non-printable characters  -  \ooo  (where ooo is their 3 digit octet
value)
    '  -  ''

and these i believe are the unescape rules for bytea (string - binary):
    \ooo  -  N  (where ooo is their 3 digit octet value)
    \\  -  \

test=# CREATE TABLE testbinary ( id serial PRIMARY KEY, data bytea);
test=# INSERT INTO testbinary (data) VALUES
('\\000\001\002Three''Four''\\\\Five');
INSERT 124403 1
test=# select octet_length(data), data FROM testbinary;
 octet_length |             data
--------------+-------------------------------
           19 | \000\001\002Three'Four'\\Five
(1 row)


if you are not worried about space you could base64 encode the data and
store it as a varchar.




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

Предыдущее
От: Einar Karttunen
Дата:
Сообщение: Re: Re: Perfomance decreasing
Следующее
От: "mike"
Дата:
Сообщение: GUI Application mode