Thread: inet type and network()

inet type and network()

From
"Daniel J. Kressin"
Date:
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/        |
                          `-----------------------------------'

Re: inet type and network()

From
Tom Lane
Date:
"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