dbTalk Databases Forums  

[BUGS] inet subtraction fails with IPv6?

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] inet subtraction fails with IPv6? in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jon Nelson
 
Posts: n/a

Default [BUGS] inet subtraction fails with IPv6? - 01-31-2012 , 09:38 AM






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

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #2  
Old   
Robert Haas
 
Posts: n/a

Default Re: [BUGS] inet subtraction fails with IPv6? - 01-31-2012 , 02:03 PM






On Tue, Jan 31, 2012 at 10:38 AM, Jon Nelson <jnelson+pgsql (AT) jamponi (DOT) net> wrote:
Quote:
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

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #3  
Old   
Jon Nelson
 
Posts: n/a

Default Re: [BUGS] inet subtraction fails with IPv6? - 01-31-2012 , 02:07 PM



On Tue, Jan 31, 2012 at 2:03 PM, Robert Haas <robertmhaas (AT) gmail (DOT) com> wrote:
Quote:
On Tue, Jan 31, 2012 at 10:38 AM, Jon Nelson <jnelson+pgsql (AT) jamponi (DOT) 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 negativeIP 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

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
  #4  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] inet subtraction fails with IPv6? - 01-31-2012 , 03:37 PM



Jon Nelson <jnelson+pgsql (AT) jamponi (DOT) net> writes:
Quote:
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

--
Sent via pgsql-bugs mailing list (pgsql-bugs (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.