BTW, for the inet data type, I considered simply calling the "minus"
function, but that does not work because of this strange behavior:
int4=# select '10.1.1.102/32'::inet > '10.1.1.142/24'::inet;
?column?
----------
t
(1 row)
int4=# select '10.1.1.102/32'::inet - '10.1.1.142/24'::inet;
?column?
----------
-40
(1 row)
That is, (a>b) but then (a-b) < 0. AFAICS it's due to comparator
considering the mask, while the minus ignores it. I find it a bit
strange, but I assume it's intentional.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company