Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.postgresql > #643
| From | "M. Strobel" <strobel@example.com> |
|---|---|
| Newsgroups | comp.databases.postgresql |
| Subject | Re: how to count the number of ipv6 addresses in a range? |
| Date | 2015-03-31 09:56 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <mfdjue$3it$1@dont-email.me> (permalink) |
| References | <55197d18$0$2962$426a34cc@news.free.fr> <mfcaof$bmu$1@dont-email.me> <551a4f3d$0$3031$426a34cc@news.free.fr> |
Maybe calculate the length of the netmask? There are functions for it.
/Str.
On 31.03.2015 09:39, Mateusz Viste wrote:
> Hi,
>
> You are right of course, the scale of addresses count is far wider than what I
> imagined (and I didn't take the time to do a proper calculation). Thanks for the clue :)
>
> I will have to think about an alternative method of comparing ranges - the need is
> simply to tell "this range is larger than that one", so an exact count of IP
> addresses is not necessary.
>
> cheers,
> Mateusz
>
>
>
> On 30/03/2015 22:13, M. Strobel wrote:
>> On 30.03.2015 18:43, Mateusz Viste wrote:
>>> Hello group,
>>>
>>> Today I got into troubles with an old piece of code that was working
>>> very well on an
>>> "inet" column when the column was used for IPv4 addresses, but went
>>> south with
>>> introduction of IPv6 records.
>>>
>>> Basically, it's about counting the number of IP addresses in a range:
>>>
>>> > postgres=# select 'a:b:c:dd::'::inet - 'a:b:c:dd::'::inet;
>>> > ?column?
>>> > ----------
>>> > 0
>>> > (1 row)
>>>
>>> The above works fine, but if the range becomes greater, then postgres
>>> is happy no more:
>>>
>>> postgres=# select 'a:b:c:dd::'::inet - 'a:b:c:da::'::inet;
>>> ERROR: result is out of range
>>> postgres=#
>>>
>>> Question to you guys - is there some "clean" way to deal with this? I
>>> naively tried
>>> casting the result in such way:
>>>
>>> > select ('a:b:c:dd::'::inet - 'a:b:c:da::'::inet)::NUMERIC(30);
>>>
>>> But this won't help. Any kind ideas? I'm running a Postgres 8.4
>>> cluster, but tested
>>> on a v9.3.2 with same sad results.
>>>
>>> cheers,
>>> Mateusz
>>
>> well, looking at
>>
>> 'a:b:c:dd::'::inet - 'a:b:c:da::'::inet
>>
>> let's find out the size of the difference.
>>
>> The prefix aa:b:c:dd is 32 bits long, subtract this from 128 to get a
>> remaining length of 96 bits.
>>
>> Add to this the difference 0xd - 0xa, so the result has at least 98
>> bits. This can be handled only with bignum support.
>>
>> I would raise this on a postgresql mailing list, for example
>> www.postgresql.org/list/pgsql-general/
>>
>> You can read the lists with a newsreader, for example
>> news://news.gmane.org:119/gmane.comp.db.postgresql.general
>>
>> /Str.
>
Back to comp.databases.postgresql | Previous | Next — Previous in thread | Next in thread | Find similar
how to count the number of ipv6 addresses in a range? Mateusz Viste <mateusz.viste@localhost> - 2015-03-30 18:43 +0200
Re: how to count the number of ipv6 addresses in a range? "M. Strobel" <strobel@example.com> - 2015-03-30 22:13 +0200
Re: how to count the number of ipv6 addresses in a range? "M. Strobel" <strobel@example.com> - 2015-03-31 01:25 +0200
Re: how to count the number of ipv6 addresses in a range? Mateusz Viste <mateusz.viste@localhost> - 2015-03-31 09:39 +0200
Re: how to count the number of ipv6 addresses in a range? "M. Strobel" <strobel@example.com> - 2015-03-31 09:56 +0200
Re: how to count the number of ipv6 addresses in a range? Mateusz Viste <mateusz.viste@localhost> - 2015-03-31 11:03 +0200
Re: how to count the number of ipv6 addresses in a range? Ralf Döblitz <doeblitz@doeblitz.net> - 2015-04-02 16:48 +0000
Re: how to count the number of ipv6 addresses in a range? Mateusz Viste <mateusz.viste@localhost> - 2015-04-03 09:09 +0200
Re: how to count the number of ipv6 addresses in a range? Ralf Döblitz <doeblitz@doeblitz.net> - 2015-04-03 13:17 +0000
csiph-web