summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 4df5af7a6c3..ae4c7b2ff66 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -8627,14 +8627,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)
@@ -8647,6 +8651,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();
}
/**
@@ -8956,6 +8961,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
@@ -9005,13 +9028,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() &&