From: | Philip Carlsen <plcplc(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | valid casts to anyarray |
Date: | 2023-09-26 19:39:31 |
Message-ID: | CALkT+D4qBsGL8OruvtZSKL9fXa21HCD-KSDVajujtDs3RV-RDQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi list
I've been down a rabbit hole today trying to understand what exactly makes
a type a valid candidate for an ANYARRAY function argument (e.g., something
you can 'unnest()').
My reading has led me across such functions as 'get_promoted_array_type',
'IsTrueArrayType', 'can_coerce_type', and 'check_generic_type_consistency',
and this has led me to believe that any type which has a valid (i.e.,
non-zero?) pg_type.typelem defined should be applicable.
However, I cannot seem to be able to call 'unnest' on a 'point':
postgres=# select unnest(point(1,2));
ERROR: function unnest(point) does not exist
... even though according to 'pg_catalog.pg_type' the type 'point' does
indeed look very array-like (it should be equivalent to an float8 array).
The only difference I can spot is that it has
'typsubscript=raw_array_subscript_handler', as opposed to
typsubscript=array_subscript_handler' which is what 'IsTrueArrayType'
checks for.
Can anyone here perhaps enlighten me as to how I can tell if a type is a
valid ANYARRAY (and bonus points to point out the check I must have missed
in the (parser?) source code)?
-Philip
From | Date | Subject | |
---|---|---|---|
Next Message | Maciek Sakrejda | 2023-09-26 19:43:54 | Re: log_statement vs log_min_duration_statement |
Previous Message | Ron | 2023-09-26 19:30:02 | Re: Ad hoc SETOF type definition? |