aboutsummaryrefslogtreecommitdiff
path: root/src/fe_utils/option_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe_utils/option_utils.c')
-rw-r--r--src/fe_utils/option_utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/fe_utils/option_utils.c b/src/fe_utils/option_utils.c
index 763c991015b..d2a3adeb4ba 100644
--- a/src/fe_utils/option_utils.c
+++ b/src/fe_utils/option_utils.c
@@ -82,3 +82,30 @@ option_parse_int(const char *optarg, const char *optname,
*result = val;
return true;
}
+
+/*
+ * Provide strictly harmonized handling of the --sync-method option.
+ */
+bool
+parse_sync_method(const char *optarg, DataDirSyncMethod *sync_method)
+{
+ if (strcmp(optarg, "fsync") == 0)
+ *sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
+ else if (strcmp(optarg, "syncfs") == 0)
+ {
+#ifdef HAVE_SYNCFS
+ *sync_method = DATA_DIR_SYNC_METHOD_SYNCFS;
+#else
+ pg_log_error("this build does not support sync method \"%s\"",
+ "syncfs");
+ return false;
+#endif
+ }
+ else
+ {
+ pg_log_error("unrecognized sync method: %s", optarg);
+ return false;
+ }
+
+ return true;
+}