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

Commit901b89e

Browse files
committed
Get rid of obsolete parse_version helper function.
For getting the server's version in numeric form, use PQserverVersion().It does the exact same parsing as dumputils.c's parse_version(), and hasbeen around in libpq for a long time. For the client's version, just usethe PG_VERSION_NUM constant.
1 parentec143f9 commit901b89e

File tree

6 files changed

+8
-59
lines changed

6 files changed

+8
-59
lines changed

‎src/bin/pg_dump/dumputils.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -456,29 +456,6 @@ appendByteaLiteral(PQExpBuffer buf, const unsigned char *str, size_t length,
456456
}
457457

458458

459-
/*
460-
* Convert backend's version string into a number.
461-
*/
462-
int
463-
parse_version(constchar*versionString)
464-
{
465-
intcnt;
466-
intvmaj,
467-
vmin,
468-
vrev;
469-
470-
cnt=sscanf(versionString,"%d.%d.%d",&vmaj,&vmin,&vrev);
471-
472-
if (cnt<2)
473-
return-1;
474-
475-
if (cnt==2)
476-
vrev=0;
477-
478-
return (100*vmaj+vmin)*100+vrev;
479-
}
480-
481-
482459
/*
483460
* Deconstruct the text representation of a 1-dimensional Postgres array
484461
* into individual items.

‎src/bin/pg_dump/dumputils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
6060
externvoidappendByteaLiteral(PQExpBufferbuf,
6161
constunsignedchar*str,size_tlength,
6262
boolstd_strings);
63-
externintparse_version(constchar*versionString);
6463
externboolparsePGArray(constchar*atext,char***itemarray,int*nitems);
6564
externboolbuildACLCommands(constchar*name,constchar*subname,
6665
constchar*type,constchar*acls,constchar*owner,

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,23 @@ static void _check_database_version(ArchiveHandle *AH);
2929
staticPGconn*_connectDB(ArchiveHandle*AH,constchar*newdbname,constchar*newUser);
3030
staticvoidnotice_processor(void*arg,constchar*message);
3131

32-
staticint
33-
_parse_version(constchar*versionString)
34-
{
35-
intv;
36-
37-
v=parse_version(versionString);
38-
if (v<0)
39-
exit_horribly(modulename,"could not parse version string \"%s\"\n",versionString);
40-
41-
returnv;
42-
}
43-
4432
staticvoid
4533
_check_database_version(ArchiveHandle*AH)
4634
{
47-
intmyversion;
4835
constchar*remoteversion_str;
4936
intremoteversion;
5037

51-
myversion=_parse_version(PG_VERSION);
52-
5338
remoteversion_str=PQparameterStatus(AH->connection,"server_version");
54-
if (!remoteversion_str)
39+
remoteversion=PQserverVersion(AH->connection);
40+
if (remoteversion==0|| !remoteversion_str)
5541
exit_horribly(modulename,"could not get server_version from libpq\n");
5642

57-
remoteversion=_parse_version(remoteversion_str);
58-
5943
AH->public.remoteVersionStr=pg_strdup(remoteversion_str);
6044
AH->public.remoteVersion=remoteversion;
6145
if (!AH->archiveRemoteVersion)
6246
AH->archiveRemoteVersion=AH->public.remoteVersionStr;
6347

64-
if (myversion!=remoteversion
48+
if (remoteversion!=PG_VERSION_NUM
6549
&& (remoteversion<AH->public.minRemoteVersion||
6650
remoteversion>AH->public.maxRemoteVersion))
6751
{

‎src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ main(int argc, char **argv)
295295
intoutputNoOwner=0;
296296
char*outputSuperuser=NULL;
297297
char*use_role=NULL;
298-
intmy_version;
299298
intoptindex;
300299
RestoreOptions*ropt;
301300
ArchiveFormatarchiveFormat=archUnknown;
@@ -620,16 +619,12 @@ main(int argc, char **argv)
620619
/* Let the archiver know how noisy to be */
621620
fout->verbose=g_verbose;
622621

623-
my_version=parse_version(PG_VERSION);
624-
if (my_version<0)
625-
exit_horribly(NULL,"could not parse version string \"%s\"\n",PG_VERSION);
626-
627622
/*
628623
* We allow the server to be back to 7.0, and up to any minor release of
629624
* our own major version. (See also version check in pg_dumpall.c.)
630625
*/
631626
fout->minRemoteVersion=70000;
632-
fout->maxRemoteVersion= (my_version /100)*100+99;
627+
fout->maxRemoteVersion= (PG_VERSION_NUM /100)*100+99;
633628

634629
fout->numWorkers=numWorkers;
635630

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,21 +1873,15 @@ connectDatabase(const char *dbname, const char *connection_string,
18731873
fprintf(stderr,_("%s: could not get server version\n"),progname);
18741874
exit_nicely(1);
18751875
}
1876-
server_version=parse_version(remoteversion_str);
1877-
if (server_version<0)
1876+
server_version=PQserverVersion(conn);
1877+
if (server_version==0)
18781878
{
18791879
fprintf(stderr,_("%s: could not parse server version \"%s\"\n"),
18801880
progname,remoteversion_str);
18811881
exit_nicely(1);
18821882
}
18831883

1884-
my_version=parse_version(PG_VERSION);
1885-
if (my_version<0)
1886-
{
1887-
fprintf(stderr,_("%s: could not parse version \"%s\"\n"),
1888-
progname,PG_VERSION);
1889-
exit_nicely(1);
1890-
}
1884+
my_version=PG_VERSION_NUM;
18911885

18921886
/*
18931887
* We allow the server to be back to 7.0, and up to any minor release of

‎src/bin/psql/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ connection_warnings(bool in_startup)
17081708
{
17091709
if (!pset.quiet&& !pset.notty)
17101710
{
1711-
intclient_ver=parse_version(PG_VERSION);
1711+
intclient_ver=PG_VERSION_NUM;
17121712

17131713
if (pset.sversion!=client_ver)
17141714
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp