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

From Brendan Jurd
Subject Re: [GENERAL] Empty arrays with ARRAY[]
Date
Msg-id 37ed240d0711270832j24cf3a79m99257e787c639adc@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[]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Nov 28, 2007 2:56 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > I wonder whether we are also interested in catching CAST(), e.g.:
>
> > CAST(ARRAY[] AS text[])
>
> I think you'll find that it's just about impossible to not handle both,
> because they look the same after the grammar gets done.

Thanks Tom ... your comment makes me suspect I've been barking up the
wrong tree.

My original intent was to modify the grammar rules to catch an array
expression followed by a typecast, and put the target typename of the
cast directly into the A_ArrayExpr struct.  That notion came from
looking at the way that TypeName gets put into A_Const --
makeStringConst() takes an optional TypeName argument.

Looking at the code in the context of your comment, that was probably
a bad approach.  I may've taken the A_Const analogy too far.

Now I'm thinking I leave the grammar rules alone (apart from making it
legal to specify an empty list of elements), and instead push the
typename down into the child node from makeTypeCast(), if the child is
an A_ArrayExpr.  Does that work better?

Regards,
BJ


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PG 8.3beta3 Segmentation Fault during Database Restore
Next
From:
Date:
Subject: Re: Replacement Selection