"=?UTF-8?B?5YiY55u4KOS9keeGmSk=?=" <evan.lx@alibaba-inc.com> writes:
> This problem seems to have been solved in v15 and v16. Because of this patch
(12d768e70497afc5a57acf73c251316997b5175a),the use of static variables has been cancelled. But this problem can
obviouslybe reproduced on v14(and perhaps v12 v13). Try the following SQL again.
Oooh ... I see the problem. It's not really about the use of static
variables. In the older branches, CommitTransactionCommand does
if (s->chain)
SaveTransactionCharacteristics();
....
if (s->chain)
RestoreTransactionCharacteristics();
but if we're closing out any subtransactions then *those two checks
are inspecting different "s" structs*, and the "chain" flag has
only been set in the bottom of the state stack.
12d768e70 fixed the problem rather accidentally, because I removed the
initial "if (s->chain)" test to avoid a compiler warning. I think we
can just do the same in the back branches, without having to address
the question of whether it'd be OK to break API for
SaveTransactionCharacteristics and RestoreTransactionCharacteristics.
regards, tom lane