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. Maybe, it is good idea, to implement such functions separatelly as /contrib ... for a start ... Live example for inet_inc() (as "+" operator) (PL/pgSQL) > -- (try to) Peek address from group pool > SELECT next INTO next_ip FROM peer_ranges WHERE > group_id = (SELECT id FROM peer_groups WHERE name = $3) AND > next < last > ORDER BY first LIMIT 1; > > -- Return NULL if pool is empty > IF NOT FOUND THEN > RAISE NOTICE ''Group address pool is empty''; > RETURN NULL; > END IF; > > -- Update pool > UPDATE peer_ranges SET next = next_ip + 1 WHERE next = next_ip; > > RETURN next_ip; where, peer_ranges is: CREATE TABLE peer_ranges ( group_id bigint NOT NULL REFERENCES peer_groups (id), first inet NOT NULL UNIQUE, next inet NOT NULL UNIQUE, last inet NOT NULL UNIQUE ); Thank you, Ilya A. Kovalenko (mailto:[EMAIL PROTECTED]) ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])