pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Lukas Eder <lukas.eder@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Wrong behaviour of array comparison when arrays contain nulls
Date: Wed, 06 Apr 2022 09:37:52 -0400
Message-ID: <3034594.1649252272@sss.pgh.pa.us> (raw)
In-Reply-To: <CAB4ELO7afJgQfZoQfqfMBA7Zk1AdWRkZ9mUN5jpTZupurQTRsA@mail.gmail.com>
References: <CAB4ELO7afJgQfZoQfqfMBA7Zk1AdWRkZ9mUN5jpTZupurQTRsA@mail.gmail.com>

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





view thread (3+ messages)

Message-ID: <3034594.1649252272@sss.pgh.pa.us>
Permalink:  ../3034594.1649252272@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3034594.1649252272@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Wrong behaviour of array comparison when arrays contain nulls
  In-Reply-To: <3034594.1649252272@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox