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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange error message when reference non-existent column foo."count"
Дата
Msg-id 32098.1418857576@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strange error message when reference non-existent column foo."count"  (Patrick Krecker <patrick@judicata.com>)
Список pgsql-general
Patrick Krecker <patrick@judicata.com> 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Patrick Krecker
Дата:
Сообщение: Re: Strange error message when reference non-existent column foo."count"
Следующее
От: David G Johnston
Дата:
Сообщение: Re: Strange error message when reference non-existent column foo."count"