* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.303 2008/05/12 00:00:46 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.304 2008/05/12 08:35:05 mha Exp $
*
*-------------------------------------------------------------------------
*/
int XLogArchiveTimeout = 0;
bool XLogArchiveMode = false;
char *XLogArchiveCommand = NULL;
-char *XLOG_sync_method = NULL;
-const char XLOG_sync_method_default[] = DEFAULT_SYNC_METHOD_STR;
bool fullPageWrites = true;
bool log_checkpoints = false;
#define XLOG_SYNC_BIT (enableFsync ? open_sync_bit : 0)
+/*
+ * GUC support
+ */
+const struct config_enum_entry sync_method_options[] = {
+ {"fsync", SYNC_METHOD_FSYNC},
+#ifdef HAVE_FSYNC_WRITETHROUGH
+ {"fsync_writethrough", SYNC_METHOD_FSYNC_WRITETHROUGH},
+#endif
+#ifdef HAVE_FDATASYNC
+ {"fdatasync", SYNC_METHOD_FDATASYNC},
+#endif
+#ifdef OPEN_SYNC_FLAG
+ {"open_sync", SYNC_METHOD_OPEN},
+#endif
+#ifdef OPEN_DATASYNC_FLAG
+ {"open_datasync", SYNC_METHOD_OPEN_DSYNC},
+#endif
+ {NULL, 0}
+};
/*
* Statistics for current checkpoint are collected in this global struct.
* have no open file or the wrong one. However, we do not need to
* fsync more than one file.
*/
- if (sync_method != SYNC_METHOD_OPEN)
+ if (sync_method != SYNC_METHOD_OPEN && sync_method != SYNC_METHOD_OPEN_DSYNC)
{
if (openLogFile >= 0 &&
!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
/*
* GUC support
*/
-const char *
-assign_xlog_sync_method(const char *method, bool doit, GucSource source)
+bool
+assign_xlog_sync_method(int new_sync_method, bool doit, GucSource source)
{
- int new_sync_method;
- int new_sync_bit;
+ int new_sync_bit = 0;
- if (pg_strcasecmp(method, "fsync") == 0)
- {
- new_sync_method = SYNC_METHOD_FSYNC;
- new_sync_bit = 0;
- }
-#ifdef HAVE_FSYNC_WRITETHROUGH
- else if (pg_strcasecmp(method, "fsync_writethrough") == 0)
- {
- new_sync_method = SYNC_METHOD_FSYNC_WRITETHROUGH;
- new_sync_bit = 0;
- }
-#endif
-#ifdef HAVE_FDATASYNC
- else if (pg_strcasecmp(method, "fdatasync") == 0)
+ switch (new_sync_method)
{
- new_sync_method = SYNC_METHOD_FDATASYNC;
- new_sync_bit = 0;
- }
-#endif
+ /*
+ * Values for these sync options are defined even if they are not
+ * supported on the current platform. They are not included in
+ * the enum option array, and therefor will never be set if the
+ * platform doesn't support it.
+ */
+ case SYNC_METHOD_FSYNC:
+ case SYNC_METHOD_FSYNC_WRITETHROUGH:
+ case SYNC_METHOD_FDATASYNC:
+ new_sync_bit = 0;
+ break;
#ifdef OPEN_SYNC_FLAG
- else if (pg_strcasecmp(method, "open_sync") == 0)
- {
- new_sync_method = SYNC_METHOD_OPEN;
- new_sync_bit = OPEN_SYNC_FLAG;
- }
+ case SYNC_METHOD_OPEN:
+ new_sync_bit = OPEN_SYNC_FLAG;
+ break;
#endif
#ifdef OPEN_DATASYNC_FLAG
- else if (pg_strcasecmp(method, "open_datasync") == 0)
- {
- new_sync_method = SYNC_METHOD_OPEN;
- new_sync_bit = OPEN_DATASYNC_FLAG;
- }
+ case SYNC_METHOD_OPEN_DSYNC:
+ new_sync_bit = OPEN_DATASYNC_FLAG;
+ break;
#endif
- else
- return NULL;
+ default:
+ /*
+ * This "can never happen", since the available values in
+ * new_sync_method are controlled by the available enum
+ * options.
+ */
+ elog(PANIC, "unrecognized wal_sync_method: %d", sync_method);
+ break;
+ }
if (!doit)
- return method;
+ return true;
if (sync_method != new_sync_method || open_sync_bit != new_sync_bit)
{
open_sync_bit = new_sync_bit;
}
- return method;
+ return true;
}
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.452 2008/05/12 00:00:52 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.453 2008/05/12 08:35:05 mha Exp $
*
*--------------------------------------------------------------------
*/
{NULL, 0}
};
+/*
+ * Options for enum values stored in other modules
+ */
+extern const struct config_enum_entry sync_method_options[];
+
/*
* GUC option variables that are exported from this module
*/
"localhost", NULL, NULL
},
- {
- {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
- gettext_noop("Selects the method used for forcing WAL updates to disk."),
- NULL
- },
- &XLOG_sync_method,
- XLOG_sync_method_default, assign_xlog_sync_method, NULL
- },
-
{
{"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS,
gettext_noop("Sets the list of known custom variable classes."),
assign_session_replication_role, NULL
},
+ {
+ {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS,
+ gettext_noop("Selects the method used for forcing WAL updates to disk."),
+ NULL
+ },
+ &sync_method,
+ DEFAULT_SYNC_METHOD, sync_method_options,
+ assign_xlog_sync_method, NULL
+ },
+
{
{"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets how binary values are to be encoded in XML."),
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.87 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.88 2008/05/12 08:35:05 mha Exp $
*/
#ifndef XLOG_H
#define XLOG_H
/* Sync methods */
#define SYNC_METHOD_FSYNC 0
#define SYNC_METHOD_FDATASYNC 1
-#define SYNC_METHOD_OPEN 2 /* for O_SYNC and O_DSYNC */
+#define SYNC_METHOD_OPEN 2 /* for O_SYNC */
#define SYNC_METHOD_FSYNC_WRITETHROUGH 3
+#define SYNC_METHOD_OPEN_DSYNC 4 /* for O_DSYNC */
extern int sync_method;
/*
extern bool XLogArchiveMode;
extern char *XLogArchiveCommand;
extern int XLogArchiveTimeout;
-extern char *XLOG_sync_method;
-extern const char XLOG_sync_method_default[];
extern bool log_checkpoints;
#define XLogArchivingActive() (XLogArchiveMode)
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlogdefs.h,v 1.19 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlogdefs.h,v 1.20 2008/05/12 08:35:05 mha Exp $
*/
#ifndef XLOG_DEFS_H
#define XLOG_DEFS_H
#endif
#if defined(OPEN_DATASYNC_FLAG)
-#define DEFAULT_SYNC_METHOD_STR "open_datasync"
-#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN
+#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN_DSYNC
#define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG
#elif defined(HAVE_FDATASYNC)
-#define DEFAULT_SYNC_METHOD_STR "fdatasync"
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
#define DEFAULT_SYNC_FLAGBIT 0
#elif defined(HAVE_FSYNC_WRITETHROUGH_ONLY)
-#define DEFAULT_SYNC_METHOD_STR "fsync_writethrough"
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC_WRITETHROUGH
#define DEFAULT_SYNC_FLAGBIT 0
#else
-#define DEFAULT_SYNC_METHOD_STR "fsync"
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC
#define DEFAULT_SYNC_FLAGBIT 0
#endif
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
- * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.94 2008/04/18 01:42:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.95 2008/05/12 08:35:05 mha Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
bool doit, GucSource source);
/* in access/transam/xlog.c */
-extern const char *assign_xlog_sync_method(const char *method,
- bool doit, GucSource source);
+extern bool assign_xlog_sync_method(int newval,
+ bool doit, GucSource source);
#endif /* GUC_H */