Skip to content

Commit

Permalink
Check properly if indexes need to be updated.
Browse files Browse the repository at this point in the history
In PG 16 it's possible to use HOT update even if indexed attributes change -
in particular, the attributes of "summarizing" indexes. Therefore, the check
for HOT update is not sufficient.
  • Loading branch information
Antonin Houska committed Jul 12, 2024
1 parent b50e184 commit 1d1777f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ Bug fixes
Like with other functions of this extension, the SUPERUSER role attribute
is not needed for execution. The REPLICATION attribute is sufficient.

4. Update BRIN indexes when appropriate.

If a row was updated during the table processing and only the attributes of
"summarizing" (BRIN) indexes changed, pg_squeeze might fail to update those
indexes.

This bug only affects pg_squeeze on PostgreSQL 16.


Release 1.6.1
=============
Expand Down
14 changes: 14 additions & 0 deletions concurrent.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,21 @@ apply_concurrent_changes(DecodingOutputState *dstate, Relation relation,
&update_indexes
#endif
);
/*
* In PG < 16, change of any indexed attribute makes HOT
* impossible, Therefore HOT update implies that no index
* needs to be updated.
*
* In PG >= 16, if only attributes of "summarizing indexes"
* change, HOT update is still possible. Therefore HOT update
* might still require some indexes (in particular, the
* summarizing ones) to be updated.
*/
#if PG_VERSION_NUM >= 160000
if (update_indexes != TU_None)
#else
if (!HeapTupleIsHeapOnly(tup))
#endif
{
List *recheck;

Expand Down

0 comments on commit 1d1777f

Please sign in to comment.