Re: inet subtraction fails with IPv6?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: inet subtraction fails with IPv6?
Date: 2012-01-31 21:37:11
Message-ID: 11082.1328045831@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jon Nelson <jnelson+pgsql(at)jamponi(dot)net> writes:
> On Tue, Jan 31, 2012 at 2:03 PM, Robert Haas <robertmhaas(at)gmail(dot)com> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message chester c young 2012-02-01 00:42:10 Fw: Re: pg_dump not correctly saving schema with partitioned tables?
Previous Message Tom Lane 2012-01-31 21:25:29 Re: BUG #6200: standby bad memory allocations on SELECT