Re: [GENERAL] Empty arrays with ARRAY[]

From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Gregory Stark" <stark(at)enterprisedb(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [GENERAL] Empty arrays with ARRAY[]
Date: 2008-03-04 03:15:53
Message-ID: 37ed240d0803031915p6e58a075ycfb3f90b517bc468@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

A quick recap: I submitted a patch for empty ARRAY[] syntax back in
November, and as far as I can see it never made it to the patches
list. Gregory suggested a different way of approaching the problem
(quoted below), but nobody commented further about how it might be
made to work.

I'd like to RFC again on Gregory's idea, and if that doesn't bear any
fruit I'd like to submit the patch as-is for review.

Regards,
BJ

On 01/12/2007, Brendan Jurd <direvus(at)gmail(dot)com> wrote:
> On Nov 30, 2007 9:09 PM, Gregory Stark <stark(at)enterprisedb(dot)com> wrote:
> > I'm sorry to suggest anything at this point, but... would it be less invasive
> > if instead of requiring the immediate cast you created a special case in the
> > array code to allow a placeholder object for "empty array of unknown type".
> > The only operation which would be allowed on it would be to cast it to some
> > specific array type.
> >
> > That way things like
> >
> > UPDATE foo SET col = array[];
> > INSERT INTO foo (col) VALUES (array[]);
> >
> > could be allowed if they could be contrived to introduce an assignment cast.
>
> Not sure it would be less invasive, but I do like the outcome of being
> able to create an empty array pending assignment. In addition to your
> examples, it might also make it possible to do things like this in
> plpgsql
>
> DECLARE
> a text[] := array[];
>
> Whereas my patch requires you to write
>
> a text[]: =array[]::text[];
>
> ... which seems pretty stupid.
>
...
> Any suggestions about how you would enforce the "only allow casts to
> array types" restriction on the empty array?
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2008-03-04 03:19:53 Re: [GENERAL] ts_headline
Previous Message brian 2008-03-04 03:15:11 Re: Connect to postgres from a dynamic IP

Browse pgsql-hackers by date

  From Date Subject
Next Message chris.jurado 2008-03-04 05:02:56 Replacing the corrupt "global" folder with older one
Previous Message Bruce Momjian 2008-03-04 02:48:27 Re: pg_dump additional options for performance

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2008-03-04 03:19:53 Re: [GENERAL] ts_headline
Previous Message Tom Lane 2008-03-03 23:39:50 Re: [PATCHES] BUG #3973: pg_dump using inherited tables do not always restore