]> granicus.if.org Git - postgresql/commitdiff
Remove unportable use of strptime() to parse recovery target time spec.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 19 Jul 2004 14:34:39 +0000 (14:34 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 19 Jul 2004 14:34:39 +0000 (14:34 +0000)
Instead use our own abstimein code, which is more flexible anyway.

src/backend/access/transam/recovery.conf.sample
src/backend/access/transam/xlog.c

index ad1bd5879bb17a7b8748f3fa8beeed31c38adc3a..8a0801764c06802fd969d344e20d522fb39dec9b 100644 (file)
@@ -3,12 +3,12 @@
 # -------------------------------
 #
 # Edit this file to provide the parameters that PostgreSQL
-# needs to perform an archive recovery of a database
+# needs to perform an archive recovery of a database.
 #
 # If "recovery.conf" is present in the PostgreSQL data directory, it is
 # read on postmaster startup.  After successful recovery, it is renamed
-# to "recovery.done" to ensure that we do not accidentally re-enter archive
-# recovery mode.
+# to "recovery.done" to ensure that we do not accidentally re-enter
+# archive recovery mode.
 #
 # This file consists of lines of the form:
 #
 #
 # Comments are introduced with '#'.
 #
-# The complete list of option names and
-# allowed values can be found in the PostgreSQL documentation. The
-# commented-out settings shown below are sample values.
+# The complete list of option names and allowed values can be found
+# in the PostgreSQL documentation. The commented-out settings shown below
+# are example values.
 #
 #---------------------------------------------------------------------------
 # REQUIRED PARAMETERS
 #---------------------------------------------------------------------------
 #
-# restore command
+# restore_command
 #
 # specifies the shell command that is executed to copy log files
 # back from archival storage.  The command string may contain %f,
 #
 # By default, recovery will rollforward to the end of the WAL log.
 # If you want to stop rollforward before that point, you
-# MUST set a recovery target.
+# must set a recovery target.
 #
 # You may set a recovery target either by transactionId, or
 # by timestamp. Recovery may either include or exclude the
-# records with the recovery target value (ie, stop either just
-# after or just before the given target).
+# transaction(s) with the recovery target value (ie, stop either
+# just after or just before the given target, respectively).
 #
-#recovery_target_time = '2004-07-14 22:39:00'
+#recovery_target_time = '2004-07-14 22:39:00 EST'
 #
-# note: target time is interpreted by strptime() and must therefore be
-# given in your system's default timezone.
+#recovery_target_xid = '1100842'
 #
-#recovery_target_xid = '11000'
-#
-# true or false
-#recovery_target_inclusive = 'true'
+#recovery_target_inclusive = 'true'            # 'true' or 'false'
 #
 #---------------------------------------------------------------------------
index 0466fbfa5365e1e1647f73b3a306a31f0e5bdb16..358966d4fc402c174eb6dcd720af769a95705480 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.148 2004/07/19 02:47:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.149 2004/07/19 14:34:39 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3196,8 +3196,6 @@ readRecoveryCommandFile(void)
                        recoveryTargetExact = true;
                }
                else if (strcmp(tok1,"recovery_target_time") == 0) {
-                       struct  tm tm;
-
                        /*
                         * if recovery_target_xid specified, then this overrides
                         * recovery_target_time
@@ -3207,23 +3205,17 @@ readRecoveryCommandFile(void)
                        recoveryTarget = true;
                        recoveryTargetExact = false;
                        /*
-                        * convert the time string given
-                        * by the user to the time_t format.
+                        * Convert the time string given by the user to the time_t format.
+                        * We use type abstime's input converter because we know abstime
+                        * has the same representation as time_t.
                         */
-                       if (strptime(tok2, "%Y-%m-%d %H:%M:%S", &tm) == NULL)
-                               ereport(FATAL,
-                                               (errmsg("invalid recovery_target_time \"%s\"",
-                                                               tok2),
-                                                errhint("Correct format is YYYY-MM-DD hh:mm:ss.")));
-                       recoveryTargetTime = mktime(&tm);
-                       if (recoveryTargetTime == (time_t) -1)
-                               ereport(FATAL,
-                                               (errmsg("invalid recovery_target_time \"%s\"",
-                                                               tok2),
-                                                errhint("Correct format is YYYY-MM-DD hh:mm:ss.")));
+                       recoveryTargetTime = (time_t)
+                               DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
+                                                                                                                CStringGetDatum(tok2)));
                        ereport(LOG,
                                        (errmsg("recovery_target_time = %s",
-                                                       tok2)));
+                                                       DatumGetCString(DirectFunctionCall1(abstimeout,
+                                                                                                                               AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime))))));
                }
                else if (strcmp(tok1,"recovery_target_inclusive") == 0) {
                        /*