Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
bbc02243
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bbc02243
编写于
4月 05, 2012
作者:
R
Robert Haas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow pg_archivecleanup to strip optional file extensions.
Greg Smith and Jaime Casanova, reviewed by Alex Shulgin and myself. e
上级
b736aef2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
4 deletion
+50
-4
contrib/pg_archivecleanup/pg_archivecleanup.c
contrib/pg_archivecleanup/pg_archivecleanup.c
+35
-4
doc/src/sgml/pgarchivecleanup.sgml
doc/src/sgml/pgarchivecleanup.sgml
+15
-0
未找到文件。
contrib/pg_archivecleanup/pg_archivecleanup.c
浏览文件 @
bbc02243
...
...
@@ -37,6 +37,7 @@ const char *progname;
/* Options and defaults */
bool
debug
=
false
;
/* are we debugging? */
bool
dryrun
=
false
;
/* are we performing a dry-run operation? */
char
*
additional_ext
=
NULL
;
/* Extension to remove from filenames */
char
*
archiveLocation
;
/* where to find the archive? */
char
*
restartWALFileName
;
/* the file from which we can restart restore */
...
...
@@ -90,17 +91,37 @@ Initialize(void)
}
}
static
void
TrimExtension
(
char
*
filename
,
char
*
extension
)
{
int
flen
;
int
elen
;
if
(
extension
==
NULL
)
return
;
elen
=
strlen
(
extension
);
flen
=
strlen
(
filename
);
if
(
flen
>
elen
&&
strcmp
(
filename
+
flen
-
elen
,
extension
)
==
0
)
filename
[
flen
-
elen
]
=
'\0'
;
}
static
void
CleanupPriorWALFiles
(
void
)
{
int
rc
;
DIR
*
xldir
;
struct
dirent
*
xlde
;
char
walfile
[
MAXPGPATH
];
if
((
xldir
=
opendir
(
archiveLocation
))
!=
NULL
)
{
while
((
xlde
=
readdir
(
xldir
))
!=
NULL
)
{
strncpy
(
walfile
,
xlde
->
d_name
,
MAXPGPATH
);
TrimExtension
(
walfile
,
additional_ext
);
/*
* We ignore the timeline part of the XLOG segment identifiers in
* deciding whether a segment is still needed. This ensures that
...
...
@@ -114,10 +135,14 @@ CleanupPriorWALFiles(void)
* file. Note that this means files are not removed in the order
* they were originally written, in case this worries you.
*/
if
(
strlen
(
xlde
->
d_nam
e
)
==
XLOG_DATA_FNAME_LEN
&&
strspn
(
xlde
->
d_nam
e
,
"0123456789ABCDEF"
)
==
XLOG_DATA_FNAME_LEN
&&
strcmp
(
xlde
->
d_nam
e
+
8
,
exclusiveCleanupFileName
+
8
)
<
0
)
if
(
strlen
(
walfil
e
)
==
XLOG_DATA_FNAME_LEN
&&
strspn
(
walfil
e
,
"0123456789ABCDEF"
)
==
XLOG_DATA_FNAME_LEN
&&
strcmp
(
walfil
e
+
8
,
exclusiveCleanupFileName
+
8
)
<
0
)
{
/*
* Use the original file name again now, including any extension
* that might have been chopped off before testing the sequence.
*/
snprintf
(
WALFilePath
,
MAXPGPATH
,
"%s/%s"
,
archiveLocation
,
xlde
->
d_name
);
...
...
@@ -167,6 +192,8 @@ SetWALFileNameForCleanup(void)
{
bool
fnameOK
=
false
;
TrimExtension
(
restartWALFileName
,
additional_ext
);
/*
* If restartWALFileName is a WAL file name then just use it directly. If
* restartWALFileName is a .backup filename, make sure we use the prefix
...
...
@@ -223,6 +250,7 @@ usage(void)
printf
(
"
\n
Options:
\n
"
);
printf
(
" -d generates debug output (verbose mode)
\n
"
);
printf
(
" -n shows the names of the files that would have been removed (dry-run)
\n
"
);
printf
(
" -x EXT cleanup files if they have this same extension
\n
"
);
printf
(
" --help show this help, then exit
\n
"
);
printf
(
" --version output version information, then exit
\n
"
);
printf
(
"
\n
"
...
...
@@ -259,7 +287,7 @@ main(int argc, char **argv)
}
}
while
((
c
=
getopt
(
argc
,
argv
,
"dn"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"
x:
dn"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -269,6 +297,9 @@ main(int argc, char **argv)
case
'n'
:
/* Dry-Run mode */
dryrun
=
true
;
break
;
case
'x'
:
additional_ext
=
optarg
;
/* Extension to remove from xlogfile names */
break
;
default:
fprintf
(
stderr
,
"Try
\"
%s --help
\"
for more information.
\n
"
,
progname
);
exit
(
2
);
...
...
doc/src/sgml/pgarchivecleanup.sgml
浏览文件 @
bbc02243
...
...
@@ -107,6 +107,21 @@ pg_archivecleanup: removing file "archive/00000001000000370000000E"
</listitem>
</varlistentry>
<varlistentry>
<term><option>-x</option> <replaceable>extension</></term>
<listitem>
<para>
When using the program as a standalone utility, provide an extension
that will be stripped from all file names before deciding if they
should be deleted. This is typically useful for cleaning up archives
that have been compressed during storage, and therefore have had an
extension added by the compression program. Note that the
<filename>.backup</> file name passed to the program should not
include the extension.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录