Re: how to read bytea field

From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: marcelo Cortez <jmdc_marcelo(at)yahoo(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to read bytea field
Date: 2007-01-24 13:38:56
Message-ID: 45B76170.7010501@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

marcelo Cortez wrote:
> Yes i know, but if your define bytea field and store
> bytea in this field , decode don't work,

Sure it does:

test=# select encode(E'\\000\\001', 'escape')::text;
encode
----------
\000\x01
(1 row)

If you inspect the function, you'll find that encode can *only* handle
bytea, not text (as the first parameter):

test=# \df encode;
List of functions
Schema | Name | Result data type | Argument data types
------------+--------+------------------+---------------------
pg_catalog | encode | text | bytea, text
(1 row)

And trying to feed it text gives:

test=# select encode('some text'::text, 'escape')::text;
ERROR: function encode(text, "unknown") does not exist

Are you sure you tested with a real bytea field?

Regards

Markus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kenneth Marshall 2007-01-24 13:40:31 Re: [GENERAL] Autovacuum Improvements
Previous Message marcelo Cortez 2007-01-24 13:05:58 Re: how to read bytea field