Re: Can we set time exception?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Shaozhong SHI <shishaozhong(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: Can we set time exception?
Date: 2023-07-13 15:52:32
Message-ID: 2884749.1689263552@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Thu, Jul 13, 2023 at 7:46 AM Shaozhong SHI <shishaozhong(at)gmail(dot)com>
> wrote:
>> Can we set a time exception?
>> If the function responds with result in a given time, we take the result.
>> If the response of the function exceeds the time set, skip it.

> No. Function execution happens on a single thread (i.e., synchronous) in a
> stacked manner. There is no way for the caller to get processing control
> back other than the callee returning.

You could do something with statement_timeout, but the recovery would
have to be managed on the client (application) side. IIRC we measure
that as the total time to finish a client query, not the time of any
one statement within a function or DO block.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Shaozhong SHI 2023-07-14 06:38:34 Memory allocation error
Previous Message David G. Johnston 2023-07-13 15:36:48 Re: Can we set time exception?