summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2004-08-20 16:32:40 -0700
committerunknown <igor@rurik.mysql.com>2004-08-20 16:32:40 -0700
commit7c46252467101d841de5b7774b4f5b6ddf858d9f (patch)
treef06700cf3a42691a32a4aaadb4f2b67f2f9872a6 /sql/sql_select.cc
parent6bccd36664c09c094bf3281ccdeaf7e8b249f8ef (diff)
parent282ec5bd28ba5739f1fe5754e9031646138f3acf (diff)
downloadmariadb-git-7c46252467101d841de5b7774b4f5b6ddf858d9f.tar.gz
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-4.1
into rurik.mysql.com:/home/igor/mysql-4.1 sql/item_sum.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc46
1 files changed, 30 insertions, 16 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47294402763..fdea963b3ca 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4379,25 +4379,39 @@ COND *eliminate_not_funcs(THD *thd, COND *cond)
static COND *
optimize_cond(THD *thd, COND *conds, Item::cond_result *cond_value)
{
+ SELECT_LEX *select= thd->lex->current_select;
DBUG_ENTER("optimize_cond");
- if (!conds)
+ if (conds)
+ {
+ DBUG_EXECUTE("where", print_where(conds, "original"););
+ /* Eliminate NOT operators; in case of PS/SP do it once */
+ if (thd->current_arena->is_first_stmt_execute())
+ {
+ Item_arena *arena= thd->current_arena, backup;
+ thd->set_n_backup_item_arena(arena, &backup);
+ conds= eliminate_not_funcs(thd, conds);
+ select->prep_where= conds->copy_andor_structure(thd);
+ thd->restore_backup_item_arena(arena, &backup);
+ }
+ else
+ conds= eliminate_not_funcs(thd, conds);
+ DBUG_EXECUTE("where", print_where(conds, "after negation elimination"););
+
+ /* change field = field to field = const for each found field = const */
+ propagate_cond_constants((I_List<COND_CMP> *) 0, conds, conds);
+ /*
+ Remove all instances of item == item
+ Remove all and-levels where CONST item != CONST item
+ */
+ DBUG_EXECUTE("where", print_where(conds, "after const change"););
+ conds= remove_eq_conds(thd, conds, cond_value);
+ DBUG_EXECUTE("info", print_where(conds, "after remove"););
+ }
+ else
{
*cond_value= Item::COND_TRUE;
- DBUG_RETURN(conds);
- }
- DBUG_EXECUTE("where",print_where(conds,"original"););
- /* eliminate NOT operators */
- conds= eliminate_not_funcs(thd, conds);
- DBUG_EXECUTE("where", print_where(conds, "after negation elimination"););
- /* change field = field to field = const for each found field = const */
- propagate_cond_constants((I_List<COND_CMP> *) 0,conds,conds);
- /*
- Remove all instances of item == item
- Remove all and-levels where CONST item != CONST item
- */
- DBUG_EXECUTE("where",print_where(conds,"after const change"););
- conds= remove_eq_conds(thd, conds, cond_value) ;
- DBUG_EXECUTE("info",print_where(conds,"after remove"););
+ select->prep_where= 0;
+ }
DBUG_RETURN(conds);
}