File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
src/backend/access/transam Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,14 @@ typedef struct
6161/* State of generic xlog record construction */
6262struct GenericXLogState
6363{
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 ];
6570 PageData pages [MAX_GENERIC_XLOG_PAGES ];
71+ bool isLogged ;
6672};
6773
6874static void writeFragment (PageData * pageData , OffsetNumber offset ,
@@ -267,16 +273,11 @@ GenericXLogStart(Relation relation)
267273 int i ;
268274
269275 state = (GenericXLogState * ) palloc (sizeof (GenericXLogState ));
270-
271276 state -> isLogged = RelationNeedsWAL (relation );
277+
272278 for (i = 0 ; i < MAX_GENERIC_XLOG_PAGES ; i ++ )
273279 {
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 ;
280281 state -> pages [i ].buffer = InvalidBuffer ;
281282 }
282283
@@ -432,8 +433,6 @@ GenericXLogFinish(GenericXLogState *state)
432433 lsn = InvalidXLogRecPtr ;
433434 }
434435
435- for (i = 0 ; i < MAX_GENERIC_XLOG_PAGES ; i ++ )
436- pfree (state -> pages [i ].image );
437436 pfree (state );
438437
439438 return lsn ;
You can’t perform that action at this time.
0 commit comments