pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14964: statement_timeout cann't set in plpgsql
3+ messages / 3 participants
[nested] [flat]
* BUG #14964: statement_timeout cann't set in plpgsql
@ 2017-12-11 14:29 digoal@126.com
0 siblings, 1 reply; 3+ messages in thread
From: digoal@126.com @ 2017-12-11 14:29 UTC (permalink / raw)
To: pgsql-bugs; +Cc: digoal@126.com
The following bug has been logged on the website:
Bug reference: 14964
Logged by: Zhou Digoal
Email address: digoal@126.com
PostgreSQL version: 10.1
Operating system: centos 7.4 x64
Description:
```
create or replace function f1(int) returns setof record as $$
declare
begin
set local statement_timeout='1ms';
return query select count(*) as cnt, id from a where id<$1 group by id;
end;
$$ language plpgsql strict ;
```
but it can execute every time, which when the query run more than 1ms.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14964: statement_timeout cann't set in plpgsql
@ 2017-12-11 14:44 David G. Johnston <david.g.johnston@gmail.com>
parent: digoal@126.com
0 siblings, 1 reply; 3+ messages in thread
From: David G. Johnston @ 2017-12-11 14:44 UTC (permalink / raw)
To: 德哥 <digoal@126.com>; +Cc: pgsql-bugs
On Mon, Dec 11, 2017 at 7:29 AM, <digoal@126.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14964
> Logged by: Zhou Digoal
> Email address: digoal@126.com
> PostgreSQL version: 10.1
> Operating system: centos 7.4 x64
> Description:
>
> ```
> create or replace function f1(int) returns setof record as $$
> declare
> begin
> set local statement_timeout='1ms';
> return query select count(*) as cnt, id from a where id<$1 group by id;
> end;
> $$ language plpgsql strict ;
> ```
>
> but it can execute every time, which when the query run more than 1ms.
>
>
A quick Google search turns up the response that this is working as
designed. In short, the timeout applies to statements sent by the client.
Once changed the next statement the client sends to the server will use the
new setting. Since a server function invocation is a single statement as
far as the client-server relationship goes a timeout set within a function
will not apply until the statement the invoked the function ends and a new
statement is sent from the client to the server.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re:Re: BUG #14964: statement_timeout cann't set in plpgsql
@ 2017-12-11 15:55 德哥 <digoal@126.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: 德哥 @ 2017-12-11 15:55 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs
Sorry, it's not a bug.
can we use some hook , to deal this function?
--
公益是一辈子的事,I'm Digoal,Just Do It.
在 2017-12-11 22:44:53,"David G. Johnston" <david.g.johnston@gmail.com> 写道:
On Mon, Dec 11, 2017 at 7:29 AM, <digoal@126.com> wrote:
The following bug has been logged on the website:
Bug reference: 14964
Logged by: Zhou Digoal
Email address: digoal@126.com
PostgreSQL version: 10.1
Operating system: centos 7.4 x64
Description:
```
create or replace function f1(int) returns setof record as $$
declare
begin
set local statement_timeout='1ms';
return query select count(*) as cnt, id from a where id<$1 group by id;
end;
$$ language plpgsql strict ;
```
but it can execute every time, which when the query run more than 1ms.
A quick Google search turns up the response that this is working as designed. In short, the timeout applies to statements sent by the client. Once changed the next statement the client sends to the server will use the new setting. Since a server function invocation is a single statement as far as the client-server relationship goes a timeout set within a function will not apply until the statement the invoked the function ends and a new statement is sent from the client to the server.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2017-12-11 15:55 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-12-11 14:29 BUG #14964: statement_timeout cann't set in plpgsql digoal@126.com
2017-12-11 14:44 ` David G. Johnston <david.g.johnston@gmail.com>
2017-12-11 15:55 ` 德哥 <digoal@126.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox