diff options
author | unknown <sergefp@mysql.com> | 2005-09-09 10:54:59 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2005-09-09 10:54:59 +0400 |
commit | 20994fec52db1d95b085704c424ef5d292c9a307 (patch) | |
tree | d061df624f7dfc9d9b60f22b9a9d7e570f0a819d /sql | |
parent | cf0b4702f568ca76e78e1ac47e0e37e19f1b00f8 (diff) | |
parent | 213fa9cbc234c1a10e50f2bf53b2e1f520284034 (diff) | |
download | mariadb-git-20994fec52db1d95b085704c424ef5d292c9a307.tar.gz |
Merge 4.1->5.0
client/mysqlimport.c:
Auto merged
configure.in:
Auto merged
include/my_global.h:
Auto merged
mysql-test/r/connect.result:
Auto merged
mysql-test/r/func_gconcat.result:
Auto merged
mysql-test/t/connect.test:
Auto merged
mysql-test/t/func_gconcat.test:
Auto merged
ndb/src/kernel/blocks/backup/Backup.cpp:
Auto merged
ndb/src/kernel/blocks/backup/Backup.hpp:
Auto merged
ndb/src/kernel/main.cpp:
Auto merged
ndb/src/mgmsrv/MgmtSrvr.cpp:
Auto merged
ndb/src/mgmsrv/MgmtSrvr.hpp:
Auto merged
ndb/src/ndbapi/Makefile.am:
Auto merged
ndb/test/src/NdbBackup.cpp:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/item_sum.cc | 5 | ||||
-rw-r--r-- | sql/item_sum.h | 1 | ||||
-rw-r--r-- | sql/sql_class.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 17 |
5 files changed, 23 insertions, 8 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 3bbc78f5db8..09a0fa8c357 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -910,7 +910,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(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 17d82e3fc98..4f991615bfa 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2740,7 +2740,9 @@ int dump_leaf_key(byte* key, element_count count __attribute__((unused)), String *result= &item->result; Item **arg= item->args, **arg_end= item->args + item->arg_count_field; - if (result->length()) + if (item->no_appended) + item->no_appended= FALSE; + else result->append(*item->separator); tmp.length(0); @@ -2925,6 +2927,7 @@ void Item_func_group_concat::clear() result.copy(); null_value= TRUE; warning_for_row= FALSE; + no_appended= TRUE; if (tree) reset_tree(tree); /* No need to reset the table as we never call write_row */ diff --git a/sql/item_sum.h b/sql/item_sum.h index 0da9178eabf..8c31cc5952c 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -898,6 +898,7 @@ class Item_func_group_concat : public Item_sum element_count count __attribute__((unused)), Item_func_group_concat *group_concat_item); + bool no_appended; public: Item_func_group_concat(Name_resolution_context *context_arg, bool is_distinct, List<Item> *is_select, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2ff0413e05e..4ed8d61a2be 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -377,14 +377,14 @@ void THD::cleanup(void) mysql_ha_flush(this, (TABLE_LIST*) 0, MYSQL_HA_CLOSE_FINAL | MYSQL_HA_FLUSH_ALL); hash_free(&handler_tables_hash); + delete_dynamic(&user_var_events); + hash_free(&user_vars); close_temporary_tables(this); 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)); - delete_dynamic(&user_var_events); - hash_free(&user_vars); sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); + sp_cache_clear(&sp_func_cache); /*psergey: move to ~THD? */ if (global_read_lock) unlock_global_read_lock(this); if (ull) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bf06599b25e..28afec2f688 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13043,6 +13043,8 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) The function replaces occurrences of group by fields in expr by ref objects for these fields unless they are under aggregate functions. + The function also corrects value of the the maybe_null attribute + for the items of all subexpressions containing group by fields. IMPLEMENTATION The function recursively traverses the tree of the expr expression, @@ -13053,6 +13055,9 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) This substitution is needed GROUP BY queries with ROLLUP if SELECT list contains expressions over group by attributes. + TODO: Some functions are not null-preserving. For those functions + updating of the maybe_null attribute is an overkill. + EXAMPLES SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP SELECT SUM(a)+a FROM t1 GROUP BY a WITH ROLLUP @@ -13074,6 +13079,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, arg != arg_end; arg++) { Item *item= *arg; + bool arg_changed= FALSE; if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM) { ORDER *group_tmp; @@ -13086,15 +13092,20 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, item->name))) return 1; // fatal_error is set thd->change_item_tree(arg, new_item); - *changed= TRUE; + arg_changed= TRUE; } } } else if (item->type() == Item::FUNC_ITEM) { - if (change_group_ref(thd, (Item_func *) item, group_list, changed)) + if (change_group_ref(thd, (Item_func *) item, group_list, &arg_changed)) return 1; } + if (arg_changed) + { + expr->maybe_null= 1; + *changed= TRUE; + } } } return 0; @@ -13157,7 +13168,7 @@ bool JOIN::rollup_init() } if (item->type() == Item::FUNC_ITEM) { - bool changed= 0; + bool changed= FALSE; if (change_group_ref(thd, (Item_func *) item, group_list, &changed)) return 1; /* |