Re: contrib/xinetops for 8.1 "patch"

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Stephen R(dot) van den Berg" <srb(at)cuci(dot)nl>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: contrib/xinetops for 8.1 "patch"
Date: 2006-02-09 20:39:29
Message-ID: 200602092039.k19KdTq23963@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Stephen R. van den Berg wrote:
> I've been meaning to send it in for a while now, IMHO it could be
> made part of the main distribution as well, but contrib is fine
> if not everyone likes it.
>
> I included the source in patch-format, since I didn't feel comfortable
> attaching a tar.gz file on this list.
> Below is an excerpt from the included README:
> -------------------------------- cut here ---------------------------------
> inet extended operations
> ~~~~~~~~~~~~~~~~~~~~~~~~
>
> This directory contains definitions for extended operators on the
> inet data type.
>
> Operators available are:
>
> ~ & | + -
>
> It supports the "natural" arithmetic with IP addresses and integers.
> It is useful for applications which have to hand out and administer
> ranges of IP-addresses (like a Radius or DHCP server).

I have modified your original patch to add the code into the main
backend routines. I added documentation and regression tests as well.

I created only inet functions because family() works on both inet and
cidr, so I assume we are to create just inet versions and cidr will
still work.

Patch needs a catalog version bump.

One unusual issue is because 'inet - inet' returns an int32, you can't
subtract two IPv6 addresses that differ by more than int32.

A larger problem is this:

test=> SELECT '255.255.255.0'::inet - '1.1.1.1'::inet;
?column?
-----------
-16843265
(1 row)

Should subtraction return int8? Perhaps it is OK because:

test=> select '255.255.255.0'::inet - (-16843265);
?column?
----------
1.1.1.1
(1 row)

We don't have an unsigned data type. Of course we also have this
excitement:

test=> SELECT '255.255.255.0'::inet + 1000000;
?column?
------------
0.15.65.64
(1 row)

so we underflow and overflow cleanly. Not great, but it works.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 14.5 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-02-09 20:51:54 Re: In pg_dump "no owner" mode don't dump owner names in comments
Previous Message Stephen Frost 2006-02-09 19:08:18 Re: [HACKERS] Krb5 & multiple DB connections