Re: any, anyelement, and anyarray

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: any, anyelement, and anyarray
Дата
Msg-id 23824.1147441581@sss.pgh.pa.us
обсуждение исходный текст
Ответ на any, anyelement, and anyarray  (Thomas Hallgren <thomas@tada.se>)
Ответы Re: any, anyelement, and anyarray
Список pgsql-hackers
Thomas Hallgren <thomas@tada.se> writes:
> - Why does PostgreSQL declare three different generic types? Isn't one 
> enough? ISTM it would be far simpler to use constructs like 'any' and 
> 'any[]' but neither of them are permitted.

"any" isn't the same as "anyelement", because it doesn't have the
property of constraining different argument positions to be the same
type.  For instance, compare(any,any) and compare(anyelement,anyelement)
would accept different sets of input types.

There's some historical background to this, having to do with the fact
that "any" existed first.  Possibly we wouldn't have bothered with "any"
if all had been invented at the same time.  But I feel no pressure to
remove "any".

> - Why isn't the 'anyarray' declared as an array using the elemenent type 
> 'anyelement' in pg_type?

Because it's a pseudotype, not a type.

> - Why can't I write 'anyelement[]'. Shouldn't that be the same thing as 
> 'anyarray'?

No, you're confusing these with actual datatypes.  They are pseudotypes,
which means they're only allowed as function argument/result type
placeholders.
        regards, tom lane


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

Предыдущее
От: "Jaime Casanova"
Дата:
Сообщение: Re: BEGIN inside transaction should be an error
Следующее
От: Thomas Hallgren
Дата:
Сообщение: Re: any, anyelement, and anyarray