From 348218d21d6f49d526e29557783044b11defaabe Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Thu, 20 Jan 2005 00:54:01 +0300 Subject: [PATCH 01/16] Fix for bug #7637: "Test failure: 'user_limits' on QNX and 64-bit systems" Made user_limits.test scheduling independant (this solves failure on QNX). Made sys_var_max_user_conn variable int sized. Changed max_user_connections from ulong to uint to be able to use it in sys_var_max_user_conn::value_ptr() (solves failures on 64-bit platforms). --- mysql-test/r/user_limits.result | 7 +++++++ mysql-test/t/user_limits.test | 8 ++++++++ sql/mysql_priv.h | 2 +- sql/mysqld.cc | 7 ++++--- sql/set_var.cc | 8 ++++++++ sql/set_var.h | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/user_limits.result b/mysql-test/r/user_limits.result index b374b05e3f0..75062e97200 100644 --- a/mysql-test/r/user_limits.result +++ b/mysql-test/r/user_limits.result @@ -6,6 +6,7 @@ delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -16,6 +17,7 @@ select * from t1; ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2) drop user mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -34,6 +36,7 @@ select * from t1; i drop user mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +flush user_resources; select * from t1; i select * from t1; @@ -47,6 +50,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections' resource (cur drop user mysqltest_1@localhost; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +flush user_resources; select * from t1; i select * from t1; @@ -56,6 +60,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource select * from t1; i grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; select * from t1; i connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); @@ -71,6 +76,7 @@ select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 2 2 grant usage on *.* to mysqltest_1@localhost; +flush user_resources; select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 2 2 @@ -79,6 +85,7 @@ i connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 3 2 diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test index 50c16e5e114..729894a588a 100644 --- a/mysql-test/t/user_limits.test +++ b/mysql-test/t/user_limits.test @@ -19,6 +19,8 @@ flush privileges; # Test of MAX_QUERIES_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +# This ensures that counters are reset and makes test scheduling independent +flush user_resources; connect (mqph, localhost, mysqltest_1,,); connection mqph; select * from t1; @@ -37,6 +39,7 @@ disconnect mqph2; # Test of MAX_UPDATES_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +flush user_resources; connect (muph, localhost, mysqltest_1,,); connection muph; select * from t1; @@ -60,6 +63,7 @@ disconnect muph2; # Test of MAX_CONNECTIONS_PER_HOUR limit grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +flush user_resources; connect (mcph1, localhost, mysqltest_1,,); connection mcph1; select * from t1; @@ -86,6 +90,7 @@ drop user mysqltest_1@localhost; # We need this to reset internal mqh_used variable flush privileges; grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +flush user_resources; connect (muc1, localhost, mysqltest_1,,); connection muc1; select * from t1; @@ -102,6 +107,7 @@ select * from t1; # Changing of limit should also help (and immediately) connection default; grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; connect (muc4, localhost, mysqltest_1,,); connection muc4; select * from t1; @@ -127,6 +133,7 @@ set global max_user_connections= 2; select @@session.max_user_connections, @@global.max_user_connections; # Let us check that global limit works grant usage on *.* to mysqltest_1@localhost; +flush user_resources; connect (muca1, localhost, mysqltest_1,,); connection muca1; select @@session.max_user_connections, @@global.max_user_connections; @@ -139,6 +146,7 @@ connect (muca3, localhost, mysqltest_1,,); # Now we are testing that per-account limit prevails over gloabl limit connection default; grant usage on *.* to mysqltest_1@localhost with max_user_connections 3; +flush user_resources; connect (muca3, localhost, mysqltest_1,,); connection muca3; select @@session.max_user_connections, @@global.max_user_connections; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 322b38abe13..9d20dc267d5 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1001,7 +1001,7 @@ extern ulong ha_read_count, ha_discover_count; extern ulong table_cache_size; extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout; -extern ulong max_user_connections; +extern uint max_user_connections; extern my_bool timed_mutexes; extern ulong what_to_log,flush_time; extern ulong query_buff_size, thread_stack,thread_stack_min; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 35eddb0734f..3e7db0b5fd5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -333,7 +333,8 @@ ulong delayed_insert_errors,flush_time, thread_created; ulong specialflag=0; ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong max_connections,max_used_connections, - max_connect_errors, max_user_connections = 0; + max_connect_errors; +uint max_user_connections= 0; ulong thread_id=1L,current_pid; my_bool timed_mutexes= 0; ulong slow_launch_threads = 0, sync_binlog_period; @@ -5246,8 +5247,8 @@ The minimum value for this variable is 4096.", REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0}, {"max_user_connections", OPT_MAX_USER_CONNECTIONS, "The maximum number of active connections for a single user (0 = no limit).", - (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_ULONG, - REQUIRED_ARG, 0, 1, ~0L, 0, 1, 0}, + (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT, + REQUIRED_ARG, 0, 1, ~0, 0, 1, 0}, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, "After this many write locks, allow some read locks to run in between.", (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG, diff --git a/sql/set_var.cc b/sql/set_var.cc index 957cacc91ac..deb33cf389b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1599,6 +1599,14 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) var_type= OPT_GLOBAL; } switch (type()) { + case SHOW_INT: + { + uint value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(uint*) value_ptr(thd, var_type, base); + pthread_mutex_unlock(&LOCK_global_system_variables); + return new Item_uint((int32) value); + } case SHOW_LONG: { ulong value; diff --git a/sql/set_var.h b/sql/set_var.h index 7c9f11041c8..0f30f764ed5 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -740,7 +740,7 @@ public: return type != OPT_GLOBAL || !option_limits; } void set_default(THD *thd, enum_var_type type); - SHOW_TYPE type() { return SHOW_LONG; } + SHOW_TYPE type() { return SHOW_INT; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; From ef448b7fb19b3f4e78e2f131d8c52369cab86a29 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 25 Jan 2005 14:00:35 +0200 Subject: [PATCH 02/16] Add flags for Intel 64 bit --- BUILD/SETUP.sh | 3 +++ BUILD/compile-pentium64-debug | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 BUILD/compile-pentium64-debug diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 5f4233b8371..d378276a0a3 100644 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -1,3 +1,5 @@ +#!/bin/sh + if ! test -f sql/mysqld.cc then echo "You must run this script from the MySQL top-level directory" @@ -43,6 +45,7 @@ cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wcto alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet pentium_cflags="-mcpu=pentiumpro" +pentium64_cflags="-mcpu=nocona -m64" ppc_cflags="-mpowerpc -mcpu=powerpc" sparc_cflags="" diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug new file mode 100755 index 00000000000..1bbca36d851 --- /dev/null +++ b/BUILD/compile-pentium64-debug @@ -0,0 +1,13 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium64_cflags $debug_cflags" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" +extra_configs="$pentium_configs $debug_configs $static_link" + +extra_configs="$extra_configs " + +. "$path/FINISH.sh" From b4eebbc0b6c428e15d7eb83bd8bc17032e89cc8a Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Tue, 25 Jan 2005 13:46:40 +0100 Subject: [PATCH 03/16] changed from using column names to column id in ndb setBound in ha_ndbcluster --- sql/ha_ndbcluster.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c2d12ddd316..c5bb4984f40 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1476,10 +1476,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, // Set bound if not cancelled via type -1 if (p.bound_type != -1) { - char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; - strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); - truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; - if (op->setBound(truncated_field_name, p.bound_type, p.bound_ptr)) + if (op->setBound(i, p.bound_type, p.bound_ptr)) ERR_RETURN(op->getNdbError()); } } From da658b9f11bc3b2bf3dc4f1b2b2356d54324e989 Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Tue, 25 Jan 2005 15:08:51 +0100 Subject: [PATCH 04/16] Fix for failing INSERT IGNORE in test ndb_insert --- sql/sql_insert.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 92c429bcfde..844e5e7dac2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -241,7 +241,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, error=0; id=0; thd->proc_info="update"; - if (duplic != DUP_ERROR) + if (duplic != DUP_ERROR || ignore) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); /* let's *try* to start bulk inserts. It won't necessary @@ -380,7 +380,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, table->next_number_field=0; thd->count_cuted_fields= CHECK_FIELD_IGNORE; thd->next_insert_id=0; // Reset this if wrongly used - if (duplic != DUP_ERROR) + if (duplic != DUP_ERROR || ignore) table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); /* Reset value of LAST_INSERT_ID if no rows where inserted */ @@ -1345,7 +1345,7 @@ bool delayed_insert::handle_inserts(void) info.ignore= row->ignore; info.handle_duplicates= row->dup; if (info.ignore || - info.handle_duplicates == DUP_REPLACE) + info.handle_duplicates != DUP_ERROR) { table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); using_ignore=1; @@ -1463,7 +1463,7 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) table->next_number_field=table->found_next_number_field; thd->cuted_fields=0; if (info.ignore || - info.handle_duplicates == DUP_REPLACE) + info.handle_duplicates != DUP_ERROR) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); table->file->start_bulk_insert((ha_rows) 0); DBUG_RETURN(0); @@ -1649,7 +1649,7 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) restore_record(table,default_values); // Get empty record thd->cuted_fields=0; if (info.ignore || - info.handle_duplicates == DUP_REPLACE) + info.handle_duplicates != DUP_ERROR) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); table->file->start_bulk_insert((ha_rows) 0); DBUG_RETURN(0); From 37168015cd4a2135cfcfcd71478c066759fffd6a Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 25 Jan 2005 21:27:51 +0200 Subject: [PATCH 05/16] Cleanups during review --- .bzrignore | 3 +++ client/mysqlbinlog.cc | 17 +++++++++++++---- innobase/include/eval0eval.ic | 2 -- sql/mysqld.cc | 9 ++++----- sql/sql_select.cc | 7 ------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.bzrignore b/.bzrignore index 40b7668cb64..199da0dd558 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1004,3 +1004,6 @@ vio/test-sslserver vio/viotest-ssl tests/mysql_client_test tests/mysql_client_test +libmysqld/examples/mysql_client_test.c +libmysqld/examples/mysql_client_test_embedded +libmysqld/examples/mysqltest_embedded diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7ddb01d9ec8..0b15ad893e2 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -687,7 +687,7 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { - MYSQL *local_mysql = mysql_init(NULL); + MYSQL *local_mysql= mysql_init(NULL); if (!local_mysql) die("Failed on mysql_init"); @@ -695,8 +695,12 @@ static MYSQL* safe_connect() if (opt_protocol) mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) - die("failed on connect: %s", mysql_error(local_mysql)); - + { + char errmsg[256]; + strmake(errmsg, mysql_error(local_mysql), sizeof(errmsg)-1); + mysql_close(local_mysql); + die("failed on connect: %s", errmsg); + } return local_mysql; } @@ -717,7 +721,12 @@ static int check_master_version(MYSQL* mysql) if (mysql_query(mysql, "SELECT VERSION()") || !(res = mysql_store_result(mysql))) - die("Error checking master version: %s", mysql_error(mysql)); + { + char errmsg[256]; + strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1); + mysql_close(mysql); + die("Error checking master version: %s", errmsg); + } if (!(row = mysql_fetch_row(res))) { mysql_free_result(res); diff --git a/innobase/include/eval0eval.ic b/innobase/include/eval0eval.ic index 2530c869206..069cbfe5f37 100644 --- a/innobase/include/eval0eval.ic +++ b/innobase/include/eval0eval.ic @@ -205,8 +205,6 @@ eval_node_copy_and_alloc_val( { byte* data; - ut_ad(UNIV_SQL_NULL > ULINT_MAX); - if (len == UNIV_SQL_NULL) { dfield_set_len(que_node_get_val(node), len); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6d647b6edf0..c5ed516570a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2915,12 +2915,11 @@ You should consider changing lower_case_table_names to 1 or 2", (test_if_case_insensitive(mysql_real_data_home) == 1))) { if (global_system_variables.log_warnings) - sql_print_warning("\ -You have forced lower_case_table_names to 2 through a command-line \ -option, even though your file system '%s' is case sensitive. This means \ -that you can create a table that you can then no longer access. \ -You should consider changing lower_case_table_names to 0.", + sql_print_warning("lower_case_table_names was set to 2, even though your " + "the file system '%s' is case sensitive. Now setting " + "lower_case_table_names to 0 to avoid future problems.", mysql_real_data_home); + lower_case_table_names= 0; } select_thread=pthread_self(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a53b878cf6c..e956d71a4be 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2828,16 +2828,9 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, x = used key parts (1 <= x <= c) */ double rec_per_key; -#if 0 - if (!(rec_per_key=(double) - keyinfo->rec_per_key[keyinfo->key_parts-1])) - rec_per_key=(double) s->records/rec+1; -#else rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : (double) s->records/rec+1; -#endif - if (!s->records) tmp=0; else if (rec_per_key/(double) s->records >= 0.01) From 7db99fa5591da5c71f28ee50f185bdc023210705 Mon Sep 17 00:00:00 2001 From: "patg@krsna.patg.net" <> Date: Tue, 25 Jan 2005 23:52:47 -0800 Subject: [PATCH 06/16] change to Makefile.am per Serg's request --- libmysqld/examples/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index b94d2db2912..d70d7330e55 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -29,7 +29,7 @@ mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \ mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) mysql_client_test_embedded_LINK = $(CXXLINK) -mysql_client_test_embedded_SOURCES = $(top_srcdir)/tests/mysql_client_test.c +mysql_client_test_embedded_SOURCES = mysql_client_test.c clean: rm -f $(client_sources) From 7084b494c44eb2d815652640381c8930981dc435 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 26 Jan 2005 08:57:43 +0100 Subject: [PATCH 07/16] innobase/include/univ.i remove a change that broke the test --- innobase/include/univ.i | 6 ++---- sql/item_create.cc | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/innobase/include/univ.i b/innobase/include/univ.i index c6ab258d3b7..625978ffc38 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,10 +80,8 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ -#ifdef DBUG_ON -# define UNIV_DEBUG -#endif /* DBUG_ON */ /* +#define UNIV_DEBUG #define UNIV_MEM_DEBUG #define UNIV_IBUF_DEBUG #define UNIV_SYNC_DEBUG @@ -121,7 +119,7 @@ by one. */ /* Definition for inline version */ #ifdef __WIN__ -#define UNIV_INLINE __inline +#define UNIV_INLINE __inline #else /* config.h contains the right def for 'inline' for the current compiler */ #if (__GNUC__ == 2) diff --git a/sql/item_create.cc b/sql/item_create.cc index 99db184e71f..d959a6f393a 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -377,13 +377,14 @@ Item *create_func_space(Item *a) { uint dummy_errors; sp= new Item_string("",0,cs); - sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); + if (sp) + sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); } else { sp= new Item_string(" ",1,cs); } - return new Item_func_repeat(sp, a); + return sp ? new Item_func_repeat(sp, a) : 0; } Item *create_func_soundex(Item* a) From 60b64b7077c2c9a4c59b84134b44e4ba2288ceb0 Mon Sep 17 00:00:00 2001 From: "mleich@mysql.com" <> Date: Wed, 26 Jan 2005 10:19:28 +0100 Subject: [PATCH 08/16] WL#1420 convert NIST test for mysql Test cases using common object (database,user,table,..) names could probably destroy customer data, when connecting to an already running server. This Changeset contains an auxiliary routine include/testdb_only.inc" which should be sourced by tests doing such dangerous things. The test case will get a "[skipped]" when the environment variable USE_RUNNING_SERVER is not 0 . The modified mysql-test-run.sh sets USE_RUNNING_SERVER to 0, when the "mysql-test-run" starts its own server, aka there was no "--extern" option. --- mysql-test/include/testdb_only.inc | 30 ++++++++++++++++++++++++ mysql-test/mysql-test-run.sh | 37 ++++++++++++++++-------------- mysql-test/r/testdb_only.require | 2 ++ 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 mysql-test/include/testdb_only.inc create mode 100644 mysql-test/r/testdb_only.require diff --git a/mysql-test/include/testdb_only.inc b/mysql-test/include/testdb_only.inc new file mode 100644 index 00000000000..ddc3f123d45 --- /dev/null +++ b/mysql-test/include/testdb_only.inc @@ -0,0 +1,30 @@ +#################### include/testdb_only.inc ###################### +# # +# We must prevent to work on databases created by customers, # +# because we DROP/CREATE/MODIFY objects with sometimes common # +# names like STAFF, EMPLOYEE etc. # +# # +# Therefore we check the environment variable USE_RUNNING_SERVER. # +# USE_RUNNING_SERVER is exported by "mysql-test-run" and could # +# contain the following values: # +# 0 -- mysql-test-run was started without the --extern option # +# That means the test will be performed within the test # +# area 'mysql-test/var/...' . # +# 1 -- mysql-test-run was started with the --extern option # +# That means the test will be performed by an already # +# running server and data modifications will most probably # +# outside of the common test area 'mysql-test/var/...' . # +# # +# If USE_RUNNING_SERVER is not 0 the test will be skipped. # +# # +################################################################### + +--disable_query_log +eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER'; +--require r/testdb_only.require +SELECT 'use extern server' + AS "Variable_name ", + IF(@USE_RUNNING_SERVER= '1','YES', + IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED')) + AS "Value" ; +--enable_query_log diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 1e3052de8e8..73f10fca5cf 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -224,7 +224,7 @@ EXTRA_MASTER_OPT="" EXTRA_MYSQL_TEST_OPT="" EXTRA_MYSQLDUMP_OPT="" EXTRA_MYSQLBINLOG_OPT="" -USE_RUNNING_SERVER="" +USE_RUNNING_SERVER=0 USE_NDBCLUSTER="" USE_RUNNING_NDBCLUSTER="" DO_GCOV="" @@ -255,7 +255,7 @@ NDBD_EXTRA_OPTS= while test $# -gt 0; do case "$1" in --embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 ; \ - USE_RUNNING_SERVER="" RESULT_EXT=".es" TEST_MODE="embedded" ;; + USE_RUNNING_SERVER=0 RESULT_EXT=".es" TEST_MODE="embedded" ;; --user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;; --force) FORCE=1 ;; --timer) USE_TIMER=1 ;; @@ -265,8 +265,8 @@ while test $# -gt 0; do MASTER_MYSQLD=`$ECHO "$1" | $SED -e "s;--master-binary=;;"` ;; --slave-binary=*) SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;; - --local) USE_RUNNING_SERVER="" ;; - --extern) USE_RUNNING_SERVER="1" ;; + --local) USE_RUNNING_SERVER=0 ;; + --extern) USE_RUNNING_SERVER=1 ;; --with-ndbcluster) USE_NDBCLUSTER="--ndbcluster" ;; --ndb-connectstring=*) @@ -303,7 +303,7 @@ while test $# -gt 0; do --no-manager | --skip-manager) USE_MANAGER=0 ;; --manager) USE_MANAGER=1 - USE_RUNNING_SERVER= + USE_RUNNING_SERVER=0 ;; --start-and-exit) START_AND_EXIT=1 @@ -372,7 +372,7 @@ while test $# -gt 0; do EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" # This needs to be checked properly # USE_MANAGER=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 ;; --client-gdb ) if [ x$BINARY_DIST = x1 ] ; then @@ -385,7 +385,7 @@ while test $# -gt 0; do --manual-gdb ) DO_GDB=1 MANUAL_GDB=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" ;; @@ -394,7 +394,7 @@ while test $# -gt 0; do $ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option" fi DO_DDD=1 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb" ;; @@ -412,7 +412,7 @@ while test $# -gt 0; do EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb" SLEEP_TIME_AFTER_RESTART=10 SLEEP_TIME_FOR_DELETE=60 - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 if test "$1" = "--valgrind-all" then VALGRIND="$VALGRIND -v --show-reachable=yes" @@ -627,9 +627,9 @@ fi if [ -z "$1" ] then - USE_RUNNING_SERVER="" + USE_RUNNING_SERVER=0 fi -if [ -n "$USE_RUNNING_SERVER" ] +if [ $USE_RUNNING_SERVER -eq 1 ] then MASTER_MYSOCK=$LOCAL_SOCKET; DBUSER=${DBUSER:-test} @@ -801,7 +801,7 @@ report_stats () { $ECHO "http://www.mysql.com/doc/en/MySQL_test_suite.html" fi - if test -z "$USE_RUNNING_SERVER" + if [ $USE_RUNNING_SERVER -eq 0 ] then # Report if there was any fatal warnings/errors in the log files @@ -1511,7 +1511,7 @@ run_testcase () done fi - if [ -z "$USE_RUNNING_SERVER" ] ; + if [ $USE_RUNNING_SERVER -eq 0 ] ; then if [ -f $master_opt_file ] ; then @@ -1655,7 +1655,7 @@ run_testcase () if [ x$FORCE != x1 ] ; then $ECHO "Aborting: $tname failed in $TEST_MODE mode. To continue, re-run with '--force'." $ECHO - if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \ + if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \ [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ] then mysql_stop @@ -1664,7 +1664,7 @@ run_testcase () exit 1 fi FAILED_CASES="$FAILED_CASES $tname" - if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \ + if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \ [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ] then mysql_restart @@ -1683,7 +1683,7 @@ run_testcase () [ "$DO_GCOV" ] && gcov_prepare [ "$DO_GPROF" ] && gprof_prepare -if [ -z "$USE_RUNNING_SERVER" ] +if [ $USE_RUNNING_SERVER -eq 0 ] then if [ -z "$FAST_START" ] then @@ -1744,6 +1744,9 @@ fi $ECHO "Starting Tests" +# Some test cases need USE_RUNNING_SERVER +export USE_RUNNING_SERVER + # # This can probably be deleted # @@ -1816,7 +1819,7 @@ fi $ECHO $DASH72 $ECHO -if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ] +if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && [ -z "$DO_DDD" ] then mysql_stop fi diff --git a/mysql-test/r/testdb_only.require b/mysql-test/r/testdb_only.require new file mode 100644 index 00000000000..e717418fdb6 --- /dev/null +++ b/mysql-test/r/testdb_only.require @@ -0,0 +1,2 @@ +Variable_name Value +use extern server NO From 5779a6a576100fa008f51bcd9ad50bce6007c037 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 26 Jan 2005 11:31:46 +0100 Subject: [PATCH 09/16] Bug#8101 unique indexes which attribute are _not_ specified in the order of the table does not work --- mysql-test/r/ndb_index_unique.result | 14 ++++++++ mysql-test/t/ndb_index_unique.test | 21 +++++++++++ sql/ha_ndbcluster.cc | 54 +++++++++++++++++++++++++--- sql/ha_ndbcluster.h | 1 + 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9cc89ee4cc..598b9dcccf7 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -612,3 +612,17 @@ a b c 3 NULL NULL 4 4 NULL drop table t1, t8; +create table t1( +id integer not null auto_increment, +month integer not null, +year integer not null, +code varchar( 2) not null, +primary key ( id), +unique idx_t1( month, code, year) +) engine=ndb; +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); +select * from t1 where code = '12' and month = 4 and year = 2004 ; +id month year code +1 4 2004 12 +drop table t1; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index f235d1ffc30..9bbea75028b 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -286,3 +286,24 @@ select * from t8 order by a; select * from t1 order by a; drop table t1, t8; +############################### +# Bug 8101 +# +# Unique index not specified in the same order as in table +# + +create table t1( + id integer not null auto_increment, + month integer not null, + year integer not null, + code varchar( 2) not null, + primary key ( id), + unique idx_t1( month, code, year) +) engine=ndb; + +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); + +select * from t1 where code = '12' and month = 4 and year = 2004 ; + +drop table t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c5bb4984f40..437b5ebcdf7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -765,6 +765,42 @@ int ha_ndbcluster::get_metadata(const char *path) DBUG_RETURN(build_index_list(table, ILBP_OPEN)); } +static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, + const NDBINDEX *index, + KEY *key_info) +{ + DBUG_ENTER("fix_unique_index_attr_order"); + unsigned sz= index->getNoOfIndexColumns(); + + if (data.unique_index_attrid_map) + my_free((char*)data.unique_index_attrid_map, MYF(0)); + data.unique_index_attrid_map= (unsigned char*)my_malloc(sz,MYF(MY_WME)); + + KEY_PART_INFO* key_part= key_info->key_part; + KEY_PART_INFO* end= key_part+key_info->key_parts; + DBUG_ASSERT(key_info->key_parts == sz); + for (unsigned i= 0; key_part != end; key_part++, i++) + { + const char *field_name= key_part->field->field_name; + unsigned name_sz= strlen(field_name); + if (name_sz >= NDB_MAX_ATTR_NAME_SIZE) + name_sz= NDB_MAX_ATTR_NAME_SIZE-1; +#ifndef DBUG_OFF + data.unique_index_attrid_map[i]= 255; +#endif + for (unsigned j= 0; j < sz; j++) + { + const NdbDictionary::Column *c= index->getColumn(j); + if (strncmp(field_name, c->getName(), name_sz) == 0) + { + data.unique_index_attrid_map[i]= j; + break; + } + } + DBUG_ASSERT(data.unique_index_attrid_map[i] != 255); + } + DBUG_RETURN(0); +} int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) { @@ -839,7 +875,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) const NDBINDEX *index= dict->getIndex(unique_index_name, m_tabname); if (!index) DBUG_RETURN(1); m_index[i].unique_index= (void *) index; - } + error= fix_unique_index_attr_order(m_index[i], index, key_info); + } } DBUG_RETURN(error); @@ -897,6 +934,11 @@ void ha_ndbcluster::release_metadata() { m_index[i].unique_index= NULL; m_index[i].index= NULL; + if (m_index[i].unique_index_attrid_map) + { + my_free((char *)m_index[i].unique_index_attrid_map, MYF(0)); + m_index[i].unique_index_attrid_map= NULL; + } } DBUG_VOID_RETURN; @@ -1209,7 +1251,8 @@ int ha_ndbcluster::unique_index_read(const byte *key, for (i= 0; key_part != end; key_part++, i++) { - if (set_ndb_key(op, key_part->field, i, + if (set_ndb_key(op, key_part->field, + m_index[active_index].unique_index_attrid_map[i], key_part->null_bit ? key_ptr + 1 : key_ptr)) ERR_RETURN(trans->getNdbError()); key_ptr+= key_part->store_length; @@ -3836,9 +3879,10 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): for (i= 0; i < MAX_KEY; i++) { - m_index[i].type= UNDEFINED_INDEX; - m_index[i].unique_index= NULL; - m_index[i].index= NULL; + m_index[i].type= UNDEFINED_INDEX; + m_index[i].unique_index= NULL; + m_index[i].index= NULL; + m_index[i].unique_index_attrid_map= NULL; } DBUG_VOID_RETURN; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 15e61a93574..07b305bad3e 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -52,6 +52,7 @@ typedef struct ndb_index_data { NDB_INDEX_TYPE type; void *index; void *unique_index; + unsigned char *unique_index_attrid_map; } NDB_INDEX_DATA; typedef struct st_ndbcluster_share { From f995a526b1f244c1303c3d4dc02cefac7738543d Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Wed, 26 Jan 2005 15:11:55 +0400 Subject: [PATCH 10/16] a fix (bug #8129: help.test fails using --ps-protocol) --- sql/sql_help.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 7bf28a439b6..ff2f5bf4992 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -559,7 +559,8 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, if (!cond->fixed) cond->fix_fields(thd, tables, &cond); // can never fail SQL_SELECT *res= make_select(table,0,0,cond,error); - if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR))) + if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) || + (res->quick && res->quick->reset())) { delete res; res=0; From 4453a6243e6c2db7d92f0de544a5f8f46b05ad04 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Wed, 26 Jan 2005 16:02:19 +0400 Subject: [PATCH 11/16] after review fixup (bug #8129: help.test fails using --ps-protocol) --- sql/sql_help.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index ff2f5bf4992..759b535da53 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -558,6 +558,10 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, { if (!cond->fixed) cond->fix_fields(thd, tables, &cond); // can never fail + + /* Assume that no indexes cover all required fields */ + table->used_keys.clear_all(); + SQL_SELECT *res= make_select(table,0,0,cond,error); if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) || (res->quick && res->quick->reset())) From 8828884f4c1230e80650141f36144e63d03c4b66 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Wed, 26 Jan 2005 16:34:09 +0400 Subject: [PATCH 12/16] CSC#4385: slow sorting for UTF8 large table: my_strnxfrm_utf8 now requires 2 bytes per character in filesort key, instead of 3 bytes per character. Shorter filesort keys make sorting faster. --- include/m_ctype.h | 4 +++- sql/filesort.cc | 4 ++-- strings/ctype-big5.c | 1 + strings/ctype-bin.c | 2 ++ strings/ctype-cp932.c | 1 + strings/ctype-czech.c | 1 + strings/ctype-euc_kr.c | 1 + strings/ctype-eucjpms.c | 1 + strings/ctype-gb2312.c | 1 + strings/ctype-gbk.c | 1 + strings/ctype-latin1.c | 1 + strings/ctype-mb.c | 1 + strings/ctype-simple.c | 10 ++++++++++ strings/ctype-sjis.c | 1 + strings/ctype-tis620.c | 1 + strings/ctype-uca.c | 2 ++ strings/ctype-ucs2.c | 2 ++ strings/ctype-ujis.c | 1 + strings/ctype-utf8.c | 37 ++++++++++++++++++++++++------------- strings/ctype-win1250ch.c | 1 + 20 files changed, 58 insertions(+), 16 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index c2354c7feff..c41c7385b3d 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -110,6 +110,7 @@ typedef struct my_collation_handler_st my_bool diff_if_only_endspace_difference); int (*strnxfrm)(struct charset_info_st *, uchar *, uint, const uchar *, uint); + uint (*strnxfrmlen)(struct charset_info_st *, uint); my_bool (*like_range)(struct charset_info_st *, const char *s, uint s_length, pchar w_prefix, pchar w_one, pchar w_many, @@ -259,7 +260,8 @@ extern CHARSET_INFO my_charset_cp1250_czech_ci; /* declarations for simple charsets */ extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, - uint); + uint); +uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint, my_bool); diff --git a/sql/filesort.cc b/sql/filesort.cc index 0e9fa8c79ed..1665358dbf0 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1187,7 +1187,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) { sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); } } if (sortorder->field->maybe_null()) @@ -1200,7 +1200,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) sortorder->length=sortorder->item->max_length; if (use_strnxfrm((cs=sortorder->item->collation.collation))) { - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index a2db7de244e..70c5ec633be 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6293,6 +6293,7 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = my_strnncoll_big5, my_strnncollsp_big5, my_strnxfrm_big5, + my_strnxfrmlen_simple, my_like_range_big5, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 401605a462f..50c66a63e97 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -447,6 +447,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler = my_strnncoll_8bit_bin, my_strnncollsp_8bit_bin, my_strnxfrm_8bit_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, @@ -461,6 +462,7 @@ static MY_COLLATION_HANDLER my_collation_binary_handler = my_strnncoll_binary, my_strnncollsp_binary, my_strnxfrm_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 804f87b2a5b..c47f2c2d8ce 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5454,6 +5454,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_cp932, my_strnncollsp_cp932, my_strnxfrm_cp932, + my_strnxfrmlen_simple, my_like_range_cp932, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 2834dbb28ff..f5a410afc50 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -593,6 +593,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = my_strnncoll_czech, my_strnncollsp_czech, my_strnxfrm_czech, + my_strnxfrmlen_simple, my_like_range_czech, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index ee792d9c3e4..289b7309ea0 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8641,6 +8641,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 5b108d24f4b..8c8d237cf48 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8636,6 +8636,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index f17cc94723f..73e4132dd7f 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5692,6 +5692,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, /* instr */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index dc4aea60096..6b47b537fb9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9939,6 +9939,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_gbk, my_strnncollsp_gbk, my_strnxfrm_gbk, + my_strnxfrmlen_simple, my_like_range_gbk, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index b5da99a7452..043645684cf 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -693,6 +693,7 @@ static MY_COLLATION_HANDLER my_collation_german2_ci_handler= my_strnncoll_latin1_de, my_strnncollsp_latin1_de, my_strnxfrm_latin1_de, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 4be21599fef..e902730d65a 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -912,6 +912,7 @@ MY_COLLATION_HANDLER my_collation_mb_bin_handler = my_strnncoll_mb_bin, my_strnncollsp_mb_bin, my_strnxfrm_mb_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index bb623ef66f1..e436d5f8702 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -21,6 +21,15 @@ #include "stdarg.h" +/* + Returns the number of bytes required for strnxfrm(). +*/ +uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) +{ + return len * (cs->strxfrm_multiply ? cs->strxfrm_multiply : 1); +} + + /* Converts a string into its sort key. @@ -1365,6 +1374,7 @@ MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler = my_strnncoll_simple, my_strnncollsp_simple, my_strnxfrm_simple, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index c1e41dc2d94..22cc8d9818d 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4627,6 +4627,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_sjis, my_strnncollsp_sjis, my_strnxfrm_sjis, + my_strnxfrmlen_simple, my_like_range_sjis, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index c6bdd106ad4..9ba35e1c8ec 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -927,6 +927,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_tis620, my_strnncollsp_tis620, my_strnxfrm_tis620, + my_strnxfrmlen_simple, my_like_range_tis620, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 2353c9397a2..8345d0474f2 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -8024,6 +8024,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = my_strnncoll_ucs2_uca, my_strnncollsp_ucs2_uca, my_strnxfrm_ucs2_uca, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_uca, NULL, @@ -8504,6 +8505,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, + my_strnxfrmlen_simple, my_like_range_mb, my_wildcmp_uca, NULL, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index adfd4794e36..0d45cceb64d 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1499,6 +1499,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = my_strnncoll_ucs2, my_strnncollsp_ucs2, my_strnxfrm_ucs2, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_ucs2_ci, my_strcasecmp_ucs2, @@ -1513,6 +1514,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_strnncoll_ucs2_bin, my_strnncollsp_ucs2_bin, my_strnxfrm_ucs2_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_ucs2_bin, my_strcasecmp_ucs2_bin, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index fc1496df280..deaddcc76f6 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8501,6 +8501,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 1f9f158a73d..e17e7587e85 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2238,6 +2238,12 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, } +static +uint my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), uint len) +{ + return (len * 2 + 2) / 3; +} + static int my_strnxfrm_utf8(CHARSET_INFO *cs, uchar *dst, uint dstlen, const uchar *src, uint srclen) @@ -2245,29 +2251,33 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, my_wc_t wc; int res; int plane; - uchar *de = dst + dstlen; + uchar *de= dst + dstlen; + uchar *de_beg= de - 1; const uchar *se = src + srclen; - while( src < se && dst < de ) + while (dst < de_beg) { - if ((res=my_utf8_uni(cs,&wc, src, se))<0) - { + if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0) break; - } src+=res; - srclen-=res; plane=(wc>>8) & 0xFF; wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - if ((res=my_uni_utf8(cs,wc,dst,de)) <0) - { - break; - } - dst+=res; + *dst++= wc >> 8; + *dst++= wc & 0xFF; + } - if (dst < de) - bfill(dst, de - dst, ' '); + + while (dst < de_beg) /* Fill the tail with keys for space character */ + { + *dst++= 0x00; + *dst++= 0x20; + } + + if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ + *de= 0x00; + return dstlen; } @@ -2306,6 +2316,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_utf8, + my_strnxfrmlen_utf8, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index b58a8f0f1e5..37611a5bd20 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -626,6 +626,7 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler = my_strnncoll_win1250ch, my_strnncollsp_win1250ch, my_strnxfrm_win1250ch, + my_strnxfrmlen_simple, my_like_range_win1250ch, my_wildcmp_8bit, my_strcasecmp_8bit, From a87e0069ab751e2efec7130d29e70c9edc2ba63f Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 26 Jan 2005 14:38:13 +0100 Subject: [PATCH 13/16] added check in ndb tests that require "default" cluster running i.e. ndb_restore --- mysql-test/include/ndb_default_cluster.inc | 4 ++++ mysql-test/r/ndb_default_cluster.require | 2 ++ mysql-test/t/ndb_restore.test | 1 + 3 files changed, 7 insertions(+) create mode 100644 mysql-test/include/ndb_default_cluster.inc create mode 100644 mysql-test/r/ndb_default_cluster.require diff --git a/mysql-test/include/ndb_default_cluster.inc b/mysql-test/include/ndb_default_cluster.inc new file mode 100644 index 00000000000..2f900b6a0b4 --- /dev/null +++ b/mysql-test/include/ndb_default_cluster.inc @@ -0,0 +1,4 @@ +-- require r/ndb_default_cluster.require +disable_query_log; +show status like "Ndb_connected_host"; +enable_query_log; diff --git a/mysql-test/r/ndb_default_cluster.require b/mysql-test/r/ndb_default_cluster.require new file mode 100644 index 00000000000..aa4988cdca3 --- /dev/null +++ b/mysql-test/r/ndb_default_cluster.require @@ -0,0 +1,2 @@ +Variable_name Value +Ndb_connected_host localhost diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 09939ec119d..3a77289a8fb 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc --disable_warnings use test; From 259aa7131c0dc7eff4132e3e591ddc83bda1a7ae Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 26 Jan 2005 15:07:39 +0100 Subject: [PATCH 14/16] updated show table status usage in ndb tests to become independent on ndb cluster run --- mysql-test/r/ndb_alter_table.result | 8 ++++---- mysql-test/r/ndb_autodiscover.result | 4 ++-- mysql-test/t/ndb_alter_table.test | 4 ++++ mysql-test/t/ndb_autodiscover.test | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index 2857a4b5cc7..2aab46014a9 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 0 0 0 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 0 0 # # 0 # 1 # # # latin1_swedish_ci NULL # SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 96 131072 0 0 0 101 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 96 # # 0 # 101 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col1 col2 col3 col4 col5 col6 to_be_deleted 0 4 3 5 PENDING 1 7 @@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 152 131072 0 0 0 102 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 152 # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 @@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 10 152 131072 0 0 0 103 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 10 152 # # 0 # 103 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index b89b4ce1f21..ba21483a9b0 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -144,8 +144,8 @@ Handler_discover 1 flush tables; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL -t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL number_of_replicas: 2 +t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL # +t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL # show status like 'handler_discover%'; Variable_name Value Handler_discover 2 diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 892443a1407..3544a50c3e1 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -47,10 +47,12 @@ col3 varchar (20) not null, col4 varchar(4) not null, col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; alter table t1 @@ -59,9 +61,11 @@ add column col7 varchar(30) not null after col5, add column col8 datetime not null, drop column to_be_deleted, change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; delete from t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 2159e6b6e62..713aa326e4d 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -176,7 +176,7 @@ show status like 'handler_discover%'; flush tables; system rm var/master-data/test/t7.frm ; ---replace_column 7 # 8 # 9 # 12 # 13 # 15 # +--replace_column 7 # 8 # 9 # 12 # 13 # 15 # 18 # show table status; show status like 'handler_discover%'; From 3b2bf2f512a62ae5b2c9e06e38026033b177bed9 Mon Sep 17 00:00:00 2001 From: "georg@beethoven.site" <> Date: Wed, 26 Jan 2005 15:19:20 +0100 Subject: [PATCH 15/16] Fixes for windows compilation bugs (After review of cs georg:1.1800 by Monty) --- VC++Files/libmysqld/libmysqld.dsp | 4 ---- VC++Files/mysqldemb/mysqldemb.dsp | 4 ---- extra/comp_err.c | 8 ++++---- innobase/ut/ut0ut.c | 7 +++++++ libmysql/libmysql.c | 4 ++-- sql/field.h | 2 +- sql/item_sum.cc | 6 +++--- sql/key.cc | 4 ++-- sql/opt_range.cc | 2 +- sql/sql_acl.cc | 4 ++-- sql/table.cc | 6 +++--- 11 files changed, 25 insertions(+), 26 deletions(-) diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 99912228445..019589289cd 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -228,10 +228,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/VC++Files/mysqldemb/mysqldemb.dsp b/VC++Files/mysqldemb/mysqldemb.dsp index a8207d436a0..61a745ff7e8 100644 --- a/VC++Files/mysqldemb/mysqldemb.dsp +++ b/VC++Files/mysqldemb/mysqldemb.dsp @@ -169,10 +169,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/extra/comp_err.c b/extra/comp_err.c index baed28a0350..a554fc2437e 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -41,7 +41,7 @@ static char *HEADERFILE= (char*) "mysqld_error.h"; static char *NAMEFILE= (char*) "mysqld_ername.h"; static char *STATEFILE= (char*) "sql_state.h"; static char *TXTFILE= (char*) "../sql/share/errmsg.txt"; -static char *DATADIR= (char*) "../sql/share/"; +static char *DATADIRECTORY= (char*) "../sql/share/"; static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace"; /* Header for errmsg.sys files */ @@ -112,8 +112,8 @@ static struct my_option my_long_options[]= 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"in_file", 'F', "Input file", (gptr *) & TXTFILE, (gptr *) & TXTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"out_dir", 'D', "Output base directory", (gptr *) & DATADIR, - (gptr *) & DATADIR, + {"out_dir", 'D', "Output base directory", (gptr *) & DATADIRECTORY, + (gptr *) & DATADIRECTORY, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"out_file", 'O', "Output filename (errmsg.sys)", (gptr *) & OUTFILE, (gptr *) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -281,7 +281,7 @@ static int create_sys_files(struct languages *lang_head, DBUG_RETURN(1); } - outfile_end= strxmov(outfile, DATADIR, + outfile_end= strxmov(outfile, DATADIRECTORY, tmp_lang->lang_long_name, NullS); if (!my_stat(outfile, &stat_info,MYF(0))) { diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index f35b4dea5e0..6f2aa0957d8 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -82,10 +82,17 @@ ut_usectime( ulint* sec, /* out: seconds since the Epoch */ ulint* ms) /* out: microseconds since the Epoch+*sec */ { +#ifdef __WIN__ + SYSTEMTIME st; + GetLocalTime(&st); + *sec = (ulint) st.wSecond; + *ms = (ulint) st.wMilliseconds; +#else struct timeval tv; gettimeofday(&tv,NULL); *sec = (ulint) tv.tv_sec; *ms = (ulint) tv.tv_usec; +#endif } /************************************************************** diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c6815d2a5ce..258391ac899 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1740,7 +1740,7 @@ static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row); STMT_ATTR_UPDATE_MAX_LENGTH attribute is set. */ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); -static bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); +static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); /* Maximum sizes of MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME @@ -3718,7 +3718,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlongstore(buffer, data); } *param->error= value != (param->is_unsigned ? - (double) (*(ulonglong*) buffer) : + ulonglong2double(*(ulonglong*) buffer) : (double) (*(longlong*) buffer)); break; case MYSQL_TYPE_FLOAT: diff --git a/sql/field.h b/sql/field.h index fd1ef09d14f..84d71afcd6f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1228,7 +1228,7 @@ public: int cmp(const char *a, const char *b) { return cmp_binary(a, b); } int key_cmp(const byte *a, const byte *b) - { return cmp_binary(a, b); } + { return cmp_binary((char *) a, (char *) b); } int key_cmp(const byte *str, uint length); int cmp_offset(uint row_offset); void get_key_image(char *buff, uint length, imagetype type); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index be89aa3f86d..29837c3afbd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1234,7 +1234,7 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2) { Field* f = *field; int len = *lengths++; - int res = f->cmp(key1, key2); + int res = f->cmp((char *) key1, (char *) key2); if (res) return res; key1 += len; @@ -1688,7 +1688,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return res; } } @@ -1722,7 +1722,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return (*order_item)->asc ? res : -res; } } diff --git a/sql/key.cc b/sql/key.cc index aec294e370a..c5ed60b129c 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -135,7 +135,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->get_key_image(to_key, length, Field::itRAW); + key_part->field->get_key_image((char *) to_key, length, Field::itRAW); to_key+= HA_KEY_BLOB_LENGTH; } else @@ -217,7 +217,7 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->set_key_image(from_key, length); + key_part->field->set_key_image((char *) from_key, length); from_key+= HA_KEY_BLOB_LENGTH; } else diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c3b84564504..e5799bfd509 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1891,7 +1891,7 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records) else { double n_blocks= - ceil((double)param->table->file->data_file_length / IO_SIZE); + ceil(ulonglong2double(param->table->file->data_file_length) / IO_SIZE); double busy_blocks= n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, rows2double(records))); if (busy_blocks < 1.0) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f9d95b2cde5..71d042eda02 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1494,12 +1494,12 @@ static bool update_user_table(THD *thd, const char *host, const char *user, DBUG_RETURN(1); /* purecov: deadcode */ table->field[0]->store(host,(uint) strlen(host), system_charset_info); table->field[1]->store(user,(uint) strlen(user), system_charset_info); - key_copy(user_key, table->record[0], table->key_info, + key_copy((byte *) user_key, table->record[0], table->key_info, table->key_info->key_length); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); if (table->file->index_read_idx(table->record[0], 0, - user_key, table->key_info->key_length, + (byte *) user_key, table->key_info->key_length, HA_READ_KEY_EXACT)) { my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), diff --git a/sql/table.cc b/sql/table.cc index 82ad32341c0..69a132329c0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -305,7 +305,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, if (!(record= (char *) alloc_root(&outparam->mem_root, rec_buff_length * records))) goto err; /* purecov: inspected */ - share->default_values= record; + share->default_values= (byte *) record; if (my_pread(file,(byte*) record, (uint) share->reclength, (ulong) (uint2korr(head+6)+ ((uint2korr(head+14) == 0xffff ? @@ -320,9 +320,9 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, } else { - outparam->record[0]= record+ rec_buff_length; + outparam->record[0]= (byte *) record+ rec_buff_length; if (records > 2) - outparam->record[1]= record+ rec_buff_length*2; + outparam->record[1]= (byte *) record+ rec_buff_length*2; else outparam->record[1]= outparam->record[0]; // Safety } From c38886b20c8f8e74304f1c5a507dbc4635b53da2 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Wed, 26 Jan 2005 18:37:49 +0400 Subject: [PATCH 16/16] timed_mutexes moved to include/my_sys.h and mysys/my_static.c to avoid linking problems referring to the variable from .c programs. --- include/my_sys.h | 2 ++ mysys/my_static.c | 2 ++ sql/mysql_priv.h | 1 - sql/mysqld.cc | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index d11dc4a3e46..72d4bec74b1 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -259,6 +259,8 @@ extern char wild_many,wild_one,wild_prefix; extern const char *charsets_dir; extern char *defaults_extra_file; +extern my_bool timed_mutexes; + typedef struct wild_file_pack /* Struct to hold info when selecting files */ { uint wilds; /* How many wildcards */ diff --git a/mysys/my_static.c b/mysys/my_static.c index 57d41676390..8207463ea50 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -25,6 +25,8 @@ #include "my_alarm.h" #endif +my_bool timed_mutexes= 0; + /* from my_init */ my_string home_dir=0,my_progname=0; char NEAR curr_dir[FN_REFLEN]= {0}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5a222a1ce10..0349d9a635f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1002,7 +1002,6 @@ extern ulong table_cache_size; extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout; extern ulong max_user_connections; -extern my_bool timed_mutexes; extern ulong what_to_log,flush_time; extern ulong query_buff_size, thread_stack,thread_stack_min; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 94eb34954ba..e99acd7ed82 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -335,7 +335,6 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong max_connections,max_used_connections, max_connect_errors, max_user_connections = 0; ulong thread_id=1L,current_pid; -my_bool timed_mutexes= 0; ulong slow_launch_threads = 0, sync_binlog_period; ulong expire_logs_days = 0; ulong rpl_recovery_rank=0;