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

Commitcfb0d4c

Browse files
committed
add new option to pg_controldata. '-m' which checks if catversion in pg_control matches catverision of the current binary. Return 0 on match, 1 otherwise
1 parent5f26aa8 commitcfb0d4c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

‎src/bin/pg_controldata/pg_controldata.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ usage(const char *progname)
3838
printf(_(" %s [OPTION] [DATADIR]\n"),progname);
3939
printf(_("\nOptions:\n"));
4040
printf(_(" [-D] DATADIR data directory\n"));
41-
printf(_(" [-c] update catversion in pg_control to the verision of the current binary\n"));
41+
printf(_(" [-c] update catversion in pg_control to the verision of the current binary\n"));
42+
printf(_(" [-m] check if catversion in pg_control matches catverision of the current binary. Return 0 on match, 1 otherwise.\n"));
4243
printf(_(" -V, --version output version information, then exit\n"));
4344
printf(_(" -?, --help show this help, then exit\n"));
4445
printf(_("\nIf no data directory (DATADIR) is specified, "
@@ -101,6 +102,7 @@ main(int argc, char *argv[])
101102
charxlogfilename[MAXFNAMELEN];
102103
intc;
103104
boolreset_catversion= false;
105+
boolcheck_catversion_match= false;
104106

105107
set_pglocale_pgservice(argv[0],PG_TEXTDOMAIN("pg_controldata"));
106108

@@ -120,7 +122,7 @@ main(int argc, char *argv[])
120122
}
121123
}
122124

123-
while ((c=getopt(argc,argv,"D:c"))!=-1)
125+
while ((c=getopt(argc,argv,"D:c:m"))!=-1)
124126
{
125127
switch (c)
126128
{
@@ -130,7 +132,9 @@ main(int argc, char *argv[])
130132
case'c':
131133
reset_catversion= true;
132134
break;
133-
135+
case'm':
136+
check_catversion_match= true;
137+
break;
134138
default:
135139
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
136140
exit(1);
@@ -165,6 +169,14 @@ main(int argc, char *argv[])
165169
/* get a copy of the control file */
166170
ControlFile=get_controlfile(DataDir,progname);
167171

172+
if (check_catversion_match)
173+
{
174+
if (ControlFile->catalog_version_no==CATALOG_VERSION_NO)
175+
return0;
176+
else
177+
return1;
178+
}
179+
168180
if (reset_catversion)
169181
{
170182
ControlFile->catalog_version_no=CATALOG_VERSION_NO;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp