From 19bc36241ac8d572265b159de6348db5443e1eaf Mon Sep 17 00:00:00 2001 From: "venu@hundin.mysql.fi" <> Date: Wed, 2 Jul 2003 10:49:07 +0300 Subject: [PATCH 1/4] Removed dbug.h inclussion from client/get_password.c (windows build fix) --- client/get_password.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/get_password.c b/client/get_password.c index 9928d24de32..f187c113644 100644 --- a/client/get_password.c +++ b/client/get_password.c @@ -23,7 +23,6 @@ #include "mysql.h" #include #include -#include #if defined(HAVE_BROKEN_GETPASS) && !defined(HAVE_GETPASSPHRASE) #undef HAVE_GETPASS From feb425a9f21f10068116c0c59670fc953e0c459e Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 2 Jul 2003 14:45:35 +0300 Subject: [PATCH 2/4] fixed bug, which lead to crash mysqld by running 'mysql some_db_with_tables' --- sql/item.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 3ea537a19de..9b3e367ccff 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -50,7 +50,13 @@ Item::Item(): next= thd->free_list; // Put in free list thd->free_list= this; loop_id= 0; - if (thd->lex.current_select->parsing_place == SELECT_LEX_NODE::SELECT_LIST) + /* + Item constractor can be called during execution other tnec SQL_COM + command => we should check thd->lex.current_select on zero (thd->lex + can be uninitialized) + */ + if (thd->lex.current_select && + thd->lex.current_select->parsing_place == SELECT_LEX_NODE::SELECT_LIST) thd->lex.current_select->select_items++; } From 5cd54c6945e1e0edeb3a6a8474f1dc3134fd3bd9 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Wed, 2 Jul 2003 15:03:49 +0300 Subject: [PATCH 3/4] fixed typos --- sql/item.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 9b3e367ccff..072dec4e6a6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -51,9 +51,9 @@ Item::Item(): thd->free_list= this; loop_id= 0; /* - Item constractor can be called during execution other tnec SQL_COM + Item constructor can be called during execution other tnen SQL_COM command => we should check thd->lex.current_select on zero (thd->lex - can be uninitialized) + can be uninitialised) */ if (thd->lex.current_select && thd->lex.current_select->parsing_place == SELECT_LEX_NODE::SELECT_LIST) From 74b74ad5e7e3e7a350fbc26ad6c91abb783662e3 Mon Sep 17 00:00:00 2001 From: "bar@bar.mysql.r18.ru" <> Date: Wed, 2 Jul 2003 18:34:43 +0500 Subject: [PATCH 4/4] There is no Item->binary() anymore. It was remain from 4.0. --- sql/item.h | 3 --- sql/item_cmpfunc.cc | 11 +++-------- sql/item_cmpfunc.h | 2 -- sql/item_func.cc | 13 ++++++++++++- sql/item_strfunc.cc | 2 +- sql/sql_analyse.cc | 6 ------ sql/sql_analyse.h | 5 +---- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/sql/item.h b/sql/item.h index e80648b89de..57061221878 100644 --- a/sql/item.h +++ b/sql/item.h @@ -185,9 +185,6 @@ public: collation.collation= collation_arg->collation; collation.derivation= collation_arg->derivation; } - bool binary() const - { return charset()->state & MY_CS_BINSORT ? 1 : 0 ; } - virtual void set_outer_resolving() {} // Row emulation diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index e3586fef260..a19311cd2fe 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -380,12 +380,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables, return 1; if (args[0]->maybe_null) maybe_null=1; - /* - TODO: Check if following is right - (set_charset set type of result, not how compare should be used) - */ - if (args[0]->binary()) - set_charset(&my_charset_bin); + with_sum_func= args[0]->with_sum_func; used_tables_cache= args[0]->used_tables(); const_item_cache= args[0]->const_item(); @@ -933,7 +928,7 @@ Item *Item_func_case::find_item(String *str) if ((tmp=args[i]->val_str(str))) // If not null { /* QQ: COERCIBILITY */ - if (first_expr_is_binary || args[i]->binary()) + if (first_expr_is_binary || (args[i]->charset()->state & MY_CS_BINSORT)) { if (sortcmp(tmp,first_expr_str,&my_charset_bin)==0) return args[i+1]; @@ -1044,7 +1039,7 @@ Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) used_tables_cache|=(first_expr)->used_tables(); const_item_cache&= (first_expr)->const_item(); with_sum_func= with_sum_func || (first_expr)->with_sum_func; - first_expr_is_binary= first_expr->binary(); + first_expr_is_binary= first_expr->charset()->state & MY_CS_BINSORT; } if (else_expr) { diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 1311cae335f..1d93c9b6892 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -129,8 +129,6 @@ public: bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; } void print(String *str) { Item_func::print_op(str); } bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } - virtual bool binary() const - { return test(cmp_collation.collation->state & MY_CS_BINSORT); } static Item_bool_func2* eq_creator(Item *a, Item *b); static Item_bool_func2* ne_creator(Item *a, Item *b); diff --git a/sql/item_func.cc b/sql/item_func.cc index d7237f55522..41daa09521c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1353,7 +1353,18 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, Item *item= *arg; if (item->fix_fields(thd, tables, arg) || item->check_cols(1)) return 1; - if (item->binary()) + /* + TODO: We should think about this. It is not always + right way just to set an UDF result to return my_charset_bin + if one argument has binary sorting order. + The result collation should be calculated according to arguments + derivations in some cases and should not in other cases. + Moreover, some arguments can represent a numeric input + which doesn't effect the result character set and collation. + There is no a general rule for UDF. Everything depends on + the particular user definted function. + */ + if (item->charset()->state & MY_CS_BINSORT) func->set_charset(&my_charset_bin); if (item->maybe_null) func->maybe_null=1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ae63ac85d4d..cbfe98bfd21 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -748,7 +748,7 @@ String *Item_func_replace::val_str(String *str) res->set_charset(collation.collation); #ifdef USE_MB - binary_cmp = (args[0]->binary() || args[1]->binary() || !use_mb(res->charset())); + binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !use_mb(res->charset())); #endif if (res2->length() == 0) diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 1b1f7c75c26..ced5993e293 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -44,12 +44,6 @@ int sortcmp2(void* cmp_arg __attribute__((unused)), return sortcmp(a,b,a->charset()); } -int stringcmp2(void* cmp_arg __attribute__((unused)), - const String *a,const String *b) -{ - return sortcmp(a,b,&my_charset_bin); -} - int compare_double2(void* cmp_arg __attribute__((unused)), const double *s, const double *t) { diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 2087e6b2b75..3d1cffecaef 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -99,8 +99,6 @@ int collect_string(String *element, element_count count, int sortcmp2(void* cmp_arg __attribute__((unused)), const String *a,const String *b); -int stringcmp2(void* cmp_arg __attribute__((unused)), - const String *a,const String *b); class field_str :public field_info { @@ -117,8 +115,7 @@ public: max_arg("",default_charset_info), sum(0), must_be_blob(0), was_zero_fill(0), was_maybe_zerofill(0), can_be_still_num(1) - { init_tree(&tree, 0, 0, sizeof(String), a->binary() ? - (qsort_cmp2) stringcmp2 : (qsort_cmp2) sortcmp2, + { init_tree(&tree, 0, 0, sizeof(String), (qsort_cmp2) sortcmp2, 0, (tree_element_free) free_string, NULL); }; void add();