Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
ba0f9ff3
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,发现更多精彩内容 >>
提交
ba0f9ff3
编写于
6月 13, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code review for recently-added network functions. Get it to work when
log_hostname is enabled, clean up documentation.
上级
88961fc4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
192 addition
and
135 deletion
+192
-135
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+32
-16
src/backend/utils/adt/network.c
src/backend/utils/adt/network.c
+145
-104
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+10
-10
src/include/utils/builtins.h
src/include/utils/builtins.h
+5
-5
未找到文件。
doc/src/sgml/func.sgml
浏览文件 @
ba0f9ff3
<!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.20
6 2004/06/02 21:34:49 momjian
Exp $
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.20
7 2004/06/13 19:56:49 tgl
Exp $
PostgreSQL documentation
-->
...
...
@@ -6609,25 +6609,25 @@ SELECT NULLIF(value, '(none)') ...
</row>
<row>
<entry><function>inet_client_addr</function></entry>
<entry><function>inet_client_addr
()
</function></entry>
<entry><type>inet</type></entry>
<entry>address of the remote connection</entry>
</row>
<row>
<entry><function>inet_client_port</function></entry>
<entry><function>inet_client_port
()
</function></entry>
<entry><type>int4</type></entry>
<entry>port of the remote connection</entry>
</row>
<row>
<entry><function>inet_server_addr</function></entry>
<entry><function>inet_server_addr
()
</function></entry>
<entry><type>inet</type></entry>
<entry>address of the local connection</entry>
</row>
<row>
<entry><function>inet_server_port</function></entry>
<entry><function>inet_server_port
()
</function></entry>
<entry><type>int4</type></entry>
<entry>port of the local connection</entry>
</row>
...
...
@@ -6687,17 +6687,6 @@ SELECT NULLIF(value, '(none)') ...
</para>
</note>
<para>
<function>inet_client_addr</function> and
<function>inet_server_addr</function> return the IPv4 or IPv6 (if
configured) address of the remote or local host connecting to the
database, respectively. <function>inet_client_port</function>
and <function>inet_server_port</function> return the port number
of the remote or local host connecting to the database,
respectively. If the connection is not a network connection,
these functions will return <literal>NULL</literal>.
</para>
<para>
<function>current_schema</function> returns the name of the schema that is
at the front of the search path (or a null value if the search path is
...
...
@@ -6718,6 +6707,33 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
</para>
</note>
<indexterm zone="functions-misc">
<primary>inet_client_addr</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>inet_client_port</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>inet_server_addr</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>inet_server_port</primary>
</indexterm>
<para>
<function>inet_client_addr</function> returns the IP address of the
current client, and <function>inet_client_port</function> returns the
port number.
<function>inet_server_addr</function> returns the IP address on which
the server accepted the current connection, and
<function>inet_server_port</function> returns the port number.
All these functions return NULL if the connection is via a Unix-domain
socket.
</para>
<indexterm zone="functions-misc">
<primary>version</primary>
</indexterm>
...
...
src/backend/utils/adt/network.c
浏览文件 @
ba0f9ff3
/*
* PostgreSQL type definitions for the INET and CIDR types.
*
* $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.5
0 2004/05/26 18:35:38 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.5
1 2004/06/13 19:56:50 tgl
Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
...
...
@@ -133,109 +133,6 @@ cidr_in(PG_FUNCTION_ARGS)
PG_RETURN_INET_P
(
network_in
(
src
,
1
));
}
/* INET that the client is connecting from */
Datum
inet_client_addr
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
raddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
PG_RETURN_INET_P
(
network_in
(
port
->
remote_host
,
0
));
}
/* port that the client is connecting from */
Datum
inet_client_port
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
PG_RETURN_INT32
(
DirectFunctionCall1
(
int4in
,
CStringGetDatum
(
port
->
remote_port
)));
}
/* server INET that the client connected to */
Datum
inet_server_addr
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
local_host
[
NI_MAXHOST
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
laddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
local_host
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
laddr
.
addr
,
port
->
laddr
.
salen
,
local_host
,
sizeof
(
local_host
),
NULL
,
0
,
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_INET_P
(
network_in
(
local_host
,
0
));
}
/* port that the server accepted the connection on */
Datum
inet_server_port
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
local_port
[
NI_MAXSERV
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
laddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
local_port
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
laddr
.
addr
,
port
->
laddr
.
salen
,
NULL
,
0
,
local_port
,
sizeof
(
local_port
),
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_INT32
(
DirectFunctionCall1
(
int4in
,
CStringGetDatum
(
local_port
)));
}
/*
* INET address output function.
...
...
@@ -1069,3 +966,147 @@ network_scan_last(Datum in)
DirectFunctionCall1
(
network_broadcast
,
in
),
Int32GetDatum
(
-
1
));
}
/*
* IP address that the client is connecting from (NULL if Unix socket)
*/
Datum
inet_client_addr
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
remote_host
[
NI_MAXHOST
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
raddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
remote_host
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
raddr
.
addr
,
port
->
raddr
.
salen
,
remote_host
,
sizeof
(
remote_host
),
NULL
,
0
,
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_INET_P
(
network_in
(
remote_host
,
0
));
}
/*
* port that the client is connecting from (NULL if Unix socket)
*/
Datum
inet_client_port
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
remote_port
[
NI_MAXSERV
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
raddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
remote_port
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
raddr
.
addr
,
port
->
raddr
.
salen
,
NULL
,
0
,
remote_port
,
sizeof
(
remote_port
),
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_DATUM
(
DirectFunctionCall1
(
int4in
,
CStringGetDatum
(
remote_port
)));
}
/*
* IP address that the server accepted the connection on (NULL if Unix socket)
*/
Datum
inet_server_addr
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
local_host
[
NI_MAXHOST
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
laddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
local_host
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
laddr
.
addr
,
port
->
laddr
.
salen
,
local_host
,
sizeof
(
local_host
),
NULL
,
0
,
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_INET_P
(
network_in
(
local_host
,
0
));
}
/*
* port that the server accepted the connection on (NULL if Unix socket)
*/
Datum
inet_server_port
(
PG_FUNCTION_ARGS
)
{
Port
*
port
=
MyProcPort
;
char
local_port
[
NI_MAXSERV
];
int
ret
;
if
(
port
==
NULL
)
PG_RETURN_NULL
();
switch
(
port
->
laddr
.
addr
.
ss_family
)
{
case
AF_INET
:
#ifdef HAVE_IPV6
case
AF_INET6
:
#endif
break
;
default:
PG_RETURN_NULL
();
}
local_port
[
0
]
=
'\0'
;
ret
=
getnameinfo_all
(
&
port
->
laddr
.
addr
,
port
->
laddr
.
salen
,
NULL
,
0
,
local_port
,
sizeof
(
local_port
),
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
ret
)
PG_RETURN_NULL
();
PG_RETURN_DATUM
(
DirectFunctionCall1
(
int4in
,
CStringGetDatum
(
local_port
)));
}
src/include/catalog/pg_proc.h
浏览文件 @
ba0f9ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.33
5 2004/06/06 19:07:00
tgl Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.33
6 2004/06/13 19:56:51
tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -2346,15 +2346,6 @@ DESCR("I/O");
DATA
(
insert
OID
=
911
(
inet_out
PGNSP
PGUID
12
f
f
t
f
i
1
2275
"869"
_null_
inet_out
-
_null_
));
DESCR
(
"I/O"
);
DATA
(
insert
OID
=
2196
(
inet_client_addr
PGNSP
PGUID
12
f
f
f
f
s
0
869
""
_null_
inet_client_addr
-
_null_
));
DESCR
(
"Returns the INET address of the client connected to the backend"
);
DATA
(
insert
OID
=
2197
(
inet_client_port
PGNSP
PGUID
12
f
f
f
f
s
0
23
""
_null_
inet_client_port
-
_null_
));
DESCR
(
"Returns the client's port number for this connection"
);
DATA
(
insert
OID
=
2198
(
inet_server_addr
PGNSP
PGUID
12
f
f
f
f
s
0
869
""
_null_
inet_server_addr
-
_null_
));
DESCR
(
"Returns the INET address that the backend is using to service the connection"
);
DATA
(
insert
OID
=
2199
(
inet_server_port
PGNSP
PGUID
12
f
f
f
f
s
0
23
""
_null_
inet_server_port
-
_null_
));
DESCR
(
"Returns the servers's port number for this connection"
);
/* for cidr type support */
DATA
(
insert
OID
=
1267
(
cidr_in
PGNSP
PGUID
12
f
f
t
f
i
1
650
"2275"
_null_
cidr_in
-
_null_
));
DESCR
(
"I/O"
);
...
...
@@ -2411,6 +2402,15 @@ DESCR("text to cidr");
DATA
(
insert
OID
=
1715
(
set_masklen
PGNSP
PGUID
12
f
f
t
f
i
2
869
"869 23"
_null_
inet_set_masklen
-
_null_
));
DESCR
(
"change the netmask of an inet"
);
DATA
(
insert
OID
=
2196
(
inet_client_addr
PGNSP
PGUID
12
f
f
f
f
s
0
869
""
_null_
inet_client_addr
-
_null_
));
DESCR
(
"INET address of the client"
);
DATA
(
insert
OID
=
2197
(
inet_client_port
PGNSP
PGUID
12
f
f
f
f
s
0
23
""
_null_
inet_client_port
-
_null_
));
DESCR
(
"client's port number for this connection"
);
DATA
(
insert
OID
=
2198
(
inet_server_addr
PGNSP
PGUID
12
f
f
f
f
s
0
869
""
_null_
inet_server_addr
-
_null_
));
DESCR
(
"INET address of the server"
);
DATA
(
insert
OID
=
2199
(
inet_server_port
PGNSP
PGUID
12
f
f
f
f
s
0
23
""
_null_
inet_server_port
-
_null_
));
DESCR
(
"server's port number for this connection"
);
DATA
(
insert
OID
=
1686
(
numeric
PGNSP
PGUID
12
f
f
t
f
i
1
1700
"25"
_null_
text_numeric
-
_null_
));
DESCR
(
"(internal)"
);
DATA
(
insert
OID
=
1688
(
text
PGNSP
PGUID
12
f
f
t
f
i
1
25
"1700"
_null_
numeric_text
-
_null_
));
...
...
src/include/utils/builtins.h
浏览文件 @
ba0f9ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.24
1 2004/06/02 21:29:29 momjian
Exp $
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.24
2 2004/06/13 19:56:52 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -649,10 +649,6 @@ extern int inet_net_pton(int af, const char *src,
void
*
dst
,
size_t
size
);
/* network.c */
extern
Datum
inet_client_addr
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_client_port
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_server_addr
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_server_port
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_in
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_out
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_recv
(
PG_FUNCTION_ARGS
);
...
...
@@ -687,6 +683,10 @@ extern Datum text_inet(PG_FUNCTION_ARGS);
extern
Datum
inet_set_masklen
(
PG_FUNCTION_ARGS
);
extern
Datum
network_scan_first
(
Datum
in
);
extern
Datum
network_scan_last
(
Datum
in
);
extern
Datum
inet_client_addr
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_client_port
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_server_addr
(
PG_FUNCTION_ARGS
);
extern
Datum
inet_server_port
(
PG_FUNCTION_ARGS
);
/* mac.c */
extern
Datum
macaddr_in
(
PG_FUNCTION_ARGS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录