bytea hex input/output

From: "Michael Artz" <mlartz(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: bytea hex input/output
Date: 2006-05-16 20:14:23
Message-ID: 1147810463.746249.14600@i39g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Silly little question, but is there something to input/output hex
escaped data into a bytea, ala

CREATE TABLE a (lob BYTEA);
INSERT into a (lob) VALUES ('\x01\x02\x00\x03\x04');
INSERT into a (lob) VALUES ('\x01\x00\x02\x00\x03\x04');

It seems to work (doesn't error), but when selecting the data back out,
it is truncated at the first \x00, ala

SELECT lob FROM a;

lob
----------
\001\002
\001

SELECT octet_length(lob) from a;

octet_length
--------------
2
1

Why does this happen? Also, can I get the output in similar hex form?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2006-05-16 20:54:13 Re: problems with postgresql 9
Previous Message Scott Marlowe 2006-05-16 20:11:54 Re: Is it me, or the list?