Unix Technical Forum

thats funny :)

This is a discussion on thats funny :) within the pgsql Admins forums, part of the PostgreSQL category; --> hi all i created a function that restarts the server, i will show you what i am doing drop ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 01:48 AM
Vasilis Ventirozos
 
Posts: n/a
Default thats funny :)

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


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 01:48 AM
Michael Fuhr
 
Posts: n/a
Default Re: thats funny :)

[Please use a descriptive subject -- "thats funny " conveys no
information about the problem, and it resembles subjects seen on
some viruses.]

On Mon, May 09, 2005 at 02:06:46PM +0300, Vasilis Ventirozos wrote:
>
> hi all i created a function that restarts the server, i will show you
> what i am doing


The trigger function you posted is called whenever you insert a
record into the favorites table, then the function inserts a record
into favorites, which calls the trigger, which inserts a record,
which calls the trigger, etc. Infinite recursion.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 01:48 AM
Vasilis Ventirozos
 
Posts: n/a
Default Re: thats funny :)

i know what the trigger does, i writed it
i dont have a problem , i already fixed the function to work nice and smooth
i just sent it for fun, anyway no problem about the subject

>[Please use a descriptive subject -- "thats funny " conveys no
>information about the problem, and it resembles subjects seen on
>some viruses.]
>
>On Mon, May 09, 2005 at 02:06:46PM +0300, Vasilis Ventirozos wrote:
>
>
>>hi all i created a function that restarts the server, i will show you
>>what i am doing
>>
>>

>
>The trigger function you posted is called whenever you insert a
>record into the favorites table, then the function inserts a record
>into favorites, which calls the trigger, which inserts a record,
>which calls the trigger, etc. Infinite recursion.
>
>
>



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 01:49 AM
Enrico Weigelt
 
Posts: n/a
Default Re: thats funny :)

* Vasilis Ventirozos <vendi@cosmoline.com> wrote:
> i know what the trigger does, i writed it
> i dont have a problem , i already fixed the function to work nice and smooth
> i just sent it for fun, anyway no problem about the subject


probably there should be a detection of too deep recursion instead
of just crashing on stack overflow.


cu
--
---------------------------------------------------------------------
Enrico Weigelt == metux IT service
phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact@metux.de
---------------------------------------------------------------------
Realtime Forex/Stock Exchange trading powered by postgresSQL )
http://www.fxignal.net/
---------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 01:49 AM
Tom Lane
 
Posts: n/a
Default Re: thats funny :)

Enrico Weigelt <weigelt@metux.de> writes:
> * Vasilis Ventirozos <vendi@cosmoline.com> wrote:
>> i know what the trigger does, i writed it
>> i dont have a problem , i already fixed the function to work nice and smooth
>> i just sent it for fun, anyway no problem about the subject


> probably there should be a detection of too deep recursion instead
> of just crashing on stack overflow.


Already done in PG 8.0 ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 01:50 AM
Postgres Admin
 
Posts: n/a
Default ACT! and PostgreSQL

I have some clients that are looking to upgrade to MSSQL Server because
they use ACT!. I'm developing a web application for them that uses
PostgreSQL. Does anyone know if ACT! can use PostgreSQL? or if I can
hack it?

Suggestion welcome and Thanks,
J

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:36 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com