Re: [GENERAL] Empty arrays with ARRAY[]

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

Hi folks,

The patch is coming along nicely now. I do have a couple of questions
about the implementation in transformArrayExpr though.

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

Currently, transformArrayExpr uses the results of its search for a
common element type to figure out whether the array is
multidimensional. If we know the type in advance, we don't need to do
the common type search (a nice side-effect), so we need some other way
of figuring out how to set ArrayExpr->multidims on the new node.

I could just check the nodeTag of the elements as they are
transformed, but I'm concerned that the existing code might be relying
on select_common_type to catch stupid input, like a mixture of scalar
and array elements. If that's the case it might be unwise to bypass
select_common_type or, at least, I'd need to come up with something
else to provide the same level of sanity assurance in both code paths.

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

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[])?

If I'm reading the code correctly, the end result should be much the
same, because the inner arrays will end up being coerced to float[]
anyway. But shortcutting the coercion could save some cycles.

Comments?

Regards,
BJ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Norberto Delle 2007-11-29 19:23:18 Dump/Restore Large Object OID
Previous Message Andrew Sullivan 2007-11-29 19:02:56 Re: HD is flooded by Error Log info

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-11-29 19:48:16 Re: [GENERAL] Empty arrays with ARRAY[]
Previous Message Ron Mayer 2007-11-29 19:11:03 Re: PG 7.3 is five years old today

Browse pgsql-patches by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-11-29 19:48:16 Re: [GENERAL] Empty arrays with ARRAY[]
Previous Message David Fetter 2007-11-29 17:52:36 Re: [PATCHES] Partition: use triggers instead of rules