From 71acf51498d61ec509e532f5c76efaae841b96f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Feb 2005 18:43:27 -0800 Subject: [PATCH 01/41] Fix per-hour user connection limits by making sure that the number of connections is actually reset after an hour, and also fix (unlikely) conditions under which the per-hour query and connection limits could be exceeded. (Bug #8350) sql/sql_parse.cc: Add time_out_user_resource_limits() function to reset the user resource limits before they are checked, and add locking to check_mqh() because not doing so isn't as safe as the old comment explaining its absence said it is. --- sql/sql_parse.cc | 60 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cd0abafc0c9..bc7d71d8eaa 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -52,7 +52,8 @@ extern "C" pthread_mutex_t THR_LOCK_keycache; extern "C" int gethostname(char *name, int namelen); #endif -static int check_for_max_user_connections(USER_CONN *uc); +static void time_out_user_resource_limits(THD *thd, USER_CONN *uc); +static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); static bool check_db_used(THD *thd,TABLE_LIST *tables); static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables); @@ -272,7 +273,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, return -1; if (thd->user_connect && (thd->user_connect->user_resources.connections || max_user_connections) && - check_for_max_user_connections(thd->user_connect)) + check_for_max_user_connections(thd, thd->user_connect)) return -1; if (db && db[0]) { @@ -312,7 +313,7 @@ void init_max_user_conn(void) } -static int check_for_max_user_connections(USER_CONN *uc) +static int check_for_max_user_connections(THD *thd, USER_CONN *uc) { int error=0; DBUG_ENTER("check_for_max_user_connections"); @@ -325,6 +326,7 @@ static int check_for_max_user_connections(USER_CONN *uc) error=1; goto end; } + time_out_user_resource_limits(thd, uc); if (uc->user_resources.connections && uc->user_resources.connections <= uc->conn_per_hour) { @@ -397,14 +399,41 @@ void init_update_queries(void) /* - Check if maximum queries per hour limit has been reached - returns 0 if OK. + Reset per-hour user resource limits when it has been more than + an hour since they were last checked - In theory we would need a mutex in the USER_CONN structure for this to - be 100 % safe, but as the worst scenario is that we would miss counting - a couple of queries, this isn't critical. + SYNOPSIS: + time_out_user_resource_limits() + thd Thread handler + uc User connection details + + NOTE: + This assumes that the LOCK_user_conn mutex has been acquired, so it is + safe to test and modify members of the USER_CONN structure. */ +void time_out_user_resource_limits(THD *thd, USER_CONN *uc) +{ + time_t check_time = thd->start_time ? thd->start_time : time(NULL); + DBUG_ENTER("time_out_user_resource_limits"); + + /* If more than a hour since last check, reset resource checking */ + if (check_time - uc->intime >= 3600) + { + uc->questions=1; + uc->updates=0; + uc->conn_per_hour=0; + uc->intime=check_time; + } + + DBUG_VOID_RETURN; +} + + +/* + Check if maximum queries per hour limit has been reached + returns 0 if OK. +*/ static bool check_mqh(THD *thd, uint check_command) { @@ -414,16 +443,10 @@ static bool check_mqh(THD *thd, uint check_command) DBUG_ENTER("check_mqh"); DBUG_ASSERT(uc != 0); - /* If more than a hour since last check, reset resource checking */ - if (check_time - uc->intime >= 3600) - { - (void) pthread_mutex_lock(&LOCK_user_conn); - uc->questions=1; - uc->updates=0; - uc->conn_per_hour=0; - uc->intime=check_time; - (void) pthread_mutex_unlock(&LOCK_user_conn); - } + (void) pthread_mutex_lock(&LOCK_user_conn); + + time_out_user_resource_limits(thd, uc); + /* Check that we have not done too many questions / hour */ if (uc->user_resources.questions && uc->questions++ >= uc->user_resources.questions) @@ -446,6 +469,7 @@ static bool check_mqh(THD *thd, uint check_command) } } end: + (void) pthread_mutex_unlock(&LOCK_user_conn); DBUG_RETURN(error); } From f048032c6843548ca6c04d78b2dd77ff5eddbe9e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 02:06:21 +0200 Subject: [PATCH 02/41] removed wrong distinct UNION detection (BUG#6565) mysql-test/r/derived.result: test of union subquery in the FROM clause with complex distinct/all mysql-test/t/derived.test: test of union subquery in the FROM clause with complex distinct/all sql/sql_derived.cc: removed wrong distinct UNION detection --- mysql-test/r/derived.result | 19 +++++++++++++++++++ mysql-test/t/derived.test | 12 ++++++++++++ sql/sql_derived.cc | 10 ++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 61d745d0236..b4d9a921178 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -339,3 +339,22 @@ select distinct sum(b) from (select a,b from t1) y group by a; sum(b) 4 drop table t1; +create table t1(a int); +create table t2(a int); +create table t3(a int); +insert into t1 values(1),(1); +insert into t2 values(2),(2); +insert into t3 values(3),(3); +select * from t1 union distinct select * from t2 union all select * from t3; +a +1 +2 +3 +3 +select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; +a +1 +2 +3 +3 +drop table t1, t2, t3; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 8b322746ed6..bd27e0654e0 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -224,3 +224,15 @@ select distinct sum(b) from t1 group by a; select distinct sum(b) from (select a,b from t1) y group by a; drop table t1; +# +# test of union subquery in the FROM clause with complex distinct/all (BUG#6565) +# +create table t1(a int); +create table t2(a int); +create table t3(a int); +insert into t1 values(1),(1); +insert into t2 values(2),(2); +insert into t3 values(3),(3); +select * from t1 union distinct select * from t2 union all select * from t3; +select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; +drop table t1, t2, t3; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 9475ec08c96..3e627243b9f 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -132,10 +132,16 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, /* Temp table is created so that it hounours if UNION without ALL is to be processed + + As 'distinct' parameter we always pass FALSE (0), because underlying + query will control distinct condition by itself. Correct test of + distinct underlying query will be is_union && + !unit->union_distinct->next_select() (i.e. it is union and last distinct + SELECT is last SELECT of UNION). */ if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, - unit->types, (ORDER*) 0, - is_union && unit->union_distinct, 1, + unit->types, (ORDER*) 0, + FALSE, 1, (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, From 95dec435c2c2b0d2dff54adb5d46b1d766efa3b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 11:02:01 +0100 Subject: [PATCH 03/41] Bug#7879: Using TL_READ_NO_INSERT locks instead of TL_READ locks when reading tables in "complex" SQL statements. If inserts happen in a table being read, the statements have no serialization order and the change can therefore not be reproduced on the slave. sql/sql_update.cc: Switching to using T_READ_NO_INSERT when the binlog is used. sql/sql_yacc.yy: Switching to using T_READ_NO_INSERT when the binlog is used. --- sql/sql_update.cc | 5 ++++- sql/sql_yacc.yy | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4f7e34ec74f..bff360d02dc 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -479,7 +479,10 @@ int mysql_multi_update(THD *thd, else { DBUG_PRINT("info",("setting table `%s` for read-only", tl->alias)); - tl->lock_type= TL_READ; + // If we are using the binary log, we need TL_READ_NO_INSERT to get + // correct order of statements. Otherwise, we use a TL_READ lock to + // improve performance. + tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ; tl->updating= 0; wants= SELECT_ACL; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7b72c73a915..3e45e35c618 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -822,7 +822,7 @@ create_select: SELECT_SYM { LEX *lex=Lex; - lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ; + lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; if (lex->sql_command == SQLCOM_INSERT) lex->sql_command= SQLCOM_INSERT_SELECT; else if (lex->sql_command == SQLCOM_REPLACE) @@ -1532,7 +1532,7 @@ select_part2: { LEX *lex=Lex; lex->lock_option=TL_READ; - mysql_init_select(lex); + mysql_init_select(lex); } select_options select_item_list select_into select_lock_type; From 5edc77beb87e47d977a22945bfd82485d1707239 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 11:58:35 -0800 Subject: [PATCH 04/41] When calling initgroups(), set a flag that the segfault handler checks in order to output a special warning about a particular case of segfaults due to a mix of static binaries, NSS, and LDAP. (Bug #4872) sql/mysqld.cc: Add code to output a special message when we get a segfault when calling initgroups() to explain the problem. --- sql/mysqld.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f104e461d6a..0585b5840d3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -308,6 +308,9 @@ my_bool opt_readonly = 0, opt_sync_bdb_logs, opt_sync_frm; volatile bool mqh_used = 0; FILE *bootstrap_file=0; int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice +#ifdef HAVE_INITGROUPS +static bool calling_initgroups= FALSE; /* Used in SIGSEGV handler. */ +#endif /* If sql_bin_update is true, SQL_LOG_UPDATE and SQL_LOG_BIN are kept in sync, @@ -1086,7 +1089,15 @@ static void set_user(const char *user, struct passwd *user_info) #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) DBUG_ASSERT(user_info); #ifdef HAVE_INITGROUPS + /* + We can get a SIGSEGV when calling initgroups() on some systems when NSS + is configured to use LDAP and the server is statically linked. We set + calling_initgroups as a flag to the SIGSEGV handler that is then used to + output a specific message to help the user resolve this problem. + */ + calling_initgroups= TRUE; initgroups((char*) user, user_info->pw_gid); + calling_initgroups= FALSE; #endif if (setgid(user_info->pw_gid) == -1) { @@ -1807,6 +1818,17 @@ information that should help you find out what is causing the crash.\n"); fflush(stderr); #endif /* HAVE_STACKTRACE */ +#ifdef HAVE_INITGROUPS + if (calling_initgroups) + fprintf(stderr, "\n\ +This crash occured while the server was calling initgroups(). This is\n\ +often due to the use of a mysqld that is statically linked against glibc\n\ +and configured to use LDAP in /etc/nsswitch.conf. You will need to either\n\ +upgrade to a version of glibc that does not have this problem (2.3.4 or\n\ +later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\ +mysqld that is not statically linked.\n"); +#endif + if (test_flags & TEST_CORE_ON_SIGNAL) { fprintf(stderr, "Writing a core file\n"); From a2d622b0571e707c36d953f7a1153337e6d421d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Feb 2005 00:28:04 +0100 Subject: [PATCH 05/41] BUG#8297: If query is filtered on slave, do not put it in general log. sql/log_event.cc: If query is filtered on slave, do not put info in general log. --- sql/log_event.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 19113a3b97e..37072d7845b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1016,7 +1016,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) VOID(pthread_mutex_unlock(&LOCK_thread_count)); thd->variables.pseudo_thread_id= thread_id; // for temp tables - mysql_log.write(thd,COM_QUERY,"%s",thd->query); DBUG_PRINT("query",("%s",thd->query)); if (ignored_error_code((expected_error= error_code)) || !check_expected_error(thd,rli,expected_error)) @@ -1046,6 +1045,10 @@ START SLAVE; . Query: '%s'", expected_error, thd->query); goto end; } + /* If the query was not ignored, it is printed to the general log */ + if (thd->net.last_errno != ER_SLAVE_IGNORED_TABLE) + mysql_log.write(thd,COM_QUERY,"%s",thd->query); + /* If we expected a non-zero error code, and we don't get the same error code, and none of them should be ignored. From 3ece905301621e8e8b5742a30e82f2e8b2fa59fa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 17:37:56 -0800 Subject: [PATCH 06/41] Fix output of perror to include whether the error message corresponds to an OS or MySQL error. (Bug #8517) extra/perror.c: Don't report OS errors that start with 'Unknown Error', and always make clear whether we are reporting an OS or MySQL error message. --- extra/perror.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extra/perror.c b/extra/perror.c index b377b360b5c..6e632b20d96 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -245,16 +245,17 @@ int main(int argc,char *argv[]) msg = strerror(code); /* - Don't print message for not existing error messages or for - unknown errors. We test for 'Uknown Errors' just as an - extra safety for Netware + We don't print the OS error message if it is the same as the + unknown_error message we retrieved above, or it starts with + 'Unknown Error' (without regard to case). */ - if (msg && strcmp(msg, "Unknown Error") && + if (msg && + my_strnncoll(&my_charset_latin1, msg, 13, "Unknown Error", 13) && (!unknown_error || strcmp(msg, unknown_error))) { found=1; if (verbose) - printf("Error code %3d: %s\n",code,msg); + printf("OS error code %3d: %s\n",code,msg); else puts(msg); } @@ -269,7 +270,7 @@ int main(int argc,char *argv[]) else { if (verbose) - printf("MySQL error: %3d = %s\n",code,msg); + printf("MySQL error code %3d: %s\n",code,msg); else puts(msg); } From ae9166cd65ab10b21c92befa8cfe4a8e87bed0cb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Feb 2005 11:48:44 -0800 Subject: [PATCH 07/41] Log each slow query in a multi-statement query to the slow query log. (Bug #8475) sql/sql_parse.cc: Reset the start time before each statement before each statement in a multi-statement query, and check whether each statement should be logged to the slow query log independently. mysql-test/r/multi_statement.result: Add new results mysql-test/t/multi_statement.test: Add new regression test --- mysql-test/r/multi_statement.result | 17 +++++++++++++ mysql-test/t/multi_statement-master.opt | 2 ++ mysql-test/t/multi_statement.test | 15 +++++++++++ sql/sql_parse.cc | 33 ++++++++++++++++--------- 4 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 mysql-test/t/multi_statement-master.opt diff --git a/mysql-test/r/multi_statement.result b/mysql-test/r/multi_statement.result index 4451b0a355e..3a8d86bf349 100644 --- a/mysql-test/r/multi_statement.result +++ b/mysql-test/r/multi_statement.result @@ -31,3 +31,20 @@ select 5'abcd' select 'finish'; finish finish +flush status; +create table t1 (i int); +insert into t1 values (1); +select * from t1 where i = 1; +insert into t1 values (2),(3),(4); +select * from t1 where i = 2; +select * from t1 where i = 3|||| +i +1 +i +2 +i +3 +show status like 'Slow_queries'|||| +Variable_name Value +Slow_queries 2 +drop table t1|||| diff --git a/mysql-test/t/multi_statement-master.opt b/mysql-test/t/multi_statement-master.opt new file mode 100644 index 00000000000..b30df037531 --- /dev/null +++ b/mysql-test/t/multi_statement-master.opt @@ -0,0 +1,2 @@ +--log-slow-queries=slow.log +--log-queries-not-using-indexes diff --git a/mysql-test/t/multi_statement.test b/mysql-test/t/multi_statement.test index 862f2294641..2abec332878 100644 --- a/mysql-test/t/multi_statement.test +++ b/mysql-test/t/multi_statement.test @@ -14,3 +14,18 @@ select "abcd'";'abcd'select "'abcd";'abcd' select 5'abcd' delimiter ;'abcd' select 'finish'; + +# Bug #8475: Make sure every statement that is a slow query in +# a multi-statement query gets logged as a slow query. +flush status; +delimiter ||||; +create table t1 (i int); +insert into t1 values (1); +select * from t1 where i = 1; +insert into t1 values (2),(3),(4); +select * from t1 where i = 2; +select * from t1 where i = 3|||| +show status like 'Slow_queries'|||| +drop table t1|||| + +delimiter ;|||| diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1329a6cd732..54cc555e48c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -58,6 +58,7 @@ static void remove_escape(char *name); static void refresh_status(void); static bool append_file_to_dir(THD *thd, const char **filename_ptr, const char *table_name); +static void log_slow_query(THD *thd); const char *any_db="*any*"; // Special symbol for check_access @@ -1491,6 +1492,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif ulong length= (ulong)(packet_end-packet); + log_slow_query(thd); + /* Remove garbage at start of query */ while (my_isspace(thd->charset(), *packet) && length > 0) { @@ -1501,6 +1504,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->query_length= length; thd->query= packet; thd->query_id= query_id++; + thd->set_time(); /* Reset the query start time. */ /* TODO: set thd->lex->sql_command to SQLCOM_END here */ VOID(pthread_mutex_unlock(&LOCK_thread_count)); #ifndef EMBEDDED_LIBRARY @@ -1797,6 +1801,24 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (thd->is_fatal_error) send_error(thd,0); // End of memory ? + log_slow_query(thd); + + thd->proc_info="cleaning up"; + VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list + thd->proc_info=0; + thd->command=COM_SLEEP; + thd->query=0; + thd->query_length=0; + thread_running--; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); + thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory + free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); + DBUG_RETURN(error); +} + + +static void log_slow_query(THD *thd) +{ time_t start_of_query=thd->start_time; thd->end_time(); // Set start time @@ -1815,17 +1837,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query); } } - thd->proc_info="cleaning up"; - VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list - thd->proc_info=0; - thd->command=COM_SLEEP; - thd->query=0; - thd->query_length=0; - thread_running--; - VOID(pthread_mutex_unlock(&LOCK_thread_count)); - thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory - free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); - DBUG_RETURN(error); } From cfad792e747733b655963510ec4d7c985df544ca Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Feb 2005 12:47:33 -0800 Subject: [PATCH 08/41] Clean up fix for Bug #7989 by avoiding extra memory copy, and adding some more information to the error message. sql/sql_acl.cc: Change strmov() call to strnmov(), and don't do redundant copy. Add to warning message that privilege can't be removed with REVOKE. --- sql/sql_acl.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 92d6f471a1e..252a2af7134 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -202,18 +202,17 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) { /* We make a temporary copy of the database, force it to lower case, - and then copy it back over the original name. We can't just update - the host.db pointer, because tmp_name is allocated on the stack. + and then check it against the original name. */ - (void)strmov(tmp_name, host.db); - my_casedn_str(files_charset_info, tmp_name); + (void)strnmov(tmp_name, host.db, sizeof(tmp_name)); + my_casedn_str(files_charset_info, host.db); if (strcmp(host.db, tmp_name) != 0) { sql_print_warning("'host' entry '%s|%s' had database in mixed " "case that has been forced to lowercase because " - "lower_case_table_names is set.", + "lower_case_table_names is set. It will not be " + "possible to remove this privilege using REVOKE.", host.host.hostname, host.db); - (void)strmov(host.db, tmp_name); } } host.access= get_access(table,2); @@ -403,18 +402,17 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) { /* We make a temporary copy of the database, force it to lower case, - and then copy it back over the original name. We can't just update - the db.db pointer, because tmp_name is allocated on the stack. + and then check it against the original name. */ - (void)strmov(tmp_name, db.db); - my_casedn_str(files_charset_info, tmp_name); + (void)strnmov(tmp_name, db.db, sizeof(tmp_name)); + my_casedn_str(files_charset_info, db.db); if (strcmp(db.db, tmp_name) != 0) { sql_print_warning("'db' entry '%s %s@%s' had database in mixed " "case that has been forced to lowercase because " - "lower_case_table_names is set.", + "lower_case_table_names is set. It will not be " + "possible to remove this privilege using REVOKE.", db.db, db.user, db.host.hostname, db.host.hostname); - (void)strmov(db.db, tmp_name); } } db.sort=get_sort(3,db.host.hostname,db.db,db.user); From 97e6e780063e464b7ec1ec2b8204fb3ec3831a20 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 19 Feb 2005 19:51:47 +0200 Subject: [PATCH 09/41] fix for a bug with my_print_defaults with --defaults-extra-file= option --- extra/my_print_defaults.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 2ec6f8b406f..d5836cb0dc8 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -120,25 +120,33 @@ int main(int argc, char **argv) int count, error; char **load_default_groups, *tmp_arguments[2], **argument, **arguments; + char *defaults, *extra_defaults; MY_INIT(argv[0]); + get_defaults_files(argc, argv, &defaults, &extra_defaults); + /* ** Check out the args */ - if (get_options(&argc,&argv)) - exit(1); if (!(load_default_groups=(char**) my_malloc((argc+2)*sizeof(char*), MYF(MY_WME)))) exit(1); + if (get_options(&argc,&argv)) + exit(1); for (count=0; *argv ; argv++,count++) load_default_groups[count]= *argv; load_default_groups[count]=0; - count=1; + count=0; arguments=tmp_arguments; - arguments[0]=my_progname; - arguments[1]=0; + arguments[count++]=my_progname; + if (extra_defaults) + arguments[count++]= extra_defaults; + if (defaults) + arguments[count++]= defaults; + arguments[count]= 0; + if ((error= load_defaults(config_file, (const char **) load_default_groups, &count, &arguments))) { From e8f888a52593988b642046c162edca6e45270f57 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 15:43:25 +0400 Subject: [PATCH 10/41] mysql.cc: bug#7571: Server & Client characterset are shown under different decriptions Switch them into the correct order. client/mysql.cc: bug#7571: Server & Client characterset are shown under different decriptions Switch them into the correct order. --- client/mysql.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 635973e946c..4004757359b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2914,9 +2914,9 @@ com_status(String *buffer __attribute__((unused)), MYSQL_ROW cur=mysql_fetch_row(result); if (cur) { - tee_fprintf(stdout, "Server characterset:\t%s\n", cur[0] ? cur[0] : ""); + tee_fprintf(stdout, "Server characterset:\t%s\n", cur[0] ? cur[2] : ""); tee_fprintf(stdout, "Db characterset:\t%s\n", cur[3] ? cur[3] : ""); - tee_fprintf(stdout, "Client characterset:\t%s\n", cur[2] ? cur[2] : ""); + tee_fprintf(stdout, "Client characterset:\t%s\n", cur[2] ? cur[0] : ""); tee_fprintf(stdout, "Conn. characterset:\t%s\n", cur[1] ? cur[1] : ""); } mysql_free_result(result); From 65410bd0a15f42a0f0858524ba98ad92d88bcdc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 17:17:30 +0400 Subject: [PATCH 11/41] ctype_utf8.result, ctype_utf8.test, ctype-utf8.c: Bugs: #8385: utf8_general_ci treats cyrillic letters I and SHORT I as the same strings/ctype-utf8.c: Bugs: #8385: utf8_general_ci treats cyrillic letters I and SHORT I as the same mysql-test/t/ctype_utf8.test: Bugs: #8385: utf8_general_ci treats cyrillic letters I and SHORT I as the same mysql-test/r/ctype_utf8.result: Bugs: #8385: utf8_general_ci treats cyrillic letters I and SHORT I as the same --- mysql-test/r/ctype_utf8.result | 3 +++ mysql-test/t/ctype_utf8.test | 5 +++++ strings/ctype-utf8.c | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 415ed33ad40..13105e2276c 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -861,3 +861,6 @@ user c one two DROP TABLE t1; +select convert(_koi8r'' using utf8) < convert(_koi8r'' using utf8); +convert(_koi8r'' using utf8) < convert(_koi8r'' using utf8) +1 diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 8e3eb71c3e5..35f2b2642be 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -693,3 +693,8 @@ INSERT INTO t1 VALUES ('one'),('two'); SELECT CHARSET('a'); SELECT user, CONCAT('<', user, '>') AS c FROM t1; DROP TABLE t1; + +# +# Bug#8385: utf8_general_ci treats Cyrillic letters I and SHORT I as the same +# +select convert(_koi8r'' using utf8) < convert(_koi8r'' using utf8); diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 486d428bf1d..69371aa38c2 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -578,7 +578,7 @@ static MY_UNICASE_INFO plane04[]={ {0x0412,0x0432,0x0412}, {0x0413,0x0433,0x0413}, {0x0414,0x0434,0x0414}, {0x0415,0x0435,0x0415}, {0x0416,0x0436,0x0416}, {0x0417,0x0437,0x0417}, - {0x0418,0x0438,0x0418}, {0x0419,0x0439,0x0418}, + {0x0418,0x0438,0x0418}, {0x0419,0x0439,0x0419}, {0x041A,0x043A,0x041A}, {0x041B,0x043B,0x041B}, {0x041C,0x043C,0x041C}, {0x041D,0x043D,0x041D}, {0x041E,0x043E,0x041E}, {0x041F,0x043F,0x041F}, @@ -594,7 +594,7 @@ static MY_UNICASE_INFO plane04[]={ {0x0412,0x0432,0x0412}, {0x0413,0x0433,0x0413}, {0x0414,0x0434,0x0414}, {0x0415,0x0435,0x0415}, {0x0416,0x0436,0x0416}, {0x0417,0x0437,0x0417}, - {0x0418,0x0438,0x0418}, {0x0419,0x0439,0x0418}, + {0x0418,0x0438,0x0418}, {0x0419,0x0439,0x0419}, {0x041A,0x043A,0x041A}, {0x041B,0x043B,0x041B}, {0x041C,0x043C,0x041C}, {0x041D,0x043D,0x041D}, {0x041E,0x043E,0x041E}, {0x041F,0x043F,0x041F}, From ae8c3e130a91687839b570f82f6694f81c21dbaf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 17:27:36 +0300 Subject: [PATCH 12/41] Fix -ansi -pedantic compilation failure. --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0dcb59f689d..a22feda7d89 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2780,8 +2780,8 @@ unsent_create_error: TABLE *table= tables->table; /* Skip first table, which is the table we are inserting in */ - tables= (TABLE_LIST *) - lex->select_lex.table_list.first= (byte*) first_local_table->next; + lex->select_lex.table_list.first= (byte*) first_local_table->next; + tables= (TABLE_LIST *) lex->select_lex.table_list.first; first_local_table->next= 0; if (!(res= mysql_prepare_insert(thd, tables, first_local_table, From aef137bc810d8c4cbe13651f9fe14c1a8ea0f2df Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 09:15:43 -0600 Subject: [PATCH 13/41] sql_parse.cc: Fix compiler complaint. sql/sql_parse.cc: Fix compiler complaint. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0dcb59f689d..41705fb82e7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2781,7 +2781,7 @@ unsent_create_error: TABLE *table= tables->table; /* Skip first table, which is the table we are inserting in */ tables= (TABLE_LIST *) - lex->select_lex.table_list.first= (byte*) first_local_table->next; + (lex->select_lex.table_list.first= (byte*) first_local_table->next); first_local_table->next= 0; if (!(res= mysql_prepare_insert(thd, tables, first_local_table, From df1b674a695c6cba3228a94a556f97c707e732fc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 16:26:04 +0100 Subject: [PATCH 14/41] BUG#6676: Derivation of user variables should be of derivation "IMPLICIT" --- mysql-test/r/rpl_charset.result | 7 +++++++ mysql-test/t/rpl_charset.test | 13 +++++++++++++ sql/log_event.cc | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_charset.result b/mysql-test/r/rpl_charset.result index cab41344238..292cfb19175 100644 --- a/mysql-test/r/rpl_charset.result +++ b/mysql-test/r/rpl_charset.result @@ -207,3 +207,10 @@ select hex(c1), hex(c2) from t1; hex(c1) hex(c2) CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 drop table t1; +create table `t1` ( +`pk` varchar(10) not null default '', +primary key (`pk`) +) engine=myisam default charset=latin1; +set @p=_latin1 'test'; +update t1 set pk='test' where pk=@p; +drop table t1; diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test index 68036ae49f1..3f7eabfa434 100644 --- a/mysql-test/t/rpl_charset.test +++ b/mysql-test/t/rpl_charset.test @@ -169,3 +169,16 @@ select hex(c1), hex(c2) from t1; connection master; drop table t1; sync_slave_with_master; + +# +# BUG#6676: Derivation of variables must be correct on slave +# +connection master; +create table `t1` ( + `pk` varchar(10) not null default '', + primary key (`pk`) +) engine=myisam default charset=latin1; +set @p=_latin1 'test'; +update t1 set pk='test' where pk=@p; +drop table t1; +sync_slave_with_master; diff --git a/sql/log_event.cc b/sql/log_event.cc index 19113a3b97e..7d2848700f6 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2528,7 +2528,7 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) 0 can be passed as last argument (reference on item) */ e.fix_fields(thd, 0, 0); - e.update_hash(val, val_len, type, charset, DERIVATION_NONE); + e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT); free_root(thd->mem_root,0); rli->inc_event_relay_log_pos(get_event_len()); From 25b205cec8d634220677f633c015ce8c7bde6c51 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 17:52:15 +0100 Subject: [PATCH 15/41] BUG#6676: Added comment for the fix --- sql/log_event.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/log_event.cc b/sql/log_event.cc index 7d2848700f6..fabc6718826 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2528,6 +2528,11 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) 0 can be passed as last argument (reference on item) */ e.fix_fields(thd, 0, 0); + /* + A variable can just be considered as a table with + a single record and with a single column. Thus, like + a column value, it could always have IMPLICIT derivation. + */ e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT); free_root(thd->mem_root,0); From edaf33a14e922571e8e80910bba6693b72e2db83 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Feb 2005 18:40:28 +0100 Subject: [PATCH 16/41] BUG#6662: Importing mysqldumps should not show any warnings of level "notes". --- client/mysqldump.c | 4 +++ mysql-test/r/mysqldump.result | 54 +++++++++++++++++++++++------------ sql/mysql_priv.h | 4 +++ sql/mysqld.cc | 3 +- sql/set_var.cc | 4 +++ sql/sql_error.cc | 4 +++ 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 52255ccb896..2a6d9adf8bd 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -492,6 +492,8 @@ static void write_header(FILE *sql_file, char *db_name) "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n", path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", compatible_mode_normal_str); + fprintf(sql_file, + "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n"); check_io(sql_file); } } /* write_header */ @@ -518,6 +520,8 @@ static void write_footer(FILE *sql_file) "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n" "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n" "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n"); + fprintf(sql_file, + "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); fputs("\n", sql_file); check_io(sql_file); } diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 8f2294caa48..754d1458eac 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -61,6 +61,7 @@ INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456) /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` decimal(10,5) default NULL, @@ -80,10 +81,11 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE TABLE `t1` ( `a` decimal(10,5) default NULL, `b` float default NULL @@ -94,7 +96,7 @@ INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456) /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); @@ -150,6 +152,7 @@ INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` varchar(255) default NULL @@ -169,13 +172,14 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; CREATE TABLE t1 (a int) ENGINE=MYISAM; INSERT INTO t1 VALUES (1), (2); /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL40' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -191,10 +195,11 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -210,7 +215,7 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; create table ```a` (i int); CREATE TABLE ```a` ( @@ -226,6 +231,7 @@ create table t1(a int); /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -243,10 +249,11 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS "t1"; CREATE TABLE "t1" ( "a" int(11) default NULL @@ -261,7 +268,7 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; set global sql_mode='ANSI_QUOTES'; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; @@ -271,6 +278,7 @@ set global sql_mode='ANSI_QUOTES'; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -288,10 +296,11 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS "t1"; CREATE TABLE "t1" ( "a" int(11) default NULL @@ -306,7 +315,7 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; set global sql_mode=''; drop table t1; create table t1(a int); @@ -317,6 +326,7 @@ insert into t1 values (1),(2),(3); /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -327,7 +337,7 @@ CREATE TABLE `t1` ( /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 1 2 3 @@ -340,6 +350,7 @@ drop table t1; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; @@ -351,7 +362,7 @@ USE `test`; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; create database mysqldump_test_db character set latin2 collate latin2_bin; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; @@ -361,6 +372,7 @@ create database mysqldump_test_db character set latin2 collate latin2_bin; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin2 COLLATE latin2_bin */; @@ -372,7 +384,7 @@ USE `mysqldump_test_db`; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop database mysqldump_test_db; CREATE TABLE t1 (a CHAR(10)); INSERT INTO t1 VALUES (_latin1 ''); @@ -384,6 +396,7 @@ INSERT INTO t1 VALUES (_latin1 ' /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -402,10 +415,11 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -421,10 +435,11 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -440,10 +455,11 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -459,10 +475,11 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -478,7 +495,7 @@ UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); @@ -492,6 +509,7 @@ INSERT INTO t2 VALUES (4),(5),(6); /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t2`; CREATE TABLE `t2` ( `a` int(11) default NULL @@ -510,6 +528,6 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; DROP TABLE t2; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6218bc49f53..3cb5eba8efa 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -212,6 +212,10 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27) #define SELECT_NO_UNLOCK (1L << 28) +/* If set to 0, then the thread will ignore all warnings with level notes. + Set by executing SET SHOW_NOTES=1 */ +#define OPTION_NOTES (1L << 31) + /* Bits for different SQL modes modes (including ANSI mode) */ #define MODE_REAL_AS_FLOAT 1 #define MODE_PIPES_AS_CONCAT 2 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 53dca59bc92..3e4d0593a85 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5622,7 +5622,8 @@ static void mysql_init_variables(void) language_ptr= language; mysql_data_home= mysql_real_data_home; thd_startup_options= (OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL | - OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE); + OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE | + OPTION_NOTES); protocol_version= PROTOCOL_VERSION; what_to_log= ~ (1L << (uint) COM_TIME); refresh_version= flush_version= 1L; /* Increments on each reload */ diff --git a/sql/set_var.cc b/sql/set_var.cc index ca7987d2636..00ab4658f30 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -423,6 +423,9 @@ static sys_var_thd_bit sys_log_binlog("sql_log_bin", static sys_var_thd_bit sys_sql_warnings("sql_warnings", 0, set_option_bit, OPTION_WARNINGS); +static sys_var_thd_bit sys_sql_notes("sql_notes", 0, + set_option_bit, + OPTION_NOTES); static sys_var_thd_bit sys_auto_is_null("sql_auto_is_null", 0, set_option_bit, OPTION_AUTO_IS_NULL); @@ -610,6 +613,7 @@ sys_var *sys_variables[]= &sys_sql_max_join_size, &sys_sql_mode, &sys_sql_warnings, + &sys_sql_notes, &sys_storage_engine, #ifdef HAVE_REPLICATION &sys_sync_binlog_period, diff --git a/sql/sql_error.cc b/sql/sql_error.cc index eab5ec890df..e04c2843c93 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -104,6 +104,10 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, { MYSQL_ERROR *err= 0; DBUG_ENTER("push_warning"); + + if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_NOTES)) + return(0); + if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); From 1329f063c052e70fa71c7aaacb08e49357d108f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 08:35:15 +0400 Subject: [PATCH 17/41] field.cc: optimize test_if_minus() when not UCS2 support is compiled. sql/field.cc: optimize test_if_minus() when not UCS2 support is compiled. --- sql/field.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sql/field.cc b/sql/field.cc index fa0e202d513..34c5d572526 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1776,13 +1776,23 @@ void Field_medium::sql_type(String &res) const ** long int ****************************************************************************/ - +/* + A helper function to check whether the next character + in the string "s" is MINUS SIGN. +*/ +#ifdef HAVE_CHARSET_ucs2 static bool test_if_minus(CHARSET_INFO *cs, const char *s, const char *e) { my_wc_t wc; return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-'; } +#else +/* + If not UCS2 support is compiled then it is easier +*/ +#define test_if_minus(cs, s, e) (*s == '-') +#endif int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) From 14707d71c388375817b4ffb74df189bbe14a709d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 09:56:07 +0400 Subject: [PATCH 18/41] ctype_latin1.result, ctype_latin1.test, charset.c: Treat unknown characters straight in a query as syntax error, rather skipping it as a space character. mysys/charset.c: Treat unknown characters straight in a query as syntax error, rather skipping it as a space character. mysql-test/t/ctype_latin1.test: Treat unknown characters straight in a query as syntax error, rather skipping it as a space character. mysql-test/r/ctype_latin1.result: Treat unknown characters straight in a query as syntax error, rather skipping it as a space character. --- mysql-test/r/ctype_latin1.result | 5 +++++ mysql-test/t/ctype_latin1.test | 9 +++++++++ mysys/charset.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index cd804939a75..21c40e24fe2 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -325,3 +325,8 @@ latin1_bin 6109 latin1_bin 61 latin1_bin 6120 drop table t1; +CREATE TABLE a (a int); +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 'a (a int)' at line 1 +SELECT 'a' as str; +str +a diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index cee0324d12f..6006ee4c527 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -66,3 +66,12 @@ SET collation_connection='latin1_swedish_ci'; -- source include/ctype_filesort.inc SET collation_connection='latin1_bin'; -- source include/ctype_filesort.inc + +# +# Bug#8041 +# An unknown character (e.g. 0x84) should result in ERROR, +# It was treated like a space character earlier. +# Howerver, it should still work fine as a string part. +--error 1064 +CREATE TABLE a (a int); +SELECT 'a' as str; diff --git a/mysys/charset.c b/mysys/charset.c index bb8f2d178b9..5840c885e40 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -64,7 +64,7 @@ static my_bool init_state_maps(CHARSET_INFO *cs) else if (my_mbcharlen(cs, i)>1) state_map[i]=(uchar) MY_LEX_IDENT; #endif - else if (!my_isgraph(cs,i)) + else if (my_isspace(cs,i)) state_map[i]=(uchar) MY_LEX_SKIP; else state_map[i]=(uchar) MY_LEX_CHAR; From f7c60b9f038840a4c590c8bba20b81a259557faf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 10:59:24 +0100 Subject: [PATCH 19/41] Fix name of ndb-cache-check-time sql/mysqld.cc: Change _ to - for ndb-cache-check-time variable --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9559ed55b3c..180d9427c66 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4646,7 +4646,7 @@ Disable with --skip-ndbcluster (will save memory).", (gptr*) &opt_ndb_optimized_node_selection, (gptr*) &opt_ndb_optimized_node_selection, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, - { "ndb_cache_check_time", OPT_NDB_CACHE_CHECK_TIME, + { "ndb-cache-check-time", OPT_NDB_CACHE_CHECK_TIME, "A dedicated thread is created to update cached commit count value at the given interval.", (gptr*) &opt_ndb_cache_check_time, (gptr*) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG, 0, 0, LONG_TIMEOUT, 0, 1, 0}, From cb8d9c3ad40f00018cff05168e731ff2547d6144 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 12:51:23 +0200 Subject: [PATCH 20/41] Backport my_strntod() from 5.0 Change string->float conversion to delay division as long as possible. This gives us more exact integer->float conversion for numbers of type '123.45E+02' (Bug #7740) client/mysql.cc: Fix wront usage of charset (found during review of pushed code) include/m_string.h: Backported my_strtod() from 5.0 mysql-test/mysql-test-run.sh: Run also mysql_client_test with --debug mysql-test/r/ps_1general.result: Safety fix (if mysql_client_test.test fails) mysql-test/r/type_float.result: More test mysql-test/t/mysql_client_test.test: Comments for what to do if this test fails mysql-test/t/ps_1general.test: Safety fix (if mysql_client_test.test fails) mysql-test/t/type_float.test: More test to better test new strtod() function Test also bug #7740 (wrong comparsion between integer and float-in-integer-range) sql/field.cc: Backport my_strntod() from 5.0 sql/item.cc: Backport my_strntod() from 5.0 sql/item.h: Backport my_strntod() from 5.0 sql/item_func.h: Backport my_strntod() from 5.0 sql/item_strfunc.cc: Backport my_strntod() from 5.0 sql/item_sum.cc: Backport my_strntod() from 5.0 sql/item_sum.h: Backport my_strntod() from 5.0 sql/procedure.h: Backport my_strntod() from 5.0 strings/ctype-simple.c: Backport my_strntod() from 5.0 strings/ctype-ucs2.c: Backport my_strntod() from 5.0 strings/strtod.c: Backport my_strntod() from 5.0 Change conversion to delay division as long as possible. This gives us more exact integer-> float conversion for numbers of type '123.45E+02' --- client/mysql.cc | 4 +- include/m_string.h | 2 +- mysql-test/mysql-test-run.sh | 3 +- mysql-test/r/ps_1general.result | 1 + mysql-test/r/type_float.result | 34 +++++- mysql-test/t/mysql_client_test.test | 7 ++ mysql-test/t/ps_1general.test | 1 + mysql-test/t/type_float.test | 26 ++++- sql/field.cc | 14 ++- sql/item.cc | 11 +- sql/item.h | 6 +- sql/item_func.h | 7 +- sql/item_strfunc.cc | 3 +- sql/item_sum.cc | 3 +- sql/item_sum.h | 6 +- sql/procedure.h | 11 +- strings/ctype-simple.c | 27 +---- strings/ctype-ucs2.c | 9 +- strings/strtod.c | 175 +++++++++++++++++++--------- 19 files changed, 243 insertions(+), 107 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 4004757359b..1bbab75434c 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2914,9 +2914,9 @@ com_status(String *buffer __attribute__((unused)), MYSQL_ROW cur=mysql_fetch_row(result); if (cur) { - tee_fprintf(stdout, "Server characterset:\t%s\n", cur[0] ? cur[2] : ""); + tee_fprintf(stdout, "Server characterset:\t%s\n", cur[2] ? cur[2] : ""); tee_fprintf(stdout, "Db characterset:\t%s\n", cur[3] ? cur[3] : ""); - tee_fprintf(stdout, "Client characterset:\t%s\n", cur[2] ? cur[0] : ""); + tee_fprintf(stdout, "Client characterset:\t%s\n", cur[0] ? cur[0] : ""); tee_fprintf(stdout, "Conn. characterset:\t%s\n", cur[1] ? cur[1] : ""); } mysql_free_result(result); diff --git a/include/m_string.h b/include/m_string.h index 97d34421537..d3465363beb 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -215,7 +215,7 @@ extern char *strstr(const char *, const char *); extern int is_prefix(const char *, const char *); /* Conversion routines */ -double my_strtod(const char *str, char **end); +double my_strtod(const char *str, char **end, int *error); double my_atof(const char *nptr); extern char *llstr(longlong value,char *buff); diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index af432f37868..8c484d2ddb1 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -444,6 +444,7 @@ while test $# -gt 0; do --debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqldump.trace" EXTRA_MYSQLBINLOG_OPT="$EXTRA_MYSQLBINLOG_OPT \ --debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqlbinlog.trace" + EXTRA_MYSQL_CLIENT_TEST_OPT="--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysql_client_test.trace" ;; --fast) FAST_START=1 @@ -681,7 +682,7 @@ then EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root" fi -MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent" +MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent $EXTRA_MYSQL_CLIENT_TEST_OPT" MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 2356989eaf6..ec4aa528a7f 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -1,5 +1,6 @@ drop table if exists t5, t6, t7, t8; drop database if exists mysqltest ; +drop database if exists client_test_db; test_sequence ------ basic tests ------ drop table if exists t1, t9 ; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 1f5a34917d7..c1cefe4b35d 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; SELECT 10,10.0,10.,.1e+2,100.0e-1; 10 10.0 10. .1e+2 100.0e-1 10 10.0 10 10 10 @@ -8,6 +8,15 @@ SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; 1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1 10 10 10 10 10 10 0.1 0.1 0.1 +SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; +0.001e+1 0.001e-1 -0.001e+01 -0.001e-01 +0.01 0.0001 -0.01 -0.0001 +SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; +123.23E+02 -123.23E-02 "123.23E+02"+0.0 "-123.23E-02"+0.0 +12323 -1.2323 12323 -1.2323 +SELECT 2147483647E+02,21474836.47E+06; +2147483647E+02 21474836.47E+06 +214748364700 21474836470000 create table t1 (f1 float(24),f2 float(52)); show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment @@ -139,6 +148,9 @@ create table t1 (c20 char); insert into t1 values (5000.0); Warnings: Warning 1265 Data truncated for column 'c20' at row 1 +insert into t1 values (0.5e4); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 drop table t1; create table t1 (f float(54)); ERROR 42000: Incorrect column specifier for column 'f' @@ -203,3 +215,23 @@ c 0.0002 2e-05 drop table t1; +CREATE TABLE t1 ( +reckey int unsigned NOT NULL, +recdesc varchar(50) NOT NULL, +PRIMARY KEY (reckey) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (108, 'Has 108 as key'); +INSERT INTO t1 VALUES (109, 'Has 109 as key'); +select * from t1 where reckey=108; +reckey recdesc +108 Has 108 as key +select * from t1 where reckey=1.08E2; +reckey recdesc +108 Has 108 as key +select * from t1 where reckey=109; +reckey recdesc +109 Has 109 as key +select * from t1 where reckey=1.09E2; +reckey recdesc +109 Has 109 as key +drop table t1; diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 86aecf43cbd..3639fc2e262 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -1,3 +1,10 @@ # We run with different binaries for normal and --embedded-server +# +# If this test fails with "command "$MYSQL_CLIENT_TEST" failed", +# you should either run mysql_client_test separartely against a running +# server or run mysql-test-run --debug mysql_client_test and check +# var/log/mysql_client_test.trace + --disable_result_log +--exec echo $MYSQL_CLIENT_TEST --exec $MYSQL_CLIENT_TEST diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index 4ab81dfcac5..b3ce6d7fd82 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -11,6 +11,7 @@ --disable_warnings drop table if exists t5, t6, t7, t8; drop database if exists mysqltest ; +drop database if exists client_test_db; --enable_warnings --disable_query_log diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 5b106d242de..6e991dc53d4 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -3,7 +3,7 @@ # Numeric floating point. --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings --replace_result e-0 e- e+0 e+ @@ -11,6 +11,9 @@ SELECT 10,10.0,10.,.1e+2,100.0e-1; --replace_result e-00 e-0 SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; +SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; +SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; +SELECT 2147483647E+02,21474836.47E+06; create table t1 (f1 float(24),f2 float(52)); show full columns from t1; @@ -83,6 +86,7 @@ drop table t1; # create table t1 (c20 char); insert into t1 values (5000.0); +insert into t1 values (0.5e4); drop table t1; # Errors @@ -120,3 +124,23 @@ create table t1 (c char(6)); insert into t1 values (2e5),(2e6),(2e-4),(2e-5); select * from t1; drop table t1; + +# +# Test of comparison of integer with float-in-range (Bug #7840) +# This is needed because some ODBC applications (like Foxpro) uses +# floats for everything. +# + +CREATE TABLE t1 ( + reckey int unsigned NOT NULL, + recdesc varchar(50) NOT NULL, + PRIMARY KEY (reckey) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES (108, 'Has 108 as key'); +INSERT INTO t1 VALUES (109, 'Has 109 as key'); +select * from t1 where reckey=108; +select * from t1 where reckey=1.08E2; +select * from t1 where reckey=109; +select * from t1 where reckey=1.09E2; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index fa0e202d513..ca923d723bc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -968,7 +968,9 @@ int Field_decimal::store(longlong nr) double Field_decimal::val_real(void) { int not_used; - return my_strntod(&my_charset_bin, ptr, field_length, NULL, ¬_used); + char *end_not_used; + return my_strntod(&my_charset_bin, ptr, field_length, &end_not_used, + ¬_used); } longlong Field_decimal::val_int(void) @@ -4360,8 +4362,9 @@ int Field_string::store(longlong nr) double Field_string::val_real(void) { int not_used; + char *end_not_used; CHARSET_INFO *cs=charset(); - return my_strntod(cs,ptr,field_length,(char**)0,¬_used); + return my_strntod(cs, ptr, field_length, &end_not_used, ¬_used); } @@ -4577,7 +4580,9 @@ double Field_varstring::val_real(void) int not_used; uint length=uint2korr(ptr)+HA_KEY_BLOB_LENGTH; CHARSET_INFO *cs=charset(); - return my_strntod(cs, ptr+HA_KEY_BLOB_LENGTH, length, (char**)0, ¬_used); + char *end_not_used; + return my_strntod(cs, ptr+HA_KEY_BLOB_LENGTH, length, &end_not_used, + ¬_used); } @@ -4955,12 +4960,13 @@ double Field_blob::val_real(void) { int not_used; char *blob; + char *end_not_used; memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); if (!blob) return 0.0; uint32 length=get_length(ptr); CHARSET_INFO *cs=charset(); - return my_strntod(cs,blob,length,(char**)0, ¬_used); + return my_strntod(cs,blob,length, &end_not_used, ¬_used); } diff --git a/sql/item.cc b/sql/item.cc index 4b3acbe5a3c..76cbaa99029 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1140,8 +1140,9 @@ double Item_param::val() case LONG_DATA_VALUE: { int dummy_err; + char *end_not_used; return my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), (char**) 0, &dummy_err); + str_value.length(), &end_not_used, &dummy_err); } case TIME_VALUE: /* @@ -2585,10 +2586,12 @@ double Item_cache_str::val() DBUG_ASSERT(fixed == 1); int err; if (value) + { + char *end_not_used; return my_strntod(value->charset(), (char*) value->ptr(), - value->length(), (char**) 0, &err); - else - return (double)0; + value->length(), &end_not_used, &err); + } + return (double)0; } diff --git a/sql/item.h b/sql/item.h index dd06d4ce61a..97e2b0c0945 100644 --- a/sql/item.h +++ b/sql/item.h @@ -719,8 +719,9 @@ public: { DBUG_ASSERT(fixed == 1); int err; + char *end_not_used; return my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), (char**) 0, &err); + str_value.length(), &end_not_used, &err); } longlong val_int() { @@ -1044,9 +1045,10 @@ public: double val() { int err; + char *end_not_used; return (null_value ? 0.0 : my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(),NULL,&err)); + str_value.length(), &end_not_used, &err)); } longlong val_int() { diff --git a/sql/item_func.h b/sql/item_func.h index 8a5347d675e..2738c7419ca 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -828,8 +828,11 @@ public: double val() { int err; - String *res; res=val_str(&str_value); - return res ? my_strntod(res->charset(),(char*) res->ptr(),res->length(),0,&err) : 0.0; + String *res; + char *end_not_used; + res=val_str(&str_value); + return res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(), + &end_not_used, &err) : 0.0; } longlong val_int() { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index bbbcadbb071..8bd1da4e15f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -63,10 +63,11 @@ double Item_str_func::val() DBUG_ASSERT(fixed == 1); int err; char buff[64]; + char *end_not_used; String *res, tmp(buff,sizeof(buff), &my_charset_bin); res= val_str(&tmp); return res ? my_strntod(res->charset(), (char*) res->ptr(),res->length(), - NULL, &err) : 0.0; + &end_not_used, &err) : 0.0; } longlong Item_str_func::val_int() diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 029a1fd6c48..6bd2cc00b3e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -471,13 +471,14 @@ double Item_sum_hybrid::val() { DBUG_ASSERT(fixed == 1); int err; + char *end_not_used; if (null_value) return 0.0; switch (hybrid_type) { case STRING_RESULT: String *res; res=val_str(&str_value); return (res ? my_strntod(res->charset(), (char*) res->ptr(),res->length(), - (char**) 0, &err) : 0.0); + &end_not_used, &err) : 0.0); case INT_RESULT: if (unsigned_flag) return ulonglong2double(sum_int); diff --git a/sql/item_sum.h b/sql/item_sum.h index d1e82387944..dab136e4716 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -600,9 +600,11 @@ public: double val() { int err; - String *res; res=val_str(&str_value); + char *end_not_used; + String *res; + res=val_str(&str_value); return res ? my_strntod(res->charset(),(char*) res->ptr(),res->length(), - (char**) 0, &err) : 0.0; + &end_not_used, &err) : 0.0; } longlong val_int() { diff --git a/sql/procedure.h b/sql/procedure.h index 5365b2e1102..abe50bdc0a0 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -59,7 +59,11 @@ public: void set(double nr) { value=nr; } void set(longlong nr) { value=(double) nr; } void set(const char *str,uint length,CHARSET_INFO *cs) - { int err; value=my_strntod(cs,(char*) str,length,(char**)0,&err); } + { + int err; + char *end_not_used; + value= my_strntod(cs, (char*) str, length, &end_not_used, &err); + } double val() { return value; } longlong val_int() { return (longlong) value; } String *val_str(String *s) { s->set(value,decimals,default_charset()); return s; } @@ -99,9 +103,10 @@ public: double val() { int err; - CHARSET_INFO *cs=str_value.charset(); + CHARSET_INFO *cs= str_value.charset(); + char *end_not_used; return my_strntod(cs, (char*) str_value.ptr(), str_value.length(), - (char**) 0, &err); + &end_not_used, &err); } longlong val_int() { diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 1a09b16a264..c2a6aa4e17f 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -773,31 +773,10 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), char *str, uint length, char **end, int *err) { - char end_char; - double result; - - errno= 0; /* Safety */ - - /* - The following define is to avoid warnings from valgrind as str[length] - may not be defined (which is not fatal in real life) - */ - -#ifdef HAVE_purify if (length == INT_MAX32) -#else - if (length == INT_MAX32 || str[length] == 0) -#endif - result= my_strtod(str, end); - else - { - end_char= str[length]; - str[length]= 0; - result= my_strtod(str, end); - str[length]= end_char; /* Restore end char */ - } - *err= errno; - return result; + length= 65535; /* Should be big enough */ + *end= str + length; + return my_strtod(str, end, err); } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index e92704b83d7..9c67d1b7846 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -946,13 +946,10 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), break; /* Can't be part of double */ *b++= (char) wc; } - *b= 0; - errno= 0; - res=my_strtod(buf, endptr); - *err= errno; - if (endptr) - *endptr=(char*) (*endptr-buf+nptr); + *endptr= b; + res= my_strtod(buf, endptr, err); + *endptr= nptr + (uint) (*endptr- buf); return res; } diff --git a/strings/strtod.c b/strings/strtod.c index bc8105b8040..61f2c107abe 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -2,7 +2,7 @@ An alternative implementation of "strtod()" that is both simplier, and thread-safe. - From mit-threads as bundled with MySQL 3.23 + Original code from mit-threads as bundled with MySQL 3.23 SQL:2003 specifies a number as @@ -29,6 +29,8 @@ #include "my_base.h" /* Includes errno.h */ #include "m_ctype.h" +#define MAX_DBL_EXP 308 +#define MAX_RESULT_FOR_MAX_EXP 1.79769313486232 static double scaler10[] = { 1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90 }; @@ -37,89 +39,157 @@ static double scaler1[] = { }; -double my_strtod(const char *str, char **end) +/* + Convert string to double (string doesn't have to be null terminated) + + SYNOPSIS + my_strtod() + str String to convert + end_ptr Pointer to pointer that points to end of string + Will be updated to point to end of double. + error Will contain error number in case of error (else 0) + + RETURN + value of str as double +*/ + +double my_strtod(const char *str, char **end_ptr, int *error) { double result= 0.0; - int negative, ndigits; - const char *old_str; + uint negative= 0, ndigits, dec_digits= 0, neg_exp= 0; + int exp= 0, digits_after_dec_point= 0; + const char *old_str, *end= *end_ptr, *start_of_number; + char next_char; my_bool overflow=0; - while (my_isspace(&my_charset_latin1, *str)) - str++; + *error= 0; + if (str >= end) + goto done; + while (my_isspace(&my_charset_latin1, *str)) + { + if (++str == end) + goto done; + } + + start_of_number= str; if ((negative= (*str == '-')) || *str=='+') - str++; + { + if (++str == end) + goto done; /* Could be changed to error */ + } + + /* Skip pre-zero for easier calculation of overflows */ + while (*str == '0') + { + if (++str == end) + goto done; + start_of_number= 0; /* Found digit */ + } old_str= str; - while (my_isdigit (&my_charset_latin1, *str)) + while ((next_char= *str) >= '0' && next_char <= '9') { - result= result*10.0 + (*str - '0'); - str++; - } - ndigits= str-old_str; - - if (*str == '.') - { - double p10=10; - str++; - old_str= str; - while (my_isdigit (&my_charset_latin1, *str)) + result= result*10.0 + (next_char - '0'); + if (++str == end) { - result+= (*str++ - '0')/p10; - p10*=10; + next_char= 0; /* Found end of string */ + break; } - ndigits+= str-old_str; - if (!ndigits) str--; + start_of_number= 0; /* Found digit */ } - if (ndigits && (*str=='e' || *str=='E')) + ndigits= (uint) (str-old_str); + + if (next_char == '.' && str < end-1) + { + /* + Continue to add numbers after decimal point to the result, as if there + was no decimal point. We will later (in the exponent handling) shift + the number down with the required number of fractions. We do it this + way to be able to get maximum precision for numbers like 123.45E+02, + which are normal for some ODBC applications. + */ + old_str= ++str; + while (my_isdigit(&my_charset_latin1, (next_char= *str))) + { + result= result*10.0 + (next_char - '0'); + digits_after_dec_point++; + if (++str == end) + { + next_char= 0; + break; + } + } + /* If we found just '+.' or '.' then point at first character */ + if (!(dec_digits= (uint) (str-old_str)) && start_of_number) + str= start_of_number; /* Point at '+' or '.' */ + } + if ((next_char == 'e' || next_char == 'E') && + dec_digits + ndigits != 0 && str < end-1) { - int exp= 0; - int neg= 0; const char *old_str= str++; - if ((neg= (*str == '-')) || *str == '+') + if ((neg_exp= (*str == '-')) || *str == '+') str++; - if (!my_isdigit (&my_charset_latin1, *str)) + if (str == end || !my_isdigit(&my_charset_latin1, *str)) str= old_str; else { - double scaler= 1.0; - while (my_isdigit (&my_charset_latin1, *str)) + do { - if (exp < 9999) /* protection against exp overflow */ - exp= exp*10 + *str - '0'; + if (exp < 9999) /* prot. against exp overfl. */ + exp= exp*10 + (*str - '0'); str++; - } - if (exp >= 1000) + } while (str < end && my_isdigit(&my_charset_latin1, *str)); + } + } + if ((exp= (neg_exp ? exp + digits_after_dec_point : + exp - digits_after_dec_point))) + { + double scaler; + if (exp < 0) + { + exp= -exp; + neg_exp= 1; /* neg_exp was 0 before */ + } + if (exp + ndigits >= MAX_DBL_EXP + 1 && result) + { + /* + This is not 100 % as we actually will give an owerflow for + 17E307 but not for 1.7E308 but lets cut some corners to make life + simpler + */ + if (exp + ndigits > MAX_DBL_EXP + 1 || + result >= MAX_RESULT_FOR_MAX_EXP) { - if (neg) - result= 0.0; - else + if (neg_exp) + result= 0.0; + else overflow= 1; goto done; } - while (exp >= 100) - { - scaler*= 1.0e100; - exp-= 100; - } - scaler*= scaler10[exp/10]*scaler1[exp%10]; - if (neg) - result/= scaler; - else - result*= scaler; } + scaler= 1.0; + while (exp >= 100) + { + scaler*= 1.0e100; + exp-= 100; + } + scaler*= scaler10[exp/10]*scaler1[exp%10]; + if (neg_exp) + result/= scaler; + else + result*= scaler; } done: - if (end) - *end = (char *)str; + *end_ptr= (char*) str; /* end of number */ if (overflow || isinf(result)) { result= DBL_MAX; - errno= EOVERFLOW; + *error= EOVERFLOW; } return negative ? -result : result; @@ -127,6 +197,7 @@ done: double my_atof(const char *nptr) { - return (my_strtod(nptr, 0)); + int error; + const char *end= nptr+65535; /* Should be enough */ + return (my_strtod(nptr, (char**) &end, &error)); } - From 7d766fdbeb1418488f99125b510dce5942b7f79f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 12:40:31 +0100 Subject: [PATCH 21/41] BUG#6662: Changes after Guilhems and Sergs review --- client/mysqldump.c | 7 +++---- mysql-test/r/mysqldump.result | 18 ++++++++++++++++++ sql/mysql_priv.h | 4 ++-- sql/mysqld.cc | 2 +- sql/set_var.cc | 4 +++- sql/sql_error.cc | 2 +- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 2a6d9adf8bd..c2c44024cf4 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -489,11 +489,10 @@ static void write_header(FILE *sql_file, char *db_name) "); } fprintf(sql_file, - "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n", + "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n" + "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n", path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", compatible_mode_normal_str); - fprintf(sql_file, - "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n"); check_io(sql_file); } } /* write_header */ @@ -521,7 +520,7 @@ static void write_footer(FILE *sql_file) "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n" "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n"); fprintf(sql_file, - "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); + "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n"); fputs("\n", sql_file); check_io(sql_file); } diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 754d1458eac..f763a16836f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -82,6 +82,7 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; @@ -97,6 +98,7 @@ INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456) /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); @@ -173,6 +175,7 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + DROP TABLE t1; CREATE TABLE t1 (a int) ENGINE=MYISAM; INSERT INTO t1 VALUES (1), (2); @@ -196,6 +199,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; @@ -216,6 +220,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + DROP TABLE t1; create table ```a` (i int); CREATE TABLE ```a` ( @@ -250,6 +255,7 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; @@ -269,6 +275,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + set global sql_mode='ANSI_QUOTES'; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; @@ -297,6 +304,7 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; @@ -316,6 +324,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + set global sql_mode=''; drop table t1; create table t1(a int); @@ -338,6 +347,7 @@ CREATE TABLE `t1` ( /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + 1 2 3 @@ -363,6 +373,7 @@ USE `test`; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + create database mysqldump_test_db character set latin2 collate latin2_bin; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; @@ -385,6 +396,7 @@ USE `mysqldump_test_db`; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + drop database mysqldump_test_db; CREATE TABLE t1 (a CHAR(10)); INSERT INTO t1 VALUES (_latin1 ''); @@ -416,6 +428,7 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; @@ -436,6 +449,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; @@ -456,6 +470,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; @@ -476,6 +491,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; @@ -496,6 +512,7 @@ UNLOCK TABLES; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + DROP TABLE t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); @@ -529,5 +546,6 @@ UNLOCK TABLES; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + DROP TABLE t1; DROP TABLE t2; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3cb5eba8efa..3f7262283b4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -213,8 +213,8 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define SELECT_NO_UNLOCK (1L << 28) /* If set to 0, then the thread will ignore all warnings with level notes. - Set by executing SET SHOW_NOTES=1 */ -#define OPTION_NOTES (1L << 31) + Set by executing SET SQL_NOTES=1 */ +#define OPTION_SQL_NOTES (1L << 31) /* Bits for different SQL modes modes (including ANSI mode) */ #define MODE_REAL_AS_FLOAT 1 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3e4d0593a85..fd3c26c6175 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5623,7 +5623,7 @@ static void mysql_init_variables(void) mysql_data_home= mysql_real_data_home; thd_startup_options= (OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL | OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE | - OPTION_NOTES); + OPTION_SQL_NOTES); protocol_version= PROTOCOL_VERSION; what_to_log= ~ (1L << (uint) COM_TIME); refresh_version= flush_version= 1L; /* Increments on each reload */ diff --git a/sql/set_var.cc b/sql/set_var.cc index 00ab4658f30..5fdb3de3178 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -425,7 +425,7 @@ static sys_var_thd_bit sys_sql_warnings("sql_warnings", 0, OPTION_WARNINGS); static sys_var_thd_bit sys_sql_notes("sql_notes", 0, set_option_bit, - OPTION_NOTES); + OPTION_SQL_NOTES); static sys_var_thd_bit sys_auto_is_null("sql_auto_is_null", 0, set_option_bit, OPTION_AUTO_IS_NULL); @@ -863,6 +863,8 @@ struct show_var_st init_vars[]= { {sys_sort_buffer.name, (char*) &sys_sort_buffer, SHOW_SYS}, {sys_sql_mode.name, (char*) &sys_sql_mode, SHOW_SYS}, {sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS}, + {"sql_notes", (char*) &sys_sql_notes, SHOW_BOOL}, + {"sql_warnings", (char*) &sys_sql_warnings, SHOW_BOOL}, #ifdef HAVE_REPLICATION {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, {sys_sync_replication.name, (char*) &sys_sync_replication, SHOW_SYS}, diff --git a/sql/sql_error.cc b/sql/sql_error.cc index e04c2843c93..d19e9fbdb09 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -105,7 +105,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, MYSQL_ERROR *err= 0; DBUG_ENTER("push_warning"); - if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_NOTES)) + if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_SQL_NOTES)) return(0); if (thd->query_id != thd->warn_id) From 2fb807d1d0a817c177e02cee7b508b6122ce832e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 15:55:40 +0400 Subject: [PATCH 22/41] A user variable are now always have IMPLICIT coercibility, independently from the expression it is initialized from. In other words, this change treats a user variable like a table with one column and one record. Discussed with PeterG, Serg and Lars. This change also simplifies replication allowing not to replicate variables' coercibility. mysql-test/r/user_var.result: Test changes accordintly mysql-test/t/user_var.test: Test changes accordintly --- mysql-test/r/user_var.result | 16 +++++++++------- mysql-test/t/user_var.test | 2 -- sql/item_func.cc | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 81846391795..d82c17b0fe0 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -123,7 +123,7 @@ drop table t1; set @a=_latin2'test'; select charset(@a),collation(@a),coercibility(@a); charset(@a) collation(@a) coercibility(@a) -latin2 latin2_general_ci 3 +latin2 latin2_general_ci 2 select @a=_latin2'TEST'; @a=_latin2'TEST' 1 @@ -133,12 +133,13 @@ select @a=_latin2'TEST' collate latin2_bin; set @a=_latin2'test' collate latin2_general_ci; select charset(@a),collation(@a),coercibility(@a); charset(@a) collation(@a) coercibility(@a) -latin2 latin2_general_ci 0 +latin2 latin2_general_ci 2 select @a=_latin2'TEST'; @a=_latin2'TEST' 1 select @a=_latin2'TEST' collate latin2_bin; -ERROR HY000: Illegal mix of collations (latin2_general_ci,EXPLICIT) and (latin2_bin,EXPLICIT) for operation '=' +@a=_latin2'TEST' collate latin2_bin +0 select charset(@a:=_latin2'test'); charset(@a:=_latin2'test') latin2 @@ -147,21 +148,22 @@ collation(@a:=_latin2'test') latin2_general_ci select coercibility(@a:=_latin2'test'); coercibility(@a:=_latin2'test') -3 +2 select collation(@a:=_latin2'test' collate latin2_bin); collation(@a:=_latin2'test' collate latin2_bin) latin2_bin select coercibility(@a:=_latin2'test' collate latin2_bin); coercibility(@a:=_latin2'test' collate latin2_bin) -0 +2 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' 0 select charset(@a),collation(@a),coercibility(@a); charset(@a) collation(@a) coercibility(@a) -latin2 latin2_bin 0 +latin2 latin2_bin 2 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; -ERROR HY000: Illegal mix of collations (latin2_bin,EXPLICIT) and (latin2_general_ci,EXPLICIT) for operation '=' +(@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci +1 create table t1 (a varchar(50)); reset master; SET TIMESTAMP=10000; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 81788ce8d73..2f526dc9a46 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -84,7 +84,6 @@ select @a=_latin2'TEST' collate latin2_bin; set @a=_latin2'test' collate latin2_general_ci; select charset(@a),collation(@a),coercibility(@a); select @a=_latin2'TEST'; ---error 1267 select @a=_latin2'TEST' collate latin2_bin; # @@ -97,7 +96,6 @@ select collation(@a:=_latin2'test' collate latin2_bin); select coercibility(@a:=_latin2'test' collate latin2_bin); select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; select charset(@a),collation(@a),coercibility(@a); ---error 1267 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; # Check that user variables are binlogged correctly (BUG#3875) diff --git a/sql/item_func.cc b/sql/item_func.cc index 34c8732a9f2..895740d2e5e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2361,7 +2361,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, entry->value=0; entry->length=0; entry->update_query_id=0; - entry->collation.set(NULL, DERIVATION_NONE); + entry->collation.set(NULL, DERIVATION_IMPLICIT); /* If we are here, we were called from a SET or a query which sets a variable. Imagine it is this: @@ -2419,8 +2419,8 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables, and the variable has previously been initialized. */ if (!entry->collation.collation || !args[0]->null_value) - entry->collation.set(args[0]->collation); - collation.set(entry->collation); + entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); + collation.set(entry->collation.collation, DERIVATION_IMPLICIT); cached_result_type= args[0]->result_type(); return 0; } @@ -2432,7 +2432,7 @@ Item_func_set_user_var::fix_length_and_dec() maybe_null=args[0]->maybe_null; max_length=args[0]->max_length; decimals=args[0]->decimals; - collation.set(args[0]->collation); + collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); } @@ -2659,7 +2659,7 @@ Item_func_set_user_var::update() res= update_hash((void*) save_result.vstr->ptr(), save_result.vstr->length(), STRING_RESULT, save_result.vstr->charset(), - args[0]->collation.derivation); + DERIVATION_IMPLICIT); break; } case ROW_RESULT: From 6965e72bd07874efee8ff6f94ab664533fc422e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 14:15:50 +0200 Subject: [PATCH 23/41] Fixed compiler warnings Fixed failing myisam.test and rpl_rotate_logs.test on some configurations mysql-test/r/myisam.result: Portability fix mysql-test/r/rpl_rotate_logs.result: Portability fix mysql-test/t/myisam.test: Depending on if you compiled with -DHAVE_RAID or not, you could get different errors for this test mysql-test/t/rpl_rotate_logs.test: Portability fix sql/ha_innodb.cc: Fixed compiler warnings --- mysql-test/r/myisam.result | 4 ++-- mysql-test/r/rpl_rotate_logs.result | 4 ++-- mysql-test/t/myisam.test | 4 ++-- mysql-test/t/rpl_rotate_logs.test | 3 +++ sql/ha_innodb.cc | 6 +++--- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 01aca27d4fc..256bc1e3745 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1156,9 +1156,9 @@ Warnings: Error 2 Can't find file: 't1' (errno: 2) create table t1 (a int) engine=myisam; drop table t1; -ERROR 42S02: Unknown table 't1' +Got one of the listed errors create table t1 (a int) engine=myisam; drop table t1; -ERROR HY000: File './test/t1.MYD' not found (Errcode: 2) +Got one of the listed errors drop table t1; ERROR 42S02: Unknown table 't1' diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 2a73eea7517..745d4d8138e 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -100,7 +100,7 @@ commit; drop table t1; show binlog events in 'master-bin.000001'; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 96 Server ver: 5.0.3-alpha-debug-log, Binlog ver: 4 +master-bin.000001 4 Format_desc 1 96 Server ver: VERSION, Binlog ver: 4 master-bin.000001 96 Query 1 197 use `test`; create table t1 (n int) engine=innodb master-bin.000001 197 Query 1 266 use `test`; BEGIN master-bin.000001 266 Query 1 94 use `test`; insert into t1 values(100 + 4) @@ -207,5 +207,5 @@ master-bin.000001 9558 Xid 1 9319 COMMIT /* xid=146 */ master-bin.000001 9585 Rotate 1 9629 master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000002 4 Format_desc 1 96 Server ver: 5.0.3-alpha-debug-log, Binlog ver: 4 +master-bin.000002 4 Format_desc 1 96 Server ver: VERSION, Binlog ver: 4 master-bin.000002 96 Query 1 173 use `test`; drop table t1 diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 05e80597fab..f919bfced77 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -548,11 +548,11 @@ system rm ./var/master-data/test/t1.MYI ; drop table if exists t1; create table t1 (a int) engine=myisam; system rm ./var/master-data/test/t1.MYI ; ---error 1051 +--error 1051,6 drop table t1; create table t1 (a int) engine=myisam; system rm ./var/master-data/test/t1.MYD ; ---error 1105 +--error 1105,6 drop table t1; --error 1051 drop table t1; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 1029c64867a..850d3c1741c 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -174,6 +174,9 @@ while ($1) --enable_query_log commit; drop table t1; +let $VERSION=`select version()`; +--replace_result $VERSION VERSION show binlog events in 'master-bin.000001'; +--replace_result $VERSION VERSION show binlog events in 'master-bin.000002'; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index d6e17b3b5e2..d2607616a55 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1698,7 +1698,7 @@ innobase_rollback_to_savepoint( innobase_release_stat_resources(trx); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", savepoint); + char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); error = trx_rollback_to_savepoint_for_mysql(trx, name, &mysql_binlog_cache_pos); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); @@ -1724,7 +1724,7 @@ innobase_release_savepoint( trx = check_trx_exists(thd); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", savepoint); + char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); error = trx_release_savepoint_for_mysql(trx, name); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); @@ -1763,7 +1763,7 @@ innobase_savepoint( DBUG_ASSERT(trx->active_trans); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", savepoint); + char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); error = trx_savepoint_for_mysql(trx, name, (ib_longlong)0); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); From 0865c81c09e54516f5fd17b23bb0fedde61eee06 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 14:39:15 +0200 Subject: [PATCH 24/41] Copy X/Open XA XID from trx structure to a list in recovery. --- innobase/trx/trx0trx.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index eee0d43ce56..7d5370b1ac1 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -1848,7 +1848,7 @@ trx_recover_for_mysql( ulint len) /* in: number of slots in xid_list */ { trx_t* trx; - int num_of_transactions = 0; + int count = 0; ut_ad(xid_list); ut_ad(len); @@ -1866,7 +1866,16 @@ trx_recover_for_mysql( while (trx) { if (trx->conc_state == TRX_PREPARED) { - xid_list[num_of_transactions] = trx->xid; + xid_list[count].formatID = trx->xid.formatID; + xid_list[count].gtrid_length = trx->xid.gtrid_length; + xid_list[count].bqual_length = trx->xid.bqual_length; + + memcpy(xid_list[count].data, + trx->xid.data, + trx->xid.gtrid_length + + trx->xid.bqual_length); + + ut_print_timestamp(stderr); fprintf(stderr, "InnoDB: Transaction %lu %lu in prepared state after recovery\n", @@ -1877,9 +1886,9 @@ trx_recover_for_mysql( "InnoDB: Transaction contains changes to %lu rows\n", (ulong)ut_conv_dulint_to_longlong(trx->undo_no)); - num_of_transactions++; + count++; - if ((uint)num_of_transactions == len ) { + if ((uint)count == len ) { break; } } @@ -1891,9 +1900,9 @@ trx_recover_for_mysql( fprintf(stderr, "InnoDB: %d transactions in prepare state after recovery\n", - num_of_transactions); + count); - return (num_of_transactions); + return (count); } /*********************************************************************** From acaa20e21e5c086b2a1b375f4145bec52435482d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 15:03:17 +0200 Subject: [PATCH 25/41] Clean up prints in innodb_xa_prepare. --- innobase/trx/trx0trx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 7d5370b1ac1..69415beb331 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -1853,8 +1853,9 @@ trx_recover_for_mysql( ut_ad(xid_list); ut_ad(len); + ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: Starting recovery for XA transactions...\n"); + " InnoDB: Starting recovery for XA transactions...\n"); /* We should set those transactions which are in @@ -1876,14 +1877,14 @@ trx_recover_for_mysql( trx->xid.bqual_length); ut_print_timestamp(stderr); - fprintf(stderr, -"InnoDB: Transaction %lu %lu in prepared state after recovery\n", +" InnoDB: Transaction %lu %lu in prepared state after recovery\n", (ulong) ut_dulint_get_high(trx->id), (ulong) ut_dulint_get_low(trx->id)); + ut_print_timestamp(stderr); fprintf(stderr, -"InnoDB: Transaction contains changes to %lu rows\n", +" InnoDB: Transaction contains changes to %lu rows\n", (ulong)ut_conv_dulint_to_longlong(trx->undo_no)); count++; @@ -1898,8 +1899,9 @@ trx_recover_for_mysql( mutex_exit(&kernel_mutex); + ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: %d transactions in prepare state after recovery\n", +" InnoDB: %d transactions in prepare state after recovery\n", count); return (count); From 2ae6eb094bb02a3e41ab611c9e9f27982a2ef9c3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 15:08:12 +0200 Subject: [PATCH 26/41] Fix errors in my last changeset --- libmysql/libmysql.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9c49c7eb15b..16dda115ee9 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3390,14 +3390,17 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, } case MYSQL_TYPE_FLOAT: { + char *end_not_used; float data = (float) my_strntod(&my_charset_latin1, value, length, - NULL, &err); + &end_not_used, &err); floatstore(buffer, data); break; } case MYSQL_TYPE_DOUBLE: { - double data= my_strntod(&my_charset_latin1, value, length, NULL, &err); + char *end_not_used; + double data= my_strntod(&my_charset_latin1, value, length, &end_not_used, + &err); doublestore(buffer, data); break; } From 59554966bb8b652f2c8f388937952bbdae407e93 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 15:40:13 +0200 Subject: [PATCH 27/41] Fixed a bug on InnoDB X/Open XA prepare. --- innobase/trx/trx0undo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index 4bfa9c20a54..e9296d1d9c7 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -537,7 +537,7 @@ trx_undo_header_create( /* If X/Open XID exits in the log header we store a flag of it in upper byte of dict operation flag. */ - if (xid != NULL || xid->formatID != -1) { + if (xid != NULL && xid->formatID != -1) { mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, TRUE); } else { mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE); From 10ffa887f0123fd45e853c38dbc9cc88071954d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 16:18:34 +0200 Subject: [PATCH 28/41] trx0trx.c: Disable the XA code in InnoDB crash recovery; when Jan and Sergei want to test XA, they should revert this patch innobase/trx/trx0trx.c: Disable the XA code in crash recovery; when Jan and Sergei want to test XA, they should revert this patch --- innobase/trx/trx0trx.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 69415beb331..40e12f206dc 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -434,9 +434,21 @@ trx_lists_init_at_db_start(void) commit or abort decision from MySQL */ if (undo->state == TRX_UNDO_PREPARED) { - trx->conc_state = TRX_PREPARED; + + fprintf(stderr, +"InnoDB: Transaction %lu %lu was in the XA prepared state. We change it to\n" +"InnoDB: the 'active' state, so that InnoDB's true-and-tested crash\n" +"InnoDB: recovery will roll it back. If mysqld refuses to start after\n" +"InnoDB: this, you may be able to resolve the problem by moving the binlog\n" +"InnoDB: files to a safe place, and deleting all binlog files and the binlog\n" +"InnoDB: .index file from the datadir.\n", ut_dulint_get_high(trx->id), + ut_dulint_get_low(trx->id)); + + /* trx->conc_state = TRX_PREPARED; */ + trx->conc_state = + TRX_ACTIVE; } else { - trx->conc_state = + trx->conc_state = TRX_COMMITTED_IN_MEMORY; } @@ -490,11 +502,23 @@ trx_lists_init_at_db_start(void) commit or abort decision from MySQL */ if (undo->state == TRX_UNDO_PREPARED) { - trx->conc_state = - TRX_PREPARED; + + fprintf(stderr, +"InnoDB: Transaction %lu %lu was in the XA prepared state. We change it to\n" +"InnoDB: the 'active' state, so that InnoDB's true-and-tested crash\n" +"InnoDB: recovery will roll it back. If mysqld refuses to start after\n" +"InnoDB: this, you may be able to resolve the problem by moving the binlog\n" +"InnoDB: files to a safe place, and deleting all binlog files and the binlog\n" +"InnoDB: .index file from the datadir.\n", ut_dulint_get_high(trx->id), + ut_dulint_get_low(trx->id)); + + /* trx->conc_state = TRX_PREPARED; */ + trx->conc_state = + TRX_ACTIVE; + } else { trx->conc_state = - TRX_COMMITTED_IN_MEMORY; + TRX_COMMITTED_IN_MEMORY; } /* We give a dummy value for the trx From 7caef7f4aa826db751626a9833c70df33ebf1363 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 15:22:37 +0100 Subject: [PATCH 29/41] compatibility fixes, crashing tests include/my_sys.h: sol9x86, sunfire100b, qnx compatibility mysql-test/t/rpl_rotate_logs.test: fix the test sql/ha_innodb.cc: don't bother sql/handler.cc: few more ways to crash mysqld :) sql/handler.h: gdb/safemalloc workaround sql/log.cc: rotate a binlog on heuristic recover sql/mysqld.cc: rotate a binlog on heuristic recover --- include/my_sys.h | 7 ++++++- mysql-test/t/rpl_rotate_logs.test | 1 + sql/ha_innodb.cc | 4 ++-- sql/handler.cc | 8 ++++++-- sql/handler.h | 4 ++++ sql/log.cc | 11 ++++++++--- sql/mysqld.cc | 2 +- 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 498a1bd30fe..4618c25dbfb 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -804,8 +804,13 @@ my_bool my_gethwaddr(uchar *to); #endif #define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) +#ifdef HAVE_GETPAGESIZE #define my_getpagesize() getpagesize() -#define my_munmap(a,b) munmap(a,b) +#else +/* qnx ? */ +#define my_getpagesize() 8192 +#endif +#define my_munmap(a,b) munmap((char*)(a),(b)) #else /* not a complete set of mmap() flags, but only those that nesessary */ diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 1029c64867a..c11a19c343b 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -174,6 +174,7 @@ while ($1) --enable_query_log commit; drop table t1; +--replace_result "xid=373" "xid=146" show binlog events in 'master-bin.000001'; show binlog events in 'master-bin.000002'; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index d6e17b3b5e2..ac5cb4221be 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1346,14 +1346,14 @@ innobase_commit_low( return; } -#ifdef HAVE_REPLICATION +#ifdef DISABLE_HAVE_REPLICATION if (current_thd->slave_thread) { /* Update the replication position info inside InnoDB */ trx->mysql_master_log_file_name = active_mi->rli.group_master_log_name; trx->mysql_master_log_pos= ((ib_longlong) - active_mi->rli.future_group_master_log_pos); + active_mi->rli.future_group_master_log_pos); } #endif /* HAVE_REPLICATION */ diff --git a/sql/handler.cc b/sql/handler.cc index b733ec6c267..b76fbe5ccd5 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -553,6 +553,7 @@ int ha_commit_trans(THD *thd, bool all) #ifdef USING_TRANSACTIONS if (trans->nht) { + DBUG_EXECUTE_IF("crash_commit_before", abort();); if (!trans->no_2pc && trans->nht > 1) { for (; *ht && !error; ht++) @@ -565,16 +566,20 @@ int ha_commit_trans(THD *thd, bool all) } statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status); } + DBUG_EXECUTE_IF("crash_commit_after_prepare", abort();); if (error || (is_real_trans && xid && (error= !(cookie= tc_log->log(thd, xid))))) { ha_rollback_trans(thd, all); return 1; } + DBUG_EXECUTE_IF("crash_commit_after_log", abort();); } error=ha_commit_one_phase(thd, all) ? cookie ? 2 : 1 : 0; + DBUG_EXECUTE_IF("crash_commit_before_unlog", abort();); if (cookie) tc_log->unlog(cookie, xid); + DBUG_EXECUTE_IF("crash_commit_after", abort();); } #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); @@ -738,8 +743,7 @@ int ha_recover(HASH *commit_list) DBUG_ASSERT(total_ha_2pc); DBUG_ASSERT(commit_list || tc_heuristic_recover); - for (len=commit_list ? commit_list->records : MAX_XID_LIST_SIZE ; - list==0 && len > MIN_XID_LIST_SIZE; len/=2) + for (len= MAX_XID_LIST_SIZE ; list==0 && len > MIN_XID_LIST_SIZE; len/=2) { list=(XID *)my_malloc(len*sizeof(XID), MYF(0)); } diff --git a/sql/handler.h b/sql/handler.h index 3a1862cad07..ad9345ac75c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -253,7 +253,11 @@ typedef struct xid_t XID; /* for recover() handlerton call */ #define MIN_XID_LIST_SIZE 128 +#ifdef SAFEMALLOC +#define MAX_XID_LIST_SIZE 256 +#else #define MAX_XID_LIST_SIZE (1024*128) +#endif /* handlerton is a singleton structure - one instance per storage engine - diff --git a/sql/log.cc b/sql/log.cc index 6cb465f839c..5348ae795b5 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2903,7 +2903,12 @@ int TC_LOG_BINLOG::open(const char *opt_name) pthread_cond_init (&COND_prep_xids, 0); if (using_heuristic_recover()) + { + /* generate a new binlog to mask a corrupted one */ + open(opt_name, LOG_BIN, 0, WRITE_CACHE, 0, max_binlog_size, 0); + cleanup(); return 1; + } if ((error= find_log_pos(&log_info, NullS, 1))) { @@ -2946,9 +2951,9 @@ int TC_LOG_BINLOG::open(const char *opt_name) if ((ev= Log_event::read_log_event(&log, 0, &fdle)) && ev->get_type_code() == FORMAT_DESCRIPTION_EVENT && ev->flags & LOG_EVENT_BINLOG_IN_USE_F) - error= recover(&log, (Format_description_log_event *)ev); - else - error=0; + error= recover(&log, (Format_description_log_event *)ev); + else + error=0; delete ev; end_io_cache(&log); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9559ed55b3c..1cf1e8ca2bf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2738,7 +2738,7 @@ server."); (TC_LOG *)&tc_log_mmap : (TC_LOG *)&tc_log_dummy; - if (tc_log->open(opt_tc_log_file)) + if (tc_log->open(opt_bin_logname)) { sql_print_error("Can't init tc log"); unireg_abort(1); From db895ce72047bbdcfb41639521db3c9169e0d2a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:00:01 +0300 Subject: [PATCH 30/41] Fix for BUG#8578 "Test case 'index_merge_ror' fails on SGI irix" Take into account that bitmap_is_set() may return any non-zero zero value when the bit is set. --- sql/opt_range.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ceb9f97bbbc..449aecb29f5 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2562,7 +2562,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, char *key_ptr= (char*) key_val; SEL_ARG *sel_arg, *tuple_arg= NULL; bool cur_covered; - bool prev_covered= bitmap_is_set(&info->covered_fields, key_part->fieldnr); + bool prev_covered= (bitmap_is_set(&info->covered_fields, key_part->fieldnr))? 1:0; key_range min_range; key_range max_range; min_range.key= (byte*) key_val; @@ -2575,7 +2575,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, for(i= 0, sel_arg= scan->sel_arg; sel_arg; i++, sel_arg= sel_arg->next_key_part) { - cur_covered= bitmap_is_set(&info->covered_fields, (key_part + i)->fieldnr); + DBUG_PRINT("info",("sel_arg step")); + cur_covered= (bitmap_is_set(&info->covered_fields, (key_part + i)->fieldnr))? 1:0; if (cur_covered != prev_covered) { /* create (part1val, ..., part{n-1}val) tuple. */ From fa1ee8986d3be42a8a214201900bf0af398b4089 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:30:44 +0300 Subject: [PATCH 31/41] Fix for BUG#8579 (failing test case): Allow small differences in #rows estimate in test results --- mysql-test/r/index_merge_ror_cpk.result | 2 +- mysql-test/t/index_merge_ror_cpk.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/index_merge_ror_cpk.result b/mysql-test/r/index_merge_ror_cpk.result index 6cfeb20b2de..79bb1297abf 100644 --- a/mysql-test/r/index_merge_ror_cpk.result +++ b/mysql-test/r/index_merge_ror_cpk.result @@ -59,7 +59,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref key1 key1 4 const 100 Using where explain select * from t1 where pk1 < 7500 and key1 = 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL 38 Using intersect(key1,PRIMARY); Using where +1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL ROWS Using intersect(key1,PRIMARY); Using where explain select * from t1 where pktail1ok=1 and key1=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 Using intersect(key1,pktail1ok); Using where diff --git a/mysql-test/t/index_merge_ror_cpk.test b/mysql-test/t/index_merge_ror_cpk.test index 867b0b3a036..94abf395d0a 100644 --- a/mysql-test/t/index_merge_ror_cpk.test +++ b/mysql-test/t/index_merge_ror_cpk.test @@ -63,6 +63,7 @@ select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; # Verify that CPK is always used for index intersection scans # (this is because it is used as a filter, not for retrieval) explain select * from t1 where badkey=1 and key1=10; +--replace_result 38 ROWS 37 ROWS explain select * from t1 where pk1 < 7500 and key1 = 10; # Verify that keys with 'tails' of PK members are ok. From 965f2b4d6aff1aa10672e99abead31e8617af4e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:34:14 +0300 Subject: [PATCH 32/41] Post review coding style fixes. --- sql/opt_range.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 449aecb29f5..2f93da28395 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2562,7 +2562,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, char *key_ptr= (char*) key_val; SEL_ARG *sel_arg, *tuple_arg= NULL; bool cur_covered; - bool prev_covered= (bitmap_is_set(&info->covered_fields, key_part->fieldnr))? 1:0; + bool prev_covered= (bitmap_is_set(&info->covered_fields, + key_part->fieldnr))? 1 : 0; key_range min_range; key_range max_range; min_range.key= (byte*) key_val; @@ -2576,7 +2577,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, i++, sel_arg= sel_arg->next_key_part) { DBUG_PRINT("info",("sel_arg step")); - cur_covered= (bitmap_is_set(&info->covered_fields, (key_part + i)->fieldnr))? 1:0; + cur_covered= (bitmap_is_set(&info->covered_fields, + (key_part + i)->fieldnr))? 1 : 0; if (cur_covered != prev_covered) { /* create (part1val, ..., part{n-1}val) tuple. */ From 59a39534b5178a47ef495c3398aec2905bbbf3ab Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:30:40 +0200 Subject: [PATCH 33/41] After merge fixes mysql-test/r/strict.result: Update tests after merge mysql-test/t/strict.test: Update tests after merge (We can't handle 2.2E-307) anymore as this is out of range with the new method to calculate double sql/item_sum.h: After merge fix use my_strtoll10 instead of my_strtonll --- mysql-test/r/strict.result | 12 +++++++----- mysql-test/t/strict.test | 4 ++-- sql/item_sum.h | 14 ++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 69e4b082422..c28ea0fce02 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -852,8 +852,8 @@ NULL NULL 3.40282e+38 0 DROP TABLE t1; CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED); -INSERT INTO t1 VALUES (-2.2E-307,0),(+1.7E+308,+1.7E+308); -INSERT INTO t1 VALUES ('-2.2E-307',0),('+1.7E+308','+1.7E+308'); +INSERT INTO t1 VALUES (-2.2E-307,0),(2E-307,0),(+1.7E+308,+1.7E+308); +INSERT INTO t1 VALUES ('-2.2E-307',0),('-2E-307',0),('+1.7E+308','+1.7E+308'); INSERT INTO t1 (col1) VALUES (-2.2E-330); INSERT INTO t1 (col1) VALUES (+1.7E+309); Got one of the listed errors @@ -864,7 +864,7 @@ ERROR 22003: Out of range value adjusted for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ERROR 22003: Out of range value adjusted for column 'col2' at row 1 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; -ERROR 22003: Out of range value adjusted for column 'col1' at row 2 +ERROR 22003: Out of range value adjusted for column 'col1' at row 3 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; ERROR 22012: Division by 0 UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0; @@ -890,9 +890,11 @@ Warning 1264 Out of range value adjusted for column 'col2' at row 1 Warning 1264 Out of range value adjusted for column 'col2' at row 1 SELECT * FROM t1; col1 col2 --2.2e-307 0 +0 0 +1e-303 0 1.7e+308 1.7e+308 --2.2e-307 0 +0 0 +-2e-307 0 1.7e+308 1.7e+308 0 NULL 2 NULL diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index d8833f6f914..d3928a623f4 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -828,8 +828,8 @@ DROP TABLE t1; # Test INSERT with DOUBLE CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED); -INSERT INTO t1 VALUES (-2.2E-307,0),(+1.7E+308,+1.7E+308); -INSERT INTO t1 VALUES ('-2.2E-307',0),('+1.7E+308','+1.7E+308'); +INSERT INTO t1 VALUES (-2.2E-307,0),(2E-307,0),(+1.7E+308,+1.7E+308); +INSERT INTO t1 VALUES ('-2.2E-307',0),('-2E-307',0),('+1.7E+308','+1.7E+308'); # We don't give warnings for underflow INSERT INTO t1 (col1) VALUES (-2.2E-330); --error 1367,1264 diff --git a/sql/item_sum.h b/sql/item_sum.h index c3eae176b1f..eca2ae188db 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -691,7 +691,6 @@ public: { int err_not_used; char *end_not_used; - char *end_not_used; String *res; res=val_str(&str_value); return res ? my_strntod(res->charset(),(char*) res->ptr(),res->length(), @@ -700,9 +699,16 @@ public: longlong val_int() { int err_not_used; - String *res; res=val_str(&str_value); - return res ? my_strntoll(res->charset(),res->ptr(),res->length(),10, - (char**) 0, &err_not_used) : (longlong) 0; + char *end; + String *res; + longlong value; + CHARSET_INFO *cs; + + if (!(res= val_str(&str_value))) + return 0; /* Null value */ + cs= res->charset(); + end= (char*) res->ptr()+res->length(); + return cs->cset->my_strtoll10(cs, res->ptr(), &end, &err_not_used); } my_decimal *val_decimal(my_decimal *dec); enum Item_result result_type () const { return STRING_RESULT; } From 9c6eebe84f9d2b9e571e28984a3326da13299af5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:08:33 +0100 Subject: [PATCH 34/41] 64-bit safe address->string conversion --- sql/ha_innodb.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 4af73108438..c8bd810e46d 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1698,7 +1698,9 @@ innobase_rollback_to_savepoint( innobase_release_stat_resources(trx); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); + char name[64]; + longlong2str((ulonglong)savepoint,buff,36); + error = trx_rollback_to_savepoint_for_mysql(trx, name, &mysql_binlog_cache_pos); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); @@ -1724,7 +1726,9 @@ innobase_release_savepoint( trx = check_trx_exists(thd); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); + char name[64]; + longlong2str((ulonglong)savepoint,buff,36); + error = trx_release_savepoint_for_mysql(trx, name); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); @@ -1763,7 +1767,9 @@ innobase_savepoint( DBUG_ASSERT(trx->active_trans); /* TODO: use provided savepoint data area to store savepoint data */ - char name[16]; sprintf(name, "s_%08lx", (ulong) savepoint); + char name[64]; + longlong2str((ulonglong)savepoint,buff,36); + error = trx_savepoint_for_mysql(trx, name, (ib_longlong)0); DBUG_RETURN(convert_error_code_to_mysql(error, NULL)); From fe118843579d80a26be47978cf2a342df878fee5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 18:45:19 +0100 Subject: [PATCH 35/41] copy-paste fixed --- sql/ha_innodb.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index c8bd810e46d..eddc7616e66 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1699,7 +1699,7 @@ innobase_rollback_to_savepoint( /* TODO: use provided savepoint data area to store savepoint data */ char name[64]; - longlong2str((ulonglong)savepoint,buff,36); + longlong2str((ulonglong)savepoint,name,36); error = trx_rollback_to_savepoint_for_mysql(trx, name, &mysql_binlog_cache_pos); @@ -1727,7 +1727,7 @@ innobase_release_savepoint( /* TODO: use provided savepoint data area to store savepoint data */ char name[64]; - longlong2str((ulonglong)savepoint,buff,36); + longlong2str((ulonglong)savepoint,name,36); error = trx_release_savepoint_for_mysql(trx, name); @@ -1768,7 +1768,7 @@ innobase_savepoint( /* TODO: use provided savepoint data area to store savepoint data */ char name[64]; - longlong2str((ulonglong)savepoint,buff,36); + longlong2str((ulonglong)savepoint,name,36); error = trx_savepoint_for_mysql(trx, name, (ib_longlong)0); From 6850c17f94e8f3c7a29eab75df643a7e96c8ba29 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 21:58:10 +0300 Subject: [PATCH 36/41] Fix for BUG#8397 (second commit after review): In Item_cache_decimal::store(item) the call item->val_decimal_result() returns NULL if the passed item has an SQL null value. Don't try copying NULL into Item_cache_decimal::val in this case. mysql-test/r/type_decimal.result: Test for BUG#8397 mysql-test/t/type_decimal.test: Test for BUG#8397 sql/item.cc: Fix for BUG#8397: In Item_cache_decimal::store(item) the call item->val_decimal_result() returns NULL if the passed item has an SQL null value. Don't try copying NULL into Item_cache_decimal::val in this case. --- mysql-test/r/type_decimal.result | 18 +++++++++++++++++- mysql-test/t/type_decimal.test | 19 ++++++++++++++++++- sql/item.cc | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 6c4a1fab857..2d5c2d2ac97 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1, t2; SET SQL_WARNINGS=1; CREATE TABLE t1 ( id int(11) NOT NULL auto_increment, @@ -677,3 +677,19 @@ a 9999.999 0000.000 drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +CREATE TABLE t2 +(EMPNUM CHAR(3) NOT NULL, +HOURS BIGINT); +INSERT INTO t1 VALUES ('E1',40); +INSERT INTO t1 VALUES ('E8',NULL); +INSERT INTO t2 VALUES ('E1',40); +SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2); +EMPNUM +E1 +SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1); +EMPNUM +E1 +DROP TABLE t1,t2; diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 6f170a52700..18ac5d1e467 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -1,7 +1,7 @@ # bug in decimal() with negative numbers by kaido@tradenet.ee --disable_warnings -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1, t2; --enable_warnings SET SQL_WARNINGS=1; @@ -268,3 +268,20 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000 --enable_warnings select * from t1; drop table t1; + +# Test for BUG#8397: decimal type in subselects (Item_cache_decimal) +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +CREATE TABLE t2 +(EMPNUM CHAR(3) NOT NULL, +HOURS BIGINT); + +INSERT INTO t1 VALUES ('E1',40); +INSERT INTO t1 VALUES ('E8',NULL); +INSERT INTO t2 VALUES ('E1',40); + +SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2); +SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1); + +DROP TABLE t1,t2; diff --git a/sql/item.cc b/sql/item.cc index 33e6d7cfc42..da9c98862b7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4349,7 +4349,7 @@ my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val) void Item_cache_decimal::store(Item *item) { my_decimal *val= item->val_decimal_result(&decimal_value); - if (val != &decimal_value) + if (val != &decimal_value && !item->null_value) my_decimal2decimal(val, &decimal_value); null_value= item->null_value; } From eec458e2c59be4daf11c4b3d6094a3fbd681d31d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 21:59:02 +0300 Subject: [PATCH 37/41] Coding style fixes according to Sergei's feedback --- sql/opt_range.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2f93da28395..66d9da10334 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2562,8 +2562,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, char *key_ptr= (char*) key_val; SEL_ARG *sel_arg, *tuple_arg= NULL; bool cur_covered; - bool prev_covered= (bitmap_is_set(&info->covered_fields, - key_part->fieldnr))? 1 : 0; + bool prev_covered= test(bitmap_is_set(&info->covered_fields, + key_part->fieldnr)); key_range min_range; key_range max_range; min_range.key= (byte*) key_val; @@ -2577,8 +2577,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, i++, sel_arg= sel_arg->next_key_part) { DBUG_PRINT("info",("sel_arg step")); - cur_covered= (bitmap_is_set(&info->covered_fields, - (key_part + i)->fieldnr))? 1 : 0; + cur_covered= test(bitmap_is_set(&info->covered_fields, + (key_part + i)->fieldnr)); if (cur_covered != prev_covered) { /* create (part1val, ..., part{n-1}val) tuple. */ From 3c213ae3bfc5ea6912acb474ee64e365d4565684 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 21:57:57 +0100 Subject: [PATCH 38/41] forget savepoints at the end of transaction --- sql/sql_class.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index e793f5776d7..d57eb3d3cc6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1072,7 +1072,8 @@ public: MEM_ROOT mem_root; // Transaction-life memory allocation pool void cleanup() { - changed_tables = 0; + changed_tables= 0; + savepoints= 0; #ifdef USING_TRANSACTIONS free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); #endif From a26e966d41d24465f9c294f32afdda7d9809a8df Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2005 22:42:49 +0100 Subject: [PATCH 39/41] Manual merge 4.1->5.0 --- sql/sql_error.cc | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/sql/sql_error.cc b/sql/sql_error.cc index d19e9fbdb09..79f7579d311 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -43,6 +43,7 @@ This file contains the implementation of error and warnings related ***********************************************************************/ #include "mysql_priv.h" +#include "sp_rcontext.h" /* Store a new message in an error object @@ -110,6 +111,25 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); + thd->got_warning= 1; + if (thd->spcont && + thd->spcont->find_handler(code, + ((int) level >= + (int) MYSQL_ERROR::WARN_LEVEL_WARN && + thd->really_abort_on_warning()) ? + MYSQL_ERROR::WARN_LEVEL_ERROR : level)) + { + DBUG_RETURN(NULL); + } + + /* Abort if we are using strict mode and we are not using IGNORE */ + if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN && + thd->really_abort_on_warning()) + { + thd->killed= THD::KILL_BAD_DATA; + my_message(code, msg, MYF(0)); + DBUG_RETURN(NULL); + } if (thd->warn_list.elements < thd->variables.max_error_count) { @@ -119,8 +139,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, */ MEM_ROOT *old_root= thd->mem_root; thd->mem_root= &thd->warn_root; - err= new MYSQL_ERROR(thd, code, level, msg); - if (err) + if ((err= new MYSQL_ERROR(thd, code, level, msg))) thd->warn_list.push_back(err); thd->mem_root= old_root; } @@ -168,14 +187,14 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, Takes into account the current LIMIT RETURN VALUES - 0 ok - 1 Error sending data to client + FALSE ok + TRUE Error sending data to client */ static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; static int warning_level_length[]= { 4, 7, 5, 1 }; -my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) +bool mysqld_show_warnings(THD *thd, ulong levels_to_show) { List field_list; DBUG_ENTER("mysqld_show_warnings"); @@ -184,8 +203,9 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) field_list.push_back(new Item_return_int("Code",4, MYSQL_TYPE_LONG)); field_list.push_back(new Item_empty_string("Message",MYSQL_ERRMSG_SIZE)); - if (thd->protocol->send_fields(&field_list,1)) - DBUG_RETURN(1); + if (thd->protocol->send_fields(&field_list, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + DBUG_RETURN(TRUE); MYSQL_ERROR *err; SELECT_LEX *sel= &thd->lex->select_lex; @@ -209,10 +229,10 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) protocol->store((uint32) err->code); protocol->store(err->msg, strlen(err->msg), system_charset_info); if (protocol->write()) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if (!--limit) break; } - send_eof(thd); - DBUG_RETURN(0); + send_eof(thd); + DBUG_RETURN(FALSE); } From 6f1a4fe4512ab96c10f72eb873c24a930582a8a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Feb 2005 00:50:30 +0100 Subject: [PATCH 40/41] After merge fixes mysql-test/t/rpl_charset.test: I have no idea why the automatic merge changed these, but now I have changed it back --- mysql-test/r/mysqldump.result | 2 ++ mysql-test/t/rpl_charset.test | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 0854fb5f50f..d8d9e60acd1 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -365,6 +365,7 @@ create view v1 as select * from t1; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -385,6 +386,7 @@ CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` fro /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop view v1; drop table t1; diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test index 92582f9d748..d2c195dfdbf 100644 --- a/mysql-test/t/rpl_charset.test +++ b/mysql-test/t/rpl_charset.test @@ -63,10 +63,10 @@ connection master; set character_set_client=latin1, collation_connection=latin1_german1_ci; truncate table t1; insert into t1 (b) values(@@collation_connection); -insert into t1 (b) values(LEAST("Müller","Muffler")); +insert into t1 (b) values(LEAST("Mller","Muffler")); set collation_connection=latin1_german2_ci; insert into t1 (b) values(@@collation_connection); -insert into t1 (b) values(LEAST("Müller","Muffler")); +insert into t1 (b) values(LEAST("Mller","Muffler")); --disable_query_log select "--- --master--" as ""; --enable_query_log @@ -90,7 +90,7 @@ select * from mysqltest2.t1 order by a; # which provokes error messages (like 'Illegal mix of collation') when # we replay the master's INSERT/etc statements. connection master; -set @a= _cp850 'Müller' collate cp850_general_ci; +set @a= _cp850 'Mller' collate cp850_general_ci; truncate table t1; insert into t1 (b) values(collation(@a)); --disable_query_log @@ -145,7 +145,7 @@ CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); SET CHARACTER_SET_CLIENT=koi8r, CHARACTER_SET_CONNECTION=cp1251, CHARACTER_SET_RESULTS=koi8r; -INSERT INTO t1 (c1, c2) VALUES ('îÕ, ÚÁ ÒÙÂÁÌËÕ','îÕ, ÚÁ ÒÙÂÁÌËÕ'); +INSERT INTO t1 (c1, c2) VALUES (', ',', '); select hex(c1), hex(c2) from t1; sync_slave_with_master; select hex(c1), hex(c2) from t1; From e1d76d166304c96b8f35fc782aafd374a42bc8c5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Feb 2005 10:12:26 +0100 Subject: [PATCH 41/41] removed printout "- Repeated 1 times" make sure transporter connections are close early in shutdown ndb/src/common/logger/LogHandler.cpp: removed printout "- Repeated 1 times" ndb/src/kernel/main.cpp: make sure transporter connections are close early in shutdown ndb/src/kernel/vm/Emulator.cpp: make sure transporter connections are close early in shutdown ndb/src/kernel/vm/Emulator.hpp: make sure transporter connections are close early in shutdown --- ndb/src/common/logger/LogHandler.cpp | 4 ++-- ndb/src/kernel/main.cpp | 11 ++--------- ndb/src/kernel/vm/Emulator.cpp | 18 +++++++++++++++++- ndb/src/kernel/vm/Emulator.hpp | 3 ++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ndb/src/common/logger/LogHandler.cpp b/ndb/src/common/logger/LogHandler.cpp index e038b05401e..ec4137297f1 100644 --- a/ndb/src/common/logger/LogHandler.cpp +++ b/ndb/src/common/logger/LogHandler.cpp @@ -76,15 +76,15 @@ LogHandler::append_impl(const char* pCategory, Logger::LoggerLevel level, const char* pMsg) { writeHeader(pCategory, level); - if (m_count_repeated_messages == 0) + if (m_count_repeated_messages <= 1) writeMessage(pMsg); else { BaseString str(pMsg); str.appfmt(" - Repeated %d times", m_count_repeated_messages); writeMessage(str.c_str()); - m_count_repeated_messages= 0; } + m_count_repeated_messages= 0; writeFooter(); } diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 448bdd9a1fa..e6e0a7ca877 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -180,11 +180,9 @@ int main(int argc, char** argv) assert("Illegal state globalData.theRestartFlag" == 0); } - SocketServer socket_server; - globalTransporterRegistry.startSending(); globalTransporterRegistry.startReceiving(); - if (!globalTransporterRegistry.start_service(socket_server)){ + if (!globalTransporterRegistry.start_service(*globalEmulatorData.m_socket_server)){ ndbout_c("globalTransporterRegistry.start_service() failed"); exit(-1); } @@ -196,7 +194,7 @@ int main(int argc, char** argv) globalEmulatorData.theWatchDog->doStart(); - socket_server.startServer(); + globalEmulatorData.m_socket_server->startServer(); // theConfig->closeConfiguration(); @@ -204,11 +202,6 @@ int main(int argc, char** argv) NdbShutdown(NST_Normal); - socket_server.stopServer(); - socket_server.stopSessions(); - - globalTransporterRegistry.stop_clients(); - return NRT_Default; } diff --git a/ndb/src/kernel/vm/Emulator.cpp b/ndb/src/kernel/vm/Emulator.cpp index 068610b6778..d6ed6c0dafd 100644 --- a/ndb/src/kernel/vm/Emulator.cpp +++ b/ndb/src/kernel/vm/Emulator.cpp @@ -68,6 +68,7 @@ EmulatorData::EmulatorData(){ theThreadConfig = 0; theSimBlockList = 0; theShutdownMutex = 0; + m_socket_server = 0; } void @@ -83,6 +84,7 @@ EmulatorData::create(){ theWatchDog = new WatchDog(); theThreadConfig = new ThreadConfig(); theSimBlockList = new SimBlockList(); + m_socket_server = new SocketServer(); theShutdownMutex = NdbMutex_Create(); @@ -99,7 +101,8 @@ EmulatorData::destroy(){ delete theThreadConfig; theThreadConfig = 0; if(theSimBlockList) delete theSimBlockList; theSimBlockList = 0; - + if(m_socket_server) + delete m_socket_server; m_socket_server = 0; NdbMem_Destroy(); } @@ -195,9 +198,22 @@ NdbShutdown(NdbShutdownType type, fclose(outputStream); #endif + /** + * Stop all transporter connection attempts and accepts + */ + globalEmulatorData.m_socket_server->stopServer(); + globalEmulatorData.m_socket_server->stopSessions(); + globalTransporterRegistry.stop_clients(); + + /** + * Stop transporter communication with other nodes + */ globalTransporterRegistry.stopSending(); globalTransporterRegistry.stopReceiving(); + /** + * Remove all transporters + */ globalTransporterRegistry.removeAll(); #ifdef VM_TRACE diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index b3c64830802..dba8cb3ab9b 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -55,7 +55,8 @@ struct EmulatorData { class WatchDog * theWatchDog; class ThreadConfig * theThreadConfig; class SimBlockList * theSimBlockList; - + class SocketServer * m_socket_server; + /** * Constructor *