Re: Debugging postmaster to fix possible bug in Postgres?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Nicholas Allen <nallen(at)freenet(dot)co(dot)uk>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Childs <blue(dot)dragon(at)blueyonder(dot)co(dot)uk>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Debugging postmaster to fix possible bug in Postgres?
Date: 2003-02-13 19:27:18
Message-ID: 20030213110929.X47380-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 13 Feb 2003, Nicholas Allen wrote:

> Because the WHERE clause is directly affected by the ORDER BY clause. If you
> leave out the order by clause then the row count will be completely different
> and therefore wrong. The ORDER BY clause is just as important as the WHERE
> clause when counting rows. It should be possible to get a count for the rows
> for any query that can be done which can return row data as I understand it.

WHERE effectively occurs before ORDER BY, so unless it's an order by in a
subselect I don't think the where clause can be affected by the ORDER BY
legally.

select count(*) from foo where a<3 order by a;
and
select count(*) from foo where a<3;
must give the same results AFAICT.

> I have tried to find a definition for SQL SELECT command but everywhere I have
> looked so far makes no mention of this being invalid SQL syntax. Can you let
> me know where you got this information?

I think this may follow from the syntax rules of the general select from
a strict reading of SQL92 20.2 and 9.7 (which implies to me that any
form of select a from table order by b; would be an extension) or a looser
reading of syntax rule 7 in 9.7 which disallows value expressions
referencing a column that wasn't specified in a set function specification
for non-grouped tables.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Manfred Koizar 2003-02-13 19:39:38 Re: Debugging postmaster to fix possible bug in Postgres? Followup to "How do you select
Previous Message Roberto Mello 2003-02-13 18:50:13 Re: SQL Functions vs PL/PgSQL