CIDR/INET improvements

From: Joachim Wieland <joe(at)mcknight(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: CIDR/INET improvements
Date: 2006-01-07 13:02:48
Message-ID: 20060107130248.GA2666@mcknight.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2006-01-07 17:12:08 Re: Warm-up cache may have its virtue
Previous Message Marko Kreen 2006-01-07 10:52:41 Re: [HACKERS] Inconsistent syntax in GRANT

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-01-07 17:50:23 Re: CIDR/INET improvements
Previous Message Marko Kreen 2006-01-07 10:52:41 Re: [HACKERS] Inconsistent syntax in GRANT