Derived tables is the internal name for subqueries in the
The processing of derived tables is now included in the table
opening process (
Routine of execution derived tables and substituting temporary
table instead of it (
will be called just after opening and locking all real tables used
in query (including tables used in derived table query).
lex->derived_tables flag is present, all
SELECT_LEX structures will be scanned (there is
a list of all
SELECT_LEX structures in reverse
lex->all_selects_list, the first
SELECT in the query will be last in this list).
There is a pointer for the derived table,
SELECT_LEX_UNIT stored in the
TABLE_LIST::derived). For any table that has
mysql_derived() will be called.
union_result for writing results in
this table (with empty table entry, same as for
unit->prepare() to get list of
types of result fields (it work correctly for single
SELECT, and do not create temporary table
UNION processing in this case).
Creates a temporary table for storing results.
Assign this temporary table to
mysql_union to execute the query.
If it is not explain, then cleanup
structures after execution (
data of optimization phase and cleanup them after whole query
Stores pointer to this temporary table in
TABLE_LIST structure, then this table will
be used by outer query.
Links this temporary table in
thd->derived_tables for removing after
query execution. This table will be closed in
close_thread_tables if its second parameter
bool skip_derived) is true.
Copyright © 1997, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices