Non-subquery unions are performed with the help of
mysql_union(). For now, it is divided into the
st_select_lex_unit::prepare(the same procedure can be called for single
SELECTfor derived table => we have support for it in this procedure, but we will not describe it here):
select_result) which will write select results in this temporary table, with empty temporary table entry. We will need this object to store in every
JOINstructure link on it, but we have not (yet) temporary table structure.
JOINstructures and execute
SELECTto get full information about types of elements of
SELECTlist (results). Merging types of result fields and storing them in special Items (
Item_type_holder) will be done in this loop, too. Result of this operation (list of types of result fields) will be stored in
Create a temporary table for storing union results (if
ALLoption, 'distinct' parameter will be passed to the table creation procedure).
Assign a temporary table to the
select_unionobject created in the first step.
Delete rows from the temporary table if this is not the first call.
if this is the first call, call
select_unionwill write a result for the temporary table). If union is cacheable and this is not the first call, the method will do nothing.
mysql_selecton temporary table with global
LIMITparameters after collecting results from all
SELECTs. A special
SELECT_LEX) which is created for every
UNIONwill be passed for this procedure (this
SELECT_LEXalso can be used to store global
LIMITparameters if brackets used in a query).