pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of NULLs when merging BRIN summaries
Date: Thu, 18 May 2023 21:33:33 +0000
Message-ID: <E1pzlFd-000Ynb-Ae@gemulon.postgresql.org> (raw)

Fix handling of NULLs when merging BRIN summaries

When merging BRIN summaries, union_tuples() did not correctly update the
target hasnulls/allnulls flags. When merging all-NULL summary into a
summary without any NULL values, the result had both flags set to false
(instead of having hasnulls=true).

This happened because the code only considered the hasnulls flags,
ignoring the possibility the source summary has allnulls=true.

Discovered while investigating issues with handling empty BRIN ranges
and handling of NULL values, but it's a separate problem (has nothing to
do with empty ranges).

Fixed by considering both flags on the source summary, and updating the
hasnulls flag on the target summary.

Backpatch to 11. The bug exists since 9.5 (where BRIN indexes were
introduced), but those releases are EOL already.

Discussion: https://postgr.es/m/9d993d0d-e431-2196-9ccc-0554d0e60154%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3ec8a3bfb5472ecf93aba416e9f384ea16d340d1

Modified Files
--------------
src/backend/access/brin/brin.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1pzlFd-000Ynb-Ae@gemulon.postgresql.org>
Permalink:  ../E1pzlFd-000Ynb-Ae@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pzlFd-000Ynb-Ae@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix handling of NULLs when merging BRIN summaries
  In-Reply-To: <E1pzlFd-000Ynb-Ae@gemulon.postgresql.org>

* 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