greatest cannot be used as sfunc for CREATE AGGREGATE

Поиск
Список
Период
Сортировка
От Ryan Kelly
Тема greatest cannot be used as sfunc for CREATE AGGREGATE
Дата
Msg-id 20130625123947.GA24810@llserver.lakeliving.com
обсуждение исходный текст
Ответы Re: greatest cannot be used as sfunc for CREATE AGGREGATE  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
In trying to learn about aggregates, I came across this seemingly odd
behavior:

(postgres@[local]:5435 08:27:42) [postgres]> CREATE AGGREGATE example_max (TEXT) (SFUNC = greatest, STYPE = TEXT);
ERROR:  syntax error at or near "greatest"
LINE 1: CREATE AGGREGATE example_max (TEXT) (SFUNC = greatest, STYPE...
                                                     ^

Of course, this is a silly example (one could just use max), but I'm
interested in knowing why greatest cannot be used here. Someone on IRC
mentioned that it was because "greatest was not actually a function" but
the documentation for greatest says nothing along those lines:
http://www.postgresql.org/docs/9.2/static/functions-conditional.html#FUNCTIONS-GREATEST-LEAST

The documentation also indicates that greatest is non-reserved (cannot
be function or type):
http://www.postgresql.org/docs/9.2/static/sql-keywords-appendix.html

But I'm not sure I understand how to interpret the "cannot be function
or type" or portion of that.

Quoting "greatest" causes this error instead:
(postgres@[local]:5435 08:30:08) [postgres]> CREATE AGGREGATE example_max (TEXT) (SFUNC = "greatest", STYPE = TEXT);
ERROR:  function greatest(text, text) does not exist

Which I would assume is because greatest is variadic and not simply a
function of two arguments.

I'm sure I'm just being dense and missing something obvious here...

-Ryan P. Kelly



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

Предыдущее
От: Daniel Cristian Cruz
Дата:
Сообщение: Debian Weezy PGDG CD/DVD iso image
Следующее
От: dinesh kumar
Дата:
Сообщение: PostgreSQL 9.3 pg_dump issue