From: Tom Lane <tgl@sss.pgh.pa.us>
To: tjo@acm.org
Cc: pgsql-sql@postgresql.org
Subject: Re: 9.17.5. Row-wise Comparison
Date: Thu, 07 Apr 2005 00:47:42 -0400
Message-ID: <13655.1112849262@sss.pgh.pa.us> (raw)
In-Reply-To: <4254AD87.2030508@acm.org>
References: <200504032037.j33Kb1kh016358@hosting.commandprompt.com>
<4254AD87.2030508@acm.org>
"TJ O'Donnell" <tjo@acm.org> writes:
> I've been using syntax like
> select a from tbl where (b,c,d) > (1,2,3)
> to mean
> select a from t where b>1 and b>2 and d>3
> But I see in the manual at:
> http://www.postgresql.org/docs/7.4/interactive/functions-comparisons.html#AEN12735
> that only = and <> operators are supported. Does this section of the manual
> not properly apply to this query? Is the manual in error, or am I
> not understanding?
PG's current code acts as you are supposing, but it is broken because it
doesn't follow the SQL spec, and we will change it as soon as someone
gets around to working on it.
The spec says that this syntax implies a column-by-column ordering,
essentially
if (b > 1) then true
else if (b = 1 and c > 2) then true
else if (b = 1 and c = 2 and d > 3) then true
else false
You can find related discussions in the archives from a few months
back. The spec's semantics correspond exactly to the sort ordering
of a multiple-column btree index, and so there are good reasons why we'd
want to provide that behavior even if it weren't mandated by the spec.
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, tjo@acm.org
Subject: Re: 9.17.5. Row-wise Comparison
In-Reply-To: <13655.1112849262@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