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 /doc/src | |
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 'doc/src')
-rw-r--r-- | doc/src/sgml/indexam.sgml | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 18cf23296f2..e3c1539a1e3 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -367,21 +367,21 @@ aminsert (Relation indexRelation, within an SQL statement, it can allocate space in <literal>indexInfo->ii_Context</literal> and store a pointer to the data in <literal>indexInfo->ii_AmCache</literal> (which will be NULL - initially). After the index insertions complete, the memory will be freed - automatically. If additional cleanup is required (e.g. if the cache contains - buffers and tuple descriptors), the AM may define an optional function - <literal>aminsertcleanup</literal>, called before the memory is released. + initially). If resources other than memory have to be released after + index insertions, <function>aminsertcleanup</function> may be provided, + which will be called before the memory is released. </para> <para> <programlisting> void -aminsertcleanup (IndexInfo *indexInfo); +aminsertcleanup (Relation indexRelation, + IndexInfo *indexInfo); </programlisting> Clean up state that was maintained across successive inserts in <literal>indexInfo->ii_AmCache</literal>. This is useful if the data - requires additional cleanup steps, and simply releasing the memory is not - sufficient. + requires additional cleanup steps (e.g., releasing pinned buffers), and + simply releasing the memory is not sufficient. </para> <para> |