Re: BUG #7575: "between" does not work properly with inet/cidr addresses - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #7575: "between" does not work properly with inet/cidr addresses
Date
Msg-id 15990.1348982762@sss.pgh.pa.us
Whole thread Raw
In response to BUG #7575: "between" does not work properly with inet/cidr addresses  (mr.dash.four@googlemail.com)
Responses Re: BUG #7575: "between" does not work properly with inet/cidr addresses  (Mr Dash Four <mr.dash.four@googlemail.com>)
List pgsql-bugs
mr.dash.four@googlemail.com writes:
> 1. select '10.1.1.0/24'::inet between '10.1.1.0'::inet and
> '10.1.1.255'::inet gives me FALSE.

> Am I missing something obvious?

10.1.1.0/24 is different from, and sorts before, 10.1.1.0/32
(which is what '10.1.1.0'::inet is an abbreviation for).

You might find that the net address inclusion operators (<< and friends)
provide the semantics you're looking for.  BETWEEN only knows about
btree sort ordering, which is fundamentally a brick or two shy of a
load when considering two-dimensional quantities such as netmasks.

            regards, tom lane

pgsql-bugs by date:

Previous
From: mr.dash.four@googlemail.com
Date:
Subject: BUG #7575: "between" does not work properly with inet/cidr addresses
Next
From: Mr Dash Four
Date:
Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses