From 1fa7b95d987bb97dc2a4855df1f33ac355b2014a Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 22 Jun 2005 20:00:21 -0700 Subject: [PATCH 01/10] Fix multiplication of abs() by a negative value. (Bug #11402) --- mysql-test/r/func_math.result | 3 +++ mysql-test/t/func_math.test | 5 +++++ sql/item_func.cc | 3 --- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 9cb1e4a56d6..80b15d1d3c8 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -137,3 +137,6 @@ select * from t1; round(1, 6) 1.000000 drop table t1; +select abs(-2) * -2; +abs(-2) * -2 +-4 diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 4c24dae8c5d..11af874380e 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -71,3 +71,8 @@ create table t1 select round(1, 6); show create table t1; select * from t1; drop table t1; + +# +# Bug #11402: abs() forces rest of calculation to unsigned +# +select abs(-2) * -2; diff --git a/sql/item_func.cc b/sql/item_func.cc index 442ef15bba8..657eb374c6f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -914,10 +914,7 @@ void Item_func_abs::fix_length_and_dec() max_length=args[0]->max_length; hybrid_type= REAL_RESULT; if (args[0]->result_type() == INT_RESULT) - { hybrid_type= INT_RESULT; - unsigned_flag= 1; - } } From d4dea98f44c17064a43b582a0371cfae5ad3480a Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 27 Jun 2005 18:03:14 -0700 Subject: [PATCH 02/10] Fix max_connections_per_hour handling when the global max_user_connections is also set. (Bug #9947) --- sql/sql_parse.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2eeae8f7332..be5d6283d65 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -136,7 +136,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, const char *host, USER_RESOURCES *mqh) { - int return_val=0; + int return_val= 0; uint temp_len, user_len; char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; struct user_conn *uc; @@ -144,7 +144,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, DBUG_ASSERT(user != 0); DBUG_ASSERT(host != 0); - user_len=strlen(user); + user_len= strlen(user); temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, @@ -156,25 +156,23 @@ static int get_or_create_user_conn(THD *thd, const char *user, MYF(MY_WME))))) { send_error(thd, 0, NullS); // Out of memory - return_val=1; + return_val= 1; goto end; } uc->user=(char*) (uc+1); memcpy(uc->user,temp_user,temp_len+1); uc->user_len= user_len; - uc->host=uc->user + uc->user_len + 1; - uc->len = temp_len; - uc->connections = 1; - uc->questions=uc->updates=uc->conn_per_hour=0; - uc->user_resources=*mqh; - if (max_user_connections && mqh->connections > max_user_connections) - uc->user_resources.connections = max_user_connections; - uc->intime=thd->thr_create_time; + uc->host= uc->user + uc->user_len + 1; + uc->len= temp_len; + uc->connections= 0; + uc->questions= uc->updates= uc->conn_per_hour=0; + uc->user_resources= *mqh; + uc->intime= thd->thr_create_time; if (my_hash_insert(&hash_user_connections, (byte*) uc)) { my_free((char*) uc,0); send_error(thd, 0, NullS); // Out of memory - return_val=1; + return_val= 1; goto end; } } From 3409537f2a31fc5c1334c2a9d8b5456903fa8166 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 25 Jul 2005 11:25:28 -0700 Subject: [PATCH 03/10] Don't force column header to @@session.var_name if @@local.var_name was used. (Bug #10724) --- mysql-test/r/key_cache.result | 6 +++--- mysql-test/r/ps_1general.result | 2 +- mysql-test/r/user_var.result | 24 ++++++++++++++++++++++++ mysql-test/r/variables.result | 12 ++++++------ mysql-test/t/user_var.test | 21 +++++++++++++++++++++ sql/item_func.cc | 22 ++-------------------- sql/sql_parse.cc | 12 ++++++++++-- 7 files changed, 67 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 79b5a6e84b2..41aaa21eea3 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -23,13 +23,13 @@ SELECT @@global.default.key_buffer_size; @@global.default.key_buffer_size 16777216 SELECT @@global.default.`key_buffer_size`; -@@global.default.key_buffer_size +@@global.default.`key_buffer_size` 16777216 SELECT @@global.`default`.`key_buffer_size`; -@@global.default.key_buffer_size +@@global.`default`.`key_buffer_size` 16777216 SELECT @@`default`.key_buffer_size; -@@default.key_buffer_size +@@`default`.key_buffer_size 16777216 SELECT @@small.key_buffer_size; @@small.key_buffer_size diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 97af043d4f2..c4ccdf9eb34 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -332,7 +332,7 @@ execute stmt1 ; ERROR 42S02: Unknown table 't5' prepare stmt1 from ' SELECT @@version ' ; execute stmt1 ; -@@VERSION +@@version prepare stmt_do from ' do @var:= (1 in (select a from t1)) ' ; prepare stmt_set from ' set @var= (1 in (select a from t1)) ' ; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index e42849abdf1..58b785d1432 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -179,3 +179,27 @@ set session @honk=99; 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 '@honk=99' at line 1 set one_shot @honk=99; ERROR HY000: The SET ONE_SHOT syntax is reserved for purposes internal to the MySQL server +select @@local.max_allowed_packet; +@@local.max_allowed_packet +# +select @@session.max_allowed_packet; +@@session.max_allowed_packet +# +select @@global.max_allowed_packet; +@@global.max_allowed_packet +# +select @@max_allowed_packet; +@@max_allowed_packet +# +select @@Max_Allowed_Packet; +@@Max_Allowed_Packet +# +select @@version; +@@version +# +select @@global.version; +@@global.version +# +select @@session.VERSION; +@@session.VERSION +# diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index e370202cc9f..14260cd04f9 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -70,7 +70,7 @@ Variable_name Value max_join_size HA_POS_ERROR set @@max_join_size=1000, @@global.max_join_size=2000; select @@local.max_join_size, @@global.max_join_size; -@@session.max_join_size @@global.max_join_size +@@local.max_join_size @@global.max_join_size 1000 2000 select @@identity, length(@@version)>0; @@identity length(@@version)>0 @@ -407,23 +407,23 @@ Variable_name Value myisam_max_sort_file_size MAX_FILE_SIZE set global myisam_max_sort_file_size=default; select @@global.max_user_connections,@@local.max_join_size; -@@global.max_user_connections @@session.max_join_size +@@global.max_user_connections @@local.max_join_size 100 200 set @svc=@@global.max_user_connections, @svj=@@local.max_join_size; select @@global.max_user_connections,@@local.max_join_size; -@@global.max_user_connections @@session.max_join_size +@@global.max_user_connections @@local.max_join_size 100 200 set @@global.max_user_connections=111,@@local.max_join_size=222; select @@global.max_user_connections,@@local.max_join_size; -@@global.max_user_connections @@session.max_join_size +@@global.max_user_connections @@local.max_join_size 111 222 set @@global.max_user_connections=@@local.max_join_size,@@local.max_join_size=@@global.max_user_connections; select @@global.max_user_connections,@@local.max_join_size; -@@global.max_user_connections @@session.max_join_size +@@global.max_user_connections @@local.max_join_size 222 111 set @@global.max_user_connections=@svc, @@local.max_join_size=@svj; select @@global.max_user_connections,@@local.max_join_size; -@@global.max_user_connections @@session.max_join_size +@@global.max_user_connections @@local.max_join_size 100 200 set @a=1, @b=2; set @a=@b, @b=@a; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index a288b7ef708..028c110d158 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -119,3 +119,24 @@ select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); set session @honk=99; --error 1105 set one_shot @honk=99; + +# +# Bug #10724 @@local not preserved in column name of select +# +# The value doesn't actually matter, we just care about the column name +--replace_column 1 # +select @@local.max_allowed_packet; +--replace_column 1 # +select @@session.max_allowed_packet; +--replace_column 1 # +select @@global.max_allowed_packet; +--replace_column 1 # +select @@max_allowed_packet; +--replace_column 1 # +select @@Max_Allowed_Packet; +--replace_column 1 # +select @@version; +--replace_column 1 # +select @@global.version; +--replace_column 1 # +select @@session.VERSION; diff --git a/sql/item_func.cc b/sql/item_func.cc index 44917eb48e4..3cff3f5380a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3417,7 +3417,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, if (component.str == 0 && !my_strcasecmp(system_charset_info, name.str, "VERSION")) - return new Item_string("@@VERSION", server_version, + return new Item_string(NULL, server_version, (uint) strlen(server_version), system_charset_info, DERIVATION_SYSCONST); @@ -3444,28 +3444,10 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, } thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - buff[0]='@'; - buff[1]='@'; - pos=buff+2; - if (var_type == OPT_SESSION) - pos=strmov(pos,"session."); - else if (var_type == OPT_GLOBAL) - pos=strmov(pos,"global."); - set_if_smaller(component_name->length, MAX_SYS_VAR_LENGTH); - set_if_smaller(base_name->length, MAX_SYS_VAR_LENGTH); - - if (component_name->str) - { - memcpy(pos, component_name->str, component_name->length); - pos+= component_name->length; - *pos++= '.'; - } - memcpy(pos, base_name->str, base_name->length); - pos+= base_name->length; return new Item_func_get_system_var(var, var_type, component_name, - buff, pos - buff); + NULL, 0); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a3f3ef41dee..dd3c1fa7ba0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4197,6 +4197,8 @@ void create_select_for_variable(const char *var_name) THD *thd; LEX *lex; LEX_STRING tmp, null_lex_string; + Item *var; + char buff[MAX_SYS_VAR_LENGTH*2+4+8], *end; DBUG_ENTER("create_select_for_variable"); thd= current_thd; @@ -4206,8 +4208,14 @@ void create_select_for_variable(const char *var_name) tmp.str= (char*) var_name; tmp.length=strlen(var_name); bzero((char*) &null_lex_string.str, sizeof(null_lex_string)); - add_item_to_list(thd, get_system_var(thd, OPT_SESSION, tmp, - null_lex_string)); + /* + We set the name of Item to @@session.var_name because that then is used + as the column name in the output. + */ + var= get_system_var(thd, OPT_SESSION, tmp, null_lex_string); + end= strxmov(buff, "@@session.", var_name, NullS); + var->set_name(buff, end-buff, system_charset_info); + add_item_to_list(thd, var); DBUG_VOID_RETURN; } From 08faad4a4bfea500ec05611b9c13cb44fa996159 Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Thu, 28 Jul 2005 19:08:01 -0600 Subject: [PATCH 04/10] patch for bug 10780 --- mysql-test/r/rpl_slave_status.result | 23 +++++++++++++++++++++++ sql/slave.cc | 5 +++-- sql/slave.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/rpl_slave_status.result diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result new file mode 100644 index 00000000000..4eb2e87d221 --- /dev/null +++ b/mysql-test/r/rpl_slave_status.result @@ -0,0 +1,23 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl'; +stop slave; +change master to master_user='rpl',master_password='rpl'; +start slave; +drop table if exists t1; +create table t1 (n int); +insert into t1 values (1); +select * from t1; +n +1 +delete from mysql.user where user='rpl'; +flush privileges; +stop slave; +start slave; +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +Connecting to master 127.0.0.1 rpl MASTER_MYPORT 1 master-bin.000001 357 slave-relay-bin.000001 401 master-bin.000001 No Yes 0 0 357 401 None 0 No NULL diff --git a/sql/slave.cc b/sql/slave.cc index f25ad90487a..286bb07e4c9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2186,7 +2186,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi) &my_charset_bin); protocol->store((ulonglong) mi->rli.group_relay_log_pos); protocol->store(mi->rli.group_master_log_name, &my_charset_bin); - protocol->store(mi->slave_running ? "Yes":"No", &my_charset_bin); + protocol->store(mi->slave_running == MYSQL_SLAVE_RUN_CONNECT + ? "Yes":"No", &my_charset_bin); protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin); protocol->store(&replicate_do_db); protocol->store(&replicate_ignore_db); @@ -3078,7 +3079,7 @@ slave_begin: pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); - mi->slave_running = 1; + mi->slave_running = MYSQL_SLAVE_RUN_INIT; mi->abort_slave = 0; pthread_mutex_unlock(&mi->run_lock); pthread_cond_broadcast(&mi->start_cond); diff --git a/sql/slave.h b/sql/slave.h index 5a85e26d9ad..6aa61c3a7e4 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -112,6 +112,7 @@ enum enum_binlog_formats { #define MYSQL_SLAVE_NOT_RUN 0 #define MYSQL_SLAVE_RUN_NOT_CONNECT 1 #define MYSQL_SLAVE_RUN_CONNECT 2 +#define MYSQL_SLAVE_RUN_INIT 3 /**************************************************************************** From 0abc5c941d705a96c8d6706cf4c05f1635c43f06 Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Thu, 28 Jul 2005 19:10:49 -0600 Subject: [PATCH 05/10] testcase for bug 10780 was not added in the previous commit --- mysql-test/t/rpl_slave_status.test | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 mysql-test/t/rpl_slave_status.test diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test new file mode 100644 index 00000000000..6bccf6fd341 --- /dev/null +++ b/mysql-test/t/rpl_slave_status.test @@ -0,0 +1,28 @@ +# Test case for BUG #10780 +source include/master-slave.inc +connection master; +grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl'; +connection slave; +stop slave; +change master to master_user='rpl',master_password='rpl'; +start slave; +connection master; +--disable_warnings +drop table if exists t1; +--enable_warning +create table t1 (n int); +insert into t1 values (1); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +connection master; +delete from mysql.user where user='rpl'; +flush privileges; +connection slave; +stop slave; +start slave; +--replace_result $MASTER_MYPORT MASTER_MYPORT +show slave status; + +# end of 4.1 tests From fa7897c62a6cf831fddb0c7f2d4a36594e8d5c1d Mon Sep 17 00:00:00 2001 From: "sasha@asksasha.com" <> Date: Fri, 29 Jul 2005 21:00:28 -0600 Subject: [PATCH 06/10] updates for BUG#10780 - fixed slave I/O thread running status to No while attempting to connect --- mysql-test/r/rpl_slave_status.result | 35 ++++++++++++++++++++++++++-- mysql-test/t/rpl_slave_status.test | 1 + sql/slave.cc | 2 +- sql/slave.h | 1 - 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result index 4eb2e87d221..5e9b6ab31ad 100644 --- a/mysql-test/r/rpl_slave_status.result +++ b/mysql-test/r/rpl_slave_status.result @@ -19,5 +19,36 @@ flush privileges; stop slave; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -Connecting to master 127.0.0.1 rpl MASTER_MYPORT 1 master-bin.000001 357 slave-relay-bin.000001 401 master-bin.000001 No Yes 0 0 357 401 None 0 No NULL +Slave_IO_State Connecting to master +Master_Host 127.0.0.1 +Master_User rpl +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 357 +Relay_Log_File slave-relay-bin.000001 +Relay_Log_Pos 401 +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 357 +Relay_Log_Space 401 +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master NULL diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index 6bccf6fd341..4e0d7dae35c 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -23,6 +23,7 @@ connection slave; stop slave; start slave; --replace_result $MASTER_MYPORT MASTER_MYPORT +--vertical_results show slave status; # end of 4.1 tests diff --git a/sql/slave.cc b/sql/slave.cc index 286bb07e4c9..a0cc773d44f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3079,7 +3079,7 @@ slave_begin: pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); - mi->slave_running = MYSQL_SLAVE_RUN_INIT; + mi->slave_running = 1; mi->abort_slave = 0; pthread_mutex_unlock(&mi->run_lock); pthread_cond_broadcast(&mi->start_cond); diff --git a/sql/slave.h b/sql/slave.h index 6aa61c3a7e4..5a85e26d9ad 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -112,7 +112,6 @@ enum enum_binlog_formats { #define MYSQL_SLAVE_NOT_RUN 0 #define MYSQL_SLAVE_RUN_NOT_CONNECT 1 #define MYSQL_SLAVE_RUN_CONNECT 2 -#define MYSQL_SLAVE_RUN_INIT 3 /**************************************************************************** From ea7df08c93fed654825baaa532d6752024a3dc46 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 1 Aug 2005 15:43:40 -0700 Subject: [PATCH 07/10] Fix crash in 'SHOW CREATE FUNCTION' introduced by Monty's last cleanup. --- sql/sp_head.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 0c3a6d04598..18cf9f17b88 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1320,7 +1320,6 @@ sp_head::show_create_function(THD *thd) String buffer(buff, sizeof(buff), system_charset_info); int res; List field_list; - sys_var *sql_mode_var; byte *sql_mode_str; ulong sql_mode_len; bool full_access; @@ -1337,8 +1336,7 @@ sp_head::show_create_function(THD *thd) m_sql_mode, &sql_mode_len); field_list.push_back(new Item_empty_string("Function",NAME_LEN)); - if (sql_mode_var) - field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len)); + field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len)); field_list.push_back(new Item_empty_string("Create Function", max(buffer.length(),1024))); if (protocol->send_fields(&field_list, From 4cf8696eae268d6595c825784a624d9146d58967 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 1 Aug 2005 17:00:03 -0700 Subject: [PATCH 08/10] Fix crash in 'INSERT DELAYED' statement that failed due to a conflict in a unique key. (Bug #12226) --- mysql-test/r/delayed.result | 7 +++++++ mysql-test/t/delayed.test | 9 +++++++++ sql/sql_insert.cc | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index e9766622cf6..f8ae61b03fb 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -32,3 +32,10 @@ a b 3 d 4 e drop table t1; +create table t1 (a int not null primary key); +insert into t1 values (1); +insert delayed into t1 values (1); +select * from t1; +a +1 +drop table t1; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 3030ac20304..ca34cc020f3 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -38,3 +38,12 @@ select * from t1; drop table t1; # End of 4.1 tests + +# +# Bug #12226: Crash when a delayed insert fails due to a duplicate key +# +create table t1 (a int not null primary key); +insert into t1 values (1); +insert delayed into t1 values (1); +select * from t1; +drop table t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 125390e4411..27342287fcd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1088,7 +1088,9 @@ ok_or_after_trg_err: err: info->last_errno= error; - thd->lex->current_select->no_error= 0; // Give error + /* current_select is NULL if this is a delayed insert */ + if (thd->lex->current_select) + thd->lex->current_select->no_error= 0; // Give error table->file->print_error(error,MYF(0)); before_trg_err: From fb903c1e2c9026eb58dc1725014f07ca2475cfd4 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 1 Aug 2005 19:21:56 -0700 Subject: [PATCH 09/10] Fix two test results that were merged out-of-order. --- mysql-test/r/func_math.result | 10 ++++++++ mysql-test/r/user_var.result | 48 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index c84b26ce24e..0149911e36b 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -152,6 +152,16 @@ ceil(0.09) select ceil(0.000000000000000009); ceil(0.000000000000000009) 1 +create table t1 select round(1, 6); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `round(1, 6)` decimal(7,6) NOT NULL default '0.000000' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +round(1, 6) +1.000000 +drop table t1; select abs(-2) * -2; abs(-2) * -2 -4 diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 893e024719b..acdc793fb69 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -183,6 +183,30 @@ set session @honk=99; 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 '@honk=99' at line 1 set one_shot @honk=99; ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL server +select @@local.max_allowed_packet; +@@local.max_allowed_packet +# +select @@session.max_allowed_packet; +@@session.max_allowed_packet +# +select @@global.max_allowed_packet; +@@global.max_allowed_packet +# +select @@max_allowed_packet; +@@max_allowed_packet +# +select @@Max_Allowed_Packet; +@@Max_Allowed_Packet +# +select @@version; +@@version +# +select @@global.version; +@@global.version +# +select @@session.VERSION; +@@session.VERSION +# set @first_var= NULL; create table t1 select @first_var; show create table t1; @@ -224,27 +248,3 @@ t1 CREATE TABLE `t1` ( `@first_var` longtext ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -select @@local.max_allowed_packet; -@@local.max_allowed_packet -# -select @@session.max_allowed_packet; -@@session.max_allowed_packet -# -select @@global.max_allowed_packet; -@@global.max_allowed_packet -# -select @@max_allowed_packet; -@@max_allowed_packet -# -select @@Max_Allowed_Packet; -@@Max_Allowed_Packet -# -select @@version; -@@version -# -select @@global.version; -@@global.version -# -select @@session.VERSION; -@@session.VERSION -# From 9217c90a771c85928a2fd76511a508794c4e93cd Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 2 Aug 2005 13:59:02 +0200 Subject: [PATCH 10/10] - Fixed the Requires: tag for the server RPM (BUG#12233), make sure to list all required commands/packages so the installation succeeds. Removed the superflouus Requires field from the source RPM. --- support-files/mysql.spec.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index e4cd3027b8a..3c58e642a1d 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -29,7 +29,6 @@ Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql URL: http://www.mysql.com/ Packager: Lenz Grimmer Vendor: MySQL AB -Requires: fileutils sh-utils Provides: msqlormysql MySQL-server mysql BuildRequires: ncurses-devel Obsoletes: mysql @@ -60,7 +59,7 @@ documentation and the manual for more information. %package server Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases -Requires: fileutils sh-utils +Requires: coreutils grep procps /usr/sbin/useradd /usr/sbin/groupadd /sbin/chkconfig Provides: msqlormysql mysql-server mysql MySQL Obsoletes: MySQL mysql mysql-server @@ -669,6 +668,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Tue Aug 02 2005 Lenz Grimmer + +- Fixed the Requires: tag for the server RPM (BUG 12233) + * Fri Jul 15 2005 Lenz Grimmer - create a "mysql" user group and assign the mysql user account to that group