From 624f855e948c374bda73f0594e4be9090dd90be0 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 23 Feb 2005 17:58:20 -0800 Subject: [PATCH 1/3] Make sure that warning message when GROUP_CONCAT() cuts values is also updated with the correct number of lines. (Bug #8681) --- mysql-test/r/join_outer.result | 19 +++++++++++++++++++ mysql-test/t/join_outer.test | 11 +++++++++++ sql/item_sum.cc | 23 +++++++++++++++-------- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index c045aa0d00a..1d15b2ba070 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -816,3 +816,22 @@ id text_id text_data 1 0 0-SV 2 10 10-SV DROP TABLE invoice, text_table; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 2 line(s) were cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 2 line(s) were cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index d177a68e685..62e76525d84 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -582,3 +582,14 @@ SELECT invoice.id, invoice.text_id, text_table.text_data WHERE (invoice.id LIKE '%' OR text_table.text_data LIKE '%'); DROP TABLE invoice, text_table; + +# Bug #8681: Bad warning message when group_concat() exceeds max length +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +drop table t1, t2; +set group_concat_max_len=default; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 6bd2cc00b3e..7e9c5d09136 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1787,16 +1787,26 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, void Item_func_group_concat::cleanup() { + THD *thd= current_thd; + DBUG_ENTER("Item_func_group_concat::cleanup"); Item_sum::cleanup(); + /* Adjust warning message to include total number of cut values */ + if (warning) + { + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values); + warning->set_msg(thd, warn_buff); + warning= 0; + } + /* Free table and tree if they belong to this item (if item have not pointer to original item from which was made copy => it own its objects ) */ if (!original) { - THD *thd= current_thd; if (table) { free_tmp_table(thd, table); @@ -1809,13 +1819,6 @@ void Item_func_group_concat::cleanup() tree_mode= 0; delete_tree(tree); } - if (warning) - { - char warn_buff[MYSQL_ERRMSG_SIZE]; - sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values); - warning->set_msg(thd, warn_buff); - warning= 0; - } } DBUG_VOID_RETURN; } @@ -2076,6 +2079,10 @@ String* Item_func_group_concat::val_str(String* str) if (null_value) return 0; if (count_cut_values && !warning) + /* + ER_CUT_VALUE_GROUP_CONCAT needs an argument, but this gets set in + Item_func_group_concat::cleanup(). + */ warning= push_warning(item_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_CUT_VALUE_GROUP_CONCAT, ER(ER_CUT_VALUE_GROUP_CONCAT)); From 9c86b351945af4e3cde4e48a33394a268c16429a Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 28 Mar 2005 09:59:41 -0800 Subject: [PATCH 2/3] Fix reconnect when using prepared statements, and add --disable_reconnect and --enable_reconnect to mysqltest so that it can be tested properly. (Bug #8866) --- client/mysqltest.c | 9 +++++++++ mysql-test/r/kill.result | 8 ++++++++ mysql-test/t/kill.test | 13 ++++++++----- sql-common/client.c | 27 +++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 042f84dfb9e..1c102bc1073 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -280,6 +280,7 @@ Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_START_TIMER, Q_END_TIMER, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, +Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -365,6 +366,8 @@ const char *command_names[]= "character_set", "disable_ps_protocol", "enable_ps_protocol", + "disable_reconnect", + "enable_reconnect", 0 }; @@ -3624,6 +3627,12 @@ int main(int argc, char **argv) case Q_ENABLE_PS_PROTOCOL: ps_protocol_enabled= ps_protocol; break; + case Q_DISABLE_RECONNECT: + cur_con->mysql.reconnect= 0; + break; + case Q_ENABLE_RECONNECT: + cur_con->mysql.reconnect= 1; + break; default: processed = 0; break; } diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index 788fab8d31a..dcf17e4bf52 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -5,6 +5,14 @@ select ((@id := kill_id) - kill_id) from t1; ((@id := kill_id) - kill_id) 0 kill @id; +select 1; +ERROR HY000: MySQL server has gone away +select ((@id := kill_id) - kill_id) from t1; +((@id := kill_id) - kill_id) +0 +select @id != connection_id(); +@id != connection_id() +1 select 4; 4 4 diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 65d4f27059f..4afb60a7bdd 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -23,12 +23,15 @@ connection con2; select ((@id := kill_id) - kill_id) from t1; kill @id; -# Wait for thread to do. ---sleep 5 -# verify that con1 is doning a reconnect connection con1; -ping -ping + +--disable_reconnect +# this statement should fail +--error 2006 +select 1; +--enable_reconnect +# this should work, and we should have a new connection_id() +select ((@id := kill_id) - kill_id) from t1; select @id != connection_id(); #make sure the server is still alive diff --git a/sql-common/client.c b/sql-common/client.c index 3de2483ef75..b1455f0976a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2189,6 +2189,29 @@ my_bool mysql_reconnect(MYSQL *mysql) DBUG_RETURN(1); } tmp_mysql.free_me= mysql->free_me; + + /* + For each stmt in mysql->stmts, move it to tmp_mysql if it is + in state MYSQL_STMT_INIT_DONE, otherwise close it. + */ + { + LIST *element= mysql->stmts; + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + } + else + { + tmp_mysql.stmts= list_add(tmp_mysql.stmts, &stmt->list); + } + /* No need to call list_delete for statement here */ + } + mysql->stmts= NULL; + } + /* Don't free options as these are now used in tmp_mysql */ bzero((char*) &mysql->options,sizeof(mysql->options)); mysql->free_me=0; @@ -2277,6 +2300,10 @@ static void mysql_close_free(MYSQL *mysql) SYNOPSYS mysql_detach_stmt_list() stmt_list pointer to mysql->stmts + + NOTE + There is similar code in mysql_reconnect(), so changes here + should also be reflected there. */ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused))) From 9e16f121455042848dd5234b46bd9ef076798dfd Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 1 Apr 2005 16:09:20 -0800 Subject: [PATCH 3/3] Fix handling of max_allowed_packet and net_buffer_length in embedded server when a size suffix (K, M, G) is added. (Bug #9472) --- sql/mysqld.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d75efbd0b00..0590333a20f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5916,16 +5916,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), sf_malloc_mem_limit = atoi(argument); #endif break; -#ifdef EMBEDDED_LIBRARY - case OPT_MAX_ALLOWED_PACKET: - max_allowed_packet= atoi(argument); - global_system_variables.max_allowed_packet= max_allowed_packet; - break; - case OPT_NET_BUFFER_LENGTH: - net_buffer_length= atoi(argument); - global_system_variables.net_buffer_length= net_buffer_length; - break; -#endif #include case 'V': print_version(); @@ -6477,6 +6467,9 @@ static void get_options(int argc,char **argv) #ifndef EMBEDDED_LIBRARY if (mysqld_chroot) set_root(mysqld_chroot); +#else + max_allowed_packet= global_system_variables.max_allowed_packet; + net_buffer_length= global_system_variables.net_buffer_length; #endif fix_paths();