Re: Strange error message when reference non-existent column foo."count"

From: Patrick Krecker <patrick(at)judicata(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Strange error message when reference non-existent column foo."count"
Date: 2014-12-17 22:53:40
Message-ID: CAK2mJFPhG0k_Uh2YYMKwoNsfAd=B8DGCnh33OQ9TMBVsFaUBpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry, I changed the email as I was writing it but I forgot to change the
subject line. An appropriate subject would be 'Strange behavior when
referencing non-existent column foo."count".'

On Wed, Dec 17, 2014 at 2:50 PM, Patrick Krecker <patrick(at)judicata(dot)com>
wrote:
>
> I encountered this today and it was quite surprising:
>
> select version();
> version
>
>
> ------------------------------------------------------------------------------------------------------
> PostgreSQL 9.3.5 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu
> 4.8.2-19ubuntu1) 4.8.2, 64-bit
>
> create table foo as (select generate_series(1,3));
>
> As expected, the following fails:
>
> select count from foo;
> ERROR: column "count" does not exist
> LINE 1: select count from foo;
> ^
> But if I change the syntax to something I thought was equivalent:
>
> select foo."count" from foo;
> count
> -------
> 3
> (1 row)
>
> It works! This was quite surprising to me. Is this expected behavior, that
> you can call an aggregate function without any parentheses (I can't find
> any other syntax that works for count() sans parentheses, and this behavior
> doesn't occur for any other aggregate)?
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2014-12-17 23:06:16 Re: Strange error message when reference non-existent column foo."count"
Previous Message Patrick Krecker 2014-12-17 22:50:06 Strange error message when reference non-existent column foo."count"