diff options
author | unknown <konstantin@mysql.com> | 2004-08-21 02:08:20 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-08-21 02:08:20 +0400 |
commit | 282ec5bd28ba5739f1fe5754e9031646138f3acf (patch) | |
tree | 03d527868f0af6ab03ac466e054bd64503da4a0e /sql/sql_select.cc | |
parent | ae99cc1f6707acd839a1e45edaf69202080411b5 (diff) | |
parent | 095b686c09f5c143abbfb99839c1d1e2810a5a35 (diff) | |
download | mariadb-git-282ec5bd28ba5739f1fe5754e9031646138f3acf.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/kostja/work/mysql-4.1-4912
sql/item_cmpfunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a5cd3dc4f87..86e8cec7cb4 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); } |