From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Thomas Hallgren <thomas(at)tada(dot)se> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: any, anyelement, and anyarray |
Date: | 2006-05-12 13:46:21 |
Message-ID: | 23824.1147441581@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thomas Hallgren <thomas(at)tada(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Matteo Beccati | 2006-05-12 13:56:03 | Re: [HACKERS] Enhanced containment selectivity function |
Previous Message | Tom Lane | 2006-05-12 13:33:45 | Re: [HACKERS] Enhanced containment selectivity function |