几何类型转换函数:
| 函数 | 返回类型 | 描述 | 例子 |
| box(circle) | box | 圆到方框 | box(circle '((0,0),2.0)') |
| box(point) | box | 点到空方框 | box(point '(0,0)') |
| box(point, point) | box | 点到方框 | box(point '(0,0)', point '(1,1)') |
| box(polygon) | box | 多边形到方框 | box(polygon '((0,0),(1,1),(2,0))') |
| bound_box(box, box) | box | 盒到边界框 | bound_box(box '((0,0),(1,1))', box '((3,3),(4,4))') |
| circle(box) | circle | 方框到圆 | circle(box '((0,0),(1,1))') |
| circle(point, double precision) | circle | 中心和半径到圆 | circle(point '(0,0)', 2.0) |
| circle(polygon) | circle | 多边形到圆 | circle(polygon '((0,0),(1,1),(2,0))') |
| line(point, point) | line | 点到线 | line(point '(-1,0)', point '(1,0)') |
| lseg(box) | lseg | 方框对角线到线段 | lseg(box '((-1,0),(1,0))') |
| lseg(point, point) | lseg | 点到线段 | lseg(point '(-1,0)', point '(1,0)') |
| path(polygon) | path | 多边形到路径 | path(polygon '((0,0),(1,1),(2,0))') |
| point(double precision, double precision) | point | 构造点 | point(23.4, -44.5) |
| point(box) | point | 方框的中心 | point(box '((-1,0),(1,0))') |
| point(circle) | point | 圆的中心 | point(circle '((0,0),2.0)') |
| point(lseg) | point | 线段的中心 | point(lseg '((-1,0),(1,0))') |
| point(polygon) | point | 多边形的中心 | point(polygon '((0,0),(1,1),(2,0))') |
| polygon(box) | polygon | 方框到4点多边形 | polygon(box '((0,0),(1,1))') |
| polygon(circle) | polygon | 圆到12点多边形 | polygon(circle '((0,0),2.0)') |
| polygon(npts, circle) | polygon | 点到npts点多边形 | polygon(12, circle '((0,0),2.0)') |
| polygon(path) | polygon | 路径到多边形 | polygon(path '((0,0),(1,1),(2,0))') |
可用于cidr和inet的操作符:
| 操作符 | 描述 | 例子 |
| < | 小于 | inet '192.168.1.5' < inet '192.168.1.6' |
| <= | 小于等于 | inet '192.168.1.5' <= inet '192.168.1.5' |
| = | 等于 | inet '192.168.1.5' = inet '192.168.1.5' |
| >= | 大于等于 | inet '192.168.1.5' >= inet '192.168.1.5' |
| > | 大于 | inet '192.168.1.5' > inet '192.168.1.4' |
| <> | 不等于 | inet '192.168.1.5' <> inet '192.168.1.4' |
| << | 被包含在内 | inet '192.168.1.5' << inet '192.168.1/24' |
| <<= | 被包含在内或等于 | inet '192.168.1/24' <<= inet '192.168.1/24' |
| >> | 包含 | inet '192.168.1/24' >> inet '192.168.1.5' |
| >>= | 包含或等于 | inet '192.168.1/24' >>= inet '192.168.1/24' |
| && | 包含或者被包含contains or is contained by | inet '192.168.1/24' && inet '192.168.1.80/28' |
| ~ | 按位 NOT | ~ inet '192.168.1.6' |
| & | 按位 AND | inet '192.168.1.6' & inet '0.0.0.255' |
| | | 按位 OR | inet '192.168.1.6' | inet '0.0.0.255' |
| + | 加 | inet '192.168.1.6' + 25 |
| - | 减 | inet '192.168.1.43' - 36 |
| - | 减 | inet '192.168.1.43' - inet '192.168.1.19' |
可用于cidr和inet的函数:
| 函数 | 返回类型 | 描述 | 例子 | 结果 |
| abbrev(inet) | text | 缩写显示格式文本 | abbrev(inet '10.1.0.0/16') | 10.1.0.0/16 |
| abbrev(cidr) | text | 缩写显示格式文本 | abbrev(cidr '10.1.0.0/16') | 10.1/16 |
| broadcast(inet) | inet | 网络广播地址 | broadcast('192.168.1.5/24') | 192.168.1.255/24 |
| family(inet) | int | 抽取地址族;4为 IPv4, 6为 IPv6 | family('::1') | 6 |
| host(inet) | text | 抽取 IP 地址为文本 | host('192.168.1.5/24') | 192.168.1.5 |
| hostmask(inet) | inet | 为网络构造主机掩码 | hostmask('192.168.23.20/30') | 0.0.0.3 |
| masklen(inet) | int | 抽取网络掩码长度 | masklen('192.168.1.5/24') | 24 |
| netmask(inet) | inet | 为网络构造网络掩码 | netmask('192.168.1.5/24') | 255.255.255.0 |
| network(inet) | cidr | 抽取地址的网络部分 | network('192.168.1.5/24') | 192.168.1.0/24 |
| set_masklen(inet, int) | inet | 为inet值设置网络掩码长度 | set_masklen('192.168.1.5/24', 16) | 192.168.1.5/16 |
| set_masklen(cidr, int) | cidr | 为cidr值设置网络掩码长度 | set_masklen('192.168.1.0/24'::cidr, 16) | 192.168.0.0/16 |
| text(inet) | text | 抽取 IP 地址和网络掩码长度为文本 | text(inet '192.168.1.5') | 192.168.1.5/32 |
| inet_same_family(inet, inet) | boolean | 地址来自同一个地址族吗? | inet_same_family('192.168.1.5/24', '::1') | false |
| inet_merge(inet, inet) | cidr | 最小的网络包括给定的两个网络 | inet_merge('192.168.1.5/24', '192.168.2.5/24') | 192.168.0.0/22 |