diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/sql/table.cc b/sql/table.cc index b1a7b6bfe2b..4e858cdb24c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8989,14 +8989,18 @@ void TABLE::vers_update_fields() return; } - if (versioned(VERS_TIMESTAMP) && - vers_start_field()->store_timestamp(in_use->query_start(), - in_use->query_start_sec_part())) + if (versioned(VERS_TIMESTAMP)) { - DBUG_ASSERT(0); + if (vers_start_field()->store_timestamp(in_use->query_start(), + in_use->query_start_sec_part())) + { + DBUG_ASSERT(0); + } + vers_start_field()->set_has_explicit_value(); } vers_end_field()->set_max(); + vers_end_field()->set_has_explicit_value(); bitmap_set_bit(read_set, vers_end_field()->field_index); file->column_bitmaps_signal(); if (vfield) @@ -9009,6 +9013,7 @@ void TABLE::vers_update_end() if (vers_end_field()->store_timestamp(in_use->query_start(), in_use->query_start_sec_part())) DBUG_ASSERT(0); + vers_end_field()->set_has_explicit_value(); } /** @@ -9318,6 +9323,24 @@ void TABLE_LIST::wrap_into_nested_join(List<TABLE_LIST> &join_list) /** + Check whether optimization has been performed and a derived table either + been merged to upper select level or materialized. + + @param table a TABLE_LIST object containing a derived table + + @return true in case the derived table has been merged to surrounding select, + false otherwise +*/ + +static inline bool derived_table_optimization_done(TABLE_LIST *table) +{ + return table->derived && + (table->derived->is_excluded() || + table->is_materialized_derived()); +} + + +/** @brief Initialize this derived table/view @@ -9367,13 +9390,15 @@ bool TABLE_LIST::init_derived(THD *thd, bool init_view) } } - if (init_view && !view) + if (init_view && !view && + !derived_table_optimization_done(this)) { /* This is all what we can do for a derived table for now. */ set_derived(); } - if (!is_view()) + if (!is_view() && + !derived_table_optimization_done(this)) { /* A subquery might be forced to be materialized due to a side-effect. */ if (!is_materialized_derived() && first_select->is_mergeable() && |