Re: INET/CIDR types

From: Larry Rosenman <ler(at)lerctr(dot)org>
To: Alex Pilosov <alex(at)pilosoft(dot)com>
Cc: Larry Rosenman <ler(at)lerctr(dot)org>, Sevo Stille <sevo(at)ip23(dot)net>, pgsql-hackers(at)hub(dot)org
Subject: Re: INET/CIDR types
Date: 2000-07-25 03:10:01
Message-ID: 200007250310.e6P3A1v13825@lerami.lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The bad news is it doesn't work now...

ler=# select host(netblock::int8::inet) from networks;
ERROR: Cannot cast type 'cidr' to 'int8'
ler=# \d networks
Table "networks"
Attribute | Type | Modifier
---------------+--------------+----------
netblock | cidr |
router | integer |
interface | varchar(64) |
dest_ip | inet |
net_name | varchar(64) |
owner | integer |
origin | varchar(256) |
assigned_date | date |
assigned_by | varchar(64) |
asn | smallint |

ler=#

> On Mon, 24 Jul 2000, Larry Rosenman wrote:
>
> > > This whole discussion is quite silly guys.
> > >
> > > It is quite reasonable to have ability to split CIDR net into two pieces:
> > > the network and the bitshift. Second one is already possible, the first
> > > one can be accomplished by having functions to convert a cidr/inet to int8
> > > (not int4 because of sign thing), and back.
> > >
> > > Its also very easy to implement ;)
> > >
> > > This will actually come very useful for many applications. Something I'm
> > > working on now (allocation of 'most appropriate' block) requires ability
> > > to split a netblock into two, which could be most easily accomplished
> > > using int8 math. (net::int8+2^(netmask(net)-1)).
> > All I'm looking for is to be able to print all 4 octets of an IP address
> > out so that joe user can take the 4 numbers and type it into the
> > 4 boxes on a Windows 98 box, and use them.
> >
> > Is that really that abhorrent?
> >
> > They also need the 4 octet netmask which I can get now.
> >
> > All we are missing is a way to print ALL 4 NUMBERS ALL THE TIME
> > for the output. It's not asking for classful, and for sure
> > we use CIDR all over the place, but for the final output that my
> > users see, why can't I have the database just print all 4 octets?
>
> Larry,
> With my suggestion, you can do it as follows:
>
> net::int8::inet
>
> (net being of cidr type)
> -alex
>

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alex Pilosov 2000-07-25 03:25:41 Re: INET/CIDR types
Previous Message Trond Eivind=?iso-8859-1?q?_Glomsr=F8d?= 2000-07-25 02:54:12 Re: State of RPMs