Re: inet increment w/ int8

From: Bruce Momjian
Subject: Re: inet increment w/ int8
Date: ,
Msg-id: 200504191603.j3JG3Rk19696@candle.pha.pa.us
(view: Whole thread, Raw)
In response to: Re: inet increment w/ int8  ("Ilya A. Kovalenko")
Responses: Re: inet increment w/ int8  (Greg Stark)
Re: inet increment w/ int8  (Bruno Wolff III)
List: pgsql-hackers

Tree view

inet increment w/ int8  ("Ilya A. Kovalenko", )
 Re: inet increment w/ int8  ("Ilya A. Kovalenko", )
 Re: inet increment w/ int8  (Bruce Momjian, )
  Re: inet increment w/ int8  ("Ilya A. Kovalenko", )
   Re: inet increment w/ int8  (Bruce Momjian, )
    Re: inet increment w/ int8  (Greg Stark, )
     Re: inet increment w/ int8  (Bruce Momjian, )
      Re: inet increment w/ int8  (Greg Stark, )
       Re: inet increment w/ int8  ("Ilya A. Kovalenko", )
        Re: inet increment w/ int8  (Bruno Wolff III, )
      Re: inet increment w/ int8  ("Ilya A. Kovalenko", )
    Re: inet increment w/ int8  (Bruno Wolff III, )
  Re: inet increment w/ int8  (Patrick Welche, )
 Re: inet increment w/ int8  (Bruce Momjian, )
  Re: inet increment w/ int8  (Douglas McNaught, )
   Re: inet increment w/ int8  (Bruce Momjian, )
    Re: inet increment w/ int8  (Stephen Frost, )
    Re: inet increment w/ int8  ("Sander Steffann", )

Ilya A. Kovalenko wrote:
> BM> Would you modify this so it can go in /contrib or pgfoundry?  Is there
> BM> general interest for this?
> 
>   Actually, I suggested to do such or similar function as internal.
> PostgreSQL has inet/cidr - excellent data type and good facilities to
> examine and compare inet values, but has no facilities to modify
> them (i.e. get-change-return operations).
> 
>   There is place for many useful operators and functions to do but
> they not invented enough yet (to supplement with existing facilites
> and each other).
> 
>    Only facility that has no doubt is increment/decrement inet
> address value with numeric value. It nicely supplements existing
> inet compare operators (that compares two addresses as numeric
> values). Also, it can be used to override "+" and "-" operators
> between inet and numeric values.
> 
>   I understand, that you have more important things to do, so I write
> this function, to save your time.

Agreed.  Let's implement '+/-' for 'inet + int4' and put it in the
backend as standard (I can help do the system table stuff if you give me
the C functions).  However, how do we handle cases where int4 > 255.  I
am thinking we should support only inet + inet, like this:
SELECT '1.2.3.4'::inet + '0.0.1.2'::inet;

But how do we do:
SELECT '1.2.3.255'::inet + '0.0.0.1'::inet;

I assume this becomes '1.2.4.0'.  Inet +/- inet seems the most flexible
because it allows you to add to any part of the mask, rather than just
the lower-order bytes, or trying to make sense that 256 adds like
'0.0.1.0'.

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



pgsql-hackers by date:

From: "Victor Y. Yegorov"
Date:
Subject: Re: Comparing Datum's at aminsert() stage
From: Bruno Wolff III
Date:
Subject: Re: inet increment w/ int8