From c64c108eda29fbcb397a694056708261f2891916 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Mar 2006 17:58:01 +0400 Subject: [PATCH 1/3] Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE) union.result, union.test: Adding test case. item.cc: Allow safe character set conversion in UNION - string constant to column's charset - to unicode Thus, UNION now works the same with CONCAT (and other string functions) in respect of aggregating arguments with different character sets. sql/item.cc: Allow character set conversion in UNION - string to column's charset - to unicode Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE) mysql-test/t/union.test: Adding test case. mysql-test/r/union.result: Adding test case. --- mysql-test/r/union.result | 12 +++++++++++- mysql-test/t/union.test | 11 ++++++++++- sql/item.cc | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index a9b2345d834..d01ce6249f7 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1185,6 +1185,16 @@ select concat('value is: ', @val) union select 'some text'; concat('value is: ', @val) value is: 6 some text +select concat(_latin1'a', _ascii'b' collate ascii_bin); +concat(_latin1'a', _ascii'b' collate ascii_bin) +ab +create table t1 (foo varchar(100)) collate ascii_bin; +insert into t1 (foo) values ("foo"); +select foo from t1 union select 'bar' as foo from dual; +foo +foo +bar +drop table t1; CREATE TABLE t1 ( a ENUM('ä','ö','ü') character set utf8 not null default 'ü', b ENUM("one", "two") character set utf8, @@ -1214,7 +1224,7 @@ Field Type Null Key Default Extra a char(1) drop table t2; create table t2 select a from t1 union select c from t1; -ERROR HY000: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation 'UNION' +drop table t2; create table t2 select a from t1 union select b from t1; show columns from t2; Field Type Null Key Default Extra diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 1f6fc2c8d3b..994546e9d97 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -710,6 +710,15 @@ drop table t1; set @val:=6; select concat('value is: ', @val) union select 'some text'; +# +# Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE) +# +select concat(_latin1'a', _ascii'b' collate ascii_bin); +create table t1 (foo varchar(100)) collate ascii_bin; +insert into t1 (foo) values ("foo"); +select foo from t1 union select 'bar' as foo from dual; +drop table t1; + # # Enum merging test # @@ -729,8 +738,8 @@ drop table t2; create table t2 select a from t1 union select a from t1; show columns from t2; drop table t2; --- error 1267 create table t2 select a from t1 union select c from t1; +drop table t2; create table t2 select a from t1 union select b from t1; show columns from t2; drop table t2, t1; diff --git a/sql/item.cc b/sql/item.cc index f996e962cca..5964ed388c6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3258,7 +3258,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item) const char *old_cs, *old_derivation; old_cs= collation.collation->name; old_derivation= collation.derivation_name(); - if (collation.aggregate(item->collation)) + if (collation.aggregate(item->collation, MY_COLL_ALLOW_CONV)) { my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), old_cs, old_derivation, From a127344a6c6954012c5d750e07927501f40d907b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Mar 2006 18:26:39 +0100 Subject: [PATCH 2/3] kill (subquery) - three years old bugfix that never worked --- mysql-test/r/kill.result | 2 ++ mysql-test/t/kill.test | 3 +++ sql/sql_yacc.yy | 17 +++++++---------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index ba9ba2833f6..7e38311a556 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -17,3 +17,5 @@ select 4; 4 4 drop table t1; +kill (select count(*) from mysql.user); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from mysql.user)' at line 1 diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index aada8dd2ef3..e9136ce49b4 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -40,4 +40,7 @@ connection con2; select 4; drop table t1; +--error 1064 +kill (select count(*) from mysql.user); + # End of 4.1 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c99abc7d349..05d95b57abb 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3564,9 +3564,8 @@ select_derived2: { LEX *lex= Lex; lex->derived_tables= 1; - if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN && - lex->sql_command <= (int)SQLCOM_HA_READ) || - lex->sql_command == (int)SQLCOM_KILL) + if (lex->sql_command == (int)SQLCOM_HA_READ || + lex->sql_command == (int)SQLCOM_KILL) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; @@ -4739,16 +4738,15 @@ purge_option: /* kill threads */ kill: - KILL_SYM expr + KILL_SYM { Lex->sql_command= SQLCOM_KILL; } expr { LEX *lex=Lex; - if ($2->fix_fields(lex->thd, 0, &$2) || $2->check_cols(1)) + if ($3->fix_fields(lex->thd, 0, &$3) || $3->check_cols(1)) { send_error(lex->thd, ER_SET_CONSTANTS_ONLY); YYABORT; } - lex->sql_command=SQLCOM_KILL; - lex->thread_id= (ulong) $2->val_int(); + lex->thread_id= (ulong) $3->val_int(); }; /* change database */ @@ -6162,9 +6160,8 @@ subselect_start: '(' SELECT_SYM { LEX *lex=Lex; - if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN && - lex->sql_command <= (int)SQLCOM_HA_READ) || - lex->sql_command == (int)SQLCOM_KILL) + if (lex->sql_command == (int)SQLCOM_HA_READ || + lex->sql_command == (int)SQLCOM_KILL) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; From 502b30735857df97a3ca2e652b3a32375d122507 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Mar 2006 22:08:29 +0100 Subject: [PATCH 3/3] compilation fixes BitKeeper/etc/ignore: Added include/openssl to the ignore list --- .bzrignore | 1 + libmysqld/lib_sql.cc | 51 +++++++++++++++++++------------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.bzrignore b/.bzrignore index a16ed70a812..e521692f6c2 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1274,3 +1274,4 @@ vio/viotest.cpp zlib/*.ds? zlib/*.vcproj scripts/mysql_upgrade +include/openssl diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index e4c9d8cb4e9..a2fdae994b1 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -38,6 +38,7 @@ int check_user(THD *thd, enum enum_server_command command, const char *passwd, uint passwd_len, const char *db, bool check_count); C_MODE_START + #include #undef ER #include "errmsg.h" @@ -46,19 +47,6 @@ C_MODE_START static my_bool emb_read_query_result(MYSQL *mysql); -void THD::clear_data_list() -{ - while (first_data) - { - MYSQL_DATA *data= first_data; - first_data= data->embedded_info->next; - free_rows(data); - } - data_tail= &first_data; - free_rows(cur_data); - cur_data= 0; -} - /* Reads error information from the MYSQL_DATA and puts @@ -423,15 +411,6 @@ MYSQL_METHODS embedded_methods= emb_read_rows_from_cursor }; -C_MODE_END - -void THD::clear_error() -{ - net.last_error[0]= 0; - net.last_errno= 0; - net.report_error= 0; -} - /* Make a copy of array and the strings array points to */ @@ -458,11 +437,7 @@ char **copy_arguments(int argc, char **argv) return res; } - -extern "C" -{ - -char ** copy_arguments_ptr= 0; +char ** copy_arguments_ptr= 0; int init_embedded_server(int argc, char **argv, char **groups) { @@ -571,9 +546,7 @@ void end_embedded_server() clean_up(0); } -} /* extern "C" */ -C_MODE_START void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db) { THD *thd = (THD *)mysql->thd; @@ -693,6 +666,26 @@ err: C_MODE_END +void THD::clear_data_list() +{ + while (first_data) + { + MYSQL_DATA *data= first_data; + first_data= data->embedded_info->next; + free_rows(data); + } + data_tail= &first_data; + free_rows(cur_data); + cur_data= 0; +} + +void THD::clear_error() +{ + net.last_error[0]= 0; + net.last_errno= 0; + net.report_error= 0; +} + static char *dup_str_aux(MEM_ROOT *root, const char *from, uint length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) {