[HACKERS] operator suggest " interval / interval = numeric"

2008-01-09 Thread Ilya A. Kovalenko
I suggest one more standard date/time operator, to divide one interval by another with numeric (or float, for example) result. I.e. something like that: database=# SELECT '5400 seconds'::interval / '1 hour'::interval; ?column? -- 1.5 (1 row

[HACKERS] inet increment w/ int8

2005-04-17 Thread Ilya A. Kovalenko
htobe64(betoh64(*((int64*)(ip_addr(dst - 1); } } // Return result VARATT_SIZEP(dst) = VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + ip_addrsize(dst); PG_RETURN_INET_P(dst); } -

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

Re: [HACKERS] inet increment w/ int8

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

Re: [HACKERS] inet increment w/ int8

2005-04-19 Thread Ilya A. Kovalenko
URNS int2 FUNCTION extract_dword(inet, integer) RETURNS int4 FUNCTION extract_qword(inet, integer) RETURNS int8 -- FUNCTION replace_octet(inet, integer, integer) RETURNS inet FUNCTION replace_word (inet, integer, int2)RETURNS inet FUNCTION replace_dword(inet, integer, int4)

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 -