On Fri, Nov 27, 2020 at 11:57 AM Hou, Zhijie <houzj.f...@cn.fujitsu.com> wrote: > > > Thanks a lot for the use case. Yes with the current patch table will lose > > data related to the subplan. On analyzing further, I think we can not allow > > parallel inserts in the cases when the Gather node has some projections > > to do. Because the workers can not perform that projection. So, having > > ps_ProjInfo in the Gather node is an indication for us to disable parallel > > inserts and only the leader can do the insertions after the Gather node > > does the required projections. > > > > Thoughts? > > > > Agreed. >
Thanks! I will add/modify IsParallelInsertInCTASAllowed() to return false in this case. > > 2. > @@ -166,6 +228,16 @@ ExecGather(PlanState *pstate) > { > ParallelContext *pcxt; > > + /* > + * Take the necessary information to be passed to > workers for > + * parallel inserts in CTAS. > + */ > + if (ISCTAS(node->ps.intoclause)) > + { > + node->ps.lefttree->intoclause = > node->ps.intoclause; > + node->ps.lefttree->objectid = > node->ps.objectid; > + } > + > /* Initialize, or re-initialize, shared state needed > by workers. */ > if (!node->pei) > node->pei = > ExecInitParallelPlan(node->ps.lefttree, > > I found the code pass intoclause and objectid to Gather node's lefttree. > Is it necessary? It seems only Gather node will use the information. > I am passing the required information from the up to here through PlanState structure. Since the Gather node's leftree is also a PlanState structure variable, here I just assigned them to pass that information to ExecInitParallelPlan(). With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com