Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty - Mailing list pgsql-bugs

From Alan Pinstein
Subject Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty
Date
Msg-id D0E2518E-950A-485E-80D9-0357395A6B8A@mac.com
Whole thread Raw
In response to Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
> Hmm.  ltree has always had that ARR_NDIM == 1 check.  I think the
> reason
> the behavior changed is that ARRAY(SELECT ...) used to return a NULL
> for
> zero rows, and now it returns an empty (zero-dimensional) array.

Ah OK that makes sense, especially given the "hack" I used as a
workaround, which effectively emulates the old behavior.

> I can see two reasonable ways to address this:
>
> * Change the ltree test to reject only ARR_NDIM > 1.
>
> * Drop the ARR_NDIM check altogether, and let it search any sort of
> array.
>
> I'm leaning to #2 myself.  However, there are probably other places
> with
> the same kind of issue, and in some of them it might make more sense
> to
> reject multidimensional arrays.

There may be a third option; it seems to me that the assert is there
more to stop unexpected behavior with arrays of dims of 2 or more.

The real solution might be to just convert a 0-dim array into "null"
or equivalent and still assert error if dims >= 2?

Alan

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty
Next
From: Alan Pinstein
Date:
Subject: Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty