From: Oliver Jowett <oliver@opencloud.com>
To: yoursoft <yoursoft@freemail.hu>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement vs. Statement problem
Date: Thu, 29 Nov 2007 22:21:35 +1300
Message-ID: <474E849F.3050603@opencloud.com> (raw)
In-Reply-To: <474E5E18.4080909@freemail.hu>
References: <c752d6bd0711280650q53b3547ew7ea92ca45fd38d12@mail.gmail.com>
<474E5E18.4080909@freemail.hu>
yoursoft wrote:
> I have a problem:
> SELECT * FROM mytable WHERE c1 like 'a' UNION ALL SELECT * FROM mytable
> WHERE c2 like 'a' || '%' AND c2 not like 'a' UNION ALL SELECT * FROM
> mytable WHERE c2 like '%' || 'a' || '%' AND c2 not like 'a' || '%' AND
> c2 not like 'a' LIMIT 101 OFFSET 0
>
> Where 'a' is a variable.
> When I run this query from Statement. There is no problem. The result is
> ordered by: First SELECT, second SELECT third SELECT.
> When I run this query from PreparedStatement ('a' values replaced by ?).
> The result is ordered by in alphabets.Why?
You don't have an ORDER BY so the result ordering is undefined. The
planner happens to pick different plans in the two cases which result in
different orderings.
-O
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: oliver@opencloud.com, yoursoft@freemail.hu
Subject: Re: PreparedStatement vs. Statement problem
In-Reply-To: <474E849F.3050603@opencloud.com>
References: <c752d6bd0711280650q53b3547ew7ea92ca45fd38d12@mail.gmail.com> <474E5E18.4080909@freemail.hu> <474E849F.3050603@opencloud.com>
* 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