Re: Select aliasses in where and other places of the

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Arjen van der Meijden <acm(at)tweakers(dot)net>
Cc: 'Postgre General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: Select aliasses in where and other places of the
Date: 2003-03-29 18:48:13
Message-ID: 20030329103833.G12465-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Sat, 29 Mar 2003, Arjen van der Meijden wrote:

> I know it isn't possible to do queries like:
> SELECT 1 AS c, c + 1 AS d;
>
> Other queries that aren't possible are those:
> SELECT intfield AS a, intfield * intfield AS square FROM tableX WHERE a
> < 10 AND square < 50
>
> Of course, these are bogus examples to simply illustrate my point :)
> But is there a good reason not to support it or is it something like
> "not yet implemented", "not interesting" or "to complex to (easily)
> implement".

For the second, in the theoretical model, where clause entries are
processed before the select list is evaluated. You don't want to evaluate
the entire select list before testing the where (what if there's an
expensive subselect or function). You could get around that by only doing
the referenced ones, but you still run into issues if a select list entry
has the same name as a field in one of the from entries (since to be
complient it must be the field not the select list entry afaics). There'd
have to be a good definition and some real gain (for particularly
complicated cases you can use subselect in from to avoid double typing of
the expression so I personally don't think that's good enough alone).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-03-29 18:48:53 Re: pg_dump data and foreign keys
Previous Message RobertD.Stewart 2003-03-29 16:27:34 functions and triggers