Re: ARRAY() returning NULL instead of ARRAY[] resp. {}

From: Markus Bertheau ☭ <twanger(at)bluetwanger(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joe Conway <mail(at)joeconway(dot)com>, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Date: 2005-06-06 14:17:24
Message-ID: 1118067445.5506.6.camel@dicaprio.akademie1.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql

В Втр, 24/05/2005 в 00:06 -0400, Tom Lane пишет:
> Joe Conway <mail(at)joeconway(dot)com> writes:
> > Markus Bertheau wrote:
> >> why does SELECT ARRAY(SELECT 1 WHERE FALSE) return NULL instead of
> >> ARRAY[] resp. '{}'?
>
> > Why would you expect an empty array instead of a NULL?
>
> I think he's got a good point, actually. We document the ARRAY-with-
> parens-around-a-SELECT syntax as
>
> The resulting one-dimensional array will have an element for
> each row in the subquery result, with an element type matching
> that of the subquery's output column.
>
> To me, that implies that a subquery result of no rows generates a
> one-dimensional array of no elements, not a null array.

By analogy, array_upper('{}'::TEXT[], 1) should return 0 instead of
NULL.

Markus

--
Markus Bertheau ☭ <twanger(at)bluetwanger(dot)de>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-06-06 14:18:43 Re: Quick-and-dirty compression for WAL backup blocks
Previous Message Tom Lane 2005-06-06 13:56:30 Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-06-06 14:44:49 Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Previous Message Tom Lane 2005-06-06 13:56:30 Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-06-06 14:31:15 Re: how to store more than 3 MB of character data in Postgres Varchar field
Previous Message Richard Huxton 2005-06-06 11:46:25 Re: how to store more than 3 MB of character data in Postgres