Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
84e8e5b4
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,发现更多精彩内容 >>
提交
84e8e5b4
编写于
5月 06, 2001
作者:
P
Peter Eisentraut
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make prompt customization work with changeable Unix socket location.
上级
36161b30
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
62 deletion
+31
-62
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+18
-5
src/bin/psql/prompt.c
src/bin/psql/prompt.c
+13
-57
未找到文件。
doc/src/sgml/ref/psql-ref.sgml
浏览文件 @
84e8e5b4
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.4
7 2001/03/24 23:03:26
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.4
8 2001/05/06 17:21:11
petere Exp $
Postgres documentation
-->
...
...
@@ -1970,14 +1970,27 @@ testdb=> <userinput>\set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`</userinp
<variablelist>
<varlistentry>
<term><literal>%M</literal></term>
<listitem><para>The full hostname (with domain name) of the database server (or
<quote>localhost</quote> if hostname information is not available).</para></listitem>
<listitem>
<para>
The full hostname (with domain name) of the database server,
or <literal>[local]</literal> if the connection is over a
Unix domain socket, or
<literal>[local:<replaceable>/dir/name</replaceable>]</literal>,
if the Unix domain socket is not at the compiled in default
location.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>%m</literal></term>
<listitem><para>The hostname of the database server, truncated after the
first dot.</para></listitem>
<listitem>
<para>
The hostname of the database server, truncated after the
first dot, or <literal>[local]</literal> if the connection
is over a Unix domain socket.
</para>
</listitem>
</varlistentry>
<varlistentry>
...
...
src/bin/psql/prompt.c
浏览文件 @
84e8e5b4
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.1
8 2001/03/22 04:00:22 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.1
9 2001/05/06 17:21:11 petere
Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
...
...
@@ -32,9 +32,9 @@
* (might not be completely multibyte safe)
*
* Defined interpolations are:
* %M - database server "hostname.domainname"
(or "localhost" if this
*
information is not available)
* %m - like %M, but hostname only (before first dot)
* %M - database server "hostname.domainname"
, "[local]" for AF_UNIX
*
sockets, "[local:/dir/name]" if not default
* %m - like %M, but hostname only (before first dot)
, or always "[local]"
* %> - database server port number
* %n - database user name
* %/ - current database
...
...
@@ -61,52 +61,6 @@
*--------------------------
*/
/*
* We need hostname information, only if connection is via UNIX socket
*/
#ifdef HAVE_UNIX_SOCKETS
#define DOMAINNAME 1
#define HOSTNAME 2
/*
* Return full hostname for localhost.
* - informations are init only in firts time - not queries DNS or NIS
* for every localhost() call
*/
static
char
*
localhost
(
int
type
,
char
*
buf
,
int
siz
)
{
static
struct
hostent
*
hp
=
NULL
;
static
int
err
=
0
;
if
(
hp
==
NULL
&&
err
==
0
)
{
char
hname
[
256
];
if
(
gethostname
(
hname
,
256
)
==
0
)
{
if
(
!
(
hp
=
gethostbyname
(
hname
)))
err
=
1
;
}
else
err
=
1
;
}
if
(
hp
==
NULL
)
return
strncpy
(
buf
,
"localhost"
,
siz
);
strncpy
(
buf
,
hp
->
h_name
,
siz
);
/* full aaa.bbb.ccc */
if
(
type
==
HOSTNAME
)
buf
[
strcspn
(
buf
,
"."
)]
=
'\0'
;
return
buf
;
}
#endif
/* HAVE_UNIX_SOCKETS */
char
*
get_prompt
(
promptStatus_t
status
)
{
...
...
@@ -166,23 +120,25 @@ get_prompt(promptStatus_t status)
case
'm'
:
if
(
pset
.
db
)
{
const
char
*
host
=
PQhost
(
pset
.
db
);
/* INET socket */
if
(
PQhost
(
pset
.
db
)
)
if
(
host
&&
host
[
0
]
&&
host
[
0
]
!=
'/'
)
{
strncpy
(
buf
,
PQhost
(
pset
.
db
)
,
MAX_PROMPT_SIZE
);
strncpy
(
buf
,
host
,
MAX_PROMPT_SIZE
);
if
(
*
p
==
'm'
)
buf
[
strcspn
(
buf
,
"."
)]
=
'\0'
;
}
/* UNIX socket */
#ifdef HAVE_UNIX_SOCKETS
else
{
if
(
*
p
==
'm'
)
localhost
(
HOSTNAME
,
buf
,
MAX_PROMPT_SIZE
);
if
(
!
host
||
strcmp
(
host
,
DEFAULT_PGSOCKET_DIR
)
==
0
||
*
p
==
'm'
)
strncpy
(
buf
,
"[local]"
,
MAX_PROMPT_SIZE
);
else
localhost
(
DOMAINNAME
,
buf
,
MAX_PROMPT_SIZE
);
snprintf
(
buf
,
MAX_PROMPT_SIZE
,
"[local:%s]"
,
host
);
}
#endif
/* HAVE_UNIX_SOCKETS */
}
break
;
/* DB server port number */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录