11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.117 2003/06/17 23:12:36 tgl Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.118 2003/06/24 22:21:21 momjian Exp $
33-->
44
55 <chapter id="datatype">
@@ -100,7 +100,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.117 2003/06/17 23:12:36 t
100100 <row>
101101 <entry><type>cidr</type></entry>
102102 <entry></entry>
103- <entry>IP network address</entry>
103+ <entry>IPv4 or IPv6 network address</entry>
104104 </row>
105105
106106 <row>
@@ -124,7 +124,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.117 2003/06/17 23:12:36 t
124124 <row>
125125 <entry><type>inet</type></entry>
126126 <entry></entry>
127- <entry>IP host address</entry>
127+ <entry>IPv4 or IPv6 host address</entry>
128128 </row>
129129
130130 <row>
@@ -2425,7 +2425,7 @@ SELECT * FROM test1 WHERE a;
24252425 </indexterm>
24262426
24272427 <para>
2428- <productname>PostgreSQL</> offers data types to storeIP and MAC
2428+ <productname>PostgreSQL</> offers data types to storeIPv4, IPv6, and MAC
24292429 addresses, shown in <xref linkend="datatype-net-types-table">. It
24302430 is preferable to use these types over plain text types, because
24312431 these types offer input error checking and several specialized
@@ -2446,14 +2446,14 @@ SELECT * FROM test1 WHERE a;
24462446
24472447 <row>
24482448<entry><type>cidr</type></entry>
2449- <entry>12 bytes</entry>
2450- <entry>IPv4 networks</entry>
2449+ <entry>12or 24 bytes</entry>
2450+ <entry>IPv4or IPv6 networks</entry>
24512451 </row>
24522452
24532453 <row>
24542454<entry><type>inet</type></entry>
2455- <entry>12 bytes</entry>
2456- <entry>IPv4 hosts and networks</entry>
2455+ <entry>12or 24 bytes</entry>
2456+ <entry>IPv4and IPv6 hosts and networks</entry>
24572457 </row>
24582458
24592459 <row>
@@ -2467,7 +2467,10 @@ SELECT * FROM test1 WHERE a;
24672467 </table>
24682468
24692469 <para>
2470- IPv6 is not yet supported.
2470+ When sorting <type>inet</type> or <type>cidr</type> data types,
2471+ IPv4 addresses will always sort before IPv6 addresses, including
2472+ IPv4 addresses encapsulated or mapped into IPv6 addresses, such as
2473+ ::10.2.3.4 or ::ffff::10.4.3.2.
24712474 </para>
24722475
24732476
@@ -2479,26 +2482,32 @@ SELECT * FROM test1 WHERE a;
24792482 </indexterm>
24802483
24812484 <para>
2482- The <type>inet</type> type holds anIP host address, and
2485+ The <type>inet</type> type holds anIPv4 or IPv6 host address, and
24832486 optionally the identity of the subnet it is in, all in one field.
24842487 The subnet identity is represented by stating how many bits of
24852488 the host address represent the network address (the
2486- <quote>netmask</quote>). If the netmask is 32, then the value
2487- does not indicate a subnet, only a single host. Note that if you
2489+ <quote>netmask</quote>). If the netmask is 32 and the address is IPv4,
2490+ then the value does not indicate a subnet, only a single host.
2491+ In IPv6, the address length is 128 bits, so 128 bits will specify a
2492+ unique host address. Note that if you
24882493 want to accept networks only, you should use the
24892494 <type>cidr</type> type rather than <type>inet</type>.
24902495 </para>
24912496
24922497 <para>
2493- The input format for this type is <replaceable
2494- class="parameter">x.x.x.x/y</replaceable> where <replaceable
2495- class="parameter">x.x.x.x</replaceable> is an IP address and
2496- <replaceable class="parameter">y</replaceable> is the number of
2497- bits in the netmask. If the <replaceable
2498- class="parameter">/y</replaceable> part is left off, then the
2499- netmask is 32, and the value represents just a single host.
2500- On display, the <replaceable class="parameter">/y</replaceable>
2501- portion is suppressed if the netmask is 32.
2498+ The input format for this type is
2499+ <replaceable class="parameter">address/y</replaceable>
2500+ where
2501+ <replaceable class="parameter">address</replaceable>
2502+ is an IPv4 or IPv6 address and
2503+ <replaceable class="parameter">y</replaceable>
2504+ is the number of bits in the netmask. If the
2505+ <replaceable class="parameter">/y</replaceable>
2506+ part is left off, then the
2507+ netmask is 32 for IPv4 and 128 for IPv6, and the value represents
2508+ just a single host. On display, the
2509+ <replaceable class="parameter">/y</replaceable>
2510+ portion is suppressed if the netmask specifies a single host.
25022511 </para>
25032512 </sect2>
25042513
@@ -2510,12 +2519,13 @@ SELECT * FROM test1 WHERE a;
25102519 </indexterm>
25112520
25122521 <para>
2513- The <type>cidr</type> type holds anIP network specification.
2522+ The <type>cidr</type> type holds anIPv4 or IPv6 network specification.
25142523 Input and output formats follow Classless Internet Domain Routing
25152524 conventions.
25162525 The format for specifying networks is <replaceable
2517- class="parameter">x.x.x.x/y</> where <replaceable
2518- class="parameter">x.x.x.x</> is the network and <replaceable
2526+ class="parameter">address/y</> where <replaceable
2527+ class="parameter">address</> is the network represented as an
2528+ IPv4 or IPv6 address, and <replaceable
25192529 class="parameter">y</> is the number of bits in the netmask. If
25202530 <replaceable class="parameter">y</> is omitted, it is calculated
25212531 using assumptions from the older classful network numbering system, except
@@ -2594,6 +2604,28 @@ SELECT * FROM test1 WHERE a;
25942604 <entry>10.0.0.0/8</entry>
25952605 <entry>10/8</entry>
25962606</row>
2607+ <row>
2608+ <entry>10.1.2.3/32</entry>
2609+ <entry>10.1.2.3/32</entry>
2610+ <entry>10.1.2.3/32</entry>
2611+ <row>
2612+ <entry>2001:4f8:3:ba::/64</entry>
2613+ <entry>2001:4f8:3:ba::/64</entry>
2614+ <entry>2001:4f8:3:ba::/64</entry>
2615+ </row>
2616+ <row>
2617+ <entry>2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128</entry>
2618+ <entry>2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128</entry>
2619+ <entry>2001:4f8:3:ba:2e0:81ff:fe22:d1f1</entry>
2620+ </row>
2621+ <row>
2622+ <entry>::ffff:1.2.3.0/120</entry>
2623+ <entry>::ffff:1.2.3.0/120</entry>
2624+ <entry>::ffff:1.2.3/120</entry>
2625+ <row>
2626+ <entry>::ffff:1.2.3.0/128</entry>
2627+ <entry>::ffff:1.2.3.0/128</entry>
2628+ <entry>::ffff:1.2.3.0/128</entry>
25972629 </tbody>
25982630 </tgroup>
25992631 </table>