1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Change default output formatting for CIDR to be unabbreviated, per

recommendation from Paul Vixie.  Add a new abbrev() function to produce
abbreviated format as text.  No forced initdb, but new function is not
available unless you do an initdb or add the pg_proc row manually.
This commit is contained in:
Tom Lane
2000-12-22 18:00:24 +00:00
parent 13b78a2400
commit 61784c54b5
6 changed files with 151 additions and 91 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.44 2000/12/14 22:30:56 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.45 2000/12/22 18:00:24 tgl Exp $
-->
<chapter id="datatype">
@ -1818,7 +1818,7 @@ January 8 04:05:06 1999 PST
class="parameter">x.x.x.x</replaceable> is an IP address and
<replaceable class="parameter">y</replaceable> is the number of
bits in the netmask. If the <replaceable
class="parameter">y</replaceable> part is left off, then the
class="parameter">/y</replaceable> part is left off, then the
netmask is 32, and the value represents just a single host.
On display, the <replaceable class="parameter">/y</replaceable>
portion is suppressed if the netmask is 32.
@ -1837,7 +1837,7 @@ January 8 04:05:06 1999 PST
class="parameter">x.x.x.x/y</> where <replaceable
class="parameter">x.x.x.x</> is the network and <replaceable
class="parameter">y</> is the number of bits in the netmask. If
<replaceable class="parameter">y</> omitted, it is calculated
<replaceable class="parameter">y</> is omitted, it is calculated
using assumptions from the older classful numbering system, except
that it will be at least large enough to include all of the octets
written in the input.
@ -1848,56 +1848,68 @@ January 8 04:05:06 1999 PST
<table tocentry="1">
<title><type>cidr</> Type Input Examples</title>
<tgroup cols="2">
<tgroup cols="3">
<thead>
<row>
<entry>CIDR Input</entry>
<entry>CIDR Displayed</entry>
<entry>abbrev(CIDR)</entry>
</row>
</thead>
<tbody>
<row>
<entry>192.168.100.128/25</entry>
<entry>192.168.100.128/25</entry>
<entry>192.168.100.128/25</entry>
</row>
<row>
<entry>192.168/24</entry>
<entry>192.168.0.0/24</entry>
<entry>192.168.0/24</entry>
</row>
<row>
<entry>192.168/25</entry>
<entry>192.168.0.0/25</entry>
<entry>192.168.0.0/25</entry>
</row>
<row>
<entry>192.168.1</entry>
<entry>192.168.1.0/24</entry>
<entry>192.168.1/24</entry>
</row>
<row>
<entry>192.168</entry>
<entry>192.168.0.0/24</entry>
<entry>192.168.0/24</entry>
</row>
<row>
<entry>128.1</entry>
<entry>128.1.0.0/16</entry>
<entry>128.1/16</entry>
</row>
<row>
<entry>128</entry>
<entry>128.0.0.0/16</entry>
<entry>128.0/16</entry>
</row>
<row>
<entry>128.1.2</entry>
<entry>128.1.2.0/24</entry>
<entry>128.1.2/24</entry>
</row>
<row>
<entry>10.1.2</entry>
<entry>10.1.2.0/24</entry>
<entry>10.1.2/24</entry>
</row>
<row>
<entry>10.1</entry>
<entry>10.1.0.0/16</entry>
<entry>10.1/16</entry>
</row>
<row>
<entry>10</entry>
<entry>10.0.0.0/8</entry>
<entry>10/8</entry>
</row>
</tbody>
@ -1917,8 +1929,8 @@ January 8 04:05:06 1999 PST
<tip>
<para>
If you do not like the output format for <type>inet</type> or
<type>cidr</type> values, try the <function>host</>() and
<function>text</>() functions.
<type>cidr</type> values, try the <function>host</>(),
<function>text</>(), and <function>abbrev</>() functions.
</para>
</tip>
</para>

View File

@ -1,4 +1,4 @@
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.45 2000/12/19 17:35:46 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.46 2000/12/22 18:00:24 tgl Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
@ -2432,7 +2432,7 @@ Not defined by this name. Implements the intersection operator '#'
<entry>cidr</entry>
<entry>extract network part of address</entry>
<entry>network('192.168.1.5/24')</entry>
<entry>192.168.1/24</entry>
<entry>192.168.1.0/24</entry>
</row>
<row>
<entry>text(inet)</entry>
@ -2441,15 +2441,22 @@ Not defined by this name. Implements the intersection operator '#'
<entry>text(inet '192.168.1.5')</entry>
<entry>192.168.1.5/32</entry>
</row>
<row>
<entry>abbrev(inet)</entry>
<entry>text</entry>
<entry>extract abbreviated display as text</entry>
<entry>abbrev(cidr '10.1.0.0/16')</entry>
<entry>10.1/16</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
All of the functions for <type>inet</type> can be applied to
<type>cidr</type> values as well. The <function>host</>() and
<function>text</>() functions are primarily intended to offer
alternative display formats.
<type>cidr</type> values as well. The <function>host</>(),
<function>text</>(), and <function>abbrev</>() functions are primarily
intended to offer alternative display formats.
</para>
<para>