summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-05-16 15:07:04 +0300
committerMichael Widenius <monty@askmonty.org>2011-05-16 15:07:04 +0300
commit8543621fa0f4a3c4102ac8f799888ef79e2e1dcf (patch)
tree29e8f301ef929cfe1c00eec9dee265aa0acaa350 /sql/sql_base.cc
parentf458e198c0bea67c6a3787738108bbfb139639bd (diff)
parentbcee6652c6052cabd67f8d30c14e162235749d38 (diff)
downloadmariadb-git-8543621fa0f4a3c4102ac8f799888ef79e2e1dcf.tar.gz
Merge with 5.3 main
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index a733ccd0659..eb58b09fd00 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8139,6 +8139,29 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
}
+/**
+ Wrap Item_ident
+
+ @param thd thread handle
+ @param conds pointer to the condition which should be wrapped
+*/
+
+void wrap_ident(THD *thd, Item **conds)
+{
+ Item_direct_ref_to_ident *wrapper;
+ DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM);
+ Query_arena *arena= thd->stmt_arena, backup;
+ if (arena->is_conventional())
+ arena= 0;
+ else
+ thd->set_n_backup_active_arena(arena, &backup);
+ if ((wrapper= new Item_direct_ref_to_ident((Item_ident *)(*conds))))
+ (*conds)= (Item*) wrapper;
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+}
+
+
/*
Fix all conditions and outer join expressions.
@@ -8202,6 +8225,12 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
print_where(*conds,
"WHERE in setup_conds",
QT_ORDINARY););
+ /*
+ Wrap alone field in WHERE clause in case it will be outer field of subquery
+ which need persistent pointer on it, but conds could be changed by optimizer
+ */
+ if ((*conds)->type() == Item::FIELD_ITEM)
+ wrap_ident(thd, conds);
if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
(*conds)->check_cols(1))
goto err_no_arena;