Unix Technical Forum

statement_timeout doesnt work within plpgsql by design?

This is a discussion on statement_timeout doesnt work within plpgsql by design? within the pgsql Hackers forums, part of the PostgreSQL category; --> pagila=# select version(); version ------------------------------------------------------------- PostgreSQL 8.2.3 on i386-pc-solaris2.10, compiled by cc -Xa (1 row) pagila=# create or replace ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 07:12 AM
Robert Treat
 
Posts: n/a
Default statement_timeout doesnt work within plpgsql by design?

pagila=# select version();
version
-------------------------------------------------------------
PostgreSQL 8.2.3 on i386-pc-solaris2.10, compiled by cc -Xa
(1 row)

pagila=# create or replace function test() returns bool as $$ begin set
statement_timeout = 3000; perform pg_sleep(4) ; return true; end $$ language
plpgsql;
CREATE FUNCTION
pagila=# select test();
test
------
t
(1 row)

pagila=# select test();
ERROR: canceling statement due to statement timeout
CONTEXT: SQL statement "SELECT pg_sleep(4)"
PL/pgSQL function "test" line 1 at perform


is this behavior by design? if so why would you design it that way? :-)

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 07:12 AM
Tom Lane
 
Posts: n/a
Default Re: statement_timeout doesnt work within plpgsql by design?

Robert Treat <xzilla@users.sourceforge.net> writes:
> pagila=# create or replace function test() returns bool as $$ begin set
> statement_timeout = 3000; perform pg_sleep(4) ; return true; end $$ language
> plpgsql;
> CREATE FUNCTION


statement_timeout is measured across an entire interactive command, not
individual commands within a function; and the timeout that applies to
an interactive command is determined at its beginning. So the above
doesn't do what you think.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, 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
  #3 (permalink)  
Old 04-12-2008, 07:12 AM
Robert Treat
 
Posts: n/a
Default Re: statement_timeout doesnt work within plpgsql by design?

On Tuesday 20 February 2007 12:50, Tom Lane wrote:
> Robert Treat <xzilla@users.sourceforge.net> writes:
> > pagila=# create or replace function test() returns bool as $$ begin set
> > statement_timeout = 3000; perform pg_sleep(4) ; return true; end $$
> > language plpgsql;
> > CREATE FUNCTION

>
> statement_timeout is measured across an entire interactive command, not
> individual commands within a function; and the timeout that applies to
> an interactive command is determined at its beginning. So the above
> doesn't do what you think.
>


Well, I'd be happy if it caused the entire function to bail out or if it
caused individual statements within a function to bail out, but it does
neither. I can see how that would be a bit tricky to implement though.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

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:54 AM.


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