Skip site navigation (1) Skip section navigation (2)

unhelpful error message

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: unhelpful error message
Date: 2009-06-18 10:21:22
Message-ID: 20090618102122.GA11915@depesz.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Hi,
I tested it on 8.3.7 and on 8.4, but it doesn't seem to be version
bound.

steps to reproduce:

# create table sold_products (items int4, product_id int4);
# create table products (id int4, codename text);
# select sp.count, p.codename from sold_products sp join products p on sp.product_id = p.id;

shown error:
ERROR:  column "p.codename" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: select sp.count, p.codename from sold_products sp join produ...
                         ^

Now - the problem is that I "forgot" name of the column, thought it will be "count", but it's "items".

the error doesn't say that I used column that doesn't exist - it says something about grouping.

I know it is related to the fact that this works:

select sp.count from sold_products sp;

but i'm not sure if it this (rather obscure) functionality is really worth the trouble.

Best regards,

depesz

-- 
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2009-06-18 14:03:21
Subject: Re: unhelpful error message
Previous:From: Simon RiggsDate: 2009-06-18 06:38:27
Subject: Re: [HACKERS] Cannot use all four trigger events at once

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group