Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c7a765

Browse files
committed
Remove unportable use of strptime() to parse recovery target time spec.
Instead use our own abstimein code, which is more flexible anyway.
1 parent66ec2db commit9c7a765

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

‎src/backend/access/transam/recovery.conf.sample

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# -------------------------------
44
#
55
# Edit this file to provide the parameters that PostgreSQL
6-
# needs to perform an archive recovery of a database
6+
# needs to perform an archive recovery of a database.
77
#
88
# If "recovery.conf" is present in the PostgreSQL data directory, it is
99
# read on postmaster startup. After successful recovery, it is renamed
10-
# to "recovery.done" to ensure that we do not accidentally re-enter archive
11-
# recovery mode.
10+
# to "recovery.done" to ensure that we do not accidentally re-enter
11+
#archiverecovery mode.
1212
#
1313
# This file consists of lines of the form:
1414
#
@@ -18,15 +18,15 @@
1818
#
1919
# Comments are introduced with '#'.
2020
#
21-
# The complete list of option names and
22-
#allowed values can be foundin the PostgreSQL documentation. The
23-
#commented-out settings shown belowaresample values.
21+
# The complete list of option names and allowed values can be found
22+
# in the PostgreSQL documentation. The commented-out settings shown below
23+
# areexample values.
2424
#
2525
#---------------------------------------------------------------------------
2626
# REQUIRED PARAMETERS
2727
#---------------------------------------------------------------------------
2828
#
29-
#restore command
29+
#restore_command
3030
#
3131
# specifies the shell command that is executed to copy log files
3232
# back from archival storage. The command string may contain %f,
@@ -50,21 +50,17 @@
5050
#
5151
# By default, recovery will rollforward to the end of the WAL log.
5252
# If you want to stop rollforward before that point, you
53-
#MUST set a recovery target.
53+
#must set a recovery target.
5454
#
5555
# You may set a recovery target either by transactionId, or
5656
# by timestamp. Recovery may either include or exclude the
57-
#records with the recovery target value (ie, stop either just
58-
# after or just before the given target).
57+
#transaction(s) with the recovery target value (ie, stop either
58+
#justafter or just before the given target, respectively).
5959
#
60-
#recovery_target_time = '2004-07-14 22:39:00'
60+
#recovery_target_time = '2004-07-14 22:39:00 EST'
6161
#
62-
# note: target time is interpreted by strptime() and must therefore be
63-
# given in your system's default timezone.
62+
#recovery_target_xid = '1100842'
6463
#
65-
#recovery_target_xid = '11000'
66-
#
67-
# true or false
68-
#recovery_target_inclusive = 'true'
64+
#recovery_target_inclusive = 'true'# 'true' or 'false'
6965
#
7066
#---------------------------------------------------------------------------

‎src/backend/access/transam/xlog.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.148 2004/07/1902:47:05 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.149 2004/07/1914:34:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -3196,8 +3196,6 @@ readRecoveryCommandFile(void)
31963196
recoveryTargetExact= true;
31973197
}
31983198
elseif (strcmp(tok1,"recovery_target_time")==0) {
3199-
structtmtm;
3200-
32013199
/*
32023200
* if recovery_target_xid specified, then this overrides
32033201
* recovery_target_time
@@ -3207,23 +3205,17 @@ readRecoveryCommandFile(void)
32073205
recoveryTarget= true;
32083206
recoveryTargetExact= false;
32093207
/*
3210-
* convert the time string given
3211-
* by the user to the time_t format.
3208+
* Convert the time string given by the user to the time_t format.
3209+
* We use type abstime's input converter because we know abstime
3210+
* has the same representation as time_t.
32123211
*/
3213-
if (strptime(tok2,"%Y-%m-%d %H:%M:%S",&tm)==NULL)
3214-
ereport(FATAL,
3215-
(errmsg("invalid recovery_target_time \"%s\"",
3216-
tok2),
3217-
errhint("Correct format is YYYY-MM-DD hh:mm:ss.")));
3218-
recoveryTargetTime=mktime(&tm);
3219-
if (recoveryTargetTime== (time_t)-1)
3220-
ereport(FATAL,
3221-
(errmsg("invalid recovery_target_time \"%s\"",
3222-
tok2),
3223-
errhint("Correct format is YYYY-MM-DD hh:mm:ss.")));
3212+
recoveryTargetTime= (time_t)
3213+
DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
3214+
CStringGetDatum(tok2)));
32243215
ereport(LOG,
32253216
(errmsg("recovery_target_time = %s",
3226-
tok2)));
3217+
DatumGetCString(DirectFunctionCall1(abstimeout,
3218+
AbsoluteTimeGetDatum((AbsoluteTime)recoveryTargetTime))))));
32273219
}
32283220
elseif (strcmp(tok1,"recovery_target_inclusive")==0) {
32293221
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp