NULLs in array_cat vs array || array

Started by Thom Brownabout 15 years ago5 messageshackers
Jump to latest
#1Thom Brown
thom@linux.com

Hi all,

I assumed array_cat would behave similarly to array || array, but it
appears not when it comes to NULLs. Shouldn't these have identical
functionality? The attached patch makes it so, although it would
break existing code.

Would such a change have any knock-on effect, or cause inconsistency
with other functions?

Thanks

Thom

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

Attachments:

array_cat_nulls.patchapplication/octet-stream; name=array_cat_nulls.patchDownload+6-13
#2Cédric Villemain
cedric.villemain.debian@gmail.com
In reply to: Thom Brown (#1)
Re: NULLs in array_cat vs array || array

2011/2/15 Thom Brown <thom@linux.com>:

Hi all,

I assumed array_cat would behave similarly to array || array, but it
appears not when it comes to NULLs.  Shouldn't these have identical
functionality?  The attached patch makes it so, although it would
break existing code.

There is bugreport and todo entry for that if it helps:

http://archives.postgresql.org/pgsql-bugs/2008-11/msg00032.php

Would such a change have any knock-on effect, or cause inconsistency
with other functions?

Thanks

Thom

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Cédric Villemain               2ndQuadrant
http://2ndQuadrant.fr/     PostgreSQL : Expertise, Formation et Support

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thom Brown (#1)
Re: NULLs in array_cat vs array || array

Thom Brown <thom@linux.com> writes:

I assumed array_cat would behave similarly to array || array, but it
appears not when it comes to NULLs. Shouldn't these have identical
functionality? The attached patch makes it so, although it would
break existing code.

That patch is the hard way: the right change would be to remove the code
altogether and mark the function strict in pg_proc. However, the fact
that it's not like that already shows that we went out of our way to
make it so. I don't think we should undo that decision just because
somebody submits a patch to do so.

Also, so far as I can see array_cat *is* ||, so I'm not sure what
discrepancy in behavior you're on about.

regards, tom lane

#4Thom Brown
thom@linux.com
In reply to: Cédric Villemain (#2)
Re: NULLs in array_cat vs array || array

On 15 February 2011 21:46, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:

2011/2/15 Thom Brown <thom@linux.com>:

Hi all,

I assumed array_cat would behave similarly to array || array, but it
appears not when it comes to NULLs.  Shouldn't these have identical
functionality?  The attached patch makes it so, although it would
break existing code.

There is bugreport and todo entry for that if it helps:

http://archives.postgresql.org/pgsql-bugs/2008-11/msg00032.php

Ah, I see. More to it than meets the eye. My bad.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

#5Thom Brown
thom@linux.com
In reply to: Tom Lane (#3)
Re: NULLs in array_cat vs array || array

On 15 February 2011 21:47, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Also, so far as I can see array_cat *is* ||, so I'm not sure what
discrepancy in behavior you're on about.

You've confused me now. I had a case where I replaced || with , and
surrounded it with array_cat, and the result differed, and now I can't
recreate it. I think I should get an early night.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935