mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
A cleanup in derived table handling: removing duplicate code from st_select_lex::handle_derived()
st_select_lex::handle_derived() and mysql_handle_list_of_derived() had exactly the same implementations. - Adding a new method LEX::handle_list_of_derived() instead - Removing public function mysql_handle_list_of_derived() - Reusing LEX::handle_list_of_derived() in st_select_lex::handle_derived()
This commit is contained in:
@ -37,7 +37,7 @@
|
|||||||
#include "sql_trigger.h"
|
#include "sql_trigger.h"
|
||||||
#include "transaction.h"
|
#include "transaction.h"
|
||||||
#include "records.h" // init_read_record,
|
#include "records.h" // init_read_record,
|
||||||
#include "sql_derived.h" // mysql_handle_list_of_derived
|
#include "sql_derived.h" // mysql_handle_derived
|
||||||
// end_read_record
|
// end_read_record
|
||||||
/**
|
/**
|
||||||
Implement DELETE SQL word.
|
Implement DELETE SQL word.
|
||||||
@ -71,9 +71,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
if (open_and_lock_tables(thd, table_list, TRUE, 0))
|
if (open_and_lock_tables(thd, table_list, TRUE, 0))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
|
if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
|
if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
if (!table_list->single_table_updatable())
|
if (!table_list->single_table_updatable())
|
||||||
|
@ -199,36 +199,6 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Run specified phases for derived tables/views in the given list
|
|
||||||
|
|
||||||
@param lex LEX for this thread
|
|
||||||
@param table_list list of derived tables/view to handle
|
|
||||||
@param phase_map phases to process tables/views through
|
|
||||||
|
|
||||||
@details
|
|
||||||
This function runs phases specified by the 'phases_map' on derived
|
|
||||||
tables/views found in the 'dt_list' with help of the
|
|
||||||
TABLE_LIST::handle_derived function.
|
|
||||||
'lex' is passed as an argument to the TABLE_LIST::handle_derived.
|
|
||||||
|
|
||||||
@return FALSE ok
|
|
||||||
@return TRUE error
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool
|
|
||||||
mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *table_list, uint phases)
|
|
||||||
{
|
|
||||||
for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
|
|
||||||
{
|
|
||||||
if (tl->is_view_or_derived() &&
|
|
||||||
tl->handle_derived(lex, phases))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Merge a derived table/view into the embedding select
|
Merge a derived table/view into the embedding select
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ struct LEX;
|
|||||||
|
|
||||||
bool mysql_handle_derived(LEX *lex, uint phases);
|
bool mysql_handle_derived(LEX *lex, uint phases);
|
||||||
bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases);
|
bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases);
|
||||||
bool mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *dt_list, uint phases);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cleans up the SELECT_LEX_UNIT for the derived table (if any).
|
Cleans up the SELECT_LEX_UNIT for the derived table (if any).
|
||||||
|
@ -1404,7 +1404,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
|
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
|
if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
/*
|
/*
|
||||||
For subqueries in VALUES() we should not see the table in which we are
|
For subqueries in VALUES() we should not see the table in which we are
|
||||||
|
@ -3593,14 +3593,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
|
|||||||
|
|
||||||
bool st_select_lex::handle_derived(LEX *lex, uint phases)
|
bool st_select_lex::handle_derived(LEX *lex, uint phases)
|
||||||
{
|
{
|
||||||
for (TABLE_LIST *cursor= (TABLE_LIST*) table_list.first;
|
return lex->handle_list_of_derived(table_list.first, phases);
|
||||||
cursor;
|
|
||||||
cursor= cursor->next_local)
|
|
||||||
{
|
|
||||||
if (cursor->is_view_or_derived() && cursor->handle_derived(lex, phases))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2785,6 +2785,31 @@ struct LEX: public Query_tables_list
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool save_prep_leaf_tables();
|
bool save_prep_leaf_tables();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Run specified phases for derived tables/views in the given list
|
||||||
|
|
||||||
|
@param table_list - list of derived tables/view to handle
|
||||||
|
@param phase - phases to process tables/views through
|
||||||
|
|
||||||
|
@details
|
||||||
|
This method runs phases specified by the 'phases' on derived
|
||||||
|
tables/views found in the 'table_list' with help of the
|
||||||
|
TABLE_LIST::handle_derived function.
|
||||||
|
'this' is passed as an argument to the TABLE_LIST::handle_derived.
|
||||||
|
|
||||||
|
@return false - ok
|
||||||
|
@return true - error
|
||||||
|
*/
|
||||||
|
bool handle_list_of_derived(TABLE_LIST *table_list, uint phases)
|
||||||
|
{
|
||||||
|
for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
|
||||||
|
{
|
||||||
|
if (tl->is_view_or_derived() && tl->handle_derived(this, phases))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
|
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
|
if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
|
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
|
||||||
&thd->lex->select_lex.top_join_list,
|
&thd->lex->select_lex.top_join_list,
|
||||||
|
Reference in New Issue
Block a user