1010 *
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.184 2004/08/3002:54:38 momjian Exp $
13+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.185 2004/08/3019:00:03 tgl Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -3462,12 +3462,30 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
34623462if (info == XLOG_XACT_COMMIT )
34633463{
34643464xl_xact_commit * xlrec = (xl_xact_commit * )XLogRecGetData (record );
3465+ TransactionId * sub_xids ;
3466+ TransactionId max_xid ;
34653467int i ;
34663468
34673469TransactionIdCommit (record -> xl_xid );
3470+
34683471/* Mark committed subtransactions as committed */
3469- TransactionIdCommitTree (xlrec -> nsubxacts ,
3470- (TransactionId * )& (xlrec -> xnodes [xlrec -> nrels ]));
3472+ sub_xids = (TransactionId * )& (xlrec -> xnodes [xlrec -> nrels ]);
3473+ TransactionIdCommitTree (xlrec -> nsubxacts ,sub_xids );
3474+
3475+ /* Make sure nextXid is beyond any XID mentioned in the record */
3476+ max_xid = record -> xl_xid ;
3477+ for (i = 0 ;i < xlrec -> nsubxacts ;i ++ )
3478+ {
3479+ if (TransactionIdPrecedes (max_xid ,sub_xids [i ]))
3480+ max_xid = sub_xids [i ];
3481+ }
3482+ if (TransactionIdFollowsOrEquals (max_xid ,
3483+ ShmemVariableCache -> nextXid ))
3484+ {
3485+ ShmemVariableCache -> nextXid = max_xid ;
3486+ TransactionIdAdvance (ShmemVariableCache -> nextXid );
3487+ }
3488+
34713489/* Make sure files supposed to be dropped are dropped */
34723490for (i = 0 ;i < xlrec -> nrels ;i ++ )
34733491{
@@ -3478,12 +3496,30 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
34783496else if (info == XLOG_XACT_ABORT )
34793497{
34803498xl_xact_abort * xlrec = (xl_xact_abort * )XLogRecGetData (record );
3499+ TransactionId * sub_xids ;
3500+ TransactionId max_xid ;
34813501int i ;
34823502
34833503TransactionIdAbort (record -> xl_xid );
3484- /* mark subtransactions as aborted */
3485- TransactionIdAbortTree (xlrec -> nsubxacts ,
3486- (TransactionId * )& (xlrec -> xnodes [xlrec -> nrels ]));
3504+
3505+ /* Mark subtransactions as aborted */
3506+ sub_xids = (TransactionId * )& (xlrec -> xnodes [xlrec -> nrels ]);
3507+ TransactionIdAbortTree (xlrec -> nsubxacts ,sub_xids );
3508+
3509+ /* Make sure nextXid is beyond any XID mentioned in the record */
3510+ max_xid = record -> xl_xid ;
3511+ for (i = 0 ;i < xlrec -> nsubxacts ;i ++ )
3512+ {
3513+ if (TransactionIdPrecedes (max_xid ,sub_xids [i ]))
3514+ max_xid = sub_xids [i ];
3515+ }
3516+ if (TransactionIdFollowsOrEquals (max_xid ,
3517+ ShmemVariableCache -> nextXid ))
3518+ {
3519+ ShmemVariableCache -> nextXid = max_xid ;
3520+ TransactionIdAdvance (ShmemVariableCache -> nextXid );
3521+ }
3522+
34873523/* Make sure files supposed to be dropped are dropped */
34883524for (i = 0 ;i < xlrec -> nrels ;i ++ )
34893525{