Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIC2a-0006ro-Es for pgsql-bugs@postgresql.org; Sun, 30 Sep 2012 05:26:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIC2X-0002gj-QJ for pgsql-bugs@postgresql.org; Sun, 30 Sep 2012 05:26:07 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q8U5Q3RT015991; Sun, 30 Sep 2012 01:26:03 -0400 (EDT) From: Tom Lane To: mr.dash.four@googlemail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses In-reply-to: References: Comments: In-reply-to mr.dash.four@googlemail.com message dated "Fri, 28 Sep 2012 22:08:30 -0000" Date: Sun, 30 Sep 2012 01:26:02 -0400 Message-ID: <15990.1348982762@sss.pgh.pa.us> X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201209/305 X-Sequence-Number: 34299 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