Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
92d1cc89
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,发现更多精彩内容 >>
提交
92d1cc89
编写于
7月 01, 2008
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue psql connection warnings on connection start and via \c, per
observation by David Fetter.
上级
6b797c85
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
113 addition
and
127 deletion
+113
-127
src/bin/psql/command.c
src/bin/psql/command.c
+108
-1
src/bin/psql/command.h
src/bin/psql/command.h
+3
-1
src/bin/psql/startup.c
src/bin/psql/startup.c
+2
-125
未找到文件。
src/bin/psql/command.c
浏览文件 @
92d1cc89
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.19
1 2008/06/26 01:35:45
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.19
2 2008/07/01 00:08:18
momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -29,6 +29,9 @@
#include <sys/types.h>
/* for umask() */
#include <sys/stat.h>
/* for stat() */
#endif
#ifdef USE_SSL
#include <openssl/ssl.h>
#endif
#include "portability/instr_time.h"
...
...
@@ -57,6 +60,15 @@ static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
static
bool
do_connect
(
char
*
dbname
,
char
*
user
,
char
*
host
,
char
*
port
);
static
bool
do_shell
(
const
char
*
command
);
#ifdef USE_SSL
static
void
printSSLInfo
(
void
);
#endif
#ifdef WIN32
static
void
checkWin32Codepage
(
void
);
#endif
/*----------
* HandleSlashCmds:
...
...
@@ -1185,6 +1197,7 @@ do_connect(char *dbname, char *user, char *host, char *port)
* Replace the old connection with the new one, and update
* connection-dependent variables.
*/
connection_warnings
();
PQsetNoticeProcessor
(
n_conn
,
NoticeProcessor
,
NULL
);
pset
.
db
=
n_conn
;
SyncVariables
();
...
...
@@ -1212,6 +1225,100 @@ do_connect(char *dbname, char *user, char *host, char *port)
}
void
connection_warnings
(
void
)
{
if
(
!
pset
.
quiet
&&
!
pset
.
notty
)
{
int
client_ver
=
parse_version
(
PG_VERSION
);
if
(
pset
.
sversion
!=
client_ver
)
{
const
char
*
server_version
;
char
server_ver_str
[
16
];
/* 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
(
_
(
"%s (%s, server %s)
\n
"
),
pset
.
progname
,
PG_VERSION
,
server_version
);
}
else
printf
(
"%s (%s)
\n
"
,
pset
.
progname
,
PG_VERSION
);
if
(
pset
.
sversion
/
100
!=
client_ver
/
100
)
printf
(
_
(
"WARNING: %s version %d.%d, server version %d.%d.
\n
"
" Some psql features might not work.
\n
"
),
pset
.
progname
,
client_ver
/
10000
,
(
client_ver
/
100
)
%
100
,
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
100
);
#ifdef WIN32
checkWin32Codepage
();
#endif
#ifdef USE_SSL
printSSLInfo
();
#endif
}
}
/*
* printSSLInfo
*
* Prints information about the current SSL connection, if SSL is in use
*/
#ifdef USE_SSL
static
void
printSSLInfo
(
void
)
{
int
sslbits
=
-
1
;
SSL
*
ssl
;
ssl
=
PQgetssl
(
pset
.
db
);
if
(
!
ssl
)
return
;
/* no SSL */
SSL_get_cipher_bits
(
ssl
,
&
sslbits
);
printf
(
_
(
"SSL connection (cipher: %s, bits: %i)
\n
"
),
SSL_get_cipher
(
ssl
),
sslbits
);
}
#endif
/*
* checkWin32Codepage
*
* Prints a warning when win32 console codepage differs from Windows codepage
*/
#ifdef WIN32
static
void
checkWin32Codepage
(
void
)
{
unsigned
int
wincp
,
concp
;
wincp
=
GetACP
();
concp
=
GetConsoleCP
();
if
(
wincp
!=
concp
)
{
printf
(
_
(
"WARNING: Console code page (%u) differs from Windows code page (%u)
\n
"
" 8-bit characters might not work correctly. See psql reference
\n
"
" page
\"
Notes for Windows users
\"
for details.
\n
"
),
concp
,
wincp
);
}
}
#endif
/*
* SyncVariables
*
...
...
src/bin/psql/command.h
浏览文件 @
92d1cc89
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.3
0 2008/01/01 19:45:55
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.3
1 2008/07/01 00:08:18
momjian Exp $
*/
#ifndef COMMAND_H
#define COMMAND_H
...
...
@@ -34,6 +34,8 @@ extern bool do_pset(const char *param,
printQueryOpt
*
popt
,
bool
quiet
);
extern
void
connection_warnings
(
void
);
extern
void
SyncVariables
(
void
);
extern
void
UnsyncVariables
(
void
);
...
...
src/bin/psql/startup.c
浏览文件 @
92d1cc89
...
...
@@ -3,14 +3,11 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.14
8 2008/05/16 17:17:00
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.14
9 2008/07/01 00:08:18
momjian Exp $
*/
#include "postgres_fe.h"
#include <sys/types.h>
#ifdef USE_SSL
#include <openssl/ssl.h>
#endif
#ifndef WIN32
#include <unistd.h>
...
...
@@ -78,7 +75,6 @@ struct adhoc_opts
bool
single_txn
;
};
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
);
...
...
@@ -86,14 +82,6 @@ static void process_psqlrc_file(char *filename);
static
void
showVersion
(
void
);
static
void
EstablishVariableSpace
(
void
);
#ifdef USE_SSL
static
void
printSSLInfo
(
void
);
#endif
#ifdef WIN32
static
void
checkWin32Codepage
(
void
);
#endif
/*
*
* main
...
...
@@ -296,49 +284,9 @@ main(int argc, char *argv[])
if
(
!
options
.
no_psqlrc
)
process_psqlrc
(
argv
[
0
]);
connection_warnings
();
if
(
!
pset
.
quiet
&&
!
pset
.
notty
)
{
int
client_ver
=
parse_version
(
PG_VERSION
);
if
(
pset
.
sversion
!=
client_ver
)
{
const
char
*
server_version
;
char
server_ver_str
[
16
];
/* 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
(
_
(
"%s (%s, server %s)
\n
"
),
pset
.
progname
,
PG_VERSION
,
server_version
);
}
else
printf
(
"%s (%s)
\n
"
,
pset
.
progname
,
PG_VERSION
);
if
(
pset
.
sversion
/
100
!=
client_ver
/
100
)
printf
(
_
(
"WARNING: %s version %d.%d, server version %d.%d.
\n
"
" Some psql features might not work.
\n
"
),
pset
.
progname
,
client_ver
/
10000
,
(
client_ver
/
100
)
%
100
,
pset
.
sversion
/
10000
,
(
pset
.
sversion
/
100
)
%
100
);
#ifdef WIN32
checkWin32Codepage
();
#endif
#ifdef USE_SSL
printSSLInfo
();
#endif
printf
(
_
(
"Type
\"
help
\"
for help.
\n\n
"
));
}
if
(
!
pset
.
notty
)
initializeInput
(
options
.
no_readline
?
0
:
1
);
if
(
options
.
action_string
)
/* -f - was used */
...
...
@@ -357,29 +305,6 @@ 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
*/
...
...
@@ -683,54 +608,6 @@ showVersion(void)
/*
* printSSLInfo
*
* Prints information about the current SSL connection, if SSL is in use
*/
#ifdef USE_SSL
static
void
printSSLInfo
(
void
)
{
int
sslbits
=
-
1
;
SSL
*
ssl
;
ssl
=
PQgetssl
(
pset
.
db
);
if
(
!
ssl
)
return
;
/* no SSL */
SSL_get_cipher_bits
(
ssl
,
&
sslbits
);
printf
(
_
(
"SSL connection (cipher: %s, bits: %i)
\n
"
),
SSL_get_cipher
(
ssl
),
sslbits
);
}
#endif
/*
* checkWin32Codepage
*
* Prints a warning when win32 console codepage differs from Windows codepage
*/
#ifdef WIN32
static
void
checkWin32Codepage
(
void
)
{
unsigned
int
wincp
,
concp
;
wincp
=
GetACP
();
concp
=
GetConsoleCP
();
if
(
wincp
!=
concp
)
{
printf
(
_
(
"WARNING: Console code page (%u) differs from Windows code page (%u)
\n
"
" 8-bit characters might not work correctly. See psql reference
\n
"
" page
\"
Notes for Windows users
\"
for details.
\n
"
),
concp
,
wincp
);
}
}
#endif
/*
* Assign hooks for psql variables.
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录