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

From Brendan Jurd
Subject Re: [GENERAL] Empty arrays with ARRAY[]
Date
Msg-id 37ed240d0711291113q2963241cs4a2fe821e538c88a@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Empty arrays with ARRAY[]  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] Empty arrays with ARRAY[]
Re: [GENERAL] Empty arrays with ARRAY[]
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgwin32_open returning EINVAL
Next
From: Ron Mayer
Date:
Subject: Re: PG 7.3 is five years old today