Re: [HACKERS] inet increment w/ int8

2005-05-23 Thread Sander Steffann
Hi, > I modified the TODO. I think we only need an INT4. I realize INT8 > would be for IPV6 but I can't imagine a network that has more than INT4 > hosts (not part of the network address). Actually "increment the host address" isn't a well-defined concept for IPV6. The "host" part of the add

Re: [HACKERS] inet increment w/ int8

2005-05-23 Thread Stephen Frost
* Bruce Momjian (pgman@candle.pha.pa.us) wrote: > Douglas McNaught wrote: > > Bruce Momjian writes: > > > > > I modified the TODO. I think we only need an INT4. I realize INT8 > > > would be for IPV6 but I can't imagine a network that has more than INT4 > > > hosts (not part of the network addr

Re: [HACKERS] inet increment w/ int8

2005-05-23 Thread Bruce Momjian
Douglas McNaught wrote: > Bruce Momjian writes: > > > I modified the TODO. I think we only need an INT4. I realize INT8 > > would be for IPV6 but I can't imagine a network that has more than INT4 > > hosts (not part of the network address). > > Actually "increment the host address" isn't a wel

Re: [HACKERS] inet increment w/ int8

2005-05-23 Thread Douglas McNaught
Bruce Momjian writes: > I modified the TODO. I think we only need an INT4. I realize INT8 > would be for IPV6 but I can't imagine a network that has more than INT4 > hosts (not part of the network address). Actually "increment the host address" isn't a well-defined concept for IPV6. The "host

Re: [HACKERS] inet increment w/ int8

2005-05-21 Thread Bruce Momjian
Patrick Welche wrote: > On Fri, May 20, 2005 at 11:12:54PM -0400, Bruce Momjian wrote: > > Added to TODO: > > > > * Allow INET + INT4/INT8 to increment the host part of the address, or > > throw an error on overflow > > > > I have not heard any use-case for adding to the network value i

Re: [HACKERS] inet increment w/ int8

2005-04-20 Thread Bruno Wolff III
On Wed, Apr 20, 2005 at 12:30:08 +0800, "Ilya A. Kovalenko" <[EMAIL PROTECTED]> wrote: > GS> I see a use case for of generating addresses based on a sequence or some > GS> primary key from the database. > > GS> Something like > > GS> CREATE SEQUENCE hosts_ip_seq MAXVALUE 65536; > GS> ALTER TABL

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Ilya A. Kovalenko
GS> I see a use case for of generating addresses based on a sequence or some GS> primary key from the database. GS> Something like GS> CREATE SEQUENCE hosts_ip_seq MAXVALUE 65536; GS> ALTER TABLE hosts ALTER ip SET DEFAULT '10.0.0.0/16'::inet + nextval(hosts_ip_seq') hmm, not quite good idea -

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Ilya A. Kovalenko
BM> Greg Stark wrote: >> >> Bruce Momjian writes: >> >> > am thinking we should support only inet + inet, like this: >> > >> >SELECT '1.2.3.4'::inet + '0.0.1.2'::inet; >> >> I don't think inet+inet makes any sense. >> >> I think inet+int4 should work by adding to the host address and over

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Bruno Wolff III
On Tue, Apr 19, 2005 at 12:03:27 -0400, Bruce Momjian wrote: > > 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

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Greg Stark
Bruce Momjian writes: > > Ie, > > > > 10.0.0.0/24 + 1 = 10.0.0.1/24 > > 10.0.0.255/24 + 1 => overflow > > > > Or > > > > 10.1/16 + 1 = 10.1.0.1/16 > > 10.1/16 + 16384 = 10.1.64.0/16 > > 10.1/16 + 65536 => overflow > > So, do not overflow? You mean not doing modulus arithemtic? Ye

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Bruce Momjian
Greg Stark wrote: > > Bruce Momjian writes: > > > am thinking we should support only inet + inet, like this: > > > > SELECT '1.2.3.4'::inet + '0.0.1.2'::inet; > > I don't think inet+inet makes any sense. > > I think inet+int4 should work by adding to the host address and overflowing if >

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Greg Stark
Bruce Momjian writes: > am thinking we should support only inet + inet, like this: > > SELECT '1.2.3.4'::inet + '0.0.1.2'::inet; I don't think inet+inet makes any sense. I think inet+int4 should work by adding to the host address and overflowing if it exceeds the network mask. Ie, 10

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Bruce Momjian
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 compa

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Patrick Welche
On Mon, Apr 18, 2005 at 08:58:01PM -0400, Bruce Momjian wrote: > > Would you modify this so it can go in /contrib or pgfoundry? Is there > general interest for this? I was about to sit down and write the same function yesterday, when as if by magic this appeared. In my case it is to loop over ip

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Ilya A. Kovalenko
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

Re: [HACKERS] inet increment w/ int8

2005-04-18 Thread Bruce Momjian
Would you modify this so it can go in /contrib or pgfoundry? Is there general interest for this? --- Ilya A. Kovalenko wrote: >Greetings, > > I suggest function for "inet" increment w/ int8 (signed). > > FUNCTION in

Re: [HACKERS] inet increment w/ int8

2005-04-17 Thread Ilya A. Kovalenko
oops - FUNCTION inet_inc(int, int8) RETURNS inet + FUNCTION inet_inc(inet, int8) RETURNS inet ---(end of broadcast)--- TIP 8: explain analyze is your friend

[HACKERS] inet increment w/ int8

2005-04-17 Thread Ilya A. Kovalenko
Greetings, I suggest function for "inet" increment w/ int8 (signed). FUNCTION inet_inc(int, int8) RETURNS inet Function, useful for making address pools (using also existing "inet" compare functions to trap boundaries). Notes: This version lets address wrap around 0-*ff boundary. Uses