Re: type cast from bytea to varchar or whatever

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Monnerie <michael(dot)monnerie(at)is(dot)it-management(dot)at>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: type cast from bytea to varchar or whatever
Date: 2009-09-10 14:57:22
Message-ID: 23806.1252594642@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Michael Monnerie <michael(dot)monnerie(at)is(dot)it-management(dot)at> writes:
> in dbmail there's a query that worked until postgresql 8.2 (i stripped
> the unneeded parts for other tables):

> SELECT k.messageblk FROM dbmail_messageblks k WHERE k.messageblk ILIKE
> '%multipart/encrypted%';

> In 8.3, you get an error

There has *never* been a Postgres release that accepted bytea ILIKE
something. I'm not sure what you were really doing before, but that
wasn't it.

You could possibly get what you want by explicitly casting the bytea
value to text. But since that would have been needed (and was not
available) in earlier versions too, I'm a bit mystified by your claim
that this used to work.

I wouldn't really recommend relying on the cast to text, either,
as that has significant probability of not doing what you want
in 8.5 and above :-(. CVS HEAD does this:

regression=# select 'abcd'::bytea::text;
text
------------
\x61626364
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ken Banyas 2009-09-10 17:40:10 How to mask password when changing it using ALTER USER command in psql.
Previous Message raghu ram 2009-09-10 14:46:39 Re: Changing character set of existing databases