Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id CA00ED45792 for ; Tue, 31 Jan 2012 17:37:24 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RsLOG-0006Zh-SB for pgsql-bugs@postgresql.org; Tue, 31 Jan 2012 21:37:25 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q0VLbBii011083; Tue, 31 Jan 2012 16:37:11 -0500 (EST) To: Jon Nelson cc: pgsql-bugs@postgresql.org Subject: Re: inet subtraction fails with IPv6? In-reply-to: References: Comments: In-reply-to Jon Nelson message dated "Tue, 31 Jan 2012 14:07:59 -0600" Date: Tue, 31 Jan 2012 16:37:11 -0500 Message-ID: <11082.1328045831@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/276 X-Sequence-Number: 32343 Jon Nelson writes: > On Tue, Jan 31, 2012 at 2:03 PM, Robert Haas wrote: >> What were you expecting to get? There's no such thing as a negative IP address. > True, but it works for IPv4: > jnelson=# select inet '255.255.255.255' - inet '0/0'; > ?column? > ------------ > 4294967295 > (1 row) The inet minus inet operator is defined to yield bigint, so it only copes for addresses within 2^63 of each other. Short of inventing an integer type at least 129 bits wide, the only way we could fix this is to make the operator return numeric instead, which doesn't really seem like an improvement for typical use-cases. I'm fairly sure this was debated when the operator was added, and we thought it was an acceptable limitation; though maybe with IPv6 finally starting to see real usage it's going to seem less so. regards, tom lane