diff options
author | igor@rurik.mysql.com <> | 2003-06-30 09:52:30 -0700 |
---|---|---|
committer | igor@rurik.mysql.com <> | 2003-06-30 09:52:30 -0700 |
commit | fb461728802835be3a0f05876a5a6962ff4f59e4 (patch) | |
tree | 2e26047124198eb4e44c50a1eb23cbe831cc064e | |
parent | 9a446b97973b64dae7c8d5721eee4d2fe29eff03 (diff) | |
download | mariadb-git-fb461728802835be3a0f05876a5a6962ff4f59e4.tar.gz |
item_cmpfunc.h, opt_range.cc:
Added inequality predicate to range optimization
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/opt_range.cc | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 549839b4f96..8ae987c5498 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -238,7 +238,7 @@ public: longlong val_int(); enum Functype functype() const { return NE_FUNC; } cond_result eq_cmp_result() const { return COND_FALSE; } - optimize_type select_optimize() const { return OPTIMIZE_NONE; } + optimize_type select_optimize() const { return OPTIMIZE_KEY; } const char *func_name() const { return "<>"; } }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 6c1c49e23fc..a3af2bde449 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -880,10 +880,17 @@ static SEL_TREE * get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value, Item_result cmp_type) { + bool ne_func= FALSE; DBUG_ENTER("get_mm_parts"); if (field->table != param->table) DBUG_RETURN(0); + if (type == Item_func::NE_FUNC) + { + ne_func= TRUE; + type= Item_func::LT_FUNC; + } + KEY_PART *key_part = param->key_parts,*end=param->key_parts_end; SEL_TREE *tree=0; if (value && @@ -913,6 +920,14 @@ get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value, tree->keys[key_part->key]=sel_add(tree->keys[key_part->key],sel_arg); } } + + if (ne_func) + { + SEL_TREE *tree2= get_mm_parts(param, field, Item_func::GT_FUNC, + value, cmp_type); + if (tree2) + tree= tree=tree_or(param,tree,tree2); + } DBUG_RETURN(tree); } |