Skip to content

Commit 152a569

Browse files
committed
Backport addition of rs_old_rel to rewriteheap's state.
Originally part of b89e151, 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
1 parent d5f767c commit 152a569

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/backend/access/heap/rewriteheap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
*/
121121
typedef struct RewriteStateData
122122
{
123+
Relation rs_old_rel; /* source heap */
123124
Relation rs_new_rel; /* destination heap */
124125
Page rs_buffer; /* page currently being built */
125126
BlockNumber rs_blockno; /* block where page will go */
@@ -187,7 +188,7 @@ static void raw_heap_insert(RewriteState state, HeapTuple tup);
187188
* to be used in subsequent calls to the other functions.
188189
*/
189190
RewriteState
190-
begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
191+
begin_heap_rewrite(Relation old_heap, Relation new_heap, TransactionId oldest_xmin,
191192
TransactionId freeze_xid, MultiXactId cutoff_multi,
192193
bool use_wal)
193194
{
@@ -210,6 +211,7 @@ begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
210211
/* Create and fill in the state struct */
211212
state = palloc0(sizeof(RewriteStateData));
212213

214+
state->rs_old_rel = old_heap;
213215
state->rs_new_rel = new_heap;
214216
state->rs_buffer = (Page) palloc(BLCKSZ);
215217
/* new_heap needn't be empty, just locked */

src/backend/commands/cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
887887
is_system_catalog = IsSystemRelation(OldHeap);
888888

889889
/* Initialize the rewrite operation */
890-
rwstate = begin_heap_rewrite(NewHeap, OldestXmin, FreezeXid,
890+
rwstate = begin_heap_rewrite(OldHeap, NewHeap, OldestXmin, FreezeXid,
891891
MultiXactCutoff, use_wal);
892892

893893
/*

src/include/access/rewriteheap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/* struct definition is private to rewriteheap.c */
2020
typedef struct RewriteStateData *RewriteState;
2121

22-
extern RewriteState begin_heap_rewrite(Relation NewHeap,
22+
extern RewriteState begin_heap_rewrite(Relation OldHeap, Relation NewHeap,
2323
TransactionId OldestXmin, TransactionId FreezeXid,
2424
MultiXactId MultiXactCutoff, bool use_wal);
2525
extern void end_heap_rewrite(RewriteState state);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy