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
2da2d347
Commit
2da2d347
authored
Sep 05, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up version comparison/display code, per gripe from Michael Fuhr.
parent
03728942
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
33 deletions
+51
-33
src/bin/psql/startup.c
src/bin/psql/startup.c
+51
-33
No files found.
src/bin/psql/startup.c
View file @
2da2d347
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.12
1 2005/09/05 13:59:08 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.12
2 2005/09/05 18:05:13 tgl
Exp $
*/
#include "postgres_fe.h"
...
...
@@ -78,6 +78,7 @@ struct adhoc_opts
bool
no_psqlrc
;
};
static
int
parse_version
(
const
char
*
versionString
);
static
void
parse_psql_options
(
int
argc
,
char
*
argv
[],
struct
adhoc_opts
*
options
);
static
void
process_psqlrc
(
char
*
argv0
);
...
...
@@ -312,41 +313,27 @@ main(int argc, char *argv[])
if
(
!
QUIET
()
&&
!
pset
.
notty
)
{
/*
* Server value for 8.12 is 80102.
* This code does not handle release numbers like
* 8.112. (Is that 8.1, version 12, or 8.11, version 2?
*/
int
client_ver_major_int
=
atoi
(
PG_VERSION
)
*
100
+
strchr
(
PG_VERSION
,
'.'
)[
1
]
-
'0'
;
int
client_ver_int
=
atoi
(
PG_VERSION
)
*
10000
+
(
strchr
(
PG_VERSION
,
'.'
)[
1
]
-
'0'
)
*
100
+
(
isdigit
(
strchr
(
PG_VERSION
,
'.'
)[
2
])
?
strchr
(
PG_VERSION
,
'.'
)[
2
]
-
'0'
:
'\0'
);
if
(
pset
.
sversion
/
100
!=
client_ver_major_int
)
{
printf
(
_
(
"WARNING: You are connected to a server with major version %d.%d,
\n
"
"but your %s client is major version %d.%d. Informational backslash
\n
"
"commands, like
\\
d, might not work properly.
\n\n
"
),
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
10
,
pset
.
progname
,
atoi
(
PG_VERSION
),
strchr
(
PG_VERSION
,
'.'
)[
1
]
-
'0'
);
}
int
client_ver
=
parse_version
(
PG_VERSION
);
if
(
pset
.
sversion
!=
client_ver
_int
)
if
(
pset
.
sversion
!=
client_ver
)
{
const
char
*
server_version
;
char
server_ver_str
[
16
];
snprintf
(
server_ver_str
,
16
,
"%d.%c%c"
,
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
10
+
'0'
,
/* print last digit? */
(
pset
.
sversion
%
10
!=
0
)
?
pset
.
sversion
%
10
+
'0'
:
'\0'
);
/* Try to get full text form, might include "devel" etc */
server_version
=
PQparameterStatus
(
pset
.
db
,
"server_version"
);
if
(
!
server_version
)
{
snprintf
(
server_ver_str
,
sizeof
(
server_ver_str
),
"%d.%d.%d"
,
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
100
,
pset
.
sversion
%
100
);
server_version
=
server_ver_str
;
}
printf
(
_
(
"Welcome to %s, the PostgreSQL interactive terminal.
\n
"
),
pset
.
progname
);
printf
(
_
(
"%s version %s, server version %s
\n\n
"
),
pset
.
progname
,
PG_VERSION
,
server_ver_str
);
printf
(
_
(
"Welcome to %s %s (server %s), the PostgreSQL interactive terminal.
\n\n
"
),
pset
.
progname
,
PG_VERSION
,
server_version
);
}
else
printf
(
_
(
"Welcome to %s %s, the PostgreSQL interactive terminal.
\n\n
"
),
...
...
@@ -357,6 +344,15 @@ main(int argc, char *argv[])
"
\\
? for help with psql commands
\n
"
"
\\
g or terminate with semicolon to execute query
\n
"
"
\\
q to quit
\n\n
"
));
if
(
pset
.
sversion
/
100
!=
client_ver
/
100
)
printf
(
_
(
"WARNING: You are connected to a server with major version %d.%d,
\n
"
"but your %s client is major version %d.%d. Some backslash commands,
\n
"
"such as
\\
d, might not work properly.
\n\n
"
),
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
100
,
pset
.
progname
,
client_ver
/
10000
,
(
client_ver
/
100
)
%
100
);
#ifdef USE_SSL
printSSLInfo
();
#endif
...
...
@@ -383,6 +379,28 @@ main(int argc, char *argv[])
}
/*
* Convert a version string into a number.
*/
static
int
parse_version
(
const
char
*
versionString
)
{
int
cnt
;
int
vmaj
,
vmin
,
vrev
;
cnt
=
sscanf
(
versionString
,
"%d.%d.%d"
,
&
vmaj
,
&
vmin
,
&
vrev
);
if
(
cnt
<
2
)
return
-
1
;
if
(
cnt
==
2
)
vrev
=
0
;
return
(
100
*
vmaj
+
vmin
)
*
100
+
vrev
;
}
/*
* Parse command line options
...
...
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