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: 2007-11-30 20:26:15
Message-ID: 37ed240d0711301226r3382750dwb20134ee49d719a5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

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.

Hi Gregory.

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.

So, I like your idea a lot from a usability point of view. But I
really, really hate it from a "just spent half a week on this patch"
point of view =/

Any suggestions about how you would enforce the "only allow casts to
array types" restriction on the empty array?

Cheers
BJ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Postgres User 2007-11-30 20:31:53 Re: Record variable not behaving as expected (bug?)
Previous Message Andrew Dunstan 2007-11-30 20:22:07 Re: [HACKERS] [GENERAL] plperl and regexps with accented characters - incompatible?

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2007-11-30 22:27:30 Re: CommandCounterIncrement versus plan caching
Previous Message Andrew Dunstan 2007-11-30 20:22:07 Re: [HACKERS] [GENERAL] plperl and regexps with accented characters - incompatible?

Browse pgsql-patches by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2007-12-01 00:54:06 pt_BR FAQ update
Previous Message Andrew Dunstan 2007-11-30 20:22:07 Re: [HACKERS] [GENERAL] plperl and regexps with accented characters - incompatible?