1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-01 14:21:49 +03:00

Backport addition of rs_old_rel to rewriteheap's state.

Originally part of b89e151054a05f0f6d356ca52e3b725dd0505e53, the
introduction of logical decoding, this is required to backport a
commit introducing error checks defending against recent bugs.

It's possible that extensions calls begin_heap_rewrite(), but it seems
highly unlikely. But if so, they'd break.

Author: Andres Freund
Discussion: https://postgr.es/m/20171215010029.3dxx56vjlymudvwo@alap3.anarazel.de
This commit is contained in:
Andres Freund 2017-12-14 16:50:31 -08:00
parent d5f767c136
commit 152a569056
3 changed files with 5 additions and 3 deletions

View File

@ -120,6 +120,7 @@
*/ */
typedef struct RewriteStateData typedef struct RewriteStateData
{ {
Relation rs_old_rel; /* source heap */
Relation rs_new_rel; /* destination heap */ Relation rs_new_rel; /* destination heap */
Page rs_buffer; /* page currently being built */ Page rs_buffer; /* page currently being built */
BlockNumber rs_blockno; /* block where page will go */ BlockNumber rs_blockno; /* block where page will go */
@ -187,7 +188,7 @@ static void raw_heap_insert(RewriteState state, HeapTuple tup);
* to be used in subsequent calls to the other functions. * to be used in subsequent calls to the other functions.
*/ */
RewriteState RewriteState
begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin, begin_heap_rewrite(Relation old_heap, Relation new_heap, TransactionId oldest_xmin,
TransactionId freeze_xid, MultiXactId cutoff_multi, TransactionId freeze_xid, MultiXactId cutoff_multi,
bool use_wal) bool use_wal)
{ {
@ -210,6 +211,7 @@ begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
/* Create and fill in the state struct */ /* Create and fill in the state struct */
state = palloc0(sizeof(RewriteStateData)); state = palloc0(sizeof(RewriteStateData));
state->rs_old_rel = old_heap;
state->rs_new_rel = new_heap; state->rs_new_rel = new_heap;
state->rs_buffer = (Page) palloc(BLCKSZ); state->rs_buffer = (Page) palloc(BLCKSZ);
/* new_heap needn't be empty, just locked */ /* new_heap needn't be empty, just locked */

View File

@ -887,7 +887,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
is_system_catalog = IsSystemRelation(OldHeap); is_system_catalog = IsSystemRelation(OldHeap);
/* Initialize the rewrite operation */ /* Initialize the rewrite operation */
rwstate = begin_heap_rewrite(NewHeap, OldestXmin, FreezeXid, rwstate = begin_heap_rewrite(OldHeap, NewHeap, OldestXmin, FreezeXid,
MultiXactCutoff, use_wal); MultiXactCutoff, use_wal);
/* /*

View File

@ -19,7 +19,7 @@
/* struct definition is private to rewriteheap.c */ /* struct definition is private to rewriteheap.c */
typedef struct RewriteStateData *RewriteState; typedef struct RewriteStateData *RewriteState;
extern RewriteState begin_heap_rewrite(Relation NewHeap, extern RewriteState begin_heap_rewrite(Relation OldHeap, Relation NewHeap,
TransactionId OldestXmin, TransactionId FreezeXid, TransactionId OldestXmin, TransactionId FreezeXid,
MultiXactId MultiXactCutoff, bool use_wal); MultiXactId MultiXactCutoff, bool use_wal);
extern void end_heap_rewrite(RewriteState state); extern void end_heap_rewrite(RewriteState state);