1040 for subquery in ppi.rqlst.with_[:]: |
1040 for subquery in ppi.rqlst.with_[:]: |
1041 sppis = [PartPlanInformation(plan, select) |
1041 sppis = [PartPlanInformation(plan, select) |
1042 for select in subquery.query.children] |
1042 for select in subquery.query.children] |
1043 for sppi in sppis: |
1043 for sppi in sppis: |
1044 if sppi.needsplit or sppi.part_sources != ppi.part_sources: |
1044 if sppi.needsplit or sppi.part_sources != ppi.part_sources: |
1045 temptable = 'T%s' % make_uid(id(subquery)) |
1045 temptable = plan.make_temp_table_name('T%s' % make_uid(id(subquery))) |
1046 sstep = self._union_plan(plan, sppis, temptable)[0] |
1046 sstep = self._union_plan(plan, sppis, temptable)[0] |
1047 break |
1047 break |
1048 else: |
1048 else: |
1049 sstep = None |
1049 sstep = None |
1050 if sstep is not None: |
1050 if sstep is not None: |
1073 add_types_restriction(self.schema, select) |
1073 add_types_restriction(self.schema, select) |
1074 # part plan info for subqueries |
1074 # part plan info for subqueries |
1075 inputmap = self._ppi_subqueries(ppi) |
1075 inputmap = self._ppi_subqueries(ppi) |
1076 aggrstep = need_aggr_step(select, sources) |
1076 aggrstep = need_aggr_step(select, sources) |
1077 if aggrstep: |
1077 if aggrstep: |
1078 atemptable = 'T%s' % make_uid(id(select)) |
1078 atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select))) |
1079 sunion = Union() |
1079 sunion = Union() |
1080 sunion.append(select) |
1080 sunion.append(select) |
1081 selected = select.selection[:] |
1081 selected = select.selection[:] |
1082 select_group_sort(select) |
1082 select_group_sort(select) |
1083 step = AggrStep(plan, selected, select, atemptable, temptable) |
1083 step = AggrStep(plan, selected, select, atemptable, temptable) |
1117 plan = ppi.plan |
1117 plan = ppi.plan |
1118 select = ppi.rqlst |
1118 select = ppi.rqlst |
1119 subinputmap = self._ppi_subqueries(ppi) |
1119 subinputmap = self._ppi_subqueries(ppi) |
1120 stepdefs = ppi.part_steps() |
1120 stepdefs = ppi.part_steps() |
1121 if need_aggr_step(select, ppi.part_sources, stepdefs): |
1121 if need_aggr_step(select, ppi.part_sources, stepdefs): |
1122 atemptable = 'T%s' % make_uid(id(select)) |
1122 atemptable = plan.make_temp_table_name('T%s' % make_uid(id(select))) |
1123 selection = select.selection[:] |
1123 selection = select.selection[:] |
1124 select_group_sort(select) |
1124 select_group_sort(select) |
1125 else: |
1125 else: |
1126 atemptable = None |
1126 atemptable = None |
1127 selection = select.selection |
1127 selection = select.selection |
1167 steps.append(ppi.build_final_part(minrqlst, solindices, inputmap, |
1167 steps.append(ppi.build_final_part(minrqlst, solindices, inputmap, |
1168 sources, insertedvars)) |
1168 sources, insertedvars)) |
1169 else: |
1169 else: |
1170 table = '_T%s%s' % (''.join(sorted(v._ms_table_key() for v in terms)), |
1170 table = '_T%s%s' % (''.join(sorted(v._ms_table_key() for v in terms)), |
1171 ''.join(sorted(str(i) for i in solindices))) |
1171 ''.join(sorted(str(i) for i in solindices))) |
|
1172 table = plan.make_temp_table_name(table) |
1172 ppi.build_non_final_part(minrqlst, solindices, sources, |
1173 ppi.build_non_final_part(minrqlst, solindices, sources, |
1173 insertedvars, table) |
1174 insertedvars, table) |
1174 # finally: join parts, deal with aggregat/group/sorts if necessary |
1175 # finally: join parts, deal with aggregat/group/sorts if necessary |
1175 if atemptable is not None: |
1176 if atemptable is not None: |
1176 step = AggrStep(plan, selection, select, atemptable, temptable) |
1177 step = AggrStep(plan, selection, select, atemptable, temptable) |