X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 712BE5351F for ; Mon, 9 May 2005 08:07:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95708-05 for ; Mon, 9 May 2005 11:06:55 +0000 (GMT) Received: from mail.cosmoline.gr (mail.cosmoline.gr [217.69.10.77]) by svr1.postgresql.org (Postfix) with ESMTP id 2199A5351E for ; Mon, 9 May 2005 08:06:53 -0300 (ADT) Received: from mailhub.cosmoline.gr (mailhub-c.cosmoline.gr [217.69.0.250]) by mail.cosmoline.gr (8.12.3/8.12.3/COSMOLINE) with ESMTP id j49B7EfE030795 for ; Mon, 9 May 2005 14:07:15 +0300 Received: from cosmoline.com ([192.168.198.171]) (authenticated bits=0) by mailhub.cosmoline.gr (8.12.3/8.12.3/COSMOLINE) with ESMTP id j49B4pjo028431 for ; Mon, 9 May 2005 14:04:54 +0300 Message-ID: <427F4446.8030808@cosmoline.com> Date: Mon, 09 May 2005 14:06:46 +0300 From: Vasilis Ventirozos User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: thats funny :) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/85 X-Sequence-Number: 17514 hi all i created a function that restarts the server, i will show you what i am doing drop trigger lala_trig on favorites; drop function fav_funct() cascade; create or replace function fav_funct() returns trigger AS ' declare old_id int default 0; new_id int default 0; rec record; rec2 record; rec3 record; BEGIN select into rec max(id) as max_id from favorites ; IF rec.max_id IS NULL THEN new_id :=1; ELSE new_id = rec.max_id; END IF; select into rec2 max(id) as cnt from favorites where id = (select max(id) from favorites); select into rec3 count(*) as call_cat from call_cat ; IF rec2.cnt < rec3.call_cat THEN new_id := rec.max_id; ELSE new_id := rec.max_id +1; END IF; insert into favorites (id) values (new_id); RETURN NEW; END; ' LANGUAGE 'plpgsql'; create trigger lala_trig before insert on favorites for each row execute procedure fav_funct(); insert into favorites (call_cat_id,details) values (1,'1'); --------------------------- NOTE --------------------------- I know this function sux but i am currently developing :) ---------------------------------------------------------------- test=# insert into favorites (call_cat_id,details) values (1,'1'); server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. !> \q postgres@statistics:~$ psql -l psql: FATAL: the database system is starting up --------- AFTER A WHILE --------- postgres@statistics:~$ psql -l List of databases Name | Owner | Encoding -----------------+----------+------------ my_tests | postgres | ISO_8859_7 template0 | postgres | ISO_8859_7 template1 | postgres | ISO_8859_7 test | postgres | ISO_8859_7 ps the psql version is: postgres@statistics:~$ psql -V psql (PostgreSQL) 7.4