Re: INET/CIDR types - Mailing list pgsql-hackers

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Re: INET/CIDR types
Date
Msg-id m13GjIB-000AXgC@druid.net
Whole thread Raw
In response to INET/CIDR types  (Larry Rosenman <ler@lerctr.org>)
Responses Re: INET/CIDR types  (Larry Rosenman <ler@lerctr.org>)
List pgsql-hackers
Thus spake Larry Rosenman
> I noticed a discussion on this list about a re-do of the INET/CIDR
> types.   I was wondering if there was ANY way at all to add
> an output function that ALWAYS returns all 4 octets of an INET or CIDR
> type with and without the /netmask?
> 
> I'm writing a IP Allocation/Tracking app for the ISP I work for, and
> find the current output format causes confusion for the less
> technical types. 

The host() function does this for the INET type.  It doesn't work for
the CIDR type (it throws an error) because CIDR doesn't have a host
part per se.

darcy=> select '1.2.0.0/23'::inet;
?column?
--------
1.2.0/23
(1 row)

darcy=> select host('1.2.0.0/23'::inet);  host
-------
1.2.0.0
(1 row)

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-hackers by date:

Previous
From: Zeugswetter Andreas SB
Date:
Subject: AW: libpgtcl on aix
Next
From: Larry Rosenman
Date:
Subject: Re: INET/CIDR types