diff options
author | unknown <monty@hundin.mysql.fi> | 2002-05-15 01:01:26 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-05-15 01:01:26 +0300 |
commit | eba5ec8b4bceabab302462db850882f715a7b040 (patch) | |
tree | 3dc97e13fe4695f7d461248693b9267cf1bcc638 /sql | |
parent | 3051d8bbc15ef775dcb549fd00be596d61131fcf (diff) | |
download | mariadb-git-eba5ec8b4bceabab302462db850882f715a7b040.tar.gz |
Fixed bug in datetime range optimization
Docs/manual.texi:
Changelog
mysql-test/r/type_datetime.result:
Test of datetime optimization
mysql-test/t/type_datetime.test:
Test of datetime optimization
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 19 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/sql/item.h b/sql/item.h index 41b897956db..b8903756027 100644 --- a/sql/item.h +++ b/sql/item.h @@ -342,6 +342,25 @@ public: }; +/* + The following class is used to optimize comparing of date columns + We need to save the original item, to be able to set the field to the + original value in 'opt_range'. +*/ + +class Item_int_with_ref :public Item_int +{ + Item *ref; +public: + Item_int_with_ref(longlong i, Item *ref_arg) :Item_int(i), ref(ref_arg) + {} + bool save_in_field(Field *field) + { + return ref->save_in_field(field); + } +}; + + #include "item_sum.h" #include "item_func.h" #include "item_cmpfunc.h" diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 73821f8d826..ae50090fea1 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -45,8 +45,8 @@ static bool convert_constant_item(Field *field, Item **item) (*item)->save_in_field(field); if (!((*item)->null_value)) { - Item *tmp=new Item_int(field->val_int()); - if ((tmp)) + Item *tmp=new Item_int_with_ref(field->val_int(), *item); + if (tmp) *item=tmp; return 1; } |