Re: Syntax bug? Group by?

From: "Przemek " <krycek6(at)wp(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Syntax bug? Group by?
Date: 2006-10-18 10:59:11
Message-ID: 453608fff0494@wp.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dnia 17-10-2006 o godz. 23:21 Tom Lane napisał(a):
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > Mark Woodward wrote:
> >> My question, is it a syntactic technicality that PostgreSQL asks for a
> >> "group by," or a bug in the parser?
>
> > AFAIK what you want is not per sql spec.
>
> It would in fact be a violation of spec. Consider the case where there
> are no rows matching 15. In this case
>
> select min(tindex), avg(tindex) from y where ycis_id = 15;
>
> will yield one row containing NULLs, whereas
>
> select min(tindex), avg(tindex) from y where ycis_id = 15 group by
> ycis_id;
>
> will yield no rows (because there are no groups). Therefore, if
> Postgres were to implicitly insert a GROUP BY to make it legal to
> reference ycis_id directly, we'd be changing the query behavior
> and breaking spec.
>
> regards, tom lane
>

Hello

IMHO:

Also take into consider that - what should be expected behavior of this:

select ycis_id, min(tindex), avg(tindex) from y where ycis_id = truncate(random()*100);

Since result of comparission is not known on parsing phase it couldn't be done here if there is no other requirements on argum

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Joseph Krogh 2006-10-18 11:52:46 bug or feature, || -operator and NULLs
Previous Message Heikki Linnakangas 2006-10-18 09:41:36 Bitmap index status