From 8d8bf127605d0a87b22bb07e630a075506ca5e1e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 26 Jan 2006 02:35:51 +0000 Subject: Clean up the INET-vs-CIDR situation. Get rid of the internal is_cidr flag and rely exclusively on the SQL type system to tell the difference between the types. Prevent creation of invalid CIDR values via casting from INET or set_masklen() --- both of these operations now silently zero any bits to the right of the netmask. Remove duplicate CIDR comparison operators, letting the type rely on the INET operators instead. --- doc/src/sgml/func.sgml | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index a3eadb4bc40..8f6f1ba3926 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,5 +1,5 @@ @@ -6797,9 +6797,7 @@ SELECT pg_sleep(1.5); types. The host, text, and abbrev functions are primarily intended to offer alternative display - formats. You can cast a text value to inet using normal casting - syntax: inet(expression) or - colname::inet. + formats. @@ -6843,6 +6841,13 @@ SELECT pg_sleep(1.5); set_masklen('192.168.1.5/24', 16)192.168.1.5/16 + + set_masklen(cidr, int) + cidr + set netmask length for cidr value + set_masklen('192.168.1.0/24'::cidr, 16) + 192.168.0.0/16 + netmask(inet) inet @@ -6875,6 +6880,13 @@ SELECT pg_sleep(1.5); abbrev(inet) text abbreviated display format as text + abbrev(inet '10.1.0.0/16') + 10.1.0.0/16 + + + abbrev(cidr) + text + abbreviated display format as text abbrev(cidr '10.1.0.0/16') 10.1/16 @@ -6890,6 +6902,22 @@ SELECT pg_sleep(1.5);
+ + Any cidr value can be cast to inet implicitly + or explicitly; therefore, the functions shown above as operating on + inet also work on cidr values. (Where there are + separate functions for inet and cidr, it is because + the behavior should be different for the two cases.) + Also, it is permitted to cast an inet value to cidr. + When this is done, any bits to the right of the netmask are silently zeroed + to create a valid cidr value. + In addition, + you can cast a text value to inet or cidr + using normal casting syntax: for example, + inet(expression) or + colname::cidr. + + shows the functions available for use with the macaddr type. The function -- cgit v1.2.3