Fix recovery.conf boolean variables to take the same range of string
authorBruce Momjian <bruce@momjian.us>
Mon, 30 Jun 2008 22:10:43 +0000 (22:10 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 30 Jun 2008 22:10:43 +0000 (22:10 +0000)
values as postgresql.conf.

src/backend/access/transam/xlog.c
src/backend/utils/misc/guc.c
src/include/utils/guc.h

index dfe8375d1f2822159a01ff195f26ec2919b28cc2..c40fb5b4a06ca4f6de57fd0e36e03f065ef75cff 100644 (file)
@@ -4523,13 +4523,10 @@ readRecoveryCommandFile(void)
                        /*
                         * does nothing if a recovery_target is not also set
                         */
-                       if (strcmp(tok2, "true") == 0)
-                               recoveryTargetInclusive = true;
-                       else
-                       {
-                               recoveryTargetInclusive = false;
-                               tok2 = "false";
-                       }
+                       if (!parse_bool(tok2, &recoveryTargetInclusive))
+                                 ereport(ERROR,
+                                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                         errmsg("parameter \"recovery_target_inclusive\" requires a Boolean value")));
                        ereport(LOG,
                                        (errmsg("recovery_target_inclusive = %s", tok2)));
                }
@@ -4538,13 +4535,10 @@ readRecoveryCommandFile(void)
                        /*
                         * does nothing if a recovery_target is not also set
                         */
-                       if (strcmp(tok2, "true") == 0)
-                               recoveryLogRestartpoints = true;
-                       else
-                       {
-                               recoveryLogRestartpoints = false;
-                               tok2 = "false";
-                       }
+                       if (!parse_bool(tok2, &recoveryLogRestartpoints))
+                                 ereport(ERROR,
+                                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                         errmsg("parameter \"log_restartpoints\" requires a Boolean value")));
                        ereport(LOG,
                                        (errmsg("log_restartpoints = %s", tok2)));
                }
index 456560ba3bc40b17de762560b0f0a5a18d861d23..66cc03df0ec587464a861d5e53750b9228b3cae5 100644 (file)
@@ -3991,7 +3991,7 @@ ReportGUCOption(struct config_generic * record)
  * If the string parses okay, return true, else false.
  * If okay and result is not NULL, return the value in *result.
  */
-static bool
+bool
 parse_bool(const char *value, bool *result)
 {
        size_t          len = strlen(value);
index 7649ffc3429084df8d9332fb6e4e0a962c3e0f63..004df9fdd2fd6a99866ca896f7a68d0459792f7f 100644 (file)
@@ -223,6 +223,7 @@ extern int  NewGUCNestLevel(void);
 extern void AtEOXact_GUC(bool isCommit, int nestLevel);
 extern void BeginReportingGUCOptions(void);
 extern void ParseLongOption(const char *string, char **name, char **value);
+extern bool parse_bool(const char *value, bool *result);
 extern bool set_config_option(const char *name, const char *value,
                                  GucContext context, GucSource source,
                                  GucAction action, bool changeVal);