Re: [GENERAL] Empty arrays with ARRAY[] - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: [GENERAL] Empty arrays with ARRAY[]
Date
Msg-id 20071129194816.GD30574@svana.org
Whole thread Raw
In response to Re: [GENERAL] Empty arrays with ARRAY[]  ("Brendan Jurd" <direvus@gmail.com>)
Responses Re: [GENERAL] Empty arrays with ARRAY[]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Nov 30, 2007 at 06:13:20AM +1100, Brendan Jurd wrote:
> Hi folks,
>
> The patch is coming along nicely now.  I do have a couple of questions
> about the implementation in transformArrayExpr though.

Awesome.

> 1) How should we determine whether the array is multidimensional if we
> know the type in advance?

Well, given the array should be regular you should be able to just look
at the first element, if it's a array  look at it's first element, etc
to determine the dimensions. This'll be fairly quick.

> 2) Should the typecast propagate downwards into nested array elements?

IMHO yes, you have th einfo you may as well use it.

> If we have a nested array written as, say, ARRAY[ARRAY[1, 2], ARRAY[3,
> 4], ARRAY[5, 6]]::float[], should we treat the inner arrays the same
> way as the outer array (with the advance knowledge that the array type
> should be float[])?

TBH, I think you're going to have to go through the whole array to
coerce them and check, so you may as well determine the dimensions at
the same time. In general I think it's better to mark the type up
front.

In don't know if you should actually do the conversion straight away,
but at least you don't need to guess the type anymore.

Hope this helps,

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

pgsql-hackers by date:

Previous
From: Ron Mayer
Date:
Subject: Re: PG 7.3 is five years old today
Next
From: "Andrew Hammond"
Date:
Subject: Re: PG 7.3 is five years old today