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-27 16:32:27
Message-ID: 37ed240d0711270832j24cf3a79m99257e787c639adc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

On Nov 28, 2007 2:56 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2007-11-27 16:38:16 Re: select from an index
Previous Message Thomas Chille 2007-11-27 16:22:57 Re: autovacuum process blocks without reporting a deadlock

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-11-27 16:38:09 Re: Proposed patch for operator lookup caching
Previous Message Tom Lane 2007-11-27 15:59:59 Re: PG 8.3beta3 Segmentation Fault during Database Restore

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2007-11-27 16:38:09 Re: Proposed patch for operator lookup caching
Previous Message Tom Lane 2007-11-27 15:56:01 Re: [GENERAL] Empty arrays with ARRAY[]