Re: [GENERAL] Empty arrays with ARRAY[]

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] Empty arrays with ARRAY[]
Date: 2007-11-29 19:48:16
Message-ID: 20071129194816.GD30574@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

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(at)svana(dot)org> http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Benoît Carpentier 2007-11-29 20:59:21 free ETL using Postgresql 8.2.x
Previous Message Pedro Doria Meunier 2007-11-29 19:34:18 problems with email...

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Hammond 2007-11-29 20:00:51 Re: PG 7.3 is five years old today
Previous Message Brendan Jurd 2007-11-29 19:13:20 Re: [GENERAL] Empty arrays with ARRAY[]

Browse pgsql-patches by date

  From Date Subject
Next Message Gregory Stark 2007-11-29 20:22:55 Re: [DOCS] Partition: use triggers instead of rules
Previous Message Brendan Jurd 2007-11-29 19:13:20 Re: [GENERAL] Empty arrays with ARRAY[]