Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIIQH-0003qL-Ct for pgsql-bugs@postgresql.org; Sun, 30 Sep 2012 12:15:01 +0000 Received: from mail-we0-f174.google.com ([74.125.82.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIIQF-0004Vk-DG for pgsql-bugs@postgresql.org; Sun, 30 Sep 2012 12:15:00 +0000 Received: by weyt9 with SMTP id t9so2359139wey.19 for ; Sun, 30 Sep 2012 05:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=M3uhZ1kI11XvVL7AjNwupadOZFPyprTGpiax2V48eFM=; b=sFehst5WGSfBwxQWwHSCri4dGX5Q28Ae/wzwiMqrioM9GoeBeO8L9w64wCT1UYVqHJ fiEQlUdVd9yjQ4ZrXafiEnPuwVgp7zITDcEffXKoSrDV8Ue6YojkzlUU+RxGongtVFAX WWaSRcvB9cE6zRttK8sxLnZ5qkGbJO2a1EHDsU8i/1TrD6ygXP5lt2ffcvelkQ1KwQim +Yu/cwHKq22gJmpzbFkzR0mIFV6ivUu8rhfm9PWJORgWJ+1uBPX7eE5qMdRjWsAfF69x nLX8YHpk/xxikCJxIRhWnPikGHJfYXGkq9rCUQ5Zb0hHdVHlOR9R7O3q2742qiw431dB TUcg== Received: by 10.180.94.226 with SMTP id df2mr8173246wib.11.1349007297926; Sun, 30 Sep 2012 05:14:57 -0700 (PDT) Received: from [10.68.68.173] (cpc2-gill1-0-0-cust218.basl.cable.virginmedia.com. [82.34.56.219]) by mx.google.com with ESMTPS id v3sm10518138wiw.7.2012.09.30.05.14.56 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 30 Sep 2012 05:14:57 -0700 (PDT) Message-ID: <506837BC.3050305@googlemail.com> Date: Sun, 30 Sep 2012 13:14:52 +0100 From: Mr Dash Four User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses References: <15990.1348982762@sss.pgh.pa.us> In-Reply-To: <15990.1348982762@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.4 (/) X-Archive-Number: 201209/306 X-Sequence-Number: 34300 > 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. That isn't possible in my case, because on the right side I have IP ranges (from-to) and currently there isn't a PostgreSQL function which converts IP ranges to cidr/inet, but even if there was such function available, this may produce more than one cidr/inet ranges, so it won't be of much use. Employing << and friends is of no use either, as they work on inet/cidr on the right side - I can't use something like "10.1.1.0/24 << (10.1.1.0-10.1.1.255)" for example. > 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. > If BETWEEN can't handle operations between cidr/inet and IP ranges (which is what I highlighted in the initial bug report), it should either be fixed to produce the correct result or it should return an error. Leaving things as they are can't be allowed.