diff options
author | Noah Misch <noah@leadboat.com> | 2024-10-25 06:51:02 -0700 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2024-10-25 06:51:02 -0700 |
commit | 243e9b40f1b2dd09d6e5bf91ebf6e822a2cd3704 (patch) | |
tree | d092b3c3b261da64a5f17a35b87d67626f9591f7 /src/include/utils | |
parent | 0fe173680e148984a150326b80c322a91ffa899d (diff) | |
download | postgresql-243e9b40f1b2dd09d6e5bf91ebf6e822a2cd3704.tar.gz postgresql-243e9b40f1b2dd09d6e5bf91ebf6e822a2cd3704.zip |
For inplace update, send nontransactional invalidations.
The inplace update survives ROLLBACK. The inval didn't, so another
backend's DDL could then update the row without incorporating the
inplace update. In the test this fixes, a mix of CREATE INDEX and ALTER
TABLE resulted in a table with an index, yet relhasindex=f. That is a
source of index corruption. Back-patch to v12 (all supported versions).
The back branch versions don't change WAL, because those branches just
added end-of-recovery SIResetAll(). All branches change the ABI of
extern function PrepareToInvalidateCacheTuple(). No PGXN extension
calls that, and there's no apparent use case in extensions.
Reviewed by Nitin Motiani and (in earlier versions) Andres Freund.
Discussion: https://postgr.es/m/20240523000548.58.nmisch@google.com
Diffstat (limited to 'src/include/utils')
-rw-r--r-- | src/include/utils/catcache.h | 3 | ||||
-rw-r--r-- | src/include/utils/inval.h | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 3fb9647b87c..8f04bb8845b 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -225,6 +225,7 @@ extern void CatCacheInvalidate(CatCache *cache, uint32 hashValue); extern void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple, - void (*function) (int, uint32, Oid)); + void (*function) (int, uint32, Oid, void *), + void *context); #endif /* CATCACHE_H */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index 24695facf22..3390e7ab8af 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -28,6 +28,9 @@ extern void AcceptInvalidationMessages(void); extern void AtEOXact_Inval(bool isCommit); +extern void PreInplace_Inval(void); +extern void AtInplace_Inval(void); + extern void AtEOSubXact_Inval(bool isCommit); extern void PostPrepare_Inval(void); @@ -37,6 +40,9 @@ extern void CommandEndInvalidationMessages(void); extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple); +extern void CacheInvalidateHeapTupleInplace(Relation relation, + HeapTuple tuple, + HeapTuple newtuple); extern void CacheInvalidateCatalog(Oid catalogId); |