A question about StartSubTransaction
A question about StartSubTransaction
От:
Japin Li <japinli@hotmail.com>
Дата:
Hi hackers,
I found the StartSubTransaction has the following code:
static void
StartSubTransaction(void)
{
[...]
s->state = TRANS_START;
/*
* Initialize subsystems for new subtransaction
*
* must initialize resource-management stuff first
*/
AtSubStart_Memory();
AtSubStart_ResourceOwner();
AfterTriggerBeginSubXact();
s->state = TRANS_INPROGRESS;
[...]
}
IIRC, AtSubStart_Memory, AtSubStart_ResourceOwner and AfterTriggerBeginSubXact don't
use s->state. Why should we set s->state to TRANS_START and then TRANS_INPROGRESS?
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
Re: A question about StartSubTransaction
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Japin Li writes: > IIRC, AtSubStart_Memory, AtSubStart_ResourceOwner and AfterTriggerBeginSubXact don't > use s->state. No, they don't. > Why should we set s->state to TRANS_START and then TRANS_INPROGRESS? I believe it's so that if an error gets thrown somewhere in that area, we'll recover properly. I'd be the first to say that this stuff isn't terribly well-tested, since it's hard to force an error there. regards, tom lane
Re: A question about StartSubTransaction
От:
Japin Li <japinli@hotmail.com>
Дата:
On Wed, 14 Sep 2022 at 13:52, Tom Lane wrote: > Japin Li writes: >> Why should we set s->state to TRANS_START and then TRANS_INPROGRESS? > > I believe it's so that if an error gets thrown somewhere in that > area, we'll recover properly. I'd be the first to say that this > stuff isn't terribly well-tested, since it's hard to force an > error there. > Thanks for the explanation! Maybe more comments here is better. -- Regrads, Japin Li. ChengDu WenWu Information Technology Co.,Ltd.