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
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to