Is there a constraint or some other PostgreSQL feature that prevents CIDR columns from having values that overlap?
For example:
192.168.1.0/24
and 192.168.1.1/32
These could not exist together because 192.168.1.1/32
is contained in the 192.168.1.0/24
subnet.
Yes, that is easily done with an exclusion constraint.
The exclusion constraint will cause an error whenever you try to insert two rows where the values for
net
overlap (&&
is the "overlaps" operator).