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

Function execute_sqlcom_select

sql/sql_parse.cc:6123–6248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6121 }
6122
6123static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
6124{
6125 LEX *lex= thd->lex;
6126 select_result *result=lex->result;
6127 bool res;
6128 /* assign global limit variable if limit is not given */
6129 {
6130 SELECT_LEX *param= lex->unit.global_parameters();
6131 if (!param->limit_params.explicit_limit)
6132 param->limit_params.select_limit=
6133 new (thd->mem_root) Item_int(thd,
6134 (ulonglong) thd->variables.select_limit);
6135 }
6136
6137 if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0)))
6138 {
6139 lex->resolve_optimizer_hints();
6140 if (lex->describe)
6141 {
6142 /*
6143 We always use select_send for EXPLAIN, even if it's an EXPLAIN
6144 for SELECT ... INTO OUTFILE: a user application should be able
6145 to prepend EXPLAIN to any query and receive output for it,
6146 even if the query itself redirects the output.
6147 */
6148 if (unlikely(!(result= new (thd->mem_root) select_send(thd))))
6149 return 1; /* purecov: inspected */
6150 thd->send_explain_fields(result, lex->describe, lex->analyze_stmt);
6151
6152 /*
6153 This will call optimize() for all parts of query. The query plan is
6154 printed out below.
6155 */
6156 res= mysql_explain_union(thd, &lex->unit, result);
6157
6158 /* Print EXPLAIN only if we don't have an error */
6159 if (likely(!res))
6160 {
6161 /*
6162 Do like the original select_describe did: remove OFFSET from the
6163 top-level LIMIT
6164 */
6165 result->remove_offset_limit();
6166 if (lex->explain_json)
6167 {
6168 lex->explain->print_explain_json(result, lex->analyze_stmt);
6169 }
6170 else
6171 {
6172 lex->explain->print_explain(result, thd->lex->describe,
6173 thd->lex->analyze_stmt);
6174 if (lex->describe & DESCRIBE_EXTENDED)
6175 {
6176 char buff[1024];
6177 String str(buff,(uint32) sizeof(buff), system_charset_info);
6178 str.length(0);
6179 /*
6180 The warnings system requires input in utf8, @see

Callers 2

sql_parse.ccFile · 0.85
execute_show_statusFunction · 0.85

Calls 15

mysql_explain_unionFunction · 0.85
push_warningFunction · 0.85
handle_selectFunction · 0.85
global_parametersMethod · 0.80
send_explain_fieldsMethod · 0.80
remove_offset_limitMethod · 0.80
print_explain_jsonMethod · 0.80
disable_my_ok_callsMethod · 0.80
send_explainMethod · 0.80
get_sent_row_countMethod · 0.80
is_cursor_executionMethod · 0.80

Tested by

no test coverage detected