From afbdcd413adf6ff5b15de0e9c5d332aecf66850e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Sep 2005 22:57:27 +0200 Subject: [PATCH 1/2] BUG#12695: Item_func_isnull::update_used_tables did not update const_item_cache --- mysql-test/r/group_by.result | 9 +++++++++ mysql-test/t/group_by.test | 10 ++++++++++ sql/item_cmpfunc.h | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 8287a042d60..4ad28091164 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -764,3 +764,12 @@ select date(left(f1+0,8)) from t1 group by 1; date(left(f1+0,8)) 2005-06-06 drop table t1; +create table t1(f1 varchar(5) key); +insert into t1 values (1),(2); +select sql_buffer_result max(f1) is null from t1; +max(f1) is null +0 +select sql_buffer_result max(f1)+1 from t1; +max(f1)+1 +3 +drop table t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 815da66c717..f14fab2d30e 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -600,4 +600,14 @@ insert into t1 values('2005-06-06'); select date(left(f1+0,8)) from t1 group by 1; drop table t1; +# +# BUG#12695: Item_func_isnull::update_used_tables +# did not update const_item_cache +# +create table t1(f1 varchar(5) key); +insert into t1 values (1),(2); +select sql_buffer_result max(f1) is null from t1; +select sql_buffer_result max(f1)+1 from t1; +drop table t1; + # End of 4.1 tests diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 47884f6064e..bb4759918ff 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -805,7 +805,7 @@ public: else { args[0]->update_used_tables(); - if (!(used_tables_cache=args[0]->used_tables())) + if ((const_item_cache= !(used_tables_cache= args[0]->used_tables()))) { /* Remember if the value is always NULL or never NULL */ cached_value= (longlong) args[0]->is_null(); From f32088a94188f5baf4acea10067643d9352c6d23 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2005 11:43:26 +0400 Subject: [PATCH 2/2] Post-merge fixes. Call sp_cache_clear in THD::cleanup. --- sql/sql_class.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4ed8d61a2be..975014b9780 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -383,8 +383,10 @@ void THD::cleanup(void) my_free((char*) variables.time_format, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) variables.date_format, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) variables.datetime_format, MYF(MY_ALLOW_ZERO_PTR)); + sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); /*psergey: move to ~THD? */ + sp_cache_clear(&sp_func_cache); + if (global_read_lock) unlock_global_read_lock(this); if (ull) @@ -424,9 +426,6 @@ THD::~THD() ha_close_connection(this); - sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); - DBUG_PRINT("info", ("freeing host")); if (host != my_localhost) // If not pointer to constant safeFree(host);