Use PG_FINALLY to simplify code
Use PG_FINALLY to simplify code
Hi
In (/src/pl/plpgsql/src/pl_exec.c), I found some code like the following:
PG_CATCH();
{
if (expr->plan && !expr->plan->saved)
expr->plan = NULL;
PG_RE_THROW();
}
PG_END_TRY();
if (expr->plan && !expr->plan->saved)
expr->plan = NULL;
Since PG_FINALLY can be used now, I think we can use PG_FINALLY to simplify code here.
Best regards,
houzj
Re: Use PG_FINALLY to simplify code
От:
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Дата:
At Tue, 29 Sep 2020 01:03:13 +0000, "Hou, Zhijie" wrote in
> In (/src/pl/plpgsql/src/pl_exec.c), I found some code like the following:
>
> PG_CATCH();
> {
> if (expr->plan && !expr->plan->saved)
> expr->plan = NULL;
> PG_RE_THROW();
> }
> PG_END_TRY();
>
> if (expr->plan && !expr->plan->saved)
> expr->plan = NULL;
>
> Since PG_FINALLY can be used now, I think we can use PG_FINALLY to simplify code here.
The patch removes PG_RETHROW(), which is crucial in the code
path. There's at least one other instance of that coding in pquery.c
but PG_FINALLY() is not applicable there for the same reason, too.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Re: Use PG_FINALLY to simplify code
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Kyotaro Horiguchi writes: > At Tue, 29 Sep 2020 01:03:13 +0000, "Hou, Zhijie" wrote in >> Since PG_FINALLY can be used now, I think we can use PG_FINALLY to simplify code here. > The patch removes PG_RETHROW(), which is crucial in the code > path. No, that's not a problem, because PG_FINALLY incorporates logic to reproduce the PG_RE_THROW action if we get to the code block due to an error being thrown. The patch is nonetheless moot, because after a6b1f5365 those two code paths are no longer identical. regards, tom lane
Re: Use PG_FINALLY to simplify code
От:
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Дата:
At Tue, 29 Sep 2020 23:10:52 -0400, Tom Lane wrote in tgl> Kyotaro Horiguchi writes: tgl> > At Tue, 29 Sep 2020 01:03:13 +0000, "Hou, Zhijie" wrote in tgl> >> Since PG_FINALLY can be used now, I think we can use PG_FINALLY to simplify code here. tgl> tgl> > The patch removes PG_RETHROW(), which is crucial in the code tgl> > path. tgl> tgl> No, that's not a problem, because PG_FINALLY incorporates logic tgl> to reproduce the PG_RE_THROW action if we get to the code block tgl> due to an error being thrown. Oops! Sorry. It's exactly the definition of finally block. tgl> The patch is nonetheless moot, because after a6b1f5365 those tgl> two code paths are no longer identical. regards. -- Kyotaro Horiguchi NTT Open Source Software Center