Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E3A65B5DBC1 for ; Fri, 19 Aug 2011 20:18:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 95216-04 for ; Fri, 19 Aug 2011 23:18:02 +0000 (UTC) X-Greylist: delayed 00:53:25.355384 by SQLgrey-1.7.6 Received: from mail.dhs-club.com (mail.dhs-club.com [208.69.229.2]) by mail.postgresql.org (Postfix) with ESMTP id 58E1BB5D803 for ; Fri, 19 Aug 2011 20:18:02 -0300 (ADT) Received: from [192.168.0.11] (hq.clubshop.com [208.78.129.189]) (authenticated bits=0) by mail.dhs-club.com (8.13.1/8.13.1) with ESMTP id p7JMOZap010720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 19 Aug 2011 18:24:35 -0400 Message-ID: <4E4EE29F.2070209@dhs-club.com> Date: Fri, 19 Aug 2011 18:24:31 -0400 From: Bill MacArthur User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: compare integer to inet Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 208.69.229.2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.067 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.167 X-Spam-Level: X-Archive-Number: 201108/187 X-Sequence-Number: 38174 Greetings, Considering that this can be done: network=# SELECT '0.0.0.0'::inet + 702545920; ?column? ------------ 41.224.0.0 (1 row) How can I perform an operation similar to this that works? network=# select case when '41.224.0.0'::inet = 702545920 then true else false end; ERROR: operator does not exist: inet = integer LINE 1: select case when '41.224.0.0'::inet = 702545920 then true el... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. network=# select case when '41.224.0.0'::inet = 702545920::inet then true else false end; ERROR: cannot cast type integer to inet LINE 1: select case when '41.224.0.0'::inet = 702545920::inet then t... I'm guessing that there is some internal postgres function that performs the integer to IP address conversion in the first example, but I am at a loss to identify it. The reason I ask for this is that we have a dataset that contains ranges of IP addresses, associated with countries, where the addresses are represented as integers (bigints). Thanks for the pointer. Bill MacArthur