Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0686E6330BC for ; Sun, 30 Aug 2009 20:00:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 66532-02 for ; Sun, 30 Aug 2009 23:00:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C4DFF6329F4 for ; Sun, 30 Aug 2009 20:00:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n7UMwnPP004018; Sun, 30 Aug 2009 18:58:50 -0400 (EDT) To: Sylvain Leroux cc: pgsql-jdbc@postgresql.org, Damiano Bolzoni Subject: Re: Search content within a bytea field In-reply-to: <4A9AF477.5040706@wanadoo.fr> References: <6fb522db0908301333o3bfeb6e9l5c2ad9dd04308e18@mail.gmail.com> <4A9AF477.5040706@wanadoo.fr> Comments: In-reply-to Sylvain Leroux message dated "Sun, 30 Aug 2009 23:51:51 +0200" Date: Sun, 30 Aug 2009 18:58:49 -0400 Message-ID: <4017.1251673129@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/91 X-Sequence-Number: 19940 Sylvain Leroux 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