From 1d1777f6ace4ba7b2012d79b750751f861c8817e Mon Sep 17 00:00:00 2001 From: Antonin Houska Date: Fri, 12 Jul 2024 15:22:05 +0200 Subject: [PATCH] Check properly if indexes need to be updated. 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. --- NEWS | 8 ++++++++ concurrent.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/NEWS b/NEWS index 3ee7dcb..6941dc1 100644 --- a/NEWS +++ b/NEWS @@ -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 ============= diff --git a/concurrent.c b/concurrent.c index 6607a23..96b5a56 100644 --- a/concurrent.c +++ b/concurrent.c @@ -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;