Re: how to read bytea field - Mailing list pgsql-general

From Markus Schiltknecht
Subject Re: how to read bytea field
Date
Msg-id 45B76170.7010501@bluegap.ch
Whole thread Raw
In response to Re: how to read bytea field  (marcelo Cortez <jmdc_marcelo@yahoo.com.ar>)
Responses Re: how to read bytea field  (marcelo Cortez <jmdc_marcelo@yahoo.com.ar>)
List 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


pgsql-general by date:

Previous
From: marcelo Cortez
Date:
Subject: Re: how to read bytea field
Next
From: marcelo Cortez
Date:
Subject: Re: how to read bytea field