summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc78
1 files changed, 17 insertions, 61 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 1c2ff2b012b..c5cedf795a3 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -692,64 +692,6 @@ bool st_select_lex_unit::prepare_join(THD *thd_arg, SELECT_LEX *sl,
}
-class Type_holder: public Sql_alloc,
- public Item_args,
- public Type_handler_hybrid_field_type,
- public Type_all_attributes,
- public Type_geometry_attributes
-{
- TYPELIB *m_typelib;
- bool m_maybe_null;
-public:
- Type_holder()
- :m_typelib(NULL),
- m_maybe_null(false)
- { }
-
- void set_maybe_null(bool maybe_null_arg) { m_maybe_null= maybe_null_arg; }
- bool get_maybe_null() const { return m_maybe_null; }
-
- uint decimal_precision() const
- {
- /*
- Type_holder is not used directly to create fields, so
- its virtual decimal_precision() is never called.
- We should eventually extend create_result_table() to accept
- an array of Type_holders directly, without having to allocate
- Item_type_holder's and put them into List<Item>.
- */
- DBUG_ASSERT(0);
- return 0;
- }
- void set_geometry_type(uint type)
- {
- Type_geometry_attributes::set_geometry_type(type);
- }
- uint uint_geometry_type() const
- {
- return Type_geometry_attributes::get_geometry_type();
- }
- void set_typelib(TYPELIB *typelib)
- {
- m_typelib= typelib;
- }
- TYPELIB *get_typelib() const
- {
- return m_typelib;
- }
-
- bool aggregate_attributes(THD *thd)
- {
- for (uint i= 0; i < arg_count; i++)
- m_maybe_null|= args[i]->maybe_null;
- return
- type_handler()->Item_hybrid_func_fix_attributes(thd,
- "UNION", this, this,
- args, arg_count);
- }
-};
-
-
/**
Aggregate data type handlers for the "count" leftmost UNION parts.
*/
@@ -978,7 +920,12 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
if (!is_union_select && !is_recursive)
{
- if (prepare_join(thd_arg, first_sl, tmp_result, additional_options,
+ if (sl->tvc)
+ {
+ if (sl->tvc->prepare(thd_arg, sl, tmp_result))
+ goto err;
+ }
+ else if (prepare_join(thd_arg, first_sl, tmp_result, additional_options,
is_union_select))
goto err;
types= first_sl->item_list;
@@ -987,8 +934,13 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
for (;sl; sl= sl->next_select(), union_part_count++)
{
- if (prepare_join(thd_arg, sl, tmp_result, additional_options,
- is_union_select))
+ if (sl->tvc)
+ {
+ if (sl->tvc->prepare(thd_arg, sl, tmp_result))
+ goto err;
+ }
+ else if (prepare_join(thd_arg, sl, tmp_result, additional_options,
+ is_union_select))
goto err;
/*
@@ -1296,6 +1248,8 @@ bool st_select_lex_unit::optimize()
}
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
+ if (sl->tvc)
+ continue;
thd->lex->current_select= sl;
if (optimized)
@@ -1411,6 +1365,8 @@ bool st_select_lex_unit::exec()
if (!saved_error)
{
records_at_start= table->file->stats.records;
+ if (sl->tvc)
+ sl->tvc->exec();
sl->join->exec();
if (sl == union_distinct && !(with_element && with_element->is_recursive))
{