提交 9c7a765f 编写于 作者: T Tom Lane

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

Instead use our own abstimein code, which is more flexible anyway.
上级 66ec2db7
......@@ -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:
#
......@@ -18,15 +18,15 @@
#
# 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,
......@@ -50,21 +50,17 @@
#
# 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'
#
#---------------------------------------------------------------------------
......@@ -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) {
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册