From 52d9e13ffcacee74e42bc436877f5f4eb1999e66 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 5 Sep 2011 14:38:20 +0200 Subject: [PATCH 01/12] Bug #11750417 40942: UNABLE TO INSTALL FEDERATED PLUGIN Link plugin with a copy of string.o Copied test from 5.5 but this was dysfunctional, made it work Also tested on Windows --- mysql-test/include/have_federated_plugin.inc | 5 +++ mysql-test/mysql-test-run.pl | 18 ++++++++++ .../federated/federated_plugin-master.opt | 2 ++ .../suite/federated/federated_plugin.result | 19 +++++++++++ .../suite/federated/federated_plugin.test | 34 +++++++++++++++++++ storage/federated/Makefile.am | 4 +-- 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 mysql-test/include/have_federated_plugin.inc create mode 100644 mysql-test/suite/federated/federated_plugin-master.opt create mode 100644 mysql-test/suite/federated/federated_plugin.result create mode 100644 mysql-test/suite/federated/federated_plugin.test diff --git a/mysql-test/include/have_federated_plugin.inc b/mysql-test/include/have_federated_plugin.inc new file mode 100644 index 00000000000..5c7549de53f --- /dev/null +++ b/mysql-test/include/have_federated_plugin.inc @@ -0,0 +1,5 @@ +if (`select plugin_library IS NULL from information_schema.plugins where plugin_name LIKE '%federated%'`) +{ + --skip federated plugin not available +} + diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 1c7efccc69d..7661714eb03 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1979,6 +1979,24 @@ sub environment_setup { $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".$plugin_filename; } + # -------------------------------------------------------------------------- + # Add the path where mysqld will find ha_federated.so + # -------------------------------------------------------------------------- + my $fedplug_filename; + if (IS_WINDOWS) { + $fedplug_filename = "ha_federated.dll"; + } else { + $fedplug_filename = "ha_federated.so"; + } + my $lib_fed_plugin= + mtr_file_exists(vs_config_dirs('storage/federated',$fedplug_filename), + "$basedir/storage/federated/.libs/".$fedplug_filename, + "$basedir/lib/mysql/plugin/".$fedplug_filename); + + $ENV{'FEDERATED_PLUGIN'}= $fedplug_filename; + $ENV{'FEDERATED_PLUGIN_DIR'}= + ($lib_fed_plugin ? dirname($lib_fed_plugin) : ""); + # ---------------------------------------------------- # Add the path where mysqld will find mypluglib.so # ---------------------------------------------------- diff --git a/mysql-test/suite/federated/federated_plugin-master.opt b/mysql-test/suite/federated/federated_plugin-master.opt new file mode 100644 index 00000000000..027a6d949c0 --- /dev/null +++ b/mysql-test/suite/federated/federated_plugin-master.opt @@ -0,0 +1,2 @@ +--plugin_dir=$FEDERATED_PLUGIN_DIR +--loose-federated=ON diff --git a/mysql-test/suite/federated/federated_plugin.result b/mysql-test/suite/federated/federated_plugin.result new file mode 100644 index 00000000000..b49a977d9df --- /dev/null +++ b/mysql-test/suite/federated/federated_plugin.result @@ -0,0 +1,19 @@ +CREATE TABLE t2(a int); +CREATE TABLE t1(a int) ENGINE=FEDERATED +CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/t2'; +Warnings: +Warning 1286 Unknown table engine 'FEDERATED' +Warning 1266 Using storage engine MyISAM for table 't1' +DROP TABLE t1; +INSTALL PLUGIN federated SONAME 'FEDERATED_PLUGIN'; +INSTALL PLUGIN FEDERATED SONAME 'FEDERATED_PLUGIN'; +ERROR HY000: Function 'FEDERATED' already exists +UNINSTALL PLUGIN federated; +INSTALL PLUGIN federated SONAME 'FEDERATED_PLUGIN'; +CREATE TABLE t1(a int) ENGINE=FEDERATED +CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/t2'; +DROP TABLE t1; +UNINSTALL PLUGIN federated; +UNINSTALL PLUGIN federated; +ERROR 42000: PLUGIN federated does not exist +DROP TABLE t2; diff --git a/mysql-test/suite/federated/federated_plugin.test b/mysql-test/suite/federated/federated_plugin.test new file mode 100644 index 00000000000..6e5152df17c --- /dev/null +++ b/mysql-test/suite/federated/federated_plugin.test @@ -0,0 +1,34 @@ +--source include/have_federated_plugin.inc + +connect (master,localhost,root,,test,$MASTER_MYPORT,); +connect (slave,localhost,root,,test,$SLAVE_MYPORT,); + +connection master; +CREATE TABLE t2(a int); + +connection slave; +CREATE TABLE t1(a int) ENGINE=FEDERATED + CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/t2'; +DROP TABLE t1; + +--replace_result $FEDERATED_PLUGIN FEDERATED_PLUGIN +eval INSTALL PLUGIN federated SONAME '$FEDERATED_PLUGIN'; +--replace_result $FEDERATED_PLUGIN FEDERATED_PLUGIN +--error ER_UDF_EXISTS +eval INSTALL PLUGIN FEDERATED SONAME '$FEDERATED_PLUGIN'; + +UNINSTALL PLUGIN federated; + +--replace_result $FEDERATED_PLUGIN FEDERATED_PLUGIN +eval INSTALL PLUGIN federated SONAME '$FEDERATED_PLUGIN'; + +CREATE TABLE t1(a int) ENGINE=FEDERATED + CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/t2'; +DROP TABLE t1; + +UNINSTALL PLUGIN federated; +--error ER_SP_DOES_NOT_EXIST +UNINSTALL PLUGIN federated; + +connection master; +DROP TABLE t2; diff --git a/storage/federated/Makefile.am b/storage/federated/Makefile.am index e0dae69539e..9b4e74af0a7 100644 --- a/storage/federated/Makefile.am +++ b/storage/federated/Makefile.am @@ -37,14 +37,14 @@ pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@ ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir) ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_federated_la_SOURCES = ha_federated.cc +ha_federated_la_SOURCES = ha_federated.cc $(top_srcdir)/mysys/string.c EXTRA_LIBRARIES = libfederated.a noinst_LIBRARIES = @plugin_federated_static_target@ libfederated_a_CXXFLAGS = $(AM_CXXFLAGS) libfederated_a_CFLAGS = $(AM_CFLAGS) -libfederated_a_SOURCES= ha_federated.cc +libfederated_a_SOURCES= ha_federated.cc $(top_srcdir)/mysys/string.c EXTRA_DIST = CMakeLists.txt plug.in From a238e6ada252aaf8c0f9f146ec46c15ea13309e7 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:15:36 +0200 Subject: [PATCH 02/12] Bug #12956584 MYSQLTEST: --ENABLE_X OR --DISABLE_X APPLYING ONLY TO NEXT COMMAND/STMT Added a keyword ONCE to add to those commands Some internal tables to keep track of which properties are temporarily overriden Added tests in mysqltest.test Updates to other tests will be done later --- client/mysqltest.cc | 132 ++++++++++++++++++++++++++-------- mysql-test/r/mysqltest.result | 19 +++++ mysql-test/t/mysqltest.test | 61 +++++++++++++--- 3 files changed, 173 insertions(+), 39 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 903f6a024f7..6b1f6645b09 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -118,6 +118,41 @@ static char **default_argv; static const char *load_default_groups[]= { "mysqltest", "client", 0 }; static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer; +/* Info on properties that can be set with --enable_X and --disable_X */ + +struct property { + my_bool *var; /* Actual variable */ + my_bool set; /* Has been set for ONE command */ + my_bool old; /* If set, thus is the old value */ + my_bool reverse; /* Varible is true if disabled */ + const char *env_name; /* Env. variable name */ +}; + +static struct property prop_list[] = { + { &abort_on_error, 0, 1, 0, "$ENABLED_ABORT_ON_ERROR" }, + { &disable_connect_log, 0, 1, 1, "$ENABLED_CONNECT_LOG" }, + { &disable_info, 0, 1, 1, "$ENABLED_INFO" }, + { &display_metadata, 0, 0, 0, "$ENABLED_METADATA" }, + { &ps_protocol, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, + { &disable_query_log, 0, 0, 1, "$ENABLED_QUERY_LOG" }, + { &disable_result_log, 0, 0, 1, "$ENABLED_RESULT_LOG" }, + { &disable_warnings, 0, 0, 1, "$ENABLED_WARNINGS" } +}; + +static my_bool once_property= FALSE; + +enum enum_prop { + P_ABORT= 0, + P_CONNECT, + P_INFO, + P_META, + P_PS, + P_QUERY, + P_RESULT, + P_WARN, + P_MAX +}; + static uint start_lineno= 0; /* Start line of current command */ static uint my_end_arg= 0; @@ -712,6 +747,7 @@ void handle_error(struct st_command*, unsigned int err_errno, const char *err_error, const char *err_sqlstate, DYNAMIC_STRING *ds); void handle_no_error(struct st_command*); +void revert_properties(); #ifdef EMBEDDED_LIBRARY @@ -1174,6 +1210,7 @@ void handle_command_error(struct st_command *command, uint error) { DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %d", command->first_word_len, command->query, error)); + revert_properties(); DBUG_VOID_RETURN; } if (command->expected_errors.count > 0) @@ -1188,6 +1225,7 @@ void handle_command_error(struct st_command *command, uint error) command->first_word_len, command->query, command->expected_errors.err[0].code.errnum); } + revert_properties(); DBUG_VOID_RETURN; } @@ -2267,6 +2305,50 @@ void var_set_errno(int sql_errno) var_set_string("$mysql_errname", get_errname_from_code(sql_errno)); } +/* Functions to handle --disable and --enable properties */ + +void set_once_property(enum_prop prop, my_bool val) +{ + property &pr= prop_list[prop]; + pr.set= 1; + pr.old= *pr.var; + *pr.var= val; + var_set_int(pr.env_name, (val != pr.reverse)); + once_property= TRUE; +} + +void set_property(st_command *command, enum_prop prop, my_bool val) +{ + char* p= command->first_argument; + if (p && !strcmp (p, "ONCE")) + { + command->last_argument= p + 4; + set_once_property(prop, val); + return; + } + property &pr= prop_list[prop]; + *pr.var= val; + pr.set= 0; + var_set_int(pr.env_name, (val != pr.reverse)); +} + +void revert_properties() +{ + if (! once_property) + return; + for (int i= 0; i < (int) P_MAX; i++) + { + property &pr= prop_list[i]; + if (pr.set) + { + *pr.var= pr.old; + pr.set= 0; + var_set_int(pr.env_name, (pr.old != pr.reverse)); + } + } + once_property=FALSE; +} + /* Set variable from the result of a query @@ -4426,6 +4508,7 @@ void do_let(struct st_command *command) var_set(var_name, var_name_end, let_rhs_expr.str, (let_rhs_expr.str + let_rhs_expr.length)); dynstr_free(&let_rhs_expr); + revert_properties(); DBUG_VOID_RETURN; } @@ -7354,6 +7437,7 @@ void handle_error(struct st_command *command, dynstr_append(ds,"Got one of the listed errors\n"); } /* OK */ + revert_properties(); DBUG_VOID_RETURN; } @@ -7381,6 +7465,7 @@ void handle_error(struct st_command *command, command->expected_errors.err[0].code.sqlstate); } + revert_properties(); DBUG_VOID_RETURN; } @@ -7415,6 +7500,7 @@ void handle_no_error(struct st_command *command) command->query, command->expected_errors.err[0].code.sqlstate); } + revert_properties(); DBUG_VOID_RETURN; } @@ -8475,60 +8561,46 @@ int main(int argc, char **argv) case Q_DIRTY_CLOSE: do_close_connection(command); break; case Q_ENABLE_QUERY_LOG: - disable_query_log= 0; - var_set_int("$ENABLED_QUERY_LOG", 1); + set_property(command, P_QUERY, 0); break; case Q_DISABLE_QUERY_LOG: - disable_query_log= 1; - var_set_int("$ENABLED_QUERY_LOG", 0); + set_property(command, P_QUERY, 1); break; case Q_ENABLE_ABORT_ON_ERROR: - abort_on_error= 1; - var_set_int("$ENABLED_ABORT_ON_ERROR", 1); + set_property(command, P_ABORT, 1); break; case Q_DISABLE_ABORT_ON_ERROR: - abort_on_error= 0; - var_set_int("$ENABLED_ABORT_ON_ERROR", 0); + set_property(command, P_ABORT, 0); break; case Q_ENABLE_RESULT_LOG: - disable_result_log= 0; - var_set_int("$ENABLED_RESULT_LOG", 1); + set_property(command, P_RESULT, 0); break; case Q_DISABLE_RESULT_LOG: - disable_result_log=1; - var_set_int("$ENABLED_RESULT_LOG", 0); + set_property(command, P_RESULT, 1); break; case Q_ENABLE_CONNECT_LOG: - disable_connect_log=0; - var_set_int("$ENABLED_CONNECT_LOG", 1); + set_property(command, P_CONNECT, 0); break; case Q_DISABLE_CONNECT_LOG: - disable_connect_log=1; - var_set_int("$ENABLED_CONNECT_LOG", 0); + set_property(command, P_CONNECT, 1); break; case Q_ENABLE_WARNINGS: - disable_warnings= 0; - var_set_int("$ENABLED_WARNINGS", 1); + set_property(command, P_WARN, 0); break; case Q_DISABLE_WARNINGS: - disable_warnings= 1; - var_set_int("$ENABLED_WARNINGS", 0); + set_property(command, P_WARN, 1); break; case Q_ENABLE_INFO: - disable_info= 0; - var_set_int("$ENABLED_INFO", 1); + set_property(command, P_INFO, 0); break; case Q_DISABLE_INFO: - disable_info= 1; - var_set_int("$ENABLED_INFO", 0); + set_property(command, P_INFO, 1); break; case Q_ENABLE_METADATA: - display_metadata= 1; - var_set_int("$ENABLED_METADATA", 1); + set_property(command, P_META, 1); break; case Q_DISABLE_METADATA: - display_metadata= 0; - var_set_int("$ENABLED_METADATA", 0); + set_property(command, P_META, 0); break; case Q_SOURCE: do_source(command); break; case Q_SLEEP: do_sleep(command, 0); break; @@ -8744,12 +8816,12 @@ int main(int argc, char **argv) do_set_charset(command); break; case Q_DISABLE_PS_PROTOCOL: - ps_protocol_enabled= 0; + set_property(command, P_PS, 0); /* Close any open statements */ close_statements(); break; case Q_ENABLE_PS_PROTOCOL: - ps_protocol_enabled= ps_protocol; + set_property(command, P_PS, 1); break; case Q_DISABLE_RECONNECT: set_reconnect(&cur_con->mysql, 0); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 9d000e6f782..2dfb0e88f6e 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -160,6 +160,25 @@ after_--enable_abort_on_error select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064... +garbage; +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 'garbage' at line 1 +select 2; +select 3; +3 +3 +select 5; +ERROR 42S02: Table 'test.t1' doesn't exist +select 7; +7 +7 +mysqltest: At line 1: End of line junk detected: "OCNE" +connect con1,localhost,root,,; +select 5 from t1; +lower +case +name +abc +xyz hello hello ;;;;;;;; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 9fa41b9eb51..6279a392119 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -383,6 +383,54 @@ select 3 from t1 ; --error 1 --exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# Test --enable and --disable with ONCE +# ---------------------------------------------------------------------------- + +--disable_abort_on_error ONCE +garbage; +--disable_abort_on_error ONCE +--remove_file DoesNotExist + +--disable_result_log +select 2; +--enable_result_log ONCE +select 3; +select 5; +--enable_result_log + +# ---------------------------------------------------------------------------- +# Test cumulative ONCE +# ---------------------------------------------------------------------------- + +--disable_abort_on_error ONCE +--disable_query_log ONCE +select 3 from t1; +select 7; + +--error 1 +--exec echo "--disable_info OCNE" | $MYSQL_TEST 2>&1 + +--enable_connect_log ONCE +connect (con1,localhost,root,,); +connection default; +disconnect con1; + +# ---------------------------------------------------------------------------- +# Test ONCE can be combined with --error or modifiers like lowercase +# ---------------------------------------------------------------------------- + +--disable_result_log ONCE +--error ER_NO_SUCH_TABLE +select 5 from t1; + +--disable_query_log ONCE +--lowercase_result +select "CASE" as "LOWER"; + +--sorted_result +--disable_query_log ONCE +select "xyz" as name union select "abc" as name order by name desc; # ---------------------------------------------------------------------------- # Test comments @@ -952,10 +1000,9 @@ while ($outer) --source $MYSQLTEST_VARDIR/tmp/sourced.inc --error ER_NO_SUCH_TABLE SELECT * from nowhere; - --disable_abort_on_error + --disable_abort_on_error ONCE # Statement giving a different error, to make sure we don't mask it SELECT * FROM nowhere else; - --enable_abort_on_error } dec $outer; inc $ifval; @@ -1104,9 +1151,8 @@ system echo "hej" > /dev/null; --error 1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 ---disable_abort_on_error +--disable_abort_on_error ONCE system NonExistsinfComamdn 2> /dev/null; ---enable_abort_on_error # ---------------------------------------------------------------------------- @@ -2517,10 +2563,9 @@ INSERT INTO t1 SELECT f1 - 64 FROM t1; INSERT INTO t1 SELECT f1 - 128 FROM t1; INSERT INTO t1 SELECT f1 - 256 FROM t1; INSERT INTO t1 SELECT f1 - 512 FROM t1; ---disable_result_log +--disable_result_log ONCE --sorted_result SELECT * FROM t1; ---enable_result_log DROP TABLE t1; # ---------------------------------------------------------------------------- @@ -2568,11 +2613,9 @@ SELECT 0 as "WILL NOT lower case --exec $MYSQL_TEST --help 2>&1 > /dev/null --exec $MYSQL_TEST --version 2>&1 > /dev/null --enable_query_log ---disable_abort_on_error +--disable_abort_on_error ONCE --error 1 --exec $MYSQL_TEST a b c 2>&1 > /dev/null ---enable_abort_on_error ---enable_query_log # ---------------------------------------------------------------------------- # test for query_get_value From 52960624d350359c67a333fb09c3a93465116668 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:19:24 +0200 Subject: [PATCH 03/12] Bug #12793118 MYSQLTEST: --ERROR AND --DISABLE_ABORT_ON_ERROR DO NOT WORK FOR SQL IN COMMANDS Call handle_error() instead of die() when evaluating these Must remember "current command" with link to errors to ignore Added test cases to mysqltest.test --- client/mysqltest.cc | 27 ++++++++++++++++++++++----- mysql-test/r/mysqltest.result | 11 +++++++++-- mysql-test/t/mysqltest.test | 25 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9985b70fcbc..593bb8ea290 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -451,6 +451,7 @@ TYPELIB command_typelib= {array_elements(command_names),"", command_names, 0}; DYNAMIC_STRING ds_res; +struct st_command *curr_command= 0; char builtin_echo[FN_REFLEN]; @@ -2212,9 +2213,16 @@ void var_query_set(VAR *var, const char *query, const char** query_end) init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); do_eval(&ds_query, query, end, FALSE); - if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + if (mysql_real_query(mysql, ds_query.str, ds_query.length)) + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); dynstr_free(&ds_query); @@ -2315,8 +2323,15 @@ void var_set_query_get_value(struct st_command *command, VAR *var) /* Run the query */ if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); @@ -8147,6 +8162,8 @@ int main(int argc, char **argv) { command->last_argument= command->first_argument; processed = 1; + /* Need to remember this for handle_error() */ + curr_command= command; switch (command->type) { case Q_CONNECT: do_connect(command); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a16b3ec2670..ecfd526ebc9 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -135,6 +135,10 @@ select 1146 as "after_!errno_masked_error" ; after_!errno_masked_error 1146 mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000... +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 'garbage' at line 1 + is empty +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 'nonsense' at line 1 + is empty garbage ; 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 'garbage' at line 1 select 1064 as "after_--enable_abort_on_error" ; @@ -143,6 +147,9 @@ after_--enable_abort_on_error select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064... + is empty + is empty +"Yes it's empty" hello hello ;;;;;;;; @@ -315,7 +322,7 @@ insert into t1 values ('$dollar'); $dollar `select 42` drop table t1; -mysqltest: At line 1: Error running query 'failing query': 1064 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 'failing query' at line 1 +mysqltest: At line 1: query 'let $var2= `failing query`' failed: 1064: 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 'failing query' at line 1 mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Could not open './non_existingFile' for reading, errno: 2 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": @@ -813,7 +820,7 @@ mysqltest: At line 1: Could not find column 'column_not_exists' in the result of mysqltest: At line 1: Query 'SET @A = 1' didn't return a result set mysqltest: At line 1: Could not find column '1 AS B' in the result of 'SELECT 1 AS A' value= No such row -mysqltest: At line 1: Error running query 'SHOW COLNS FROM t1': 1064 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 'COLNS FROM t1' at line 1 +mysqltest: At line 1: query 'let $value= query_get_value(SHOW COLNS FROM t1, Field, 1)' failed: 1064: 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 'COLNS FROM t1' at line 1 Field Type Null Key Default Extra a int(11) YES -><- NULL diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 52dfd8e86d3..7b897117b9b 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -334,6 +334,14 @@ eval select $mysql_errno as "after_!errno_masked_error" ; exit(2); EOF +# ---------------------------------------------------------------------------- +# Check backtick and query_get_value, result should be empty +# ---------------------------------------------------------------------------- +let $empty= `garbage`; +echo $empty is empty; +let $empty= query_get_value(nonsense, blabla, 1); +echo $empty is empty; + # ---------------------------------------------------------------------------- # Switch the abort on error on and check the effect on $mysql_errno # ---------------------------------------------------------------------------- @@ -364,6 +372,23 @@ select 3 from t1 ; --exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# Test --error with backtick operator or query_get_value +# ---------------------------------------------------------------------------- + +--error 0,ER_NO_SUCH_TABLE +let $empty= `SELECT foo from bar`; +echo $empty is empty; + +--error 0,ER_BAD_FIELD_ERROR +let $empty= query_get_value(SELECT bar as foo, baz, 1); +echo $empty is empty; + +--error 0,ER_NO_SUCH_TABLE +if (!`SELECT foo from bar`) { + echo "Yes it's empty"; +} + # ---------------------------------------------------------------------------- # Test comments # ---------------------------------------------------------------------------- From 6e2adc9fb4770f1151f8ce7b7e0353f9c0358fc9 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:26:53 +0200 Subject: [PATCH 04/12] Bug #12912120 MTR SHOULD EXPORT MYSQLD'S PATH TO TEST CASES Export $MYSQLD as full path to executable $MYSQLD_CMD is executable with minimum required args --- mysql-test/mysql-test-run.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 7661714eb03..148339c3890 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2130,6 +2130,12 @@ sub environment_setup { $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= mysql_fix_arguments(); $ENV{'EXE_MYSQL'}= $exe_mysql; + my $exe_mysqld= find_mysqld($basedir); + $ENV{'MYSQLD'}= $exe_mysqld; + my $extra_opts= join (" ", @opt_extra_mysqld_opt); + $ENV{'MYSQLD_CMD'}= "$exe_mysqld --defaults-group-suffix=.1 ". + "--defaults-file=$path_config_file $extra_opts"; + # ---------------------------------------------------- # bug25714 executable may _not_ exist in # some versions, test using it should be skipped From 69e76a168b9311f79f4f5ab6b942bf6048a7241f Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:32:19 +0200 Subject: [PATCH 05/12] Bug #12939555 MTR FINDS ALREADY COMPRESSED CORE WHEN LOOKING FOR CORE FILES AFTER RETRIED TEST Just check that core file name does not end in .gz Not a problem for Windows, as we check for files *ending* in .dmp --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 451b877f9a8..1e46ac79d95 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -653,8 +653,9 @@ sub run_test_server ($$$) { my $core_file= $File::Find::name; my $core_name= basename($core_file); - if ($core_name =~ /^core/ or # Starting with core - (IS_WINDOWS and $core_name =~ /\.dmp$/)){ + # Name beginning with core, not ending in .gz + if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) + or (IS_WINDOWS and $core_name =~ /\.dmp$/)){ # Ending with .dmp mtr_report(" - found '$core_name'", "($num_saved_cores/$opt_max_save_core)"); From 32e8085de932a60d933b6405cdbaf5982d6204c3 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 15 Sep 2011 10:53:19 +0200 Subject: [PATCH 06/12] Bug #12956584 - MYSQLTEST: --ENABLE_X OR --DISABLE_X APPLYING ONLY TO NEXT COMMAND/STMT Followup fixes for --ps-protocol: 1) Incorrectly set ps_protocol variable instead of ps_protocol_enabled 2) disable_result_log was tested after calling handle_no_error() which would revert a temporary setting. --- client/mysqltest.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 6b1f6645b09..806f35bb85a 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -133,7 +133,7 @@ static struct property prop_list[] = { { &disable_connect_log, 0, 1, 1, "$ENABLED_CONNECT_LOG" }, { &disable_info, 0, 1, 1, "$ENABLED_INFO" }, { &display_metadata, 0, 0, 0, "$ENABLED_METADATA" }, - { &ps_protocol, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, + { &ps_protocol_enabled, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, { &disable_query_log, 0, 0, 1, "$ENABLED_QUERY_LOG" }, { &disable_result_log, 0, 0, 1, "$ENABLED_RESULT_LOG" }, { &disable_warnings, 0, 0, 1, "$ENABLED_WARNINGS" } @@ -7531,6 +7531,9 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, DBUG_ENTER("run_query_stmt"); DBUG_PRINT("query", ("'%-.60s'", query)); + /* Remember disable_result_log since handle_no_error() may reset it */ + my_bool dis_res= disable_result_log; + /* Init a new stmt if it's not already one created for this connection */ @@ -7626,7 +7629,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, /* If we got here the statement was both executed and read successfully */ handle_no_error(command); - if (!disable_result_log) + if (!dis_res) { /* Not all statements creates a result set. If there is one we can @@ -8821,7 +8824,7 @@ int main(int argc, char **argv) close_statements(); break; case Q_ENABLE_PS_PROTOCOL: - set_property(command, P_PS, 1); + set_property(command, P_PS, ps_protocol); break; case Q_DISABLE_RECONNECT: set_reconnect(&cur_con->mysql, 0); From e24d8bbf0af4d1312f431cf5274fd0fa38646d9f Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 15 Sep 2011 12:20:43 +0200 Subject: [PATCH 07/12] Test federated_plugin must have ps-protocol off --- mysql-test/suite/federated/federated_plugin.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/federated/federated_plugin.test b/mysql-test/suite/federated/federated_plugin.test index 6e5152df17c..8c465095cfa 100644 --- a/mysql-test/suite/federated/federated_plugin.test +++ b/mysql-test/suite/federated/federated_plugin.test @@ -1,5 +1,8 @@ --source include/have_federated_plugin.inc +# Uninstall will not uninstall if ps has been used +--disable_ps_protocol + connect (master,localhost,root,,test,$MASTER_MYPORT,); connect (slave,localhost,root,,test,$SLAVE_MYPORT,); From e0a9cd56a76d4dfcf797e5a0186f53405f0b7fef Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 15 Sep 2011 12:34:32 +0200 Subject: [PATCH 08/12] Bug #11751927 42960: MTR2: NO MORE --STRESS PARAMETERS Quick fix: run mysql-stress-test.pl via a wrapper test Amend mtr to run just that test when using --stress Updated mysql-stress-test.pl to exit(1) if wrong options --- mysql-test/mysql-stress-test.pl | 7 ++++--- mysql-test/mysql-test-run.pl | 25 ++++++++++++++++++++-- mysql-test/suite/stress/t/wrapper.test | 29 ++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/stress/t/wrapper.test diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl index f2471d169d1..0e3b52d7bf5 100755 --- a/mysql-test/mysql-stress-test.pl +++ b/mysql-test/mysql-stress-test.pl @@ -238,9 +238,9 @@ GetOptions("server-host=s", "server-logs-dir=s", "server-port=s", "test-duration=i", "test-suffix=s", "check-tests-file", "verbose", "log-error-details", "cleanup", "mysqltest=s", # OBN: (changing 'abort-on-error' to numberic for WL-4626/4685) - "abort-on-error=i" => \$opt_abort_on_error, "help") || usage(); + "abort-on-error=i" => \$opt_abort_on_error, "help") || usage(1); -usage() if ($opt_help); +usage(0) if ($opt_help); #$opt_abort_on_error=1; @@ -1131,6 +1131,7 @@ sub sig_TERM_handler sub usage { + my $retcode= shift; print < 1 && $opt_start_exit) { - mtr_warning("Parallel and --start-and-exit cannot be combined\n" . + if ($opt_parallel > 1 && ($opt_start_exit || $opt_stress)) { + mtr_warning("Parallel cannot be used with --start-and-exit or --stress\n" . "Setting parallel to 1"); $opt_parallel= 1; } @@ -1174,6 +1176,7 @@ sub command_line_setup { 'report-times' => \$opt_report_times, 'result-file' => \$opt_resfile, 'unit-tests!' => \$opt_ctest, + 'stress=s' => \$opt_stress, 'help|h' => \$opt_usage, # list-options is internal, not listed in help @@ -1627,6 +1630,22 @@ sub command_line_setup { mtr_error("--wait-all can only be used with --start options"); } + # -------------------------------------------------------------------------- + # Gather stress-test options and modify behavior + # -------------------------------------------------------------------------- + + if ($opt_stress) + { + $opt_stress=~ s/,/ /g; + $opt_user_args= 1; + mtr_error("--stress cannot be combined with named ordinary suites or tests") + if $opt_suites || @opt_cases; + $opt_suites="stress"; + @opt_cases= ("wrapper"); + $ENV{MST_OPTIONS}= $opt_stress; + $opt_ctest= 0; + } + # -------------------------------------------------------------------------- # Check timeout arguments # -------------------------------------------------------------------------- @@ -6128,6 +6147,8 @@ Misc options nounit-tests Do not run unit tests. Normally run if configured and if not running named tests/suites unit-tests Run unit tests even if they would otherwise not be run + stress=ARGS Run stress test, providing options to + mysql-stress-test.pl. Options are separated by comma. Some options that control enabling a feature for normal test runs, can be turned off by prepending 'no' to the option, e.g. --notimer. diff --git a/mysql-test/suite/stress/t/wrapper.test b/mysql-test/suite/stress/t/wrapper.test new file mode 100644 index 00000000000..4d2dd808a4c --- /dev/null +++ b/mysql-test/suite/stress/t/wrapper.test @@ -0,0 +1,29 @@ +# +# This is a wrapper "pseudo" test for mtr --stress execution. +# It should not be run directly (will be skipped) +# Do not create a result file! +# + +if (!$MST_OPTIONS) { + skip Only to be run with mtr --stress; +} + +# echo Running MST with options $MST_OPTIONS; + +perl; + my ($mtest)= split " ", $ENV{MYSQL_TEST}; + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mtest.inc") or die; + print FILE "let \$MYSQLTEST_BIN= $mtest;\n"; + close FILE; +EOF + +--source $MYSQL_TMP_DIR/mtest.inc +--remove_file $MYSQL_TMP_DIR/mtest.inc + +exec perl mysql-stress-test.pl --mysqltest=$MYSQLTEST_BIN + --server-port=$MASTER_MYPORT --server-socket=$MASTER_MYSOCK + --server-user=root --cleanup + --server-logs-dir=$MYSQLTEST_VARDIR/log + --stress-basedir=$MYSQLTEST_VARDIR + $MST_OPTIONS +; From 4f7a290e70eaf1bdb7bb4c017dfb1cd490f2e917 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 15 Sep 2011 13:18:12 +0200 Subject: [PATCH 09/12] Some tests simplified after 12912120 --- mysql-test/t/mysql_plugin.test | 1 - mysql-test/t/mysqld--defaults-file.test | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/mysql-test/t/mysql_plugin.test b/mysql-test/t/mysql_plugin.test index b07ce40e43a..2ad9a8de186 100644 --- a/mysql-test/t/mysql_plugin.test +++ b/mysql-test/t/mysql_plugin.test @@ -45,7 +45,6 @@ use File::Basename; my $plugindir_ini= "$ENV{PLUGIN_DIR}/daemon_example.ini"; my $notfound= ""; open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die; - print FILE "let \$MYSQLD= $mysqld;\n"; print FILE "let \$MYSQLD_BASEDIR= $mysqld_basedir;\n"; print FILE "let \$MYSQL_MY_PRINT_DEFAULTS_BASEDIR= $my_print_defaults_basedir;\n"; if ((!-e $daemonexample_ini) || (!-r $daemonexample_ini)) diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test index 065436c38aa..3bfe0aa891f 100644 --- a/mysql-test/t/mysqld--defaults-file.test +++ b/mysql-test/t/mysqld--defaults-file.test @@ -5,21 +5,6 @@ source include/not_embedded.inc; source include/not_windows.inc; -# We need to use a plain "mysqld" without any other options to trigger -# the bug. In particular, it seems that passing --bootstrap does not -# trigger the bug. To do that, we extract the "command name" from the -# MYSQLD_BOOTSTRAP_CMD variable and store that in a file, which we -# then load into the test case. - -perl; - my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD}; - open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die; - print FILE "let \$MYSQLD= $mysqld;\n"; - close FILE; -EOF - -source $MYSQL_TMP_DIR/mysqld.inc; - # All these tests refer to configuration files that do not exist --error 1 @@ -44,4 +29,3 @@ exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1; --error 1 exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; -remove_file $MYSQL_TMP_DIR/mysqld.inc; From 4896fc11b70274f903b89e329464bea122991192 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 19 Sep 2011 16:06:35 +0200 Subject: [PATCH 10/12] Bug #12916194 MTR SHOULD CUT OFF ANALYSIS OF SERVER LOG IF THERE IS TOO MUCH Added simple cut-off w/warning if > one million lines --- mysql-test/mysql-test-run.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 148339c3890..4e4333767da 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3855,6 +3855,11 @@ sub extract_server_log ($$) { else { push(@lines, $line); + if (scalar(@lines) > 1000000) { + $Ferr = undef; + mtr_warning("Too much log from test, bailing out from extracting"); + return (); + } } } else From 4d19a19d6e19d76d18fccd7e863ec8211a9de110 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 19 Sep 2011 16:08:52 +0200 Subject: [PATCH 11/12] Bug #12934729 MTR: ADD OPTION TO RUN BOOTSTRAP THROUGH DEBUGGER Added options --boot-gdb etc. Extended gdb_arguments() with optional input argument Cannot use set args in gdb init file, as run < kills them (?) --- mysql-test/mysql-test-run.pl | 45 ++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 401b3ab2b5a..288aa2dfda2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -224,10 +224,13 @@ our %gprof_dirs; our $glob_debugger= 0; our $opt_gdb; our $opt_client_gdb; +my $opt_boot_gdb; our $opt_dbx; our $opt_client_dbx; +my $opt_boot_dbx; our $opt_ddd; our $opt_client_ddd; +my $opt_boot_ddd; our $opt_manual_gdb; our $opt_manual_dbx; our $opt_manual_ddd; @@ -1100,14 +1103,17 @@ sub command_line_setup { 'gdb' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, + 'boot-gdb' => \$opt_boot_gdb, 'manual-debug' => \$opt_manual_debug, 'ddd' => \$opt_ddd, 'client-ddd' => \$opt_client_ddd, 'manual-ddd' => \$opt_manual_ddd, + 'boot-ddd' => \$opt_boot_ddd, 'dbx' => \$opt_dbx, 'client-dbx' => \$opt_client_dbx, 'manual-dbx' => \$opt_manual_dbx, 'debugger=s' => \$opt_debugger, + 'boot-dbx' => \$opt_boot_dbx, 'client-debugger=s' => \$opt_client_debugger, 'strace-client:s' => \$opt_strace_client, 'max-save-core=i' => \$opt_max_save_core, @@ -3259,6 +3265,19 @@ sub mysql_install_db { # ---------------------------------------------------------------------- my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql"; + if ($opt_boot_gdb) { + gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_dbx) { + dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_ddd) { + ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + my $path_sql= my_find_file($install_basedir, ["mysql", "sql/share", "share/mysql", "share", "scripts"], @@ -5581,19 +5600,21 @@ sub gdb_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; - # Write $args to gdb init file - my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; # Remove the old gdbinit file unlink($gdb_init_file); + # Put $args into a single string + my $str= join(" ", @$$args); + my $runline= $input ? "run $str < $input" : "run $str"; + # write init file for mysqld or client mtr_tofile($gdb_init_file, - "set args $str\n" . "break main\n" . - "run"); + $runline); if ( $opt_manual_gdb ) { @@ -5632,20 +5653,22 @@ sub ddd_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; - # Write $args to ddd init file - my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; # Remove the old gdbinit file unlink($gdb_init_file); + # Put $args into a single string + my $str= join(" ", @$$args); + my $runline= $input ? "run $str < $input" : "run $str"; + # write init file for mysqld or client mtr_tofile($gdb_init_file, "file $$exe\n" . - "set args $str\n" . "break main\n" . - "run"); + $runline); if ( $opt_manual_ddd ) { @@ -5681,14 +5704,16 @@ sub dbx_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; # Put $args into a single string my $str= join " ", @$$args; + my $runline= $input ? "run $str < $input" : "run $str"; if ( $opt_manual_dbx ) { print "\nTo start dbx for $type, type in another window:\n"; print "cd $glob_mysql_test_dir; dbx -c \"stop in main; " . - "run $str\" $$exe\n"; + "$runline\" $$exe\n"; # Indicate the exe should not be started $$exe= undef; @@ -5707,7 +5732,7 @@ sub dbx_arguments { mtr_add_arg($$args, "dbx"); mtr_add_arg($$args, "-c"); - mtr_add_arg($$args, "stop in main; run $str"); + mtr_add_arg($$args, "stop in main; $runline"); mtr_add_arg($$args, "$$exe"); $$exe= "xterm"; From 9fb56539d055375b5881ded8d31131af5a81816c Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 26 Sep 2011 10:47:08 +0200 Subject: [PATCH 12/12] Fixed test sys_vars.all_vars: innodb_large_prefix no longer missing --- mysql-test/suite/sys_vars/r/all_vars.result | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/all_vars.result b/mysql-test/suite/sys_vars/r/all_vars.result index 715ad9e2c15..af05e3bc393 100644 --- a/mysql-test/suite/sys_vars/r/all_vars.result +++ b/mysql-test/suite/sys_vars/r/all_vars.result @@ -11,7 +11,5 @@ There should be *no* long test name listed below: select variable_name as `There should be *no* variables listed below:` from t2 left join t1 on variable_name=test_name where test_name is null; There should be *no* variables listed below: -INNODB_LARGE_PREFIX -INNODB_LARGE_PREFIX drop table t1; drop table t2;