Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty

Поиск
Список
Период
Сортировка
От Alan Pinstein
Тема Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty
Дата
Msg-id D0E2518E-950A-485E-80D9-0357395A6B8A@mac.com
обсуждение исходный текст
Ответ на Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty
Следующее
От: Alan Pinstein
Дата:
Сообщение: Re: BUG #4921: ltree @> ltree[] operator shouldn't fail if ltree[] is empty