Re: Error-safe user functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ted Yu <yuzhihong(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Amul Sul <sulamul(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Joe Conway <mail(at)joeconway(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Error-safe user functions
Date: 2022-12-23 21:38:09
Message-ID: 2793039.1671831489@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ted Yu <yuzhihong(at)gmail(dot)com> writes:
> On Fri, Dec 23, 2022 at 1:22 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Ted Yu <yuzhihong(at)gmail(dot)com> writes:
>>> + /* See regexp.c for explanation */
>>> + CHECK_FOR_INTERRUPTS();

>> Yes, it is. We don't want a query-cancel transformed into a soft error.

> `ereturn(escontext` calls appear in multiple places in the patch.
> What about other callsites (w.r.t. checking interrupt) ?

What about them? The reason this one is special is that backend/regexp
might return a failure code that's specifically "I gave up because
there's a query cancel pending". We don't want to report that as a soft
error. It's true that we might cancel the query for real a bit later on
even if this check weren't here, but that doesn't mean it's okay to go
down the soft error path and hope that there'll be a CHECK_FOR_INTERRUPTS
sometime before there's any visible evidence that we did the wrong thing.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dag Lem 2022-12-23 21:44:26 Re: daitch_mokotoff module
Previous Message Ted Yu 2022-12-23 21:25:42 Re: Error-safe user functions