Skip site navigation (1) Skip section navigation (2)

Re: Search content within a bytea field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sylvain Leroux <sl20(at)wanadoo(dot)fr>
Cc: pgsql-jdbc(at)postgresql(dot)org, Damiano Bolzoni <damiano(dot)bolzoni(at)gmail(dot)com>
Subject: Re: Search content within a bytea field
Date: 2009-08-30 22:58:49
Message-ID: 4017.1251673129@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-jdbc
Sylvain Leroux <sl20(at)wanadoo(dot)fr> writes:
> It seems to me that the problem is comming from the BYTEA type, not from 
> the prepared statement by itself: As far as I know the only operator 
> supported by BYTEA is concatenation. You can't even compare two BYTEA 
> for (in)equality - even less using the LIKE operator.

Nonsense ...

regression=# select oid::regoperator from pg_operator where oprleft = 'bytea'::regtype or oprright = 'bytea'::regtype;
       oid        
------------------
 =(bytea,bytea)
 <>(bytea,bytea)
 <(bytea,bytea)
 <=(bytea,bytea)
 >(bytea,bytea)
 >=(bytea,bytea)
 ~~(bytea,bytea)
 !~~(bytea,bytea)
 ||(bytea,bytea)
(9 rows)

But this does point out the problem: LIKE (a/k/a ~~) on a bytea wants
a bytea on the righthand side, not text or varchar.  So setString is
the wrong thing to use.

			regards, tom lane

In response to

Responses

pgsql-jdbc by date

Next:From: Damiano BolzoniDate: 2009-08-31 06:06:36
Subject: Re: Search content within a bytea field
Previous:From: Sylvain LerouxDate: 2009-08-30 21:51:51
Subject: Re: Search content within a bytea field

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group