type cast from bytea to varchar or whatever

From: Michael Monnerie <michael(dot)monnerie(at)is(dot)it-management(dot)at>
To: pgsql-admin(at)postgresql(dot)org
Subject: type cast from bytea to varchar or whatever
Date: 2009-09-10 08:37:20
Message-ID: 200909101037.20571@zmi.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Dear list,

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

[ERROR: operator does not exist: bytea ~~* unknown LINE 1: ...55) ILIKE
'%multipart/encrypted%' OR k.messageblk ILIKE '%mu...
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.

OK, but how to cast that? messageblk is of type "bytea", so I can't use
these:

SELECT k.messageblk FROM dbmail_messageblks k WHERE k.messageblk ILIKE
'%multipart/encrypted%'::bytea;
SELECT k.messageblk FROM dbmail_messageblks k WHERE
k.messageblk::varchar ILIKE '%multipart/encrypted%';

any ideas?

(It should just convert, in case of special chars ignore them. The
contect are mails, so normally text. Don't care about non-ascii here.)

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0660 / 415 65 31 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: wwwkeys.eu.pgp.net Key-ID: 1C1209B4

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Keller, Oliver 2009-09-10 09:37:15 integer import problem
Previous Message Verna Violet 2009-09-09 21:46:07 RE