]> granicus.if.org Git - postgresql/commitdiff
Exclude special values in recovery_target_time
authorSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Sep 2017 11:56:34 +0000 (04:56 -0700)
committerSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Sep 2017 11:56:34 +0000 (04:56 -0700)
recovery_target_time accepts timestamp input, though
does not allow use of special values, e.g. “today”.
Report a useful error message for these cases.

Reported-by: Piotr Stefaniak
Author: Simon Riggs
Discussion: https://postgr.es/m/CANP8+jJdKA+BkkYLWz9zAm16Y0s2ExBv0WfpAwXdTpPfWnA9Bg@mail.gmail.com

src/backend/access/transam/xlog.c

index df4843f409363f74737e027526e4a15f8fbd275f..442341a707e07b38142de7f300f9863ec251b540 100644 (file)
@@ -5265,6 +5265,18 @@ readRecoveryCommandFile(void)
                {
                        recoveryTarget = RECOVERY_TARGET_TIME;
 
+                       if (strcmp(item->value, "epoch") == 0 ||
+                               strcmp(item->value, "infinity") == 0 ||
+                               strcmp(item->value, "-infinity") == 0 ||
+                               strcmp(item->value, "now") == 0 ||
+                               strcmp(item->value, "today") == 0 ||
+                               strcmp(item->value, "tomorrow") == 0 ||
+                               strcmp(item->value, "yesterday") == 0)
+                               ereport(FATAL,
+                                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                                errmsg("recovery_target_time is not a valid timestamp: \"%s\"",
+                                                               item->value)));
+
                        /*
                         * Convert the time string given by the user to TimestampTz form.
                         */