summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-07-13 21:06:28 -0700
committerIgor Babaev <igor@askmonty.org>2011-07-13 21:06:28 -0700
commitff9c406c1d3ac007d0079a4ef16d86b7a8b823bb (patch)
tree0cbb52268a50c48149f87834ebb0b1e3e1d2fd39 /sql
parent7c46dc525e65ce2cde71a9591fc780f44bebc384 (diff)
downloadmariadb-git-ff9c406c1d3ac007d0079a4ef16d86b7a8b823bb.tar.gz
Fixed LP bug #809179.
The attribute not_null_tables could be calculated incorrectly in the function SELECT_LEX::update_used_tables for queries over views with row items in the WHERE clause. It happened because no implementation of the virtual callback function eval_not_null_tables was provided for the class Item_row. Also slightly optimized the code calculating the value of the maybe_null flag for tables in the function SELECT_LEX::update_used_tables.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_row.cc16
-rw-r--r--sql/item_row.h1
-rw-r--r--sql/sql_lex.cc16
3 files changed, 28 insertions, 5 deletions
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 99a1644cc48..09977d71bb7 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -93,6 +93,22 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
}
+bool
+Item_row::eval_not_null_tables(uchar *opt_arg)
+{
+ Item **arg,**arg_end;
+ not_null_tables_cache= 0;
+ if (arg_count)
+ {
+ for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
+ {
+ not_null_tables_cache|= (*arg)->not_null_tables();
+ }
+ }
+ return FALSE;
+}
+
+
void Item_row::cleanup()
{
DBUG_ENTER("Item_row::cleanup");
diff --git a/sql/item_row.h b/sql/item_row.h
index 0b43309391d..1572ef77b79 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -73,6 +73,7 @@ public:
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
Item *transform(Item_transformer transformer, uchar *arg);
+ bool eval_not_null_tables(uchar *opt_arg);
uint cols() { return arg_count; }
Item* element_index(uint i) { return items[i]; }
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 80a80363cc0..c8b5a3439b0 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3472,18 +3472,24 @@ void SELECT_LEX::update_used_tables()
List_iterator<TABLE_LIST> ti(leaf_tables);
while ((tl= ti++))
{
- for (embedding= tl;
- !tl->table->maybe_null && embedding;
- embedding= embedding->embedding)
+ TABLE_LIST *embedding;
+ embedding= tl;
+ do
{
- tl->table->maybe_null= test(embedding->outer_join);
+ bool maybe_null;
+ if ((maybe_null= test(embedding->outer_join)))
+ {
+ tl->table->maybe_null= maybe_null;
+ break;
+ }
}
+ while ((embedding= embedding->embedding));
if (tl->on_expr)
{
tl->on_expr->update_used_tables();
tl->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);
}
- TABLE_LIST *embedding= tl->embedding;
+ embedding= tl->embedding;
while (embedding)
{
if (embedding->on_expr &&