pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedinet subtraction fails with IPv6?
4+ messages / 3 participants
[nested] [flat]
* inet subtraction fails with IPv6?
@ 2012-01-31 15:38 Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 20:03 ` Re: inet subtraction fails with IPv6? Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Jon Nelson @ 2012-01-31 15:38 UTC (permalink / raw)
To: pgsql-bugs
Example (using one of google's IPv6 addrs):
jnelson=# select inet '0::0' - inet '2001:4860:4006:800::1011';
ERROR: result is out of range
jnelson=#
--
Jon
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: inet subtraction fails with IPv6?
2012-01-31 15:38 inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
@ 2012-01-31 20:03 ` Robert Haas <robertmhaas@gmail.com>
2012-01-31 20:07 ` Re: inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
0 siblings, 1 reply; 4+ messages in thread
From: Robert Haas @ 2012-01-31 20:03 UTC (permalink / raw)
To: Jon Nelson <jnelson+pgsql@jamponi.net>; +Cc: pgsql-bugs
On Tue, Jan 31, 2012 at 10:38 AM, Jon Nelson <jnelson+pgsql@jamponi.net> wrote:
> Example (using one of google's IPv6 addrs):
>
> jnelson=# select inet '0::0' - inet '2001:4860:4006:800::1011';
> ERROR: result is out of range
> jnelson=#
What were you expecting to get? There's no such thing as a negative IP address.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: inet subtraction fails with IPv6?
2012-01-31 15:38 inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 20:03 ` Re: inet subtraction fails with IPv6? Robert Haas <robertmhaas@gmail.com>
@ 2012-01-31 20:07 ` Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 21:37 ` Re: inet subtraction fails with IPv6? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Jon Nelson @ 2012-01-31 20:07 UTC (permalink / raw)
To: ; +Cc: pgsql-bugs
On Tue, Jan 31, 2012 at 2:03 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Tue, Jan 31, 2012 at 10:38 AM, Jon Nelson <jnelson+pgsql@jamponi.net> wrote:
>> Example (using one of google's IPv6 addrs):
>>
>> jnelson=# select inet '0::0' - inet '2001:4860:4006:800::1011';
>> ERROR: result is out of range
>> jnelson=#
>
> 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)
Time: 0.417 ms
jnelson=# select inet '0/0' - inet '255.255.255.255';
?column?
-------------
-4294967295
(1 row)
Time: 0.166 ms
jnelson=#
If it makes you happy, reverse the arguments and try it again.
--
Jon
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: inet subtraction fails with IPv6?
2012-01-31 15:38 inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 20:03 ` Re: inet subtraction fails with IPv6? Robert Haas <robertmhaas@gmail.com>
2012-01-31 20:07 ` Re: inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
@ 2012-01-31 21:37 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2012-01-31 21:37 UTC (permalink / raw)
To: Jon Nelson <jnelson+pgsql@jamponi.net>; +Cc: pgsql-bugs
Jon Nelson <jnelson+pgsql@jamponi.net> writes:
> On Tue, Jan 31, 2012 at 2:03 PM, Robert Haas <robertmhaas@gmail.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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2012-01-31 21:37 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-01-31 15:38 inet subtraction fails with IPv6? Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 20:03 ` Robert Haas <robertmhaas@gmail.com>
2012-01-31 20:07 ` Jon Nelson <jnelson+pgsql@jamponi.net>
2012-01-31 21:37 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox