diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2024-04-19 15:47:48 +0200 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2024-04-19 16:08:34 +0200 |
commit | 41d2c6f952edc4841763d05296b65f3c0edad4f2 (patch) | |
tree | b5f50488ec55160505bfed7ae64ea0abb74e17bd /src/backend/commands/constraint.c | |
parent | 95d14b7ae26db5ed85d9945e29121bb0e9b59863 (diff) | |
download | postgresql-41d2c6f952edc4841763d05296b65f3c0edad4f2.tar.gz postgresql-41d2c6f952edc4841763d05296b65f3c0edad4f2.zip |
Add missing index_insert_cleanup calls
The optimization for inserts into BRIN indexes added by c1ec02be1d79
relies on a cache that needs to be explicitly released after calling
index_insert(). The commit however failed to invoke the cleanup in
validate_index(), which calls index_insert() indirectly through
table_index_validate_scan().
After inspecting index_insert() callers, it seems unique_key_recheck()
is missing the call too.
Fixed by adding the two missing index_insert_cleanup() calls.
The commit does two additional improvements. The aminsertcleanup()
signature is modified to have the index as the first argument, to make
it more like the other AM callbacks. And the aminsertcleanup() callback
is invoked even if the ii_AmCache is NULL, so that it can decide if the
cleanup is necessary.
Author: Alvaro Herrera, Tomas Vondra
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/202401091043.e3nrqiad6gb7@alvherre.pgsql
Diffstat (limited to 'src/backend/commands/constraint.c')
-rw-r--r-- | src/backend/commands/constraint.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/commands/constraint.c b/src/backend/commands/constraint.c index 94d491b7541..f7dc42f7452 100644 --- a/src/backend/commands/constraint.c +++ b/src/backend/commands/constraint.c @@ -174,6 +174,9 @@ unique_key_recheck(PG_FUNCTION_ARGS) index_insert(indexRel, values, isnull, &checktid, trigdata->tg_relation, UNIQUE_CHECK_EXISTING, false, indexInfo); + + /* Cleanup cache possibly initialized by index_insert. */ + index_insert_cleanup(indexRel, indexInfo); } else { |