From: Tom Lane <tgl@sss.pgh.pa.us>
To: Damiano Bolzoni <damiano.bolzoni@gmail.com>
Cc: Sylvain Leroux <sl20@wanadoo.fr>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Search content within a bytea field
Date: Mon, 31 Aug 2009 10:11:11 -0400
Message-ID: <798.1251727871@sss.pgh.pa.us> (raw)
In-Reply-To: <6fb522db0908302306n7fcda5f7ncd7423f650855dca@mail.gmail.com>
References: <6fb522db0908301333o3bfeb6e9l5c2ad9dd04308e18@mail.gmail.com>
<4A9AF477.5040706@wanadoo.fr>
<6fb522db0908302306n7fcda5f7ncd7423f650855dca@mail.gmail.com>
Damiano Bolzoni <damiano.bolzoni@gmail.com> writes:
> But...why if I manually query with a SQL client (AquaStudio) as
> follows:
> SELECT myfield FROM mytable WHERE myfield LIKE '%hello%'
> and 'myfield' is a bytea field I get the result I expected?
The unknown-type literal is assumed to be of type bytea in this case.
In general, if the parser finds "known_type_value operator unmarked_literal"
then it preferentially selects an operator with both input types the
same, ie, it prefers to believe the unmarked_literal is the same data
type as the other input.
The JDBC environment behaves differently because setString and so on
do not produce unmarked literals --- there's an implicit cast to
some datatype. So you have to make sure you've picked a
parameter-setting function that is reasonably compatible with the
intended operation. This is a good thing, really; it tends to keep
the system from choosing an unexpected operation.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, damiano.bolzoni@gmail.com, sl20@wanadoo.fr
Subject: Re: Search content within a bytea field
In-Reply-To: <798.1251727871@sss.pgh.pa.us>
References: <6fb522db0908301333o3bfeb6e9l5c2ad9dd04308e18@mail.gmail.com> <4A9AF477.5040706@wanadoo.fr> <6fb522db0908302306n7fcda5f7ncd7423f650855dca@mail.gmail.com> <798.1251727871@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox