Commit 9c7a765f authored by Tom Lane's avatar Tom Lane

Remove unportable use of strptime() to parse recovery target time spec.

Instead use our own abstimein code, which is more flexible anyway.
parent 66ec2db7
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
# ------------------------------- # -------------------------------
# #
# Edit this file to provide the parameters that PostgreSQL # 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 # If "recovery.conf" is present in the PostgreSQL data directory, it is
# read on postmaster startup. After successful recovery, it is renamed # read on postmaster startup. After successful recovery, it is renamed
# to "recovery.done" to ensure that we do not accidentally re-enter archive # to "recovery.done" to ensure that we do not accidentally re-enter
# recovery mode. # archive recovery mode.
# #
# This file consists of lines of the form: # This file consists of lines of the form:
# #
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
# #
# Comments are introduced with '#'. # Comments are introduced with '#'.
# #
# The complete list of option names and # The complete list of option names and allowed values can be found
# allowed values can be found in the PostgreSQL documentation. The # in the PostgreSQL documentation. The commented-out settings shown below
# commented-out settings shown below are sample values. # are example values.
# #
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# REQUIRED PARAMETERS # REQUIRED PARAMETERS
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# #
# restore command # restore_command
# #
# specifies the shell command that is executed to copy log files # specifies the shell command that is executed to copy log files
# back from archival storage. The command string may contain %f, # back from archival storage. The command string may contain %f,
...@@ -50,21 +50,17 @@ ...@@ -50,21 +50,17 @@
# #
# By default, recovery will rollforward to the end of the WAL log. # By default, recovery will rollforward to the end of the WAL log.
# If you want to stop rollforward before that point, you # 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 # You may set a recovery target either by transactionId, or
# by timestamp. Recovery may either include or exclude the # by timestamp. Recovery may either include or exclude the
# records with the recovery target value (ie, stop either just # transaction(s) with the recovery target value (ie, stop either
# after or just before the given target). # 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 #recovery_target_xid = '1100842'
# given in your system's default timezone.
# #
#recovery_target_xid = '11000' #recovery_target_inclusive = 'true' # 'true' or 'false'
#
# true or false
#recovery_target_inclusive = 'true'
# #
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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) ...@@ -3196,8 +3196,6 @@ readRecoveryCommandFile(void)
recoveryTargetExact = true; recoveryTargetExact = true;
} }
else if (strcmp(tok1,"recovery_target_time") == 0) { else if (strcmp(tok1,"recovery_target_time") == 0) {
struct tm tm;
/* /*
* if recovery_target_xid specified, then this overrides * if recovery_target_xid specified, then this overrides
* recovery_target_time * recovery_target_time
...@@ -3207,23 +3205,17 @@ readRecoveryCommandFile(void) ...@@ -3207,23 +3205,17 @@ readRecoveryCommandFile(void)
recoveryTarget = true; recoveryTarget = true;
recoveryTargetExact = false; recoveryTargetExact = false;
/* /*
* convert the time string given * Convert the time string given by the user to the time_t format.
* 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) recoveryTargetTime = (time_t)
ereport(FATAL, DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
(errmsg("invalid recovery_target_time \"%s\"", CStringGetDatum(tok2)));
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.")));
ereport(LOG, ereport(LOG,
(errmsg("recovery_target_time = %s", (errmsg("recovery_target_time = %s",
tok2))); DatumGetCString(DirectFunctionCall1(abstimeout,
AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime))))));
} }
else if (strcmp(tok1,"recovery_target_inclusive") == 0) { else if (strcmp(tok1,"recovery_target_inclusive") == 0) {
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment