"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thu, Jul 13, 2023 at 7:46 AM Shaozhong SHI <shishaozhong@gmail.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