Some small accelerations ...

I intend to do some more accelerations in mysql_execute_command and
in SQLCOM_SELECT part for which I need to fix EXPLAIN with derived
tables plus few additional items. If this proves to be much I wil
just make it a new SCRUM task
parent 0f663d34
...@@ -378,7 +378,7 @@ typedef struct st_lex ...@@ -378,7 +378,7 @@ typedef struct st_lex
uint param_count; uint param_count;
bool drop_primary, drop_if_exists, local_file, olap; bool drop_primary, drop_if_exists, local_file, olap;
bool in_comment, ignore_space, verbose, simple_alter; bool in_comment, ignore_space, verbose, simple_alter;
bool derived_tables; bool derived_tables, describe;
uint slave_thd_opt; uint slave_thd_opt;
CHARSET_INFO *charset; CHARSET_INFO *charset;
} LEX; } LEX;
......
...@@ -1335,8 +1335,7 @@ mysql_execute_command(THD *thd) ...@@ -1335,8 +1335,7 @@ mysql_execute_command(THD *thd)
TODO: solve problem with depended derived tables in subselects TODO: solve problem with depended derived tables in subselects
*/ */
if (lex->sql_command == SQLCOM_SELECT && if (lex->sql_command == SQLCOM_SELECT &&
(select_lex->options & SELECT_DESCRIBE) && lex->describe && lex->derived_tables)
lex->derived_tables)
{ {
if (!(explain_result= new select_send())) if (!(explain_result= new select_send()))
{ {
...@@ -1405,8 +1404,6 @@ mysql_execute_command(THD *thd) ...@@ -1405,8 +1404,6 @@ mysql_execute_command(THD *thd)
case SQLCOM_SELECT: case SQLCOM_SELECT:
{ {
select_result *result=lex->result; select_result *result=lex->result;
if (select_lex->options & SELECT_DESCRIBE)
lex->exchange=0;
if (tables) if (tables)
{ {
res=check_table_access(thd, res=check_table_access(thd,
...@@ -1431,35 +1428,10 @@ mysql_execute_command(THD *thd) ...@@ -1431,35 +1428,10 @@ mysql_execute_command(THD *thd)
if (unit->select_limit_cnt == HA_POS_ERROR) if (unit->select_limit_cnt == HA_POS_ERROR)
select_lex->options&= ~OPTION_FOUND_ROWS; select_lex->options&= ~OPTION_FOUND_ROWS;
if (!result)
{
if ((result=new select_send()))
{
/*
Normal select:
Change lock if we are using SELECT HIGH PRIORITY,
FOR UPDATE or IN SHARE MODE
*/
TABLE_LIST *table;
for (table = tables ; table ; table=table->next)
table->lock_type= lex->lock_option;
}
else
{
res= -1;
#ifdef DELETE_ITEMS
delete select_lex->having;
delete select_lex->where;
#endif
break;
}
}
if (!(res=open_and_lock_tables(thd,tables))) if (!(res=open_and_lock_tables(thd,tables)))
{ {
if (select_lex->options & SELECT_DESCRIBE) if (lex->describe)
{ {
delete result; // we do not need it for explain
if (!explain_result) if (!explain_result)
if (!(explain_result= new select_send())) if (!(explain_result= new select_send()))
{ {
...@@ -1477,12 +1449,33 @@ mysql_execute_command(THD *thd) ...@@ -1477,12 +1449,33 @@ mysql_execute_command(THD *thd)
} }
else else
{ {
if (!result)
{
if ((result=new select_send()))
{
/*
Normal select:
Change lock if we are using SELECT HIGH PRIORITY,
FOR UPDATE or IN SHARE MODE
*/
TABLE_LIST *table;
for (table = tables ; table ; table=table->next)
table->lock_type= lex->lock_option;
}
else
{
res= -1;
#ifdef DELETE_ITEMS
delete select_lex->having;
delete select_lex->where;
#endif
break;
}
}
query_cache_store_query(thd, tables); query_cache_store_query(thd, tables);
res=handle_select(thd, lex, result); res=handle_select(thd, lex, result);
} }
} }
else
delete result;
break; break;
} }
case SQLCOM_DO: case SQLCOM_DO:
...@@ -2913,7 +2906,7 @@ mysql_init_query(THD *thd) ...@@ -2913,7 +2906,7 @@ mysql_init_query(THD *thd)
thd->free_list= 0; thd->free_list= 0;
thd->lex.union_option= 0; thd->lex.union_option= 0;
thd->lex.select= &thd->lex.select_lex; thd->lex.select= &thd->lex.select_lex;
thd->lex.olap=0; thd->lex.olap=thd->lex.describe=0;
thd->lex.select->olap= UNSPECIFIED_OLAP_TYPE; thd->lex.select->olap= UNSPECIFIED_OLAP_TYPE;
thd->fatal_error= 0; // Safety thd->fatal_error= 0; // Safety
thd->total_warn_count=0; // Warnings for this query thd->total_warn_count=0; // Warnings for this query
......
...@@ -2553,7 +2553,8 @@ procedure_item: ...@@ -2553,7 +2553,8 @@ procedure_item:
select_var_list_init: select_var_list_init:
{ {
if (!(Lex->result= new select_dumpvar())) LEX *lex=Lex;
if (!lex->describe && (!(lex->result= new select_dumpvar())))
YYABORT; YYABORT;
} }
select_var_list select_var_list
...@@ -2567,27 +2568,34 @@ select_var_list: ...@@ -2567,27 +2568,34 @@ select_var_list:
select_var_ident: '@' ident_or_text select_var_ident: '@' ident_or_text
{ {
LEX *lex=Lex; LEX *lex=Lex;
if ( ((select_dumpvar *)lex->result)->var_list.push_back((LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING)))) if (lex->result && ((select_dumpvar *)lex->result)->var_list.push_back((LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING))))
YYABORT; YYABORT;
} }
;
opt_into: opt_into:
INTO OUTFILE TEXT_STRING INTO OUTFILE TEXT_STRING
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!(lex->exchange= new sql_exchange($3.str,0))) if (!lex->describe)
YYABORT; {
if (!(lex->result= new select_export(lex->exchange))) if (!(lex->exchange= new sql_exchange($3.str,0)))
YYABORT; YYABORT;
if (!(lex->result= new select_export(lex->exchange)))
YYABORT;
}
} }
opt_field_term opt_line_term opt_field_term opt_line_term
| INTO DUMPFILE TEXT_STRING | INTO DUMPFILE TEXT_STRING
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!(lex->exchange= new sql_exchange($3.str,1))) if (!lex->describe)
YYABORT; {
if (!(lex->result= new select_dump(lex->exchange))) if (!(lex->exchange= new sql_exchange($3.str,1)))
YYABORT; YYABORT;
if (!(lex->result= new select_dump(lex->exchange)))
YYABORT;
}
} }
| INTO select_var_list_init | INTO select_var_list_init
{ {
...@@ -3057,7 +3065,11 @@ describe: ...@@ -3057,7 +3065,11 @@ describe:
} }
opt_describe_column opt_describe_column
| describe_command select | describe_command select
{ Lex->select_lex.options|= SELECT_DESCRIBE; }; {
LEX *lex=Lex;
lex->select_lex.options|= SELECT_DESCRIBE;
lex->describe=1;
};
describe_command: describe_command:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment