On Wed, Jul 11, 2012 at 12:36 PM, Valentin Davydov <sqlite-u...@soi.spb.ru> wrote: > Individual IP addresses are nicely supported in the form of unsigned > integers, and prefixes/ranges - as contiguous ranges of such integers. > For example, to determine whether given IP address belongs to a particular > subnet, one can calculate "IP between NETWORK_MIN and NETWORK_MAX", which > sqlite does quite efficiently. This is for IPv4 at least.
Using ranges instead of prefixes is fraught with peril. One has to have triggers to ensure that ranges start and end on proper boundaries, and then checking for overlap, or sorting ranges is much harder than with the bit string approach. And, as you point out, this only works for IPv4 (since v6 addresses are 128-bit but SQLite3 only has 64-bit integers). That said, it's easy to represent bit strings as BLOBs that sort properly, so perhaps all we need is a set of user-defined functions for converting between IP addresses in string form and bit strings encoded as BLOBs. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users