CIDR/INET improvements - Mailing list pgsql-hackers

From Joachim Wieland
Subject CIDR/INET improvements
Date
Msg-id 20060107130248.GA2666@mcknight.de
Whole thread Raw
Responses Re: CIDR/INET improvements
List pgsql-hackers
The TODO list contains some items concerning the CIDR/INET datatype.

* %Prevent INET cast to CIDR if the unmasked bits are not zero, or zero the bits

I added a function for this cast (which zeroes the bits) but then the
opr_sanity regression test failed because there is a cast from INET -> CIDR
but the other way round is considered to be binary compatible.

Actually both types are not binary compatible, since they have a
type component that is either 0 or 1, depending on whether it is of type
INET or CIDR.

If nobody objects, I'll send in a patch that includes a cast function for
the other way round as well.



* Allow INET + INT4 to increment the host part of the address, or throw an error on overflow

Once at it I wonder how much arithmetic these types need?
What about functions to get/set a specific byte, for example:

inet_get_byte('192.168.1.1'::inet, 0) returns 1
inet_get_byte('192.168.1.1'::inet, 1) returns 1
inet_get_byte('192.168.1.1'::inet, 2) returns 168
inet_get_byte('192.168.1.1'::inet, 3) returns 192

and inet_set_byte('192.168.1.1'::inet, 3, 128) returns '128.168.1.1'


Which other functions have been missing here in the past?


Joachim



pgsql-hackers by date:

Previous
From: Qingqing Zhou
Date:
Subject: Re: Warm-up cache may have its virtue
Next
From: Greg Stark
Date:
Subject: Re: Warm-up cache may have its virtue