Re: BUG #7575: "between" does not work properly with inet/cidr addresses

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mr(dot)dash(dot)four(at)googlemail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses
Date: 2012-09-30 05:26:02
Message-ID: 15990.1348982762@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

mr(dot)dash(dot)four(at)googlemail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mr Dash Four 2012-09-30 12:14:52 Re: BUG #7575: "between" does not work properly with inet/cidr addresses
Previous Message mr.dash.four 2012-09-28 22:08:30 BUG #7575: "between" does not work properly with inet/cidr addresses