Re: Function accepting array of complex type - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Function accepting array of complex type
Date
Msg-id 32696.1440795352@sss.pgh.pa.us
Whole thread Raw
In response to Re: Function accepting array of complex type  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List pgsql-hackers
Jim Nasby <Jim.Nasby@BlueTreble.com> writes:
> On 8/25/15 6:28 PM, Tom Lane wrote:
>> You need to cast it to some specific record type:
>> regression=# SELECT magsum( array[row(2.1, 2.1), row(2.2,2.2)]::c[] );

> Right, I was wondering how hard it would be to improve that, but it's 
> not clear to me where to look at in the code. Does the resolution happen 
> as part of parsing, or is it further down the road?

It would possibly make sense to allow coercion of record[] to
complex-array types, but there would be a lot of code to be written to
support it.  See the unimplemented cases referencing RECORDARRAYOID in
parse_coerce.c, and compare to corresponding cases for coercing RECORDOID
to complex.  (Note that the way array[...]::foo[] works is very specific
to ARRAY constructs, so it would not handle the general case.  OTOH,
coerce_record_to_complex doesn't pretend to handle all cases either.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: proposal: multiple psql option -c
Next
From: Jim Nasby
Date:
Subject: Re: proposal: multiple psql option -c