Thread

  1. NULLs in array_cat vs array || array

    Thom Brown <thom@linux.com> — 2011-02-15T21:37:21Z

    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
    
  2. Re: NULLs in array_cat vs array || array

    Cédric Villemain <cedric.villemain.debian@gmail.com> — 2011-02-15T21:46:09Z

    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
    
    
  3. Re: NULLs in array_cat vs array || array

    Tom Lane <tgl@sss.pgh.pa.us> — 2011-02-15T21:47:42Z

    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
    
    
  4. Re: NULLs in array_cat vs array || array

    Thom Brown <thom@linux.com> — 2011-02-15T21:50:00Z

    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
    
    
  5. Re: NULLs in array_cat vs array || array

    Thom Brown <thom@linux.com> — 2011-02-15T21:58:20Z

    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