Re: INET/CIDR types - Mailing list pgsql-hackers
From | Alex Pilosov |
---|---|
Subject | Re: INET/CIDR types |
Date | |
Msg-id | Pine.BSO.4.10.10007242314200.4362-100000@spider.pilosoft.com Whole thread Raw |
In response to | Re: INET/CIDR types (Larry Rosenman <ler@lerctr.org>) |
List | pgsql-hackers |
Yes, I know. I didn't say it existed, I proposed to create a simple conversion function that would do that, which is why I asked for a patch. I'd do it myself but it'll take some time. Should be really simple, something to the effect of return a.s_addr (where a is struct in_addr), however, I'm not sure what's POSIXly correct way to do that. On Mon, 24 Jul 2000, Larry Rosenman wrote: > 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 > > > > >
pgsql-hackers by date: