Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Krecker <patrick@xxxxxxxxxxxx> writes:
> 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,

Yes.  foo.bar is equivalent to bar(foo) in Postgres.  It is documented;
see for instance the Note here:
http://www.postgresql.org/docs/9.3/static/sql-expressions.html#SQL-EXPRESSIONS-FUNCTION-CALLS

> 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)?

It occurs for any function at all, aggregate or otherwise, if the function
can accept the table's composite type as argument.  The alternatives you
tried probably were not things that could take a composite-type argument.
count() is pretty lax about what it will take, since it only cares about
is-null-or-not.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux