1313 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1414 * Portions Copyright (c) 1994, Regents of the University of California
1515 *
16- * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.20 2004/05/31 03:47:54 tgl Exp $
16+ * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.21 2004/07/01 00:49:42 tgl Exp $
1717 *
1818 *-------------------------------------------------------------------------
1919 */
2020#include "postgres.h"
2121
2222#include <fcntl.h>
2323#include <dirent.h>
24- #include <errno.h>
2524#include <sys/stat.h>
2625#include <unistd.h>
2726
2827#include "access/clog.h"
2928#include "access/slru.h"
30- #include "storage/lwlock.h"
3129#include "miscadmin.h"
30+ #include "storage/lwlock.h"
3231
3332
3433/*
6564 * is guaranteed flushed through the XLOG commit record before we are called
6665 * to log a commit, so the WAL rule "write xlog before data" is satisfied
6766 * automatically for commits, and we don't really care for aborts. Therefore,
68- * we don't need to mark XLOG pages with LSN information; we have enough
67+ * we don't need to mark CLOG pages with LSN information; we have enough
6968 * synchronization already.
7069 *----------
7170 */
@@ -95,20 +94,22 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status)
9594 char * byteptr ;
9695
9796 Assert (status == TRANSACTION_STATUS_COMMITTED ||
98- status == TRANSACTION_STATUS_ABORTED );
97+ status == TRANSACTION_STATUS_ABORTED ||
98+ status == TRANSACTION_STATUS_SUB_COMMITTED );
9999
100100 LWLockAcquire (ClogCtl -> ControlLock , LW_EXCLUSIVE );
101101
102102 byteptr = SimpleLruReadPage (ClogCtl , pageno , xid , true);
103103 byteptr += byteno ;
104104
105- /* Current state should be 0 or target state */
105+ /* Current state should be 0, subcommitted or target state */
106106 Assert (((* byteptr >> bshift ) & CLOG_XACT_BITMASK ) == 0 ||
107+ ((* byteptr >> bshift ) & CLOG_XACT_BITMASK ) == TRANSACTION_STATUS_SUB_COMMITTED ||
107108 ((* byteptr >> bshift ) & CLOG_XACT_BITMASK ) == status );
108109
109110 * byteptr |= (status << bshift );
110111
111- /* ...->page_status[slotno] = CLOG_PAGE_DIRTY ; already done */
112+ /* ...->page_status[slotno] = SLRU_PAGE_DIRTY ; already done */
112113
113114 LWLockRelease (ClogCtl -> ControlLock );
114115}
@@ -117,7 +118,7 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status)
117118 * Interrogate the state of a transaction in the commit log.
118119 *
119120 * NB: this is a low-level routine and is NOT the preferred entry point
120- * for most uses; TransactionLogTest () in transam.c is the intended caller.
121+ * for most uses; TransactionLogFetch () in transam.c is the intended caller.
121122 */
122123XidStatus
123124TransactionIdGetStatus (TransactionId xid )
@@ -176,7 +177,7 @@ BootStrapCLOG(void)
176177
177178 /* Make sure it's written out */
178179 SimpleLruWritePage (ClogCtl , slotno , NULL );
179- /* Assert(ClogCtl->page_status[slotno] == CLOG_PAGE_CLEAN ); */
180+ /* Assert(ClogCtl->page_status[slotno] == SLRU_PAGE_CLEAN ); */
180181
181182 LWLockRelease (ClogCtl -> ControlLock );
182183}
@@ -211,7 +212,8 @@ StartupCLOG(void)
211212 /*
212213 * Initialize our idea of the latest page number.
213214 */
214- SimpleLruSetLatestPage (ClogCtl , TransactionIdToPage (ShmemVariableCache -> nextXid ));
215+ SimpleLruSetLatestPage (ClogCtl ,
216+ TransactionIdToPage (ShmemVariableCache -> nextXid ));
215217}
216218
217219/*
@@ -333,51 +335,20 @@ WriteZeroPageXlogRec(int pageno)
333335 rdata .data = (char * ) (& pageno );
334336 rdata .len = sizeof (int );
335337 rdata .next = NULL ;
336- (void ) XLogInsert (RM_CLOG_ID , CLOG_ZEROPAGE | XLOG_NO_TRAN , & rdata );
337- }
338-
339- /*
340- * CLOG resource manager's routines
341- */
342- void
343- clog_redo (XLogRecPtr lsn , XLogRecord * record )
344- {
345- uint8 info = record -> xl_info & ~XLR_INFO_MASK ;
346-
347- if (info == CLOG_ZEROPAGE )
348- {
349- int pageno ;
350- int slotno ;
351-
352- memcpy (& pageno , XLogRecGetData (record ), sizeof (int ));
353-
354- LWLockAcquire (ClogCtl -> ControlLock , LW_EXCLUSIVE );
355-
356- slotno = ZeroCLOGPage (pageno , false);
357- SimpleLruWritePage (ClogCtl , slotno , NULL );
358- /* Assert(ClogCtl->page_status[slotno] == SLRU_PAGE_CLEAN); */
359-
360- LWLockRelease (ClogCtl -> ControlLock );
361- }
338+ (void ) XLogInsert (RM_SLRU_ID , CLOG_ZEROPAGE | XLOG_NO_TRAN , & rdata );
362339}
363340
341+ /* Redo a ZEROPAGE action during WAL replay */
364342void
365- clog_undo ( XLogRecPtr lsn , XLogRecord * record )
343+ clog_zeropage_redo ( int pageno )
366344{
367- }
345+ int slotno ;
368346
369- void
370- clog_desc (char * buf , uint8 xl_info , char * rec )
371- {
372- uint8 info = xl_info & ~XLR_INFO_MASK ;
347+ LWLockAcquire (ClogCtl -> ControlLock , LW_EXCLUSIVE );
373348
374- if ( info == CLOG_ZEROPAGE )
375- {
376- int pageno ;
349+ slotno = ZeroCLOGPage ( pageno , false);
350+ SimpleLruWritePage ( ClogCtl , slotno , NULL );
351+ /* Assert(ClogCtl->page_status[slotno] == SLRU_PAGE_CLEAN); */
377352
378- memcpy (& pageno , rec , sizeof (int ));
379- sprintf (buf + strlen (buf ), "zeropage: %d" , pageno );
380- }
381- else
382- strcat (buf , "UNKNOWN" );
353+ LWLockRelease (ClogCtl -> ControlLock );
383354}
0 commit comments