Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
dd81eee2
Commit
dd81eee2
authored
Jun 22, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use libpq's new logic to get the server version, instead of doing it ourselves.
parent
e92dc1e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
26 deletions
+16
-26
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_db.c
+7
-13
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_dumpall.c
+9
-13
No files found.
src/bin/pg_dump/pg_backup_db.c
View file @
dd81eee2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
* Implements the basic DB functions used by the archiver.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.4
7 2003/05/14 03:26:02
tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.4
8 2003/06/22 00:56:58
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -53,29 +53,23 @@ _parse_version(ArchiveHandle *AH, const char *versionString)
...
@@ -53,29 +53,23 @@ _parse_version(ArchiveHandle *AH, const char *versionString)
static
void
static
void
_check_database_version
(
ArchiveHandle
*
AH
,
bool
ignoreVersion
)
_check_database_version
(
ArchiveHandle
*
AH
,
bool
ignoreVersion
)
{
{
PGresult
*
res
;
int
myversion
;
int
myversion
;
const
char
*
remoteversion_str
;
const
char
*
remoteversion_str
;
int
remoteversion
;
int
remoteversion
;
PGconn
*
conn
=
AH
->
connection
;
myversion
=
_parse_version
(
AH
,
PG_VERSION
);
myversion
=
_parse_version
(
AH
,
PG_VERSION
);
res
=
PQexec
(
conn
,
"SELECT version();"
);
remoteversion_str
=
PQparameterStatus
(
AH
->
connection
,
"server_version"
);
if
(
!
res
||
if
(
!
remoteversion_str
)
PQresultStatus
(
res
)
!=
PGRES_TUPLES_OK
||
die_horribly
(
AH
,
modulename
,
"could not get server_version from libpq
\n
"
);
PQntuples
(
res
)
!=
1
)
die_horribly
(
AH
,
modulename
,
"could not get version from server: %s"
,
PQerrorMessage
(
conn
));
remoteversion_str
=
PQgetvalue
(
res
,
0
,
0
);
remoteversion
=
_parse_version
(
AH
,
remoteversion_str
+
11
);
PQclear
(
res
);
remoteversion
=
_parse_version
(
AH
,
remoteversion_str
);
AH
->
public
.
remoteVersion
=
remoteversion
;
AH
->
public
.
remoteVersion
=
remoteversion
;
if
(
myversion
!=
remoteversion
if
(
myversion
!=
remoteversion
&&
(
remoteversion
<
AH
->
public
.
minRemoteVersion
||
remoteversion
>
AH
->
public
.
maxRemoteVersion
))
&&
(
remoteversion
<
AH
->
public
.
minRemoteVersion
||
remoteversion
>
AH
->
public
.
maxRemoteVersion
))
{
{
write_msg
(
NULL
,
"server version: %s; %s version: %s
\n
"
,
write_msg
(
NULL
,
"server version: %s; %s version: %s
\n
"
,
remoteversion_str
,
progname
,
PG_VERSION
);
remoteversion_str
,
progname
,
PG_VERSION
);
...
...
src/bin/pg_dump/pg_dumpall.c
View file @
dd81eee2
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
*
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.2
1 2003/06/11 05:13:11 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.2
2 2003/06/22 00:56:58 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -701,7 +701,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
...
@@ -701,7 +701,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
PGconn
*
conn
;
PGconn
*
conn
;
char
*
password
=
NULL
;
char
*
password
=
NULL
;
bool
need_pass
=
false
;
bool
need_pass
=
false
;
PGresult
*
res
;
const
char
*
remoteversion_str
;
if
(
require_password
)
if
(
require_password
)
password
=
simple_prompt
(
"Password: "
,
100
,
false
);
password
=
simple_prompt
(
"Password: "
,
100
,
false
);
...
@@ -745,23 +745,19 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
...
@@ -745,23 +745,19 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
exit
(
1
);
exit
(
1
);
}
}
re
s
=
executeQuery
(
conn
,
"SELECT version();
"
);
re
moteversion_str
=
PQparameterStatus
(
conn
,
"server_version
"
);
if
(
PQntuples
(
res
)
!=
1
)
if
(
!
remoteversion_str
)
{
{
fprintf
(
stderr
,
_
(
"%s: could not get server version
\n
"
),
progname
);
fprintf
(
stderr
,
_
(
"%s: could not get server version
\n
"
),
progname
);
exit
(
1
);
exit
(
1
);
}
}
else
server_version
=
parse_version
(
remoteversion_str
);
if
(
server_version
<
0
)
{
{
char
*
val
=
PQgetvalue
(
res
,
0
,
0
);
fprintf
(
stderr
,
_
(
"%s: could not parse server version
\"
%s
\"\n
"
),
server_version
=
parse_version
(
val
+
strcspn
(
val
,
"0123456789"
));
progname
,
remoteversion_str
);
if
(
server_version
<
0
)
exit
(
1
);
{
fprintf
(
stderr
,
_
(
"%s: could not parse server version
\"
%s
\"\n
"
),
progname
,
val
);
exit
(
1
);
}
}
}
PQclear
(
res
);
return
conn
;
return
conn
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment