File tree 1 file changed +9
-10
lines changed
src/backend/access/transam
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,14 @@ typedef struct
61
61
/* State of generic xlog record construction */
62
62
struct GenericXLogState
63
63
{
64
- bool isLogged ;
64
+ /*
65
+ * page's images. Should be first in this struct to have MAXALIGN'ed
66
+ * images addresses, because some code working with pages directly aligns
67
+ * addresses, not an offsets from begining of page
68
+ */
69
+ char images [MAX_GENERIC_XLOG_PAGES * BLCKSZ ];
65
70
PageData pages [MAX_GENERIC_XLOG_PAGES ];
71
+ bool isLogged ;
66
72
};
67
73
68
74
static void writeFragment (PageData * pageData , OffsetNumber offset ,
@@ -267,16 +273,11 @@ GenericXLogStart(Relation relation)
267
273
int i ;
268
274
269
275
state = (GenericXLogState * ) palloc (sizeof (GenericXLogState ));
270
-
271
276
state -> isLogged = RelationNeedsWAL (relation );
277
+
272
278
for (i = 0 ; i < MAX_GENERIC_XLOG_PAGES ; i ++ )
273
279
{
274
- /*
275
- * pre-alloc page's images to prevent allocation in
276
- * GenericXLogRegisterBuffer() which could be called in different
277
- * memory context(s)
278
- */
279
- state -> pages [i ].image = palloc (BLCKSZ );
280
+ state -> pages [i ].image = state -> images + BLCKSZ * i ;
280
281
state -> pages [i ].buffer = InvalidBuffer ;
281
282
}
282
283
@@ -432,8 +433,6 @@ GenericXLogFinish(GenericXLogState *state)
432
433
lsn = InvalidXLogRecPtr ;
433
434
}
434
435
435
- for (i = 0 ; i < MAX_GENERIC_XLOG_PAGES ; i ++ )
436
- pfree (state -> pages [i ].image );
437
436
pfree (state );
438
437
439
438
return lsn ;
You can’t perform that action at this time.
0 commit comments