summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-03-09 19:04:59 -0800
committerIgor Babaev <igor@askmonty.org>2012-03-09 19:04:59 -0800
commite6578a345c807987cc6e7fb4e9504f03b36dfa00 (patch)
tree9e0b57c6d0cea4a77c23dc87356e09a524eb268d /sql/table.cc
parent6c1aab92d25580643595962ae61a963a3e2fbd9d (diff)
parentf92cfdb8a9ff7f8287239c39ce4735789a23e3df (diff)
downloadmariadb-git-e6578a345c807987cc6e7fb4e9504f03b36dfa00.tar.gz
Merged 5.3 changes into the mwl #248 tree.
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc62
1 files changed, 61 insertions, 1 deletions
diff --git a/sql/table.cc b/sql/table.cc
index f4923a1e841..6b8adaa7c79 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -3730,6 +3730,28 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
DBUG_RETURN(FALSE);
}
+/**
+ Check that table/view is updatable and if it has single
+ underlying tables/views it is also updatable
+
+ @return Result of the check.
+*/
+
+bool TABLE_LIST::single_table_updatable()
+{
+ if (!updatable)
+ return false;
+ if (view_tables && view_tables->elements == 1)
+ {
+ /*
+ We need to check deeply only single table views. Multi-table views
+ will be turned to multi-table updates and then checked by leaf tables
+ */
+ return view_tables->head()->single_table_updatable();
+ }
+ return true;
+}
+
/*
Merge ON expressions for a view
@@ -4374,6 +4396,36 @@ bool TABLE_LIST::prepare_security(THD *thd)
DBUG_RETURN(FALSE);
}
+#ifndef DBUG_OFF
+void TABLE_LIST::set_check_merged()
+{
+ DBUG_ASSERT(derived);
+ /*
+ It is not simple to check all, but at least this should be checked:
+ this select is not excluded or the exclusion came from above.
+ */
+ DBUG_ASSERT(!derived->first_select()->exclude_from_table_unique_test ||
+ derived->outer_select()->
+ exclude_from_table_unique_test);
+}
+#endif
+
+void TABLE_LIST::set_check_materialized()
+{
+ DBUG_ASSERT(derived);
+ if (!derived->first_select()->exclude_from_table_unique_test)
+ derived->set_unique_exclude();
+ else
+ {
+ /*
+ The subtree should be already excluded
+ */
+ DBUG_ASSERT(!derived->first_select()->first_inner_unit() ||
+ derived->first_select()->first_inner_unit()->first_select()->
+ exclude_from_table_unique_test);
+ }
+}
+
Natural_join_column::Natural_join_column(Field_translator *field_param,
TABLE_LIST *tab)
@@ -4499,6 +4551,7 @@ Item *Field_iterator_table::create_item(THD *thd)
{
select->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;
+ select->set_non_agg_field_used(true);
}
return item;
}
@@ -5202,6 +5255,12 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl)
Field **vfield_ptr, *tmp_vfield;
bool bitmap_updated= FALSE;
+ if (!vfield)
+ return;
+
+ if (!vfield)
+ return;
+
for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++)
{
tmp_vfield= *vfield_ptr;
@@ -5908,8 +5967,9 @@ bool TABLE_LIST::init_derived(THD *thd, bool init_view)
*/
if (is_materialized_derived())
{
- unit->master_unit()->set_unique_exclude();
+ set_check_materialized();
}
+
/*
Create field translation for mergeable derived tables/views.
For derived tables field translation can be created only after