Re: Array constructor requires one argument - Mailing list pgsql-general

From Tom Lane
Subject Re: Array constructor requires one argument
Date
Msg-id 12210.1168382985@sss.pgh.pa.us
Whole thread Raw
In response to Re: Array constructor requires one argument  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Tue, Jan 09, 2007 at 04:09:21PM -0500, Tom Lane wrote:
>> One possibility that might handle Martijn's problem is to allow the
>> construct
>> ARRAY[]::type[]

> I don't think it would be too hard to fix, I'll look tomorrow.

It could be pretty ugly, because type assignment normally proceeds
bottom-up :-(.  What you might have to do is make the raw grammar
representation of ARRAY[] work like A_Const does, ie, there's a
slot to plug in a typecast.  That's pretty much vestigial now for
A_Const, if memory serves, but it'd be needful if ARRAY[] has to
be able to "see" the typecast that would otherwise be above it in
the parse tree.

Come to think of it, there is an additional possible benefit to doing
it this way, which is that if ARRAY[] knows a target array type then
it can just coerce all the elements to that without bothering with
trying to induce a common type.  So you should be able to save a few
cycles in the non-empty case, too.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Questions about horizontal partitioning
Next
From: "Matthew T. O'Connor"
Date:
Subject: Re: Autovacuum Improvements