Slightly confused error message

Lists: pgsql-sql
From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Slightly confused error message
Date: 2006-04-28 15:59:45
Message-ID: 44523BF1.1080307@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hi,

I just stumbled over a slightly confused error message:

mydb=# select count(*),coverage_area from myschema.streets except select
cd as coverage_area from countryref.disks group by streets.coverage_area;
ERROR: column "streets.coverage_area" must appear in the GROUP BY
clause or be used in an aggregate function

As the query looks, streets.coverage_area is actually used in the GROUP BY.

I know how to fix the query, but I wonder whether it is worth the effort
to try improving the error message.

Thanks,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Schaber <schabi(at)logix-tt(dot)com>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slightly confused error message
Date: 2006-04-28 16:07:04
Message-ID: 1612.1146240424@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Markus Schaber <schabi(at)logix-tt(dot)com> writes:
> I just stumbled over a slightly confused error message:

> mydb=# select count(*),coverage_area from myschema.streets except select
> cd as coverage_area from countryref.disks group by streets.coverage_area;
> ERROR: column "streets.coverage_area" must appear in the GROUP BY
> clause or be used in an aggregate function

> As the query looks, streets.coverage_area is actually used in the GROUP BY.

The complaint is 100% accurate; the subquery that it's unhappy about is

select count(*),coverage_area from myschema.streets

which is an aggregating query, but coverage_area is being used outside
an aggregate without having been grouped by.

regards, tom lane


From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slightly confused error message
Date: 2006-04-28 16:30:08
Message-ID: 44524310.70906@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hi, Tom,

Tom Lane wrote:

>>I just stumbled over a slightly confused error message:
>
>>mydb=# select count(*),coverage_area from myschema.streets except select
>>cd as coverage_area from countryref.disks group by streets.coverage_area;
>>ERROR: column "streets.coverage_area" must appear in the GROUP BY
>>clause or be used in an aggregate function
>
>>As the query looks, streets.coverage_area is actually used in the GROUP BY.
>
> The complaint is 100% accurate;

I know that, and won't deny.

> the subquery that it's unhappy about is
>
> select count(*),coverage_area from myschema.streets
>
> which is an aggregating query, but coverage_area is being used outside
> an aggregate without having been grouped by.

Yes, and my question is whether it is easy and worth the effort. to add
that information (about the acutally offending subquery) to the message.

Thanks,
Markus

--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org


From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Markus Schaber <schabi(at)logix-tt(dot)com>, PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slightly confused error message
Date: 2006-04-28 16:36:19
Message-ID: dafdc3e847f55e0a67d11c779bf013ec@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql


On Fri, 28 Apr 2006 12:07:04 -0400, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Markus Schaber <schabi(at)logix-tt(dot)com> writes:
>> I just stumbled over a slightly confused error message:
>
>> mydb=# select count(*),coverage_area from myschema.streets except select
>> cd as coverage_area from countryref.disks group by
> streets.coverage_area;
>> ERROR: column "streets.coverage_area" must appear in the GROUP BY
>> clause or be used in an aggregate function
>
>> As the query looks, streets.coverage_area is actually used in the GROUP
> BY.
>
> The complaint is 100% accurate; the subquery that it's unhappy about is
>
> select count(*),coverage_area from myschema.streets
>
> which is an aggregating query, but coverage_area is being used outside
> an aggregate without having been grouped by.

I see lack of parenthesis in the sub-query:

select count(*),coverage_area from myschema.streets except
(select cd as coverage_area from countryref.disks)
group by streets.coverage_area;

--
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Schaber <schabi(at)logix-tt(dot)com>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slightly confused error message
Date: 2006-04-28 19:02:42
Message-ID: 15232.1146250962@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Markus Schaber <schabi(at)logix-tt(dot)com> writes:
> Yes, and my question is whether it is easy and worth the effort. to add
> that information (about the acutally offending subquery) to the message.

I'm not sure about localizing the subquery per se, but it might be
possible to add a syntax pointer to the specific variable occurrence
that it's complaining about. That would help at least somewhat in
cases like this.

regards, tom lane