mirror of
https://github.com/postgres/postgres.git
synced 2026-03-15 07:04:10 -04:00
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 v14 - v17. This is a back-patch of commits: -243e9b40f1(main change, on master, before v18 branched) -0bada39c83(defect fix, on master, before v18 branched) -bae8ca82fd(cosmetics from post-commit review, on REL_18_STABLE) It reverses commitc1099dd745, my revert of the original back-patch of243e9b4. This back-patch omits the non-comment heap_decode() changes. I find those changes removed harmless code that was last necessary in v13. See discussion thread for details. The back branches aren't the place to remove such code. Like the original back-patch, this doesn't change WAL, because these branches use 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. Expect ".abi-compliance-history" edits to follow. Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com> Reviewed-by: Surya Poondla <s_poondla@apple.com> Reviewed-by: Ilyasov Ian <ianilyasov@outlook.com> Reviewed-by: Nitin Motiani <nitinmotiani@google.com> (in earlier versions) Reviewed-by: Andres Freund <andres@anarazel.de> (in earlier versions) Discussion: https://postgr.es/m/20240523000548.58.nmisch@google.com Backpatch-through: 14-17
74 lines
2.1 KiB
C
74 lines
2.1 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* inval.h
|
|
* POSTGRES cache invalidation dispatcher definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/utils/inval.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef INVAL_H
|
|
#define INVAL_H
|
|
|
|
#include "access/htup.h"
|
|
#include "storage/relfilelocator.h"
|
|
#include "utils/relcache.h"
|
|
|
|
extern PGDLLIMPORT int debug_discard_caches;
|
|
|
|
typedef void (*SyscacheCallbackFunction) (Datum arg, int cacheid, uint32 hashvalue);
|
|
typedef void (*RelcacheCallbackFunction) (Datum arg, Oid relid);
|
|
|
|
|
|
extern void AcceptInvalidationMessages(void);
|
|
|
|
extern void AtEOXact_Inval(bool isCommit);
|
|
|
|
extern void PreInplace_Inval(void);
|
|
extern void AtInplace_Inval(void);
|
|
extern void ForgetInplace_Inval(void);
|
|
|
|
extern void AtEOSubXact_Inval(bool isCommit);
|
|
|
|
extern void PostPrepare_Inval(void);
|
|
|
|
extern void CommandEndInvalidationMessages(void);
|
|
|
|
extern void CacheInvalidateHeapTuple(Relation relation,
|
|
HeapTuple tuple,
|
|
HeapTuple newtuple);
|
|
extern void CacheInvalidateHeapTupleInplace(Relation relation,
|
|
HeapTuple key_equivalent_tuple);
|
|
|
|
extern void CacheInvalidateCatalog(Oid catalogId);
|
|
|
|
extern void CacheInvalidateRelcache(Relation relation);
|
|
|
|
extern void CacheInvalidateRelcacheAll(void);
|
|
|
|
extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple);
|
|
|
|
extern void CacheInvalidateRelcacheByRelid(Oid relid);
|
|
|
|
extern void CacheInvalidateSmgr(RelFileLocatorBackend rlocator);
|
|
|
|
extern void CacheInvalidateRelmap(Oid databaseId);
|
|
|
|
extern void CacheRegisterSyscacheCallback(int cacheid,
|
|
SyscacheCallbackFunction func,
|
|
Datum arg);
|
|
|
|
extern void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func,
|
|
Datum arg);
|
|
|
|
extern void CallSyscacheCallbacks(int cacheid, uint32 hashvalue);
|
|
|
|
extern void InvalidateSystemCaches(void);
|
|
extern void InvalidateSystemCachesExtended(bool debug_discard);
|
|
|
|
extern void LogLogicalInvalidations(void);
|
|
#endif /* INVAL_H */
|