From 9d5f8b8f9ccf759df1bb078b106047c0e15e6f01 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Sun, 3 Sep 2023 16:14:21 -0400 Subject: [PATCH v0 1/3] Extern RewriteStateData --- src/backend/access/heap/rewriteheap.c | 29 ----------------------- src/include/access/rewriteheap.h | 33 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 424958912c..93e75dc7c2 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -125,35 +125,6 @@ #include "utils/memutils.h" #include "utils/rel.h" -/* - * State associated with a rewrite operation. This is opaque to the user - * of the rewrite facility. - */ -typedef struct RewriteStateData -{ - Relation rs_old_rel; /* source heap */ - Relation rs_new_rel; /* destination heap */ - Page rs_buffer; /* page currently being built */ - BlockNumber rs_blockno; /* block where page will go */ - bool rs_buffer_valid; /* T if any tuples in buffer */ - bool rs_logical_rewrite; /* do we need to do logical rewriting */ - TransactionId rs_oldest_xmin; /* oldest xmin used by caller to determine - * tuple visibility */ - TransactionId rs_freeze_xid; /* Xid that will be used as freeze cutoff - * point */ - TransactionId rs_logical_xmin; /* Xid that will be used as cutoff point - * for logical rewrites */ - MultiXactId rs_cutoff_multi; /* MultiXactId that will be used as cutoff - * point for multixacts */ - MemoryContext rs_cxt; /* for hash tables and entries and tuples in - * them */ - XLogRecPtr rs_begin_lsn; /* XLogInsertLsn when starting the rewrite */ - HTAB *rs_unresolved_tups; /* unmatched A tuples */ - HTAB *rs_old_new_tid_map; /* unmatched B tuples */ - HTAB *rs_logical_mappings; /* logical remapping files */ - uint32 rs_num_rewrite_mappings; /* # in memory mappings */ -} RewriteStateData; - /* * The lookup keys for the hash tables are tuple TID and xmin (we must check * both to avoid false matches from dead tuples). Beware that there is diff --git a/src/include/access/rewriteheap.h b/src/include/access/rewriteheap.h index 1125457053..d5108ba2d8 100644 --- a/src/include/access/rewriteheap.h +++ b/src/include/access/rewriteheap.h @@ -14,13 +14,46 @@ #define REWRITE_HEAP_H #include "access/htup.h" +#include "access/xlogdefs.h" #include "storage/itemptr.h" #include "storage/relfilelocator.h" +#include "storage/bufpage.h" #include "utils/relcache.h" +#include "utils/hsearch.h" /* struct definition is private to rewriteheap.c */ typedef struct RewriteStateData *RewriteState; +/* + * State associated with a rewrite operation. + */ +typedef struct RewriteStateData +{ + Relation rs_old_rel; /* source heap */ + Relation rs_new_rel; /* destination heap */ + Page rs_buffer; /* page currently being built */ + BlockNumber rs_blockno; /* block where page will go */ + bool all_visible; + bool rs_buffer_valid; /* T if any tuples in buffer */ + bool rs_logical_rewrite; /* do we need to do logical rewriting */ + TransactionId rs_oldest_xmin; /* oldest xmin used by caller to determine + * tuple visibility */ + TransactionId rs_freeze_xid; /* Xid that will be used as freeze cutoff + * point */ + TransactionId rs_logical_xmin; /* Xid that will be used as cutoff point + * for logical rewrites */ + MultiXactId rs_cutoff_multi; /* MultiXactId that will be used as cutoff + * point for multixacts */ + MemoryContext rs_cxt; /* for hash tables and entries and tuples in + * them */ + XLogRecPtr rs_begin_lsn; /* XLogInsertLsn when starting the rewrite */ + HTAB *rs_unresolved_tups; /* unmatched A tuples */ + HTAB *rs_old_new_tid_map; /* unmatched B tuples */ + HTAB *rs_logical_mappings; /* logical remapping files */ + uint32 rs_num_rewrite_mappings; /* # in memory mappings */ +} RewriteStateData; + + extern RewriteState begin_heap_rewrite(Relation old_heap, Relation new_heap, TransactionId oldest_xmin, TransactionId freeze_xid, MultiXactId cutoff_multi); -- 2.37.2