From 5d5746bdbab1356680ca99ae8ccce106cd0a21c5 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 5 Sep 2011 14:38:20 +0200 Subject: [PATCH 1/5] 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 d75f2a4a6b207e05ad0cc1db7d646945e6ee140b Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:19:24 +0200 Subject: [PATCH 2/5] 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 ca697d3d4054880674b86ea72ab2b6ac9cc74f0b Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 14 Sep 2011 15:26:53 +0200 Subject: [PATCH 3/5] 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 4cdf513179d2bfcf544b3f460400d6fc84a9791e Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 15 Sep 2011 12:20:43 +0200 Subject: [PATCH 4/5] 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 6f8928cf468d24cceb992307ecdf2777240bad3f Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 19 Sep 2011 16:06:35 +0200 Subject: [PATCH 5/5] 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