7
7
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.309 2008/05/14 14:02:57 mha Exp $
10
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.310 2008/05/16 19:15:05 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -67,6 +67,7 @@ bool XLogArchiveMode = false;
67
67
char * XLogArchiveCommand = NULL ;
68
68
bool fullPageWrites = true;
69
69
bool log_checkpoints = false;
70
+ int sync_method = DEFAULT_SYNC_METHOD ;
70
71
71
72
#ifdef WAL_DEBUG
72
73
bool XLOG_DEBUG = false;
@@ -88,8 +89,6 @@ bool XLOG_DEBUG = false;
88
89
/*
89
90
* GUC support
90
91
*/
91
- int sync_method = DEFAULT_SYNC_METHOD ;
92
-
93
92
const struct config_enum_entry sync_method_options [] = {
94
93
{"fsync" , SYNC_METHOD_FSYNC },
95
94
#ifdef HAVE_FSYNC_WRITETHROUGH
@@ -1613,7 +1612,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch)
1613
1612
* have no open file or the wrong one. However, we do not need to
1614
1613
* fsync more than one file.
1615
1614
*/
1616
- if (sync_method != SYNC_METHOD_OPEN && sync_method != SYNC_METHOD_OPEN_DSYNC )
1615
+ if (sync_method != SYNC_METHOD_OPEN &&
1616
+ sync_method != SYNC_METHOD_OPEN_DSYNC )
1617
1617
{
1618
1618
if (openLogFile >= 0 &&
1619
1619
!XLByteInPrevSeg (LogwrtResult .Write , openLogId , openLogSeg ))
@@ -6340,10 +6340,10 @@ get_sync_bit(int method)
6340
6340
switch (method )
6341
6341
{
6342
6342
/*
6343
- * Values for these sync options are defined even if they are not
6344
- * supported on the current platform. They are not included in
6345
- * the enum option array, and therefor will never be set if the
6346
- * platform doesn't support it .
6343
+ * enum values for all sync options are defined even if they are not
6344
+ * supported on the current platform. But if not, they are not
6345
+ * included in the enum option array, and therefore will never be seen
6346
+ * here .
6347
6347
*/
6348
6348
case SYNC_METHOD_FSYNC :
6349
6349
case SYNC_METHOD_FSYNC_WRITETHROUGH :
@@ -6358,12 +6358,8 @@ get_sync_bit(int method)
6358
6358
return OPEN_DATASYNC_FLAG ;
6359
6359
#endif
6360
6360
default :
6361
- /*
6362
- * This "can never happen", since the available values in
6363
- * new_sync_method are controlled by the available enum
6364
- * options.
6365
- */
6366
- elog (PANIC , "unrecognized wal_sync_method: %d" , method );
6361
+ /* can't happen (unless we are out of sync with option array) */
6362
+ elog (ERROR , "unrecognized wal_sync_method: %d" , method );
6367
6363
return 0 ; /* silence warning */
6368
6364
}
6369
6365
}
@@ -6392,7 +6388,7 @@ assign_xlog_sync_method(int new_sync_method, bool doit, GucSource source)
6392
6388
(errcode_for_file_access (),
6393
6389
errmsg ("could not fsync log file %u, segment %u: %m" ,
6394
6390
openLogId , openLogSeg )));
6395
- if (get_sync_bit (sync_method ) != get_sync_bit (new_sync_method ))
6391
+ if (get_sync_bit (sync_method ) != get_sync_bit (new_sync_method ))
6396
6392
XLogFileClose ();
6397
6393
}
6398
6394
}
0 commit comments