]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Consider parallel awareness when removing single-child Appends
authorDavid Rowley <drowley@postgresql.org>
Tue, 25 Jan 2022 08:15:40 +0000 (21:15 +1300)
committerDavid Rowley <drowley@postgresql.org>
Tue, 25 Jan 2022 08:15:40 +0000 (21:15 +1300)
commit2ccd8fb29d74f91b291be20df43f9c0194642ae8
treebc7a163e7d89382192d1fd5249cf5d730399c33d
parentfcc434047d09428d48341c6faeb29e9bd9d95a4e
Consider parallel awareness when removing single-child Appends

8edd0e794 added some code to remove Append and MergeAppend nodes when they
contained a single child node.  As it turned out, this was unsafe to do
when the Append/MergeAppend was parallel_aware and the child node was not.
Removing the Append/MergeAppend, in this case, could lead to the child plan
being called multiple times by parallel workers when it was unsafe to do
so.

Here we fix this by just not removing the Append/MergeAppend when the
parallel_aware flag of the parent and child node don't match.

Reported-by: Yura Sokolov
Bug: #17335
Discussion: https://postgr.es/m/b59605fecb20ba9ea94e70ab60098c237c870628.camel%40postgrespro.ru
Backpatch-through: 12, where 8edd0e794 was first introduced
src/backend/optimizer/plan/setrefs.c