server/msplanner.py
changeset 5177 395e1ff018ae
parent 5161 a19f22bacedc
parent 5168 1ab032df5ca3
child 5423 e15abfdcce38
equal deleted inserted replaced
5176:ddd5219d7eef 5177:395e1ff018ae
  1042         for subquery in ppi.rqlst.with_[:]:
  1042         for subquery in ppi.rqlst.with_[:]:
  1043             sppis = [PartPlanInformation(plan, select)
  1043             sppis = [PartPlanInformation(plan, select)
  1044                      for select in subquery.query.children]
  1044                      for select in subquery.query.children]
  1045             for sppi in sppis:
  1045             for sppi in sppis:
  1046                 if sppi.needsplit or sppi.part_sources != ppi.part_sources:
  1046                 if sppi.needsplit or sppi.part_sources != ppi.part_sources:
  1047                     temptable = 'T%s' % make_uid(id(subquery))
  1047                     temptable = plan.make_temp_table_name('T%s' % make_uid(id(subquery)))
  1048                     sstep = self._union_plan(plan, sppis, temptable)[0]
  1048                     sstep = self._union_plan(plan, sppis, temptable)[0]
  1049                     break
  1049                     break
  1050             else:
  1050             else:
  1051                 sstep = None
  1051                 sstep = None
  1052             if sstep is not None:
  1052             if sstep is not None:
  1075                     add_types_restriction(self.schema, select)
  1075                     add_types_restriction(self.schema, select)
  1076                 # part plan info for subqueries
  1076                 # part plan info for subqueries
  1077                 inputmap = self._ppi_subqueries(ppi)
  1077                 inputmap = self._ppi_subqueries(ppi)
  1078                 aggrstep = need_aggr_step(select, sources)
  1078                 aggrstep = need_aggr_step(select, sources)
  1079                 if aggrstep:
  1079                 if aggrstep:
  1080                     atemptable = 'T%s' % make_uid(id(select))
  1080                     atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select)))
  1081                     sunion = Union()
  1081                     sunion = Union()
  1082                     sunion.append(select)
  1082                     sunion.append(select)
  1083                     selected = select.selection[:]
  1083                     selected = select.selection[:]
  1084                     select_group_sort(select)
  1084                     select_group_sort(select)
  1085                     step = AggrStep(plan, selected, select, atemptable, temptable)
  1085                     step = AggrStep(plan, selected, select, atemptable, temptable)
  1119         plan = ppi.plan
  1119         plan = ppi.plan
  1120         select = ppi.rqlst
  1120         select = ppi.rqlst
  1121         subinputmap = self._ppi_subqueries(ppi)
  1121         subinputmap = self._ppi_subqueries(ppi)
  1122         stepdefs = ppi.part_steps()
  1122         stepdefs = ppi.part_steps()
  1123         if need_aggr_step(select, ppi.part_sources, stepdefs):
  1123         if need_aggr_step(select, ppi.part_sources, stepdefs):
  1124             atemptable = 'T%s' % make_uid(id(select))
  1124             atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select)))
  1125             selection = select.selection[:]
  1125             selection = select.selection[:]
  1126             select_group_sort(select)
  1126             select_group_sort(select)
  1127         else:
  1127         else:
  1128             atemptable = None
  1128             atemptable = None
  1129             selection = select.selection
  1129             selection = select.selection
  1169                             steps.append(ppi.build_final_part(minrqlst, solindices, inputmap,
  1169                             steps.append(ppi.build_final_part(minrqlst, solindices, inputmap,
  1170                                                               sources, insertedvars))
  1170                                                               sources, insertedvars))
  1171                 else:
  1171                 else:
  1172                     table = '_T%s%s' % (''.join(sorted(v._ms_table_key() for v in terms)),
  1172                     table = '_T%s%s' % (''.join(sorted(v._ms_table_key() for v in terms)),
  1173                                         ''.join(sorted(str(i) for i in solindices)))
  1173                                         ''.join(sorted(str(i) for i in solindices)))
       
  1174                     table = plan.make_temp_table_name(table)
  1174                     ppi.build_non_final_part(minrqlst, solindices, sources,
  1175                     ppi.build_non_final_part(minrqlst, solindices, sources,
  1175                                              insertedvars, table)
  1176                                              insertedvars, table)
  1176         # finally: join parts, deal with aggregat/group/sorts if necessary
  1177         # finally: join parts, deal with aggregat/group/sorts if necessary
  1177         if atemptable is not None:
  1178         if atemptable is not None:
  1178             step = AggrStep(plan, selection, select, atemptable, temptable)
  1179             step = AggrStep(plan, selection, select, atemptable, temptable)