Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL) - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Date
Msg-id CADxJZo3TmBXMUxoNu8RSmRe73BE7=PoE7Qbc3dnUQsP2C2vBEg@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
On 26 March 2013 05:26, Greg Stark <stark@mit.edu> wrote:
> I'm not as sanguine as Tom is about how likely these corner cases will
> be met actually. As far as I can tell checking IS NULL on
> array_length() was the supported way to check for 0-length arrays
> previously

Correct.  There was no other way to check for empty arrays, because
every empty array was zero-D, and zero-D returns NULL from all array
interrogation functions, even array_ndims (which is totally bonkers).

>
> At least if it's a clean break then everyone on 9.3 knows they need to
> do IS NULL and everyone on 9.4 knows they need to check for 0.

And, as I pointed out in at the top of the thread, you can write
"coalesce(array_length(a,1), 0) = 0" if you want to be confident your
code will continue work in either case, and for some folks I expect
that will be the least painful way to upgrade from 9.3 -> 9.4.

Cheers,
BJ



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Assertion failure when promoting node by deleting recovery.conf and restart node
Next
From: Bruce Momjian
Date:
Subject: Re: Let's invent a function to report lock-wait-blocking PIDs