Re: COUNT(*) to find records which have a certain number of dependencies

From: Mischa Sandberg <ischamay(dot)andbergsay(at)activestateway(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: COUNT(*) to find records which have a certain number of dependencies
Date: 2004-09-21 22:16:24
Message-ID: YK14d.106472$XP3.11314@edtnps84
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches pgsql-sql

Greg Stark wrote:
> T E Schmitz <mailreg(at)numerixtechnology(dot)de> writes:

>>) as somealias on (model_fk = model_pk)
>>(subquery in FROM must have an alias)
>
> ARGH! This is one of the most annoying things about postgres! It bites me all
> the time. Obviously it's totally insignificant since it's easy for my to just
> throw an "AS x" on the end of it. But damn.
>
> So where can I officially register my complaint? :)

Hope you don't mind an opinion from someone who looks at this from the
underside ...

Trying to give the parser a better chance of confusing you?

Having the tag only totally insignificant if you want to have a bunch of
special validation cases, where if there is only ONE anonymous
pseudotable, and no ambiguity is possible.

If all it does is give you an annoying but understandable error message,
might you care to consider the cryptic error messages you get from
systems that try to 'do what you mean, not what you say' for such
special cases ... and thereby turn a typo into an error twenty lines
further down the page.

BTW, the "as" is optional, but I always suggest that people use it
explicitly. Why? Because without it, you get another silly error message
or even a runtime error when what you did was omit a comma. For example

select salary name from Employee

returns one column (a dollar figure called "name").
(Yes, I know it's harder to cook up an example when the comma is missing
between tables in the FROM list; just wanted it to be obvious)

Okay, apologies for what may sound like a rant.
I've just been wrangling with an interpreter that tries WAY too hard to
make something executable out of what you tell it ... even if that's
really nothing like your intent.

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-09-21 22:31:37 Re: pg_hba.conf additional comment re local line
Previous Message Andrew Dunstan 2004-09-21 20:15:19 Re: pg_hba.conf additional comment re local line

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-09-21 22:29:10 Re: raise is not working
Previous Message Greg Stark 2004-09-21 18:26:37 Re: JOIN performance