Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group