Extracting column names from ShareInputScan in ORCA plans to support proper...
Extracting column names from ShareInputScan in ORCA plans to support proper column name resolution using RTE_CTE (#992) * Extracting column names from ShareInputScan in ORCA plans to support proper column name resolution using RTE_CTE. * Code review on PR 992. * PlannerGlobal has out-function support in the upstream, so removing it altogether doesn't seem like a good idea. I'm not sure if it get printed out with suitable verbose or debug flags, but I remember seeing it being printed out during debugging somehow, and it can be useful. * Refactor the functions in cdbmutate.c, so that there's a separate function to do the DAG to Tree conversion, and a separate function for just collecting the producer nodes. It seems like a bad idea that a function called "apply_dag_to_tree" actually does something different, depending on a flag in a struct. * Now that we have a separate array of producers, no need to hold the colnames etc. lists in ShareInputScan node itself. Since we can look up the producer node at will, we might as well look at the producer node's sub-tree directly every time we construct the CTE RTE. * One complication from the previous change is that we can't call get_tle_name() in replace_shareinput_targetlists(), because that runs after the post-processing in setrefs.c, so all Vars have already been changed to use INNER/OUTER. get_tle_name() doesn't work with those. On closer inspection, I think this was a bit fiddly in the ORCA case before too, because in ORCA-generated plans, Vars always use the INNER/OUTER notation, so calling get_tle_name() on an ORCA-generated plan was always questionable. It happened to work, becuase ORCA also makes seems to always fill in TargetEntry.resname, so get_tle_name() always just picked that, rather than looking up the range table entry. This new structuring of the code avoids relying on that assumption. * Refactored the code to create the fake CTE RTE to a separate function. replace_shareinput_targetlists_walker() had grown quite complex. * Use the producers array in setrefs.c * Get rid of separate sharedNodes list. Now that we have an array of producers, conveniently indexed by share_id, just use that. Mostly for sake of readability, although you might see a performance gain in corner-cases involving a huge number of share input scans.
Showing
想要评论请 注册 或 登录