From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Check if ii_AmCache is NULL in aminsertcleanup
Date: Mon, 27 Nov 2023 15:53:24 +0000
Message-ID: <E1r7dvH-007WOn-OX@gemulon.postgresql.org> (raw)
Check if ii_AmCache is NULL in aminsertcleanup
Fix a bug introduced by c1ec02be1d79. It may happen that the executor
opens indexes on the result relation, but no rows end up being inserted.
Then the index_insert_cleanup still gets executed, but passes down NULL
to the AM callback. The AM callback may not expect this, as is the case
of brininsertcleanup, leading to a crash.
Fixed by only calling the cleanup callback if (ii_AmCache != NULL). This
way the AM can simply assume to only see a valid cache.
Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4-w9qC-o9hQox9UHvdVZAYTp8OrPQOKtwbvzWaRejTT=Q@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a82ee7ef3aacc2073d3ef5f4b7e5067fa08ea76c
Modified Files
--------------
src/backend/access/index/indexam.c | 2 +-
src/test/regress/expected/brin.out | 6 ++++++
src/test/regress/sql/brin.sql | 7 +++++++
3 files changed, 14 insertions(+), 1 deletion(-)
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: Check if ii_AmCache is NULL in aminsertcleanup
In-Reply-To: <E1r7dvH-007WOn-OX@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