Re: Summary: what to do about INET/CIDR - Mailing list pgsql-hackers

From Alex Pilosov
Subject Re: Summary: what to do about INET/CIDR
Date
Msg-id Pine.BSO.4.10.10010272255510.2291-100000@spider.pilosoft.com
Whole thread Raw
In response to Summary: what to do about INET/CIDR  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, 27 Oct 2000, Tom Lane wrote:

> A more interesting question is whether the system needs to provide any
> assisting functions that aren't there now.  The lookup function you guys
> are postulating seems like it would be (in the simple cases)
>     create function my_network(inet) returns cidr as
>     'select network from my_networks where ???'
as in my mail:
select network from my_network where network>>$1 order by
network_prefix(network) desc limit 1;

(i.e. if many networks cover the ip address, pick the one with longest
prefix). The only hard question here, how to properly index this table.
This sounds like a perfect application of user-defined index method. 
I need to look up documentation on how they work...


However, this probably won't pose a major problem in production: the
networks table will be relatively small. 

> Maybe it's too late at night, but I'm having a hard time visualizing
> what the ??? condition is and whether any additional system-level
> functions are needed to make it simple/efficient.

Actually, you can scratch my proposal. I realise it could be inconvenient
for some people.

I'll be probably putting all my hosts as inet::xxx/32, have the above
lookup function to get real network, and do operations on that.





pgsql-hackers by date:

Previous
From: Alex Pilosov
Date:
Subject: Re: Re: [GENERAL] A rare error
Next
From: Tom Lane
Date:
Subject: Re: Summary: what to do about INET/CIDR