Re: Wrong behaviour of array comparison when arrays contain nulls

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Wrong behaviour of array comparison when arrays contain nulls
Дата
Msg-id 3034594.1649252272@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Wrong behaviour of array comparison when arrays contain nulls  (Lukas Eder <lukas.eder@gmail.com>)
Список pgsql-bugs
Lukas Eder <lukas.eder@gmail.com> writes:
> For the following query:
> SELECT array[1, NULL] = array[1, NULL]
> H2 returns NULL whereas PostgreSQL returns TRUE. In my opinion and
> intuition, as well as according to ISO/IEC 9075-2:2016(E) 8.2 <comparison
> predicate> GR 1) b) ii), H2 is right and PostgreSQL is wrong.

If we don't impose a total order on array values, then we cannot build
btree indexes on such columns.  So yes, this is a deviation from the
SQL standard, and no we are not going to change it.

As for documentation, section 9.19 says

    The comparison operators compare the array contents
    element-by-element, using the default B-tree comparison function for
    the element data type, and sort based on the first difference.

which implies this behavior but perhaps could be more explicit.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Lukas Eder
Дата:
Сообщение: Re: Wrong behaviour of array comparison when arrays contain nulls
Следующее
От: "hirose.masay-01@fujitsu.com"
Дата:
Сообщение: RE: BUG #17421: Core dump in ECPGdo() when calling PostgreSQL API from 32-bit client for RHEL8