Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

pgsql-general by date

Next:From: BenoƮt CarpentierDate: 2007-11-29 20:59:21
Subject: free ETL using Postgresql 8.2.x
Previous:From: Pedro Doria MeunierDate: 2007-11-29 19:34:18
Subject: problems with email...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group