mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
merge
This commit is contained in:
@ -1335,8 +1335,7 @@ mysql_execute_command(THD *thd)
|
||||
TODO: solve problem with depended derived tables in subselects
|
||||
*/
|
||||
if (lex->sql_command == SQLCOM_SELECT &&
|
||||
(select_lex->options & SELECT_DESCRIBE) &&
|
||||
lex->derived_tables)
|
||||
lex->describe && lex->derived_tables)
|
||||
{
|
||||
if (!(explain_result= new select_send()))
|
||||
{
|
||||
@ -1404,9 +1403,7 @@ mysql_execute_command(THD *thd)
|
||||
switch (lex->sql_command) {
|
||||
case SQLCOM_SELECT:
|
||||
{
|
||||
select_result *result;
|
||||
if (select_lex->options & SELECT_DESCRIBE)
|
||||
lex->exchange=0;
|
||||
select_result *result=lex->result;
|
||||
if (tables)
|
||||
{
|
||||
res=check_table_access(thd,
|
||||
@ -1431,51 +1428,10 @@ mysql_execute_command(THD *thd)
|
||||
if (unit->select_limit_cnt == HA_POS_ERROR)
|
||||
select_lex->options&= ~OPTION_FOUND_ROWS;
|
||||
|
||||
if (lex->exchange)
|
||||
{
|
||||
if (lex->exchange->dumpfile)
|
||||
{
|
||||
if (!(result=new select_dump(lex->exchange)))
|
||||
{
|
||||
res= -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(result=new select_export(lex->exchange)))
|
||||
{
|
||||
res= -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!(result=new select_send()))
|
||||
{
|
||||
res= -1;
|
||||
#ifdef DELETE_ITEMS
|
||||
delete select_lex->having;
|
||||
delete select_lex->where;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
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= new select_send()))
|
||||
{
|
||||
@ -1485,24 +1441,7 @@ mysql_execute_command(THD *thd)
|
||||
else
|
||||
thd->send_explain_fields(explain_result);
|
||||
fix_tables_pointers(select_lex);
|
||||
for ( SELECT_LEX *sl= select_lex;
|
||||
sl && res == 0;
|
||||
sl= sl->next_select_in_list())
|
||||
{
|
||||
SELECT_LEX *first= sl->master_unit()->first_select();
|
||||
res= mysql_explain_select(thd, sl,
|
||||
((select_lex==sl)?
|
||||
((sl->next_select_in_list())?"PRIMARY":
|
||||
"SIMPLE"):
|
||||
((sl == first)?
|
||||
((sl->depended)?"DEPENDENT SUBSELECT":
|
||||
"SUBSELECT"):
|
||||
((sl->depended)?"DEPENDENT UNION":
|
||||
"UNION"))),
|
||||
explain_result);
|
||||
}
|
||||
if (res > 0)
|
||||
res= -res; // mysql_explain_select do not report error
|
||||
res= mysql_explain_union(thd, &thd->lex.unit, explain_result);
|
||||
MYSQL_LOCK *save_lock= thd->lock;
|
||||
thd->lock= (MYSQL_LOCK *)0;
|
||||
explain_result->send_eof();
|
||||
@ -1510,12 +1449,33 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
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);
|
||||
res=handle_select(thd, lex, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
delete result;
|
||||
break;
|
||||
}
|
||||
case SQLCOM_DO:
|
||||
@ -2946,7 +2906,7 @@ mysql_init_query(THD *thd)
|
||||
thd->free_list= 0;
|
||||
thd->lex.union_option= 0;
|
||||
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->fatal_error= 0; // Safety
|
||||
thd->total_warn_count=0; // Warnings for this query
|
||||
@ -2966,6 +2926,7 @@ mysql_init_select(LEX *lex)
|
||||
lex->thd->variables.select_limit;
|
||||
select_lex->olap= UNSPECIFIED_OLAP_TYPE;
|
||||
lex->exchange= 0;
|
||||
lex->result= 0;
|
||||
lex->proc_list.first= 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user