MCPcopy Create free account
hub / github.com/MariaDB/server / prepare_join

Method prepare_join

sql/sql_union.cc:1090–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1088
1089
1090bool st_select_lex_unit::prepare_join(THD *thd_arg, SELECT_LEX *sl,
1091 select_result *tmp_result,
1092 ulonglong additional_options,
1093 bool is_union_select)
1094{
1095 DBUG_ENTER("st_select_lex_unit::prepare_join");
1096 TABLE_LIST *derived= sl->master_unit()->derived;
1097 bool can_skip_order_by;
1098 sl->options|= SELECT_NO_UNLOCK;
1099 JOIN *join= new JOIN(thd_arg, sl->item_list,
1100 (sl->options | thd_arg->variables.option_bits |
1101 additional_options),
1102 tmp_result);
1103 if (!join)
1104 DBUG_RETURN(true);
1105
1106 thd_arg->lex->current_select= sl;
1107
1108 can_skip_order_by= (is_union_select && !(sl->braces &&
1109 sl->limit_params.explicit_limit) &&
1110 !thd->lex->with_rownum);
1111
1112 saved_error= join->prepare(sl->table_list.first,
1113 (derived && derived->merged ? NULL : sl->where),
1114 (can_skip_order_by ? 0 :
1115 sl->order_list.elements) +
1116 sl->group_list.elements,
1117 can_skip_order_by ?
1118 NULL : sl->order_list.first,
1119 can_skip_order_by,
1120 sl->group_list.first,
1121 sl->having,
1122 (is_union_select ? NULL :
1123 thd_arg->lex->proc_list.first),
1124 sl, this);
1125
1126 last_procedure= join->procedure;
1127
1128 if (unlikely(saved_error || (saved_error= thd_arg->is_fatal_error)))
1129 DBUG_RETURN(true);
1130 /*
1131 Remove all references from the select_lex_units to the subqueries that
1132 are inside the ORDER BY clause.
1133 */
1134 if (can_skip_order_by)
1135 {
1136 for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next)
1137 {
1138 (*ord->item)->walk(&Item::eliminate_subselect_processor, 0, 0);
1139 }
1140 }
1141 DBUG_RETURN(false);
1142}
1143
1144
1145/**

Callers

nothing calls this directly

Calls 3

master_unitMethod · 0.80
prepareMethod · 0.45
walkMethod · 0.45

Tested by

no test coverage detected