Re: Inconsistent behavior on Array & Is Null? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Inconsistent behavior on Array & Is Null?
Date
Msg-id 24111.1080892418@sss.pgh.pa.us
Whole thread Raw
In response to Re: Inconsistent behavior on Array & Is Null?  (Greg Stark <gsstark@mit.edu>)
Responses Re: Inconsistent behavior on Array & Is Null?  (Greg Stark <gsstark@mit.edu>)
Re: Inconsistent behavior on Array & Is Null?  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> array_lower() and array_upper() are returning NULL for a non-null
> input, the empty array, even though lower and upper bounds are known
> just as well as they are for any other sized array. They are behaving
> as if there's something unknown about the empty array that makes it
> hard to provide a lower bound or upper bound.

Hm.  My idea of the index lower bound is "the smallest index for which
there is an array member" --- so I agree with Joe that it's not very
well defined for an empty array.  We could pick some arbitrary value,
such as zero, for the LB and UB to be reported for an empty array, but
I can't see any way that you could justify them except as arbitrary
choices.

I think that maybe we ought to question these two properties:* empty array is different from NULL ... really?  Why?*
storinga value into an element of a NULL array yields  a NULL array instead of a singleton array.
 
IIRC the latter is presently true because we couldn't figure out
just what dimensionality to assign, but it might be easier to agree on
that than to resolve these other arguments...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Inconsistent behavior on Array & Is Null?
Next
From: "Zeugswetter Andreas SB SD"
Date:
Subject: Re: pre-loading a user table.