diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index 431c0efdaa0..865475cb56c 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -17,7 +17,7 @@ EXPORTS dynstr_append_mem init_dynamic_string dynstr_free - hash_free + my_hash_free my_vsnprintf dynstr_append my_close @@ -31,7 +31,7 @@ EXPORTS fn_format dirname_part my_hash_insert - hash_search + my_hash_search test_if_hard_path my_copy my_mkdir @@ -54,7 +54,7 @@ EXPORTS my_thread_stack_size my_safe_print_str my_stat - _hash_init + _my_hash_init pthread_attr_setstacksize pthread_attr_init my_dirend diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 12e6c9bb492..6f4ae965ca0 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1848,3 +1848,35 @@ select hex(_utf8 B'001111111111'); ERROR HY000: Invalid utf8 character string: 'FF' select (_utf8 X'616263FF'); ERROR HY000: Invalid utf8 character string: 'FF' +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL); +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +ALTER TABLE t1 ADD UNIQUE (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +DROP INDEX b ON t1; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +ALTER TABLE t1 ADD INDEX (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/wait_timeout_func.result b/mysql-test/r/wait_timeout_func.result index 35fe10a1889..01b4a71df87 100644 --- a/mysql-test/r/wait_timeout_func.result +++ b/mysql-test/r/wait_timeout_func.result @@ -1,30 +1,32 @@ -drop table if exists t1; -## Creating new table t1 ## -CREATE TABLE t1 -( -id INT NOT NULL auto_increment, -PRIMARY KEY (id), -name VARCHAR(30) -); +SET @start_value= @@global.wait_timeout; '#--------------------FN_DYNVARS_186_01-------------------------#' -## Creating new connection test_con1 ## -## Setting value of variable to 5 ## -SET @@session.wait_timeout = 5; -## Inserting record in table t1 ## -INSERT into t1(name) values('Record_1'); -## Using sleep to check timeout ## -'#--------------------FN_DYNVARS_186_02-------------------------#' -## Setting value of variable ## -SET @@global.wait_timeout = 5; -## Creating new connection test_con2 ## -INSERT into t1(name) values('Record_2'); -## Using sleep to check timeout ## +SET @start_time= UNIX_TIMESTAMP(); +connect (test_con1, localhost, root,,); +SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; +Expect 1 +1 +SET @@session.wait_timeout = ; +connect (test_con2, localhost, root,,); +SET @@session.wait_timeout = - 1; +connection default; +wait until connections ready +SELECT info FROM information_schema.processlist; +info +SELECT info FROM information_schema.processlist '#--------------------FN_DYNVARS_186_03-------------------------#' -## Setting value of variable to 1 ## -SET @@global.wait_timeout = 1; -## Creating new connection ## -INSERT into t1(name) values('Record_3'); -## Using sleep to check timeout ## -## We cannot test it further because the server stops due to wait_timeout ## -SELECT * from t1; -ERROR HY000: MySQL server has gone away +SET @@global.wait_timeout= ; +SELECT @@session.wait_timeout = @start_value AS 'Expect 1'; +Expect 1 +1 +connect (test_con3, localhost, root,,); +SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; +Expect 1 +1 +connection default; +SELECT info FROM information_schema.processlist; +info +SELECT info FROM information_schema.processlist +SELECT UNIX_TIMESTAMP() - @start_time >= + ;; +UNIX_TIMESTAMP() - @start_time >= + ; +1 +SET @@global.wait_timeout= @start_value; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 2e23ac3661c..f0c769251cf 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1439,3 +1439,20 @@ select hex(_utf8 X'616263FF'); select hex(_utf8 B'001111111111'); --error ER_INVALID_CHARACTER_STRING select (_utf8 X'616263FF'); + +# +# Bug #36772: When using UTF8, CONVERT with GROUP BY returns truncated results +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL); +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +ALTER TABLE t1 ADD UNIQUE (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +DROP INDEX b ON t1; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +ALTER TABLE t1 ADD INDEX (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/wait_timeout_func.test b/mysql-test/t/wait_timeout_func.test index e825b5a3a39..6b7c8d016d2 100644 --- a/mysql-test/t/wait_timeout_func.test +++ b/mysql-test/t/wait_timeout_func.test @@ -11,93 +11,87 @@ # Creation Date: 2008-03-07 # # Author: Salman Rawala # # # +# Modified: HHunger 2008-08-27 Simplified the test and replaced the sleeps. # +# # # Description: Test Cases of Dynamic System Variable wait_timeout # # that checks the functionality of this variable # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html#option_mysqld_wait_timeouts # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ############################################################################### --source include/not_embedded.inc ---disable_warnings -drop table if exists t1; ---enable_warnings - -############################## -# Creating two new tables # -############################## - ---echo ## Creating new table t1 ## -CREATE TABLE t1 -( -id INT NOT NULL auto_increment, -PRIMARY KEY (id), -name VARCHAR(30) -); +SET @start_value= @@global.wait_timeout; --echo '#--------------------FN_DYNVARS_186_01-------------------------#' ####################################################################### -# Setting initial value of interactive_timeout greater than sleep and -# verifying its behavior on session scope +# 1. test of scope session ####################################################################### ---echo ## Creating new connection test_con1 ## +SET @start_time= UNIX_TIMESTAMP(); +--echo connect (test_con1, localhost, root,,); connect (test_con1, localhost, root,,); connection test_con1; ---echo ## Setting value of variable to 5 ## -SET @@session.wait_timeout = 5; +# If not explicitly changed, @@session.wait_timeout equals @@global.wait_timeout. +SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; ---echo ## Inserting record in table t1 ## -INSERT into t1(name) values('Record_1'); +# Find a small value <> @@global.wait_timeout. +let $session_value = +`SELECT IF(@@global.wait_timeout <> 2 OR @@global.wait_timeout IS NULL, 2, 3)`; +--replace_result $session_value +eval SET @@session.wait_timeout = $session_value; ---echo ## Using sleep to check timeout ## -sleep 4; - - ---echo '#--------------------FN_DYNVARS_186_02-------------------------#' -####################################################################### -# Setting initial value of interactive_timeout greater than sleep and -# verifying its behavior on global scope -####################################################################### - ---echo ## Setting value of variable ## -SET @@global.wait_timeout = 5; - ---echo ## Creating new connection test_con2 ## +--echo connect (test_con2, localhost, root,,); connect (test_con2, localhost, root,,); connection test_con2; -INSERT into t1(name) values('Record_2'); - ---echo ## Using sleep to check timeout ## -sleep 4; - +--replace_result $session_value +eval SET @@session.wait_timeout = $session_value - 1; +--echo connection default; +connection default; +--echo wait until connections ready +let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist; +--source include/wait_condition.inc +SELECT info FROM information_schema.processlist; --echo '#--------------------FN_DYNVARS_186_03-------------------------#' ####################################################################### -# Setting initial value of interactive_timeout less than sleep and -# verifying its behavior on global scope +# 2. test of scope global ####################################################################### ---echo ## Setting value of variable to 1 ## -SET @@global.wait_timeout = 1; +# Find a small value <> @@global.wait_timeout. +let $global_value = $session_value + 1; +--replace_result $global_value +eval SET @@global.wait_timeout= $global_value; ---echo ## Creating new connection ## +# Changing the @@global.wait_timeout has no influence on the +# @@session.wait_timeout of already established sessions. +SELECT @@session.wait_timeout = @start_value AS 'Expect 1'; + +--echo connect (test_con3, localhost, root,,); connect (test_con3, localhost, root,,); connection test_con3; -INSERT into t1(name) values('Record_3'); +# If not explicitly changed, @@session.wait_timeout equals @@global.wait_timeout. +SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; ---echo ## Using sleep to check timeout ## -sleep 5; +--echo connection default; +connection default; +# We can be sure that the connections test_con1 and test_con2 must be +# established because both have already executed a SET @@session.wait_timeout. +# This means they are or at least were visible within the processlist. +# Therefore we can now simply wait till both disappear from the processlist. +let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist; +--source include/wait_condition.inc +SELECT info FROM information_schema.processlist; ---echo ## We cannot test it further because the server stops due to wait_timeout ## ---Error 2006 -SELECT * from t1; +--replace_result $global_value $session_value ; +eval SELECT UNIX_TIMESTAMP() - @start_time >= $global_value + $session_value; +SET @@global.wait_timeout= @start_value; diff --git a/sql/handler.cc b/sql/handler.cc index 6d5c0c93f75..47c2ff40119 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3627,7 +3627,7 @@ int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - ulong tmp_buff_size= (ulong) key_cache->param_buff_size; + size_t tmp_buff_size= (size_t) key_cache->param_buff_size; uint tmp_block_size= (uint) key_cache->param_block_size; uint division_limit= key_cache->param_division_limit; uint age_threshold= key_cache->param_age_threshold; @@ -3651,7 +3651,7 @@ int ha_resize_key_cache(KEY_CACHE *key_cache) if (key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->param_buff_size; + size_t tmp_buff_size= (size_t) key_cache->param_buff_size; long tmp_block_size= (long) key_cache->param_block_size; uint division_limit= key_cache->param_division_limit; uint age_threshold= key_cache->param_age_threshold; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 390f94945aa..843a48ae118 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2504,6 +2504,8 @@ void Item_char_typecast::fix_length_and_dec() and thus avoid unnecessary character set conversion. - If the argument is not a number, then from_cs is set to the argument's charset. + + Note (TODO): we could use repertoire technique here. */ from_cs= (args[0]->result_type() == INT_RESULT || args[0]->result_type() == DECIMAL_RESULT || @@ -2511,12 +2513,13 @@ void Item_char_typecast::fix_length_and_dec() (cast_cs->mbminlen == 1 ? cast_cs : &my_charset_latin1) : args[0]->collation.collation; charset_conversion= (cast_cs->mbmaxlen > 1) || - !my_charset_same(from_cs, cast_cs) && - from_cs != &my_charset_bin && - cast_cs != &my_charset_bin; + (!my_charset_same(from_cs, cast_cs) && + from_cs != &my_charset_bin && + cast_cs != &my_charset_bin); collation.set(cast_cs, DERIVATION_IMPLICIT); - char_length= (cast_length >= 0) ? cast_length : - args[0]->max_length/from_cs->mbmaxlen; + char_length= (cast_length >= 0) ? + cast_length : + args[0]->max_length / args[0]->collation.collation->mbmaxlen; max_length= char_length * cast_cs->mbmaxlen; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6db372c15e2..a3ef599e1f9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4371,6 +4371,9 @@ we force server id to 2, but this MySQL server will not act as a slave."); : mysqld_unix_port), mysqld_port, MYSQL_COMPILATION_COMMENT); +#if defined(_WIN32) && !defined(EMBEDDED_LIBRARY) + Service.SetRunning(); +#endif /* Signal threads waiting for server to be started */ @@ -7351,6 +7354,7 @@ SHOW_VAR status_vars[]= { {NullS, NullS, SHOW_LONG} }; +#ifndef EMBEDDED_LIBRARY static void print_version(void) { set_server_version(); @@ -7362,7 +7366,6 @@ static void print_version(void) server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } -#ifndef EMBEDDED_LIBRARY static void usage(void) { if (!(default_charset_info= get_charset_by_csname(default_character_set_name, diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 7ff06d5bdf5..f41fa08f828 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -255,10 +255,6 @@ void NTService::ServiceMain(DWORD argc, LPTSTR *argv) if (!pService->StartService()) goto error; - // Check that the service is now running. - if (!pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0)) - goto error; - // wait for exit event WaitForSingleObject (pService->hExitEvent, INFINITE); @@ -274,9 +270,18 @@ error: return; } -/** - starts the appliaction thread. -*/ + + +void NTService::SetRunning() +{ + if (pService) + pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0); +} + + +/* ------------------------------------------------------------------------ + StartService() - starts the application thread + -------------------------------------------------------------------------- */ BOOL NTService::StartService() { diff --git a/sql/nt_servc.h b/sql/nt_servc.h index 525f709388b..2f0d07df543 100644 --- a/sql/nt_servc.h +++ b/sql/nt_servc.h @@ -60,7 +60,19 @@ class NTService BOOL IsService(LPCSTR ServiceName); BOOL got_service_option(char **argv, char *service_option); BOOL is_super_user(); - void Stop(void); //to be called from app. to stop service + + /* + SetRunning() is to be called by the application + when initialization completes and it can accept + stop request + */ + void SetRunning(void); + + /* + Stop() is to be called by the application to stop + the service + */ + void Stop(void); protected: LPSTR ServiceName;