server/msplanner.py
branchstable
changeset 4722 9c13d5db03d9
parent 4721 8f63691ccb7f
child 4956 e8a5cd5032f4
equal deleted inserted replaced
4721:8f63691ccb7f 4722:9c13d5db03d9
  1025         # to permissions for variable's type, different rql queries may have to
  1025         # to permissions for variable's type, different rql queries may have to
  1026         # be executed
  1026         # be executed
  1027         plan.preprocess(rqlst)
  1027         plan.preprocess(rqlst)
  1028         ppis = [PartPlanInformation(plan, select, self.rqlhelper)
  1028         ppis = [PartPlanInformation(plan, select, self.rqlhelper)
  1029                 for select in rqlst.children]
  1029                 for select in rqlst.children]
  1030         steps = self._union_plan(plan, rqlst, ppis)
  1030         steps = self._union_plan(plan, ppis)
  1031         if server.DEBUG & server.DBG_MS:
  1031         if server.DEBUG & server.DBG_MS:
  1032             from pprint import pprint
  1032             from pprint import pprint
  1033             for step in plan.steps:
  1033             for step in plan.steps:
  1034                 pprint(step.test_repr())
  1034                 pprint(step.test_repr())
  1035             pprint(steps[0].test_repr())
  1035             pprint(steps[0].test_repr())
  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 = 'T%s' % make_uid(id(subquery))
  1048                     sstep = self._union_plan(plan, subquery.query, 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:
  1053                 ppi.rqlst.with_.remove(subquery)
  1053                 ppi.rqlst.with_.remove(subquery)
  1054                 for i, colalias in enumerate(subquery.aliases):
  1054                 for i, colalias in enumerate(subquery.aliases):
  1055                     inputmap[colalias.name] = '%s.C%s' % (temptable, i)
  1055                     inputmap[colalias.name] = '%s.C%s' % (temptable, i)
  1056                 ppi.plan.add_step(sstep)
  1056                 ppi.plan.add_step(sstep)
  1057         return inputmap
  1057         return inputmap
  1058 
  1058 
  1059     def _union_plan(self, plan, union, ppis, temptable=None):
  1059     def _union_plan(self, plan, ppis, temptable=None):
  1060         tosplit, cango, allsources = [], {}, set()
  1060         tosplit, cango, allsources = [], {}, set()
  1061         for planinfo in ppis:
  1061         for planinfo in ppis:
  1062             if planinfo.needsplit:
  1062             if planinfo.needsplit:
  1063                 tosplit.append(planinfo)
  1063                 tosplit.append(planinfo)
  1064             else:
  1064             else: