66 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
9- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.11 2000/03/07 23:49:31 momjian Exp $
9+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.12 2000/03/20 07:25:39 vadim Exp $
1010 *
1111 *-------------------------------------------------------------------------
1212 */
13+
1314#include <fcntl.h>
1415#include <unistd.h>
1516#include <errno.h>
@@ -76,6 +77,13 @@ typedef struct XLogCtlWrite
7677uint16 curridx ;/* index of next block to write */
7778}XLogCtlWrite ;
7879
80+
81+ #ifndef HAS_TEST_AND_SET
82+ #define TAS (lck )0
83+ #define S_UNLOCK (lck )
84+ #define S_INIT_LOCK (lck )
85+ #endif
86+
7987typedef struct XLogCtlData
8088{
8189XLogCtlInsert Insert ;
@@ -1153,9 +1161,12 @@ BootStrapXLOG()
11531161{
11541162int fd ;
11551163char buffer [BLCKSZ ];
1156- XLogPageHeader page = (XLogPageHeader )buffer ;
11571164CheckPoint checkPoint ;
1165+
1166+ #ifdef NOT_USED
1167+ XLogPageHeader page = (XLogPageHeader )buffer ;
11581168XLogRecord * record ;
1169+ #endif
11591170
11601171#ifndef __CYGWIN__
11611172fd = open (ControlFilePath ,O_RDWR |O_CREAT |O_EXCL ,S_IRUSR |S_IWUSR );
@@ -1166,14 +1177,14 @@ BootStrapXLOG()
11661177elog (STOP ,"BootStrapXLOG failed to create control file (%s): %d" ,
11671178ControlFilePath ,errno );
11681179
1169- logFile = XLogFileInit (0 ,0 );
1170-
11711180checkPoint .redo .xlogid = 0 ;
11721181checkPoint .redo .xrecoff = SizeOfXLogPHD ;
11731182checkPoint .undo = checkPoint .redo ;
11741183checkPoint .nextXid = FirstTransactionId ;
11751184checkPoint .nextOid = BootstrapObjectIdData ;
11761185
1186+ #ifdef NOT_USED
1187+
11771188memset (buffer ,0 ,BLCKSZ );
11781189page -> xlp_magic = XLOG_PAGE_MAGIC ;
11791190page -> xlp_info = 0 ;
@@ -1186,6 +1197,8 @@ BootStrapXLOG()
11861197record -> xl_rmid = RM_XLOG_ID ;
11871198memcpy ((char * )record + SizeOfXLogRecord ,& checkPoint ,sizeof (checkPoint ));
11881199
1200+ logFile = XLogFileInit (0 ,0 );
1201+
11891202if (write (logFile ,buffer ,BLCKSZ )!= BLCKSZ )
11901203elog (STOP ,"BootStrapXLOG failed to write logfile: %d" ,errno );
11911204
@@ -1195,6 +1208,8 @@ BootStrapXLOG()
11951208close (logFile );
11961209logFile = -1 ;
11971210
1211+ #endif
1212+
11981213memset (buffer ,0 ,BLCKSZ );
11991214ControlFile = (ControlFileData * )buffer ;
12001215ControlFile -> logId = 0 ;
@@ -1233,15 +1248,17 @@ str_time(time_t tnow)
12331248void
12341249StartupXLOG ()
12351250{
1251+ #ifdef NOT_USED
12361252XLogCtlInsert * Insert ;
12371253CheckPoint checkPoint ;
12381254XLogRecPtr RecPtr ,
12391255LastRec ;
12401256XLogRecord * record ;
12411257char buffer [MAXLOGRECSZ + SizeOfXLogRecord ];
1242- int fd ;
12431258int recovery = 0 ;
12441259bool sie_saved = false;
1260+ #endif
1261+ int fd ;
12451262
12461263elog (LOG ,"Data Base System is starting up at %s" ,str_time (time (NULL )));
12471264
@@ -1321,6 +1338,8 @@ StartupXLOG()
13211338elog (LOG ,"Data Base System was interrupted being in production at %s" ,
13221339str_time (ControlFile -> time ));
13231340
1341+ #ifdef NOT_USED
1342+
13241343LastRec = RecPtr = ControlFile -> checkPoint ;
13251344if (!XRecOffIsValid (RecPtr .xrecoff ))
13261345elog (STOP ,"Invalid checkPoint in control file" );
@@ -1460,6 +1479,8 @@ StartupXLOG()
14601479StopIfError = sie_saved ;
14611480}
14621481
1482+ #endif /* NOT_USED */
1483+
14631484ControlFile -> state = DB_IN_PRODUCTION ;
14641485ControlFile -> time = time (NULL );
14651486UpdateControlFile ();
@@ -1486,6 +1507,7 @@ ShutdownXLOG()
14861507void
14871508CreateCheckPoint (bool shutdown )
14881509{
1510+ #ifdef NOT_USED
14891511CheckPoint checkPoint ;
14901512XLogRecPtr recptr ;
14911513XLogCtlInsert * Insert = & XLogCtl -> Insert ;
@@ -1548,10 +1570,19 @@ CreateCheckPoint(bool shutdown)
15481570
15491571XLogFlush (recptr );
15501572
1573+ #endif /* NOT_USED */
1574+
15511575SpinAcquire (ControlFileLockId );
15521576if (shutdown )
15531577ControlFile -> state = DB_SHUTDOWNED ;
1578+
1579+ #ifdef NOT_USED
15541580ControlFile -> checkPoint = MyLastRecPtr ;
1581+ #else
1582+ ControlFile -> checkPoint .xlogid = 0 ;
1583+ ControlFile -> checkPoint .xrecoff = SizeOfXLogPHD ;
1584+ #endif
1585+
15551586ControlFile -> time = time (NULL );
15561587UpdateControlFile ();
15571588SpinRelease (ControlFileLockId );