Re: BUG #1314: STATEMENT_TIMEOUT DOES NOT WORK PROPERLY

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Adnan DURSUN" <adursun(at)hvkk(dot)mil(dot)tr>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1314: STATEMENT_TIMEOUT DOES NOT WORK PROPERLY
Date: 2004-11-11 22:53:08
Message-ID: 12564.1100213588@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org> writes:
> CREATE OR REPLACE FUNCTION fn_test()
> RETURNS "varchar" AS
> $BODY$
> DECLARE
> c refcursor;
> r record;
> BEGIN
> SET SESSION STATEMENT_TIMEOUT = 1000;
> OPEN C FOR SELECT * FROM T_KULLANICILAR FOR UPDATE;
> FETCH C INTO R;
> RESET STATEMENT_TIMEOUT;
> RETURN '1';
> EXCEPTION
> WHEN QUERY_CANCELED THEN
> RAISE EXCEPTION 'UNABLE TO OBTAIN LOCK... :%';
> END;
> $BODY$

statement_timeout limits the time taken for an *interactive* command,
not the time for an individual command inside a function. What this
means is you can't change it around inside a function and expect
anything to happen --- the timeout, or lack of it, for the current
interactive command was determined long before your function got called.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message andrea suisani 2004-11-11 23:06:48 Re: SELECT FOR UPDATE and LIMIT 1 behave oddly
Previous Message Josh Berkus 2004-11-11 22:44:08 Re: SELECT FOR UPDATE and LIMIT 1 behave oddly