inet type and network()

Started by Daniel J. Kressinabout 25 years ago2 messagesgeneral
Jump to latest
#1Daniel J. Kressin
dkressin@globalcrossing.com

My table contains the following rows in a column of type inet:
ip
-------------
10.24.4.0/22
10.24.4.10/22
10.24.5.0/22
10.24.5.5/22

When I do a select, the rows come up as:
ip
--------------
10.24.4/22
10.24.4.10/22
10.24.5/22
10.24.5.5/22

The .0s get dropped. Is there a way to force it to leave the .0s
attached?
--
Dan
____ Kressin ____ .-----------------------------------.
/___ \____________/ __ \ | Unix SysAdmin |
\ \ / / \ | | Global Crossing |
___/ __\/\/rench_ \__/ | | dkressin@globalcrossing.com |
\____/ \____/ | http://www.vib.org/wrench/ |
`-----------------------------------'

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Daniel J. Kressin (#1)
Re: inet type and network()

"Daniel J. Kressin" <dkressin@globalcrossing.com> writes:

The .0s get dropped. Is there a way to force it to leave the .0s
attached?

In 7.1 the default display of inet values is the way you want it.

In 7.0 I think you have to use brute force:

play=> select host('192.168.1.0/22'::inet) || '/' || masklen('192.168.1.0/22'::inet);
?column?
----------------
192.168.1.0/22
(1 row)

regards, tom lane