pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G. Johnston <david.g.johnston@gmail.com>
To: 德哥 <digoal@126.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14964: statement_timeout cann't set in plpgsql
Date: Mon, 11 Dec 2017 07:44:53 -0700
Message-ID: <CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com> (raw)
In-Reply-To: <20171211142926.20152.70880@wrigleys.postgresql.org>
References: <20171211142926.20152.70880@wrigleys.postgresql.org>

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.

view thread (3+ messages)  latest in thread

Message-ID: <CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com>
Permalink:  ../CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com/
Also on:    postgresql.org/message-id/CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: david.g.johnston@gmail.com, digoal@126.com
  Subject: Re: BUG #14964: statement_timeout cann't set in plpgsql
  In-Reply-To: <CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com>
  References: <20171211142926.20152.70880@wrigleys.postgresql.org> <CAKFQuwaDcCKhf-TPrVV=MvfwCUYYamMFfS-5u7vYJyO2snxuFw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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