inet_same_family()

用于判断 IP 地址是否属于同一类型的函数

inet_same_family() 是一个系统函数,用于判断提供的 IP 地址是否属于同一“族” (IPv4IPv6)。

inet_same_family()PostgreSQL 9.5 中被添加。

用法

inet_same_family ( inet, inet ) → boolean

如果提供了无效值,则会引发 ERROR 错误。

变更历史

示例

关于 inet_same_family() 的基本用法示例

postgres=# SELECT inet_same_family('192.168.1.2/24', '127.0.0.1');
 inet_same_family 
------------------
 t
(1 row)

postgres=# SELECT inet_same_family('192.168.1.2', '::0');
 inet_same_family 
------------------
 f
(1 row)

如果提供了无效地址,则会引发 ERROR 错误

postgres=# SELECT inet_same_family('192.168.1.999', '::0');
ERROR:  invalid input syntax for type inet: "192.168.1.999"
LINE 1: SELECT inet_same_family('192.168.1.999', '::0');

分类

网络, 系统函数

另请参阅

family()

反馈

请在此处提交您关于“inet_same_family()”的任何评论、建议或更正 这里