summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/README60
-rw-r--r--mysql-test/README.gcov16
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test1
-rw-r--r--mysql-test/extra/binlog_tests/blackhole.test1
-rw-r--r--mysql-test/extra/binlog_tests/ctype_cp932.test22
-rw-r--r--mysql-test/extra/binlog_tests/insert_select-binlog.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test343
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_001.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_UUID.test6
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_blob.test6
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_charset.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_func003.test8
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_sp006.test8
-rw-r--r--mysql-test/include/drop-on-restart.inc3
-rw-r--r--mysql-test/include/gis_generic.inc35
-rw-r--r--mysql-test/include/ndb_backup.inc4
-rw-r--r--mysql-test/include/partition_1.inc2
-rw-r--r--mysql-test/include/partition_layout.inc2
-rw-r--r--mysql-test/include/rpl_multi_engine3.inc62
-rw-r--r--mysql-test/lib/init_db.sql4
-rwxr-xr-xmysql-test/mysql-test-run.pl73
-rw-r--r--mysql-test/mysql-test-run.sh24
-rw-r--r--mysql-test/ndb/Makefile.am2
-rw-r--r--mysql-test/r/archive_gis.result58
-rw-r--r--mysql-test/r/backup.result22
-rw-r--r--mysql-test/r/bdb_gis.result58
-rw-r--r--mysql-test/r/bigint.result9
-rw-r--r--mysql-test/r/binary.result19
-rw-r--r--mysql-test/r/binlog_row_ctype_cp932.result14
-rw-r--r--mysql-test/r/binlog_row_insert_select.result1
-rwxr-xr-xmysql-test/r/binlog_stm_ctype_cp932.result14
-rw-r--r--mysql-test/r/binlog_stm_insert_select.result1
-rw-r--r--mysql-test/r/case.result2
-rw-r--r--mysql-test/r/create.result6
-rw-r--r--mysql-test/r/ctype_cp932_notembedded.result17
-rw-r--r--mysql-test/r/drop.result4
-rw-r--r--mysql-test/r/events.result48
-rw-r--r--mysql-test/r/events_logs_tests.result84
-rw-r--r--mysql-test/r/events_microsec.result59
-rw-r--r--mysql-test/r/func_system.result4
-rw-r--r--mysql-test/r/grant.result2
-rw-r--r--mysql-test/r/grant2.result21
-rw-r--r--mysql-test/r/index_merge.result22
-rw-r--r--mysql-test/r/information_schema.result8
-rw-r--r--mysql-test/r/innodb_gis.result58
-rw-r--r--mysql-test/r/innodb_notembedded.result1
-rw-r--r--mysql-test/r/join.result5
-rw-r--r--mysql-test/r/merge.result2
-rw-r--r--mysql-test/r/mysqlbinlog_base64.result2
-rw-r--r--mysql-test/r/mysqlcheck.result4
-rw-r--r--mysql-test/r/mysqldump.result102
-rw-r--r--mysql-test/r/mysqltest.result4
-rw-r--r--mysql-test/r/ndb_alter_table_row.result9
-rw-r--r--mysql-test/r/ndb_binlog_basic.result18
-rw-r--r--mysql-test/r/ndb_binlog_basic2.result12
-rw-r--r--mysql-test/r/ndb_binlog_ddl_multi.result8
-rw-r--r--mysql-test/r/ndb_binlog_multi.result10
-rw-r--r--mysql-test/r/ndb_cache_multi2.result24
-rw-r--r--mysql-test/r/ndb_dd_backuprestore.result150
-rw-r--r--mysql-test/r/ndb_gis.result164
-rw-r--r--mysql-test/r/ndb_load.result4
-rw-r--r--mysql-test/r/ndb_partition_error.result8
-rw-r--r--mysql-test/r/ndb_partition_range.result144
-rw-r--r--mysql-test/r/ndb_restore.result16
-rw-r--r--mysql-test/r/partition.result58
-rw-r--r--mysql-test/r/partition_02myisam.result4
-rw-r--r--mysql-test/r/partition_charset.result18
-rw-r--r--mysql-test/r/partition_mgm_err.result10
-rw-r--r--mysql-test/r/partition_mgm_err2.result2
-rw-r--r--mysql-test/r/partition_pruning.result24
-rw-r--r--mysql-test/r/ps.result14
-rw-r--r--mysql-test/r/ps_1general.result2
-rw-r--r--mysql-test/r/query_cache.result2
-rw-r--r--mysql-test/r/rpl_LD_INFILE.result4
-rw-r--r--mysql-test/r/rpl_alter_db.result8
-rw-r--r--mysql-test/r/rpl_bit_npk.result64
-rw-r--r--mysql-test/r/rpl_create_database.result8
-rw-r--r--mysql-test/r/rpl_load_from_master.result6
-rw-r--r--mysql-test/r/rpl_load_table_from_master.result4
-rw-r--r--mysql-test/r/rpl_loaddata2.result2
-rw-r--r--mysql-test/r/rpl_loaddata_m.result6
-rw-r--r--mysql-test/r/rpl_loadfile.result4
-rw-r--r--mysql-test/r/rpl_ndb_bank.result12
-rw-r--r--mysql-test/r/rpl_ndb_blob.result64
-rw-r--r--mysql-test/r/rpl_ndb_dd_basic.result10
-rw-r--r--mysql-test/r/rpl_ndb_idempotent.result4
-rw-r--r--mysql-test/r/rpl_ndb_log.result18
-rw-r--r--mysql-test/r/rpl_ndb_multi.result4
-rw-r--r--mysql-test/r/rpl_ndb_row_001.result2
-rw-r--r--mysql-test/r/rpl_ndb_sync.result18
-rw-r--r--mysql-test/r/rpl_row_001.result2
-rw-r--r--mysql-test/r/rpl_row_4_bytes.result2
-rw-r--r--mysql-test/r/rpl_row_basic_11bugs.result4
-rw-r--r--mysql-test/r/rpl_row_drop.result6
-rw-r--r--mysql-test/r/rpl_row_loaddata_m.result2
-rw-r--r--mysql-test/r/rpl_row_mysqlbinlog.result266
-rw-r--r--mysql-test/r/rpl_row_sp010.result6
-rw-r--r--mysql-test/r/rpl_row_stop_middle_update.result2
-rw-r--r--mysql-test/r/rpl_switch_stm_row_mixed.result224
-rw-r--r--mysql-test/r/schema.result2
-rw-r--r--mysql-test/r/show_check.result2
-rw-r--r--mysql-test/r/skip_grants.result3
-rw-r--r--mysql-test/r/sp-error.result3
-rw-r--r--mysql-test/r/sp-security.result9
-rw-r--r--mysql-test/r/sp.result362
-rw-r--r--mysql-test/r/sp.result.orig4853
-rw-r--r--mysql-test/r/sp_notembedded.result2
-rw-r--r--mysql-test/r/subselect.result1
-rw-r--r--mysql-test/r/trigger.result103
-rw-r--r--mysql-test/r/type_timestamp.result14
-rw-r--r--mysql-test/r/upgrade.result62
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/r/warnings.result2
-rw-r--r--mysql-test/r/xml.result31
-rw-r--r--mysql-test/t/bigint.test9
-rw-r--r--mysql-test/t/binary.test12
-rw-r--r--mysql-test/t/binlog_row_mix_innodb_myisam-master.opt (renamed from mysql-test/t/mix_innodb_myisam_binlog-master.opt)0
-rw-r--r--mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt1
-rw-r--r--mysql-test/t/case.test2
-rw-r--r--mysql-test/t/client_xml.test12
-rw-r--r--mysql-test/t/create.test8
-rw-r--r--mysql-test/t/disabled.def13
-rw-r--r--mysql-test/t/events.test32
-rw-r--r--mysql-test/t/events_logs_tests-master.opt1
-rw-r--r--mysql-test/t/events_logs_tests.test89
-rw-r--r--mysql-test/t/events_microsec.test55
-rw-r--r--mysql-test/t/func_system.test2
-rw-r--r--mysql-test/t/grant2.test33
-rw-r--r--mysql-test/t/index_merge.test26
-rw-r--r--mysql-test/t/innodb_notembedded.test4
-rw-r--r--mysql-test/t/join.test6
-rw-r--r--mysql-test/t/loaddata.test2
-rw-r--r--mysql-test/t/mysql_client_test.test1
-rw-r--r--mysql-test/t/mysql_protocols.test2
-rw-r--r--mysql-test/t/mysqlbinlog_base64.test8
-rw-r--r--mysql-test/t/mysqlcheck.test2
-rw-r--r--mysql-test/t/mysqldump.test92
-rw-r--r--mysql-test/t/mysqltest.test16
-rw-r--r--mysql-test/t/ndb_alter_table_row.test2
-rw-r--r--mysql-test/t/ndb_binlog_basic.test18
-rw-r--r--mysql-test/t/ndb_binlog_basic2.test14
-rw-r--r--mysql-test/t/ndb_binlog_multi.test12
-rw-r--r--mysql-test/t/ndb_cache_multi2.test14
-rw-r--r--mysql-test/t/ndb_config.test2
-rw-r--r--mysql-test/t/ndb_dd_dump.test4
-rw-r--r--mysql-test/t/ndb_load.test4
-rw-r--r--mysql-test/t/ndb_partition_error.test12
-rw-r--r--mysql-test/t/ndb_partition_range.test165
-rw-r--r--mysql-test/t/ndb_restore.test20
-rw-r--r--mysql-test/t/partition.test75
-rw-r--r--mysql-test/t/partition_charset.test21
-rw-r--r--mysql-test/t/partition_mgm_err.test27
-rw-r--r--mysql-test/t/partition_mgm_err2.test25
-rw-r--r--mysql-test/t/ps.test21
-rw-r--r--mysql-test/t/query_cache.test2
-rw-r--r--mysql-test/t/rpl_000015.test2
-rw-r--r--mysql-test/t/rpl_LD_INFILE.test4
-rw-r--r--mysql-test/t/rpl_alter_db.test10
-rw-r--r--mysql-test/t/rpl_drop_db.test2
-rw-r--r--mysql-test/t/rpl_load_table_from_master.test4
-rw-r--r--mysql-test/t/rpl_loaddata2.test2
-rw-r--r--mysql-test/t/rpl_loaddata_m.test4
-rw-r--r--mysql-test/t/rpl_loadfile.test4
-rw-r--r--mysql-test/t/rpl_ndb_2innodb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2innodb.test16
-rw-r--r--mysql-test/t/rpl_ndb_2myisam-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2myisam-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2myisam.test13
-rw-r--r--mysql-test/t/rpl_ndb_bank.test20
-rw-r--r--mysql-test/t/rpl_ndb_idempotent.test6
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb.test16
-rw-r--r--mysql-test/t/rpl_ndb_multi.test6
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb.test15
-rw-r--r--mysql-test/t/rpl_ndb_sync.test22
-rw-r--r--mysql-test/t/rpl_row_4_bytes.test2
-rw-r--r--mysql-test/t/rpl_row_NOW.test12
-rw-r--r--mysql-test/t/rpl_row_drop.test4
-rw-r--r--mysql-test/t/rpl_row_func002.test6
-rw-r--r--mysql-test/t/rpl_row_mysqlbinlog-master.opt1
-rw-r--r--mysql-test/t/rpl_row_mysqlbinlog.test319
-rw-r--r--mysql-test/t/rpl_row_sp001.test12
-rw-r--r--mysql-test/t/rpl_row_sp010.test6
-rw-r--r--mysql-test/t/rpl_row_sp011.test12
-rw-r--r--mysql-test/t/rpl_row_stop_middle_update.test2
-rw-r--r--mysql-test/t/rpl_row_trig001.test8
-rw-r--r--mysql-test/t/rpl_row_trig003.test6
-rw-r--r--mysql-test/t/rpl_sp004.test6
-rw-r--r--mysql-test/t/rpl_switch_stm_row_mixed.test165
-rw-r--r--mysql-test/t/show_check.test2
-rw-r--r--mysql-test/t/skip_grants.test3
-rw-r--r--mysql-test/t/sp-destruct.test3
-rw-r--r--mysql-test/t/sp-error.test12
-rw-r--r--mysql-test/t/sp-security.test22
-rw-r--r--mysql-test/t/sp.test436
-rw-r--r--mysql-test/t/sp.test.orig5716
-rw-r--r--mysql-test/t/sp_notembedded.test3
-rw-r--r--mysql-test/t/subselect.test6
-rw-r--r--mysql-test/t/system_mysql_db_fix.test3
-rw-r--r--mysql-test/t/temp_table.test2
-rw-r--r--mysql-test/t/trigger.test88
-rw-r--r--mysql-test/t/upgrade.test45
-rw-r--r--mysql-test/t/view.test15
-rw-r--r--mysql-test/t/view_grant.test2
-rw-r--r--mysql-test/t/xml.test31
209 files changed, 15364 insertions, 861 deletions
diff --git a/mysql-test/README b/mysql-test/README
index 10d64784ed4..77b398ebf39 100644
--- a/mysql-test/README
+++ b/mysql-test/README
@@ -1,45 +1,51 @@
-This directory contains a test suite for mysql daemon. To run
+This directory contains a test suite for the MySQL daemon. To run
the currently existing test cases, simply execute ./mysql-test-run in
this directory. It will fire up the newly built mysqld and test it.
-If you want to run a test with a running MySQL server use the --extern
-option to mysql-test-run. Please note that in this mode the test suite
-expects user to specify test names to run. Otherwise it falls back to the
-normal "non-extern" behaviour. The reason is that some tests
-could not run with external server. Here is the sample command
-to test "alias" and "analyze" tests on external server:
+Note that you do not have to have to do "make install", and you could
+actually have a co-existing MySQL installation. The tests will not
+conflict with it.
-mysql-test-run --extern alias analyze
+All tests must pass. If one or more of them fail on your system, please
+read the following manual section for instructions on how to report the
+problem:
-To match your setup you might also need to provide --socket, --user and
-other relevant options.
+http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html
-Note that you do not have to have to do make install, and you could
-actually have a co-existing MySQL installation - the tests will not
-conflict with it.
+If you want to use an already running MySQL server for specific tests,
+use the --extern option to mysql-test-run. Please note that in this mode,
+the test suite expects you to provide the names of the tests to run.
+For example, here is the command to run the "alias" and "analyze" tests
+with an external server:
-All tests must pass. If one or more of them fail on your system, please
-read the following manual section of how to report the problem:
+mysql-test-run --extern alias analyze
+
+To match your setup, you might also need to provide --socket, --user, and
+other relevant options.
-http://dev.mysql.com/doc/mysql/en/MySQL_test_suite.html
+With no test cases named on the command line, mysql-test-run falls back
+to the normal "non-extern" behavior. The reason for this is that some
+tests cannot run with an external server.
-You can create your own test cases. To create a test case:
+You can create your own test cases. To create a test case, create a new
+file in the t subdirectory using a text editor. The file should have a .test
+extension. For example:
xemacs t/test_case_name.test
- in the file, put a set of SQL commands that will create some tables,
- load test data, run some queries to manipulate it.
+ In the file, put a set of SQL statements that create some tables,
+ load test data, and run some queries to manipulate it.
- We would appreciate if the test tables were called t1, t2, t3 ... (to not
+ We would appreciate it if you name your test tables t1, t2, t3 ... (to not
conflict too much with existing tables).
Your test should begin by dropping the tables you are going to create and
- end by dropping them again. This will ensure that one can run the test
- over and over again.
+ end by dropping them again. This ensures that you can run the test over
+ and over again.
If you are using mysqltest commands (like result file names) in your
- test case you should do create the result file as follows:
+ test case, you should create the result file as follows:
mysql-test-run --record test_case_name
@@ -47,8 +53,8 @@ You can create your own test cases. To create a test case:
mysqltest --record < t/test_case_name.test
- If you only have a simple test cases consistent of SQL commands and comments
- you can create the test case one of the following ways:
+ If you only have a simple test cases consisting of SQL statements and
+ comments, you can create the test case in one of the following ways:
mysql-test-run --record test_case_name
@@ -57,11 +63,11 @@ You can create your own test cases. To create a test case:
mysqltest --record --record-file=r/test_case_name.result < t/test_case_name.test
When this is done, take a look at r/test_case_name.result
- - If the result is wrong, you have found a bug; In this case you should
+ - If the result is incorrect, you have found a bug. In this case, you should
edit the test result to the correct results so that we can verify
that the bug is corrected in future releases.
To submit your test case, put your .test file and .result file(s) into
a tar.gz archive, add a README that explains the problem, ftp the
-archive to ftp://support.mysql.com/pub/mysql/secret/ and send a mail
+archive to ftp://support.mysql.com/pub/mysql/secret/ and send a mail
to bugs@lists.mysql.com
diff --git a/mysql-test/README.gcov b/mysql-test/README.gcov
index 83ddd6df2e1..6d2852e8ca0 100644
--- a/mysql-test/README.gcov
+++ b/mysql-test/README.gcov
@@ -1,11 +1,13 @@
To be able to see the level of coverage with the current test suite,
do the following:
- - make sure gcov is installed
- - compile with BUILD/compile-pentium-gcov ( if your machine is not pentium, hack
-this script, or just live with the pentium-specific stuff)
- - ./mysql-test-run -gcov
- - to see the level of coverage for a given source file:
+ - Make sure gcov is installed
+ - Compile the MySQL distribution with BUILD/compile-pentium-gcov (if your
+ machine does not have a pentium CPU, hack this script, or just live with
+ the pentium-specific stuff)
+ - In the mysql-test directory, run this command: ./mysql-test-run -gcov
+ - To see the level of coverage for a given source file:
grep source_file_name /tmp/gcov.out
- - to see which lines are not yet covered, look at source_file_name.gcov in the source tree. Then think hard about a test case that will cover those
-lines, and write one!
+ - To see which lines are not yet covered, look at source_file_name.gcov in
+ the source tree. Then think hard about a test case that will cover those
+ lines, and write one!
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index 8eb1dcb7dc3..e569e15e519 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -2,6 +2,7 @@
# misc binlogging tests that do not require a slave running
#
+-- source include/not_embedded.inc
-- source include/have_bdb.inc
-- source include/have_innodb.inc
-- source include/have_debug.inc
diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test
index 7e03dc9ed57..bd77286a9fe 100644
--- a/mysql-test/extra/binlog_tests/blackhole.test
+++ b/mysql-test/extra/binlog_tests/blackhole.test
@@ -2,6 +2,7 @@
# Simple test for blackhole example
# Taken from the select test
#
+-- source include/not_embedded.inc
-- source include/have_blackhole.inc
--disable_warnings
diff --git a/mysql-test/extra/binlog_tests/ctype_cp932.test b/mysql-test/extra/binlog_tests/ctype_cp932.test
index ac90ceabf23..688d06c4dde 100644
--- a/mysql-test/extra/binlog_tests/ctype_cp932.test
+++ b/mysql-test/extra/binlog_tests/ctype_cp932.test
@@ -398,28 +398,6 @@ DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
-# Test prepared statement with 0x8300 sequence in parameter while
-# running with cp932 client character set.
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-# TODO: Note that this doesn't actually test the code which was added for
-# bug#11338 because this syntax for prepared statements causes the PS to
-# be replicated differently than if we executed the PS from C or Java.
-# Using this syntax, variable names are inserted into the binlog instead
-# of values. The real goal of this test is to check the code that was
-# added to Item_param::query_val_str() in order to do hex encoding of
-# PS parameters when the client character set is cp932;
-# Bug#11338 has an example java program which can be used to verify this
-# code (and I have used it to test the fix) until there is some way to
-# exercise this code from mysql-test-run.
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 102;
-SELECT HEX(f1) FROM t1;
-DROP table t1;
-# end test for bug#11338
-
SET collation_connection='cp932_japanese_ci';
-- source include/ctype_filesort.inc
SET collation_connection='cp932_bin';
diff --git a/mysql-test/extra/binlog_tests/insert_select-binlog.test b/mysql-test/extra/binlog_tests/insert_select-binlog.test
index d4041f86ab5..a665dfda2b0 100644
--- a/mysql-test/extra/binlog_tests/insert_select-binlog.test
+++ b/mysql-test/extra/binlog_tests/insert_select-binlog.test
@@ -1,6 +1,10 @@
# Embedded server doesn't support binlog
-- source include/not_embedded.inc
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
# Check if a partly-completed INSERT SELECT in a MyISAM table goes into the
# binlog
diff --git a/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test b/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test
new file mode 100644
index 00000000000..014a72db30e
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test
@@ -0,0 +1,343 @@
+#######################################
+# Author: JBM #
+# Date: 2006-02-23 #
+# Purpose: See if replication between #
+# NDB -> MyISAM and InnoDB works. #
+# and if #
+# MyISAM and InnoDB -> NDB works. #
+#######################################
+# By JBM #
+# Date 2006-02-28 #
+# Change: Implemented review comments #
+#######################################
+
+--echo --- Doing pre test cleanup ---
+
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_query_log
+
+--echo --- Start test 1 Basic testing ---
+--echo --- Create Table Section ---
+
+#################################################
+# Requirment: Create basic table, replicate #
+# basice operations such at insert, update #
+# delete between 2 different storage engines #
+# Alter table and ensure table is handled #
+# Correctly on the slave #
+#################################################
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE,PRIMARY KEY(id));
+
+--echo --- Show table on master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Show table on slave ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+# Okay lets see how it holds up to table changes
+--echo --- Check that simple Alter statements are replicated correctly --
+
+ALTER TABLE t1 MODIFY vc TEXT;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(id, total);
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still same engine ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- End test 1 Basic testing ---
+--echo --- Do Cleanup --
+
+DROP TABLE IF EXISTS t1;
+
+#################################################################
+
+--echo --- Start test 2 partition RANGE testing --
+--echo --- Do setup --
+
+
+#################################################
+# Requirment: Create table that is partitioned #
+# by range on year i.e. year(t) and replicate #
+# basice operations such at insert, update #
+# delete between 2 different storage engines #
+# Alter table and ensure table is handled #
+# Correctly on the slave #
+#################################################
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY RANGE (YEAR(t))
+ (PARTITION p0 VALUES LESS THAN (1901),
+ PARTITION p1 VALUES LESS THAN (1946),
+ PARTITION p2 VALUES LESS THAN (1966),
+ PARTITION p3 VALUES LESS THAN (1986),
+ PARTITION p4 VALUES LESS THAN (2005),
+ PARTITION p5 VALUES LESS THAN MAXVALUE);
+
+--echo --- Show table on master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Show table on slave --
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- Check that simple Alter statements are replicated correctly ---
+
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still same engine ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+--enable_query_log
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- End test 2 partition RANGE testing ---
+--echo --- Do Cleanup ---
+
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+--echo --- Start test 3 partition LIST testing ---
+--echo --- Do setup ---
+#################################################
+# Requirment: Create table that is partitioned #
+# by list on id i.e. (2,4). Pretend that we #
+# missed one and alter to add. Then replicate #
+# basice operations such at insert, update #
+# delete between 2 different storage engines #
+# Alter table and ensure table is handled #
+# Correctly on the slave #
+#################################################
+
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY LIST(id)
+ (PARTITION p0 VALUES IN (2, 4),
+ PARTITION p1 VALUES IN (42, 142));
+
+--echo --- Test 3 Alter to add partition ---
+
+ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES IN (412));
+
+--echo --- Show table on master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Show table on slave ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- Check that simple Alter statements are replicated correctly ---
+
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still same engine ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- End test 3 partition LIST testing ---
+--echo --- Do Cleanup --
+
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+--echo --- Start test 4 partition HASH testing ---
+--echo --- Do setup ---
+#################################################
+# Requirment: Create table that is partitioned #
+# by hash on year i.e. YEAR(t). Then replicate #
+# basice operations such at insert, update #
+# delete between 2 different storage engines #
+# Alter table and ensure table is handled #
+# Correctly on the slave #
+#################################################
+
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY HASH( YEAR(t) )
+ PARTITIONS 4;
+
+--echo --- show that tables have been created correctly ---
+
+SHOW CREATE TABLE t1;
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- Check that simple Alter statements are replicated correctly ---
+
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still same engine ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- End test 4 partition HASH testing ---
+--echo --- Do Cleanup --
+
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+--echo --- Start test 5 partition by key testing ---
+--echo --- Create Table Section ---
+
+#################################################
+# Requirment: Create table that is partitioned #
+# by key on id with 4 parts. Then replicate #
+# basice operations such at insert, update #
+# delete between 2 different storage engines #
+# Alter table and ensure table is handled #
+# Correctly on the slave #
+#################################################
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE,PRIMARY KEY(id))
+ PARTITION BY KEY()
+ PARTITIONS 4;
+
+--echo --- Show that tables on master are ndbcluster tables ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Show that tables on slave ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+# Okay lets see how it holds up to table changes
+--echo --- Check that simple Alter statements are replicated correctly ---
+
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(id, total);
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still right type ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- Check that simple Alter statements are replicated correctly ---
+
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- Show the new improved table on the master ---
+
+SHOW CREATE TABLE t1;
+
+--echo --- Make sure that our tables on slave are still same engine ---
+--echo --- and that the alter statements replicated correctly ---
+
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--echo --- Perform basic operation on master ---
+--echo --- and ensure replicated correctly ---
+
+--source include/rpl_multi_engine3.inc
+
+--echo --- End test 5 key partition testing ---
+--echo --- Do Cleanup ---
+
+DROP TABLE IF EXISTS t1;
+
+# End of 5.1 test case
diff --git a/mysql-test/extra/rpl_tests/rpl_row_001.test b/mysql-test/extra/rpl_tests/rpl_row_001.test
index 44638bdac96..9bdfae81093 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_001.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_001.test
@@ -2,7 +2,7 @@
-- source include/have_binlog_format_row.inc
CREATE TABLE t1 (word CHAR(20) NOT NULL);
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word LIMIT 10;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_UUID.test b/mysql-test/extra/rpl_tests/rpl_row_UUID.test
index 2f203eb8963..d1d6178773b 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_UUID.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_UUID.test
@@ -56,8 +56,8 @@ SHOW CREATE TABLE test.t1;
# then LOAD DATA INFILE in slave, and use a query to compare.
# This would have the advantage that it would not assume
# the system has a 'diff'
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/rpl_row_UUID_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/rpl_row_UUID_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_slave.sql
connection master;
# Let's cleanup
@@ -72,7 +72,7 @@ DROP TABLE test.t2;
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-)
---exec diff ./var/tmp/rpl_row_UUID_master.sql ./var/tmp/rpl_row_UUID_slave.sql;
+--exec diff $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_master.sql $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_slave.sql;
# Cleanup dump files.
# Long-term "system rm" is not portable; we could live without
diff --git a/mysql-test/extra/rpl_tests/rpl_row_blob.test b/mysql-test/extra/rpl_tests/rpl_row_blob.test
index 7f41118387f..14449e0a018 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_blob.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_blob.test
@@ -176,10 +176,10 @@ connection master;
--echo
# Post test clean up section
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/rpl_row_blob_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/rpl_row_blob_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_row_blob_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_row_blob_slave.sql
---exec diff ./var/tmp/rpl_row_blob_master.sql ./var/tmp/rpl_row_blob_slave.sql
+--exec diff $MYSQLTEST_VARDIR/tmp/rpl_row_blob_master.sql $MYSQLTEST_VARDIR/tmp/rpl_row_blob_slave.sql
DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_charset.test b/mysql-test/extra/rpl_tests/rpl_row_charset.test
index c2a7cda4333..d0fea6f9580 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_charset.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_charset.test
@@ -162,8 +162,8 @@ select hex(c1), hex(c2) from t1;
connection master;
# Let's have a look at generated SETs.
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-#--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
+--replace_result $MYSQLTEST_VARDIR MYSQL_TEST_DIR/var
+#--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
drop table t1;
sync_slave_with_master;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_func003.test b/mysql-test/extra/rpl_tests/rpl_row_func003.test
index f07c8a65265..153a03da2e7 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_func003.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_func003.test
@@ -77,8 +77,8 @@ SET AUTOCOMMIT=1;
# time to dump the databases and so we can see if they match
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func003_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func003_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
# First lets cleanupi
DROP FUNCTION test.f1;
@@ -88,9 +88,9 @@ DROP TABLE test.t1;
# the test will show that the diff statement failed and no reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files yourself to see what is not matching :-) File are located
-# in mysql-test/var/tmp
+# in $MYSQLTEST_VARDIR/tmp
-exec diff ./var/tmp/func003_master.sql ./var/tmp/func003_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/extra/rpl_tests/rpl_row_sp006.test b/mysql-test/extra/rpl_tests/rpl_row_sp006.test
index 272a7caf9ac..f40b3cbb078 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_sp006.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_sp006.test
@@ -68,8 +68,8 @@ sync_slave_with_master;
connection master;
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > ./var/tmp/sp006_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > ./var/tmp/sp006_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/sp006_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/sp006_slave.sql
DROP PROCEDURE IF EXISTS mysqltest1.p1;
@@ -81,9 +81,9 @@ DROP TABLE IF EXISTS mysqltest1.t2;
# the test will show that the diff statement failed and not reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-) Failed test
-# Dump files will be located in mysql-test/var/tmp.
+# Dump files will be located in $MYSQLTEST_VARDIR/tmp.
-exec diff ./var/tmp/sp006_master.sql ./var/tmp/sp006_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/sp006_master.sql $MYSQLTEST_VARDIR/tmp/sp006_slave.sql;
sync_slave_with_master;
diff --git a/mysql-test/include/drop-on-restart.inc b/mysql-test/include/drop-on-restart.inc
index 841b636483a..af1d0d893e0 100644
--- a/mysql-test/include/drop-on-restart.inc
+++ b/mysql-test/include/drop-on-restart.inc
@@ -23,6 +23,7 @@ drop database if exists db1_secret;
drop database if exists db2;
drop database if exists federated;
drop database if exists mysqldump_test_db;
+drop database if exists mysqlslap;
drop database if exists mysqltest1;
drop database if exists mysqltest2;
drop database if exists mysqltest3;
@@ -34,6 +35,7 @@ drop database if exists mysqltest_bob;
drop database if exists mysqltest_db1;
drop database if exists mysqltest_prometheus;
drop database if exists mysqltest_sisyfos;
+drop database if exists ndbsynctest;
drop database if exists ndbtest1;
drop database if exists rewrite;
drop database if exists test2;
@@ -429,6 +431,7 @@ drop table if exists new_t2;
drop table if exists not_exist;
drop table if exists r1;
drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t21,t70;
+drop table if exists t00,t03,t04;
drop table if exists t0_template;
drop table if exists t1Aa,t2Aa,v1Aa,v2Aa;
drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;
diff --git a/mysql-test/include/gis_generic.inc b/mysql-test/include/gis_generic.inc
index e5e7283e0e6..3abc18283fa 100644
--- a/mysql-test/include/gis_generic.inc
+++ b/mysql-test/include/gis_generic.inc
@@ -8,14 +8,14 @@
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
--enable_warnings
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
SHOW FIELDS FROM gis_point;
@@ -141,6 +141,7 @@ DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gi
# Check that ALTER TABLE doesn't loose geometry type
#
CREATE TABLE t1 (
+ a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -156,24 +157,24 @@ ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
DROP TABLE t1;
-create table t1 (a geometry not null);
-insert into t1 values (GeomFromText('Point(1 2)'));
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
-- error 1416
-insert into t1 values ('Garbage');
+insert into t1 (a) values ('Garbage');
-- error 1416
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
drop table t1;
-create table t1 (fl geometry);
+create table t1 (pk integer primary key auto_increment, fl geometry);
--error 1416
-insert into t1 values (1);
+insert into t1 (fl) values (1);
--error 1416
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
--error 1416
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
--error 1416
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
drop table t1;
diff --git a/mysql-test/include/ndb_backup.inc b/mysql-test/include/ndb_backup.inc
index 2163b479ed6..f0a883d4e11 100644
--- a/mysql-test/include/ndb_backup.inc
+++ b/mysql-test/include/ndb_backup.inc
@@ -6,13 +6,13 @@
# there is no neat way to find the backupid, this is a hack to find it...
---exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > var/tmp.dat
+--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
DELETE FROM test.backup_info;
-LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
--replace_column 1 <the_backup_id>
diff --git a/mysql-test/include/partition_1.inc b/mysql-test/include/partition_1.inc
index 9b829494a73..b0094db2efe 100644
--- a/mysql-test/include/partition_1.inc
+++ b/mysql-test/include/partition_1.inc
@@ -36,7 +36,7 @@ let $fixed_bug16370= 0;
##### Option, for displaying files #####
#
-# Attention: Displaying the directory content via "ls var/master-data/test/t*"
+# Attention: Displaying the directory content via "ls $MYSQLTEST_VARDIR/master-data/test/t*"
# is probably not portable.
# let $ls= 0; disables the execution of "ls ....."
let $ls= 0;
diff --git a/mysql-test/include/partition_layout.inc b/mysql-test/include/partition_layout.inc
index 0a59c23fafd..95f6cac37d7 100644
--- a/mysql-test/include/partition_layout.inc
+++ b/mysql-test/include/partition_layout.inc
@@ -9,5 +9,5 @@ eval SHOW CREATE TABLE t1;
# listing of files belonging to the table t1
if ($ls)
{
- --exec ls var/master-data/test/t1*
+ --exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
}
diff --git a/mysql-test/include/rpl_multi_engine3.inc b/mysql-test/include/rpl_multi_engine3.inc
new file mode 100644
index 00000000000..be89c1907f3
--- /dev/null
+++ b/mysql-test/include/rpl_multi_engine3.inc
@@ -0,0 +1,62 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-23
+# Purpose: To reuse through out test and make maint easier
+#############################################################
+connection master;
+--echo "--- Insert into t1 --" as "";
+
+--disable_query_log
+INSERT INTO t1 VALUES(42,1,'Testing MySQL databases is a cool ',
+ 'Must make it bug free for the customer',
+ 654321.4321,15.21,0,1965,"1905-11-14");
+INSERT INTO t1 VALUES(2,1,'Testing MySQL databases is a cool ',
+ 'Must make it bug free for the customer',
+ 654321.4321,15.21,0,1965,"1965-11-14");
+INSERT INTO t1 VALUES(4,1,'Testing MySQL databases is a cool ',
+ 'Must make it bug free for the customer',
+ 654321.4321,15.21,0,1965,"1985-11-14");
+INSERT INTO t1 VALUES(142,1,'Testing MySQL databases is a cool ',
+ 'Must make it bug free for the customer',
+ 654321.4321,15.21,0,1965,"1995-11-14");
+INSERT INTO t1 VALUES(412,1,'Testing MySQL databases is a cool ',
+ 'Must make it bug free for the customer',
+ 654321.4321,15.21,0,1965,"2005-11-14");
+--enable_query_log
+
+--echo --- Select from t1 on master ---
+select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
+
+sync_slave_with_master;
+--echo --- Select from t1 on slave ---
+select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
+
+connection master;
+
+--echo --- Update t1 on master --
+UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412;
+
+--echo --- Check the update on master ---
+SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412;
+
+# Must give injector thread a little time to get update
+# into the binlog other wise we will miss the update.
+sleep 3;
+
+sync_slave_with_master;
+--echo --- Check Update on slave ---
+SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412;
+
+connection master;
+--echo --- Remove a record from t1 on master ---
+DELETE FROM t1 WHERE id = 42;
+
+--echo --- Show current count on master for t1 ---
+SELECT COUNT(*) FROM t1;
+
+sync_slave_with_master;
+--echo --- Show current count on slave for t1 ---
+SELECT COUNT(*) FROM t1;
+
+connection master;
+DELETE FROM t1;
diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql
index 8eb1712d489..79a7c528370 100644
--- a/mysql-test/lib/init_db.sql
+++ b/mysql-test/lib/init_db.sql
@@ -634,5 +634,5 @@ CREATE TABLE event (
PRIMARY KEY (definer, db, name)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
-CREATE DATABASE IF NOT EXISTS cluster_replication;
-CREATE TABLE IF NOT EXISTS cluster_replication.binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
+CREATE DATABASE IF NOT EXISTS cluster;
+CREATE TABLE IF NOT EXISTS cluster.binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 55097a7deeb..acb794bce3b 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -162,6 +162,7 @@ our $path_slave_load_tmpdir; # What is this?!
our $path_mysqltest_log;
our $path_my_basedir;
our $opt_vardir; # A path but set directly on cmd line
+our $opt_vardir_trace; # unix formatted opt_vardir for trace files
our $opt_tmpdir; # A path but set directly on cmd line
our $opt_restart_cleanup; # Source a file with SQL drop statements
@@ -197,6 +198,7 @@ our $opt_big_test= 0; # Send --big-test to mysqltest
our @opt_extra_mysqld_opt;
+our $opt_comment;
our $opt_compress;
our $opt_ssl;
our $opt_skip_ssl;
@@ -668,6 +670,14 @@ sub command_line_setup () {
print '#' x 78, "\n\n";
}
+ if ( $opt_comment )
+ {
+ print "\n";
+ print '#' x 78, "\n";
+ print "# $opt_comment\n";
+ print '#' x 78, "\n\n";
+ }
+
foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
@@ -692,7 +702,7 @@ sub command_line_setup () {
{
$opt_vardir= "$glob_mysql_test_dir/var";
}
-
+ $opt_vardir_trace= $opt_vardir;
# We make the path absolute, as the server will do a chdir() before usage
unless ( $opt_vardir =~ m,^/, or
($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
@@ -981,16 +991,26 @@ sub executable_setup () {
if ( $glob_win32 )
{
$path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
- "$glob_basedir/bin");
- $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-max",
- "$path_client_bindir/mysqld-nt",
+ "$glob_basedir/client_debug",
+ "$glob_basedir/bin",
+ # New CMake locations.
+ "$glob_basedir/client/release",
+ "$glob_basedir/client/debug");
+ $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld",
- "$path_client_bindir/mysqld-debug",);
- $path_language= mtr_path_exists("$glob_basedir/share/english/");
- $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
+ "$path_client_bindir/mysqld-debug",
+ "$path_client_bindir/mysqld-max",
+ "$glob_basedir/sql/release/mysqld",
+ "$glob_basedir/sql/debug/mysqld");
+ $path_language= mtr_path_exists("$glob_basedir/share/english/",
+ "$glob_basedir/sql/share/english/");
+ $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets",
+ "$glob_basedir/sql/share/charsets");
$exe_my_print_defaults=
- mtr_exe_exists("$path_client_bindir/my_print_defaults");
+ mtr_exe_exists("$path_client_bindir/my_print_defaults",
+ "$glob_basedir/extra/release/my_print_defaults",
+ "$glob_basedir/extra/debug/my_print_defaults");
}
else
{
@@ -1031,6 +1051,7 @@ sub executable_setup () {
}
$exe_mysql_client_test=
mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
+ "$path_client_bindir/mysql_client_test",
"/usr/bin/false");
}
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
@@ -1143,9 +1164,8 @@ sub environment_setup () {
$ENV{'LC_COLLATE'}= "C";
$ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server;
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
- $ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir;
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
- $ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'};
+ $ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'};
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'};
$ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'};
@@ -1169,16 +1189,6 @@ sub environment_setup () {
$ENV{'IM_MYSQLD2_PORT'}= $instance_manager->{instances}->[1]->{port};
$ENV{'IM_MYSQLD2_PATH_PID'}=$instance_manager->{instances}->[1]->{path_pid};
- if ( $glob_cygwin_perl )
- {
- foreach my $key ('MYSQL_TEST_WINDIR','MASTER_MYSOCK')
- {
- $ENV{$key}= `cygpath -w $ENV{$key}`;
- $ENV{$key} =~ s,\\,\\\\,g;
- chomp($ENV{$key});
- }
- }
-
$ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set
# We are nice and report a bit about our settings
@@ -1507,8 +1517,8 @@ sub ndbcluster_start ($) {
sub rm_ndbcluster_tables ($) {
my $dir= shift;
- foreach my $bin ( glob("$dir/cluster_replication/apply_status*"),
- glob("$dir/cluster_replication/schema*") )
+ foreach my $bin ( glob("$dir/cluster/apply_status*"),
+ glob("$dir/cluster/schema*") )
{
unlink($bin);
}
@@ -2490,12 +2500,12 @@ sub mysqld_arguments ($$$$$$) {
if ( $type eq 'master' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace",
- $prefix, $opt_vardir, $sidx);
+ $prefix, $opt_vardir_trace, $sidx);
}
if ( $type eq 'slave' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace",
- $prefix, $opt_vardir, $sidx);
+ $prefix, $opt_vardir_trace, $sidx);
}
}
@@ -2876,7 +2886,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlcheck .=
- " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqlcheck.trace";
}
my $cmdline_mysqldump= "$exe_mysqldump --no-defaults -uroot " .
@@ -2889,7 +2899,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqldump .=
- " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqldump.trace";
}
my $cmdline_mysqlslap;
@@ -2903,7 +2913,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlslap .=
- " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqlslap.trace";
}
}
@@ -2913,7 +2923,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlimport .=
- " --debug=d:t:A,$opt_vardir/log/mysqlimport.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqlimport.trace";
}
my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " .
@@ -2922,7 +2932,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlshow .=
- " --debug=d:t:A,$opt_vardir/log/mysqlshow.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqlshow.trace";
}
my $cmdline_mysqlbinlog=
@@ -2933,7 +2943,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
$cmdline_mysqlbinlog .=
- " --debug=d:t:A,$opt_vardir/log/mysqlbinlog.trace";
+ " --debug=d:t:A,$opt_vardir_trace/log/mysqlbinlog.trace";
}
my $cmdline_mysql=
@@ -3075,7 +3085,7 @@ sub run_mysqltest ($) {
if ( $opt_debug )
{
- mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir);
+ mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir_trace);
}
if ( $opt_ssl_supported )
@@ -3255,6 +3265,7 @@ Options for coverage, profiling etc
Misc options
+ comment=STR Write STR to the output
verbose Verbose output from this script
script-debug Debug this script itself
timer Show test case execution time
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 212f0b9beb4..41a9a206306 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -19,6 +19,8 @@ TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work
LOCAL_SOCKET=@MYSQL_UNIX_ADDR@
MYSQL_TCP_PORT=@MYSQL_TCP_PORT@
+umask 022
+
# For query_cache test
case `uname` in
SCO_SV | UnixWare | OpenUNIX )
@@ -202,6 +204,7 @@ SYST=0
REALT=0
FAST_START=""
MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
+export MYSQL_TMP_DIR
# Use a relative path for where the slave will find the dumps
# generated by "LOAD DATA" on the master. The path is relative
@@ -217,8 +220,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log"
#
# Set LD_LIBRARY_PATH if we are using shared libraries
#
-LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"
-DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"
+LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/libmysql_r/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"
+DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/libmysql_r/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"
export LD_LIBRARY_PATH DYLD_LIBRARY_PATH
#
@@ -600,7 +603,14 @@ while test $# -gt 0; do
FAST_START=1
;;
--use-old-data)
- USE_OLD_DATA=1;
+ USE_OLD_DATA=1
+ ;;
+ --comment=*)
+ TMP=`$ECHO "$1" | $SED -e "s;--comment=;;"`
+ echo
+ echo '############################################'
+ echo "# $TMP"
+ echo '############################################'
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
@@ -961,7 +971,7 @@ show_failed_diff ()
$DIFF -c $result_file $reject_file
echo "-------------------------------------------------------"
echo "Please follow the instructions outlined at"
- echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html"
+ echo "http://dev.mysql.com/doc/mysql/en/reporting-mysqltest-bugs.html"
echo "to find the reason to this problem and how to report this."
echo ""
fi
@@ -1061,7 +1071,7 @@ report_stats () {
$ECHO "The log files in $MY_LOG_DIR may give you some hint"
$ECHO "of what went wrong."
$ECHO "If you want to report this error, please read first the documentation at"
- $ECHO "http://www.mysql.com/doc/en/MySQL_test_suite.html"
+ $ECHO "http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html"
fi
if [ $USE_RUNNING_SERVER -eq 0 ]
@@ -1325,8 +1335,8 @@ start_ndbcluster()
rm_ndbcluster_tables()
{
- $RM -f $1/cluster_replication/apply_status*
- $RM -f $1/cluster_replication/schema*
+ $RM -f $1/cluster/apply_status*
+ $RM -f $1/cluster/schema*
}
stop_ndbcluster()
diff --git a/mysql-test/ndb/Makefile.am b/mysql-test/ndb/Makefile.am
index 1ef02bec1f0..2a1c59fd359 100644
--- a/mysql-test/ndb/Makefile.am
+++ b/mysql-test/ndb/Makefile.am
@@ -1,4 +1,6 @@
+BUILT_SOURCES = ndbcluster
+
benchdir_root= $(prefix)
testdir = $(benchdir_root)/mysql-test/ndb
diff --git a/mysql-test/r/archive_gis.result b/mysql-test/r/archive_gis.result
index 20e427b91a9..3017a811fb0 100644
--- a/mysql-test/r/archive_gis.result
+++ b/mysql-test/r/archive_gis.result
@@ -1,50 +1,51 @@
SET storage_engine=archive;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
- `fid` int(11) DEFAULT NULL,
- `g` point DEFAULT NULL
+ `fid` int(11) NOT NULL AUTO_INCREMENT,
+ `g` point DEFAULT NULL,
+ PRIMARY KEY (`fid`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
@@ -407,6 +408,7 @@ Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
+a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -418,6 +420,7 @@ gm geometry
);
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -429,6 +432,7 @@ gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -439,20 +443,20 @@ gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
-create table t1 (a geometry not null);
-insert into t1 values (GeomFromText('Point(1 2)'));
-insert into t1 values ('Garbage');
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
+insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-create table t1 (fl geometry);
-insert into t1 values (1);
+create table t1 (pk integer primary key auto_increment, fl geometry);
+insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result
index 1207b6b7070..81090c17791 100644
--- a/mysql-test/r/backup.result
+++ b/mysql-test/r/backup.result
@@ -6,26 +6,26 @@ Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup status Operation failed
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
backup table t4 to '../tmp';
Table Op Msg_type Msg_text
test.t4 backup status OK
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
backup table t4 to '../tmp';
Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup status Operation failed
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
drop table t4;
restore table t4 from '../tmp';
Table Op Msg_type Msg_text
test.t4 restore status OK
Warnings:
-Warning 1540 The 'RESTORE TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
select count(*) from t4;
count(*)
0
@@ -35,19 +35,19 @@ backup table t1 to '../tmp';
Table Op Msg_type Msg_text
test.t1 backup status OK
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
drop table t1;
restore table t1 from '../bogus';
Table Op Msg_type Msg_text
t1 restore error Failed copying .frm file
Warnings:
-Warning 1540 The 'RESTORE TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X)
restore table t1 from '../tmp';
Table Op Msg_type Msg_text
test.t1 restore status OK
Warnings:
-Warning 1540 The 'RESTORE TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
select n from t1;
n
23
@@ -62,7 +62,7 @@ Table Op Msg_type Msg_text
test.t2 backup status OK
test.t3 backup status OK
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
drop table t1,t2,t3;
restore table t1,t2,t3 from '../tmp';
Table Op Msg_type Msg_text
@@ -70,7 +70,7 @@ test.t1 restore status OK
test.t2 restore status OK
test.t3 restore status OK
Warnings:
-Warning 1540 The 'RESTORE TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
select n from t1;
n
23
@@ -91,7 +91,7 @@ restore table t1 from '../tmp';
Table Op Msg_type Msg_text
test.t1 restore status OK
Warnings:
-Warning 1540 The 'RESTORE TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
rename table t1 to t5;
lock tables t5 write;
backup table t5 to '../tmp';
@@ -99,5 +99,5 @@ unlock tables;
Table Op Msg_type Msg_text
test.t5 backup status OK
Warnings:
-Warning 1540 The 'BACKUP TABLE' statement is deprecated and will be removed in MySQL 5.2. Please use client programs (e.g. mysqldump, mysql, MySQL Administrator) instead.
+Warning 1540 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
drop table t5;
diff --git a/mysql-test/r/bdb_gis.result b/mysql-test/r/bdb_gis.result
index 0dadceed04e..969cdb34788 100644
--- a/mysql-test/r/bdb_gis.result
+++ b/mysql-test/r/bdb_gis.result
@@ -1,50 +1,51 @@
SET storage_engine=bdb;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
- `fid` int(11) DEFAULT NULL,
- `g` point DEFAULT NULL
+ `fid` int(11) NOT NULL AUTO_INCREMENT
+ `g` point DEFAULT NULL,
+ PRIMARY KEY (`fid`)
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
@@ -407,6 +408,7 @@ Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
+a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -418,6 +420,7 @@ gm geometry
);
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -429,6 +432,7 @@ gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -439,20 +443,20 @@ gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
-create table t1 (a geometry not null);
-insert into t1 values (GeomFromText('Point(1 2)'));
-insert into t1 values ('Garbage');
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
+insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-create table t1 (fl geometry);
-insert into t1 values (1);
+create table t1 (pk integer primary key auto_increment, fl geometry);
+insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 039dc0980ce..c76385fa334 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -332,3 +332,12 @@ SELECT * FROM t1;
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 col24 col25 col26 col27 col28 col29 col30 col31 col32 col33 col34 col35 col36 col37 col38 fix1 fix2 fix3 fix4 fix5 fix6 fix7 fix8 fix9 fix10 fix11 fix12 fix13 fix14 fix15 fix16 fix17 fix18 fix19 fix20 fix21 fix22 fix23 fix24 fix25 fix26 fix27 fix28 fix29 fix30
9 99 999 9999 99999 999999 9999999 99999999 999999999 9999999999 99999999999 999999999999 9999999999999 99999999999999 999999999999999 9999999999999999 99999999999999999 999999999999999999 9999999999999999999 99999999999999999999 999999999999999999999 9999999999999999999999 99999999999999999999999 999999999999999999999999 9999999999999999999999999 99999999999999999999999999 999999999999999999999999999 9999999999999999999999999999 99999999999999999999999999999 999999999999999999999999999999 9999999999999999999999999999999 99999999999999999999999999999999 999999999999999999999999999999999 9999999999999999999999999999999999 99999999999999999999999999999999999 999999999999999999999999999999999999 9999999999999999999999999999999999999 99999999999999999999999999999999999999 9999999999999999999999999999999999999.9 999999999999999999999999999999999999.99 99999999999999999999999999999999999.999 9999999999999999999999999999999999.9999 999999999999999999999999999999999.99999 99999999999999999999999999999999.999999 9999999999999999999999999999999.9999999 999999999999999999999999999999.99999999 99999999999999999999999999999.999999999 9999999999999999999999999999.9999999999 999999999999999999999999999.99999999999 99999999999999999999999999.999999999999 9999999999999999999999999.9999999999999 999999999999999999999999.99999999999999 99999999999999999999999.999999999999999 9999999999999999999999.9999999999999999 999999999999999999999.99999999999999999 99999999999999999999.999999999999999999 9999999999999999999.9999999999999999999 999999999999999999.99999999999999999999 99999999999999999.999999999999999999999 9999999999999999.9999999999999999999999 999999999999999.99999999999999999999999 99999999999999.999999999999999999999999 9999999999999.9999999999999999999999999 999999999999.99999999999999999999999999 99999999999.999999999999999999999999999 9999999999.9999999999999999999999999999 999999999.99999999999999999999999999999 99999999.999999999999999999999999999999
DROP TABLE t1;
+create table t1 (bigint_col bigint unsigned);
+insert into t1 values (17666000000000000000);
+select * from t1 where bigint_col=17666000000000000000;
+bigint_col
+17666000000000000000
+select * from t1 where bigint_col='17666000000000000000';
+bigint_col
+17666000000000000000
+drop table t1;
diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result
index 99d9c4dad02..ccafa43c7ab 100644
--- a/mysql-test/r/binary.result
+++ b/mysql-test/r/binary.result
@@ -141,3 +141,22 @@ t1 CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+create table t1 (col1 binary(4));
+insert into t1 values ('a'),('a ');
+select hex(col1) from t1;
+hex(col1)
+61000000
+61200000
+alter table t1 modify col1 binary(10);
+select hex(col1) from t1;
+hex(col1)
+61000000000000000000
+61200000000000000000
+insert into t1 values ('b'),('b ');
+select hex(col1) from t1;
+hex(col1)
+61000000000000000000
+61200000000000000000
+62000000000000000000
+62200000000000000000
+drop table t1;
diff --git a/mysql-test/r/binlog_row_ctype_cp932.result b/mysql-test/r/binlog_row_ctype_cp932.result
index 6d213158ef6..ed57b87c1ba 100644
--- a/mysql-test/r/binlog_row_ctype_cp932.result
+++ b/mysql-test/r/binlog_row_ctype_cp932.result
@@ -11315,20 +11315,6 @@ DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 102;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 102 Query 1 189 use `test`; CREATE TABLE t1(f1 blob)
-master-bin.000001 189 Table_map 1 228 test.t1
-master-bin.000001 228 Write_rows 1 262
-SELECT HEX(f1) FROM t1;
-HEX(f1)
-8300
-DROP table t1;
SET collation_connection='cp932_japanese_ci';
create table t1 select repeat('a',4000) a;
delete from t1;
diff --git a/mysql-test/r/binlog_row_insert_select.result b/mysql-test/r/binlog_row_insert_select.result
index 90a8a5473e9..0a98a6d7233 100644
--- a/mysql-test/r/binlog_row_insert_select.result
+++ b/mysql-test/r/binlog_row_insert_select.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2;
create table t1(a int, unique(a));
insert into t1 values(2);
create table t2(a int);
diff --git a/mysql-test/r/binlog_stm_ctype_cp932.result b/mysql-test/r/binlog_stm_ctype_cp932.result
index 470ae3b5ab2..ed57b87c1ba 100755
--- a/mysql-test/r/binlog_stm_ctype_cp932.result
+++ b/mysql-test/r/binlog_stm_ctype_cp932.result
@@ -11315,20 +11315,6 @@ DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 102;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 102 Query 1 189 use `test`; CREATE TABLE t1(f1 blob)
-master-bin.000001 189 User var 1 228 @`var1`=_binary 0x8300 COLLATE binary
-master-bin.000001 228 Query 1 321 use `test`; INSERT INTO t1 VALUES(@'var1')
-SELECT HEX(f1) FROM t1;
-HEX(f1)
-8300
-DROP table t1;
SET collation_connection='cp932_japanese_ci';
create table t1 select repeat('a',4000) a;
delete from t1;
diff --git a/mysql-test/r/binlog_stm_insert_select.result b/mysql-test/r/binlog_stm_insert_select.result
index 35e328a769c..646a76b254d 100644
--- a/mysql-test/r/binlog_stm_insert_select.result
+++ b/mysql-test/r/binlog_stm_insert_select.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2;
create table t1(a int, unique(a));
insert into t1 values(2);
create table t2(a int);
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result
index 415ec1ac748..d28c3af4e0b 100644
--- a/mysql-test/r/case.result
+++ b/mysql-test/r/case.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t2;
select CASE "b" when "a" then 1 when "b" then 2 END;
CASE "b" when "a" then 1 when "b" then 2 END
2
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index acee1eb87c8..edc0ec0d01e 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -770,3 +770,9 @@ t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
drop table t1;
+create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
+character set utf8 collate utf8_general_ci;
+Warnings:
+Warning 1071 Specified key was too long; max key length is 765 bytes
+insert into t1 values('aaa');
+drop table t1;
diff --git a/mysql-test/r/ctype_cp932_notembedded.result b/mysql-test/r/ctype_cp932_notembedded.result
deleted file mode 100644
index 913e8125619..00000000000
--- a/mysql-test/r/ctype_cp932_notembedded.result
+++ /dev/null
@@ -1,17 +0,0 @@
-drop table if exists t1;
-set names cp932;
-set character_set_database = cp932;
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 102;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob)
-master-bin.000001 # Table_map 1 # test.t1
-master-bin.000001 # Write_rows 1 #
-SELECT HEX(f1) FROM t1;
-HEX(f1)
-8300
-DROP table t1;
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result
index 02342485c04..fb8c4fb9b37 100644
--- a/mysql-test/r/drop.result
+++ b/mysql-test/r/drop.result
@@ -47,7 +47,7 @@ create database mysqltest;
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest
test
@@ -59,7 +59,7 @@ drop database mysqltest;
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
test
drop database mysqltest;
diff --git a/mysql-test/r/events.result b/mysql-test/r/events.result
index f7aa6e2bb58..ecaf1ec252e 100644
--- a/mysql-test/r/events.result
+++ b/mysql-test/r/events.result
@@ -37,6 +37,54 @@ alter event event3 rename to event2;
drop event event2;
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
drop event event2;
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost RECURRING NULL 10 SECOND # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+0 1
+ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+1 1
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+1 1 non-empty comment
+ALTER EVENT event_starts_test COMMENT "";
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+1 1
+DROP EVENT event_starts_test;
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+0 0
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+starts IS NULL ends IS NULL comment
+0 0 non-empty comment
+ALTER EVENT event_starts_test COMMENT "";
+SHOW EVENTS;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
+DROP EVENT event_starts_test;
create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1;
alter event e_43 do alter event e_43 do set @a = 4;
diff --git a/mysql-test/r/events_logs_tests.result b/mysql-test/r/events_logs_tests.result
new file mode 100644
index 00000000000..e6ca3c29e9b
--- /dev/null
+++ b/mysql-test/r/events_logs_tests.result
@@ -0,0 +1,84 @@
+create database if not exists events_test;
+use events_test;
+"We use procedure here because its statements won't be logged into the general log"
+"If we had used normal select that are logged in different ways depending on whether"
+"the test suite is run in normal mode or with --ps-protocol"
+CREATE procedure select_general_log()
+BEGIN
+SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
+END|
+"Check General Query Log"
+SET GLOBAL event_scheduler=0;
+create event log_general on schedule every 1 minute do SELect 'alabala', sleep(3) from dual;
+TRUNCATE mysql.general_log;
+"1 row, the current statement!"
+call select_general_log();
+user_host argument
+SET GLOBAL event_scheduler=1;
+"Wait the scheduler to start"
+"Should see 3 rows - the 'SELect' is in the middle. The other two are selects from general_log"
+call select_general_log();
+user_host argument
+root[root] @ localhost [localhost] SELect 'alabala', sleep(3) from dual
+DROP PROCEDURE select_general_log;
+DROP EVENT log_general;
+SET GLOBAL event_scheduler=0;
+"Check slow query log"
+"Save the values"
+SET @old_global_long_query_time:=(select get_value());
+SET @old_session_long_query_time:=@@long_query_time;
+SHOW VARIABLES LIKE 'log_slow_queries';
+Variable_name Value
+log_slow_queries ON
+DROP FUNCTION get_value;
+TRUNCATE mysql.slow_log;
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+user_host query_time db sql_text
+"Set new values"
+SET GLOBAL long_query_time=4;
+SET SESSION long_query_time=2;
+"Check that logging is working"
+SELECT SLEEP(3);
+SLEEP(3)
+0
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+user_host query_time db sql_text
+root[root] @ localhost [] 00:00:03 events_test SELECT SLEEP(3)
+TRUNCATE mysql.slow_log;
+CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
+"This won't go to the slow log"
+CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
+SELECT * FROM slow_event_test;
+slo_val val
+SET GLOBAL event_scheduler=1;
+"Sleep some more time than the actual event run will take"
+SHOW VARIABLES LIKE 'event_scheduler';
+Variable_name Value
+event_scheduler ON
+"Check our table. Should see 1 row"
+SELECT * FROM slow_event_test;
+slo_val val
+4 0
+"Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+user_host query_time db sql_text
+"This should go to the slow log"
+SET SESSION long_query_time=10;
+DROP EVENT long_event;
+CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5);
+"Sleep some more time than the actual event run will take"
+"Check our table. Should see 2 rows"
+SELECT * FROM slow_event_test;
+slo_val val
+4 0
+4 0
+"Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10"
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+user_host query_time db sql_text
+root[root] @ localhost [localhost] 00:00:05 events_test INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5)
+DROP EVENT long_event2;
+SET GLOBAL long_query_time =@old_global_long_query_time;
+SET SESSION long_query_time =@old_session_long_query_time;
+TRUNCATE mysql.slow_log;
+DROP TABLE slow_event_test;
+drop database events_test;
diff --git a/mysql-test/r/events_microsec.result b/mysql-test/r/events_microsec.result
new file mode 100644
index 00000000000..ed15b066b93
--- /dev/null
+++ b/mysql-test/r/events_microsec.result
@@ -0,0 +1,59 @@
+create database if not exists events_test;
+use events_test;
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+"Now create normal event and change it on SQL level"
+CREATE EVENT micro_test2 ON SCHEDULE EVERY 1 MONTH DO SELECT 1;
+UPDATE mysql.event SET interval_field='MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+SHOW CREATE EVENT micro_test2;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+SET GLOBAL event_scheduler=0;
+"Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+Variable_name Value
+event_scheduler OFF
+UPDATE mysql.event SET interval_field='DAY_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+SHOW CREATE EVENT micro_test2;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+SET GLOBAL event_scheduler=0;
+"Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+Variable_name Value
+event_scheduler OFF
+UPDATE mysql.event SET interval_field='SECOND_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+SHOW CREATE EVENT micro_test2;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+SET GLOBAL event_scheduler=0;
+"Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+Variable_name Value
+event_scheduler OFF
+UPDATE mysql.event SET interval_field='HOUR_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+SHOW CREATE EVENT micro_test2;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+SET GLOBAL event_scheduler=0;
+"Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+Variable_name Value
+event_scheduler OFF
+UPDATE mysql.event SET interval_field='MINUTE_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+SHOW CREATE EVENT micro_test2;
+ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
+SET GLOBAL event_scheduler=0;
+"Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+Variable_name Value
+event_scheduler OFF
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='event_scheduler';
+COUNT(*)
+0
+DROP EVENT micro_test2;
+drop database events_test;
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index 9871de0f27c..e186afdfafa 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -42,13 +42,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sql_no_cache database() AS `database()`,user() AS `user()`
-create table t1 (version char(40)) select database(), user(), version() as 'version';
+create table t1 (version char(60)) select database(), user(), version() as 'version';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`database()` varchar(34) CHARACTER SET utf8 DEFAULT NULL,
`user()` varchar(77) CHARACTER SET utf8 NOT NULL DEFAULT '',
- `version` char(40) DEFAULT NULL
+ `version` char(60) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 45ab83a0cfc..661b7141a59 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -448,7 +448,7 @@ Create view Tables To create new views
Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
-Event Server Admin Creation, alteration, deletion and execution of events.
+Event Server Admin To create, alter, drop and execute events
Execute Functions,Procedures To execute stored routines
File File access on server To read and write files on the server
Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index e38953b6446..6c6e0f19e08 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -334,3 +334,24 @@ lock table mysql.user write;
revoke all on *.* from 'mysqltest_1'@'localhost';
unlock tables;
drop user 'mysqltest_1'@'localhost';
+create database TESTDB;
+create table t2(a int);
+create temporary table t1 as select * from mysql.user;
+delete from mysql.user where host='localhost';
+INSERT INTO mysql.user (host, user, password) VALUES
+('%','mysqltest_1',password('password'));
+Warnings:
+Warning 1364 Field 'ssl_cipher' doesn't have a default value
+Warning 1364 Field 'x509_issuer' doesn't have a default value
+Warning 1364 Field 'x509_subject' doesn't have a default value
+INSERT INTO mysql.db (host, db, user, select_priv) VALUES
+('%','TESTDB','mysqltest_1','Y');
+FLUSH PRIVILEGES;
+create database TEStdb;
+Got one of the listed errors
+delete from mysql.user;
+delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
+insert into mysql.user select * from t1;
+drop table t1, t2;
+drop database TESTDB;
+flush privileges;
diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result
index db87253e19a..3a69f56cbd3 100644
--- a/mysql-test/r/index_merge.result
+++ b/mysql-test/r/index_merge.result
@@ -402,3 +402,25 @@ explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'b
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 24 Using intersect(cola,colb); Using where
drop table t1;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+a int, b int,
+filler1 char(200), filler2 char(200),
+key(a),key(b)
+);
+insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C;
+create table t2 like t1;
+create table t3 (
+a int, b int,
+filler1 char(200), filler2 char(200),
+key(a),key(b)
+) engine=merge union=(t1,t2);
+explain select * from t1 where a=1 and b=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where
+explain select * from t3 where a=1 and b=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where
+drop table t3;
+drop table t0, t1, t2;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 02718b89619..457235e7003 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -14,7 +14,7 @@ NULL test latin1 latin1_swedish_ci NULL
select schema_name from information_schema.schemata;
schema_name
information_schema
-cluster_replication
+cluster
mysql
test
show databases like 't%';
@@ -23,7 +23,7 @@ test
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
test
show databases where `database` = 't%';
@@ -339,7 +339,7 @@ create view v0 (c) as select schema_name from information_schema.schemata;
select * from v0;
c
information_schema
-cluster_replication
+cluster
mysql
test
explain select * from v0;
@@ -835,7 +835,7 @@ delete from mysql.db where user='mysqltest_4';
flush privileges;
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
-cluster_replication 1
+cluster 1
information_schema 22
mysql 21
create table t1 (i int, j int);
diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result
index 849c67019ad..0222c462923 100644
--- a/mysql-test/r/innodb_gis.result
+++ b/mysql-test/r/innodb_gis.result
@@ -1,50 +1,51 @@
SET storage_engine=innodb;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
- `fid` int(11) DEFAULT NULL,
- `g` point DEFAULT NULL
+ `fid` int(11) NOT NULL AUTO_INCREMENT,
+ `g` point DEFAULT NULL,
+ PRIMARY KEY (`fid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
@@ -407,6 +408,7 @@ Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
+a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -418,6 +420,7 @@ gm geometry
);
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -429,6 +432,7 @@ gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -439,20 +443,20 @@ gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
-create table t1 (a geometry not null);
-insert into t1 values (GeomFromText('Point(1 2)'));
-insert into t1 values ('Garbage');
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
+insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-create table t1 (fl geometry);
-insert into t1 values (1);
+create table t1 (pk integer primary key auto_increment, fl geometry);
+insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
diff --git a/mysql-test/r/innodb_notembedded.result b/mysql-test/r/innodb_notembedded.result
index fc71468b97b..9aac20e515d 100644
--- a/mysql-test/r/innodb_notembedded.result
+++ b/mysql-test/r/innodb_notembedded.result
@@ -1,3 +1,4 @@
+drop table if exists t1;
create table t1 (col1 integer primary key, col2 integer) engine=innodb;
insert t1 values (1,100);
create function f1 () returns integer begin
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 724d1b1e39f..54536d6c32a 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -677,6 +677,11 @@ select t1.b from v1a;
ERROR 42S22: Unknown column 't1.b' in 'field list'
select * from v1a join v1b on t1.b = t2.b;
ERROR 42S22: Unknown column 't1.b' in 'on clause'
+select * from information_schema.statistics join information_schema.columns
+using(table_name,column_name) where table_name='user';
+TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 20 60 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+user User NULL mysql 0 mysql PRIMARY 2 A 5 NULL NULL BTREE NULL mysql 2 NO char 5 16 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
drop table t1;
drop table t2;
drop table t3;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 561c430417b..538f1fa1a20 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -56,8 +56,8 @@ a b
4 Testing
5 table
5 table
-6 t1
6 t2
+6 t1
7 Testing
7 Testing
8 table
diff --git a/mysql-test/r/mysqlbinlog_base64.result b/mysql-test/r/mysqlbinlog_base64.result
index 499587cb465..c31dbee56c6 100644
--- a/mysql-test/r/mysqlbinlog_base64.result
+++ b/mysql-test/r/mysqlbinlog_base64.result
@@ -5,7 +5,7 @@ insert into t1 values (3);
update t1 set a=a+2 where a=2;
update t1 set a=a+2 where a=3;
create table t2 (word varchar(20));
-load data infile '../../std_data/words.dat' into table t2;
+load data infile '../std_data_ln/words.dat' into table t2;
drop table t1;
drop table t2;
select * from t1;
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index bd4bbc15a4f..acdbd868361 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -1,4 +1,6 @@
-cluster_replication.binlog_index OK
+DROP SCHEMA test;
+CREATE SCHEMA test;
+cluster.binlog_index OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 73f676b6b69..e54dee1fcfd 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1464,7 +1464,10 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
+/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1797,7 +1800,9 @@ DROP TABLE IF EXISTS `v1`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v1` AS select `t1`.`a` AS `a` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1853,7 +1858,10 @@ DROP TABLE IF EXISTS `v2`;
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
+/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1959,13 +1967,19 @@ DROP TABLE IF EXISTS `v3`;
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7))*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7)) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v3`.`a` AS `a` from (`v3` join `v1`) where ((`v1`.`a` = `v3`.`a`) and (`v3`.`b` = 3)) limit 1*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `v3`.`a` AS `a` from (`v3` join `v1`) where ((`v1`.`a` = `v3`.`a`) and (`v3`.`b` = 3)) limit 1 */;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2399,10 +2413,10 @@ drop table t1;
set global time_zone=default;
set time_zone=default;
DROP TABLE IF EXISTS `t1 test`;
+DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t1 test` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t2 test` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -2534,13 +2548,19 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1` */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1` */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2650,6 +2670,68 @@ DELIMITER ;
DROP TRIGGER tr1;
DROP TABLE t1;
+create table t1 (a int);
+insert into t1 values (289), (298), (234), (456), (789);
+create definer = CURRENT_USER view v1 as select * from t1;
+create SQL SECURITY INVOKER view v2 as select * from t1;
+create view v3 as select * from t1 with local check option;
+create algorithm=merge view v4 as select * from t1 with cascaded check option;
+create algorithm =temptable view v5 as select * from t1;
+drop table t1;
+drop view v1, v2, v3, v4, v5;
+show tables;
+Tables_in_test
+t1
+v1
+v2
+v3
+v4
+v5
+select * from v3 order by a;
+a
+234
+289
+298
+456
+789
+drop table t1;
+drop view v1, v2, v3, v4, v5;
+create table t1 (a int, created datetime);
+create table t2 (b int, created datetime);
+create trigger tr1 before insert on t1 for each row set
+new.created=now();
+create trigger tr2 after insert on t1
+for each row
+begin
+insert into t2 set b=new.a and created=new.created;
+end|
+drop trigger tr1;
+drop trigger tr2;
+drop table t1, t2;
+show triggers;
+Trigger Event Table Statement Timing Created sql_mode Definer
+tr1 INSERT t1 set
+new.created=now() BEFORE # root@localhost
+tr2 INSERT t1 begin
+insert into t2 set b=new.a and created=new.created;
+end AFTER # root@localhost
+drop trigger tr1;
+drop trigger tr2;
+drop table t1, t2;
+/*!50003 CREATE FUNCTION `f`() RETURNS bigint(20)
+return 42 */|
+/*!50003 CREATE PROCEDURE `p`()
+select 42 */|
+show create function f;
+Function sql_mode Create Function
+f CREATE FUNCTION `f`() RETURNS bigint(20)
+return 42
+show create procedure p;
+Procedure sql_mode Create Procedure
+p CREATE PROCEDURE `p`()
+select 42
+drop function f;
+drop procedure p;
create table t1 (a text , b text);
create table t2 (a text , b text);
insert t1 values ("Duck, Duck", "goose");
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index c3a234875df..169eb5424f9 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -223,7 +223,7 @@ mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing assignment operator in let
-mysqltest: At line 1: Missing arguments to let
+mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Missing assignment operator in let
@@ -296,7 +296,9 @@ here is the sourced script
In loop
here is the sourced script
mysqltest: At line 1: Missing argument to sleep
+mysqltest: At line 1: Missing argument to real_sleep
mysqltest: At line 1: Invalid argument to sleep "abc"
+mysqltest: At line 1: Invalid argument to real_sleep "abc"
1
2
101
diff --git a/mysql-test/r/ndb_alter_table_row.result b/mysql-test/r/ndb_alter_table_row.result
index 450b2c9a5af..ee7c9b1c7b0 100644
--- a/mysql-test/r/ndb_alter_table_row.result
+++ b/mysql-test/r/ndb_alter_table_row.result
@@ -3,10 +3,19 @@ create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) )
engine=ndb;
insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
create index c on t1(c);
+show indexes from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A 3 NULL NULL BTREE
+t1 1 b 1 b A 3 NULL NULL YES BTREE
+t1 1 c 1 c A 3 NULL NULL YES BTREE
select * from t1 where c = 'two';
a b c
2 two two
alter table t1 drop index c;
+show indexes from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A 3 NULL NULL BTREE
+t1 1 b 1 b A 3 NULL NULL YES BTREE
select * from t1 where c = 'two';
a b c
2 two two
diff --git a/mysql-test/r/ndb_binlog_basic.result b/mysql-test/r/ndb_binlog_basic.result
index d84a331ee16..f51634d3d54 100644
--- a/mysql-test/r/ndb_binlog_basic.result
+++ b/mysql-test/r/ndb_binlog_basic.result
@@ -6,7 +6,7 @@ drop database mysqltest;
use test;
create table t1 (a int primary key) engine=ndb;
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-select @max_epoch:=max(epoch)-1 from cluster_replication.binlog_index;
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
@max_epoch:=max(epoch)-1
#
delete from t1;
@@ -19,25 +19,25 @@ update t2 set b=1 where a=3;
delete from t2 where a=4;
commit;
drop table t2;
-select inserts from cluster_replication.binlog_index where epoch > @max_epoch and inserts > 5;
+select inserts from cluster.binlog_index where epoch > @max_epoch and inserts > 5;
inserts
10
-select deletes from cluster_replication.binlog_index where epoch > @max_epoch and deletes > 5;
+select deletes from cluster.binlog_index where epoch > @max_epoch and deletes > 5;
deletes
10
select inserts,updates,deletes from
-cluster_replication.binlog_index where epoch > @max_epoch and updates > 0;
+cluster.binlog_index where epoch > @max_epoch and updates > 0;
inserts updates deletes
2 1 1
select schemaops from
-cluster_replication.binlog_index where epoch > @max_epoch and schemaops > 0;
+cluster.binlog_index where epoch > @max_epoch and schemaops > 0;
schemaops
1
1
1
flush logs;
purge master logs before now();
-select count(*) from cluster_replication.binlog_index;
+select count(*) from cluster.binlog_index;
count(*)
0
create table t1 (a int primary key, b int) engine=ndb;
@@ -46,17 +46,17 @@ use mysqltest;
create table t1 (c int, d int primary key) engine=ndb;
use test;
insert into mysqltest.t1 values (2,1),(2,2);
-select @max_epoch:=max(epoch)-1 from cluster_replication.binlog_index;
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
@max_epoch:=max(epoch)-1
#
drop table t1;
drop database mysqltest;
select inserts,updates,deletes from
-cluster_replication.binlog_index where epoch > @max_epoch and inserts > 0;
+cluster.binlog_index where epoch > @max_epoch and inserts > 0;
inserts updates deletes
2 0 0
select schemaops from
-cluster_replication.binlog_index where epoch > @max_epoch and schemaops > 0;
+cluster.binlog_index where epoch > @max_epoch and schemaops > 0;
schemaops
1
1
diff --git a/mysql-test/r/ndb_binlog_basic2.result b/mysql-test/r/ndb_binlog_basic2.result
new file mode 100644
index 00000000000..9b9f642bd86
--- /dev/null
+++ b/mysql-test/r/ndb_binlog_basic2.result
@@ -0,0 +1,12 @@
+set session binlog_format=row;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
+set session binlog_format=statement;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
+set global binlog_format=row;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
+set global binlog_format=statement;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
+set session binlog_format=default;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
+set global binlog_format=default;
+ERROR HY000: The NDB cluster engine does not support changing the binlog format on the fly yet
diff --git a/mysql-test/r/ndb_binlog_ddl_multi.result b/mysql-test/r/ndb_binlog_ddl_multi.result
index e9a3f80281d..1f44b7d5e3c 100644
--- a/mysql-test/r/ndb_binlog_ddl_multi.result
+++ b/mysql-test/r/ndb_binlog_ddl_multi.result
@@ -24,7 +24,7 @@ alter table t2 add column (b int);
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin1.000001 # Query # # BEGIN
-master-bin1.000001 # Table_map # # cluster_replication.apply_status
+master-bin1.000001 # Table_map # # cluster.apply_status
master-bin1.000001 # Write_rows # #
master-bin1.000001 # Query # # COMMIT
master-bin1.000001 # Query # # use `test`; alter table t2 add column (b int)
@@ -36,7 +36,7 @@ show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # ALTER DATABASE mysqltest CHARACTER SET latin1
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Table_map # # cluster_replication.apply_status
+master-bin.000001 # Table_map # # cluster.apply_status
master-bin.000001 # Write_rows # #
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `mysqltest`; drop table `t1`
@@ -49,7 +49,7 @@ create table t1 (a int primary key) engine=ndb;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin1.000001 # Query # # BEGIN
-master-bin1.000001 # Table_map # # cluster_replication.apply_status
+master-bin1.000001 # Table_map # # cluster.apply_status
master-bin1.000001 # Write_rows # #
master-bin1.000001 # Table_map # # test.t2
master-bin1.000001 # Write_rows # #
@@ -119,7 +119,7 @@ ENGINE = NDB
master-bin1.000001 # Query # # DROP LOGFILE GROUP lg1
ENGINE =NDB
master-bin1.000001 # Query # # BEGIN
-master-bin1.000001 # Table_map # # cluster_replication.apply_status
+master-bin1.000001 # Table_map # # cluster.apply_status
master-bin1.000001 # Write_rows # #
master-bin1.000001 # Query # # COMMIT
master-bin1.000001 # Query # # use `test`; drop table `t1`
diff --git a/mysql-test/r/ndb_binlog_multi.result b/mysql-test/r/ndb_binlog_multi.result
index 5f739327db2..808b96bcc3d 100644
--- a/mysql-test/r/ndb_binlog_multi.result
+++ b/mysql-test/r/ndb_binlog_multi.result
@@ -12,7 +12,7 @@ a b
1 1
2 2
SELECT @the_epoch:=epoch,inserts,updates,deletes,schemaops FROM
-cluster_replication.binlog_index ORDER BY epoch DESC LIMIT 1;
+cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
@the_epoch:=epoch inserts updates deletes schemaops
<the_epoch> 2 0 0 0
SELECT * FROM t2 ORDER BY a;
@@ -20,24 +20,24 @@ a b
1 1
2 2
SELECT inserts,updates,deletes,schemaops FROM
-cluster_replication.binlog_index WHERE epoch=<the_epoch>;
+cluster.binlog_index WHERE epoch=<the_epoch>;
inserts updates deletes schemaops
2 0 0 0
DROP TABLE t2;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB;
INSERT INTO t1 VALUES (1),(2);
SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM
-cluster_replication.binlog_index ORDER BY epoch DESC LIMIT 1;
+cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
@the_epoch2:=epoch inserts updates deletes schemaops
<the_epoch2> 2 0 0 0
SELECT inserts,updates,deletes,schemaops FROM
-cluster_replication.binlog_index WHERE epoch > <the_epoch> AND epoch < <the_epoch2>;
+cluster.binlog_index WHERE epoch > <the_epoch> AND epoch < <the_epoch2>;
inserts updates deletes schemaops
0 0 0 1
drop table t1;
SHOW TABLES;
Tables_in_test
SELECT inserts,updates,deletes,schemaops FROM
-cluster_replication.binlog_index WHERE epoch > <the_epoch> AND epoch < <the_epoch2>;
+cluster.binlog_index WHERE epoch > <the_epoch> AND epoch < <the_epoch2>;
inserts updates deletes schemaops
0 0 0 1
diff --git a/mysql-test/r/ndb_cache_multi2.result b/mysql-test/r/ndb_cache_multi2.result
index 63cc4d4ceed..53767bb6d3c 100644
--- a/mysql-test/r/ndb_cache_multi2.result
+++ b/mysql-test/r/ndb_cache_multi2.result
@@ -1,14 +1,17 @@
drop table if exists t1, t2;
+== Connected to server1 ==
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
reset query cache;
flush status;
+== Connected to server2 ==
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
reset query cache;
flush status;
+== Connected to server1 ==
create table t1 (a int) engine=ndbcluster;
create table t2 (a int) engine=ndbcluster;
insert into t1 value (2);
@@ -16,18 +19,22 @@ insert into t2 value (3);
select * from t1;
a
2
+select a != 3 from t1;
+a != 3
+1
select * from t2;
a
3
show status like "Qcache_queries_in_cache";
Variable_name Value
-Qcache_queries_in_cache 2
+Qcache_queries_in_cache 3
show status like "Qcache_inserts";
Variable_name Value
-Qcache_inserts 2
+Qcache_inserts 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
+== Connected to server2 ==
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
@@ -50,24 +57,13 @@ show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
update t1 set a=3 where a=2;
-show status like "Qcache_queries_in_cache";
-Variable_name Value
-Qcache_queries_in_cache 2
-show status like "Qcache_inserts";
-Variable_name Value
-Qcache_inserts 2
-show status like "Qcache_hits";
-Variable_name Value
-Qcache_hits 0
+== Connected to server1 ==
select * from t1;
a
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 3
-show status like "Qcache_inserts";
-Variable_name Value
-Qcache_inserts 4
drop table t1, t2;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
diff --git a/mysql-test/r/ndb_dd_backuprestore.result b/mysql-test/r/ndb_dd_backuprestore.result
index b5727418d17..0410589e93a 100644
--- a/mysql-test/r/ndb_dd_backuprestore.result
+++ b/mysql-test/r/ndb_dd_backuprestore.result
@@ -4,7 +4,9 @@ DROP TABLE IF EXISTS test.t3;
DROP TABLE IF EXISTS test.t4;
DROP TABLE IF EXISTS test.t5;
DROP TABLE IF EXISTS test.t6;
-**** Test 1 Simple DD backup and restore **** CREATE LOGFILE GROUP log_group1 ADD UNDOFILE './log_group1/undofile.dat'
+**** Test 1 Simple DD backup and restore ****
+CREATE LOGFILE GROUP log_group1
+ADD UNDOFILE './log_group1/undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;
@@ -14,7 +16,8 @@ USE LOGFILE GROUP log_group1
INITIAL_SIZE 12M
ENGINE NDB;
CREATE TABLE test.t1
-(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; SELECT COUNT(*) FROM test.t1;
+(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 CHAR(50) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB;
+SELECT COUNT(*) FROM test.t1;
COUNT(*)
500
SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
@@ -24,8 +27,16 @@ pk1 c2 c3 hex(c4)
3 Sweden 498 1
4 Sweden 497 1
5 Sweden 496 1
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM test.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM test.backup_info;
+@the_backup_id:=backup_id
+<the_backup_id>
+DROP TABLE test.backup_info;
DROP TABLE test.t1;
-CREATE TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; DELETE FROM test.backup_info; LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id <the_backup_id> DROP TABLE test.backup_info; ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat'
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
ENGINE = NDB;
DROP TABLESPACE table_space1
ENGINE = NDB;
@@ -41,8 +52,12 @@ pk1 c2 c3 hex(c4)
3 Sweden 498 1
4 Sweden 497 1
5 Sweden 496 1
-**** Test 2 Mixed Cluster Test backup and restore **** CREATE TABLE test.t2
-(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL)ENGINE=NDB; CREATE TABLE test.t3 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; CREATE TABLE test.t4 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=NDB; SELECT COUNT(*) FROM test.t1;
+**** Test 2 Mixed Cluster Test backup and restore ****
+CREATE TABLE test.t2
+(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(200) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL)ENGINE=NDB;
+CREATE TABLE test.t3 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB;
+CREATE TABLE test.t4 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=NDB;
+SELECT COUNT(*) FROM test.t1;
COUNT(*)
500
SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
@@ -80,7 +95,19 @@ LENGTH(data)
SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2;
LENGTH(data)
16384
-CREATE TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; DELETE FROM test.backup_info; LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id <the_backup_id> DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE test.t3; DROP TABLE test.t4; ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat'
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM test.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM test.backup_info;
+@the_backup_id:=backup_id
+<the_backup_id>
+DROP TABLE test.backup_info;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+DROP TABLE test.t4;
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
ENGINE = NDB;
DROP TABLESPACE table_space1
ENGINE = NDB;
@@ -128,59 +155,73 @@ DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE test.t3;
DROP TABLE test.t4;
-**** Test 3 Adding partition Test backup and restore **** CREATE TABLESPACE table_space2 ADD DATAFILE './table_space2/datafile.dat'
+**** Test 3 Adding partition Test backup and restore ****
+CREATE TABLESPACE table_space2
+ADD DATAFILE './table_space2/datafile.dat'
USE LOGFILE GROUP log_group1
INITIAL_SIZE 12M
ENGINE NDB;
-CREATE TABLE test.t1 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 4; CREATE TABLE test.t4 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 2; CREATE TABLE test.t2 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY KEY(c3) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); CREATE TABLE test.t5 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY KEY(pk1) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); CREATE TABLE test.t3 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY RANGE (c3) PARTITIONS 3 (PARTITION x1 VALUES LESS THAN (105), PARTITION x2 VALUES LESS THAN (333), PARTITION x3 VALUES LESS THAN (720)); CREATE TABLE test.t6 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY RANGE (pk1) PARTITIONS 2 (PARTITION x1 VALUES LESS THAN (333), PARTITION x2 VALUES LESS THAN (720)); SHOW CREATE TABLE test.t1;
+CREATE TABLE test.t1 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(150) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 4;
+CREATE TABLE test.t4 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(180) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 2;
+CREATE TABLE test.t2 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY KEY(c3) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
+CREATE TABLE test.t5 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY KEY(pk1) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
+CREATE TABLE test.t3 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(202) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY RANGE (c3) PARTITIONS 3 (PARTITION x1 VALUES LESS THAN (105), PARTITION x2 VALUES LESS THAN (333), PARTITION x3 VALUES LESS THAN (720));
+CREATE TABLE test.t6 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(220) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY RANGE (pk1) PARTITIONS 2 (PARTITION x1 VALUES LESS THAN (333), PARTITION x2 VALUES LESS THAN (720));
+SHOW CREATE TABLE test.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(150) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 4 SHOW CREATE TABLE test.t2;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 4
+SHOW CREATE TABLE test.t2;
Table Create Table
t2 CREATE TABLE `t2` (
`pk1` mediumint(9) NOT NULL auto_increment,
`c2` text NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) SHOW CREATE TABLE test.t3;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t3;
Table Create Table
t3 CREATE TABLE `t3` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(202) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) SHOW CREATE TABLE test.t4;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t4;
Table Create Table
t4 CREATE TABLE `t4` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(180) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 2 SHOW CREATE TABLE test.t5;
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 2
+SHOW CREATE TABLE test.t5;
Table Create Table
t5 CREATE TABLE `t5` (
`pk1` mediumint(9) NOT NULL auto_increment,
`c2` text NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) SHOW CREATE TABLE test.t6;
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t6;
Table Create Table
t6 CREATE TABLE `t6` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(220) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) SELECT * FROM information_schema.partitions WHERE table_name= 't1';
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster)
+SELECT * FROM information_schema.partitions WHERE table_name= 't1';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default 0 default
NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default 0 default
@@ -267,7 +308,21 @@ pk1 c2 c3 hex(c4)
248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1
247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1
246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1
-CREATE TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; DELETE FROM test.backup_info; LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id <the_backup_id> DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE test.t3; DROP TABLE test.t4; DROP TABLE test.t5; DROP TABLE test.t6; ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat'
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM test.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM test.backup_info;
+@the_backup_id:=backup_id
+<the_backup_id>
+DROP TABLE test.backup_info;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+DROP TABLE test.t4;
+DROP TABLE test.t5;
+DROP TABLE test.t6;
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
ENGINE = NDB;
ALTER TABLESPACE table_space2
DROP DATAFILE './table_space2/datafile.dat'
@@ -282,51 +337,57 @@ SHOW CREATE TABLE test.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(150) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 4 SHOW CREATE TABLE test.t2;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 4
+SHOW CREATE TABLE test.t2;
Table Create Table
t2 CREATE TABLE `t2` (
`pk1` mediumint(9) NOT NULL auto_increment,
`c2` text NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) SHOW CREATE TABLE test.t3;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t3;
Table Create Table
t3 CREATE TABLE `t3` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(202) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) SHOW CREATE TABLE test.t4;
+ PRIMARY KEY (`pk1`,`c3`)
+) TABLESPACE table_space2 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t4;
Table Create Table
t4 CREATE TABLE `t4` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(180) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 2 SHOW CREATE TABLE test.t5;
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (c3) PARTITIONS 2
+SHOW CREATE TABLE test.t5;
Table Create Table
t5 CREATE TABLE `t5` (
`pk1` mediumint(9) NOT NULL auto_increment,
`c2` text NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) SHOW CREATE TABLE test.t6;
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster)
+SHOW CREATE TABLE test.t6;
Table Create Table
t6 CREATE TABLE `t6` (
`pk1` mediumint(9) NOT NULL auto_increment,
- `c2` text NOT NULL,
+ `c2` varchar(220) NOT NULL,
`c3` int(11) NOT NULL,
`c4` bit(1) NOT NULL,
- PRIMARY KEY (`pk1`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) SELECT * FROM information_schema.partitions WHERE table_name= 't1';
+ PRIMARY KEY (`pk1`,`c3`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster)
+SELECT * FROM information_schema.partitions WHERE table_name= 't1';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default 0 default
NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default 0 default
@@ -419,5 +480,8 @@ DROP TABLE test.t3;
DROP TABLE test.t4;
DROP TABLE test.t5;
DROP TABLE test.t6;
-ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat' ENGINE=NDB; ALTER TABLESPACE table_space2 DROP DATAFILE './table_space2/datafile.dat' ENGINE=NDB; DROP TABLESPACE table_space1 ENGINE = NDB; DROP TABLESPACE table_space2 ENGINE = NDB; DROP LOGFILE GROUP log_group1 ENGINE = NDB;
-
+ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat' ENGINE=NDB;
+ALTER TABLESPACE table_space2 DROP DATAFILE './table_space2/datafile.dat' ENGINE=NDB;
+DROP TABLESPACE table_space1 ENGINE = NDB;
+DROP TABLESPACE table_space2 ENGINE = NDB;
+DROP LOGFILE GROUP log_group1 ENGINE = NDB;
diff --git a/mysql-test/r/ndb_gis.result b/mysql-test/r/ndb_gis.result
index 6c95b3d4e4e..f9b9ceb76a5 100644
--- a/mysql-test/r/ndb_gis.result
+++ b/mysql-test/r/ndb_gis.result
@@ -1,66 +1,51 @@
SET storage_engine=ndbcluster;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
- `fid` int(11) DEFAULT NULL,
- `g` point DEFAULT NULL
+ `fid` int(11) NOT NULL AUTO_INCREMENT,
+ `g` point DEFAULT NULL,
+ PRIMARY KEY (`fid`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
@@ -423,6 +408,7 @@ Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
+a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -432,10 +418,9 @@ mpg multipolygon,
gc geometrycollection,
gm geometry
);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -445,10 +430,9 @@ mpg multipolygon YES NULL
gc geometrycollection YES NULL
gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -459,90 +443,71 @@ gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
-create table t1 (a geometry not null);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-insert into t1 values (GeomFromText('Point(1 2)'));
-insert into t1 values ('Garbage');
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
+insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-create table t1 (fl geometry);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-insert into t1 values (1);
+create table t1 (pk integer primary key auto_increment, fl geometry);
+insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
set engine_condition_pushdown = on;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
-CREATE TABLE gis_point (fid INTEGER, g POINT);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
+CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
+CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
+CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
+CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
+CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
+CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
+CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
+CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
- `fid` int(11) DEFAULT NULL,
- `g` point DEFAULT NULL
+ `fid` int(11) NOT NULL AUTO_INCREMENT,
+ `g` point DEFAULT NULL,
+ PRIMARY KEY (`fid`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
-fid int(11) YES NULL
+fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
@@ -905,6 +870,7 @@ Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
+a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
@@ -914,10 +880,9 @@ mpg multipolygon,
gc geometrycollection,
gm geometry
);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -927,10 +892,9 @@ mpg multipolygon YES NULL
gc geometrycollection YES NULL
gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
+a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
@@ -941,24 +905,20 @@ gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
-create table t1 (a geometry not null);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-insert into t1 values (GeomFromText('Point(1 2)'));
-insert into t1 values ('Garbage');
+create table t1 (pk integer primary key auto_increment, a geometry not null);
+insert into t1 (a) values (GeomFromText('Point(1 2)'));
+insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert IGNORE into t1 values ('Garbage');
+insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-create table t1 (fl geometry);
-Warnings:
-Error 1538 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK'
-insert into t1 values (1);
+create table t1 (pk integer primary key auto_increment, fl geometry);
+insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (1.11);
+insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values ("qwerty");
+insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
-insert into t1 values (pointfromtext('point(1,1)'));
+insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
diff --git a/mysql-test/r/ndb_load.result b/mysql-test/r/ndb_load.result
index 76da5b2a215..416a350066b 100644
--- a/mysql-test/r/ndb_load.result
+++ b/mysql-test/r/ndb_load.result
@@ -1,10 +1,10 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ;
ERROR 23000: Can't write; duplicate key in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
word
Aarhus
diff --git a/mysql-test/r/ndb_partition_error.result b/mysql-test/r/ndb_partition_error.result
index 3fd111a7c0f..66f623dee13 100644
--- a/mysql-test/r/ndb_partition_error.result
+++ b/mysql-test/r/ndb_partition_error.result
@@ -28,3 +28,11 @@ partitions 3
partition x2 values less than (10),
partition x3 values less than (20));
drop table t1;
+CREATE TABLE t1 (id INT) ENGINE=NDB
+PARTITION BY LIST(id)
+(PARTITION p0 VALUES IN (2, 4),
+PARTITION p1 VALUES IN (42, 142));
+INSERT INTO t1 VALUES (2);
+UPDATE t1 SET id=5 WHERE id=2;
+ERROR HY000: Table has no partition for value 5
+DROP TABLE t1;
diff --git a/mysql-test/r/ndb_partition_range.result b/mysql-test/r/ndb_partition_range.result
index 2b9c55c3929..cb79f04873e 100644
--- a/mysql-test/r/ndb_partition_range.result
+++ b/mysql-test/r/ndb_partition_range.result
@@ -117,3 +117,147 @@ t1 CREATE TABLE `t1` (
UNIQUE KEY `a` (`a`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (b) (PARTITION x1 VALUES LESS THAN (5) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (10) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (20) ENGINE = ndbcluster)
drop table t1;
+CREATE TABLE t1
+(id MEDIUMINT NOT NULL,
+b1 BIT(8),
+vc VARCHAR(255),
+bc CHAR(255),
+d DECIMAL(10,4) DEFAULT 0,
+f FLOAT DEFAULT 0,
+total BIGINT UNSIGNED,
+y YEAR,
+t DATE) ENGINE=NDB
+PARTITION BY RANGE (YEAR(t))
+(PARTITION p0 VALUES LESS THAN (1901),
+PARTITION p1 VALUES LESS THAN (1946),
+PARTITION p2 VALUES LESS THAN (1966),
+PARTITION p3 VALUES LESS THAN (1986),
+PARTITION p4 VALUES LESS THAN (2005),
+PARTITION p5 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+SELECT * FROM t1;
+id b1 vc bc d f total y t
+0 NULL NULL NULL NULL NULL NULL NULL NULL
+ALTER TABLE t1 ENGINE=MYISAM;
+SELECT * FROM t1;
+id b1 vc bc d f total y t
+0 NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE t1;
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+ INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE=1M
+ENGINE=NDB;
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+ USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+CREATE TABLE test.t1 (
+a1 INT,
+a2 TEXT NOT NULL,
+a3 BIT NOT NULL,
+a4 DECIMAL(8,3),
+a5 INT NOT NULL,
+a6 INT,
+PRIMARY KEY(a1))
+TABLESPACE ts1 STORAGE DISK ENGINE=NDB
+PARTITION BY LIST (a1)
+(PARTITION p0 VALUES IN (1,2,3,4,5),
+PARTITION p1 VALUES IN (6,7,8,9, 10),
+PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
+ALTER TABLE test.t1 DROP COLUMN a6;
+ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255);
+SELECT COUNT(*) FROM test.t1;
+COUNT(*)
+15
+ALTER TABLE test.t1 DROP COLUMN a4;
+SELECT COUNT(*) FROM test.t1;
+COUNT(*)
+15
+DROP TABLE t1;
+CREATE TABLE test.t1 (
+a1 INT,
+a2 TEXT NOT NULL,
+a3 BIT NOT NULL,
+a4 DECIMAL(8,3),
+a5 INT NOT NULL,
+a6 VARCHAR(255),
+PRIMARY KEY(a1))
+TABLESPACE ts1 STORAGE DISK ENGINE=NDB
+PARTITION BY HASH(a1)
+PARTITIONS 4;
+SELECT COUNT(*) FROM test.t1;
+COUNT(*)
+15
+ALTER TABLE test.t1 DROP COLUMN a4;
+SELECT COUNT(*) FROM test.t1;
+COUNT(*)
+15
+DROP TABLE t1;
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+DROP TABLESPACE ts1 ENGINE=NDB;
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+CREATE TABLE t1
+(id MEDIUMINT NOT NULL,
+b1 BIT(8),
+vc VARCHAR(255),
+bc CHAR(255),
+d DECIMAL(10,4) DEFAULT 0,
+f FLOAT DEFAULT 0,
+total BIGINT UNSIGNED,
+y YEAR,
+t DATE) ENGINE=NDB
+PARTITION BY LIST(id)
+(PARTITION p0 VALUES IN (2, 4),
+PARTITION p1 VALUES IN (42, 142));
+INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+SELECT * FROM t1;
+id b1 vc bc d f total y t
+2 NULL NULL NULL NULL NULL NULL NULL NULL
+ALTER TABLE t1 ADD PARTITION
+(PARTITION p2 VALUES IN (412));
+SELECT * FROM t1;
+id b1 vc bc d f total y t
+2 NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null)
+partition by list(a)
+partitions 2
+(partition x123 values in (1,5,6),
+partition x234 values in (4,7,8));
+INSERT into t1 VALUES (5,1,1);
+select * from t1;
+a b c
+5 1 1
+UPDATE t1 SET a=8 WHERE a=5 AND b=1;
+select * from t1;
+a b c
+8 1 1
+drop table t1;
+CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb
+PARTITION BY RANGE(f1)
+( PARTITION part1 VALUES LESS THAN (2),
+PARTITION part2 VALUES LESS THAN (1000));
+INSERT INTO t1 VALUES(1, '---1---');
+INSERT INTO t1 VALUES(2, '---2---');
+select * from t1 order by f1;
+f1 f2
+1 ---1---
+2 ---2---
+UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2;
+select * from t1 order by f1;
+f1 f2
+1 ---1---
+6 ---2---
+UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1;
+select * from t1 order by f1;
+f1 f2
+5 ---1---
+6 ---2---
+drop table t1;
diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result
index 85c4e34cc5a..01ab286aad8 100644
--- a/mysql-test/r/ndb_restore.result
+++ b/mysql-test/r/ndb_restore.result
@@ -125,6 +125,13 @@ create table t6 engine=myisam as select * from t6_c;
create table t7 engine=myisam as select * from t7_c;
create table t8 engine=myisam as select * from t8_c;
create table t9 engine=myisam as select * from t9_c;
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM test.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM test.backup_info;
+@the_backup_id:=backup_id
+<the_backup_id>
+DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
select count(*) from t1;
count(*)
@@ -241,6 +248,13 @@ PARTITION BY LINEAR HASH (`relatta`)
PARTITIONS 4;
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM test.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM test.backup_info;
+@the_backup_id:=backup_id
+<the_backup_id>
+DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
select count(*) from t1;
count(*)
@@ -445,4 +459,4 @@ drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
Create table test/def/t2_c failed: Translate frm error
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
-520093696,2
+520093696,<the_backup_id>
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 70ff49be905..cd333cc5fb4 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -315,4 +315,62 @@ drop table t1;
create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUES in (10), partition x2 values in (20));
alter table t1 add partition (partition x3 values in (30));
drop table t1;
+CREATE TABLE t1 (
+f_int1 INTEGER, f_int2 INTEGER,
+f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000)
+)
+PARTITION BY RANGE(f_int1 DIV 2)
+SUBPARTITION BY HASH(f_int1)
+SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN (5),
+PARTITION parte VALUES LESS THAN (10),
+PARTITION partf VALUES LESS THAN (2147483647));
+INSERT INTO t1 SET f_int1 = NULL , f_int2 = -20, f_char1 = CAST(-20 AS CHAR),
+f_char2 = CAST(-20 AS CHAR), f_charbig = '#NULL#';
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+f_int1 f_int2 f_char1 f_char2 f_charbig
+NULL -20 -20 -20 #NULL#
+SELECT * FROM t1;
+f_int1 f_int2 f_char1 f_char2 f_charbig
+NULL -20 -20 -20 #NULL#
+drop table t1;
+CREATE TABLE t1 (
+f_int1 INTEGER, f_int2 INTEGER,
+f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000) )
+PARTITION BY LIST(MOD(f_int1,2))
+SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES IN (-1) (SUBPARTITION sp1, SUBPARTITION sp2),
+PARTITION part2 VALUES IN (0) (SUBPARTITION sp3, SUBPARTITION sp5),
+PARTITION part3 VALUES IN (1) (SUBPARTITION sp4, SUBPARTITION sp6));
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+f_int1 f_int2 f_char1 f_char2 f_charbig
+drop table t1;
+create procedure p ()
+begin
+create table t1 (s1 mediumint,s2 mediumint)
+partition by list (s2)
+(partition p1 values in (0),
+partition p2 values in (1));
+end//
+call p()//
+drop procedure p//
+drop table t1;
+create procedure p ()
+begin
+create table t1 (a int not null,b int not null,c int not null,primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+(partition x1 values less than (1)
+(subpartition x11,
+subpartition x12),
+partition x2 values less than (5)
+(subpartition x21,
+subpartition x22));
+end//
+call p()//
+drop procedure p//
+drop table t1//
End of 5.1 tests
diff --git a/mysql-test/r/partition_02myisam.result b/mysql-test/r/partition_02myisam.result
index 29d54c8a8b8..a7786bfcfbd 100644
--- a/mysql-test/r/partition_02myisam.result
+++ b/mysql-test/r/partition_02myisam.result
@@ -1160,12 +1160,12 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
(PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (21' at line 3
CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
PARTITION BY HASH(f1) PARTITIONS 1000000;
-ERROR HY000: Too many partitions were defined
+ERROR HY000: Too many partitions (including subpartitions) were defined
CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1)
SUBPARTITIONS 1000000
(PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647));
-ERROR HY000: Too many partitions were defined
+ERROR HY000: Too many partitions (including subpartitions) were defined
# 3.2.4 partition/subpartition numbers STRING notation
CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
PARTITION BY HASH(f1) PARTITIONS '2';
diff --git a/mysql-test/r/partition_charset.result b/mysql-test/r/partition_charset.result
new file mode 100644
index 00000000000..665e5d55f8f
--- /dev/null
+++ b/mysql-test/r/partition_charset.result
@@ -0,0 +1,18 @@
+drop table if exists t1;
+set names utf8;
+create table t1 (s1 int)
+partition by list (s1)
+(partition c values in (1),
+partition Ç values in (3));
+insert into t1 values (1),(3);
+select * from t1;
+s1
+1
+3
+flush tables;
+set names latin1;
+select * from t1;
+s1
+1
+3
+drop table t1;
diff --git a/mysql-test/r/partition_mgm_err.result b/mysql-test/r/partition_mgm_err.result
index a419d5b361b..c7003c6e14c 100644
--- a/mysql-test/r/partition_mgm_err.result
+++ b/mysql-test/r/partition_mgm_err.result
@@ -91,7 +91,7 @@ PARTITION BY KEY (a)
ALTER TABLE t1 ADD PARTITION PARTITIONS 0;
ERROR HY000: At least one partition must be added
ALTER TABLE t1 ADD PARTITION PARTITIONS 1024;
-ERROR HY000: Too many partitions were defined
+ERROR HY000: Too many partitions (including subpartitions) were defined
ALTER TABLE t1 DROP PARTITION x0;
ERROR HY000: DROP PARTITION can only be used on RANGE/LIST partitions
ALTER TABLE t1 COALESCE PARTITION 1;
@@ -112,8 +112,6 @@ ALTER TABLE t1 DROP PARTITION x1;
ALTER TABLE t1 DROP PARTITION x0;
ERROR HY000: Cannot remove all partitions, use DROP TABLE instead
DROP TABLE t1;
-INSERT INTO t1 VALUES (15);
-DROP TABLE t1;
CREATE TABLE t1 ( id INT NOT NULL,
fname VARCHAR(50) NOT NULL,
lname VARCHAR(50) NOT NULL,
@@ -142,3 +140,9 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
+DROP TABLE t1;
+CREATE TABLE t1 (s1 int, s2 int) PARTITION BY LIST (s1) (
+PARTITION p1 VALUES IN (0) (SUBPARTITION p1b),
+PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
+);
+ERROR HY000: Duplicate partition name p1b
diff --git a/mysql-test/r/partition_mgm_err2.result b/mysql-test/r/partition_mgm_err2.result
new file mode 100644
index 00000000000..7e5763b8f1b
--- /dev/null
+++ b/mysql-test/r/partition_mgm_err2.result
@@ -0,0 +1,2 @@
+INSERT INTO t1 VALUES (15);
+DROP TABLE t1;
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result
index 776a98c7d4d..cbad5d067b0 100644
--- a/mysql-test/r/partition_pruning.result
+++ b/mysql-test/r/partition_pruning.result
@@ -85,29 +85,29 @@ partition p1 values in (14)
insert into t5 values (10,2,0,0), (10,4,0,0), (10,2,0,1), (10,4,0,1);
explain partitions select * from t5;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p0_sp1,p1_sp0,p1_sp1 ALL NULL NULL NULL NULL 4
+1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4
explain partitions select * from t5
where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p0_sp1 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t5 p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3)
or (a=10 and b = 4);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p0_sp1,p1_sp0,p1_sp1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (c=1 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p1_sp0 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t5 p0_p0sp0,p1_p1sp0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t5 where (c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp1,p1_sp1 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t5 p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
(c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p0_sp1,p1_sp1 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
(b=2 and c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t5 p0_sp0,p0_sp1,p1_sp1 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where
create table t6 (a int not null) partition by LIST(a) (
partition p1 values in (1),
partition p3 values in (3),
@@ -242,13 +242,13 @@ partition p3 values in (4)
insert into t3 values (1,1),(2,2),(3,3);
explain partitions select * from t3 where a=2 or b=1;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 p0_sp1,p1_sp0,p1_sp1,p1_sp2,p1_sp3,p2_sp1,p3_sp1 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3 p0_p0sp1,p1_p1sp0,p1_p1sp1,p1_p1sp2,p1_p1sp3,p2_p2sp1,p3_p3sp1 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t3 where a=4 or b=2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 p0_sp2,p1_sp2,p2_sp2,p3_sp0,p3_sp1,p3_sp2,p3_sp3 system NULL NULL NULL NULL 1
+1 SIMPLE t3 p0_p0sp2,p1_p1sp2,p2_p2sp2,p3_p3sp0,p3_p3sp1,p3_p3sp2,p3_p3sp3 system NULL NULL NULL NULL 1
explain partitions select * from t3 where (a=2 or b=1) and (a=4 or b=2) ;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 p1_sp2,p3_sp1 system NULL NULL NULL NULL 1
+1 SIMPLE t3 p1_p1sp2,p3_p3sp1 system NULL NULL NULL NULL 1
drop table t3;
create table t1 (a int) partition by hash(a) partitions 2;
insert into t1 values (1),(2);
@@ -300,10 +300,10 @@ partition p3 values in (3)
insert into t1 values (1,1),(2,2),(3,3);
explain partitions select * from t1 where b > 1 and b < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0_sp2,p1_sp2,p2_sp2,p3_sp2 system NULL NULL NULL NULL 1
+1 SIMPLE t1 p0_p0sp2,p1_p1sp2,p2_p2sp2,p3_p3sp2 system NULL NULL NULL NULL 1
explain partitions select * from t1 where b > 1 and b < 3 and (a =1 or a =2);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p1_sp2,p2_sp2 system NULL NULL NULL NULL 1
+1 SIMPLE t1 p1_p1sp2,p2_p2sp2 system NULL NULL NULL NULL 1
drop table t1;
create table t1 (a int) partition by list(a) (
partition p0 values in (1,2),
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 5c0a13fe640..e24cee9e875 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -859,6 +859,20 @@ count(*)
5
deallocate prepare stmt;
drop table t1;
+prepare stmt from 'create table t1 (a varchar(10) character set utf8)';
+execute stmt;
+insert into t1 (a) values (repeat('a', 20));
+select length(a) from t1;
+length(a)
+10
+drop table t1;
+execute stmt;
+insert into t1 (a) values (repeat('a', 20));
+select length(a) from t1;
+length(a)
+10
+drop table t1;
+deallocate prepare stmt;
create table t1 (id int);
prepare ins_call from "insert into t1 (id) values (1)";
execute ins_call;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 859050fd4a3..22d59c7bd8f 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -259,7 +259,7 @@ prepare stmt4 from ' show databases ';
execute stmt4;
Database
information_schema
-cluster_replication
+cluster
mysql
test
prepare stmt4 from ' show tables from test like ''t2%'' ';
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 942eca42c93..40aa88439b9 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -3,7 +3,7 @@ flush query cache;
flush query cache;
reset query cache;
flush status;
-drop table if exists t1,t2,t3,t4,t11,t21;
+drop table if exists t1,t2,t3,t4,t11,t21,t1_1,t1_2,t9,t9_1,t9_2;
drop database if exists mysqltest;
drop table if exists ```a`;
drop view if exists v1;
diff --git a/mysql-test/r/rpl_LD_INFILE.result b/mysql-test/r/rpl_LD_INFILE.result
index b092dd9e088..70013f95d85 100644
--- a/mysql-test/r/rpl_LD_INFILE.result
+++ b/mysql-test/r/rpl_LD_INFILE.result
@@ -6,10 +6,10 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1 (a VARCHAR(255), PRIMARY KEY(a));
-LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
DELETE FROM test.t1 WHERE a = 'abashed';
DELETE FROM test.t1;
-LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
SELECT * FROM test.t1 ORDER BY a DESC;
a
aberration
diff --git a/mysql-test/r/rpl_alter_db.result b/mysql-test/r/rpl_alter_db.result
new file mode 100644
index 00000000000..6edbe5d427f
--- /dev/null
+++ b/mysql-test/r/rpl_alter_db.result
@@ -0,0 +1,8 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+use mysql;
+alter database collate latin1_bin;
diff --git a/mysql-test/r/rpl_bit_npk.result b/mysql-test/r/rpl_bit_npk.result
index aeefc77d69b..2850e63aabd 100644
--- a/mysql-test/r/rpl_bit_npk.result
+++ b/mysql-test/r/rpl_bit_npk.result
@@ -45,25 +45,27 @@ GSuppDf TINYINT,
VNotSupp TINYINT,
x034 TINYINT);
LOCK TABLES test.t1 WRITE;
-INSERT INTO test.t1 VALUES (6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'111110',b'110101',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'111110',b'110101',4,5,5,5,5,5,5,5,5,5,3,NULL,1);
INSERT INTO test.t1 VALUES (1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'100100',4,5,5,5,5,5,5,5,5,5,3,2,1);
INSERT INTO test.t1 VALUES (2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'101010',b'010101',4,5,5,5,5,5,5,5,5,5,3,2,1);
INSERT INTO test.t1 VALUES (3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'101010',b'111111',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1);
-INSERT INTO test.t1 VALUES (4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'0',1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
INSERT INTO test.t1 VALUES (5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
INSERT INTO test.t1 VALUES (7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
INSERT INTO test.t1 VALUES (8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
UNLOCK TABLES;
+UPDATE test.t1 set x034 = 50 where bit3 = b'000000';
+UPDATE test.t1 set VNotSupp = 33 where bit1 = b'0';
SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
oSupp sSuppD GSuppDf VNotSupp x034
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
+5 5 3 NULL 1
+5 5 3 2 1
+5 5 3 33 1
+5 5 3 2 50
+5 5 3 33 1
+5 5 3 33 1
+5 5 3 33 1
+5 5 3 33 1
SELECT hex(bit1) from test.t1;
hex(bit1)
3F
@@ -96,14 +98,14 @@ hex(bit3)
1
SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
oSupp sSuppD GSuppDf VNotSupp x034
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
-5 5 3 2 1
+5 5 3 NULL 1
+5 5 3 2 1
+5 5 3 33 1
+5 5 3 2 50
+5 5 3 33 1
+5 5 3 33 1
+5 5 3 33 1
+5 5 3 33 1
SELECT hex(bit1) from test.t1;
hex(bit1)
3F
@@ -134,4 +136,30 @@ hex(bit3)
1
1
1
+CREATE TABLE test.t2 (a INT, b BIT(1));
+INSERT INTO test.t2 VALUES (1, b'0');
+INSERT INTO test.t2 VALUES (1, b'1');
+UPDATE test.t2 SET a = 2 WHERE b = b'1';
+CREATE TABLE test.t3 (a INT, b INT);
+INSERT INTO test.t3 VALUES (1, NULL);
+INSERT INTO test.t3 VALUES (1, 0);
+UPDATE test.t3 SET a = 2 WHERE b = 0;
+SELECT a, hex(b) FROM test.t2;
+a hex(b)
+1 0
+2 1
+SELECT * FROM test.t3;
+a b
+1 NULL
+2 0
+SELECT a, hex(b) FROM test.t2;
+a hex(b)
+1 0
+2 1
+SELECT * FROM test.t3;
+a b
+1 NULL
+2 0
DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
diff --git a/mysql-test/r/rpl_create_database.result b/mysql-test/r/rpl_create_database.result
index cb3c7944962..0593501f623 100644
--- a/mysql-test/r/rpl_create_database.result
+++ b/mysql-test/r/rpl_create_database.result
@@ -23,7 +23,7 @@ ALTER DATABASE mysqltest_bob CHARACTER SET latin1;
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest_bob
mysqltest_prometheus
@@ -32,7 +32,7 @@ test
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest_prometheus
mysqltest_sisyfos
@@ -47,7 +47,7 @@ CREATE TABLE t2 (a INT);
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest_bob
mysqltest_prometheus
@@ -56,7 +56,7 @@ test
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest_prometheus
mysqltest_sisyfos
diff --git a/mysql-test/r/rpl_load_from_master.result b/mysql-test/r/rpl_load_from_master.result
index edf1f0ee7c9..c279ee6e0aa 100644
--- a/mysql-test/r/rpl_load_from_master.result
+++ b/mysql-test/r/rpl_load_from_master.result
@@ -33,7 +33,7 @@ create database mysqltest;
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest
mysqltest2
@@ -51,7 +51,7 @@ set sql_log_bin = 1;
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
test
create database mysqltest2;
@@ -71,7 +71,7 @@ load data from master;
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest
mysqltest2
diff --git a/mysql-test/r/rpl_load_table_from_master.result b/mysql-test/r/rpl_load_table_from_master.result
index 9d9a1d7d6cb..c24f857d829 100644
--- a/mysql-test/r/rpl_load_table_from_master.result
+++ b/mysql-test/r/rpl_load_table_from_master.result
@@ -29,9 +29,9 @@ drop table t1;
drop table t1;
set SQL_LOG_BIN=0;
create table t1 (word char(20) not null, index(word))ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t1;
+load data infile '../std_data_ln/words.dat' into table t1;
create table t2 (word char(20) not null)ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t2;
+load data infile '../std_data_ln/words.dat' into table t2;
create table t3 (word char(20) not null primary key)ENGINE=MyISAM;
load table t1 from master;
load table t2 from master;
diff --git a/mysql-test/r/rpl_loaddata2.result b/mysql-test/r/rpl_loaddata2.result
index 5e3923616ed..196093211b6 100644
--- a/mysql-test/r/rpl_loaddata2.result
+++ b/mysql-test/r/rpl_loaddata2.result
@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (word CHAR(20) NOT NULL);
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word;
word
Aarhus
diff --git a/mysql-test/r/rpl_loaddata_m.result b/mysql-test/r/rpl_loaddata_m.result
index 54348df9aaa..ec2f788a5e1 100644
--- a/mysql-test/r/rpl_loaddata_m.result
+++ b/mysql-test/r/rpl_loaddata_m.result
@@ -7,21 +7,21 @@ start slave;
drop database if exists mysqltest;
USE test;
CREATE TABLE t1(a INT, b INT, UNIQUE(b));
-LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE test.t1;
SELECT COUNT(*) FROM test.t1;
COUNT(*)
2
CREATE DATABASE mysqltest;
USE mysqltest;
CREATE TABLE t1(a INT, b INT, UNIQUE(b));
-LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
SELECT COUNT(*) FROM mysqltest.t1;
COUNT(*)
2
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
mysqltest
test
diff --git a/mysql-test/r/rpl_loadfile.result b/mysql-test/r/rpl_loadfile.result
index 7a5a7bc50c9..7487693a9f7 100644
--- a/mysql-test/r/rpl_loadfile.result
+++ b/mysql-test/r/rpl_loadfile.result
@@ -8,11 +8,11 @@ DROP PROCEDURE IF EXISTS test.p1;
DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
INSERT INTO test.t1 VALUES(1,'test');
-UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
+UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=1;
create procedure test.p1()
begin
INSERT INTO test.t1 VALUES(2,'test');
-UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
+UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=2;
end|
CALL test.p1();
SELECT * FROM test.t1 ORDER BY blob_column;
diff --git a/mysql-test/r/rpl_ndb_bank.result b/mysql-test/r/rpl_ndb_bank.result
index 2d2d54c9170..62ab3f18d37 100644
--- a/mysql-test/r/rpl_ndb_bank.result
+++ b/mysql-test/r/rpl_ndb_bank.result
@@ -47,17 +47,17 @@ CREATE DATABASE IF NOT EXISTS BANK;
DROP DATABASE BANK;
CREATE DATABASE BANK;
RESET MASTER;
-CREATE TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-DELETE FROM cluster_replication.backup_info;
-LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ',';
-SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info;
+CREATE TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM cluster.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
@the_backup_id:=backup_id
<the_backup_id>
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
@the_epoch:=MAX(epoch)
<the_epoch>
SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-FROM cluster_replication.binlog_index WHERE epoch > <the_epoch> ORDER BY epoch ASC LIMIT 1;
+FROM cluster.binlog_index WHERE epoch > <the_epoch> ORDER BY epoch ASC LIMIT 1;
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
<the_pos> master-bin.000001
CHANGE MASTER TO
diff --git a/mysql-test/r/rpl_ndb_blob.result b/mysql-test/r/rpl_ndb_blob.result
index 031b489f7da..1419875c743 100644
--- a/mysql-test/r/rpl_ndb_blob.result
+++ b/mysql-test/r/rpl_ndb_blob.result
@@ -86,41 +86,41 @@ a int not null primary key,
b text not null
) engine=ndb
master-bin.000001 239 Query 1 303 BEGIN
-master-bin.000001 303 Table_map 1 65 cluster_replication.apply_status
-master-bin.000001 368 Write_rows 1 107
-master-bin.000001 410 Table_map 1 147 test.t1
-master-bin.000001 450 Write_rows 1 818
-master-bin.000001 1121 Write_rows 1 9853
-master-bin.000001 10156 Query 1 10221 COMMIT
-master-bin.000001 10221 Query 1 10285 BEGIN
-master-bin.000001 10285 Table_map 1 65 cluster_replication.apply_status
-master-bin.000001 10350 Write_rows 1 107
-master-bin.000001 10392 Query 1 10457 COMMIT
-master-bin.000001 10457 Query 1 10533 use `test`; drop table t1
-master-bin.000001 10533 Query 1 10708 use `test`; create table t1 (
+master-bin.000001 303 Table_map 1 53 cluster.apply_status
+master-bin.000001 356 Write_rows 1 95
+master-bin.000001 398 Table_map 1 135 test.t1
+master-bin.000001 438 Write_rows 1 806
+master-bin.000001 1109 Write_rows 1 9841
+master-bin.000001 10144 Query 1 10209 COMMIT
+master-bin.000001 10209 Query 1 10273 BEGIN
+master-bin.000001 10273 Table_map 1 53 cluster.apply_status
+master-bin.000001 10326 Write_rows 1 95
+master-bin.000001 10368 Query 1 10433 COMMIT
+master-bin.000001 10433 Query 1 10509 use `test`; drop table t1
+master-bin.000001 10509 Query 1 10684 use `test`; create table t1 (
a int not null primary key,
b text not null,
c int,
d longblob,
e tinyblob
) engine=ndbcluster
-master-bin.000001 10708 Query 1 10772 BEGIN
-master-bin.000001 10772 Table_map 1 65 cluster_replication.apply_status
-master-bin.000001 10837 Write_rows 1 107
-master-bin.000001 10879 Table_map 1 150 test.t1
-master-bin.000001 10922 Write_rows 1 48934
-master-bin.000001 59706 Write_rows 1 124436
-master-bin.000001 135208 Write_rows 1 124542
-master-bin.000001 135314 Write_rows 1 205961
-master-bin.000001 216733 Write_rows 1 224245
-master-bin.000001 235017 Write_rows 1 227523
-master-bin.000001 238295 Write_rows 1 242391
-master-bin.000001 253163 Write_rows 1 254087
-master-bin.000001 264859 Write_rows 1 304335
-master-bin.000001 315107 Write_rows 1 330427
-master-bin.000001 341199 Query 1 341264 COMMIT
-master-bin.000001 341264 Query 1 341328 BEGIN
-master-bin.000001 341328 Table_map 1 65 cluster_replication.apply_status
-master-bin.000001 341393 Write_rows 1 107
-master-bin.000001 341435 Query 1 341500 COMMIT
-master-bin.000001 341500 Query 1 341576 use `test`; drop table t1
+master-bin.000001 10684 Query 1 10748 BEGIN
+master-bin.000001 10748 Table_map 1 53 cluster.apply_status
+master-bin.000001 10801 Write_rows 1 95
+master-bin.000001 10843 Table_map 1 138 test.t1
+master-bin.000001 10886 Write_rows 1 48922
+master-bin.000001 59670 Write_rows 1 124424
+master-bin.000001 135172 Write_rows 1 124530
+master-bin.000001 135278 Write_rows 1 205949
+master-bin.000001 216697 Write_rows 1 224233
+master-bin.000001 234981 Write_rows 1 227511
+master-bin.000001 238259 Write_rows 1 242379
+master-bin.000001 253127 Write_rows 1 254075
+master-bin.000001 264823 Write_rows 1 304323
+master-bin.000001 315071 Write_rows 1 330415
+master-bin.000001 341163 Query 1 341228 COMMIT
+master-bin.000001 341228 Query 1 341292 BEGIN
+master-bin.000001 341292 Table_map 1 53 cluster.apply_status
+master-bin.000001 341345 Write_rows 1 95
+master-bin.000001 341387 Query 1 341452 COMMIT
+master-bin.000001 341452 Query 1 341528 use `test`; drop table t1
diff --git a/mysql-test/r/rpl_ndb_dd_basic.result b/mysql-test/r/rpl_ndb_dd_basic.result
index 24488b8e62d..1afe235bd72 100644
--- a/mysql-test/r/rpl_ndb_dd_basic.result
+++ b/mysql-test/r/rpl_ndb_dd_basic.result
@@ -57,11 +57,11 @@ master-bin.000001 798 Query 1 978 use `test`; CREATE TABLE t1
tablespace ts1 storage disk
engine ndb
master-bin.000001 978 Query 1 1042 BEGIN
-master-bin.000001 1042 Table_map 1 65 cluster_replication.apply_status
-master-bin.000001 1107 Write_rows 1 107
-master-bin.000001 1149 Table_map 1 148 test.t1
-master-bin.000001 1190 Write_rows 1 190
-master-bin.000001 1232 Query 1 1297 COMMIT
+master-bin.000001 1042 Table_map 1 53 cluster.apply_status
+master-bin.000001 1095 Write_rows 1 95
+master-bin.000001 1137 Table_map 1 136 test.t1
+master-bin.000001 1178 Write_rows 1 178
+master-bin.000001 1220 Query 1 1285 COMMIT
drop table t1;
alter tablespace ts1
drop datafile 'datafile.dat'
diff --git a/mysql-test/r/rpl_ndb_idempotent.result b/mysql-test/r/rpl_ndb_idempotent.result
index 3315e05f97e..1ba23e703c2 100644
--- a/mysql-test/r/rpl_ndb_idempotent.result
+++ b/mysql-test/r/rpl_ndb_idempotent.result
@@ -9,14 +9,14 @@ INSERT INTO t1 VALUES ("row1","will go away",1);
SELECT * FROM t1 ORDER BY c3;
c1 c2 c3
row1 will go away 1
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
@the_epoch:=MAX(epoch)
<the_epoch>
SELECT * FROM t1 ORDER BY c3;
c1 c2 c3
row1 will go away 1
SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-FROM cluster_replication.binlog_index WHERE epoch = <the_epoch> ;
+FROM cluster.binlog_index WHERE epoch = <the_epoch> ;
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
<the_pos> master-bin.000001
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
diff --git a/mysql-test/r/rpl_ndb_log.result b/mysql-test/r/rpl_ndb_log.result
index 2fec18ad113..1396e829568 100644
--- a/mysql-test/r/rpl_ndb_log.result
+++ b/mysql-test/r/rpl_ndb_log.result
@@ -21,7 +21,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB
master-bin.000001 # Query 1 # BEGIN
-master-bin.000001 # Table_map 1 # cluster_replication.apply_status
+master-bin.000001 # Table_map 1 # cluster.apply_status
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
@@ -29,7 +29,7 @@ master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
master-bin.000001 # Query 1 # BEGIN
-master-bin.000001 # Table_map 1 # cluster_replication.apply_status
+master-bin.000001 # Table_map 1 # cluster.apply_status
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
@@ -43,7 +43,7 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in
master-bin.000001 # Query 1 # BEGIN
show binlog events from 102 limit 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Table_map 1 # cluster_replication.apply_status
+master-bin.000001 # Table_map 1 # cluster.apply_status
flush logs;
create table t3 (a int)ENGINE=NDB;
start slave;
@@ -56,7 +56,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB
master-bin.000001 # Query 1 # BEGIN
-master-bin.000001 # Table_map 1 # cluster_replication.apply_status
+master-bin.000001 # Table_map 1 # cluster.apply_status
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
@@ -64,7 +64,7 @@ master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
master-bin.000001 # Query 1 # BEGIN
-master-bin.000001 # Table_map 1 # cluster_replication.apply_status
+master-bin.000001 # Table_map 1 # cluster.apply_status
master-bin.000001 # Write_rows 1 #
master-bin.000001 # Table_map 1 # test.t1
master-bin.000001 # Write_rows 1 #
@@ -76,7 +76,7 @@ master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
master-bin.000002 # Query 1 # use `test`; create table t3 (a int)ENGINE=NDB
master-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=NDB
master-bin.000002 # Query 1 # BEGIN
-master-bin.000002 # Table_map 1 # cluster_replication.apply_status
+master-bin.000002 # Table_map 1 # cluster.apply_status
master-bin.000002 # Write_rows 1 #
master-bin.000002 # Table_map 1 # test.t2
master-bin.000002 # Write_rows 1 #
@@ -95,7 +95,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB
slave-bin.000001 # Query 2 # BEGIN
-slave-bin.000001 # Table_map 2 # cluster_replication.apply_status
+slave-bin.000001 # Table_map 2 # cluster.apply_status
slave-bin.000001 # Write_rows 2 #
slave-bin.000001 # Table_map 2 # test.t1
slave-bin.000001 # Write_rows 2 #
@@ -104,7 +104,7 @@ slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=NDB
slave-bin.000001 # Query 2 # BEGIN
-slave-bin.000001 # Table_map 2 # cluster_replication.apply_status
+slave-bin.000001 # Table_map 2 # cluster.apply_status
slave-bin.000001 # Write_rows 2 #
slave-bin.000001 # Table_map 2 # test.t1
slave-bin.000001 # Write_rows 2 #
@@ -115,7 +115,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4
slave-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=NDB
slave-bin.000002 # Query 2 # BEGIN
-slave-bin.000002 # Table_map 2 # cluster_replication.apply_status
+slave-bin.000002 # Table_map 2 # cluster.apply_status
slave-bin.000002 # Write_rows 2 #
slave-bin.000002 # Table_map 2 # test.t2
slave-bin.000002 # Write_rows 2 #
diff --git a/mysql-test/r/rpl_ndb_multi.result b/mysql-test/r/rpl_ndb_multi.result
index d3afd787613..13751060ed3 100644
--- a/mysql-test/r/rpl_ndb_multi.result
+++ b/mysql-test/r/rpl_ndb_multi.result
@@ -16,7 +16,7 @@ row1 will go away 1
SELECT * FROM t1 ORDER BY c3;
c1 c2 c3
row1 will go away 1
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
@the_epoch:=MAX(epoch)
<the_epoch>
SELECT * FROM t1 ORDER BY c3;
@@ -24,7 +24,7 @@ c1 c2 c3
row1 will go away 1
stop slave;
SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-FROM cluster_replication.binlog_index WHERE epoch = <the_epoch> ;
+FROM cluster.binlog_index WHERE epoch = <the_epoch> ;
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
102 master-bin1.000001
CHANGE MASTER TO
diff --git a/mysql-test/r/rpl_ndb_row_001.result b/mysql-test/r/rpl_ndb_row_001.result
index 20e98dab00d..56bb31e329d 100644
--- a/mysql-test/r/rpl_ndb_row_001.result
+++ b/mysql-test/r/rpl_ndb_row_001.result
@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (word CHAR(20) NOT NULL);
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word LIMIT 10;
word
diff --git a/mysql-test/r/rpl_ndb_sync.result b/mysql-test/r/rpl_ndb_sync.result
index 5f465dc427c..897737e95d5 100644
--- a/mysql-test/r/rpl_ndb_sync.result
+++ b/mysql-test/r/rpl_ndb_sync.result
@@ -25,13 +25,13 @@ hex(c2) hex(c3) c1
0 1 BCDEF
1 0 CD
0 0 DEFGHIJKL
-CREATE TEMPORARY TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT)ENGINE=HEAP;
-DELETE FROM cluster_replication.backup_info;
-LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ',';
-SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info;
+CREATE TEMPORARY TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT)ENGINE=HEAP;
+DELETE FROM cluster.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
@the_backup_id:=backup_id
<the_backup_id>
-DROP TABLE cluster_replication.backup_info;
+DROP TABLE cluster.backup_info;
UPDATE t1 SET c2=0 WHERE c3="row2";
SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
hex(c1) hex(c2) c3
@@ -60,11 +60,11 @@ hex(c2) hex(c3) c1
0 1 BCDEF
1 0 CD
0 0 DEFGHIJKL
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
@the_epoch:=MAX(epoch)
<the_epoch>
SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-FROM cluster_replication.binlog_index WHERE epoch > <the_epoch> ORDER BY epoch ASC LIMIT 1;
+FROM cluster.binlog_index WHERE epoch > <the_epoch> ORDER BY epoch ASC LIMIT 1;
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
<the_pos> master-bin.000001
CHANGE MASTER TO
@@ -89,8 +89,8 @@ hex(c2) hex(c3) c1
DROP DATABASE ndbsynctest;
STOP SLAVE;
reset master;
-select * from cluster_replication.binlog_index;
+select * from cluster.binlog_index;
Position File epoch inserts updates deletes schemaops
reset slave;
-select * from cluster_replication.apply_status;
+select * from cluster.apply_status;
server_id epoch
diff --git a/mysql-test/r/rpl_row_001.result b/mysql-test/r/rpl_row_001.result
index b07a99644fc..fad60af664f 100644
--- a/mysql-test/r/rpl_row_001.result
+++ b/mysql-test/r/rpl_row_001.result
@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (word CHAR(20) NOT NULL);
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word LIMIT 10;
word
diff --git a/mysql-test/r/rpl_row_4_bytes.result b/mysql-test/r/rpl_row_4_bytes.result
index b88d5661a90..e2431364ed3 100644
--- a/mysql-test/r/rpl_row_4_bytes.result
+++ b/mysql-test/r/rpl_row_4_bytes.result
@@ -24,4 +24,4 @@ a
ABE
ANG
LIL
-DROP TABLE t1,t2;
+DROP DATABASE mysqltest1;
diff --git a/mysql-test/r/rpl_row_basic_11bugs.result b/mysql-test/r/rpl_row_basic_11bugs.result
index 6cb71e48ecc..46ea9c26422 100644
--- a/mysql-test/r/rpl_row_basic_11bugs.result
+++ b/mysql-test/r/rpl_row_basic_11bugs.result
@@ -9,7 +9,7 @@ CREATE DATABASE test_ignore;
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
test
test_ignore
@@ -29,7 +29,7 @@ INSERT INTO t2 VALUES (3,3), (4,4);
SHOW DATABASES;
Database
information_schema
-cluster_replication
+cluster
mysql
test
USE test;
diff --git a/mysql-test/r/rpl_row_drop.result b/mysql-test/r/rpl_row_drop.result
index 4ef21884fda..a5abc2837e3 100644
--- a/mysql-test/r/rpl_row_drop.result
+++ b/mysql-test/r/rpl_row_drop.result
@@ -41,12 +41,6 @@ t1
t2
**** On Master ****
DROP TABLE t1,t2;
-SHOW BINLOG EVENTS;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4
-master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a int)
-master-bin.000001 188 Query 1 274 use `test`; CREATE TABLE t2 (a int)
-master-bin.000001 274 Query 1 378 use `test`; DROP TABLE `t1` /* generated by server */
SHOW TABLES;
Tables_in_test
t2
diff --git a/mysql-test/r/rpl_row_loaddata_m.result b/mysql-test/r/rpl_row_loaddata_m.result
index 198e55c71d0..149efddaf8d 100644
--- a/mysql-test/r/rpl_row_loaddata_m.result
+++ b/mysql-test/r/rpl_row_loaddata_m.result
@@ -9,7 +9,7 @@ stop slave;
create database mysqltest;
use mysqltest;
create table t1(a int, b int, unique(b));
-load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # #
diff --git a/mysql-test/r/rpl_row_mysqlbinlog.result b/mysql-test/r/rpl_row_mysqlbinlog.result
new file mode 100644
index 00000000000..374f2d3ee82
--- /dev/null
+++ b/mysql-test/r/rpl_row_mysqlbinlog.result
@@ -0,0 +1,266 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+
+---Setup Section --
+set timestamp=1000000000;
+DROP TABLE IF EXISTS t1,t2,t3;
+CREATE TABLE t1(word VARCHAR(20));
+CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+
+---Test1 check table load --
+SELECT COUNT(*) from t1;
+COUNT(*)
+351
+SELECT COUNT(*) from t2;
+COUNT(*)
+500
+SELECT COUNT(*) from t3;
+COUNT(*)
+500
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+word
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+id
+1
+2
+3
+4
+5
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+c1 c3 c4 c5
+1 2006-02-22 00:00:00 Tested in Texas 2.2
+2 2006-02-22 00:00:00 Tested in Texas 4.4
+3 2006-02-22 00:00:00 Tested in Texas 6.6
+4 2006-02-22 00:00:00 Tested in Texas 8.8
+5 2006-02-22 00:00:00 Tested in Texas 11
+SELECT COUNT(*) from t1;
+COUNT(*)
+351
+SELECT COUNT(*) from t2;
+COUNT(*)
+500
+SELECT COUNT(*) from t3;
+COUNT(*)
+500
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+word
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+id
+1
+2
+3
+4
+5
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+c1 c3 c4 c5
+1 2006-02-22 00:00:00 Tested in Texas 2.2
+2 2006-02-22 00:00:00 Tested in Texas 4.4
+3 2006-02-22 00:00:00 Tested in Texas 6.6
+4 2006-02-22 00:00:00 Tested in Texas 8.8
+5 2006-02-22 00:00:00 Tested in Texas 11
+insert into t1 values ("Alas");
+flush logs;
+
+--- Test 1 Dump binlog to file --
+
+--- Test 1 delete tables, clean master and slave --
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+stop slave;
+reset master;
+reset slave;
+start slave;
+
+--- Test 1 Load from Dump binlog file --
+
+--- Test 1 Check Load Results --
+SELECT COUNT(*) from t1;
+COUNT(*)
+352
+SELECT COUNT(*) from t2;
+COUNT(*)
+500
+SELECT COUNT(*) from t3;
+COUNT(*)
+500
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+word
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+id
+1
+2
+3
+4
+5
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+c1 c3 c4 c5
+1 2006-02-22 00:00:00 Tested in Texas 2.2
+2 2006-02-22 00:00:00 Tested in Texas 4.4
+3 2006-02-22 00:00:00 Tested in Texas 6.6
+4 2006-02-22 00:00:00 Tested in Texas 8.8
+5 2006-02-22 00:00:00 Tested in Texas 11
+SELECT COUNT(*) from t1;
+COUNT(*)
+352
+SELECT COUNT(*) from t2;
+COUNT(*)
+500
+SELECT COUNT(*) from t3;
+COUNT(*)
+500
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+word
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+Aarhus
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+id
+1
+2
+3
+4
+5
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+c1 c3 c4 c5
+1 2006-02-22 00:00:00 Tested in Texas 2.2
+2 2006-02-22 00:00:00 Tested in Texas 4.4
+3 2006-02-22 00:00:00 Tested in Texas 6.6
+4 2006-02-22 00:00:00 Tested in Texas 8.8
+5 2006-02-22 00:00:00 Tested in Texas 11
+
+--- Test 2 position test --
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+use test;
+SET TIMESTAMP=1000000000;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
+SET @@session.sql_mode=0;
+/*!\C latin1 */;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- Test 3 First Remote test --
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+ROLLBACK;
+use test;
+SET TIMESTAMP=1000000000;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
+SET @@session.sql_mode=0;
+/*!\C latin1 */;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
+DROP TABLE IF EXISTS t1,t2,t3;
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1(word VARCHAR(20));
+SET TIMESTAMP=1000000000;
+CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
+SET TIMESTAMP=1000000000;
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- Test 5 LOAD DATA --
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- Test 6 reading stdin --
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+ROLLBACK;
+use test;
+SET TIMESTAMP=1000000000;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
+SET @@session.sql_mode=0;
+/*!\C latin1 */;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
+DROP TABLE IF EXISTS t1,t2,t3;
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1(word VARCHAR(20));
+SET TIMESTAMP=1000000000;
+CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
+SET TIMESTAMP=1000000000;
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- Test 7 reading stdin w/position --
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+use test;
+SET TIMESTAMP=1000000000;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
+SET @@session.sql_mode=0;
+/*!\C latin1 */;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- Test 8 switch internal charset --
+stop slave;
+reset master;
+reset slave;
+start slave;
+create table t4 (f text character set utf8);
+create table t5 (f text character set cp932);
+flush logs;
+rename table t4 to t04, t5 to t05;
+select HEX(f) from t04;
+HEX(f)
+E382BD
+select HEX(f) from t4;
+HEX(f)
+E382BD
+select HEX(f) from t05;
+HEX(f)
+835C
+select HEX(f) from t5;
+HEX(f)
+835C
+select HEX(f) from t04;
+HEX(f)
+E382BD
+select HEX(f) from t4;
+HEX(f)
+E382BD
+select HEX(f) from t05;
+HEX(f)
+835C
+select HEX(f) from t5;
+HEX(f)
+835C
+
+--- Test cleanup --
+DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
diff --git a/mysql-test/r/rpl_row_sp010.result b/mysql-test/r/rpl_row_sp010.result
index ba97f83b86a..02567465428 100644
--- a/mysql-test/r/rpl_row_sp010.result
+++ b/mysql-test/r/rpl_row_sp010.result
@@ -22,7 +22,7 @@ INSERT INTO test.t1 VALUES(1);
CALL test.p1();
END|
CALL test.p2();
-SELECT * FROM test.t1;
+SELECT * FROM test.t1 ORDER BY a;
a
1
2
@@ -40,11 +40,11 @@ INSERT INTO test.t2 VALUES(6);
CALL test.p3();
END|
CALL test.p4();
-SELECT * FROM test.t2;
+SELECT * FROM test.t2 ORDER BY a;
a
6
7
-SELECT * FROM test.t2;
+SELECT * FROM test.t2 ORDER BY a;
a
6
7
diff --git a/mysql-test/r/rpl_row_stop_middle_update.result b/mysql-test/r/rpl_row_stop_middle_update.result
index 584a3af4543..0fd4ff86893 100644
--- a/mysql-test/r/rpl_row_stop_middle_update.result
+++ b/mysql-test/r/rpl_row_stop_middle_update.result
@@ -5,7 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (words varchar(20)) engine=myisam;
-load data infile '../../std_data/words.dat' into table t1 (words);
+load data infile '../std_data_ln/words.dat' into table t1 (words);
select count(*) from t1;
count(*)
70
diff --git a/mysql-test/r/rpl_switch_stm_row_mixed.result b/mysql-test/r/rpl_switch_stm_row_mixed.result
new file mode 100644
index 00000000000..3459320b59d
--- /dev/null
+++ b/mysql-test/r/rpl_switch_stm_row_mixed.result
@@ -0,0 +1,224 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+drop database if exists mysqltest1;
+create database mysqltest1;
+use mysqltest1;
+show global variables like "binlog_format%";
+Variable_name Value
+binlog_format ROW
+show session variables like "binlog_format%";
+Variable_name Value
+binlog_format ROW
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+ROW ROW
+CREATE TABLE t1 (a varchar(100));
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+create temporary table tmp(a char(3));
+insert into tmp values("see");
+set binlog_format=statement;
+ERROR HY000: Cannot switch out of the row-based binary log format when the session has open temporary tables
+insert into t1 select * from tmp;
+drop temporary table tmp;
+set binlog_format=statement;
+show global variables like "binlog_format%";
+Variable_name Value
+binlog_format ROW
+show session variables like "binlog_format%";
+Variable_name Value
+binlog_format STATEMENT
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+ROW STATEMENT
+set global binlog_format=statement;
+show global variables like "binlog_format%";
+Variable_name Value
+binlog_format STATEMENT
+show session variables like "binlog_format%";
+Variable_name Value
+binlog_format STATEMENT
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+STATEMENT STATEMENT
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+insert into t1 values("for");
+insert into t1 select "yesterday";
+set binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+STATEMENT STATEMENT
+set global binlog_format=default;
+ERROR 42000: Variable 'binlog_format' doesn't have a default value
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+STATEMENT STATEMENT
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+insert into t1 values("for");
+insert into t1 select "yesterday";
+set binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+STATEMENT MIXED
+set global binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+@@global.binlog_format @@session.binlog_format
+MIXED MIXED
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+create procedure foo()
+begin
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+end|
+create procedure foo2()
+begin
+insert into t1 values(concat("emergency",UUID()));
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+set session binlog_format=row; # accepted for stored procs
+insert into t1 values("more work");
+set session binlog_format=mixed;
+end|
+create function foo3() returns bigint unsigned
+begin
+set session binlog_format=row; # rejected for stored funcs
+insert into t1 values("alarm");
+return 100;
+end|
+call foo();
+call foo2();
+select foo3();
+ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
+select * from t1 where a="alarm";
+a
+show binlog events from 102;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 102 Query 1 205 drop database if exists mysqltest1
+master-bin.000001 205 Query 1 300 create database mysqltest1
+master-bin.000001 300 Query 1 401 use `mysqltest1`; CREATE TABLE t1 (a varchar(100))
+master-bin.000001 401 Table_map 1 446 mysqltest1.t1
+master-bin.000001 446 Write_rows 1 481
+master-bin.000001 481 Table_map 1 526 mysqltest1.t1
+master-bin.000001 526 Write_rows 1 602
+master-bin.000001 602 Table_map 1 647 mysqltest1.t1
+master-bin.000001 647 Write_rows 1 718
+master-bin.000001 718 Table_map 1 763 mysqltest1.t1
+master-bin.000001 763 Write_rows 1 803
+master-bin.000001 803 Table_map 1 848 mysqltest1.t1
+master-bin.000001 848 Write_rows 1 918
+master-bin.000001 918 Table_map 1 963 mysqltest1.t1
+master-bin.000001 963 Write_rows 1 1003
+master-bin.000001 1003 Table_map 1 1048 mysqltest1.t1
+master-bin.000001 1048 Write_rows 1 1082
+master-bin.000001 1082 Query 1 1180 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 1180 User var 1 1228 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 1228 Query 1 1328 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 1328 Query 1 1426 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 1426 User var 1 1474 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 1474 Query 1 1574 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 1574 Query 1 1671 use `mysqltest1`; insert into t1 values("for")
+master-bin.000001 1671 Query 1 1773 use `mysqltest1`; insert into t1 select "yesterday"
+master-bin.000001 1773 Query 1 1871 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 1871 User var 1 1919 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 1919 Query 1 2019 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 2019 Query 1 2117 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 2117 User var 1 2165 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 2165 Query 1 2265 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 2265 Query 1 2362 use `mysqltest1`; insert into t1 values("for")
+master-bin.000001 2362 Query 1 2464 use `mysqltest1`; insert into t1 select "yesterday"
+master-bin.000001 2464 Query 1 2562 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 2562 Table_map 1 2607 mysqltest1.t1
+master-bin.000001 2607 Write_rows 1 2683
+master-bin.000001 2683 Table_map 1 2728 mysqltest1.t1
+master-bin.000001 2728 Write_rows 1 2799
+master-bin.000001 2799 User var 1 2847 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 2847 Query 1 2947 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 2947 Table_map 1 2992 mysqltest1.t1
+master-bin.000001 2992 Write_rows 1 3062
+master-bin.000001 3062 Query 1 3164 use `mysqltest1`; insert into t1 select "yesterday"
+master-bin.000001 3164 Table_map 1 3209 mysqltest1.t1
+master-bin.000001 3209 Write_rows 1 3280
+master-bin.000001 3280 User var 1 3328 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
+master-bin.000001 3328 Query 1 3428 use `mysqltest1`; insert into t1 select @'string'
+master-bin.000001 3428 Table_map 1 3473 mysqltest1.t1
+master-bin.000001 3473 Write_rows 1 3543
+master-bin.000001 3543 Query 1 3645 use `mysqltest1`; insert into t1 select "yesterday"
+master-bin.000001 3645 Query 1 3857 use `mysqltest1`; create procedure foo()
+begin
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+end
+master-bin.000001 3857 Query 1 4214 use `mysqltest1`; create procedure foo2()
+begin
+insert into t1 values(concat("emergency",UUID()));
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+set session binlog_format=row; # accepted for stored procs
+insert into t1 values("more work");
+set session binlog_format=mixed;
+end
+master-bin.000001 4214 Query 1 4442 use `mysqltest1`; create function foo3() returns bigint unsigned
+begin
+set session binlog_format=row; # rejected for stored funcs
+insert into t1 values("alarm");
+return 100;
+end
+master-bin.000001 4442 Query 1 4548 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 4548 Table_map 1 4593 mysqltest1.t1
+master-bin.000001 4593 Write_rows 1 4663
+master-bin.000001 4663 Query 1 4773 use `mysqltest1`; insert into t1 select "yesterday"
+master-bin.000001 4773 Table_map 1 4818 mysqltest1.t1
+master-bin.000001 4818 Write_rows 1 4894
+master-bin.000001 4894 Query 1 5000 use `mysqltest1`; insert into t1 values("work")
+master-bin.000001 5000 Table_map 1 5045 mysqltest1.t1
+master-bin.000001 5045 Write_rows 1 5115
+master-bin.000001 5115 Table_map 1 5160 mysqltest1.t1
+master-bin.000001 5160 Write_rows 1 5200
+drop database mysqltest1;
diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result
index a1b3fa9f1b3..8ed1a587588 100644
--- a/mysql-test/r/schema.result
+++ b/mysql-test/r/schema.result
@@ -6,7 +6,7 @@ foo CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET latin1 */
show schemas;
Database
information_schema
-cluster_replication
+cluster
foo
mysql
test
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 59e9cca1e8e..a8af5c59b81 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -53,7 +53,7 @@ Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length I
show databases;
Database
information_schema
-cluster_replication
+cluster
mysql
test
show databases like "test%";
diff --git a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result
index 5dc770a7363..95464ee4ce5 100644
--- a/mysql-test/r/skip_grants.result
+++ b/mysql-test/r/skip_grants.result
@@ -12,3 +12,6 @@ create table t1 (a int);
create definer='user'@'host' sql security definer view v1 as select * from t1;
drop view v1;
drop table t1;
+drop function if exists f1;
+Warnings:
+Note 1305 FUNCTION f1 does not exist
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index fc29f915b82..5ab8779782a 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1163,3 +1163,6 @@ end|
call bug15091();
ERROR 42S02: Unknown table 'c' in field list
drop procedure bug15091;
+drop function if exists bug16896;
+create aggregate function bug16896() returns int return 1;
+ERROR 42000: AGGREGATE is not supported for stored functions
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index ff729e87f97..a1a197cb9d6 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -314,3 +314,12 @@ select * from db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
drop user user_bug14533@localhost;
drop database db_bug14533;
+CREATE DATABASE db_bug7787;
+use db_bug7787;
+CREATE PROCEDURE p1()
+SHOW INNODB STATUS;
+Warnings:
+Warning 1540 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW ENGINE INNODB STATUS' instead.
+GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
+DROP DATABASE db_bug7787;
+use test;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 7b2edd98a5b..50ab0e9d9eb 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -539,7 +539,7 @@ drop procedure if exists into_outfile|
create procedure into_outfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
-select * into outfile "/tmp/spout" from test.t1;
+select * into outfile "../tmp/spout" from test.t1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_outfile("ofile", 1)|
@@ -549,7 +549,7 @@ drop procedure if exists into_dumpfile|
create procedure into_dumpfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
-select * into dumpfile "/tmp/spdump" from test.t1 limit 1;
+select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
call into_dumpfile("dfile", 1)|
@@ -1413,8 +1413,6 @@ select `foo` ()|
5
drop function `foo`|
drop function if exists t1max|
-Warnings:
-Note 1305 FUNCTION t1max does not exist
create function t1max() returns int
begin
declare x int;
@@ -1470,6 +1468,339 @@ zip 3
foo 1
drop table t3|
drop function getcount|
+drop table if exists t3|
+drop procedure if exists h_ee|
+drop procedure if exists h_es|
+drop procedure if exists h_en|
+drop procedure if exists h_ew|
+drop procedure if exists h_ex|
+drop procedure if exists h_se|
+drop procedure if exists h_ss|
+drop procedure if exists h_sn|
+drop procedure if exists h_sw|
+drop procedure if exists h_sx|
+drop procedure if exists h_ne|
+drop procedure if exists h_ns|
+drop procedure if exists h_nn|
+drop procedure if exists h_we|
+drop procedure if exists h_ws|
+drop procedure if exists h_ww|
+drop procedure if exists h_xe|
+drop procedure if exists h_xs|
+drop procedure if exists h_xx|
+create table t3 (a smallint primary key)|
+insert into t3 (a) values (1)|
+create procedure h_ee()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (bad)' as 'h_ee';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_ee';
+insert into t3 values (1);
+end;
+end|
+create procedure h_es()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (good)' as 'h_es';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+ select 'Inner (bad)' as 'h_es';
+insert into t3 values (1);
+end;
+end|
+create procedure h_en()
+deterministic
+begin
+declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+select 'Outer (good)' as 'h_en';
+begin
+declare x int;
+declare continue handler for sqlstate '02000' -- no data
+select 'Inner (bad)' as 'h_en';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_ew()
+deterministic
+begin
+declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+select 'Outer (good)' as 'h_ew';
+begin
+declare continue handler for sqlwarning
+select 'Inner (bad)' as 'h_ew';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ex()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (good)' as 'h_ex';
+begin
+declare continue handler for sqlexception
+select 'Inner (bad)' as 'h_ex';
+insert into t3 values (1);
+end;
+end|
+create procedure h_se()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (bad)' as 'h_se';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_se';
+insert into t3 values (1);
+end;
+end|
+create procedure h_ss()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (bad)' as 'h_ss';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Inner (good)' as 'h_ss';
+insert into t3 values (1);
+end;
+end|
+create procedure h_sn()
+deterministic
+begin
+-- Note: '02000' is more specific than NOT FOUND ;
+-- there might be other not found states
+declare continue handler for sqlstate '02000' -- no data
+select 'Outer (good)' as 'h_sn';
+begin
+declare x int;
+declare continue handler for not found
+select 'Inner (bad)' as 'h_sn';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_sw()
+deterministic
+begin
+-- data exception - numeric value out of range
+declare continue handler for sqlstate '22003'
+ select 'Outer (good)' as 'h_sw';
+begin
+declare continue handler for sqlwarning
+select 'Inner (bad)' as 'h_sw';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_sx()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (good)' as 'h_sx';
+begin
+declare continue handler for sqlexception
+select 'Inner (bad)' as 'h_sx';
+insert into t3 values (1);
+end;
+end|
+create procedure h_ne()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_ne';
+begin
+declare x int;
+declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+select 'Inner (good)' as 'h_ne';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_ns()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_ns';
+begin
+declare x int;
+declare continue handler for sqlstate '02000' -- no data
+select 'Inner (good)' as 'h_ns';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_nn()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_nn';
+begin
+declare x int;
+declare continue handler for not found
+select 'Inner (good)' as 'h_nn';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_we()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_we';
+begin
+declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+select 'Inner (good)' as 'h_we';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ws()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_ws';
+begin
+-- data exception - numeric value out of range
+declare continue handler for sqlstate '22003'
+ select 'Inner (good)' as 'h_ws';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ww()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_ww';
+begin
+declare continue handler for sqlwarning
+select 'Inner (good)' as 'h_ww';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_xe()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xe';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_xe';
+insert into t3 values (1);
+end;
+end|
+create procedure h_xs()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xs';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_xs';
+insert into t3 values (1);
+end;
+end|
+create procedure h_xx()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xx';
+begin
+declare continue handler for sqlexception
+select 'Inner (good)' as 'h_xx';
+insert into t3 values (1);
+end;
+end|
+call h_ee()|
+h_ee
+Inner (good)
+call h_es()|
+h_es
+Outer (good)
+call h_en()|
+h_en
+Outer (good)
+call h_ew()|
+h_ew
+Outer (good)
+call h_ex()|
+h_ex
+Outer (good)
+call h_se()|
+h_se
+Inner (good)
+call h_ss()|
+h_ss
+Inner (good)
+call h_sn()|
+h_sn
+Outer (good)
+call h_sw()|
+h_sw
+Outer (good)
+call h_sx()|
+h_sx
+Outer (good)
+call h_ne()|
+h_ne
+Inner (good)
+call h_ns()|
+h_ns
+Inner (good)
+call h_nn()|
+h_nn
+Inner (good)
+call h_we()|
+h_we
+Inner (good)
+call h_ws()|
+h_ws
+Inner (good)
+call h_ww()|
+h_ww
+Inner (good)
+call h_xe()|
+h_xe
+Inner (good)
+call h_xs()|
+h_xs
+Inner (good)
+call h_xx()|
+h_xx
+Inner (good)
+drop table t3|
+drop procedure h_ee|
+drop procedure h_es|
+drop procedure h_en|
+drop procedure h_ew|
+drop procedure h_ex|
+drop procedure h_se|
+drop procedure h_ss|
+drop procedure h_sn|
+drop procedure h_sw|
+drop procedure h_sx|
+drop procedure h_ne|
+drop procedure h_ns|
+drop procedure h_nn|
+drop procedure h_we|
+drop procedure h_ws|
+drop procedure h_ww|
+drop procedure h_xe|
+drop procedure h_xs|
+drop procedure h_xx|
drop procedure if exists bug822|
create procedure bug822(a_id char(16), a_data int)
begin
@@ -2170,7 +2501,7 @@ Create view Tables To create new views
Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
-Event Server Admin Creation, alteration, deletion and execution of events.
+Event Server Admin To create, alter, drop and execute events
Execute Functions,Procedures To execute stored routines
File File access on server To read and write files on the server
Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
@@ -2224,7 +2555,7 @@ Create view Tables To create new views
Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
-Event Server Admin Creation, alteration, deletion and execution of events.
+Event Server Admin To create, alter, drop and execute events
Execute Functions,Procedures To execute stored routines
File File access on server To read and write files on the server
Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
@@ -4447,4 +4778,23 @@ Handler
Inner
drop procedure bug15011|
drop table t3|
+drop procedure if exists bug17476|
+create table t3 ( d date )|
+insert into t3 values
+( '2005-01-01' ), ( '2005-01-02' ), ( '2005-01-03' ),
+( '2005-01-04' ), ( '2005-02-01' ), ( '2005-02-02' )|
+create procedure bug17476(pDateFormat varchar(10))
+select date_format(t3.d, pDateFormat), count(*)
+from t3
+group by date_format(t3.d, pDateFormat)|
+call bug17476('%Y-%m')|
+date_format(t3.d, pDateFormat) count(*)
+2005-01 4
+2005-02 2
+call bug17476('%Y-%m')|
+date_format(t3.d, pDateFormat) count(*)
+2005-01 4
+2005-02 2
+drop table t3|
+drop procedure bug17476|
drop table t1,t2;
diff --git a/mysql-test/r/sp.result.orig b/mysql-test/r/sp.result.orig
new file mode 100644
index 00000000000..663204681f2
--- /dev/null
+++ b/mysql-test/r/sp.result.orig
@@ -0,0 +1,4853 @@
+use test;
+drop table if exists t1,t2,t3,t4;
+create table t1 (
+id char(16) not null default '',
+data int not null
+);
+create table t2 (
+s char(16),
+i int,
+d double
+);
+drop procedure if exists foo42;
+create procedure foo42()
+insert into test.t1 values ("foo", 42);
+call foo42();
+select * from t1;
+id data
+foo 42
+delete from t1;
+drop procedure foo42;
+drop procedure if exists bar;
+create procedure bar(x char(16), y int)
+insert into test.t1 values (x, y);
+call bar("bar", 666);
+select * from t1;
+id data
+bar 666
+delete from t1;
+drop procedure if exists empty|
+create procedure empty()
+begin
+end|
+call empty()|
+drop procedure empty|
+drop procedure if exists scope|
+create procedure scope(a int, b float)
+begin
+declare b int;
+declare c float;
+begin
+declare c int;
+end;
+end|
+drop procedure scope|
+drop procedure if exists two|
+create procedure two(x1 char(16), x2 char(16), y int)
+begin
+insert into test.t1 values (x1, y);
+insert into test.t1 values (x2, y);
+end|
+call two("one", "two", 3)|
+select * from t1|
+id data
+one 3
+two 3
+delete from t1|
+drop procedure two|
+drop procedure if exists locset|
+create procedure locset(x char(16), y int)
+begin
+declare z1, z2 int;
+set z1 = y;
+set z2 = z1+2;
+insert into test.t1 values (x, z2);
+end|
+call locset("locset", 19)|
+select * from t1|
+id data
+locset 21
+delete from t1|
+drop procedure locset|
+drop procedure if exists setcontext|
+create procedure setcontext()
+begin
+declare data int default 2;
+insert into t1 (id, data) values ("foo", 1);
+replace t1 set data = data, id = "bar";
+update t1 set id = "kaka", data = 3 where t1.data = data;
+end|
+call setcontext()|
+select * from t1|
+id data
+foo 1
+kaka 3
+delete from t1|
+drop procedure setcontext|
+create table t3 ( d date, i int, f double, s varchar(32) )|
+drop procedure if exists nullset|
+create procedure nullset()
+begin
+declare ld date;
+declare li int;
+declare lf double;
+declare ls varchar(32);
+set ld = null, li = null, lf = null, ls = null;
+insert into t3 values (ld, li, lf, ls);
+insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
+((li is null), 1, "li is null"),
+((li = 0), null, "li = 0"),
+((lf is null), 1, "lf is null"),
+((lf = 0), null, "lf = 0"),
+((ls is null), 1, "ls is null");
+end|
+call nullset()|
+select * from t3|
+d i f s
+NULL NULL NULL NULL
+NULL 1 1 ld is null
+NULL 1 1 li is null
+NULL NULL NULL li = 0
+NULL 1 1 lf is null
+NULL NULL NULL lf = 0
+NULL 1 1 ls is null
+drop table t3|
+drop procedure nullset|
+drop procedure if exists mixset|
+create procedure mixset(x char(16), y int)
+begin
+declare z int;
+set @z = y, z = 666, max_join_size = 100;
+insert into test.t1 values (x, z);
+end|
+call mixset("mixset", 19)|
+show variables like 'max_join_size'|
+Variable_name Value
+max_join_size 100
+select id,data,@z from t1|
+id data @z
+mixset 666 19
+delete from t1|
+drop procedure mixset|
+drop procedure if exists zip|
+create procedure zip(x char(16), y int)
+begin
+declare z int;
+call zap(y, z);
+call bar(x, z);
+end|
+drop procedure if exists zap|
+create procedure zap(x int, out y int)
+begin
+declare z int;
+set z = x+1, y = z;
+end|
+call zip("zip", 99)|
+select * from t1|
+id data
+zip 100
+delete from t1|
+drop procedure zip|
+drop procedure bar|
+call zap(7, @zap)|
+select @zap|
+@zap
+8
+drop procedure zap|
+drop procedure if exists c1|
+create procedure c1(x int)
+call c2("c", x)|
+drop procedure if exists c2|
+create procedure c2(s char(16), x int)
+call c3(x, s)|
+drop procedure if exists c3|
+create procedure c3(x int, s char(16))
+call c4("level", x, s)|
+drop procedure if exists c4|
+create procedure c4(l char(8), x int, s char(16))
+insert into t1 values (concat(l,s), x)|
+call c1(42)|
+select * from t1|
+id data
+levelc 42
+delete from t1|
+drop procedure c1|
+drop procedure c2|
+drop procedure c3|
+drop procedure c4|
+drop procedure if exists iotest|
+create procedure iotest(x1 char(16), x2 char(16), y int)
+begin
+call inc2(x2, y);
+insert into test.t1 values (x1, y);
+end|
+drop procedure if exists inc2|
+create procedure inc2(x char(16), y int)
+begin
+call inc(y);
+insert into test.t1 values (x, y);
+end|
+drop procedure if exists inc|
+create procedure inc(inout io int)
+set io = io + 1|
+call iotest("io1", "io2", 1)|
+select * from t1|
+id data
+io2 2
+io1 1
+delete from t1|
+drop procedure iotest|
+drop procedure inc2|
+drop procedure if exists incr|
+create procedure incr(inout x int)
+call inc(x)|
+select @zap|
+@zap
+8
+call incr(@zap)|
+select @zap|
+@zap
+9
+drop procedure inc|
+drop procedure incr|
+drop procedure if exists cbv1|
+create procedure cbv1()
+begin
+declare y int default 3;
+call cbv2(y+1, y);
+insert into test.t1 values ("cbv1", y);
+end|
+drop procedure if exists cbv2|
+create procedure cbv2(y1 int, inout y2 int)
+begin
+set y2 = 4711;
+insert into test.t1 values ("cbv2", y1);
+end|
+call cbv1()|
+select * from t1|
+id data
+cbv2 4
+cbv1 4711
+delete from t1|
+drop procedure cbv1|
+drop procedure cbv2|
+insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
+drop procedure if exists sub1|
+create procedure sub1(id char(16), x int)
+insert into test.t1 values (id, x)|
+drop procedure if exists sub2|
+create procedure sub2(id char(16))
+begin
+declare x int;
+set x = (select sum(t.i) from test.t2 t);
+insert into test.t1 values (id, x);
+end|
+drop procedure if exists sub3|
+create function sub3(i int) returns int
+return i+1|
+call sub1("sub1a", (select 7))|
+call sub1("sub1b", (select max(i) from t2))|
+call sub1("sub1c", (select i,d from t2 limit 1))|
+ERROR 21000: Operand should contain 1 column(s)
+call sub1("sub1d", (select 1 from (select 1) a))|
+call sub2("sub2")|
+select * from t1|
+id data
+sub1a 7
+sub1b 3
+sub1d 1
+sub2 6
+select sub3((select max(i) from t2))|
+sub3((select max(i) from t2))
+4
+drop procedure sub1|
+drop procedure sub2|
+drop function sub3|
+delete from t1|
+delete from t2|
+drop procedure if exists a0|
+create procedure a0(x int)
+while x do
+set x = x-1;
+insert into test.t1 values ("a0", x);
+end while|
+call a0(3)|
+select * from t1|
+id data
+a0 2
+a0 1
+a0 0
+delete from t1|
+drop procedure a0|
+drop procedure if exists a|
+create procedure a(x int)
+while x > 0 do
+set x = x-1;
+insert into test.t1 values ("a", x);
+end while|
+call a(3)|
+select * from t1|
+id data
+a 2
+a 1
+a 0
+delete from t1|
+drop procedure a|
+drop procedure if exists b|
+create procedure b(x int)
+repeat
+insert into test.t1 values (repeat("b",3), x);
+set x = x-1;
+until x = 0 end repeat|
+call b(3)|
+select * from t1|
+id data
+bbb 3
+bbb 2
+bbb 1
+delete from t1|
+drop procedure b|
+drop procedure if exists b2|
+create procedure b2(x int)
+repeat(select 1 into outfile 'b2');
+insert into test.t1 values (repeat("b2",3), x);
+set x = x-1;
+until x = 0 end repeat|
+drop procedure b2|
+drop procedure if exists c|
+create procedure c(x int)
+hmm: while x > 0 do
+insert into test.t1 values ("c", x);
+set x = x-1;
+iterate hmm;
+insert into test.t1 values ("x", x);
+end while hmm|
+call c(3)|
+select * from t1|
+id data
+c 3
+c 2
+c 1
+delete from t1|
+drop procedure c|
+drop procedure if exists d|
+create procedure d(x int)
+hmm: while x > 0 do
+insert into test.t1 values ("d", x);
+set x = x-1;
+leave hmm;
+insert into test.t1 values ("x", x);
+end while|
+call d(3)|
+select * from t1|
+id data
+d 3
+delete from t1|
+drop procedure d|
+drop procedure if exists e|
+create procedure e(x int)
+foo: loop
+if x = 0 then
+leave foo;
+end if;
+insert into test.t1 values ("e", x);
+set x = x-1;
+end loop foo|
+call e(3)|
+select * from t1|
+id data
+e 3
+e 2
+e 1
+delete from t1|
+drop procedure e|
+drop procedure if exists f|
+create procedure f(x int)
+if x < 0 then
+insert into test.t1 values ("f", 0);
+elseif x = 0 then
+insert into test.t1 values ("f", 1);
+else
+insert into test.t1 values ("f", 2);
+end if|
+call f(-2)|
+call f(0)|
+call f(4)|
+select * from t1|
+id data
+f 0
+f 1
+f 2
+delete from t1|
+drop procedure f|
+drop procedure if exists g|
+create procedure g(x int)
+case
+when x < 0 then
+insert into test.t1 values ("g", 0);
+when x = 0 then
+insert into test.t1 values ("g", 1);
+else
+insert into test.t1 values ("g", 2);
+end case|
+call g(-42)|
+call g(0)|
+call g(1)|
+select * from t1|
+id data
+g 0
+g 1
+g 2
+delete from t1|
+drop procedure g|
+drop procedure if exists h|
+create procedure h(x int)
+case x
+when 0 then
+insert into test.t1 values ("h0", x);
+when 1 then
+insert into test.t1 values ("h1", x);
+else
+insert into test.t1 values ("h?", x);
+end case|
+call h(0)|
+call h(1)|
+call h(17)|
+select * from t1|
+id data
+h0 0
+h1 1
+h? 17
+delete from t1|
+drop procedure h|
+drop procedure if exists i|
+create procedure i(x int)
+foo:
+begin
+if x = 0 then
+leave foo;
+end if;
+insert into test.t1 values ("i", x);
+end foo|
+call i(0)|
+call i(3)|
+select * from t1|
+id data
+i 3
+delete from t1|
+drop procedure i|
+insert into t1 values ("foo", 3), ("bar", 19)|
+insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
+drop procedure if exists sel1|
+create procedure sel1()
+begin
+select * from t1;
+end|
+call sel1()|
+id data
+foo 3
+bar 19
+drop procedure sel1|
+drop procedure if exists sel2|
+create procedure sel2()
+begin
+select * from t1;
+select * from t2;
+end|
+call sel2()|
+id data
+foo 3
+bar 19
+s i d
+x 9 4.1
+y -1 19.2
+z 3 2.2
+drop procedure sel2|
+delete from t1|
+delete from t2|
+drop procedure if exists into_test|
+create procedure into_test(x char(16), y int)
+begin
+insert into test.t1 values (x, y);
+select id,data into x,y from test.t1 limit 1;
+insert into test.t1 values (concat(x, "2"), y+2);
+end|
+call into_test("into", 100)|
+select * from t1|
+id data
+into 100
+into2 102
+delete from t1|
+drop procedure into_test|
+drop procedure if exists into_tes2|
+create procedure into_test2(x char(16), y int)
+begin
+insert into test.t1 values (x, y);
+select id,data into x,@z from test.t1 limit 1;
+insert into test.t1 values (concat(x, "2"), y+2);
+end|
+call into_test2("into", 100)|
+select id,data,@z from t1|
+id data @z
+into 100 100
+into2 102 100
+delete from t1|
+drop procedure into_test2|
+drop procedure if exists into_test3|
+create procedure into_test3()
+begin
+declare x char(16);
+declare y int;
+select * into x,y from test.t1 limit 1;
+insert into test.t2 values (x, y, 0.0);
+end|
+insert into t1 values ("into3", 19)|
+call into_test3()|
+call into_test3()|
+select * from t2|
+s i d
+into3 19 0
+into3 19 0
+delete from t1|
+delete from t2|
+drop procedure into_test3|
+drop procedure if exists into_test4|
+create procedure into_test4()
+begin
+declare x int;
+select data into x from test.t1 limit 1;
+insert into test.t3 values ("into4", x);
+end|
+delete from t1|
+create table t3 ( s char(16), d int)|
+call into_test4()|
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+select * from t3|
+s d
+into4 NULL
+insert into t1 values ("i4", 77)|
+call into_test4()|
+select * from t3|
+s d
+into4 NULL
+into4 77
+delete from t1|
+drop table t3|
+drop procedure into_test4|
+drop procedure if exists into_outfile|
+create procedure into_outfile(x char(16), y int)
+begin
+insert into test.t1 values (x, y);
+select * into outfile "../tmp/spout" from test.t1;
+insert into test.t1 values (concat(x, "2"), y+2);
+end|
+call into_outfile("ofile", 1)|
+delete from t1|
+drop procedure into_outfile|
+drop procedure if exists into_dumpfile|
+create procedure into_dumpfile(x char(16), y int)
+begin
+insert into test.t1 values (x, y);
+select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
+insert into test.t1 values (concat(x, "2"), y+2);
+end|
+call into_dumpfile("dfile", 1)|
+delete from t1|
+drop procedure into_dumpfile|
+drop procedure if exists create_select|
+create procedure create_select(x char(16), y int)
+begin
+insert into test.t1 values (x, y);
+create temporary table test.t3 select * from test.t1;
+insert into test.t3 values (concat(x, "2"), y+2);
+end|
+call create_select("cs", 90)|
+select * from t1, t3|
+id data id data
+cs 90 cs 90
+cs 90 cs2 92
+drop table t3|
+delete from t1|
+drop procedure create_select|
+drop function if exists e|
+create function e() returns double
+return 2.7182818284590452354|
+set @e = e()|
+select e(), @e|
+e() @e
+2.718281828459 2.718281828459
+drop function if exists inc|
+create function inc(i int) returns int
+return i+1|
+select inc(1), inc(99), inc(-71)|
+inc(1) inc(99) inc(-71)
+2 100 -70
+drop function if exists mul|
+create function mul(x int, y int) returns int
+return x*y|
+select mul(1,1), mul(3,5), mul(4711, 666)|
+mul(1,1) mul(3,5) mul(4711, 666)
+1 15 3137526
+drop function if exists append|
+create function append(s1 char(8), s2 char(8)) returns char(16)
+return concat(s1, s2)|
+select append("foo", "bar")|
+append("foo", "bar")
+foobar
+drop function if exists fac|
+create function fac(n int unsigned) returns bigint unsigned
+begin
+declare f bigint unsigned default 1;
+while n > 1 do
+set f = f * n;
+set n = n - 1;
+end while;
+return f;
+end|
+select fac(1), fac(2), fac(5), fac(10)|
+fac(1) fac(2) fac(5) fac(10)
+1 2 120 3628800
+drop function if exists fun|
+create function fun(d double, i int, u int unsigned) returns double
+return mul(inc(i), fac(u)) / e()|
+select fun(2.3, 3, 5)|
+fun(2.3, 3, 5)
+176.58213176229
+insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
+insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
+select * from t2 where s = append("a", "b")|
+s i d
+ab 24 1324.36598821719
+select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
+s i d
+xxxyyy 12 2.71828182845905
+ab 24 1324.36598821719
+select * from t2 where d = e()|
+s i d
+xxxyyy 12 2.71828182845905
+select * from t2|
+s i d
+xxxyyy 12 2.71828182845905
+ab 24 1324.36598821719
+delete from t2|
+drop function e|
+drop function inc|
+drop function mul|
+drop function append|
+drop function fun|
+drop procedure if exists hndlr1|
+create procedure hndlr1(val int)
+begin
+declare x int default 0;
+declare foo condition for 1136;
+declare bar condition for sqlstate '42S98'; # Just for testing syntax
+declare zip condition for sqlstate value '42S99'; # Just for testing syntax
+declare continue handler for foo set x = 1;
+insert into test.t1 values ("hndlr1", val, 2); # Too many values
+if (x) then
+insert into test.t1 values ("hndlr1", val); # This instead then
+end if;
+end|
+call hndlr1(42)|
+select * from t1|
+id data
+hndlr1 42
+delete from t1|
+drop procedure hndlr1|
+drop procedure if exists hndlr2|
+create procedure hndlr2(val int)
+begin
+declare x int default 0;
+begin
+declare exit handler for sqlstate '21S01' set x = 1;
+insert into test.t1 values ("hndlr2", val, 2); # Too many values
+end;
+insert into test.t1 values ("hndlr2", x);
+end|
+call hndlr2(42)|
+select * from t1|
+id data
+hndlr2 1
+delete from t1|
+drop procedure hndlr2|
+drop procedure if exists hndlr3|
+create procedure hndlr3(val int)
+begin
+declare x int default 0;
+declare continue handler for sqlexception # Any error
+begin
+declare z int;
+set z = 2 * val;
+set x = 1;
+end;
+if val < 10 then
+begin
+declare y int;
+set y = val + 10;
+insert into test.t1 values ("hndlr3", y, 2); # Too many values
+if x then
+insert into test.t1 values ("hndlr3", y);
+end if;
+end;
+end if;
+end|
+call hndlr3(3)|
+select * from t1|
+id data
+hndlr3 13
+delete from t1|
+drop procedure hndlr3|
+create table t3 ( id char(16), data int )|
+drop procedure if exists hndlr4|
+create procedure hndlr4()
+begin
+declare x int default 0;
+declare val int; # No default
+declare continue handler for sqlstate '02000' set x=1;
+select data into val from test.t3 where id='z' limit 1; # No hits
+insert into test.t3 values ('z', val);
+end|
+call hndlr4()|
+select * from t3|
+id data
+z NULL
+drop table t3|
+drop procedure hndlr4|
+drop procedure if exists cur1|
+create procedure cur1()
+begin
+declare a char(16);
+declare b int;
+declare c double;
+declare done int default 0;
+declare c cursor for select * from test.t2;
+declare continue handler for sqlstate '02000' set done = 1;
+open c;
+repeat
+fetch c into a, b, c;
+if not done then
+insert into test.t1 values (a, b+c);
+end if;
+until done end repeat;
+close c;
+end|
+insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)|
+call cur1()|
+select * from t1|
+id data
+foo 40
+bar 15
+zap 663
+drop procedure cur1|
+create table t3 ( s char(16), i int )|
+drop procedure if exists cur2|
+create procedure cur2()
+begin
+declare done int default 0;
+declare c1 cursor for select id,data from test.t1;
+declare c2 cursor for select i from test.t2;
+declare continue handler for sqlstate '02000' set done = 1;
+open c1;
+open c2;
+repeat
+begin
+declare a char(16);
+declare b,c int;
+fetch from c1 into a, b;
+fetch next from c2 into c;
+if not done then
+if b < c then
+insert into test.t3 values (a, b);
+else
+insert into test.t3 values (a, c);
+end if;
+end if;
+end;
+until done end repeat;
+close c1;
+close c2;
+end|
+call cur2()|
+select * from t3|
+s i
+foo 40
+bar 3
+zap 663
+delete from t1|
+delete from t2|
+drop table t3|
+drop procedure cur2|
+drop procedure if exists chistics|
+create procedure chistics()
+language sql
+modifies sql data
+not deterministic
+sql security definer
+comment 'Characteristics procedure test'
+ insert into t1 values ("chistics", 1)|
+show create procedure chistics|
+Procedure sql_mode Create Procedure
+chistics CREATE PROCEDURE `chistics`()
+ MODIFIES SQL DATA
+ COMMENT 'Characteristics procedure test'
+insert into t1 values ("chistics", 1)
+call chistics()|
+select * from t1|
+id data
+chistics 1
+delete from t1|
+alter procedure chistics sql security invoker|
+show create procedure chistics|
+Procedure sql_mode Create Procedure
+chistics CREATE PROCEDURE `chistics`()
+ MODIFIES SQL DATA
+ SQL SECURITY INVOKER
+ COMMENT 'Characteristics procedure test'
+insert into t1 values ("chistics", 1)
+drop procedure chistics|
+drop function if exists chistics|
+create function chistics() returns int
+language sql
+deterministic
+sql security invoker
+comment 'Characteristics procedure test'
+ return 42|
+show create function chistics|
+Function sql_mode Create Function
+chistics CREATE FUNCTION `chistics`() RETURNS int(11)
+ DETERMINISTIC
+ SQL SECURITY INVOKER
+ COMMENT 'Characteristics procedure test'
+return 42
+select chistics()|
+chistics()
+42
+alter function chistics
+no sql
+comment 'Characteristics function test'|
+show create function chistics|
+Function sql_mode Create Function
+chistics CREATE FUNCTION `chistics`() RETURNS int(11)
+ NO SQL
+ DETERMINISTIC
+ SQL SECURITY INVOKER
+ COMMENT 'Characteristics function test'
+return 42
+drop function chistics|
+insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
+set @@sql_mode = 'ANSI'|
+drop procedure if exists modes$
+create procedure modes(out c1 int, out c2 int)
+begin
+declare done int default 0;
+declare x int;
+declare c cursor for select data from t1;
+declare continue handler for sqlstate '02000' set done = 1;
+select 1 || 2 into c1;
+set c2 = 0;
+open c;
+repeat
+fetch c into x;
+if not done then
+set c2 = c2 + 1;
+end if;
+until done end repeat;
+close c;
+end$
+set @@sql_mode = ''|
+set sql_select_limit = 1|
+call modes(@c1, @c2)|
+set sql_select_limit = default|
+select @c1, @c2|
+@c1 @c2
+12 3
+delete from t1|
+drop procedure modes|
+create database sp_db1|
+drop database sp_db1|
+create database sp_db2|
+use sp_db2|
+create table t3 ( s char(4), t int )|
+insert into t3 values ("abcd", 42), ("dcba", 666)|
+use test|
+drop database sp_db2|
+create database sp_db3|
+use sp_db3|
+drop procedure if exists dummy|
+create procedure dummy(out x int)
+set x = 42|
+use test|
+drop database sp_db3|
+select type,db,name from mysql.proc where db = 'sp_db3'|
+type db name
+drop procedure if exists rc|
+create procedure rc()
+begin
+delete from t1;
+insert into t1 values ("a", 1), ("b", 2), ("c", 3);
+end|
+call rc()|
+select row_count()|
+row_count()
+3
+update t1 set data=42 where id = "b";
+select row_count()|
+row_count()
+1
+delete from t1|
+select row_count()|
+row_count()
+3
+delete from t1|
+select row_count()|
+row_count()
+0
+select * from t1|
+id data
+select row_count()|
+row_count()
+-1
+drop procedure rc|
+drop function if exists f0|
+drop function if exists f1|
+drop function if exists f2|
+drop function if exists f3|
+drop function if exists f4|
+drop function if exists f5|
+drop function if exists f6|
+drop function if exists f7|
+drop function if exists f8|
+drop function if exists f9|
+drop function if exists f10|
+drop function if exists f11|
+drop function if exists f12_1|
+drop function if exists f12_2|
+drop view if exists v0|
+drop view if exists v1|
+drop view if exists v2|
+delete from t1|
+delete from t2|
+insert into t1 values ("a", 1), ("b", 2) |
+insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) |
+create function f1() returns int
+return (select sum(data) from t1)|
+select f1()|
+f1()
+3
+select id, f1() from t1|
+id f1()
+a 3
+b 3
+create function f2() returns int
+return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
+select f2()|
+f2()
+1
+select id, f2() from t1|
+id f2()
+a 1
+b 1
+create function f3() returns int
+begin
+declare n int;
+declare m int;
+set n:= (select min(data) from t1);
+set m:= (select max(data) from t1);
+return n < m;
+end|
+select f3()|
+f3()
+1
+select id, f3() from t1|
+id f3()
+a 1
+b 1
+select f1(), f3()|
+f1() f3()
+3 1
+select id, f1(), f3() from t1|
+id f1() f3()
+a 3 1
+b 3 1
+create function f4() returns double
+return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
+select f4()|
+f4()
+2
+select s, f4() from t2|
+s f4()
+a 2
+b 2
+c 2
+create function f5(i int) returns int
+begin
+if i <= 0 then
+return 0;
+elseif i = 1 then
+return (select count(*) from t1 where data = i);
+else
+return (select count(*) + f5( i - 1) from t1 where data = i);
+end if;
+end|
+select f5(1)|
+f5(1)
+1
+select f5(2)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select f5(3)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+create function f6() returns int
+begin
+declare n int;
+set n:= f1();
+return (select count(*) from t1 where data <= f7() and data <= n);
+end|
+create function f7() returns int
+return (select sum(data) from t1 where data <= f1())|
+select f6()|
+f6()
+2
+select id, f6() from t1|
+id f6()
+a 2
+b 2
+create view v1 (a) as select f1()|
+select * from v1|
+a
+3
+select id, a from t1, v1|
+id a
+a 3
+b 3
+select * from v1, v1 as v|
+a a
+3 3
+create view v2 (a) as select a*10 from v1|
+select * from v2|
+a
+30
+select id, a from t1, v2|
+id a
+a 30
+b 30
+select * from v1, v2|
+a a
+3 30
+create function f8 () returns int
+return (select count(*) from v2)|
+select *, f8() from v1|
+a f8()
+3 1
+drop function f1|
+select * from v1|
+ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+create function f1() returns int
+return (select sum(data) from t1) + (select sum(data) from v1)|
+select f1()|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select * from v1|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select * from v2|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+drop function f1|
+create function f1() returns int
+return (select sum(data) from t1)|
+create function f0() returns int
+return (select * from (select 100) as r)|
+select f0()|
+f0()
+100
+select *, f0() from (select 1) as t|
+1 f0()
+1 100
+create view v0 as select f0()|
+select * from v0|
+f0()
+100
+select *, f0() from v0|
+f0() f0()
+100 100
+lock tables t1 read, t1 as t11 read|
+select f3()|
+f3()
+1
+select id, f3() from t1 as t11|
+id f3()
+a 1
+b 1
+select f0()|
+f0()
+100
+select * from v0|
+f0()
+100
+select *, f0() from v0, (select 123) as d1|
+f0() 123 f0()
+100 123 100
+select id, f3() from t1|
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+select f4()|
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+unlock tables|
+lock tables v2 read, mysql.proc read|
+select * from v2|
+a
+30
+select * from v1|
+a
+3
+select * from v1, t1|
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+select f4()|
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+unlock tables|
+create function f9() returns int
+begin
+declare a, b int;
+drop temporary table if exists t3;
+create temporary table t3 (id int);
+insert into t3 values (1), (2), (3);
+set a:= (select count(*) from t3);
+set b:= (select count(*) from t3 t3_alias);
+return a + b;
+end|
+select f9()|
+f9()
+6
+Warnings:
+Note 1051 Unknown table 't3'
+select f9() from t1 limit 1|
+f9()
+6
+create function f10() returns int
+begin
+drop temporary table if exists t3;
+create temporary table t3 (id int);
+insert into t3 select id from t4;
+return (select count(*) from t3);
+end|
+select f10()|
+ERROR 42S02: Table 'test.t4' doesn't exist
+create table t4 as select 1 as id|
+select f10()|
+f10()
+1
+create function f11() returns int
+begin
+drop temporary table if exists t3;
+create temporary table t3 (id int);
+insert into t3 values (1), (2), (3);
+return (select count(*) from t3 as a, t3 as b);
+end|
+select f11()|
+ERROR HY000: Can't reopen table: 'a'
+select f11() from t1|
+ERROR HY000: Can't reopen table: 'a'
+create function f12_1() returns int
+begin
+drop temporary table if exists t3;
+create temporary table t3 (id int);
+insert into t3 values (1), (2), (3);
+return f12_2();
+end|
+create function f12_2() returns int
+return (select count(*) from t3)|
+drop temporary table t3|
+select f12_1()|
+ERROR 42S02: Table 'test.t3' doesn't exist
+select f12_1() from t1 limit 1|
+ERROR 42S02: Table 'test.t3' doesn't exist
+drop function f0|
+drop function f1|
+drop function f2|
+drop function f3|
+drop function f4|
+drop function f5|
+drop function f6|
+drop function f7|
+drop function f8|
+drop function f9|
+drop function f10|
+drop function f11|
+drop function f12_1|
+drop function f12_2|
+drop view v0|
+drop view v1|
+drop view v2|
+delete from t1 |
+delete from t2 |
+drop table t4|
+drop table if exists t3|
+create table t3 (n int unsigned not null primary key, f bigint unsigned)|
+drop procedure if exists ifac|
+create procedure ifac(n int unsigned)
+begin
+declare i int unsigned default 1;
+if n > 20 then
+set n = 20; # bigint overflow otherwise
+end if;
+while i <= n do
+begin
+insert into test.t3 values (i, fac(i));
+set i = i + 1;
+end;
+end while;
+end|
+call ifac(20)|
+select * from t3|
+n f
+1 1
+2 2
+3 6
+4 24
+5 120
+6 720
+7 5040
+8 40320
+9 362880
+10 3628800
+11 39916800
+12 479001600
+13 6227020800
+14 87178291200
+15 1307674368000
+16 20922789888000
+17 355687428096000
+18 6402373705728000
+19 121645100408832000
+20 2432902008176640000
+drop table t3|
+show function status like '%f%'|
+Db Name Type Definer Modified Created Security_type Comment
+test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+drop procedure ifac|
+drop function fac|
+show function status like '%f%'|
+Db Name Type Definer Modified Created Security_type Comment
+drop table if exists t3|
+create table t3 (
+i int unsigned not null primary key,
+p bigint unsigned not null
+)|
+insert into t3 values
+( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
+( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
+(10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
+(15, 59), (16, 61), (17, 67), (18, 71), (19, 73),
+(20, 79), (21, 83), (22, 89), (23, 97), (24, 101),
+(25, 103), (26, 107), (27, 109), (28, 113), (29, 127),
+(30, 131), (31, 137), (32, 139), (33, 149), (34, 151),
+(35, 157), (36, 163), (37, 167), (38, 173), (39, 179),
+(40, 181), (41, 191), (42, 193), (43, 197), (44, 199)|
+drop procedure if exists opp|
+create procedure opp(n bigint unsigned, out pp bool)
+begin
+declare r double;
+declare b, s bigint unsigned default 0;
+set r = sqrt(n);
+again:
+loop
+if s = 45 then
+set b = b+200, s = 0;
+else
+begin
+declare p bigint unsigned;
+select t.p into p from test.t3 t where t.i = s;
+if b+p > r then
+set pp = 1;
+leave again;
+end if;
+if mod(n, b+p) = 0 then
+set pp = 0;
+leave again;
+end if;
+set s = s+1;
+end;
+end if;
+end loop;
+end|
+drop procedure if exists ip|
+create procedure ip(m int unsigned)
+begin
+declare p bigint unsigned;
+declare i int unsigned;
+set i=45, p=201;
+while i < m do
+begin
+declare pp bool default 0;
+call opp(p, pp);
+if pp then
+insert into test.t3 values (i, p);
+set i = i+1;
+end if;
+set p = p+2;
+end;
+end while;
+end|
+show create procedure opp|
+Procedure sql_mode Create Procedure
+opp CREATE PROCEDURE `opp`(n bigint unsigned, out pp bool)
+begin
+declare r double;
+declare b, s bigint unsigned default 0;
+set r = sqrt(n);
+again:
+loop
+if s = 45 then
+set b = b+200, s = 0;
+else
+begin
+declare p bigint unsigned;
+select t.p into p from test.t3 t where t.i = s;
+if b+p > r then
+set pp = 1;
+leave again;
+end if;
+if mod(n, b+p) = 0 then
+set pp = 0;
+leave again;
+end if;
+set s = s+1;
+end;
+end if;
+end loop;
+end
+show procedure status like '%p%'|
+Db Name Type Definer Modified Created Security_type Comment
+test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+call ip(200)|
+select * from t3 where i=45 or i=100 or i=199|
+i p
+45 211
+100 557
+199 1229
+drop table t3|
+drop procedure opp|
+drop procedure ip|
+show procedure status like '%p%'|
+Db Name Type Definer Modified Created Security_type Comment
+drop table if exists t3|
+create table t3 ( f bigint unsigned not null )|
+drop procedure if exists fib|
+create procedure fib(n int unsigned)
+begin
+if n > 1 then
+begin
+declare x, y bigint unsigned;
+declare c cursor for select f from t3 order by f desc limit 2;
+open c;
+fetch c into y;
+fetch c into x;
+close c;
+insert into t3 values (x+y);
+call fib(n-1);
+end;
+end if;
+end|
+set @@max_sp_recursion_depth= 20|
+insert into t3 values (0), (1)|
+call fib(3)|
+select * from t3 order by f asc|
+f
+0
+1
+1
+2
+delete from t3|
+insert into t3 values (0), (1)|
+call fib(10)|
+select * from t3 order by f asc|
+f
+0
+1
+1
+2
+3
+5
+8
+13
+21
+34
+55
+drop table t3|
+drop procedure fib|
+set @@max_sp_recursion_depth= 0|
+drop procedure if exists bar|
+create procedure bar(x char(16), y int)
+comment "111111111111" sql security invoker
+insert into test.t1 values (x, y)|
+show procedure status like 'bar'|
+Db Name Type Definer Modified Created Security_type Comment
+test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111
+alter procedure bar comment "2222222222" sql security definer|
+alter procedure bar comment "3333333333"|
+alter procedure bar|
+show create procedure bar|
+Procedure sql_mode Create Procedure
+bar CREATE PROCEDURE `bar`(x char(16), y int)
+ COMMENT '3333333333'
+insert into test.t1 values (x, y)
+show procedure status like 'bar'|
+Db Name Type Definer Modified Created Security_type Comment
+test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333
+drop procedure bar|
+drop procedure if exists p1|
+create procedure p1 ()
+select (select s1 from t3) from t3|
+create table t3 (s1 int)|
+call p1()|
+(select s1 from t3)
+insert into t3 values (1)|
+call p1()|
+(select s1 from t3)
+1
+drop procedure p1|
+drop table t3|
+drop function if exists foo|
+create function `foo` () returns int
+return 5|
+select `foo` ()|
+`foo` ()
+5
+drop function `foo`|
+drop function if exists t1max|
+create function t1max() returns int
+begin
+declare x int;
+select max(data) into x from t1;
+return x;
+end|
+insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
+select t1max()|
+t1max()
+5
+drop function t1max|
+create table t3 (
+v char(16) not null primary key,
+c int unsigned not null
+)|
+create function getcount(s char(16)) returns int
+begin
+declare x int;
+select count(*) into x from t3 where v = s;
+if x = 0 then
+insert into t3 values (s, 1);
+else
+update t3 set c = c+1 where v = s;
+end if;
+return x;
+end|
+select * from t1 where data = getcount("bar")|
+id data
+zap 1
+select * from t3|
+v c
+bar 4
+select getcount("zip")|
+getcount("zip")
+0
+select getcount("zip")|
+getcount("zip")
+1
+select * from t3|
+v c
+bar 4
+zip 2
+select getcount(id) from t1 where data = 3|
+getcount(id)
+0
+select getcount(id) from t1 where data = 5|
+getcount(id)
+1
+select * from t3|
+v c
+bar 4
+zip 3
+foo 1
+drop table t3|
+drop function getcount|
+drop table if exists t3|
+drop procedure if exists h_ee|
+drop procedure if exists h_es|
+drop procedure if exists h_en|
+drop procedure if exists h_ew|
+drop procedure if exists h_ex|
+drop procedure if exists h_se|
+drop procedure if exists h_ss|
+drop procedure if exists h_sn|
+drop procedure if exists h_sw|
+drop procedure if exists h_sx|
+drop procedure if exists h_ne|
+drop procedure if exists h_ns|
+drop procedure if exists h_nn|
+drop procedure if exists h_we|
+drop procedure if exists h_ws|
+drop procedure if exists h_ww|
+drop procedure if exists h_xe|
+drop procedure if exists h_xs|
+drop procedure if exists h_xx|
+create table t3 (a smallint primary key)|
+insert into t3 (a) values (1)|
+create procedure h_ee()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (bad)' as 'h_ee';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_ee';
+insert into t3 values (1);
+end;
+end|
+create procedure h_es()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (good)' as 'h_es';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+ select 'Inner (bad)' as 'h_es';
+insert into t3 values (1);
+end;
+end|
+create procedure h_en()
+deterministic
+begin
+declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+select 'Outer (good)' as 'h_en';
+begin
+declare x int;
+declare continue handler for sqlstate '02000' -- no data
+select 'Inner (bad)' as 'h_en';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_ew()
+deterministic
+begin
+declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+select 'Outer (good)' as 'h_ew';
+begin
+declare continue handler for sqlwarning
+select 'Inner (bad)' as 'h_ew';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ex()
+deterministic
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Outer (good)' as 'h_ex';
+begin
+declare continue handler for sqlexception
+select 'Inner (bad)' as 'h_ex';
+insert into t3 values (1);
+end;
+end|
+create procedure h_se()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (bad)' as 'h_se';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_se';
+insert into t3 values (1);
+end;
+end|
+create procedure h_ss()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (bad)' as 'h_ss';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Inner (good)' as 'h_ss';
+insert into t3 values (1);
+end;
+end|
+create procedure h_sn()
+deterministic
+begin
+-- Note: '02000' is more specific than NOT FOUND ;
+-- there might be other not found states
+declare continue handler for sqlstate '02000' -- no data
+select 'Outer (good)' as 'h_sn';
+begin
+declare x int;
+declare continue handler for not found
+select 'Inner (bad)' as 'h_sn';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_sw()
+deterministic
+begin
+-- data exception - numeric value out of range
+declare continue handler for sqlstate '22003'
+ select 'Outer (good)' as 'h_sw';
+begin
+declare continue handler for sqlwarning
+select 'Inner (bad)' as 'h_sw';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_sx()
+deterministic
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+select 'Outer (good)' as 'h_sx';
+begin
+declare continue handler for sqlexception
+select 'Inner (bad)' as 'h_sx';
+insert into t3 values (1);
+end;
+end|
+create procedure h_ne()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_ne';
+begin
+declare x int;
+declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+select 'Inner (good)' as 'h_ne';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_ns()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_ns';
+begin
+declare x int;
+declare continue handler for sqlstate '02000' -- no data
+select 'Inner (good)' as 'h_ns';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_nn()
+deterministic
+begin
+declare continue handler for not found
+select 'Outer (bad)' as 'h_nn';
+begin
+declare x int;
+declare continue handler for not found
+select 'Inner (good)' as 'h_nn';
+select a into x from t3 where a = 42;
+end;
+end|
+create procedure h_we()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_we';
+begin
+declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+select 'Inner (good)' as 'h_we';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ws()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_ws';
+begin
+-- data exception - numeric value out of range
+declare continue handler for sqlstate '22003'
+ select 'Inner (good)' as 'h_ws';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_ww()
+deterministic
+begin
+declare continue handler for sqlwarning
+select 'Outer (bad)' as 'h_ww';
+begin
+declare continue handler for sqlwarning
+select 'Inner (good)' as 'h_ww';
+insert into t3 values (123456789012);
+end;
+delete from t3;
+insert into t3 values (1);
+end|
+create procedure h_xe()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xe';
+begin
+declare continue handler for 1062 -- ER_DUP_ENTRY
+select 'Inner (good)' as 'h_xe';
+insert into t3 values (1);
+end;
+end|
+create procedure h_xs()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xs';
+begin
+-- integrity constraint violation
+declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_xs';
+insert into t3 values (1);
+end;
+end|
+create procedure h_xx()
+deterministic
+begin
+declare continue handler for sqlexception
+select 'Outer (bad)' as 'h_xx';
+begin
+declare continue handler for sqlexception
+select 'Inner (good)' as 'h_xx';
+insert into t3 values (1);
+end;
+end|
+call h_ee()|
+h_ee
+Inner (good)
+call h_es()|
+h_es
+Outer (good)
+call h_en()|
+h_en
+Outer (good)
+call h_ew()|
+h_ew
+Outer (good)
+call h_ex()|
+h_ex
+Outer (good)
+call h_se()|
+h_se
+Inner (good)
+call h_ss()|
+h_ss
+Inner (good)
+call h_sn()|
+h_sn
+Outer (good)
+call h_sw()|
+h_sw
+Outer (good)
+call h_sx()|
+h_sx
+Outer (good)
+call h_ne()|
+h_ne
+Inner (good)
+call h_ns()|
+h_ns
+Inner (good)
+call h_nn()|
+h_nn
+Inner (good)
+call h_we()|
+h_we
+Inner (good)
+call h_ws()|
+h_ws
+Inner (good)
+call h_ww()|
+h_ww
+Inner (good)
+call h_xe()|
+h_xe
+Inner (good)
+call h_xs()|
+h_xs
+Inner (good)
+call h_xx()|
+h_xx
+Inner (good)
+drop table t3|
+drop procedure h_ee|
+drop procedure h_es|
+drop procedure h_en|
+drop procedure h_ew|
+drop procedure h_ex|
+drop procedure h_se|
+drop procedure h_ss|
+drop procedure h_sn|
+drop procedure h_sw|
+drop procedure h_sx|
+drop procedure h_ne|
+drop procedure h_ns|
+drop procedure h_nn|
+drop procedure h_we|
+drop procedure h_ws|
+drop procedure h_ww|
+drop procedure h_xe|
+drop procedure h_xs|
+drop procedure h_xx|
+drop procedure if exists bug822|
+create procedure bug822(a_id char(16), a_data int)
+begin
+declare n int;
+select count(*) into n from t1 where id = a_id and data = a_data;
+if n = 0 then
+insert into t1 (id, data) values (a_id, a_data);
+end if;
+end|
+delete from t1|
+call bug822('foo', 42)|
+call bug822('foo', 42)|
+call bug822('bar', 666)|
+select * from t1|
+id data
+foo 42
+bar 666
+delete from t1|
+drop procedure bug822|
+drop procedure if exists bug1495|
+create procedure bug1495()
+begin
+declare x int;
+select data into x from t1 order by id limit 1;
+if x > 10 then
+insert into t1 values ("less", x-10);
+else
+insert into t1 values ("more", x+10);
+end if;
+end|
+insert into t1 values ('foo', 12)|
+call bug1495()|
+delete from t1 where id='foo'|
+insert into t1 values ('bar', 7)|
+call bug1495()|
+delete from t1 where id='bar'|
+select * from t1|
+id data
+less 2
+more 17
+delete from t1|
+drop procedure bug1495|
+drop procedure if exists bug1547|
+create procedure bug1547(s char(16))
+begin
+declare x int;
+select data into x from t1 where s = id limit 1;
+if x > 10 then
+insert into t1 values ("less", x-10);
+else
+insert into t1 values ("more", x+10);
+end if;
+end|
+insert into t1 values ("foo", 12), ("bar", 7)|
+call bug1547("foo")|
+call bug1547("bar")|
+select * from t1|
+id data
+foo 12
+bar 7
+less 2
+more 17
+delete from t1|
+drop procedure bug1547|
+drop table if exists t70|
+create table t70 (s1 int,s2 int)|
+insert into t70 values (1,2)|
+drop procedure if exists bug1656|
+create procedure bug1656(out p1 int, out p2 int)
+select * into p1, p1 from t70|
+call bug1656(@1, @2)|
+select @1, @2|
+@1 @2
+2 NULL
+drop table t70|
+drop procedure bug1656|
+create table t3(a int)|
+drop procedure if exists bug1862|
+create procedure bug1862()
+begin
+insert into t3 values(2);
+flush tables;
+end|
+call bug1862()|
+call bug1862()|
+select * from t3|
+a
+2
+2
+drop table t3|
+drop procedure bug1862|
+drop procedure if exists bug1874|
+create procedure bug1874()
+begin
+declare x int;
+declare y double;
+select max(data) into x from t1;
+insert into t2 values ("max", x, 0);
+select min(data) into x from t1;
+insert into t2 values ("min", x, 0);
+select sum(data) into x from t1;
+insert into t2 values ("sum", x, 0);
+select avg(data) into y from t1;
+insert into t2 values ("avg", 0, y);
+end|
+insert into t1 (data) values (3), (1), (5), (9), (4)|
+call bug1874()|
+select * from t2|
+s i d
+max 9 0
+min 1 0
+sum 22 0
+avg 0 4.4
+delete from t1|
+delete from t2|
+drop procedure bug1874|
+drop procedure if exists bug2260|
+create procedure bug2260()
+begin
+declare v1 int;
+declare c1 cursor for select data from t1;
+declare continue handler for not found set @x2 = 1;
+open c1;
+fetch c1 into v1;
+set @x2 = 2;
+close c1;
+end|
+call bug2260()|
+select @x2|
+@x2
+2
+drop procedure bug2260|
+drop procedure if exists bug2267_1|
+create procedure bug2267_1()
+begin
+show procedure status;
+end|
+drop procedure if exists bug2267_2|
+create procedure bug2267_2()
+begin
+show function status;
+end|
+drop procedure if exists bug2267_3|
+create procedure bug2267_3()
+begin
+show create procedure bug2267_1;
+end|
+drop procedure if exists bug2267_4|
+drop function if exists bug2267_4|
+create procedure bug2267_4()
+begin
+show create function bug2267_4;
+end|
+create function bug2267_4() returns int return 100|
+call bug2267_1()|
+Db Name Type Definer Modified Created Security_type Comment
+test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+call bug2267_2()|
+Db Name Type Definer Modified Created Security_type Comment
+test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+call bug2267_3()|
+Procedure sql_mode Create Procedure
+bug2267_1 CREATE PROCEDURE `bug2267_1`()
+begin
+show procedure status;
+end
+call bug2267_4()|
+Function sql_mode Create Function
+bug2267_4 CREATE FUNCTION `bug2267_4`() RETURNS int(11)
+return 100
+drop procedure bug2267_1|
+drop procedure bug2267_2|
+drop procedure bug2267_3|
+drop procedure bug2267_4|
+drop function bug2267_4|
+drop procedure if exists bug2227|
+create procedure bug2227(x int)
+begin
+declare y float default 2.6;
+declare z char(16) default "zzz";
+select 1.3, x, y, 42, z;
+end|
+call bug2227(9)|
+1.3 x y 42 z
+1.3 9 2.6 42 zzz
+drop procedure bug2227|
+drop procedure if exists bug2614|
+create procedure bug2614()
+begin
+drop table if exists t3;
+create table t3 (id int default '0' not null);
+insert into t3 select 12;
+insert into t3 select * from t3;
+end|
+call bug2614()|
+call bug2614()|
+drop table t3|
+drop procedure bug2614|
+drop function if exists bug2674|
+create function bug2674() returns int
+return @@sort_buffer_size|
+set @osbs = @@sort_buffer_size|
+set @@sort_buffer_size = 262000|
+select bug2674()|
+bug2674()
+262000
+drop function bug2674|
+set @@sort_buffer_size = @osbs|
+drop procedure if exists bug3259_1 |
+create procedure bug3259_1 () begin end|
+drop procedure if exists BUG3259_2 |
+create procedure BUG3259_2 () begin end|
+drop procedure if exists Bug3259_3 |
+create procedure Bug3259_3 () begin end|
+call BUG3259_1()|
+call BUG3259_1()|
+call bug3259_2()|
+call Bug3259_2()|
+call bug3259_3()|
+call bUG3259_3()|
+drop procedure bUg3259_1|
+drop procedure BuG3259_2|
+drop procedure BUG3259_3|
+drop function if exists bug2772|
+create function bug2772() returns char(10) character set latin2
+return 'a'|
+select bug2772()|
+bug2772()
+a
+drop function bug2772|
+drop procedure if exists bug2776_1|
+create procedure bug2776_1(out x int)
+begin
+declare v int;
+set v = default;
+set x = v;
+end|
+drop procedure if exists bug2776_2|
+create procedure bug2776_2(out x int)
+begin
+declare v int default 42;
+set v = default;
+set x = v;
+end|
+set @x = 1|
+call bug2776_1(@x)|
+select @x|
+@x
+NULL
+call bug2776_2(@x)|
+select @x|
+@x
+42
+drop procedure bug2776_1|
+drop procedure bug2776_2|
+create table t3 (s1 smallint)|
+insert into t3 values (123456789012)|
+Warnings:
+Warning 1264 Out of range value adjusted for column 's1' at row 1
+drop procedure if exists bug2780|
+create procedure bug2780()
+begin
+declare exit handler for sqlwarning set @x = 1;
+set @x = 0;
+insert into t3 values (123456789012);
+insert into t3 values (0);
+end|
+call bug2780()|
+select @x|
+@x
+1
+select * from t3|
+s1
+32767
+32767
+drop procedure bug2780|
+drop table t3|
+create table t3 (content varchar(10) )|
+insert into t3 values ("test1")|
+insert into t3 values ("test2")|
+create table t4 (f1 int, rc int, t3 int)|
+drop procedure if exists bug1863|
+create procedure bug1863(in1 int)
+begin
+declare ind int default 0;
+declare t1 int;
+declare t2 int;
+declare t3 int;
+declare rc int default 0;
+declare continue handler for 1065 set rc = 1;
+drop temporary table if exists temp_t1;
+create temporary table temp_t1 (
+f1 int auto_increment, f2 varchar(20), primary key (f1)
+);
+insert into temp_t1 (f2) select content from t3;
+select f2 into t3 from temp_t1 where f1 = 10;
+if (rc) then
+insert into t4 values (1, rc, t3);
+end if;
+insert into t4 values (2, rc, t3);
+end|
+call bug1863(10)|
+Warnings:
+Note 1051 Unknown table 'temp_t1'
+Warning 1329 No data - zero rows fetched, selected, or processed
+call bug1863(10)|
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+select * from t4|
+f1 rc t3
+2 0 NULL
+2 0 NULL
+drop procedure bug1863|
+drop temporary table temp_t1;
+drop table t3, t4|
+create table t3 (
+OrderID int not null,
+MarketID int,
+primary key (OrderID)
+)|
+create table t4 (
+MarketID int not null,
+Market varchar(60),
+Status char(1),
+primary key (MarketID)
+)|
+insert t3 (OrderID,MarketID) values (1,1)|
+insert t3 (OrderID,MarketID) values (2,2)|
+insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
+insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
+drop procedure if exists bug2656_1|
+create procedure bug2656_1()
+begin
+select
+m.Market
+from t4 m JOIN t3 o
+ON o.MarketID != 1 and o.MarketID = m.MarketID;
+end |
+drop procedure if exists bug2656_2|
+create procedure bug2656_2()
+begin
+select
+m.Market
+from
+t4 m, t3 o
+where
+m.MarketID != 1 and m.MarketID = o.MarketID;
+end |
+call bug2656_1()|
+Market
+MarketID Two
+call bug2656_1()|
+Market
+MarketID Two
+call bug2656_2()|
+Market
+MarketID Two
+call bug2656_2()|
+Market
+MarketID Two
+drop procedure bug2656_1|
+drop procedure bug2656_2|
+drop table t3, t4|
+drop procedure if exists bug3426|
+create procedure bug3426(in_time int unsigned, out x int)
+begin
+if in_time is null then
+set @stamped_time=10;
+set x=1;
+else
+set @stamped_time=in_time;
+set x=2;
+end if;
+end|
+call bug3426(1000, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+@i time
+2 01-01-1970 03:16:40
+call bug3426(NULL, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+@i time
+1 01-01-1970 03:00:10
+alter procedure bug3426 sql security invoker|
+call bug3426(NULL, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+@i time
+1 01-01-1970 03:00:10
+call bug3426(1000, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+@i time
+2 01-01-1970 03:16:40
+drop procedure bug3426|
+create table t3 (
+a int primary key,
+ach char(1)
+) engine = innodb|
+create table t4 (
+b int primary key ,
+bch char(1)
+) engine = innodb|
+insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
+Warnings:
+Warning 1265 Data truncated for column 'ach' at row 1
+Warning 1265 Data truncated for column 'ach' at row 2
+insert into t4 values (1 , 'bCh1' )|
+Warnings:
+Warning 1265 Data truncated for column 'bch' at row 1
+drop procedure if exists bug3448|
+create procedure bug3448()
+select * from t3 inner join t4 on t3.a = t4.b|
+select * from t3 inner join t4 on t3.a = t4.b|
+a ach b bch
+1 a 1 b
+call bug3448()|
+a ach b bch
+1 a 1 b
+call bug3448()|
+a ach b bch
+1 a 1 b
+drop procedure bug3448|
+drop table t3, t4|
+create table t3 (
+id int unsigned auto_increment not null primary key,
+title VARCHAR(200),
+body text,
+fulltext (title,body)
+)|
+insert into t3 (title,body) values
+('MySQL Tutorial','DBMS stands for DataBase ...'),
+('How To Use MySQL Well','After you went through a ...'),
+('Optimizing MySQL','In this tutorial we will show ...'),
+('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
+('MySQL vs. YourSQL','In the following database comparison ...'),
+('MySQL Security','When configured properly, MySQL ...')|
+drop procedure if exists bug3734 |
+create procedure bug3734 (param1 varchar(100))
+select * from t3 where match (title,body) against (param1)|
+call bug3734('database')|
+id title body
+5 MySQL vs. YourSQL In the following database comparison ...
+1 MySQL Tutorial DBMS stands for DataBase ...
+call bug3734('Security')|
+id title body
+6 MySQL Security When configured properly, MySQL ...
+drop procedure bug3734|
+drop table t3|
+drop procedure if exists bug3863|
+create procedure bug3863()
+begin
+set @a = 0;
+while @a < 5 do
+set @a = @a + 1;
+end while;
+end|
+call bug3863()|
+select @a|
+@a
+5
+call bug3863()|
+select @a|
+@a
+5
+drop procedure bug3863|
+create table t3 (
+id int(10) unsigned not null default 0,
+rid int(10) unsigned not null default 0,
+msg text not null,
+primary key (id),
+unique key rid (rid, id)
+)|
+drop procedure if exists bug2460_1|
+create procedure bug2460_1(in v int)
+begin
+( select n0.id from t3 as n0 where n0.id = v )
+union
+( select n0.id from t3 as n0, t3 as n1
+where n0.id = n1.rid and n1.id = v )
+union
+( select n0.id from t3 as n0, t3 as n1, t3 as n2
+where n0.id = n1.rid and n1.id = n2.rid and n2.id = v );
+end|
+call bug2460_1(2)|
+id
+call bug2460_1(2)|
+id
+insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')|
+call bug2460_1(2)|
+id
+2
+1
+call bug2460_1(2)|
+id
+2
+1
+drop procedure if exists bug2460_2|
+create procedure bug2460_2()
+begin
+drop table if exists t3;
+create temporary table t3 (s1 int);
+insert into t3 select 1 union select 1;
+end|
+call bug2460_2()|
+call bug2460_2()|
+select * from t3|
+s1
+1
+drop procedure bug2460_1|
+drop procedure bug2460_2|
+drop table t3|
+set @@sql_mode = ''|
+drop procedure if exists bug2564_1|
+create procedure bug2564_1()
+comment 'Joe''s procedure'
+ insert into `t1` values ("foo", 1)|
+set @@sql_mode = 'ANSI_QUOTES'|
+drop procedure if exists bug2564_2|
+create procedure bug2564_2()
+insert into "t1" values ('foo', 1)|
+set @@sql_mode = ''$
+drop function if exists bug2564_3$
+create function bug2564_3(x int, y int) returns int
+return x || y$
+set @@sql_mode = 'ANSI'$
+drop function if exists bug2564_4$
+create function bug2564_4(x int, y int) returns int
+return x || y$
+set @@sql_mode = ''|
+show create procedure bug2564_1|
+Procedure sql_mode Create Procedure
+bug2564_1 CREATE PROCEDURE `bug2564_1`()
+ COMMENT 'Joe''s procedure'
+insert into `t1` values ("foo", 1)
+show create procedure bug2564_2|
+Procedure sql_mode Create Procedure
+bug2564_2 ANSI_QUOTES CREATE PROCEDURE "bug2564_2"()
+insert into "t1" values ('foo', 1)
+show create function bug2564_3|
+Function sql_mode Create Function
+bug2564_3 CREATE FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
+return x || y
+show create function bug2564_4|
+Function sql_mode Create Function
+bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
+return x || y
+drop procedure bug2564_1|
+drop procedure bug2564_2|
+drop function bug2564_3|
+drop function bug2564_4|
+drop function if exists bug3132|
+create function bug3132(s char(20)) returns char(50)
+return concat('Hello, ', s, '!')|
+select bug3132('Bob') union all select bug3132('Judy')|
+bug3132('Bob')
+Hello, Bob!
+Hello, Judy!
+drop function bug3132|
+drop procedure if exists bug3843|
+create procedure bug3843()
+analyze table t1|
+call bug3843()|
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+call bug3843()|
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
+select 1+2|
+1+2
+3
+drop procedure bug3843|
+create table t3 ( s1 char(10) )|
+insert into t3 values ('a'), ('b')|
+drop procedure if exists bug3368|
+create procedure bug3368(v char(10))
+begin
+select group_concat(v) from t3;
+end|
+call bug3368('x')|
+group_concat(v)
+x,x
+call bug3368('yz')|
+group_concat(v)
+yz,yz
+drop procedure bug3368|
+drop table t3|
+create table t3 (f1 int, f2 int)|
+insert into t3 values (1,1)|
+drop procedure if exists bug4579_1|
+create procedure bug4579_1 ()
+begin
+declare sf1 int;
+select f1 into sf1 from t3 where f1=1 and f2=1;
+update t3 set f2 = f2 + 1 where f1=1 and f2=1;
+call bug4579_2();
+end|
+drop procedure if exists bug4579_2|
+create procedure bug4579_2 ()
+begin
+end|
+call bug4579_1()|
+call bug4579_1()|
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+call bug4579_1()|
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+drop procedure bug4579_1|
+drop procedure bug4579_2|
+drop table t3|
+drop procedure if exists bug2773|
+create function bug2773() returns int return null|
+create table t3 as select bug2773()|
+show create table t3|
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `bug2773()` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t3|
+drop function bug2773|
+drop procedure if exists bug3788|
+create function bug3788() returns date return cast("2005-03-04" as date)|
+select bug3788()|
+bug3788()
+2005-03-04
+drop function bug3788|
+create function bug3788() returns binary(1) return 5|
+select bug3788()|
+bug3788()
+5
+drop function bug3788|
+create table t3 (f1 int, f2 int, f3 int)|
+insert into t3 values (1,1,1)|
+drop procedure if exists bug4726|
+create procedure bug4726()
+begin
+declare tmp_o_id INT;
+declare tmp_d_id INT default 1;
+while tmp_d_id <= 2 do
+begin
+select f1 into tmp_o_id from t3 where f2=1 and f3=1;
+set tmp_d_id = tmp_d_id + 1;
+end;
+end while;
+end|
+call bug4726()|
+call bug4726()|
+call bug4726()|
+drop procedure bug4726|
+drop table t3|
+drop procedure if exists bug4902|
+create procedure bug4902()
+begin
+show charset like 'foo';
+show collation like 'foo';
+show column types;
+show create table t1;
+show create database test;
+show databases like 'foo';
+show errors;
+show columns from t1;
+show grants for 'root'@'localhost';
+show keys from t1;
+show open tables like 'foo';
+show privileges;
+show status like 'foo';
+show tables like 'foo';
+show variables like 'foo';
+show warnings;
+end|
+call bug4902()|
+Charset Description Default collation Maxlen
+Collation Charset Id Default Compiled Sortlen
+Type Size Min_Value Max_Value Prec Scale Nullable Auto_Increment Unsigned Zerofill Searchable Case_Sensitive Default Comment
+tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
+tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` char(16) NOT NULL default '',
+ `data` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Database Create Database
+test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
+Database (foo)
+Level Code Message
+Field Type Null Key Default Extra
+id char(16) NO
+data int(11) NO
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+Database Table In_use Name_locked
+Privilege Context Comment
+Alter Tables To alter the table
+Alter routine Functions,Procedures To alter or drop stored functions/procedures
+Create Databases,Tables,Indexes To create new databases and tables
+Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
+Create temporary tables Databases To use CREATE TEMPORARY TABLE
+Create view Tables To create new views
+Create user Server Admin To create new users
+Delete Tables To delete existing rows
+Drop Databases,Tables To drop databases, tables, and views
+Execute Functions,Procedures To execute stored routines
+File File access on server To read and write files on the server
+Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
+Index Tables To create or drop indexes
+Insert Tables To insert data into tables
+Lock tables Databases To use LOCK TABLES (together with SELECT privilege)
+Process Server Admin To view the plain text of currently executing queries
+References Databases,Tables To have references on tables
+Reload Server Admin To reload or refresh tables, logs and privileges
+Replication client Server Admin To ask where the slave or master servers are
+Replication slave Server Admin To read binary log events from the master
+Select Tables To retrieve rows from table
+Show databases Server Admin To see all databases with SHOW DATABASES
+Show view Tables To see views with SHOW CREATE VIEW
+Shutdown Server Admin To shut down the server
+Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
+Update Tables To update existing rows
+Usage Server Admin No privileges - allow connect only
+Variable_name Value
+Tables_in_test (foo)
+Variable_name Value
+Level Code Message
+call bug4902()|
+Charset Description Default collation Maxlen
+Collation Charset Id Default Compiled Sortlen
+Type Size Min_Value Max_Value Prec Scale Nullable Auto_Increment Unsigned Zerofill Searchable Case_Sensitive Default Comment
+tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
+tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` char(16) NOT NULL default '',
+ `data` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Database Create Database
+test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
+Database (foo)
+Level Code Message
+Field Type Null Key Default Extra
+id char(16) NO
+data int(11) NO
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+Database Table In_use Name_locked
+Privilege Context Comment
+Alter Tables To alter the table
+Alter routine Functions,Procedures To alter or drop stored functions/procedures
+Create Databases,Tables,Indexes To create new databases and tables
+Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
+Create temporary tables Databases To use CREATE TEMPORARY TABLE
+Create view Tables To create new views
+Create user Server Admin To create new users
+Delete Tables To delete existing rows
+Drop Databases,Tables To drop databases, tables, and views
+Execute Functions,Procedures To execute stored routines
+File File access on server To read and write files on the server
+Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
+Index Tables To create or drop indexes
+Insert Tables To insert data into tables
+Lock tables Databases To use LOCK TABLES (together with SELECT privilege)
+Process Server Admin To view the plain text of currently executing queries
+References Databases,Tables To have references on tables
+Reload Server Admin To reload or refresh tables, logs and privileges
+Replication client Server Admin To ask where the slave or master servers are
+Replication slave Server Admin To read binary log events from the master
+Select Tables To retrieve rows from table
+Show databases Server Admin To see all databases with SHOW DATABASES
+Show view Tables To see views with SHOW CREATE VIEW
+Shutdown Server Admin To shut down the server
+Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
+Update Tables To update existing rows
+Usage Server Admin No privileges - allow connect only
+Variable_name Value
+Tables_in_test (foo)
+Variable_name Value
+Level Code Message
+drop procedure bug4902|
+drop procedure if exists bug4902_2|
+create procedure bug4902_2()
+begin
+show processlist;
+end|
+call bug4902_2()|
+Id User Host db Command Time State Info
+# root localhost test Query # NULL show processlist
+call bug4902_2()|
+Id User Host db Command Time State Info
+# root localhost test Query # NULL show processlist
+drop procedure bug4902_2|
+drop procedure if exists bug4904|
+create procedure bug4904()
+begin
+declare continue handler for sqlstate 'HY000' begin end;
+create table t2 as select * from t3;
+end|
+call bug4904()|
+ERROR 42S02: Table 'test.t3' doesn't exist
+drop procedure bug4904|
+create table t3 (s1 char character set latin1, s2 char character set latin2)|
+drop procedure if exists bug4904|
+create procedure bug4904 ()
+begin
+declare continue handler for sqlstate 'HY000' begin end;
+select s1 from t3 union select s2 from t3;
+end|
+call bug4904()|
+drop procedure bug4904|
+drop table t3|
+drop procedure if exists bug336|
+create procedure bug336(out y int)
+begin
+declare x int;
+set x = (select sum(t.data) from test.t1 t);
+set y = x;
+end|
+insert into t1 values ("a", 2), ("b", 3)|
+call bug336(@y)|
+select @y|
+@y
+5
+delete from t1|
+drop procedure bug336|
+drop procedure if exists bug3157|
+create procedure bug3157()
+begin
+if exists(select * from t1) then
+set @n= @n + 1;
+end if;
+if (select count(*) from t1) then
+set @n= @n + 1;
+end if;
+end|
+set @n = 0|
+insert into t1 values ("a", 1)|
+call bug3157()|
+select @n|
+@n
+2
+delete from t1|
+drop procedure bug3157|
+drop procedure if exists bug5251|
+create procedure bug5251()
+begin
+end|
+select created into @c1 from mysql.proc
+where db='test' and name='bug5251'|
+alter procedure bug5251 comment 'foobar'|
+select count(*) from mysql.proc
+where db='test' and name='bug5251' and created = @c1|
+count(*)
+1
+drop procedure bug5251|
+drop procedure if exists bug5251|
+create procedure bug5251()
+checksum table t1|
+call bug5251()|
+Table Checksum
+test.t1 0
+call bug5251()|
+Table Checksum
+test.t1 0
+drop procedure bug5251|
+drop procedure if exists bug5287|
+create procedure bug5287(param1 int)
+label1:
+begin
+declare c cursor for select 5;
+loop
+if param1 >= 0 then
+leave label1;
+end if;
+end loop;
+end|
+call bug5287(1)|
+drop procedure bug5287|
+drop procedure if exists bug5307|
+create procedure bug5307()
+begin
+end; set @x = 3|
+call bug5307()|
+select @x|
+@x
+3
+drop procedure bug5307|
+drop procedure if exists bug5258|
+create procedure bug5258()
+begin
+end|
+drop procedure if exists bug5258_aux|
+create procedure bug5258_aux()
+begin
+declare c, m char(19);
+select created,modified into c,m from mysql.proc where name = 'bug5258';
+if c = m then
+select 'Ok';
+else
+select c, m;
+end if;
+end|
+call bug5258_aux()|
+Ok
+Ok
+drop procedure bug5258|
+drop procedure bug5258_aux|
+drop function if exists bug4487|
+create function bug4487() returns char
+begin
+declare v char;
+return v;
+end|
+select bug4487()|
+bug4487()
+NULL
+drop function bug4487|
+drop procedure if exists bug4941|
+drop procedure if exists bug4941|
+create procedure bug4941(out x int)
+begin
+declare c cursor for select i from t2 limit 1;
+open c;
+fetch c into x;
+close c;
+end|
+insert into t2 values (null, null, null)|
+set @x = 42|
+call bug4941(@x)|
+select @x|
+@x
+NULL
+delete from t1|
+drop procedure bug4941|
+drop procedure if exists bug3583|
+drop procedure if exists bug3583|
+create procedure bug3583()
+begin
+declare c int;
+select * from t1;
+select count(*) into c from t1;
+select c;
+end|
+insert into t1 values ("x", 3), ("y", 5)|
+set @x = @@query_cache_size|
+set global query_cache_size = 10*1024*1024|
+flush status|
+flush query cache|
+show status like 'Qcache_hits'|
+Variable_name Value
+Qcache_hits 0
+call bug3583()|
+id data
+x 3
+y 5
+c
+2
+show status like 'Qcache_hits'|
+Variable_name Value
+Qcache_hits 0
+call bug3583()|
+id data
+x 3
+y 5
+c
+2
+call bug3583()|
+id data
+x 3
+y 5
+c
+2
+show status like 'Qcache_hits'|
+Variable_name Value
+Qcache_hits 2
+set global query_cache_size = @x|
+flush status|
+flush query cache|
+delete from t1|
+drop procedure bug3583|
+drop procedure if exists bug4905|
+create table t3 (s1 int,primary key (s1))|
+drop procedure if exists bug4905|
+create procedure bug4905()
+begin
+declare v int;
+declare continue handler for sqlstate '23000' set v = 5;
+insert into t3 values (1);
+end|
+call bug4905()|
+select row_count()|
+row_count()
+1
+call bug4905()|
+select row_count()|
+row_count()
+0
+call bug4905()|
+select row_count()|
+row_count()
+0
+select * from t3|
+s1
+1
+drop procedure bug4905|
+drop table t3|
+drop procedure if exists bug6029|
+drop procedure if exists bug6029|
+create procedure bug6029()
+begin
+declare exit handler for 1136 select '1136';
+declare exit handler for sqlstate '23000' select 'sqlstate 23000';
+declare continue handler for sqlexception select 'sqlexception';
+insert into t3 values (1);
+insert into t3 values (1,2);
+end|
+create table t3 (s1 int, primary key (s1))|
+insert into t3 values (1)|
+call bug6029()|
+sqlstate 23000
+sqlstate 23000
+delete from t3|
+call bug6029()|
+1136
+1136
+drop procedure bug6029|
+drop table t3|
+drop procedure if exists bug8540|
+create procedure bug8540()
+begin
+declare x int default 1;
+select x as y, x+0 as z;
+end|
+call bug8540()|
+y z
+1 1
+drop procedure bug8540|
+create table t3 (s1 int)|
+drop procedure if exists bug6642|
+create procedure bug6642()
+select abs(count(s1)) from t3|
+call bug6642()|
+abs(count(s1))
+0
+call bug6642()|
+abs(count(s1))
+0
+drop procedure bug6642|
+insert into t3 values (0),(1)|
+drop procedure if exists bug7013|
+create procedure bug7013()
+select s1,count(s1) from t3 group by s1 with rollup|
+call bug7013()|
+s1 count(s1)
+0 1
+1 1
+NULL 2
+call bug7013()|
+s1 count(s1)
+0 1
+1 1
+NULL 2
+drop procedure bug7013|
+drop table if exists t4|
+create table t4 (
+a mediumint(8) unsigned not null auto_increment,
+b smallint(5) unsigned not null,
+c char(32) not null,
+primary key (a)
+) engine=myisam default charset=latin1|
+insert into t4 values (1, 2, 'oneword')|
+insert into t4 values (2, 2, 'anotherword')|
+drop procedure if exists bug7743|
+create procedure bug7743 ( searchstring char(28) )
+begin
+declare var mediumint(8) unsigned;
+select a into var from t4 where b = 2 and c = binary searchstring limit 1;
+select var;
+end|
+call bug7743("oneword")|
+var
+1
+call bug7743("OneWord")|
+var
+NULL
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+call bug7743("anotherword")|
+var
+2
+call bug7743("AnotherWord")|
+var
+NULL
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+drop procedure bug7743|
+drop table t4|
+delete from t3|
+insert into t3 values(1)|
+drop procedure if exists bug7992_1|
+Warnings:
+Note 1305 PROCEDURE bug7992_1 does not exist
+drop procedure if exists bug7992_2|
+Warnings:
+Note 1305 PROCEDURE bug7992_2 does not exist
+create procedure bug7992_1()
+begin
+declare i int;
+select max(s1)+1 into i from t3;
+end|
+create procedure bug7992_2()
+insert into t3 (s1) select max(t4.s1)+1 from t3 as t4|
+call bug7992_1()|
+call bug7992_1()|
+call bug7992_2()|
+call bug7992_2()|
+drop procedure bug7992_1|
+drop procedure bug7992_2|
+drop table t3|
+create table t3 ( userid bigint(20) not null default 0 )|
+drop procedure if exists bug8116|
+create procedure bug8116(in _userid int)
+select * from t3 where userid = _userid|
+call bug8116(42)|
+userid
+call bug8116(42)|
+userid
+drop procedure bug8116|
+drop table t3|
+drop procedure if exists bug6857|
+create procedure bug6857(counter int)
+begin
+declare t0, t1 int;
+declare plus bool default 0;
+set t0 = current_time();
+while counter > 0 do
+set counter = counter - 1;
+end while;
+set t1 = current_time();
+if t1 > t0 then
+set plus = 1;
+end if;
+select plus;
+end|
+drop procedure bug6857|
+drop procedure if exists bug8757|
+create procedure bug8757()
+begin
+declare x int;
+declare c1 cursor for select data from t1 limit 1;
+begin
+declare y int;
+declare c2 cursor for select i from t2 limit 1;
+open c2;
+fetch c2 into y;
+close c2;
+select 2,y;
+end;
+open c1;
+fetch c1 into x;
+close c1;
+select 1,x;
+end|
+delete from t1|
+delete from t2|
+insert into t1 values ("x", 1)|
+insert into t2 values ("y", 2, 0.0)|
+call bug8757()|
+2 y
+2 2
+1 x
+1 1
+delete from t1|
+delete from t2|
+drop procedure bug8757|
+drop procedure if exists bug8762|
+drop procedure if exists bug8762; create procedure bug8762() begin end|
+drop procedure if exists bug8762; create procedure bug8762() begin end|
+drop procedure bug8762|
+drop function if exists bug5240|
+create function bug5240 () returns int
+begin
+declare x int;
+declare c cursor for select data from t1 limit 1;
+open c;
+fetch c into x;
+close c;
+return x;
+end|
+delete from t1|
+insert into t1 values ("answer", 42)|
+select id, bug5240() from t1|
+id bug5240()
+answer 42
+drop function bug5240|
+drop function if exists bug5278|
+create function bug5278 () returns char
+begin
+SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
+return 'okay';
+end|
+select bug5278()|
+ERROR 42000: Can't find any matching row in the user table
+select bug5278()|
+ERROR 42000: Can't find any matching row in the user table
+drop function bug5278|
+drop procedure if exists p1|
+create table t3(id int)|
+insert into t3 values(1)|
+create procedure bug7992()
+begin
+declare i int;
+select max(id)+1 into i from t3;
+end|
+call bug7992()|
+call bug7992()|
+drop procedure bug7992|
+drop table t3|
+create table t3 (
+lpitnumber int(11) default null,
+lrecordtype int(11) default null
+)|
+create table t4 (
+lbsiid int(11) not null default '0',
+ltradingmodeid int(11) not null default '0',
+ltradingareaid int(11) not null default '0',
+csellingprice decimal(19,4) default null,
+primary key (lbsiid,ltradingmodeid,ltradingareaid)
+)|
+create table t5 (
+lbsiid int(11) not null default '0',
+ltradingareaid int(11) not null default '0',
+primary key (lbsiid,ltradingareaid)
+)|
+drop procedure if exists bug8849|
+create procedure bug8849()
+begin
+insert into t5
+(
+t5.lbsiid,
+t5.ltradingareaid
+)
+select distinct t3.lpitnumber, t4.ltradingareaid
+from
+t4 join t3 on
+t3.lpitnumber = t4.lbsiid
+and t3.lrecordtype = 1
+left join t4 as price01 on
+price01.lbsiid = t4.lbsiid and
+price01.ltradingmodeid = 1 and
+t4.ltradingareaid = price01.ltradingareaid;
+end|
+call bug8849()|
+call bug8849()|
+call bug8849()|
+drop procedure bug8849|
+drop tables t3,t4,t5|
+drop procedure if exists bug8937|
+create procedure bug8937()
+begin
+declare s,x,y,z int;
+declare a float;
+select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
+select s,x,y,z;
+select avg(data) into a from t1;
+select a;
+end|
+delete from t1|
+insert into t1 (data) values (1), (2), (3), (4), (6)|
+call bug8937()|
+s x y z
+16 3 1 6
+a
+3.2
+drop procedure bug8937|
+delete from t1|
+drop procedure if exists bug6900|
+drop procedure if exists bug9074|
+drop procedure if exists bug6900_9074|
+create table t3 (w char unique, x char)|
+insert into t3 values ('a', 'b')|
+create procedure bug6900()
+begin
+declare exit handler for sqlexception select '1';
+begin
+declare exit handler for sqlexception select '2';
+insert into t3 values ('x', 'y', 'z');
+end;
+end|
+create procedure bug9074()
+begin
+declare x1, x2, x3, x4, x5, x6 int default 0;
+begin
+declare continue handler for sqlstate '23000' set x5 = 1;
+insert into t3 values ('a', 'b');
+set x6 = 1;
+end;
+begin1_label:
+begin
+declare continue handler for sqlstate '23000' set x1 = 1;
+insert into t3 values ('a', 'b');
+set x2 = 1;
+begin2_label:
+begin
+declare exit handler for sqlstate '23000' set x3 = 1;
+set x4= 1;
+insert into t3 values ('a','b');
+set x4= 0;
+end begin2_label;
+end begin1_label;
+select x1, x2, x3, x4, x5, x6;
+end|
+create procedure bug6900_9074(z int)
+begin
+declare exit handler for sqlstate '23000' select '23000';
+begin
+declare exit handler for sqlexception select 'sqlexception';
+if z = 1 then
+insert into t3 values ('a', 'b');
+else
+insert into t3 values ('x', 'y', 'z');
+end if;
+end;
+end|
+call bug6900()|
+2
+2
+call bug9074()|
+x1 x2 x3 x4 x5 x6
+1 1 1 1 1 1
+call bug6900_9074(0)|
+sqlexception
+sqlexception
+call bug6900_9074(1)|
+23000
+23000
+drop procedure bug6900|
+drop procedure bug9074|
+drop procedure bug6900_9074|
+drop table t3|
+drop procedure if exists avg|
+create procedure avg ()
+begin
+end|
+call avg ()|
+drop procedure avg|
+drop procedure if exists bug6129|
+set @old_mode= @@sql_mode;
+set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO";
+create procedure bug6129()
+select @@sql_mode|
+call bug6129()|
+@@sql_mode
+ERROR_FOR_DIVISION_BY_ZERO
+set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"|
+call bug6129()|
+@@sql_mode
+ERROR_FOR_DIVISION_BY_ZERO
+set @@sql_mode= "NO_ZERO_IN_DATE"|
+call bug6129()|
+@@sql_mode
+ERROR_FOR_DIVISION_BY_ZERO
+set @@sql_mode=@old_mode;
+drop procedure bug6129|
+drop procedure if exists bug9856|
+create procedure bug9856()
+begin
+declare v int;
+declare c cursor for select data from t1;
+declare exit handler for sqlexception, not found select '16';
+open c;
+fetch c into v;
+select v;
+end|
+delete from t1|
+call bug9856()|
+16
+16
+call bug9856()|
+16
+16
+drop procedure bug9856|
+drop procedure if exists bug9674_1|
+drop procedure if exists bug9674_2|
+create procedure bug9674_1(out arg int)
+begin
+declare temp_in1 int default 0;
+declare temp_fl1 int default 0;
+set temp_in1 = 100;
+set temp_fl1 = temp_in1/10;
+set arg = temp_fl1;
+end|
+create procedure bug9674_2()
+begin
+declare v int default 100;
+select v/10;
+end|
+call bug9674_1(@sptmp)|
+call bug9674_1(@sptmp)|
+select @sptmp|
+@sptmp
+10
+call bug9674_2()|
+v/10
+10.0000
+call bug9674_2()|
+v/10
+10.0000
+drop procedure bug9674_1|
+drop procedure bug9674_2|
+drop procedure if exists bug9598_1|
+drop procedure if exists bug9598_2|
+create procedure bug9598_1(in var_1 char(16),
+out var_2 integer, out var_3 integer)
+begin
+set var_2 = 50;
+set var_3 = 60;
+end|
+create procedure bug9598_2(in v1 char(16),
+in v2 integer,
+in v3 integer,
+in v4 integer,
+in v5 integer)
+begin
+select v1,v2,v3,v4,v5;
+call bug9598_1(v1,@tmp1,@tmp2);
+select v1,v2,v3,v4,v5;
+end|
+call bug9598_2('Test',2,3,4,5)|
+v1 v2 v3 v4 v5
+Test 2 3 4 5
+v1 v2 v3 v4 v5
+Test 2 3 4 5
+select @tmp1, @tmp2|
+@tmp1 @tmp2
+50 60
+drop procedure bug9598_1|
+drop procedure bug9598_2|
+drop procedure if exists bug9902|
+create function bug9902() returns int(11)
+begin
+set @x = @x + 1;
+return @x;
+end|
+set @qcs1 = @@query_cache_size|
+set global query_cache_size = 100000|
+set @x = 1|
+insert into t1 values ("qc", 42)|
+select bug9902() from t1|
+bug9902()
+2
+select bug9902() from t1|
+bug9902()
+3
+select @x|
+@x
+3
+set global query_cache_size = @qcs1|
+delete from t1|
+drop function bug9902|
+drop function if exists bug9102|
+create function bug9102() returns blob return 'a'|
+select bug9102()|
+bug9102()
+a
+drop function bug9102|
+drop function if exists bug7648|
+create function bug7648() returns bit(8) return 'a'|
+select bug7648()|
+bug7648()
+a
+drop function bug7648|
+drop function if exists bug9775|
+create function bug9775(v1 char(1)) returns enum('a','b') return v1|
+select bug9775('a'),bug9775('b'),bug9775('c')|
+bug9775('a') bug9775('b') bug9775('c')
+a b
+Warnings:
+Warning 1265 Data truncated for column 'bug9775('c')' at row 1
+drop function bug9775|
+create function bug9775(v1 int) returns enum('a','b') return v1|
+select bug9775(1),bug9775(2),bug9775(3)|
+bug9775(1) bug9775(2) bug9775(3)
+a b
+Warnings:
+Warning 1265 Data truncated for column 'bug9775(3)' at row 1
+drop function bug9775|
+create function bug9775(v1 char(1)) returns set('a','b') return v1|
+select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')|
+bug9775('a') bug9775('b') bug9775('a,b') bug9775('c')
+a b a
+Warnings:
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'bug9775('c')' at row 1
+drop function bug9775|
+create function bug9775(v1 int) returns set('a','b') return v1|
+select bug9775(1),bug9775(2),bug9775(3),bug9775(4)|
+bug9775(1) bug9775(2) bug9775(3) bug9775(4)
+a b a,b
+Warnings:
+Warning 1265 Data truncated for column 'bug9775(4)' at row 1
+drop function bug9775|
+drop function if exists bug8861|
+create function bug8861(v1 int) returns year return v1|
+select bug8861(05)|
+bug8861(05)
+2005
+set @x = bug8861(05)|
+select @x|
+@x
+2005
+drop function bug8861|
+drop procedure if exists bug9004_1|
+drop procedure if exists bug9004_2|
+create procedure bug9004_1(x char(16))
+begin
+insert into t1 values (x, 42);
+insert into t1 values (x, 17);
+end|
+create procedure bug9004_2(x char(16))
+call bug9004_1(x)|
+call bug9004_1('12345678901234567')|
+Warnings:
+Warning 1265 Data truncated for column 'x' at row 1
+call bug9004_2('12345678901234567890')|
+Warnings:
+Warning 1265 Data truncated for column 'x' at row 1
+delete from t1|
+drop procedure bug9004_1|
+drop procedure bug9004_2|
+drop procedure if exists bug7293|
+insert into t1 values ('secret', 0)|
+create procedure bug7293(p1 varchar(100))
+begin
+if exists (select id from t1 where soundex(p1)=soundex(id)) then
+select 'yes';
+end if;
+end;|
+call bug7293('secret')|
+yes
+yes
+call bug7293 ('secrete')|
+yes
+yes
+drop procedure bug7293|
+delete from t1|
+drop procedure if exists bug9841|
+drop view if exists v1|
+create view v1 as select * from t1, t2 where id = s|
+create procedure bug9841 ()
+update v1 set data = 10|
+call bug9841()|
+drop view v1|
+drop procedure bug9841|
+drop procedure if exists bug5963|
+create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
+create table t3 (s1 int)|
+insert into t3 values (5)|
+call bug5963_1()|
+v
+5
+call bug5963_1()|
+v
+5
+drop procedure bug5963_1|
+drop table t3|
+create procedure bug5963_2 (cfk_value int)
+begin
+if cfk_value in (select cpk from t3) then
+set @x = 5;
+end if;
+end;
+|
+create table t3 (cpk int)|
+insert into t3 values (1)|
+call bug5963_2(1)|
+call bug5963_2(1)|
+drop procedure bug5963_2|
+drop table t3|
+drop function if exists bug9559|
+create function bug9559()
+returns int
+begin
+set @y = -6/2;
+return @y;
+end|
+select bug9559()|
+bug9559()
+-3
+drop function bug9559|
+drop procedure if exists bug10961|
+create procedure bug10961()
+begin
+declare v char;
+declare x int;
+declare c cursor for select * from dual;
+declare continue handler for sqlexception select x;
+set x = 1;
+open c;
+set x = 2;
+fetch c into v;
+set x = 3;
+close c;
+end|
+call bug10961()|
+x
+1
+x
+2
+x
+3
+call bug10961()|
+x
+1
+x
+2
+x
+3
+drop procedure bug10961|
+DROP PROCEDURE IF EXISTS bug6866|
+DROP VIEW IF EXISTS tv|
+Warnings:
+Note 1051 Unknown table 'test.tv'
+DROP TABLE IF EXISTS tt1,tt2,tt3|
+Warnings:
+Note 1051 Unknown table 'tt1'
+Note 1051 Unknown table 'tt2'
+Note 1051 Unknown table 'tt3'
+CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
+CREATE TABLE tt2 (a2 int, data2 varchar(10))|
+CREATE TABLE tt3 (a3 int, data3 varchar(10))|
+INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
+INSERT INTO tt2 VALUES (1, 'a')|
+INSERT INTO tt2 VALUES (2, 'b')|
+INSERT INTO tt2 VALUES (3, 'c')|
+INSERT INTO tt3 VALUES (4, 'd')|
+INSERT INTO tt3 VALUES (5, 'e')|
+INSERT INTO tt3 VALUES (6, 'f')|
+CREATE VIEW tv AS
+SELECT tt1.*, tt2.data2, tt3.data3
+FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
+LEFT JOIN tt3 ON tt1.a3 = tt3.a3
+ORDER BY tt1.a1, tt2.a2, tt3.a3|
+CREATE PROCEDURE bug6866 (_a1 int)
+BEGIN
+SELECT * FROM tv WHERE a1 = _a1;
+END|
+CALL bug6866(1)|
+a1 a2 a3 data data2 data3
+1 1 4 xx a d
+CALL bug6866(1)|
+a1 a2 a3 data data2 data3
+1 1 4 xx a d
+CALL bug6866(1)|
+a1 a2 a3 data data2 data3
+1 1 4 xx a d
+DROP PROCEDURE bug6866;
+DROP VIEW tv|
+DROP TABLE tt1, tt2, tt3|
+DROP PROCEDURE IF EXISTS bug10136|
+create table t3 ( name char(5) not null primary key, val float not null)|
+insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)|
+create procedure bug10136()
+begin
+declare done int default 3;
+repeat
+select * from t3;
+set done = done - 1;
+until done <= 0 end repeat;
+end|
+call bug10136()|
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+call bug10136()|
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+call bug10136()|
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+name val
+aaaaa 1
+bbbbb 2
+ccccc 3
+drop procedure bug10136|
+drop table t3|
+drop procedure if exists bug11529|
+create procedure bug11529()
+begin
+declare c cursor for select id, data from t1 where data in (10,13);
+open c;
+begin
+declare vid char(16);
+declare vdata int;
+declare exit handler for not found begin end;
+while true do
+fetch c into vid, vdata;
+end while;
+end;
+close c;
+end|
+insert into t1 values
+('Name1', 10),
+('Name2', 11),
+('Name3', 12),
+('Name4', 13),
+('Name5', 14)|
+call bug11529()|
+call bug11529()|
+delete from t1|
+drop procedure bug11529|
+drop procedure if exists bug6063|
+drop procedure if exists bug7088_1|
+drop procedure if exists bug7088_2|
+drop procedure if exists bug9565_sub|
+drop procedure if exists bug9565|
+create procedure bug9565_sub()
+begin
+select * from t1;
+end|
+create procedure bug9565()
+begin
+insert into t1 values ("one", 1);
+call bug9565_sub();
+end|
+call bug9565()|
+id data
+one 1
+delete from t1|
+drop procedure bug9565_sub|
+drop procedure bug9565|
+drop procedure if exists bug9538|
+create procedure bug9538()
+set @@sort_buffer_size = 1000000|
+set @x = @@sort_buffer_size|
+set @@sort_buffer_size = 2000000|
+select @@sort_buffer_size|
+@@sort_buffer_size
+2000000
+call bug9538()|
+select @@sort_buffer_size|
+@@sort_buffer_size
+1000000
+set @@sort_buffer_size = @x|
+drop procedure bug9538|
+drop procedure if exists bug8692|
+create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))|
+insert into t3 values ('', '', '', '', '', '', NULL)|
+Warnings:
+Warning 1265 Data truncated for column 'c3' at row 1
+create procedure bug8692()
+begin
+declare v1 VARCHAR(10);
+declare v2 VARCHAR(10);
+declare v3 VARCHAR(10);
+declare v4 VARCHAR(10);
+declare v5 VARCHAR(10);
+declare v6 VARCHAR(10);
+declare v7 VARCHAR(10);
+declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3;
+open c8692;
+fetch c8692 into v1,v2,v3,v4,v5,v6,v7;
+select v1, v2, v3, v4, v5, v6, v7;
+end|
+call bug8692()|
+v1 v2 v3 v4 v5 v6 v7
+ NULL
+drop procedure bug8692|
+drop table t3|
+drop function if exists bug10055|
+create function bug10055(v char(255)) returns char(255) return lower(v)|
+select t.column_name, bug10055(t.column_name)
+from information_schema.columns as t
+where t.table_schema = 'test' and t.table_name = 't1'|
+column_name bug10055(t.column_name)
+id id
+data data
+drop function bug10055|
+drop procedure if exists bug12297|
+create procedure bug12297(lim int)
+begin
+set @x = 0;
+repeat
+insert into t1(id,data)
+values('aa', @x);
+set @x = @x + 1;
+until @x >= lim
+end repeat;
+end|
+call bug12297(10)|
+drop procedure bug12297|
+drop function if exists f_bug11247|
+drop procedure if exists p_bug11247|
+create function f_bug11247(param int)
+returns int
+return param + 1|
+create procedure p_bug11247(lim int)
+begin
+declare v int default 0;
+while v < lim do
+set v= f_bug11247(v);
+end while;
+end|
+call p_bug11247(10)|
+drop function f_bug11247|
+drop procedure p_bug11247|
+drop procedure if exists bug12168|
+drop table if exists t3, t4|
+create table t3 (a int)|
+insert into t3 values (1),(2),(3),(4)|
+create table t4 (a int)|
+create procedure bug12168(arg1 char(1))
+begin
+declare b, c integer;
+if arg1 = 'a' then
+begin
+declare c1 cursor for select a from t3 where a % 2;
+declare continue handler for not found set b = 1;
+set b = 0;
+open c1;
+c1_repeat: repeat
+fetch c1 into c;
+if (b = 1) then
+leave c1_repeat;
+end if;
+insert into t4 values (c);
+until b = 1
+end repeat;
+end;
+end if;
+if arg1 = 'b' then
+begin
+declare c2 cursor for select a from t3 where not a % 2;
+declare continue handler for not found set b = 1;
+set b = 0;
+open c2;
+c2_repeat: repeat
+fetch c2 into c;
+if (b = 1) then
+leave c2_repeat;
+end if;
+insert into t4 values (c);
+until b = 1
+end repeat;
+end;
+end if;
+end|
+call bug12168('a')|
+select * from t4|
+a
+1
+3
+truncate t4|
+call bug12168('b')|
+select * from t4|
+a
+2
+4
+truncate t4|
+call bug12168('a')|
+select * from t4|
+a
+1
+3
+truncate t4|
+call bug12168('b')|
+select * from t4|
+a
+2
+4
+truncate t4|
+drop table t3, t4|
+drop procedure if exists bug12168|
+drop table if exists t3|
+drop procedure if exists bug11333|
+create table t3 (c1 char(128))|
+insert into t3 values
+('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')|
+create procedure bug11333(i int)
+begin
+declare tmp varchar(128);
+set @x = 0;
+repeat
+select c1 into tmp from t3
+where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
+set @x = @x + 1;
+until @x >= i
+end repeat;
+end|
+call bug11333(10)|
+drop procedure bug11333|
+drop table t3|
+drop function if exists bug9048|
+create function bug9048(f1 char binary) returns char binary
+begin
+set f1= concat( 'hello', f1 );
+return f1;
+end|
+drop function bug9048|
+drop procedure if exists bug12849_1|
+create procedure bug12849_1(inout x char) select x into x|
+set @var='a'|
+call bug12849_1(@var)|
+select @var|
+@var
+a
+drop procedure bug12849_1|
+drop procedure if exists bug12849_2|
+create procedure bug12849_2(inout foo varchar(15))
+begin
+select concat(foo, foo) INTO foo;
+end|
+set @var='abcd'|
+call bug12849_2(@var)|
+select @var|
+@var
+abcdabcd
+drop procedure bug12849_2|
+drop procedure if exists bug131333|
+drop function if exists bug131333|
+create procedure bug131333()
+begin
+begin
+declare a int;
+select a;
+set a = 1;
+select a;
+end;
+begin
+declare b int;
+select b;
+end;
+end|
+create function bug131333()
+returns int
+begin
+begin
+declare a int;
+set a = 1;
+end;
+begin
+declare b int;
+return b;
+end;
+end|
+call bug131333()|
+a
+NULL
+a
+1
+b
+NULL
+select bug131333()|
+bug131333()
+NULL
+drop procedure bug131333|
+drop function bug131333|
+drop function if exists bug12379|
+drop procedure if exists bug12379_1|
+drop procedure if exists bug12379_2|
+drop procedure if exists bug12379_3|
+drop table if exists t3|
+create table t3 (c1 char(1) primary key not null)|
+create function bug12379()
+returns integer
+begin
+insert into t3 values('X');
+insert into t3 values('X');
+return 0;
+end|
+create procedure bug12379_1()
+begin
+declare exit handler for sqlexception select 42;
+select bug12379();
+END|
+create procedure bug12379_2()
+begin
+declare exit handler for sqlexception begin end;
+select bug12379();
+end|
+create procedure bug12379_3()
+begin
+select bug12379();
+end|
+select bug12379()|
+ERROR 23000: Duplicate entry 'X' for key 1
+select 1|
+1
+1
+call bug12379_1()|
+bug12379()
+42
+42
+select 2|
+2
+2
+call bug12379_2()|
+bug12379()
+select 3|
+3
+3
+call bug12379_3()|
+ERROR 23000: Duplicate entry 'X' for key 1
+select 4|
+4
+4
+drop function bug12379|
+drop procedure bug12379_1|
+drop procedure bug12379_2|
+drop procedure bug12379_3|
+drop table t3|
+drop procedure if exists bug13124|
+create procedure bug13124()
+begin
+declare y integer;
+set @x=y;
+end|
+call bug13124()|
+drop procedure bug13124|
+drop procedure if exists bug12979_1|
+create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
+set @bug12979_user_var = NULL|
+call bug12979_1(@bug12979_user_var)|
+drop procedure bug12979_1|
+drop procedure if exists bug12979_2|
+create procedure bug12979_2()
+begin
+declare internal_var decimal(5);
+set internal_var= internal_var / 2;
+select internal_var;
+end|
+call bug12979_2()|
+internal_var
+NULL
+drop procedure bug12979_2|
+drop table if exists t3|
+drop procedure if exists bug6127|
+create table t3 (s1 int unique)|
+set @sm=@@sql_mode|
+set sql_mode='traditional'|
+create procedure bug6127()
+begin
+declare continue handler for sqlstate '23000'
+ begin
+declare continue handler for sqlstate '22003'
+ insert into t3 values (0);
+insert into t3 values (1000000000000000);
+end;
+insert into t3 values (1);
+insert into t3 values (1);
+end|
+call bug6127()|
+select * from t3|
+s1
+0
+1
+call bug6127()|
+ERROR 23000: Duplicate entry '0' for key 1
+select * from t3|
+s1
+0
+1
+set sql_mode=@sm|
+drop table t3|
+drop procedure bug6127|
+drop procedure if exists bug12589_1|
+drop procedure if exists bug12589_2|
+drop procedure if exists bug12589_3|
+create procedure bug12589_1()
+begin
+declare spv1 decimal(3,3);
+set spv1= 123.456;
+set spv1 = 'test';
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+create procedure bug12589_2()
+begin
+declare spv1 decimal(6,3);
+set spv1= 123.456;
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+create procedure bug12589_3()
+begin
+declare spv1 decimal(6,3);
+set spv1= -123.456;
+create temporary table tm1 as select spv1;
+show create table tm1;
+drop temporary table tm1;
+end|
+call bug12589_1()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(3,3) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Warnings:
+Warning 1264 Out of range value adjusted for column 'spv1' at row 1
+Warning 1366 Incorrect decimal value: 'test' for column 'spv1' at row 1
+call bug12589_2()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(6,3) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+call bug12589_3()|
+Table Create Table
+tm1 CREATE TEMPORARY TABLE `tm1` (
+ `spv1` decimal(6,3) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop procedure bug12589_1|
+drop procedure bug12589_2|
+drop procedure bug12589_3|
+drop table if exists t3|
+drop procedure if exists bug7049_1|
+drop procedure if exists bug7049_2|
+drop procedure if exists bug7049_3|
+drop procedure if exists bug7049_4|
+drop function if exists bug7049_1|
+drop function if exists bug7049_2|
+create table t3 ( x int unique )|
+create procedure bug7049_1()
+begin
+insert into t3 values (42);
+insert into t3 values (42);
+end|
+create procedure bug7049_2()
+begin
+declare exit handler for sqlexception
+select 'Caught it' as 'Result';
+call bug7049_1();
+select 'Missed it' as 'Result';
+end|
+create procedure bug7049_3()
+call bug7049_1()|
+create procedure bug7049_4()
+begin
+declare exit handler for sqlexception
+select 'Caught it' as 'Result';
+call bug7049_3();
+select 'Missed it' as 'Result';
+end|
+create function bug7049_1()
+returns int
+begin
+insert into t3 values (42);
+insert into t3 values (42);
+return 42;
+end|
+create function bug7049_2()
+returns int
+begin
+declare x int default 0;
+declare continue handler for sqlexception
+set x = 1;
+set x = bug7049_1();
+return x;
+end|
+call bug7049_2()|
+Result
+Caught it
+select * from t3|
+x
+42
+delete from t3|
+call bug7049_4()|
+Result
+Caught it
+select * from t3|
+x
+42
+select bug7049_2()|
+bug7049_2()
+1
+drop table t3|
+drop procedure bug7049_1|
+drop procedure bug7049_2|
+drop procedure bug7049_3|
+drop procedure bug7049_4|
+drop function bug7049_1|
+drop function bug7049_2|
+drop function if exists bug13941|
+drop procedure if exists bug13941|
+create function bug13941(p_input_str text)
+returns text
+begin
+declare p_output_str text;
+set p_output_str = p_input_str;
+set p_output_str = replace(p_output_str, 'xyzzy', 'plugh');
+set p_output_str = replace(p_output_str, 'test', 'prova');
+set p_output_str = replace(p_output_str, 'this', 'questo');
+set p_output_str = replace(p_output_str, ' a ', 'una ');
+set p_output_str = replace(p_output_str, 'is', '');
+return p_output_str;
+end|
+create procedure bug13941(out sout varchar(128))
+begin
+set sout = 'Local';
+set sout = ifnull(sout, 'DEF');
+end|
+select bug13941('this is a test')|
+bug13941('this is a test')
+questo una prova
+call bug13941(@a)|
+select @a|
+@a
+Local
+drop function bug13941|
+drop procedure bug13941|
+DROP PROCEDURE IF EXISTS bug13095;
+DROP TABLE IF EXISTS bug13095_t1;
+DROP VIEW IF EXISTS bug13095_v1;
+CREATE PROCEDURE bug13095(tbl_name varchar(32))
+BEGIN
+SET @str =
+CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
+SELECT @str;
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+SET @str =
+CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
+SELECT @str;
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+SET @str =
+CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
+SELECT @str;
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+SELECT * FROM bug13095_v1;
+SET @str =
+"DROP VIEW bug13095_v1";
+SELECT @str;
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+END|
+CALL bug13095('bug13095_t1');
+@str
+CREATE TABLE bug13095_t1(stuff char(15))
+@str
+INSERT INTO bug13095_t1 VALUES('row1'),('row2'),('row3')
+@str
+CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM bug13095_t1
+c1
+row1
+row2
+row3
+@str
+DROP VIEW bug13095_v1
+DROP PROCEDURE IF EXISTS bug13095;
+DROP VIEW IF EXISTS bug13095_v1;
+DROP TABLE IF EXISTS bug13095_t1;
+drop procedure if exists bug14210|
+set @@session.max_heap_table_size=16384|
+select @@session.max_heap_table_size|
+@@session.max_heap_table_size
+16384
+create table t3 (a char(255)) engine=InnoDB|
+create procedure bug14210_fill_table()
+begin
+declare table_size, max_table_size int default 0;
+select @@session.max_heap_table_size into max_table_size;
+delete from t3;
+insert into t3 (a) values (repeat('a', 255));
+repeat
+insert into t3 select a from t3;
+select count(*)*255 from t3 into table_size;
+until table_size > max_table_size*2 end repeat;
+end|
+call bug14210_fill_table()|
+drop procedure bug14210_fill_table|
+create table t4 like t3|
+create procedure bug14210()
+begin
+declare a char(255);
+declare done int default 0;
+declare c cursor for select * from t3;
+declare continue handler for sqlstate '02000' set done = 1;
+open c;
+repeat
+fetch c into a;
+if not done then
+insert into t4 values (upper(a));
+end if;
+until done end repeat;
+close c;
+end|
+call bug14210()|
+select count(*) from t4|
+count(*)
+256
+drop table t3, t4|
+drop procedure bug14210|
+set @@session.max_heap_table_size=default|
+drop function if exists bug14723|
+drop procedure if exists bug14723|
+/*!50003 create function bug14723()
+returns bigint(20)
+main_loop: begin
+return 42;
+end */;;
+show create function bug14723;;
+Function sql_mode Create Function
+bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20)
+main_loop: begin
+return 42;
+end
+select bug14723();;
+bug14723()
+42
+/*!50003 create procedure bug14723()
+main_loop: begin
+select 42;
+end */;;
+show create procedure bug14723;;
+Procedure sql_mode Create Procedure
+bug14723 CREATE PROCEDURE `bug14723`()
+main_loop: begin
+select 42;
+end
+call bug14723();;
+42
+42
+drop function bug14723|
+drop procedure bug14723|
+create procedure bug14845()
+begin
+declare a char(255);
+declare done int default 0;
+declare c cursor for select count(*) from t1 where 1 = 0;
+declare continue handler for sqlstate '02000' set done = 1;
+open c;
+repeat
+fetch c into a;
+if not done then
+select a;
+end if;
+until done end repeat;
+close c;
+end|
+call bug14845()|
+a
+0
+drop procedure bug14845|
+drop procedure if exists bug13549_1|
+drop procedure if exists bug13549_2|
+CREATE PROCEDURE `bug13549_2`()
+begin
+call bug13549_1();
+end|
+CREATE PROCEDURE `bug13549_1`()
+begin
+declare done int default 0;
+set done= not done;
+end|
+CALL bug13549_2()|
+drop procedure bug13549_2|
+drop procedure bug13549_1|
+drop function if exists bug10100f|
+drop procedure if exists bug10100p|
+drop procedure if exists bug10100t|
+drop procedure if exists bug10100pt|
+drop procedure if exists bug10100pv|
+drop procedure if exists bug10100pd|
+drop procedure if exists bug10100pc|
+create function bug10100f(prm int) returns int
+begin
+if prm > 1 then
+return prm * bug10100f(prm - 1);
+end if;
+return 1;
+end|
+create procedure bug10100p(prm int, inout res int)
+begin
+set res = res * prm;
+if prm > 1 then
+call bug10100p(prm - 1, res);
+end if;
+end|
+create procedure bug10100t(prm int)
+begin
+declare res int;
+set res = 1;
+call bug10100p(prm, res);
+select res;
+end|
+create table t3 (a int)|
+insert into t3 values (0)|
+create view v1 as select a from t3;
+create procedure bug10100pt(level int, lim int)
+begin
+if level < lim then
+update t3 set a=level;
+FLUSH TABLES;
+call bug10100pt(level+1, lim);
+else
+select * from t3;
+end if;
+end|
+create procedure bug10100pv(level int, lim int)
+begin
+if level < lim then
+update v1 set a=level;
+FLUSH TABLES;
+call bug10100pv(level+1, lim);
+else
+select * from v1;
+end if;
+end|
+prepare stmt2 from "select * from t3;";
+create procedure bug10100pd(level int, lim int)
+begin
+if level < lim then
+select level;
+prepare stmt1 from "update t3 set a=a+2";
+execute stmt1;
+FLUSH TABLES;
+execute stmt1;
+FLUSH TABLES;
+execute stmt1;
+FLUSH TABLES;
+deallocate prepare stmt1;
+execute stmt2;
+select * from t3;
+call bug10100pd(level+1, lim);
+else
+execute stmt2;
+end if;
+end|
+create procedure bug10100pc(level int, lim int)
+begin
+declare lv int;
+declare c cursor for select a from t3;
+open c;
+if level < lim then
+select level;
+fetch c into lv;
+select lv;
+update t3 set a=level+lv;
+FLUSH TABLES;
+call bug10100pc(level+1, lim);
+else
+select * from t3;
+end if;
+close c;
+end|
+set @@max_sp_recursion_depth=4|
+select @@max_sp_recursion_depth|
+@@max_sp_recursion_depth
+4
+select bug10100f(3)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select bug10100f(6)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+call bug10100t(5)|
+res
+120
+call bug10100pt(1,5)|
+a
+4
+call bug10100pv(1,5)|
+a
+4
+update t3 set a=1|
+call bug10100pd(1,5)|
+level
+1
+a
+7
+a
+7
+level
+2
+a
+13
+a
+13
+level
+3
+a
+19
+a
+19
+level
+4
+a
+25
+a
+25
+a
+25
+select * from t3|
+a
+25
+update t3 set a=1|
+call bug10100pc(1,5)|
+level
+1
+lv
+1
+level
+2
+lv
+2
+level
+3
+lv
+4
+level
+4
+lv
+7
+a
+11
+select * from t3|
+a
+11
+set @@max_sp_recursion_depth=0|
+select @@max_sp_recursion_depth|
+@@max_sp_recursion_depth
+0
+select bug10100f(5)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+call bug10100t(5)|
+ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug10100p
+set @@max_sp_recursion_depth=255|
+set @var=1|
+call bug10100p(255, @var)|
+call bug10100pt(1,255)|
+call bug10100pv(1,255)|
+call bug10100pd(1,255)|
+call bug10100pc(1,255)|
+set @@max_sp_recursion_depth=0|
+deallocate prepare stmt2|
+drop function bug10100f|
+drop procedure bug10100p|
+drop procedure bug10100t|
+drop procedure bug10100pt|
+drop procedure bug10100pv|
+drop procedure bug10100pd|
+drop procedure bug10100pc|
+drop view v1|
+drop procedure if exists bug13729|
+drop table if exists t3|
+create table t3 (s1 int, primary key (s1))|
+insert into t3 values (1),(2)|
+create procedure bug13729()
+begin
+declare continue handler for sqlexception select 55;
+update t3 set s1 = 1;
+end|
+call bug13729()|
+55
+55
+select * from t3|
+s1
+1
+2
+drop procedure bug13729|
+drop table t3|
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+create procedure bug14643_1()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+begin
+declare v int default undefined_var;
+if v = 1 then
+select 1;
+else
+select v, isnull(v);
+end if;
+end;
+end|
+create procedure bug14643_2()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+case undefined_var
+when 1 then
+select 1;
+else
+select 2;
+end case;
+select undefined_var;
+end|
+call bug14643_1()|
+Handler
+boo
+v isnull(v)
+NULL 1
+call bug14643_2()|
+Handler
+boo
+Handler
+boo
+drop procedure bug14643_1|
+drop procedure bug14643_2|
+drop procedure if exists bug14304|
+drop table if exists t3, t4|
+create table t3(a int primary key auto_increment)|
+create table t4(a int primary key auto_increment)|
+create procedure bug14304()
+begin
+insert into t3 set a=null;
+insert into t4 set a=null;
+insert into t4 set a=null;
+insert into t4 set a=null;
+insert into t4 set a=null;
+insert into t4 set a=null;
+insert into t4 select null as a;
+insert into t3 set a=null;
+insert into t3 set a=null;
+select * from t3;
+end|
+call bug14304()|
+a
+1
+2
+3
+drop procedure bug14304|
+drop table t3, t4|
+drop procedure if exists bug14376|
+create procedure bug14376()
+begin
+declare x int default x;
+end|
+call bug14376()|
+ERROR 42S22: Unknown column 'x' in 'field list'
+drop procedure bug14376|
+create procedure bug14376()
+begin
+declare x int default 42;
+begin
+declare x int default x;
+select x;
+end;
+end|
+call bug14376()|
+x
+42
+drop procedure bug14376|
+create procedure bug14376(x int)
+begin
+declare x int default x;
+select x;
+end|
+call bug14376(4711)|
+x
+4711
+drop procedure bug14376|
+drop procedure if exists bug5967|
+drop table if exists t3|
+create table t3 (a varchar(255))|
+insert into t3 (a) values ("a - table column")|
+create procedure bug5967(a varchar(255))
+begin
+declare i varchar(255);
+declare c cursor for select a from t3;
+select a;
+select a from t3 into i;
+select i as 'Parameter takes precedence over table column'; open c;
+fetch c into i;
+close c;
+select i as 'Parameter takes precedence over table column in cursors';
+begin
+declare a varchar(255) default 'a - local variable';
+declare c1 cursor for select a from t3;
+select a as 'A local variable takes precedence over parameter';
+open c1;
+fetch c1 into i;
+close c1;
+select i as 'A local variable takes precedence over parameter in cursors';
+begin
+declare a varchar(255) default 'a - local variable in a nested compound statement';
+declare c2 cursor for select a from t3;
+select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement';
+select a from t3 into i;
+select i as 'A local variable in a nested compound statement takes precedence over table column';
+open c2;
+fetch c2 into i;
+close c2;
+select i as 'A local variable in a nested compound statement takes precedence over table column in cursors';
+end;
+end;
+end|
+call bug5967("a - stored procedure parameter")|
+a
+a - stored procedure parameter
+Parameter takes precedence over table column
+a - stored procedure parameter
+Parameter takes precedence over table column in cursors
+a - stored procedure parameter
+A local variable takes precedence over parameter
+a - local variable
+A local variable takes precedence over parameter in cursors
+a - local variable
+A local variable in a nested compound statement takes precedence over a local variable in the outer statement
+a - local variable in a nested compound statement
+A local variable in a nested compound statement takes precedence over table column
+a - local variable in a nested compound statement
+A local variable in a nested compound statement takes precedence over table column in cursors
+a - local variable in a nested compound statement
+drop procedure bug5967|
+drop procedure if exists bug13012|
+create procedure bug13012()
+BEGIN
+REPAIR TABLE t1;
+BACKUP TABLE t1 to '../tmp';
+DROP TABLE t1;
+RESTORE TABLE t1 FROM '../tmp';
+END|
+call bug13012()|
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+Table Op Msg_type Msg_text
+test.t1 backup status OK
+Table Op Msg_type Msg_text
+test.t1 restore status OK
+drop procedure bug13012|
+create view v1 as select * from t1|
+create procedure bug13012()
+BEGIN
+REPAIR TABLE t1,t2,t3,v1;
+OPTIMIZE TABLE t1,t2,t3,v1;
+ANALYZE TABLE t1,t2,t3,v1;
+END|
+call bug13012()|
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+test.t3 repair status OK
+test.v1 repair error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+test.t3 optimize status OK
+test.v1 optimize error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
+test.t2 analyze status Table is already up to date
+test.t3 analyze status Table is already up to date
+test.v1 analyze error 'test.v1' is not BASE TABLE
+Warnings:
+Error 1347 'test.v1' is not BASE TABLE
+call bug13012()|
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+test.t3 repair status OK
+test.v1 repair error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+test.t3 optimize status OK
+test.v1 optimize error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
+test.t2 analyze status Table is already up to date
+test.t3 analyze status Table is already up to date
+test.v1 analyze error 'test.v1' is not BASE TABLE
+Warnings:
+Error 1347 'test.v1' is not BASE TABLE
+call bug13012()|
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+test.t3 repair status OK
+test.v1 repair error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+test.t3 optimize status OK
+test.v1 optimize error 'test.v1' is not BASE TABLE
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
+test.t2 analyze status Table is already up to date
+test.t3 analyze status Table is already up to date
+test.v1 analyze error 'test.v1' is not BASE TABLE
+Warnings:
+Error 1347 'test.v1' is not BASE TABLE
+drop procedure bug13012|
+drop view v1;
+select * from t1|
+id data
+aa 0
+aa 1
+aa 2
+aa 3
+aa 4
+aa 5
+aa 6
+aa 7
+aa 8
+aa 9
+drop schema if exists mysqltest1|
+Warnings:
+Note 1008 Can't drop database 'mysqltest1'; database doesn't exist
+drop schema if exists mysqltest2|
+Warnings:
+Note 1008 Can't drop database 'mysqltest2'; database doesn't exist
+drop schema if exists mysqltest3|
+Warnings:
+Note 1008 Can't drop database 'mysqltest3'; database doesn't exist
+create schema mysqltest1|
+create schema mysqltest2|
+create schema mysqltest3|
+use mysqltest3|
+create procedure mysqltest1.p1 (out prequestid varchar(100))
+begin
+call mysqltest2.p2('call mysqltest3.p3(1, 2)');
+end|
+create procedure mysqltest2.p2(in psql text)
+begin
+declare lsql text;
+set @lsql= psql;
+prepare lstatement from @lsql;
+execute lstatement;
+deallocate prepare lstatement;
+end|
+create procedure mysqltest3.p3(in p1 int)
+begin
+select p1;
+end|
+call mysqltest1.p1(@rs)|
+ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
+call mysqltest1.p1(@rs)|
+ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
+call mysqltest1.p1(@rs)|
+ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
+drop schema if exists mysqltest1|
+drop schema if exists mysqltest2|
+drop schema if exists mysqltest3|
+use test|
+drop table if exists t3|
+drop procedure if exists bug15441|
+create table t3 (id int not null primary key, county varchar(25))|
+insert into t3 (id, county) values (1, 'York')|
+create procedure bug15441(c varchar(25))
+begin
+update t3 set id=2, county=values(c);
+end|
+call bug15441('county')|
+ERROR 42S22: Unknown column 'c' in 'field list'
+drop procedure bug15441|
+create procedure bug15441(county varchar(25))
+begin
+declare c varchar(25) default "hello";
+insert into t3 (id, county) values (1, county)
+on duplicate key update county= values(county);
+select * from t3;
+update t3 set id=2, county=values(id);
+select * from t3;
+end|
+call bug15441('Yale')|
+id county
+1 Yale
+id county
+2 NULL
+drop table t3|
+drop procedure bug15441|
+drop procedure if exists bug14498_1|
+drop procedure if exists bug14498_2|
+drop procedure if exists bug14498_3|
+drop procedure if exists bug14498_4|
+drop procedure if exists bug14498_5|
+create procedure bug14498_1()
+begin
+declare continue handler for sqlexception select 'error' as 'Handler';
+if v then
+select 'yes' as 'v';
+else
+select 'no' as 'v';
+end if;
+select 'done' as 'End';
+end|
+create procedure bug14498_2()
+begin
+declare continue handler for sqlexception select 'error' as 'Handler';
+while v do
+select 'yes' as 'v';
+end while;
+select 'done' as 'End';
+end|
+create procedure bug14498_3()
+begin
+declare continue handler for sqlexception select 'error' as 'Handler';
+repeat
+select 'maybe' as 'v';
+until v end repeat;
+select 'done' as 'End';
+end|
+create procedure bug14498_4()
+begin
+declare continue handler for sqlexception select 'error' as 'Handler';
+case v
+when 1 then
+select '1' as 'v';
+when 2 then
+select '2' as 'v';
+else
+select '?' as 'v';
+end case;
+select 'done' as 'End';
+end|
+create procedure bug14498_5()
+begin
+declare continue handler for sqlexception select 'error' as 'Handler';
+case
+when v = 1 then
+select '1' as 'v';
+when v = 2 then
+select '2' as 'v';
+else
+select '?' as 'v';
+end case;
+select 'done' as 'End';
+end|
+call bug14498_1()|
+Handler
+error
+End
+done
+call bug14498_2()|
+Handler
+error
+End
+done
+call bug14498_3()|
+v
+maybe
+Handler
+error
+End
+done
+call bug14498_4()|
+Handler
+error
+End
+done
+call bug14498_5()|
+Handler
+error
+End
+done
+drop procedure bug14498_1|
+drop procedure bug14498_2|
+drop procedure bug14498_3|
+drop procedure bug14498_4|
+drop procedure bug14498_5|
+drop table if exists t3|
+drop procedure if exists bug15231_1|
+drop procedure if exists bug15231_2|
+drop procedure if exists bug15231_3|
+drop procedure if exists bug15231_4|
+create table t3 (id int not null)|
+create procedure bug15231_1()
+begin
+declare xid integer;
+declare xdone integer default 0;
+declare continue handler for not found set xdone = 1;
+set xid=null;
+call bug15231_2(xid);
+select xid, xdone;
+end|
+create procedure bug15231_2(inout ioid integer)
+begin
+select "Before NOT FOUND condition is triggered" as '1';
+select id into ioid from t3 where id=ioid;
+select "After NOT FOUND condtition is triggered" as '2';
+if ioid is null then
+set ioid=1;
+end if;
+end|
+create procedure bug15231_3()
+begin
+declare exit handler for sqlwarning
+select 'Caught it (wrong)' as 'Result';
+call bug15231_4();
+end|
+create procedure bug15231_4()
+begin
+declare x decimal(2,1);
+set x = 'zap';
+select 'Missed it (correct)' as 'Result';
+end|
+call bug15231_1()|
+1
+Before NOT FOUND condition is triggered
+2
+After NOT FOUND condtition is triggered
+xid xdone
+1 0
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+call bug15231_3()|
+Result
+Missed it (correct)
+Warnings:
+Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1
+drop table if exists t3|
+drop procedure if exists bug15231_1|
+drop procedure if exists bug15231_2|
+drop procedure if exists bug15231_3|
+drop procedure if exists bug15231_4|
+drop procedure if exists bug15011|
+create table t3 (c1 int primary key)|
+insert into t3 values (1)|
+create procedure bug15011()
+deterministic
+begin
+declare continue handler for 1062
+select 'Outer' as 'Handler';
+begin
+declare continue handler for 1062
+select 'Inner' as 'Handler';
+insert into t3 values (1);
+end;
+end|
+call bug15011()|
+Handler
+Inner
+drop procedure bug15011|
+drop table t3|
+drop table t1,t2;
diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result
index bdd32647f9d..d434f5c32ce 100644
--- a/mysql-test/r/sp_notembedded.result
+++ b/mysql-test/r/sp_notembedded.result
@@ -117,7 +117,7 @@ create procedure bug10100p(prm int, inout res int)
begin
set res = res * prm;
if prm > 1 then
-call bug10100p(prm - 1, res);
+call bug10100p(prm - 1, res);
end if;
end|
create procedure bug10100t(prm int)
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 93ad18a4de0..7def4cdcf9d 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -2987,7 +2987,6 @@ select * from (select max(fld) from t1) as foo;
max(fld)
1
drop table t1;
-purge master logs before (select adddate(current_timestamp(), interval -4 day));
CREATE TABLE t1 (a int, b int);
CREATE TABLE t2 (c int, d int);
CREATE TABLE t3 (e int);
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index a0a51013caa..edb5dee41be 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -1,4 +1,4 @@
-drop table if exists t1, t2, t3;
+drop table if exists t1, t2, t3, t4;
drop view if exists v1;
drop database if exists mysqltest;
drop function if exists f1;
@@ -785,6 +785,107 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0;
ERROR 3D000: No database selected
drop trigger t1_bi;
ERROR 3D000: No database selected
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+insert into t1 values (101);
+select @a;
+@a
+101
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t1 set @a:=new.id
+rename table t1 to t2;
+insert into t2 values (102);
+select @a;
+@a
+102
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t2 set @a:=new.id
+alter table t2 rename to t3;
+insert into t3 values (103);
+select @a;
+@a
+103
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t3 set @a:=new.id
+alter table t3 rename to t4, add column val int default 0;
+insert into t4 values (104, 1);
+select @a;
+@a
+104
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t4 set @a:=new.id
+drop trigger t1_bi;
+drop table t4;
+create database mysqltest;
+use mysqltest;
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+insert into t1 values (101);
+select @a;
+@a
+101
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test' or event_object_schema = 'mysqltest';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+mysqltest t1_bi mysqltest t1 set @a:=new.id
+rename table t1 to test.t2;
+ERROR HY000: Trigger in wrong schema
+insert into t1 values (102);
+select @a;
+@a
+102
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test' or event_object_schema = 'mysqltest';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+mysqltest t1_bi mysqltest t1 set @a:=new.id
+drop trigger test.t1_bi;
+ERROR HY000: Trigger does not exist
+drop trigger t1_bi;
+drop table t1;
+drop database mysqltest;
+use test;
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+create trigger t1_ai after insert on t1 for each row set @b:=new.id;
+insert into t1 values (101);
+select @a, @b;
+@a @b
+101 101
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t1 set @a:=new.id
+test t1_ai test t1 set @b:=new.id
+rename table t1 to t2;
+ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 13)
+insert into t1 values (102);
+select @a, @b;
+@a @b
+102 102
+select trigger_schema, trigger_name, event_object_schema,
+event_object_table, action_statement from information_schema.triggers
+where event_object_schema = 'test';
+trigger_schema trigger_name event_object_schema event_object_table action_statement
+test t1_bi test t1 set @a:=new.id
+test t1_ai test t1 set @b:=new.id
+drop trigger t1_bi;
+drop trigger t1_ai;
+drop table t1;
create table t1 (i int);
create trigger t1_bi before insert on t1 for each row return 0;
ERROR 42000: RETURN is only allowed in a FUNCTION
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index 38f8ce08368..a718ddb9a1b 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -100,13 +100,13 @@ create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
Warnings:
-Warning 1287 'TIMESTAMP(2)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(4)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(6)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(8)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(10)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(12)' is deprecated; use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(14)' is deprecated; use 'TIMESTAMP' instead
+Warning 1540 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
+Warning 1540 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead.
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result
index f7c8e8cdfa0..bd60b02cb6a 100644
--- a/mysql-test/r/upgrade.result
+++ b/mysql-test/r/upgrade.result
@@ -1,43 +1,43 @@
-drop database if exists `testdb1`;
-drop database if exists `testdb-1`;
-drop database if exists `#mysql50#testdb-1`;
-create database `testdb1`;
-create database `#mysql50#testdb-1`;
-create table `testdb1`.`t1` (a int);
-create table `testdb1`.`#mysql50#t-1` (a int);
-create table `#mysql50#testdb-1`.`t1` (a int);
-create table `#mysql50#testdb-1`.`#mysql50#t-1` (a int);
-show create database `testdb1`;
+drop database if exists `mysqltest1`;
+drop database if exists `mysqltest-1`;
+drop database if exists `#mysql50#mysqltest-1`;
+create database `mysqltest1`;
+create database `#mysql50#mysqltest-1`;
+create table `mysqltest1`.`t1` (a int);
+create table `mysqltest1`.`#mysql50#t-1` (a int);
+create table `#mysql50#mysqltest-1`.`t1` (a int);
+create table `#mysql50#mysqltest-1`.`#mysql50#t-1` (a int);
+show create database `mysqltest1`;
Database Create Database
-testdb1 CREATE DATABASE `testdb1` /*!40100 DEFAULT CHARACTER SET latin1 */
-show create database `testdb-1`;
-ERROR 42000: Unknown database 'testdb-1'
-show create database `#mysql50#testdb-1`;
+mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 */
+show create database `mysqltest-1`;
+ERROR 42000: Unknown database 'mysqltest-1'
+show create database `#mysql50#mysqltest-1`;
Database Create Database
-#mysql50#testdb-1 CREATE DATABASE `#mysql50#testdb-1` /*!40100 DEFAULT CHARACTER SET latin1 */
-show tables in `testdb1`;
-Tables_in_testdb1
+#mysql50#mysqltest-1 CREATE DATABASE `#mysql50#mysqltest-1` /*!40100 DEFAULT CHARACTER SET latin1 */
+show tables in `mysqltest1`;
+Tables_in_mysqltest1
#mysql50#t-1
t1
-show tables in `#mysql50#testdb-1`;
-Tables_in_#mysql50#testdb-1
+show tables in `#mysql50#mysqltest-1`;
+Tables_in_#mysql50#mysqltest-1
#mysql50#t-1
t1
-show create database `testdb1`;
+show create database `mysqltest1`;
Database Create Database
-testdb1 CREATE DATABASE `testdb1` /*!40100 DEFAULT CHARACTER SET latin1 */
-show create database `testdb-1`;
+mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 */
+show create database `mysqltest-1`;
Database Create Database
-testdb-1 CREATE DATABASE `testdb-1` /*!40100 DEFAULT CHARACTER SET latin1 */
-show create database `#mysql50#testdb-1`;
-ERROR 42000: Unknown database '#mysql50#testdb-1'
-show tables in `testdb1`;
-Tables_in_testdb1
+mysqltest-1 CREATE DATABASE `mysqltest-1` /*!40100 DEFAULT CHARACTER SET latin1 */
+show create database `#mysql50#mysqltest-1`;
+ERROR 42000: Unknown database '#mysql50#mysqltest-1'
+show tables in `mysqltest1`;
+Tables_in_mysqltest1
t1
t-1
-show tables in `testdb-1`;
-Tables_in_testdb-1
+show tables in `mysqltest-1`;
+Tables_in_mysqltest-1
t1
t-1
-drop database `testdb1`;
-drop database `testdb-1`;
+drop database `mysqltest1`;
+drop database `mysqltest-1`;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 5396db82965..e3d683a58dc 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2529,3 +2529,13 @@ Warnings:
Warning 1052 Column 'x' in group statement is ambiguous
DROP VIEW v1;
DROP TABLE t1;
+drop table if exists t1;
+drop view if exists v1;
+create table t1 (id int);
+create view v1 as select * from t1;
+drop table t1;
+show create view v1;
+drop view v1;
+//
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache `test`.`t1`.`id` AS `id` from `t1`
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 9f9d3b53063..99ed14951a4 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -168,7 +168,7 @@ max_error_count 10
drop table t1;
set table_type=MYISAM;
Warnings:
-Warning 1287 'table_type' is deprecated; use 'storage_engine' instead
+Warning 1540 The syntax 'table_type' is deprecated and will be removed in MySQL 5.2. Please use 'storage_engine' instead.
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
update t1 set a='abc';
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 4d66e034964..18516277c3c 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -65,6 +65,9 @@ c1
SELECT extractValue(@xml,'/a/child::*');
extractValue(@xml,'/a/child::*')
b1 b2
+SELECT extractValue(@xml,'/a/self::*');
+extractValue(@xml,'/a/self::*')
+a1 a2
SELECT extractValue(@xml,'/a/descendant::*');
extractValue(@xml,'/a/descendant::*')
b1 c1 b2
@@ -542,3 +545,31 @@ a
select extractvalue('<a>a<b>B</b></a>','a|/b');
extractvalue('<a>a<b>B</b></a>','a|/b')
a
+select extractvalue('<a>A</a>','/<a>');
+ERROR HY000: XPATH syntax error: '>'
+select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
+ERROR HY000: XPATH syntax error: '!'
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*')
+B C
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*')
+A
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*')
+A B C
+select extractvalue('<A_B>A</A_B>','/A_B');
+extractvalue('<A_B>A</A_B>','/A_B')
+A
+select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
+extractvalue('<a>Jack</a>','/a[contains(../a,"J")]')
+Jack
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
+extractvalue('<a>Jack</a>','/a[contains(../a,"j")]')
+Jack
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
+extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin)
+
+select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
+extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]')
+
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 7871b3647e3..35cda11646a 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -270,3 +270,12 @@ VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
SELECT * FROM t1;
DROP TABLE t1;
+
+#bug #9088 BIGINT WHERE CLAUSE
+create table t1 (bigint_col bigint unsigned);
+insert into t1 values (17666000000000000000);
+select * from t1 where bigint_col=17666000000000000000;
+select * from t1 where bigint_col='17666000000000000000';
+drop table t1;
+
+
diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test
index 1ac0cfebb28..4ab6ee9eaf1 100644
--- a/mysql-test/t/binary.test
+++ b/mysql-test/t/binary.test
@@ -89,3 +89,15 @@ show create table t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#16857
+#
+create table t1 (col1 binary(4));
+insert into t1 values ('a'),('a ');
+select hex(col1) from t1;
+alter table t1 modify col1 binary(10);
+select hex(col1) from t1;
+insert into t1 values ('b'),('b ');
+select hex(col1) from t1;
+drop table t1;
diff --git a/mysql-test/t/mix_innodb_myisam_binlog-master.opt b/mysql-test/t/binlog_row_mix_innodb_myisam-master.opt
index cb48f1aaf60..cb48f1aaf60 100644
--- a/mysql-test/t/mix_innodb_myisam_binlog-master.opt
+++ b/mysql-test/t/binlog_row_mix_innodb_myisam-master.opt
diff --git a/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt b/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt
new file mode 100644
index 00000000000..cb48f1aaf60
--- /dev/null
+++ b/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt
@@ -0,0 +1 @@
+--loose-innodb_lock_wait_timeout=2
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 555e34d5cf2..42536ce8a3b 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -3,7 +3,7 @@
#
--disable_warnings
-drop table if exists t1;
+drop table if exists t1,t2;
--enable_warnings
select CASE "b" when "a" then 1 when "b" then 2 END;
diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test
index 58e9178ef3a..017b7a1569a 100644
--- a/mysql-test/t/client_xml.test
+++ b/mysql-test/t/client_xml.test
@@ -9,13 +9,13 @@ create table t1 (
`a>b` text
);
insert into t1 values (1, 2, 'a&b a<b a>b');
---exec $MYSQL --xml test -e 'select * from t1'
+--exec $MYSQL --xml test -e "select * from t1"
--exec $MYSQL_DUMP --xml --skip-create test
---exec $MYSQL --xml test -e 'select count(*) from t1'
---exec $MYSQL --xml test -e 'select 1 < 2 from dual'
---exec $MYSQL --xml test -e 'select 1 > 2 from dual'
---exec $MYSQL --xml test -e 'select 1 & 3 from dual'
---exec $MYSQL --xml test -e 'select null from dual'
+--exec $MYSQL --xml test -e "select count(*) from t1"
+--exec $MYSQL --xml test -e "select 1 < 2 from dual"
+--exec $MYSQL --xml test -e "select 1 > 2 from dual"
+--exec $MYSQL --xml test -e "select 1 & 3 from dual"
+--exec $MYSQL --xml test -e "select null from dual"
drop table t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index d8f23b1e875..c5d1b881896 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -661,4 +661,12 @@ alter table t1 max_rows=100000000000;
show create table t1;
drop table t1;
+#
+# Bug#17530: Incorrect key truncation on table creation caused server crash.
+#
+create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
+ character set utf8 collate utf8_general_ci;
+insert into t1 values('aaa');
+drop table t1;
+
# End of 5.0 tests
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 30b298ece34..c32750d89e4 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -10,27 +10,32 @@
#
##############################################################################
#ndb_alter_table_row : sometimes wrong error 1015!=1046
+events_bugs : test case unstable (race conditions). andrey will fix
+events_stress : test case unstable. andrey will fix
+events : test case unstable. andrey will fix
ndb_autodiscover : Needs to be fixed w.r.t binlog
ndb_autodiscover2 : Needs to be fixed w.r.t binlog
ndb_binlog_basic : Results are not deterministic, Tomas will fix
ndb_binlog_ddl_multi : Bug#17038 [PATCH PENDING]
-ndb_dd_backuprestore : Bug#17045 NdbDictionaryImpl::fix_blob_events causes core
ndb_load : Bug#17233
partition_03ndb : Bug#16385
ps_7ndb : dbug assert in RBR mode when executing test suite
-rpl_bit_npk : Bug#13418
+#rpl_bit_npk : Bug#13418
rpl_ddl : Bug#15963 SBR does not show "Definer" correctly
+rpl_ndb_2innodb : Bugs#17400: delete & update of rows in table without pk fails
+rpl_ndb_2myisam : Bugs#17400: delete & update of rows in table without pk fails
rpl_ndb_auto_inc : Bug#17086
rpl_ndb_basic : Bug#16228 [IN REVIEW]
rpl_ndb_charset : Bug#17246
rpl_ndb_ddl : Bug#17400: delete & update of rows in table without pk fails
rpl_ndb_delete_nowhere : Bug#17400: delete & update of rows in table without pk fails
+rpl_ndb_innodb2ndb : Bugs#17400: delete & update of rows in table without pk fails
rpl_ndb_insert_ignore : Bugs: #17431: INSERT IGNORE INTO returns failed: 1296
-#rpl_ndb_log : result not deterministic
+rpl_ndb_myisam2ndb : Bugs#17400: delete & update of rows in table without pk fails
+rpl_ndb_log : result not deterministic
rpl_ndb_relay_space : Bug#16993
rpl_ndb_multi_update3 : Bug#17400: delete & update of rows in table without pk fails
rpl_ndb_sp007 : Bug #17290
rpl_sp : Bug#16456
rpl_until : Unstable test case, bug#15886
sp-goto : GOTO is currently is disabled - will be fixed in the future
-rpl_ndb_log : results are not deterministic
diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test
index bde8747a4ef..a261b3c0c11 100644
--- a/mysql-test/t/events.test
+++ b/mysql-test/t/events.test
@@ -48,6 +48,38 @@ drop event event2;
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
drop event event2;
+# BUG #16537 (Events: mysql.event.starts is null)
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+DROP EVENT event_starts_test;
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+DROP EVENT event_starts_test;
+#
+#
create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1;
--sleep 2
diff --git a/mysql-test/t/events_logs_tests-master.opt b/mysql-test/t/events_logs_tests-master.opt
new file mode 100644
index 00000000000..35ff7911705
--- /dev/null
+++ b/mysql-test/t/events_logs_tests-master.opt
@@ -0,0 +1 @@
+--log-slow-queries
diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test
new file mode 100644
index 00000000000..e586184c9e4
--- /dev/null
+++ b/mysql-test/t/events_logs_tests.test
@@ -0,0 +1,89 @@
+create database if not exists events_test;
+use events_test;
+--echo "We use procedure here because its statements won't be logged into the general log"
+--echo "If we had used normal select that are logged in different ways depending on whether"
+--echo "the test suite is run in normal mode or with --ps-protocol"
+delimiter |;
+CREATE procedure select_general_log()
+BEGIN
+ SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
+END|
+delimiter ;|
+--echo "Check General Query Log"
+SET GLOBAL event_scheduler=0;
+create event log_general on schedule every 1 minute do SELect 'alabala', sleep(3) from dual;
+TRUNCATE mysql.general_log;
+--echo "1 row, the current statement!"
+call select_general_log();
+SET GLOBAL event_scheduler=1;
+--echo "Wait the scheduler to start"
+--echo "Should see 3 rows - the 'SELect' is in the middle. The other two are selects from general_log"
+--sleep 2
+call select_general_log();
+DROP PROCEDURE select_general_log;
+DROP EVENT log_general;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+
+--echo "Check slow query log"
+--disable_query_log
+DELIMITER |;
+CREATE FUNCTION get_value()
+ returns INT
+ deterministic
+BEGIN
+ DECLARE var_name CHAR(255);
+ DECLARE var_val INT;
+ DECLARE done INT DEFAULT 0;
+ DECLARE cur1 CURSOR FOR SHOW GLOBAL VARIABLES LIKE 'long_query_time';
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
+ OPEN cur1;
+ FETCH cur1 INTO var_name, var_val;
+ CLOSE cur1;
+ RETURN var_val;
+end|
+DELIMITER ;|
+--enable_query_log
+--echo "Save the values"
+SET @old_global_long_query_time:=(select get_value());
+SET @old_session_long_query_time:=@@long_query_time;
+SHOW VARIABLES LIKE 'log_slow_queries';
+DROP FUNCTION get_value;
+TRUNCATE mysql.slow_log;
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+--echo "Set new values"
+SET GLOBAL long_query_time=4;
+SET SESSION long_query_time=2;
+--echo "Check that logging is working"
+SELECT SLEEP(3);
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+TRUNCATE mysql.slow_log;
+CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
+--echo "This won't go to the slow log"
+CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
+SELECT * FROM slow_event_test;
+SET GLOBAL event_scheduler=1;
+--echo "Sleep some more time than the actual event run will take"
+--sleep 5
+SHOW VARIABLES LIKE 'event_scheduler';
+--echo "Check our table. Should see 1 row"
+SELECT * FROM slow_event_test;
+--echo "Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+--echo "This should go to the slow log"
+SET SESSION long_query_time=10;
+DROP EVENT long_event;
+CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5);
+--echo "Sleep some more time than the actual event run will take"
+--sleep 7
+--echo "Check our table. Should see 2 rows"
+SELECT * FROM slow_event_test;
+--echo "Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10"
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+DROP EVENT long_event2;
+SET GLOBAL long_query_time =@old_global_long_query_time;
+SET SESSION long_query_time =@old_session_long_query_time;
+TRUNCATE mysql.slow_log;
+DROP TABLE slow_event_test;
+
+drop database events_test;
diff --git a/mysql-test/t/events_microsec.test b/mysql-test/t/events_microsec.test
new file mode 100644
index 00000000000..34855fdadff
--- /dev/null
+++ b/mysql-test/t/events_microsec.test
@@ -0,0 +1,55 @@
+create database if not exists events_test;
+use events_test;
+
+--error 1235
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1;
+--error 1235
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1;
+--error 1235
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1;
+--error 1235
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1;
+--error 1235
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1;
+
+--echo "Now create normal event and change it on SQL level"
+CREATE EVENT micro_test2 ON SCHEDULE EVERY 1 MONTH DO SELECT 1;
+UPDATE mysql.event SET interval_field='MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+--error 1235
+SHOW CREATE EVENT micro_test2;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+--echo "Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+UPDATE mysql.event SET interval_field='DAY_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+--error 1235
+SHOW CREATE EVENT micro_test2;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+--echo "Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+UPDATE mysql.event SET interval_field='SECOND_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+--error 1235
+SHOW CREATE EVENT micro_test2;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+--echo "Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+UPDATE mysql.event SET interval_field='HOUR_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+--error 1235
+SHOW CREATE EVENT micro_test2;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+--echo "Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+UPDATE mysql.event SET interval_field='MINUTE_MICROSECOND' WHERE db=database() AND definer=user() AND name='micro_test2';
+--error 1235
+SHOW CREATE EVENT micro_test2;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+--echo "Should not be running:"
+SHOW VARIABLES like 'event_scheduler';
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='event_scheduler';
+DROP EVENT micro_test2;
+
+drop database events_test;
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 4a526935491..a5041a83623 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -19,7 +19,7 @@ select version()>=_latin1"3.23.29";
select charset(version());
explain extended select database(), user();
-create table t1 (version char(40)) select database(), user(), version() as 'version';
+create table t1 (version char(60)) select database(), user(), version() as 'version';
show create table t1;
drop table t1;
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 430a3a5dd4a..ce1d0fb2271 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -429,3 +429,36 @@ disconnect con2root;
disconnect con3root;
# End of 4.1 tests
+
+#
+# Bug#17279 user with no global privs and with create
+# priv in db can create databases
+#
+
+create database TESTDB;
+create table t2(a int);
+create temporary table t1 as select * from mysql.user;
+delete from mysql.user where host='localhost';
+INSERT INTO mysql.user (host, user, password) VALUES
+('%','mysqltest_1',password('password'));
+INSERT INTO mysql.db (host, db, user, select_priv) VALUES
+('%','TESTDB','mysqltest_1','Y');
+FLUSH PRIVILEGES;
+
+connect (con1,localhost,mysqltest_1,password,TESTDB);
+
+# The user mysqltest_1 should only be allowed access to
+# database TESTDB, not TEStdb
+# On system with "lowercase names" we get error "1007: Can't create db..."
+--error 1044, 1007
+create database TEStdb;
+
+# Clean-up
+connection default;
+delete from mysql.user;
+delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
+insert into mysql.user select * from t1;
+drop table t1, t2;
+drop database TESTDB;
+flush privileges;
+
diff --git a/mysql-test/t/index_merge.test b/mysql-test/t/index_merge.test
index 10512902409..3da5711bf7a 100644
--- a/mysql-test/t/index_merge.test
+++ b/mysql-test/t/index_merge.test
@@ -357,3 +357,29 @@ explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
drop table t1;
+#
+# BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+ a int, b int,
+ filler1 char(200), filler2 char(200),
+ key(a),key(b)
+);
+insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C;
+create table t2 like t1;
+
+create table t3 (
+ a int, b int,
+ filler1 char(200), filler2 char(200),
+ key(a),key(b)
+) engine=merge union=(t1,t2);
+
+--replace_column 9 #
+explain select * from t1 where a=1 and b=1;
+--replace_column 9 #
+explain select * from t3 where a=1 and b=1;
+
+drop table t3;
+drop table t0, t1, t2;
diff --git a/mysql-test/t/innodb_notembedded.test b/mysql-test/t/innodb_notembedded.test
index 1d8a590be78..53332d9fda4 100644
--- a/mysql-test/t/innodb_notembedded.test
+++ b/mysql-test/t/innodb_notembedded.test
@@ -1,6 +1,10 @@
-- source include/not_embedded.inc
-- source include/have_innodb.inc
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
connect (a,localhost,root,,);
connect (b,localhost,root,,);
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 553aaf987bb..90abc61ca07 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -523,6 +523,12 @@ select t1.b from v1a;
-- error 1054
select * from v1a join v1b on t1.b = t2.b;
+#
+# Bug #17523 natural join and information_schema
+#
+select * from information_schema.statistics join information_schema.columns
+ using(table_name,column_name) where table_name='user';
+
drop table t1;
drop table t2;
drop table t3;
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 34d2e7dbd54..fcd127e3e98 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -135,6 +135,6 @@ select @@character_set_filesystem;
LOAD DATA INFILE 't@002d1' INTO TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
---exec rm $MYSQL_TEST_DIR/var/master-data/test/t@002d1
+--exec rm $MYSQLTEST_VARDIR/master-data/test/t@002d1
SET character_set_filesystem=default;
select @@character_set_filesystem;
diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test
index 797d667b0a3..b61deeac001 100644
--- a/mysql-test/t/mysql_client_test.test
+++ b/mysql-test/t/mysql_client_test.test
@@ -9,7 +9,6 @@
# var/log/mysql_client_test.trace
--disable_result_log
---exec echo $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
# End of 4.1 tests
diff --git a/mysql-test/t/mysql_protocols.test b/mysql-test/t/mysql_protocols.test
index 0253c2b5d17..5eba780420c 100644
--- a/mysql-test/t/mysql_protocols.test
+++ b/mysql-test/t/mysql_protocols.test
@@ -1,5 +1,7 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
+# Windows does not have SOCKET, but will try to create a PIPE as well as MEMORY
+--source include/not_windows.inc
# test for Bug #4998 "--protocol doesn't reject bad values"
diff --git a/mysql-test/t/mysqlbinlog_base64.test b/mysql-test/t/mysqlbinlog_base64.test
index 3aab767f9fa..66aaff83254 100644
--- a/mysql-test/t/mysqlbinlog_base64.test
+++ b/mysql-test/t/mysqlbinlog_base64.test
@@ -10,19 +10,19 @@ update t1 set a=a+2 where a=2;
update t1 set a=a+2 where a=3;
create table t2 (word varchar(20));
-load data infile '../../std_data/words.dat' into table t2;
+load data infile '../std_data_ln/words.dat' into table t2;
#
# Save binlog
#
---exec $MYSQL_BINLOG --hexdump $MYSQL_TEST_DIR/var/log/master-bin.000001 > $MYSQL_TEST_DIR/var/tmp/mysqlbinlog_base64.sql
+--exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
#
# Clear database and restore from binlog
#
drop table t1;
drop table t2;
---exec $MYSQL test < $MYSQL_TEST_DIR/var/tmp/mysqlbinlog_base64.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
#
# Verify that all binlog events have been executed
@@ -33,6 +33,6 @@ select * from t2;
#
# Test cleanup
#
---exec rm $MYSQL_TEST_DIR/var/tmp/mysqlbinlog_base64.sql
+--exec rm $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
drop table t1;
drop table t2;
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index 167ef435bee..61d64c733d7 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -5,6 +5,8 @@
# depends on the presence of the log tables (which are CSV-based).
--source include/have_csv.inc
+DROP SCHEMA test;
+CREATE SCHEMA test;
#
# Bug #13783 mysqlcheck tries to optimize and analyze information_schema
#
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index dc711975569..b1ddfc97c70 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -840,11 +840,11 @@ DROP TABLE t1, t2;
# Bugs #9136, #12917: problems with --defaults-extra-file option
#
---exec echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf
---exec echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf
+--system echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf
+--system echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf
--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1
--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1
---exec rm $MYSQLTEST_VARDIR/tmp/tmp.cnf
+--system rm $MYSQLTEST_VARDIR/tmp/tmp.cnf
#
# Test of fix to BUG 12597
@@ -960,15 +960,16 @@ set time_zone=default;
#
--disable_warnings
DROP TABLE IF EXISTS `t1 test`;
+DROP TABLE IF EXISTS `t2 test`;
+--enable_warnings
+
CREATE TABLE `t1 test` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t2 test` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---enable_warnings
DELIMITER //;
CREATE TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
@@ -983,11 +984,10 @@ SELECT * FROM `t2 test`;
# quoted
--exec $MYSQL_DUMP --skip-comments --compatible=ansi --triggers test
---disable_warnings
DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
---enable_warnings
+
#
# BUG# 12838 mysqldump -x with views exits with error
#
@@ -1050,6 +1050,84 @@ DROP TRIGGER tr1;
DROP TABLE t1;
#
+
+#
+# Bug 14871 Invalid view dump output
+#
+
+create table t1 (a int);
+insert into t1 values (289), (298), (234), (456), (789);
+create definer = CURRENT_USER view v1 as select * from t1;
+create SQL SECURITY INVOKER view v2 as select * from t1;
+create view v3 as select * from t1 with local check option;
+create algorithm=merge view v4 as select * from t1 with cascaded check option;
+create algorithm =temptable view v5 as select * from t1;
+
+# dump tables and views
+--exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug14871.sql
+
+# drop the db, tables and views
+drop table t1;
+drop view v1, v2, v3, v4, v5;
+
+# Reload dump
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14871.sql
+
+# check that all tables and views could be created
+show tables;
+select * from v3 order by a;
+
+drop table t1;
+drop view v1, v2, v3, v4, v5;
+
+
+#
+# Bug #16878 dump of trigger
+#
+
+create table t1 (a int, created datetime);
+create table t2 (b int, created datetime);
+create trigger tr1 before insert on t1 for each row set
+new.created=now();
+delimiter |;
+create trigger tr2 after insert on t1
+for each row
+begin
+ insert into t2 set b=new.a and created=new.created;
+end|
+delimiter ;|
+
+# dump table and trigger
+--exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug16878.sql
+drop trigger tr1;
+drop trigger tr2;
+drop table t1, t2;
+
+# reload dump
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug16878.sql
+--replace_column 6 #
+show triggers;
+drop trigger tr1;
+drop trigger tr2;
+drop table t1, t2;
+
+
+#
+# Bug#14857 Reading dump files with single statement stored routines fails.
+# fixed by patch for bug#16878
+#
+#
+DELIMITER |;
+/*!50003 CREATE FUNCTION `f`() RETURNS bigint(20)
+return 42 */|
+/*!50003 CREATE PROCEDURE `p`()
+select 42 */|
+DELIMITER ;|
+show create function f;
+show create procedure p;
+drop function f;
+drop procedure p;
+
# Added for use-thread option
#
create table t1 (a text , b text);
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index f78becc6868..f10e28327f5 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -431,7 +431,7 @@ echo ;
# Illegal use of echo
--error 1
---exec echo "echo $;" | $MYSQL_TEST 2>&1
+--exec echo "echo \$;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
@@ -518,19 +518,19 @@ echo $novar1;
--exec echo "let ;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let $=hi;" | $MYSQL_TEST 2>&1
+--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let $1 hi;" | $MYSQL_TEST 2>&1
+--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let $m hi;" | $MYSQL_TEST 2>&1
+--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let $hi;" | $MYSQL_TEST 2>&1
+--exec echo "let \$hi;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let $ hi;" | $MYSQL_TEST 2>&1
+--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let =hi;" | $MYSQL_TEST 2>&1
@@ -664,10 +664,14 @@ real_sleep 1;
# Missing parameter
--error 1
--exec echo "sleep ;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "real_sleep ;" | $MYSQL_TEST 2>&1
# Illegal parameter
--error 1
--exec echo "sleep abc;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "real_sleep abc;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# Test inc
diff --git a/mysql-test/t/ndb_alter_table_row.test b/mysql-test/t/ndb_alter_table_row.test
index 5dbfa26289b..9c834e0dd20 100644
--- a/mysql-test/t/ndb_alter_table_row.test
+++ b/mysql-test/t/ndb_alter_table_row.test
@@ -13,10 +13,12 @@ engine=ndb;
insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
create index c on t1(c);
connection server2;
+show indexes from t1;
select * from t1 where c = 'two';
connection server1;
alter table t1 drop index c;
connection server2;
+show indexes from t1;
select * from t1 where c = 'two';
connection server1;
drop table t1;
diff --git a/mysql-test/t/ndb_binlog_basic.test b/mysql-test/t/ndb_binlog_basic.test
index 86443dcd831..640fac40bb6 100644
--- a/mysql-test/t/ndb_binlog_basic.test
+++ b/mysql-test/t/ndb_binlog_basic.test
@@ -19,7 +19,7 @@ create table t1 (a int primary key) engine=ndb;
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
save_master_pos;
--replace_column 1 #
-select @max_epoch:=max(epoch)-1 from cluster_replication.binlog_index;
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
delete from t1;
alter table t1 add (b int);
@@ -38,12 +38,12 @@ drop table t2;
# (save_master_pos waits for last gcp to complete, ensuring that we have
# the expected data in the binlog)
save_master_pos;
-select inserts from cluster_replication.binlog_index where epoch > @max_epoch and inserts > 5;
-select deletes from cluster_replication.binlog_index where epoch > @max_epoch and deletes > 5;
+select inserts from cluster.binlog_index where epoch > @max_epoch and inserts > 5;
+select deletes from cluster.binlog_index where epoch > @max_epoch and deletes > 5;
select inserts,updates,deletes from
- cluster_replication.binlog_index where epoch > @max_epoch and updates > 0;
+ cluster.binlog_index where epoch > @max_epoch and updates > 0;
select schemaops from
- cluster_replication.binlog_index where epoch > @max_epoch and schemaops > 0;
+ cluster.binlog_index where epoch > @max_epoch and schemaops > 0;
#
# check that purge clears the binlog_index
@@ -51,7 +51,7 @@ select schemaops from
flush logs;
--sleep 1
purge master logs before now();
-select count(*) from cluster_replication.binlog_index;
+select count(*) from cluster.binlog_index;
#
# several tables in different databases
@@ -66,11 +66,11 @@ use test;
insert into mysqltest.t1 values (2,1),(2,2);
save_master_pos;
--replace_column 1 #
-select @max_epoch:=max(epoch)-1 from cluster_replication.binlog_index;
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
drop table t1;
drop database mysqltest;
select inserts,updates,deletes from
- cluster_replication.binlog_index where epoch > @max_epoch and inserts > 0;
+ cluster.binlog_index where epoch > @max_epoch and inserts > 0;
select schemaops from
- cluster_replication.binlog_index where epoch > @max_epoch and schemaops > 0;
+ cluster.binlog_index where epoch > @max_epoch and schemaops > 0;
diff --git a/mysql-test/t/ndb_binlog_basic2.test b/mysql-test/t/ndb_binlog_basic2.test
new file mode 100644
index 00000000000..9fa9f2f965a
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_basic2.test
@@ -0,0 +1,14 @@
+-- source include/have_ndb.inc
+
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=row;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=statement;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=row;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=statement;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=default;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=default;
diff --git a/mysql-test/t/ndb_binlog_multi.test b/mysql-test/t/ndb_binlog_multi.test
index 71edd70c14f..4bdc89fa3bd 100644
--- a/mysql-test/t/ndb_binlog_multi.test
+++ b/mysql-test/t/ndb_binlog_multi.test
@@ -14,7 +14,7 @@ drop table if exists t1,t2;
# and sets up the replication correctly
#
-# no tables and nothing in cluster_replication.binlog_index;
+# no tables and nothing in cluster.binlog_index;
connection server1;
SHOW TABLES;
@@ -33,7 +33,7 @@ select * from t2 order by a;
save_master_pos;
--replace_column 1 <the_epoch>
SELECT @the_epoch:=epoch,inserts,updates,deletes,schemaops FROM
- cluster_replication.binlog_index ORDER BY epoch DESC LIMIT 1;
+ cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
let $the_epoch= `SELECT @the_epoch`;
# see if we got something on server1
@@ -41,7 +41,7 @@ connection server1;
SELECT * FROM t2 ORDER BY a;
--replace_result $the_epoch <the_epoch>
eval SELECT inserts,updates,deletes,schemaops FROM
- cluster_replication.binlog_index WHERE epoch=$the_epoch;
+ cluster.binlog_index WHERE epoch=$the_epoch;
# drop the table on server1
DROP TABLE t2;
@@ -50,12 +50,12 @@ INSERT INTO t1 VALUES (1),(2);
save_master_pos;
--replace_column 1 <the_epoch2>
SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM
- cluster_replication.binlog_index ORDER BY epoch DESC LIMIT 1;
+ cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
let $the_epoch2= `SELECT @the_epoch2`;
--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2>
eval SELECT inserts,updates,deletes,schemaops FROM
- cluster_replication.binlog_index WHERE epoch > $the_epoch AND epoch < $the_epoch2;
+ cluster.binlog_index WHERE epoch > $the_epoch AND epoch < $the_epoch2;
drop table t1;
# flush on server2
@@ -63,7 +63,7 @@ connection server2;
SHOW TABLES;
--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2>
eval SELECT inserts,updates,deletes,schemaops FROM
- cluster_replication.binlog_index WHERE epoch > $the_epoch AND epoch < $the_epoch2;
+ cluster.binlog_index WHERE epoch > $the_epoch AND epoch < $the_epoch2;
# reset
connection server1;
diff --git a/mysql-test/t/ndb_cache_multi2.test b/mysql-test/t/ndb_cache_multi2.test
index 5a78380097e..4abb537624a 100644
--- a/mysql-test/t/ndb_cache_multi2.test
+++ b/mysql-test/t/ndb_cache_multi2.test
@@ -10,6 +10,7 @@ drop table if exists t1, t2;
# Turn on and reset query cache on server1
connection server1;
+echo == Connected to server1 ==;
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
@@ -18,6 +19,7 @@ flush status;
# Turn on and reset query cache on server2
connection server2;
+echo == Connected to server2 ==;
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
@@ -27,11 +29,14 @@ flush status;
# Create test tables in NDB and load them into cache
# on server1
connection server1;
+echo == Connected to server1 ==;
create table t1 (a int) engine=ndbcluster;
create table t2 (a int) engine=ndbcluster;
insert into t1 value (2);
insert into t2 value (3);
select * from t1;
+# Run the check query once to load it into qc on server1
+select a != 3 from t1;
select * from t2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
@@ -40,6 +45,7 @@ show status like "Qcache_hits";
# Connect server2, load table in to cache, then update the table
connection server2;
+echo == Connected to server2 ==;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
@@ -49,12 +55,10 @@ show status like "Qcache_inserts";
show status like "Qcache_hits";
update t1 set a=3 where a=2;
-# Connect to server1 and check that cache is invalidated
+# Connect to server1 and check that cache is invalidated
# and correct data is returned
connection server1;
-show status like "Qcache_queries_in_cache";
-show status like "Qcache_inserts";
-show status like "Qcache_hits";
+echo == Connected to server1 ==;
# Loop and wait for max 10 seconds until query cache thread
# has invalidated the cache and the column a in t1 is equal to 3
@@ -75,8 +79,6 @@ select * from t1;
# There should now be three queries in the cache
show status like "Qcache_queries_in_cache";
-# And inserts should be four
-show status like "Qcache_inserts";
drop table t1, t2;
diff --git a/mysql-test/t/ndb_config.test b/mysql-test/t/ndb_config.test
index e40e89d76bd..4787abe86e2 100644
--- a/mysql-test/t/ndb_config.test
+++ b/mysql-test/t/ndb_config.test
@@ -4,7 +4,7 @@
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
---exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
+--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null
diff --git a/mysql-test/t/ndb_dd_dump.test b/mysql-test/t/ndb_dd_dump.test
index e44822e83c4..13d4fd86396 100644
--- a/mysql-test/t/ndb_dd_dump.test
+++ b/mysql-test/t/ndb_dd_dump.test
@@ -177,7 +177,7 @@ INSERT INTO t2 VALUES
INSERT INTO t3 VALUES
(1,1,1);
---exec $MYSQL_DUMP --skip-comments --compact -Y test > var/tmp/ndb_dd_dump.sql
+--exec $MYSQL_DUMP --skip-comments --compact -Y test > $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql
DROP TABLE t1;
DROP TABLE t2;
@@ -206,7 +206,7 @@ DROP TABLESPACE ts3 ENGINE = NDB;
DROP LOGFILE GROUP lg1 ENGINE = NDB;
DROP LOGFILE GROUP lg2 ENGINE = NDB;
---exec $MYSQL test < var/tmp/ndb_dd_dump.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql
SELECT DISTINCT
LOGFILE_GROUP_NAME,
diff --git a/mysql-test/t/ndb_load.test b/mysql-test/t/ndb_load.test
index 72a5b53eaad..af2df70b74e 100644
--- a/mysql-test/t/ndb_load.test
+++ b/mysql-test/t/ndb_load.test
@@ -12,12 +12,12 @@ DROP TABLE IF EXISTS t1;
# should give duplicate key
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
--error 1022
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ;
DROP TABLE t1;
# now without a primary key we should be ok
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
DROP TABLE t1;
diff --git a/mysql-test/t/ndb_partition_error.test b/mysql-test/t/ndb_partition_error.test
index cf570cc0234..c84266b66f7 100644
--- a/mysql-test/t/ndb_partition_error.test
+++ b/mysql-test/t/ndb_partition_error.test
@@ -44,3 +44,15 @@ partitions 3
partition x3 values less than (20));
drop table t1;
+
+#
+# Bug #17763 mysqld cores with list partitioning if update to missing partition
+#
+CREATE TABLE t1 (id INT) ENGINE=NDB
+ PARTITION BY LIST(id)
+ (PARTITION p0 VALUES IN (2, 4),
+ PARTITION p1 VALUES IN (42, 142));
+INSERT INTO t1 VALUES (2);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+UPDATE t1 SET id=5 WHERE id=2;
+DROP TABLE t1;
diff --git a/mysql-test/t/ndb_partition_range.test b/mysql-test/t/ndb_partition_range.test
index 2eb324ccdcb..981467d4055 100644
--- a/mysql-test/t/ndb_partition_range.test
+++ b/mysql-test/t/ndb_partition_range.test
@@ -93,3 +93,168 @@ show create table t1;
drop table t1;
+#
+# Bug #17499, #17687
+# Alter partitioned NDB table causes mysqld to core
+#
+
+CREATE TABLE t1
+ (id MEDIUMINT NOT NULL,
+ b1 BIT(8),
+ vc VARCHAR(255),
+ bc CHAR(255),
+ d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0,
+ total BIGINT UNSIGNED,
+ y YEAR,
+ t DATE) ENGINE=NDB
+ PARTITION BY RANGE (YEAR(t))
+ (PARTITION p0 VALUES LESS THAN (1901),
+ PARTITION p1 VALUES LESS THAN (1946),
+ PARTITION p2 VALUES LESS THAN (1966),
+ PARTITION p3 VALUES LESS THAN (1986),
+ PARTITION p4 VALUES LESS THAN (2005),
+ PARTITION p5 VALUES LESS THAN MAXVALUE);
+
+INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+SELECT * FROM t1;
+ALTER TABLE t1 ENGINE=MYISAM;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE LOGFILE GROUP lg1
+ ADD UNDOFILE 'undofile.dat'
+ INITIAL_SIZE 16M
+ UNDO_BUFFER_SIZE=1M
+ ENGINE=NDB;
+
+CREATE TABLESPACE ts1
+ ADD DATAFILE 'datafile.dat'
+ USE LOGFILE GROUP lg1
+ INITIAL_SIZE 12M
+ ENGINE NDB;
+
+CREATE TABLE test.t1 (
+ a1 INT,
+ a2 TEXT NOT NULL,
+ a3 BIT NOT NULL,
+ a4 DECIMAL(8,3),
+ a5 INT NOT NULL,
+ a6 INT,
+ PRIMARY KEY(a1))
+ TABLESPACE ts1 STORAGE DISK ENGINE=NDB
+ PARTITION BY LIST (a1)
+ (PARTITION p0 VALUES IN (1,2,3,4,5),
+ PARTITION p1 VALUES IN (6,7,8,9, 10),
+ PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
+
+# Alter table directly without any statements inbetween
+ALTER TABLE test.t1 DROP COLUMN a6;
+ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255);
+
+let $j= 15;
+--disable_query_log
+while ($j)
+{
+eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
+b'1',$j.00,$j+1,"By NIK $j");
+dec $j;
+}
+--enable_query_log
+SELECT COUNT(*) FROM test.t1;
+
+ALTER TABLE test.t1 DROP COLUMN a4;
+SELECT COUNT(*) FROM test.t1;
+
+DROP TABLE t1;
+
+CREATE TABLE test.t1 (
+ a1 INT,
+ a2 TEXT NOT NULL,
+ a3 BIT NOT NULL,
+ a4 DECIMAL(8,3),
+ a5 INT NOT NULL,
+ a6 VARCHAR(255),
+ PRIMARY KEY(a1))
+ TABLESPACE ts1 STORAGE DISK ENGINE=NDB
+ PARTITION BY HASH(a1)
+ PARTITIONS 4;
+
+let $j= 15;
+--disable_query_log
+while ($j)
+{
+eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA",
+b'1',$j.00,$j+1,"By NIK $j");
+dec $j;
+}
+--enable_query_log
+SELECT COUNT(*) FROM test.t1;
+
+ALTER TABLE test.t1 DROP COLUMN a4;
+SELECT COUNT(*) FROM test.t1;
+
+DROP TABLE t1;
+
+ALTER TABLESPACE ts1
+ DROP DATAFILE 'datafile.dat'
+ ENGINE=NDB;
+DROP TABLESPACE ts1 ENGINE=NDB;
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+
+
+#
+# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test
+#
+
+CREATE TABLE t1
+ (id MEDIUMINT NOT NULL,
+ b1 BIT(8),
+ vc VARCHAR(255),
+ bc CHAR(255),
+ d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0,
+ total BIGINT UNSIGNED,
+ y YEAR,
+ t DATE) ENGINE=NDB
+ PARTITION BY LIST(id)
+ (PARTITION p0 VALUES IN (2, 4),
+ PARTITION p1 VALUES IN (42, 142));
+
+INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+SELECT * FROM t1;
+ALTER TABLE t1 ADD PARTITION
+ (PARTITION p2 VALUES IN (412));
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Bug #17806 Update on NDB table with list partition causes mysqld to core
+# Bug #16385 Partitions: crash when updating a range partitioned NDB table
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null)
+partition by list(a)
+partitions 2
+(partition x123 values in (1,5,6),
+ partition x234 values in (4,7,8));
+INSERT into t1 VALUES (5,1,1);
+select * from t1;
+UPDATE t1 SET a=8 WHERE a=5 AND b=1;
+select * from t1;
+drop table t1;
+
+CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb
+PARTITION BY RANGE(f1)
+( PARTITION part1 VALUES LESS THAN (2),
+PARTITION part2 VALUES LESS THAN (1000));
+INSERT INTO t1 VALUES(1, '---1---');
+INSERT INTO t1 VALUES(2, '---2---');
+select * from t1 order by f1;
+UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2;
+select * from t1 order by f1;
+UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1;
+select * from t1 order by f1;
+drop table t1;
diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test
index f340b62adae..dc28a9f5408 100644
--- a/mysql-test/t/ndb_restore.test
+++ b/mysql-test/t/ndb_restore.test
@@ -143,10 +143,10 @@ create table t8 engine=myisam as select * from t8_c;
create table t9 engine=myisam as select * from t9_c;
---exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT
+--source include/ndb_backup.inc
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
# random output order??
#show tables;
@@ -230,10 +230,10 @@ PARTITIONS 4;
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
---exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT
+--source include/ndb_backup.inc
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 2 -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-2 >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 2 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-2 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
select count(*) from t1;
select count(*) from t1_c;
@@ -290,8 +290,8 @@ select count(*)
select * from t9_c) a;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 2 -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-2 >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 2 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-2 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
select count(*) from t1;
select count(*) from t1_c;
@@ -348,7 +348,7 @@ select count(*)
select * from t9_c) a;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b 2 -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-2 2>&1 | grep Translate || true
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id 2>&1 | grep Translate || true
#
# Cleanup
@@ -363,6 +363,6 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
# Test BUG#10287
#
---exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696
+--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,<the_backup_id>/"
# End of 4.1 tests
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 4760219c911..47c25652ae9 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -408,4 +408,79 @@ create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUE
alter table t1 add partition (partition x3 values in (30));
drop table t1;
+#
+# Bug #17432: Partition functions containing NULL values should return
+# LONGLONG_MIN
+#
+CREATE TABLE t1 (
+ f_int1 INTEGER, f_int2 INTEGER,
+ f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000)
+ )
+ PARTITION BY RANGE(f_int1 DIV 2)
+ SUBPARTITION BY HASH(f_int1)
+ SUBPARTITIONS 2
+ (PARTITION parta VALUES LESS THAN (0),
+ PARTITION partb VALUES LESS THAN (5),
+ PARTITION parte VALUES LESS THAN (10),
+ PARTITION partf VALUES LESS THAN (2147483647));
+INSERT INTO t1 SET f_int1 = NULL , f_int2 = -20, f_char1 = CAST(-20 AS CHAR),
+ f_char2 = CAST(-20 AS CHAR), f_charbig = '#NULL#';
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+SELECT * FROM t1;
+drop table t1;
+
+#
+# Bug 17430: Crash when SELECT * from t1 where field IS NULL
+#
+
+CREATE TABLE t1 (
+ f_int1 INTEGER, f_int2 INTEGER,
+ f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000) )
+ PARTITION BY LIST(MOD(f_int1,2))
+ SUBPARTITION BY KEY(f_int1)
+ (PARTITION part1 VALUES IN (-1) (SUBPARTITION sp1, SUBPARTITION sp2),
+ PARTITION part2 VALUES IN (0) (SUBPARTITION sp3, SUBPARTITION sp5),
+ PARTITION part3 VALUES IN (1) (SUBPARTITION sp4, SUBPARTITION sp6));
+
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+drop table t1;
+
+#
+# Bug#14363 Partitions: failure if create in stored procedure
+#
+delimiter //;
+
+create procedure p ()
+begin
+create table t1 (s1 mediumint,s2 mediumint)
+partition by list (s2)
+(partition p1 values in (0),
+ partition p2 values in (1));
+end//
+
+call p()//
+drop procedure p//
+drop table t1;
+
+create procedure p ()
+begin
+create table t1 (a int not null,b int not null,c int not null,primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+(partition x1 values less than (1)
+ (subpartition x11,
+ subpartition x12),
+ partition x2 values less than (5)
+ (subpartition x21,
+ subpartition x22));
+end//
+
+call p()//
+drop procedure p//
+drop table t1//
+delimiter ;//
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_charset.test b/mysql-test/t/partition_charset.test
new file mode 100644
index 00000000000..27d0dc87b89
--- /dev/null
+++ b/mysql-test/t/partition_charset.test
@@ -0,0 +1,21 @@
+#
+# Test for character set related things in combination
+# with the partition storage engine
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set names utf8;
+create table t1 (s1 int)
+ partition by list (s1)
+ (partition c values in (1),
+ partition Ç values in (3));
+insert into t1 values (1),(3);
+select * from t1;
+flush tables;
+set names latin1;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/partition_mgm_err.test b/mysql-test/t/partition_mgm_err.test
index 1a24129bcf1..f72222feadd 100644
--- a/mysql-test/t/partition_mgm_err.test
+++ b/mysql-test/t/partition_mgm_err.test
@@ -169,23 +169,6 @@ ALTER TABLE t1 DROP PARTITION x0;
DROP TABLE t1;
#
-# BUG: 14354 Partitions: data directory clause fails
-#
---exec rm -rf $MYSQL_TEST_DIR/bug14354
---exec mkdir $MYSQL_TEST_DIR/bug14354
-disable_query_log;
-eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
-PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm
-DATA DIRECTORY="$MYSQL_TEST_DIR/bug14354"
-INDEX DIRECTORY="$MYSQL_TEST_DIR/bug14354");
-enable_query_log;
-INSERT INTO t1 VALUES (15);
---exec test -f $MYSQL_TEST_DIR/bug14354/t1#P#p1.MYD
---exec test -f $MYSQL_TEST_DIR/bug14354/t1#P#p1.MYI
-DROP TABLE t1;
---exec rm -rf $MYSQL_TEST_DIR/bug14354
-
-#
# Bug# 16534 - Trying to add multiple partitions crashes server
#
CREATE TABLE t1 ( id INT NOT NULL,
@@ -216,3 +199,13 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
+DROP TABLE t1;
+
+#
+#BUG 15408: Partitions: subpartition names are not unique
+#
+--error ER_SAME_NAME_PARTITION
+CREATE TABLE t1 (s1 int, s2 int) PARTITION BY LIST (s1) (
+PARTITION p1 VALUES IN (0) (SUBPARTITION p1b),
+PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
+);
diff --git a/mysql-test/t/partition_mgm_err2.test b/mysql-test/t/partition_mgm_err2.test
new file mode 100644
index 00000000000..157ba4d70d2
--- /dev/null
+++ b/mysql-test/t/partition_mgm_err2.test
@@ -0,0 +1,25 @@
+#
+# Test of partitions that require symlinks
+#
+
+-- require r/have_symlink.require
+disable_query_log;
+show variables like "have_symlink";
+enable_query_log;
+
+#
+# BUG: 14354 Partitions: data directory clause fails
+#
+--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
+--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354
+disable_query_log;
+eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
+PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm
+DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"
+INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354");
+enable_query_log;
+INSERT INTO t1 VALUES (15);
+--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYD
+--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYI
+DROP TABLE t1;
+--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 48a9f4c19f3..ffbba991fb6 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -900,6 +900,27 @@ execute stmt using @like;
deallocate prepare stmt;
drop table t1;
+#
+# Bug#13134 "Length of VARCHAR() utf8 column is increasing when table is
+# recreated with PS/SP"
+#
+
+prepare stmt from 'create table t1 (a varchar(10) character set utf8)';
+execute stmt;
+--disable_warnings
+insert into t1 (a) values (repeat('a', 20));
+--enable_warnings
+select length(a) from t1;
+drop table t1;
+execute stmt;
+--disable_warnings
+insert into t1 (a) values (repeat('a', 20));
+--enable_warnings
+# Check that the data is truncated to the same length
+select length(a) from t1;
+drop table t1;
+deallocate prepare stmt;
+
# End of 4.1 tests
#
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 15559d75d6c..7596a7ba708 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -12,7 +12,7 @@ flush query cache; # This crashed in some versions
reset query cache;
flush status;
--disable_warnings
-drop table if exists t1,t2,t3,t4,t11,t21;
+drop table if exists t1,t2,t3,t4,t11,t21,t1_1,t1_2,t9,t9_1,t9_2;
drop database if exists mysqltest;
# Fix possible left overs from other tests
diff --git a/mysql-test/t/rpl_000015.test b/mysql-test/t/rpl_000015.test
index aa866e006e0..cf93beb2bfe 100644
--- a/mysql-test/t/rpl_000015.test
+++ b/mysql-test/t/rpl_000015.test
@@ -18,7 +18,7 @@ show slave status;
change master to master_host='127.0.0.1';
# The following needs to be cleaned up when change master is fixed
---replace_result $MASTER_MYPORT MASTER_PORT $MYSQL_TCP_PORT MASTER_PORT
+--replace_result $MYSQL_TCP_PORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
--replace_result $MASTER_MYPORT MASTER_PORT
diff --git a/mysql-test/t/rpl_LD_INFILE.test b/mysql-test/t/rpl_LD_INFILE.test
index ae647ed6648..bace5d4c1f5 100644
--- a/mysql-test/t/rpl_LD_INFILE.test
+++ b/mysql-test/t/rpl_LD_INFILE.test
@@ -16,10 +16,10 @@ DROP TABLE IF EXISTS test.t1;
# Section 1 test
CREATE TABLE test.t1 (a VARCHAR(255), PRIMARY KEY(a));
-LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
DELETE FROM test.t1 WHERE a = 'abashed';
DELETE FROM test.t1;
-LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
SELECT * FROM test.t1 ORDER BY a DESC;
diff --git a/mysql-test/t/rpl_alter_db.test b/mysql-test/t/rpl_alter_db.test
new file mode 100644
index 00000000000..5ac8a2f4018
--- /dev/null
+++ b/mysql-test/t/rpl_alter_db.test
@@ -0,0 +1,10 @@
+source include/master-slave.inc;
+connection master;
+use mysql; # to be different from initial `test' db of mysqltest client
+alter database collate latin1_bin;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+
+
diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test
index df17ec88aaa..38ad07f72f1 100644
--- a/mysql-test/t/rpl_drop_db.test
+++ b/mysql-test/t/rpl_drop_db.test
@@ -46,7 +46,7 @@ show tables;
use test;
select * from t1;
-system rm var/master-data/mysqltest1/f1.txt;
+system rm $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt;
connection master;
DROP DATABASE mysqltest1;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_load_table_from_master.test b/mysql-test/t/rpl_load_table_from_master.test
index aad113878d3..b9cec3858a9 100644
--- a/mysql-test/t/rpl_load_table_from_master.test
+++ b/mysql-test/t/rpl_load_table_from_master.test
@@ -71,9 +71,9 @@ sync_with_master;
connection master;
set SQL_LOG_BIN=0;
create table t1 (word char(20) not null, index(word))ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t1;
+load data infile '../std_data_ln/words.dat' into table t1;
create table t2 (word char(20) not null)ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t2;
+load data infile '../std_data_ln/words.dat' into table t2;
create table t3 (word char(20) not null primary key)ENGINE=MyISAM;
connection slave;
load table t1 from master;
diff --git a/mysql-test/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata2.test
index 439c2b48ca5..9e908cac677 100644
--- a/mysql-test/t/rpl_loaddata2.test
+++ b/mysql-test/t/rpl_loaddata2.test
@@ -1,7 +1,7 @@
--source include/master-slave.inc
CREATE TABLE t1 (word CHAR(20) NOT NULL);
-LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_loaddata_m.test b/mysql-test/t/rpl_loaddata_m.test
index 42c3ad99f33..537d4c163ef 100644
--- a/mysql-test/t/rpl_loaddata_m.test
+++ b/mysql-test/t/rpl_loaddata_m.test
@@ -17,14 +17,14 @@ connection master;
# 'test' database should be ignored by the slave
USE test;
CREATE TABLE t1(a INT, b INT, UNIQUE(b));
-LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE test.t1;
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE test.t1;
SELECT COUNT(*) FROM test.t1;
# 'mysqltest' database should NOT be ignored by the slave
CREATE DATABASE mysqltest;
USE mysqltest;
CREATE TABLE t1(a INT, b INT, UNIQUE(b));
-LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
SELECT COUNT(*) FROM mysqltest.t1;
# Now lets check the slave to see what we have :-)
diff --git a/mysql-test/t/rpl_loadfile.test b/mysql-test/t/rpl_loadfile.test
index 598e89586b2..a671bab15bb 100644
--- a/mysql-test/t/rpl_loadfile.test
+++ b/mysql-test/t/rpl_loadfile.test
@@ -24,12 +24,12 @@ DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
INSERT INTO test.t1 VALUES(1,'test');
-UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
+UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=1;
delimiter |;
create procedure test.p1()
begin
INSERT INTO test.t1 VALUES(2,'test');
- UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
+ UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=2;
end|
delimiter ;|
diff --git a/mysql-test/t/rpl_ndb_2innodb-master.opt b/mysql-test/t/rpl_ndb_2innodb-master.opt
new file mode 100644
index 00000000000..f31d53c3cb1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2innodb-slave.opt b/mysql-test/t/rpl_ndb_2innodb-slave.opt
new file mode 100644
index 00000000000..ee81186c513
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb-slave.opt
@@ -0,0 +1 @@
+--innodb --default-storage-engine=innodb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2innodb.test b/mysql-test/t/rpl_ndb_2innodb.test
new file mode 100644
index 00000000000..e09d8b6685b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb.test
@@ -0,0 +1,16 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_ndb.inc
+-- source include/master-slave.inc
+connection slave;
+-- source include/have_innodb.inc
+connection master;
+SET storage_engine=ndb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_2myisam-master.opt b/mysql-test/t/rpl_ndb_2myisam-master.opt
new file mode 100644
index 00000000000..f31d53c3cb1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2myisam-slave.opt b/mysql-test/t/rpl_ndb_2myisam-slave.opt
new file mode 100644
index 00000000000..59de63c0da2
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam-slave.opt
@@ -0,0 +1 @@
+--default-storage-engine=myisam --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2myisam.test b/mysql-test/t/rpl_ndb_2myisam.test
new file mode 100644
index 00000000000..abbe419bc02
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam.test
@@ -0,0 +1,13 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_ndb.inc
+-- source include/master-slave.inc
+SET storage_engine=ndb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_bank.test b/mysql-test/t/rpl_ndb_bank.test
index 817f40f2fa3..102450fce91 100644
--- a/mysql-test/t/rpl_ndb_bank.test
+++ b/mysql-test/t/rpl_ndb_bank.test
@@ -117,12 +117,12 @@ RESET MASTER;
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
# there is no neat way to find the backupid, this is a hack to find it...
---exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > var/tmp.dat
-CREATE TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-DELETE FROM cluster_replication.backup_info;
-LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ',';
+--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
+CREATE TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM cluster.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
--replace_column 1 <the_backup_id>
-SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info;
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
let the_backup_id=`select @the_backup_id`;
# restore on slave, first check that nothing is there
@@ -140,7 +140,7 @@ let the_backup_id=`select @the_backup_id`;
# 1.
--connection slave
--replace_column 1 <the_epoch>
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
--let $the_epoch= `select @the_epoch`
# 2.
@@ -148,7 +148,7 @@ SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
--replace_result $the_epoch <the_epoch>
--replace_column 1 <the_pos>
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
- FROM cluster_replication.binlog_index WHERE epoch > $the_epoch ORDER BY epoch ASC LIMIT 1;
+ FROM cluster.binlog_index WHERE epoch > $the_epoch ORDER BY epoch ASC LIMIT 1;
--let $the_pos= `SELECT @the_pos`
--let $the_file= `SELECT @the_file`
@@ -191,17 +191,17 @@ while ($1)
# 1. dump database BANK on both master and slave
# 2. compare, there should be no difference
#
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > ./var/tmp/master_BANK.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > $MYSQLTEST_VARDIR/tmp/master_BANK.sql
--connection master
use test;
create table t1 (a int primary key) engine=ndb;
insert into t1 values (1);
--sync_slave_with_master
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > ./var/tmp/slave_BANK.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > $MYSQLTEST_VARDIR/tmp/slave_BANK.sql
--connection master
drop table t1;
---exec diff ./var/tmp/master_BANK.sql ./var/tmp/slave_BANK.sql
+--exec diff $MYSQLTEST_VARDIR/tmp/master_BANK.sql $MYSQLTEST_VARDIR/tmp/slave_BANK.sql
--dec $2
}
diff --git a/mysql-test/t/rpl_ndb_idempotent.test b/mysql-test/t/rpl_ndb_idempotent.test
index bb33dfaf701..1a2c29079b1 100644
--- a/mysql-test/t/rpl_ndb_idempotent.test
+++ b/mysql-test/t/rpl_ndb_idempotent.test
@@ -4,7 +4,7 @@
#
# Currently test only works with ndb since it retrieves "old"
-# binlog positions with cluster_replication.binlog_index and apply_status;
+# binlog positions with cluster.binlog_index and apply_status;
#
# create a table with one row
@@ -15,7 +15,7 @@ SELECT * FROM t1 ORDER BY c3;
# sync slave and retrieve epoch
sync_slave_with_master;
--replace_column 1 <the_epoch>
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
let $the_epoch= `select @the_epoch` ;
SELECT * FROM t1 ORDER BY c3;
@@ -24,7 +24,7 @@ connection master;
--replace_result $the_epoch <the_epoch>
--replace_column 1 <the_pos>
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
- FROM cluster_replication.binlog_index WHERE epoch = $the_epoch ;
+ FROM cluster.binlog_index WHERE epoch = $the_epoch ;
let $the_pos= `SELECT @the_pos` ;
let $the_file= `SELECT @the_file` ;
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb-master.opt b/mysql-test/t/rpl_ndb_innodb2ndb-master.opt
new file mode 100644
index 00000000000..248f9e60566
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb-master.opt
@@ -0,0 +1 @@
+--innodb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt b/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt
new file mode 100644
index 00000000000..f47e5a7e98f
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt
@@ -0,0 +1 @@
+--binlog-format=row --default-storage-engine=ndb
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb.test b/mysql-test/t/rpl_ndb_innodb2ndb.test
new file mode 100644
index 00000000000..229ee11353b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb.test
@@ -0,0 +1,16 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+connection slave;
+-- source include/have_ndb.inc
+connection master;
+SET storage_engine=innodb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_multi.test b/mysql-test/t/rpl_ndb_multi.test
index 81f0f318505..fc7ecab00ac 100644
--- a/mysql-test/t/rpl_ndb_multi.test
+++ b/mysql-test/t/rpl_ndb_multi.test
@@ -7,7 +7,7 @@
#
# Currently test only works with ndb since it retrieves "old"
-# binlog positions with cluster_replication.binlog_index and apply_status;
+# binlog positions with cluster.binlog_index and apply_status;
#
# create a table with one row, and make sure the other "master" gets it
@@ -25,7 +25,7 @@ SELECT * FROM t1 ORDER BY c3;
connection master;
sync_slave_with_master;
--replace_column 1 <the_epoch>
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
let $the_epoch= `select @the_epoch` ;
SELECT * FROM t1 ORDER BY c3;
stop slave;
@@ -34,7 +34,7 @@ stop slave;
connection server2;
--replace_result $the_epoch <the_epoch>
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
- FROM cluster_replication.binlog_index WHERE epoch = $the_epoch ;
+ FROM cluster.binlog_index WHERE epoch = $the_epoch ;
let $the_pos= `SELECT @the_pos` ;
let $the_file= `SELECT @the_file` ;
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb-master.opt b/mysql-test/t/rpl_ndb_myisam2ndb-master.opt
new file mode 100644
index 00000000000..83ed8522e72
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb-master.opt
@@ -0,0 +1 @@
+--binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
new file mode 100644
index 00000000000..f31d53c3cb1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb.test b/mysql-test/t/rpl_ndb_myisam2ndb.test
new file mode 100644
index 00000000000..0c2df6441cb
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb.test
@@ -0,0 +1,15 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/master-slave.inc
+connection slave;
+--source include/have_ndb.inc
+connection master;
+SET storage_engine=myisam;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_sync.test b/mysql-test/t/rpl_ndb_sync.test
index 5c990cd4842..d56f4a4ad03 100644
--- a/mysql-test/t/rpl_ndb_sync.test
+++ b/mysql-test/t/rpl_ndb_sync.test
@@ -4,7 +4,7 @@
#
# Currently test only works with ndb since it retrieves "old"
-# binlog positions with cluster_replication.binlog_index and apply_status;
+# binlog positions with cluster.binlog_index and apply_status;
#
# stop the save
@@ -26,14 +26,14 @@ SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
# take a backup on master
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > var/tmp.dat
-CREATE TEMPORARY TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT)ENGINE=HEAP;
-DELETE FROM cluster_replication.backup_info;
-LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ',';
+--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
+CREATE TEMPORARY TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT)ENGINE=HEAP;
+DELETE FROM cluster.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
--replace_column 1 <the_backup_id>
-SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info;
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
let the_backup_id=`select @the_backup_id` ;
-DROP TABLE cluster_replication.backup_info;
+DROP TABLE cluster.backup_info;
# update a row
UPDATE t1 SET c2=0 WHERE c3="row2";
SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
@@ -73,7 +73,7 @@ SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
# 1.
connection slave;
--replace_column 1 <the_epoch>
-SELECT @the_epoch:=MAX(epoch) FROM cluster_replication.apply_status;
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
let $the_epoch= `select @the_epoch` ;
# 2.
@@ -81,7 +81,7 @@ connection master;
--replace_result $the_epoch <the_epoch>
--replace_column 1 <the_pos>
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
- FROM cluster_replication.binlog_index WHERE epoch > $the_epoch ORDER BY epoch ASC LIMIT 1;
+ FROM cluster.binlog_index WHERE epoch > $the_epoch ORDER BY epoch ASC LIMIT 1;
let $the_pos= `SELECT @the_pos` ;
let $the_file= `SELECT @the_file` ;
@@ -124,11 +124,11 @@ STOP SLAVE;
connection master;
reset master;
# should now contain nothing
-select * from cluster_replication.binlog_index;
+select * from cluster.binlog_index;
connection slave;
reset slave;
# should now contain nothing
-select * from cluster_replication.apply_status;
+select * from cluster.apply_status;
# End 5.1 Test
diff --git a/mysql-test/t/rpl_row_4_bytes.test b/mysql-test/t/rpl_row_4_bytes.test
index 26a4e2f5bfe..73ef6dd2345 100644
--- a/mysql-test/t/rpl_row_4_bytes.test
+++ b/mysql-test/t/rpl_row_4_bytes.test
@@ -29,5 +29,5 @@ select * from t1 order by a;
select * from t2 order by a;
connection master;
-DROP TABLE t1,t2;
+DROP DATABASE mysqltest1;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_row_NOW.test b/mysql-test/t/rpl_row_NOW.test
index dba6fb16bb2..24a8774284a 100644
--- a/mysql-test/t/rpl_row_NOW.test
+++ b/mysql-test/t/rpl_row_NOW.test
@@ -50,8 +50,8 @@ sync_slave_with_master;
connection master;
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > ./var/tmp/NOW_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > ./var/tmp/NOW_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/NOW_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/NOW_slave.sql
# lets cleanup
DROP TABLE IF EXISTS mysqltest1.t1;
@@ -61,13 +61,13 @@ DROP FUNCTION mysqltest1.f1;
# the test will show that the diff statement failed and not reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-) The failed dump
-# files will be located in mysql-test/var/tmp
+# files will be located in $MYSQLTEST_VARDIR/tmp
-exec diff ./var/tmp/NOW_master.sql ./var/tmp/NOW_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm ./var/tmp/NOW_master.sql;
-system rm ./var/tmp/NOW_slave.sql;
+system rm $MYSQLTEST_VARDIR/tmp/NOW_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
sync_slave_with_master;
# End of 5.1 test case
diff --git a/mysql-test/t/rpl_row_drop.test b/mysql-test/t/rpl_row_drop.test
index 816bd108b88..dd6ef331508 100644
--- a/mysql-test/t/rpl_row_drop.test
+++ b/mysql-test/t/rpl_row_drop.test
@@ -31,8 +31,8 @@ connection master;
# Should drop the non-temporary table t1 and the temporary table t2
DROP TABLE t1,t2;
let $VERSION=`select version()`;
---replace_result $VERSION VERSION
-SHOW BINLOG EVENTS;
+#--replace_result $VERSION VERSION
+#SHOW BINLOG EVENTS;
SHOW TABLES;
sync_slave_with_master;
--echo **** On Slave ****
diff --git a/mysql-test/t/rpl_row_func002.test b/mysql-test/t/rpl_row_func002.test
index 966124ce035..46767abd529 100644
--- a/mysql-test/t/rpl_row_func002.test
+++ b/mysql-test/t/rpl_row_func002.test
@@ -84,8 +84,8 @@ connection master;
# time to dump the databases and so we can see if they match
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func002_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func002_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_slave.sql
# Cleanup
DROP FUNCTION test.f1;
@@ -97,7 +97,7 @@ sync_slave_with_master;
# the files your self to see what is not matching :-). The files are located
# in mysql-test/var/tmp
-exec diff ./var/tmp/func002_master.sql ./var/tmp/func002_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/func002_master.sql $MYSQLTEST_VARDIR/tmp/func002_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_mysqlbinlog-master.opt b/mysql-test/t/rpl_row_mysqlbinlog-master.opt
new file mode 100644
index 00000000000..07d12817f5f
--- /dev/null
+++ b/mysql-test/t/rpl_row_mysqlbinlog-master.opt
@@ -0,0 +1 @@
+--max-binlog-size=1040384
diff --git a/mysql-test/t/rpl_row_mysqlbinlog.test b/mysql-test/t/rpl_row_mysqlbinlog.test
new file mode 100644
index 00000000000..3b4c8db86d8
--- /dev/null
+++ b/mysql-test/t/rpl_row_mysqlbinlog.test
@@ -0,0 +1,319 @@
+##################################################################
+# Author: JBM #
+# Date: 2006-02-22 #
+# Purpose: To test changes to mysqlbinlog for row based bin logs #
+# We are using .opt file since we need small binlog size #
+##################################################################
+# Include Section
+# Make sure that we have row based bin log
+-- source include/have_binlog_format_row.inc
+# Embedded server doesn't support binlogging
+-- source include/not_embedded.inc
+-- source include/master-slave.inc
+
+# Setup Section
+# we need this for getting fixed timestamps inside of this test
+
+--disable_query_log
+select "---Setup Section --" as "";
+--enable_query_log
+
+set timestamp=1000000000;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+--enable_warnings
+
+connection master;
+CREATE TABLE t1(word VARCHAR(20));
+CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+
+
+# Test Section
+# Lets start by putting some data into the tables.
+
+--disable_query_log
+INSERT INTO t1 VALUES ("abirvalg");
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+
+# d1 length 3000
+set @d1 = 'dd1';
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+
+let $count=500;
+while ($count)
+{
+ INSERT INTO t2 VALUES (NULL);
+ eval INSERT INTO t3 VALUES ($count,@d1,'20060222000000','Tested in Texas',$count*2.2);
+ dec $count;
+}
+--enable_query_log
+
+
+--disable_query_log
+select "---Test1 check table load --" as "";
+--enable_query_log
+
+# Lets Check the tables on the Master
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+sync_slave_with_master;
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Okay time to get busy, back to master
+
+connection master;
+
+# simple query to show more in second binlog
+insert into t1 values ("Alas");
+flush logs;
+
+# delimiters are for easier debugging in future
+--disable_query_log
+select "--- Test 1 Dump binlog to file --" as "";
+--enable_query_log
+
+#
+# Prepare local temporary file to recreate what we have currently.
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/master.sql
+
+# Now that we have our file, lets get rid of the current database.
+# Cleanup the master and the slave and try to recreate.
+--disable_query_log
+select "--- Test 1 delete tables, clean master and slave --" as "";
+--enable_query_log
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+sync_slave_with_master;
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+--disable_warnings
+stop slave;
+--enable_warnings
+--require r/slave-stopped.result
+show status like 'Slave_running';
+connection master;
+reset master;
+connection slave;
+reset slave;
+start slave;
+--require r/slave-running.result
+show status like 'Slave_running';
+connection master;
+
+# We should be clean at this point, now we will run in the file from above.
+--disable_query_log
+select "--- Test 1 Load from Dump binlog file --" as "";
+--enable_query_log
+
+--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql"
+
+--disable_query_log
+select "--- Test 1 Check Load Results --" as "";
+--enable_query_log
+
+# Lets Check the tables on the Master
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+sync_slave_with_master;
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+connection master;
+
+# We should be gold by the time, so I will get rid of our file.
+
+--exec rm $MYSQLTEST_VARDIR/tmp/master.sql
+
+
+# this test for position option
+# By setting this position to 412, we should only get the create of t3
+--disable_query_log
+select "--- Test 2 position test --" as "";
+--enable_query_log
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=412 $MYSQLTEST_VARDIR/log/master-bin.000001
+
+# These are tests for remote binlog.
+# They should return the same as previous test.
+
+--disable_query_log
+select "--- Test 3 First Remote test --" as "";
+--enable_query_log
+
+# This is broken now
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+
+# This part is disabled due to bug #17654
+################### Start Bug 17654 ######################
+#--disable_query_log
+#select "--- Test 4 Second Remote test --" as "";
+#--enable_query_log
+#--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
+
+#--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/remote.sql
+
+# Now that we have our file, lets get rid of the current database.
+# Cleanup the master and the slave and try to recreate.
+
+#DROP TABLE t1;
+#DROP TABLE t2;
+#DROP TABLE t3;
+
+#sync_slave_with_master;
+
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+
+#--disable_warnings
+#stop slave;
+#--enable_warnings
+#--require r/slave-stopped.result
+#show status like 'Slave_running';
+#connection master;
+#reset master;
+#connection slave;
+#reset slave;
+#start slave;
+#--require r/slave-running.result
+#show status like 'Slave_running';
+#connection master;
+
+# We should be clean at this point, now we will run in the file from above.
+
+#--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/remote.sql"
+
+# Lets Check the tables on the Master
+
+#SELECT COUNT(*) from t1;
+#SELECT COUNT(*) from t2;
+#SELECT COUNT(*) from t3;
+#SELECT * FROM t1 ORDER BY word LIMIT 5;
+#SELECT * FROM t2 ORDER BY id LIMIT 5;
+#SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+#sync_slave_with_master;
+#SELECT COUNT(*) from t1;
+#SELECT COUNT(*) from t2;
+#SELECT COUNT(*) from t3;
+#SELECT * FROM t1 ORDER BY word LIMIT 5;
+#SELECT * FROM t2 ORDER BY id LIMIT 5;
+#SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+#connection master;
+
+# We should be gold by the time, so I will get rid of our file.
+
+#--exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+################### End Bug 17654 ######################
+
+# LOAD DATA
+--disable_query_log
+select "--- Test 5 LOAD DATA --" as "";
+--enable_query_log
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+
+# Bug#7853 (mysqlbinlog does not accept input from stdin)
+
+--disable_query_log
+select "--- Test 6 reading stdin --" as "";
+--enable_query_log
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--exec $MYSQL_BINLOG --short-form - < $MYSQLTEST_VARDIR/log/master-bin.000001
+
+--disable_query_log
+select "--- Test 7 reading stdin w/position --" as "";
+--enable_query_log
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--exec $MYSQL_BINLOG --short-form --position=412 - < $MYSQLTEST_VARDIR/log/master-bin.000001
+
+# Bug#16217 (mysql client did not know how not switch its internal charset)
+--disable_query_log
+select "--- Test 8 switch internal charset --" as "";
+--enable_query_log
+sync_slave_with_master;
+
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+
+--disable_warnings
+stop slave;
+--enable_warnings
+--require r/slave-stopped.result
+show status like 'Slave_running';
+connection master;
+reset master;
+connection slave;
+reset slave;
+start slave;
+--require r/slave-running.result
+show status like 'Slave_running';
+connection master;
+
+create table t4 (f text character set utf8);
+create table t5 (f text character set cp932);
+--exec $MYSQL --default-character-set=utf8 test -e "insert into t4 values(_utf8'ソ')"
+--exec $MYSQL --default-character-set=cp932 test -e "insert into t5 values(_cp932'ƒ\');"
+flush logs;
+rename table t4 to t04, t5 to t05;
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 | $MYSQL --default-character-set=utf8
+# original and recovered data must be equal
+select HEX(f) from t04;
+select HEX(f) from t4;
+select HEX(f) from t05;
+select HEX(f) from t5;
+
+# slave should have same
+sync_slave_with_master;
+select HEX(f) from t04;
+select HEX(f) from t4;
+select HEX(f) from t05;
+select HEX(f) from t5;
+
+--disable_query_log
+select "--- Test cleanup --" as "";
+--enable_query_log
+# clean up
+connection master;
+DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/rpl_row_sp001.test b/mysql-test/t/rpl_row_sp001.test
index 88384b242b0..8e01cbc4f44 100644
--- a/mysql-test/t/rpl_row_sp001.test
+++ b/mysql-test/t/rpl_row_sp001.test
@@ -119,8 +119,8 @@ SELECT * FROM t2 ORDER BY a;
# time to dump the databases and so we can see if they match
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp001_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp001_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp001_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp001_slave.sql
# First lets cleanup
@@ -135,12 +135,12 @@ sync_slave_with_master;
# the test will show that the diff statement failed and not reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-) Failed dump files
-# will be located in mysql-test/var/tmp
+# will be located in $MYSQLTEST_VARDIR/tmp
---exec diff ./var/tmp/sp001_master.sql ./var/tmp/sp001_slave.sql;
+--exec diff $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm ./var/tmp/sp001_master.sql;
-system rm ./var/tmp/sp001_slave.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp001_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_sp010.test b/mysql-test/t/rpl_row_sp010.test
index 10940e1e030..28b82217517 100644
--- a/mysql-test/t/rpl_row_sp010.test
+++ b/mysql-test/t/rpl_row_sp010.test
@@ -37,7 +37,7 @@ BEGIN
END|
delimiter ;|
CALL test.p2();
-SELECT * FROM test.t1;
+SELECT * FROM test.t1 ORDER BY a;
save_master_pos;
connection slave;
@@ -59,12 +59,12 @@ BEGIN
END|
delimiter ;|
CALL test.p4();
-SELECT * FROM test.t2;
+SELECT * FROM test.t2 ORDER BY a;
save_master_pos;
connection slave;
sync_with_master;
-SELECT * FROM test.t2;
+SELECT * FROM test.t2 ORDER BY a;
# Cleanup
connection master;
diff --git a/mysql-test/t/rpl_row_sp011.test b/mysql-test/t/rpl_row_sp011.test
index 73d2f628dbd..54e708492d1 100644
--- a/mysql-test/t/rpl_row_sp011.test
+++ b/mysql-test/t/rpl_row_sp011.test
@@ -79,8 +79,8 @@ CALL test.p1();
sync_slave_with_master;
#SELECT * FROM test.t2;
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp011_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp011_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp011_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp011_slave.sql
# Cleanup
connection master;
@@ -100,12 +100,12 @@ sync_slave_with_master;
# the test will show that the diff statement failed and not reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-) Failed test
-# Will leave dump files in mysql-test/var/tmp
+# Will leave dump files in $MYSQLTEST_VARDIR/tmp
-exec diff ./var/tmp/sp011_master.sql ./var/tmp/sp011_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm ./var/tmp/sp011_master.sql;
-system rm ./var/tmp/sp011_slave.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp011_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_stop_middle_update.test b/mysql-test/t/rpl_row_stop_middle_update.test
index 82c4b1a9936..29b3008e822 100644
--- a/mysql-test/t/rpl_row_stop_middle_update.test
+++ b/mysql-test/t/rpl_row_stop_middle_update.test
@@ -9,7 +9,7 @@
connection master;
create table t1 (words varchar(20)) engine=myisam;
-load data infile '../../std_data/words.dat' into table t1 (words);
+load data infile '../std_data_ln/words.dat' into table t1 (words);
select count(*) from t1;
save_master_pos;
diff --git a/mysql-test/t/rpl_row_trig001.test b/mysql-test/t/rpl_row_trig001.test
index b7866069a51..931cab95948 100644
--- a/mysql-test/t/rpl_row_trig001.test
+++ b/mysql-test/t/rpl_row_trig001.test
@@ -75,8 +75,8 @@ let $message=<End test section 2 (Tiggers & SP)>;
# time to dump the databases and so we can see if they match
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trig001_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trig001_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trig001_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trig001_slave.sql
# Cleanup
connection master;
@@ -93,8 +93,8 @@ sync_slave_with_master;
# the test will show that the diff statement failed and not reject file
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching :-) Failed tests
-# will leave dump files in mysql-test/var/tmp
+# will leave dump files in $MYSQLTEST_VARDIR/tmp
-exec diff ./var/tmp/trig001_master.sql ./var/tmp/trig001_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/trig001_master.sql $MYSQLTEST_VARDIR/tmp/trig001_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_trig003.test b/mysql-test/t/rpl_row_trig003.test
index 799c2d6c9c7..d4570afd094 100644
--- a/mysql-test/t/rpl_row_trig003.test
+++ b/mysql-test/t/rpl_row_trig003.test
@@ -125,8 +125,8 @@ connection master;
# time to dump the databases and so we can see if they match
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trg003_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trg003_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trg003_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trg003_slave.sql
# cleanup
--disable_warnings
@@ -147,6 +147,6 @@ DROP TABLE IF EXISTS test.t2;
DROP TABLE IF EXISTS test.t3;
--enable_warnings
-exec diff ./var/tmp/trg003_master.sql ./var/tmp/trg003_slave.sql;
+exec diff $MYSQLTEST_VARDIR/tmp/trg003_master.sql $MYSQLTEST_VARDIR/tmp/trg003_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_sp004.test b/mysql-test/t/rpl_sp004.test
index 9156e6f4047..335a17c7af0 100644
--- a/mysql-test/t/rpl_sp004.test
+++ b/mysql-test/t/rpl_sp004.test
@@ -76,8 +76,8 @@ SELECT * FROM test.t1;
SELECT * FROM test.t2;
#SELECT * FROM test.t3;
---exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp004_master.sql
---exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp004_slave.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp004_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp004_slave.sql
# Cleanup
connection master;
@@ -91,7 +91,7 @@ sync_slave_with_master;
# If the test fails, you will need to diff the dumps to see why.
--- exec diff ./var/tmp/sp004_master.sql ./var/tmp/sp004_slave.sql
+-- exec diff $MYSQLTEST_VARDIR/tmp/sp004_master.sql $MYSQLTEST_VARDIR/tmp/sp004_slave.sql
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_switch_stm_row_mixed.test b/mysql-test/t/rpl_switch_stm_row_mixed.test
new file mode 100644
index 00000000000..f607148a4b4
--- /dev/null
+++ b/mysql-test/t/rpl_switch_stm_row_mixed.test
@@ -0,0 +1,165 @@
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+connection master;
+--disable_warnings
+drop database if exists mysqltest1;
+create database mysqltest1;
+--enable_warnings
+use mysqltest1;
+
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+
+CREATE TABLE t1 (a varchar(100));
+
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+# verify that temp tables prevent a switch to SBR
+create temporary table tmp(a char(3));
+insert into tmp values("see");
+--error ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
+set binlog_format=statement;
+insert into t1 select * from tmp;
+drop temporary table tmp;
+
+# Now we go to SBR
+set binlog_format=statement;
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+set global binlog_format=statement;
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for");
+insert into t1 select "yesterday";
+
+# test SET DEFAULT (=statement at this point of test)
+set binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+# due to cluster it's hard to set back to default
+--error ER_NO_DEFAULT
+set global binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for");
+insert into t1 select "yesterday";
+
+# and now the mixed mode
+
+set binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+set global binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+# inside a stored procedure (inside a function or trigger won't
+# work)
+
+delimiter |;
+create procedure foo()
+begin
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+end|
+create procedure foo2()
+begin
+insert into t1 values(concat("emergency",UUID()));
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+set session binlog_format=row; # accepted for stored procs
+insert into t1 values("more work");
+set session binlog_format=mixed;
+end|
+create function foo3() returns bigint unsigned
+begin
+ set session binlog_format=row; # rejected for stored funcs
+ insert into t1 values("alarm");
+ return 100;
+end|
+delimiter ;|
+call foo();
+call foo2();
+
+# test that can't SET in a stored function if not in row-based mode
+--error ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT
+select foo3();
+select * from t1 where a="alarm";
+
+# and now compare:
+
+show binlog events from 102;
+sync_slave_with_master;
+# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_row_UDF_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_row_UDF_slave.sql
+
+connection master;
+drop database mysqltest1;
+sync_slave_with_master;
+
+# Let's compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching
+
+#--exec diff $MYSQLTEST_VARDIR/tmp/rpl_row_UDF_master.sql $MYSQLTEST_VARDIR/tmp/rpl_row_UDF_slave.sql;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 9cfe85d3bd4..a7b24a5e06c 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -393,7 +393,7 @@ SHOW TABLE STATUS like 't1';
--error 1033
show create table t1;
drop table if exists t1;
-system rm -f var/master-data/test/t1.frm ;
+system rm -f $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
# End of 4.1 tests
diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test
index a0164cb0759..27220c9b507 100644
--- a/mysql-test/t/skip_grants.test
+++ b/mysql-test/t/skip_grants.test
@@ -30,3 +30,6 @@ create table t1 (a int);
create definer='user'@'host' sql security definer view v1 as select * from t1;
drop view v1;
drop table t1;
+
+# BUG#17595: DROP FUNCTION IF EXISTS f1 crashes server
+drop function if exists f1;
diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test
index 5fc81c338c6..375d2289459 100644
--- a/mysql-test/t/sp-destruct.test
+++ b/mysql-test/t/sp-destruct.test
@@ -54,10 +54,13 @@ flush table mysql.proc;
# Thrashing the .frm file
--system echo 'saljdlfa' > $MYSQLTEST_VARDIR/master-data/mysql/proc.frm
+--replace_result $MYSQLTEST_VARDIR . master-data// ''
--error ER_NOT_FORM_FILE
call bug14233();
+--replace_result $MYSQLTEST_VARDIR . master-data// ''
--error ER_NOT_FORM_FILE
create view v1 as select bug14233_f();
+--replace_result $MYSQLTEST_VARDIR . master-data// ''
--error ER_NOT_FORM_FILE
insert into t1 values (0);
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 63185ea9a88..4b307de2ad0 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1682,9 +1682,21 @@ drop procedure bug15091;
#
+# BUG#16896: Stored function: unused AGGREGATE-clause in CREATE FUNCTION
+#
+--disable_warnings
+drop function if exists bug16896;
+--enable_warnings
+
+--error ER_SP_NO_AGGREGATE
+create aggregate function bug16896() returns int return 1;
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
#drop procedure if exists bugNNNN|
#--enable_warnings
#create procedure bugNNNN...
+
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index 90160780618..19f94a32d9c 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -525,4 +525,26 @@ disconnect user_bug14533;
drop user user_bug14533@localhost;
drop database db_bug14533;
+
+#
+# BUG#7787: Stored procedures: improper warning for "grant execute" statement
+#
+
+# Prepare.
+
+CREATE DATABASE db_bug7787;
+use db_bug7787;
+
+# Test.
+
+CREATE PROCEDURE p1()
+ SHOW INNODB STATUS;
+
+GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
+
+# Cleanup.
+
+DROP DATABASE db_bug7787;
+use test;
+
# End of 5.0 bugs.
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index d535fc8319e..7709fb68e87 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -699,32 +699,34 @@ drop procedure into_test4|
--disable_warnings
drop procedure if exists into_outfile|
--enable_warnings
-create procedure into_outfile(x char(16), y int)
+--replace_result $MYSQLTEST_VARDIR ..
+eval create procedure into_outfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
- select * into outfile "/tmp/spout" from test.t1;
+ select * into outfile "$MYSQLTEST_VARDIR/tmp/spout" from test.t1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
-system rm -f /tmp/spout|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spout
call into_outfile("ofile", 1)|
-system rm -f /tmp/spout|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spout
delete from t1|
drop procedure into_outfile|
--disable_warnings
drop procedure if exists into_dumpfile|
--enable_warnings
-create procedure into_dumpfile(x char(16), y int)
+--replace_result $MYSQLTEST_VARDIR ..
+eval create procedure into_dumpfile(x char(16), y int)
begin
insert into test.t1 values (x, y);
- select * into dumpfile "/tmp/spdump" from test.t1 limit 1;
+ select * into dumpfile "$MYSQLTEST_VARDIR/tmp/spdump" from test.t1 limit 1;
insert into test.t1 values (concat(x, "2"), y+2);
end|
-system rm -f /tmp/spdump|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
call into_dumpfile("dfile", 1)|
-system rm -f /tmp/spdump|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
delete from t1|
drop procedure into_dumpfile|
@@ -1660,7 +1662,7 @@ drop function `foo`|
# Implicit LOCK/UNLOCK TABLES for table access in functions
#
---disable_warning
+--disable_warnings
drop function if exists t1max|
--enable_warnings
create function t1max() returns int
@@ -1704,6 +1706,397 @@ drop table t3|
drop function getcount|
+# Test cases for different combinations of condition handlers in nested
+# begin-end blocks in stored procedures.
+#
+# Note that the standard specifies that the most specific handler should
+# be triggered even if it's an outer handler masked by a less specific
+# handler in an inner block.
+# Note also that '02000' is more specific than NOT FOUND; there might be
+# other '02xxx' states, even if we currently do not issue them in any
+# situation (e.g. '02001').
+#
+# The combinations we test are these:
+#
+# Inner
+# errcode sqlstate not found sqlwarning sqlexception
+# Outer +------------+------------+------------+------------+------------+
+#errcode | h_ee (i) | h_es (o) | h_en (o) | h_ew (o) | h_ex (o) |
+#sqlstate | h_se (i) | h_ss (i) | h_sn (o) | h_sw (o) | h_sx (o) |
+#not found | h_ne (i) | h_ns (i) | h_nn (i) | | |
+#sqlwarning | h_we (i) | h_ws (i) | | h_ww (i) | |
+#sqlexception | h_xe (i) | h_xs (i) | | | h_xx (i) |
+# +------------+---------------------------------------------------+
+#
+# (i) means that the inner handler is the one that should be invoked,
+# (o) means that the outer handler should be invoked.
+#
+# ('not found', 'sqlwarning' and 'sqlexception' are mutually exclusive, hence
+# no tests for those combinations.)
+#
+
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists h_ee|
+drop procedure if exists h_es|
+drop procedure if exists h_en|
+drop procedure if exists h_ew|
+drop procedure if exists h_ex|
+drop procedure if exists h_se|
+drop procedure if exists h_ss|
+drop procedure if exists h_sn|
+drop procedure if exists h_sw|
+drop procedure if exists h_sx|
+drop procedure if exists h_ne|
+drop procedure if exists h_ns|
+drop procedure if exists h_nn|
+drop procedure if exists h_we|
+drop procedure if exists h_ws|
+drop procedure if exists h_ww|
+drop procedure if exists h_xe|
+drop procedure if exists h_xs|
+drop procedure if exists h_xx|
+--enable_warnings
+
+# smallint - to get out of range warnings
+# primary key - to get constraint errors
+create table t3 (a smallint primary key)|
+
+insert into t3 (a) values (1)|
+
+create procedure h_ee()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (bad)' as 'h_ee';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_ee';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_es()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (good)' as 'h_es';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (bad)' as 'h_es';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_en()
+ deterministic
+begin
+ declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+ select 'Outer (good)' as 'h_en';
+
+ begin
+ declare x int;
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Inner (bad)' as 'h_en';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_ew()
+ deterministic
+begin
+ declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+ select 'Outer (good)' as 'h_ew';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (bad)' as 'h_ew';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ex()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (good)' as 'h_ex';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (bad)' as 'h_ex';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_se()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (bad)' as 'h_se';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_se';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_ss()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (bad)' as 'h_ss';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_ss';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_sn()
+ deterministic
+begin
+ -- Note: '02000' is more specific than NOT FOUND ;
+ -- there might be other not found states
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Outer (good)' as 'h_sn';
+
+ begin
+ declare x int;
+ declare continue handler for not found
+ select 'Inner (bad)' as 'h_sn';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_sw()
+ deterministic
+begin
+ -- data exception - numeric value out of range
+ declare continue handler for sqlstate '22003'
+ select 'Outer (good)' as 'h_sw';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (bad)' as 'h_sw';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_sx()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (good)' as 'h_sx';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (bad)' as 'h_sx';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_ne()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_ne';
+
+ begin
+ declare x int;
+ declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+ select 'Inner (good)' as 'h_ne';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_ns()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_ns';
+
+ begin
+ declare x int;
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Inner (good)' as 'h_ns';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_nn()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_nn';
+
+ begin
+ declare x int;
+ declare continue handler for not found
+ select 'Inner (good)' as 'h_nn';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_we()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_we';
+
+ begin
+ declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+ select 'Inner (good)' as 'h_we';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ws()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_ws';
+
+ begin
+ -- data exception - numeric value out of range
+ declare continue handler for sqlstate '22003'
+ select 'Inner (good)' as 'h_ws';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ww()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_ww';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (good)' as 'h_ww';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_xe()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xe';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_xe';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_xs()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xs';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_xs';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_xx()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xx';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (good)' as 'h_xx';
+
+ insert into t3 values (1);
+ end;
+end|
+
+call h_ee()|
+call h_es()|
+call h_en()|
+call h_ew()|
+call h_ex()|
+call h_se()|
+call h_ss()|
+call h_sn()|
+call h_sw()|
+call h_sx()|
+call h_ne()|
+call h_ns()|
+call h_nn()|
+call h_we()|
+call h_ws()|
+call h_ww()|
+call h_xe()|
+call h_xs()|
+call h_xx()|
+
+drop table t3|
+drop procedure h_ee|
+drop procedure h_es|
+drop procedure h_en|
+drop procedure h_ew|
+drop procedure h_ex|
+drop procedure h_se|
+drop procedure h_ss|
+drop procedure h_sn|
+drop procedure h_sw|
+drop procedure h_sx|
+drop procedure h_ne|
+drop procedure h_ns|
+drop procedure h_nn|
+drop procedure h_we|
+drop procedure h_ws|
+drop procedure h_ww|
+drop procedure h_xe|
+drop procedure h_xs|
+drop procedure h_xx|
+
+
#
# Test cases for old bugs
#
@@ -5228,6 +5621,31 @@ drop table t3|
#
+# BUG#17476: Stored procedure not returning data when it is called first
+# time per connection
+#
+--disable_warnings
+drop procedure if exists bug17476|
+--enable_warnings
+
+create table t3 ( d date )|
+insert into t3 values
+ ( '2005-01-01' ), ( '2005-01-02' ), ( '2005-01-03' ),
+ ( '2005-01-04' ), ( '2005-02-01' ), ( '2005-02-02' )|
+
+create procedure bug17476(pDateFormat varchar(10))
+ select date_format(t3.d, pDateFormat), count(*)
+ from t3
+ group by date_format(t3.d, pDateFormat)|
+
+call bug17476('%Y-%m')|
+call bug17476('%Y-%m')|
+
+drop table t3|
+drop procedure bug17476|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp.test.orig b/mysql-test/t/sp.test.orig
new file mode 100644
index 00000000000..a4b99620344
--- /dev/null
+++ b/mysql-test/t/sp.test.orig
@@ -0,0 +1,5716 @@
+#
+# Basic stored PROCEDURE tests
+#
+# Please keep this file free of --error cases and other
+# things that will not run in a single debugged mysqld
+# process (e.g. master-slave things).
+#
+# Test cases for bugs are added at the end. See template there.
+#
+# Tests that require --error go into sp-error.test
+# Tests that require inndb go into sp_trans.test
+# Tests that check privilege and security issues go to sp-security.test.
+# Tests that require multiple connections, except security/privilege tests,
+# go to sp-thread.
+# Tests that uses 'goto' to into sp-goto.test (currently disabled)
+# Tests that destroys system tables (e.g. mysql.proc) for error testing
+# go to sp-destruct.
+
+use test;
+
+# Test tables
+#
+# t1 and t2 are reused throughout the file, and dropped at the end.
+# t3 and up are created and dropped when needed.
+#
+--disable_warnings
+drop table if exists t1,t2,t3,t4;
+--enable_warnings
+create table t1 (
+ id char(16) not null default '',
+ data int not null
+);
+create table t2 (
+ s char(16),
+ i int,
+ d double
+);
+
+
+# Single statement, no params.
+--disable_warnings
+drop procedure if exists foo42;
+--enable_warnings
+create procedure foo42()
+ insert into test.t1 values ("foo", 42);
+
+call foo42();
+select * from t1;
+delete from t1;
+drop procedure foo42;
+
+
+# Single statement, two IN params.
+--disable_warnings
+drop procedure if exists bar;
+--enable_warnings
+create procedure bar(x char(16), y int)
+ insert into test.t1 values (x, y);
+
+call bar("bar", 666);
+select * from t1;
+delete from t1;
+# Don't drop procedure yet...
+
+
+# Now for multiple statements...
+delimiter |;
+
+# Empty statement
+--disable_warnings
+drop procedure if exists empty|
+--enable_warnings
+create procedure empty()
+begin
+end|
+
+call empty()|
+drop procedure empty|
+
+# Scope test. This is legal (warnings might be possible in the future,
+# but for the time being, we just accept it).
+--disable_warnings
+drop procedure if exists scope|
+--enable_warnings
+create procedure scope(a int, b float)
+begin
+ declare b int;
+ declare c float;
+
+ begin
+ declare c int;
+ end;
+end|
+
+drop procedure scope|
+
+# Two statements.
+--disable_warnings
+drop procedure if exists two|
+--enable_warnings
+create procedure two(x1 char(16), x2 char(16), y int)
+begin
+ insert into test.t1 values (x1, y);
+ insert into test.t1 values (x2, y);
+end|
+
+call two("one", "two", 3)|
+select * from t1|
+delete from t1|
+drop procedure two|
+
+
+# Simple test of local variables and SET.
+--disable_warnings
+drop procedure if exists locset|
+--enable_warnings
+create procedure locset(x char(16), y int)
+begin
+ declare z1, z2 int;
+ set z1 = y;
+ set z2 = z1+2;
+ insert into test.t1 values (x, z2);
+end|
+
+call locset("locset", 19)|
+select * from t1|
+delete from t1|
+drop procedure locset|
+
+
+# In some contexts local variables are not recognized
+# (and in some, you have to qualify the identifier).
+--disable_warnings
+drop procedure if exists setcontext|
+--enable_warnings
+create procedure setcontext()
+begin
+ declare data int default 2;
+
+ insert into t1 (id, data) values ("foo", 1);
+ replace t1 set data = data, id = "bar";
+ update t1 set id = "kaka", data = 3 where t1.data = data;
+end|
+
+call setcontext()|
+select * from t1|
+delete from t1|
+drop procedure setcontext|
+
+
+# Set things to null
+create table t3 ( d date, i int, f double, s varchar(32) )|
+
+--disable_warnings
+drop procedure if exists nullset|
+--enable_warnings
+create procedure nullset()
+begin
+ declare ld date;
+ declare li int;
+ declare lf double;
+ declare ls varchar(32);
+
+ set ld = null, li = null, lf = null, ls = null;
+ insert into t3 values (ld, li, lf, ls);
+
+ insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
+ ((li is null), 1, "li is null"),
+ ((li = 0), null, "li = 0"),
+ ((lf is null), 1, "lf is null"),
+ ((lf = 0), null, "lf = 0"),
+ ((ls is null), 1, "ls is null");
+end|
+
+call nullset()|
+select * from t3|
+drop table t3|
+drop procedure nullset|
+
+
+# The peculiar (non-standard) mixture of variables types in SET.
+--disable_warnings
+drop procedure if exists mixset|
+--enable_warnings
+create procedure mixset(x char(16), y int)
+begin
+ declare z int;
+
+ set @z = y, z = 666, max_join_size = 100;
+ insert into test.t1 values (x, z);
+end|
+
+call mixset("mixset", 19)|
+show variables like 'max_join_size'|
+select id,data,@z from t1|
+delete from t1|
+drop procedure mixset|
+
+
+# Multiple CALL statements, one with OUT parameter.
+--disable_warnings
+drop procedure if exists zip|
+--enable_warnings
+create procedure zip(x char(16), y int)
+begin
+ declare z int;
+ call zap(y, z);
+ call bar(x, z);
+end|
+
+# SET local variables and OUT parameter.
+--disable_warnings
+drop procedure if exists zap|
+--enable_warnings
+create procedure zap(x int, out y int)
+begin
+ declare z int;
+ set z = x+1, y = z;
+end|
+
+call zip("zip", 99)|
+select * from t1|
+delete from t1|
+drop procedure zip|
+drop procedure bar|
+
+# Top-level OUT parameter
+call zap(7, @zap)|
+select @zap|
+
+drop procedure zap|
+
+
+# "Deep" calls...
+--disable_warnings
+drop procedure if exists c1|
+--enable_warnings
+create procedure c1(x int)
+ call c2("c", x)|
+--disable_warnings
+drop procedure if exists c2|
+--enable_warnings
+create procedure c2(s char(16), x int)
+ call c3(x, s)|
+--disable_warnings
+drop procedure if exists c3|
+--enable_warnings
+create procedure c3(x int, s char(16))
+ call c4("level", x, s)|
+--disable_warnings
+drop procedure if exists c4|
+--enable_warnings
+create procedure c4(l char(8), x int, s char(16))
+ insert into t1 values (concat(l,s), x)|
+
+call c1(42)|
+select * from t1|
+delete from t1|
+drop procedure c1|
+drop procedure c2|
+drop procedure c3|
+drop procedure c4|
+
+# INOUT test
+--disable_warnings
+drop procedure if exists iotest|
+--enable_warnings
+create procedure iotest(x1 char(16), x2 char(16), y int)
+begin
+ call inc2(x2, y);
+ insert into test.t1 values (x1, y);
+end|
+
+--disable_warnings
+drop procedure if exists inc2|
+--enable_warnings
+create procedure inc2(x char(16), y int)
+begin
+ call inc(y);
+ insert into test.t1 values (x, y);
+end|
+
+--disable_warnings
+drop procedure if exists inc|
+--enable_warnings
+create procedure inc(inout io int)
+ set io = io + 1|
+
+call iotest("io1", "io2", 1)|
+select * from t1|
+delete from t1|
+drop procedure iotest|
+drop procedure inc2|
+
+# Propagating top-level @-vars
+--disable_warnings
+drop procedure if exists incr|
+--enable_warnings
+create procedure incr(inout x int)
+ call inc(x)|
+
+# Before
+select @zap|
+call incr(@zap)|
+# After
+select @zap|
+
+drop procedure inc|
+drop procedure incr|
+
+# Call-by-value test
+# The expected result is:
+# ("cbv2", 4)
+# ("cbv1", 4711)
+--disable_warnings
+drop procedure if exists cbv1|
+--enable_warnings
+create procedure cbv1()
+begin
+ declare y int default 3;
+
+ call cbv2(y+1, y);
+ insert into test.t1 values ("cbv1", y);
+end|
+
+--disable_warnings
+drop procedure if exists cbv2|
+--enable_warnings
+create procedure cbv2(y1 int, inout y2 int)
+begin
+ set y2 = 4711;
+ insert into test.t1 values ("cbv2", y1);
+end|
+
+call cbv1()|
+select * from t1|
+delete from t1|
+drop procedure cbv1|
+drop procedure cbv2|
+
+
+# Subselect arguments
+
+insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
+
+--disable_warnings
+drop procedure if exists sub1|
+--enable_warnings
+create procedure sub1(id char(16), x int)
+ insert into test.t1 values (id, x)|
+
+--disable_warnings
+drop procedure if exists sub2|
+--enable_warnings
+create procedure sub2(id char(16))
+begin
+ declare x int;
+ set x = (select sum(t.i) from test.t2 t);
+ insert into test.t1 values (id, x);
+end|
+
+--disable_warnings
+drop procedure if exists sub3|
+--enable_warnings
+create function sub3(i int) returns int
+ return i+1|
+
+call sub1("sub1a", (select 7))|
+call sub1("sub1b", (select max(i) from t2))|
+--error ER_OPERAND_COLUMNS
+call sub1("sub1c", (select i,d from t2 limit 1))|
+call sub1("sub1d", (select 1 from (select 1) a))|
+call sub2("sub2")|
+select * from t1|
+select sub3((select max(i) from t2))|
+drop procedure sub1|
+drop procedure sub2|
+drop function sub3|
+delete from t1|
+delete from t2|
+
+# Basic tests of the flow control constructs
+
+# Just test on 'x'...
+--disable_warnings
+drop procedure if exists a0|
+--enable_warnings
+create procedure a0(x int)
+while x do
+ set x = x-1;
+ insert into test.t1 values ("a0", x);
+end while|
+
+call a0(3)|
+select * from t1|
+delete from t1|
+drop procedure a0|
+
+
+# The same, but with a more traditional test.
+--disable_warnings
+drop procedure if exists a|
+--enable_warnings
+create procedure a(x int)
+while x > 0 do
+ set x = x-1;
+ insert into test.t1 values ("a", x);
+end while|
+
+call a(3)|
+select * from t1|
+delete from t1|
+drop procedure a|
+
+
+# REPEAT
+--disable_warnings
+drop procedure if exists b|
+--enable_warnings
+create procedure b(x int)
+repeat
+ insert into test.t1 values (repeat("b",3), x);
+ set x = x-1;
+until x = 0 end repeat|
+
+call b(3)|
+select * from t1|
+delete from t1|
+drop procedure b|
+
+
+# Check that repeat isn't parsed the wrong way
+--disable_warnings
+drop procedure if exists b2|
+--enable_warnings
+create procedure b2(x int)
+repeat(select 1 into outfile 'b2');
+ insert into test.t1 values (repeat("b2",3), x);
+ set x = x-1;
+until x = 0 end repeat|
+
+# We don't actually want to call it.
+drop procedure b2|
+
+
+# Labelled WHILE with ITERATE (pointless really)
+--disable_warnings
+drop procedure if exists c|
+--enable_warnings
+create procedure c(x int)
+hmm: while x > 0 do
+ insert into test.t1 values ("c", x);
+ set x = x-1;
+ iterate hmm;
+ insert into test.t1 values ("x", x);
+end while hmm|
+
+call c(3)|
+select * from t1|
+delete from t1|
+drop procedure c|
+
+
+# Labelled WHILE with LEAVE
+--disable_warnings
+drop procedure if exists d|
+--enable_warnings
+create procedure d(x int)
+hmm: while x > 0 do
+ insert into test.t1 values ("d", x);
+ set x = x-1;
+ leave hmm;
+ insert into test.t1 values ("x", x);
+end while|
+
+call d(3)|
+select * from t1|
+delete from t1|
+drop procedure d|
+
+
+# LOOP, with simple IF statement
+--disable_warnings
+drop procedure if exists e|
+--enable_warnings
+create procedure e(x int)
+foo: loop
+ if x = 0 then
+ leave foo;
+ end if;
+ insert into test.t1 values ("e", x);
+ set x = x-1;
+end loop foo|
+
+call e(3)|
+select * from t1|
+delete from t1|
+drop procedure e|
+
+
+# A full IF statement
+--disable_warnings
+drop procedure if exists f|
+--enable_warnings
+create procedure f(x int)
+if x < 0 then
+ insert into test.t1 values ("f", 0);
+elseif x = 0 then
+ insert into test.t1 values ("f", 1);
+else
+ insert into test.t1 values ("f", 2);
+end if|
+
+call f(-2)|
+call f(0)|
+call f(4)|
+select * from t1|
+delete from t1|
+drop procedure f|
+
+
+# This form of CASE is really just syntactic sugar for IF-ELSEIF-...
+--disable_warnings
+drop procedure if exists g|
+--enable_warnings
+create procedure g(x int)
+case
+when x < 0 then
+ insert into test.t1 values ("g", 0);
+when x = 0 then
+ insert into test.t1 values ("g", 1);
+else
+ insert into test.t1 values ("g", 2);
+end case|
+
+call g(-42)|
+call g(0)|
+call g(1)|
+select * from t1|
+delete from t1|
+drop procedure g|
+
+
+# The "simple CASE"
+--disable_warnings
+drop procedure if exists h|
+--enable_warnings
+create procedure h(x int)
+case x
+when 0 then
+ insert into test.t1 values ("h0", x);
+when 1 then
+ insert into test.t1 values ("h1", x);
+else
+ insert into test.t1 values ("h?", x);
+end case|
+
+call h(0)|
+call h(1)|
+call h(17)|
+select * from t1|
+delete from t1|
+drop procedure h|
+
+
+# It's actually possible to LEAVE a BEGIN-END block
+--disable_warnings
+drop procedure if exists i|
+--enable_warnings
+create procedure i(x int)
+foo:
+begin
+ if x = 0 then
+ leave foo;
+ end if;
+ insert into test.t1 values ("i", x);
+end foo|
+
+call i(0)|
+call i(3)|
+select * from t1|
+delete from t1|
+drop procedure i|
+
+
+# SELECT with one of more result set sent back to the clinet
+insert into t1 values ("foo", 3), ("bar", 19)|
+insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
+
+--disable_warnings
+drop procedure if exists sel1|
+--enable_warnings
+create procedure sel1()
+begin
+ select * from t1;
+end|
+
+call sel1()|
+drop procedure sel1|
+
+--disable_warnings
+drop procedure if exists sel2|
+--enable_warnings
+create procedure sel2()
+begin
+ select * from t1;
+ select * from t2;
+end|
+
+call sel2()|
+drop procedure sel2|
+delete from t1|
+delete from t2|
+
+# SELECT INTO local variables
+--disable_warnings
+drop procedure if exists into_test|
+--enable_warnings
+create procedure into_test(x char(16), y int)
+begin
+ insert into test.t1 values (x, y);
+ select id,data into x,y from test.t1 limit 1;
+ insert into test.t1 values (concat(x, "2"), y+2);
+end|
+
+call into_test("into", 100)|
+select * from t1|
+delete from t1|
+drop procedure into_test|
+
+
+# SELECT INTO with a mix of local and global variables
+--disable_warnings
+drop procedure if exists into_tes2|
+--enable_warnings
+create procedure into_test2(x char(16), y int)
+begin
+ insert into test.t1 values (x, y);
+ select id,data into x,@z from test.t1 limit 1;
+ insert into test.t1 values (concat(x, "2"), y+2);
+end|
+
+call into_test2("into", 100)|
+select id,data,@z from t1|
+delete from t1|
+drop procedure into_test2|
+
+
+# SELECT * INTO ... (bug test)
+--disable_warnings
+drop procedure if exists into_test3|
+--enable_warnings
+create procedure into_test3()
+begin
+ declare x char(16);
+ declare y int;
+
+ select * into x,y from test.t1 limit 1;
+ insert into test.t2 values (x, y, 0.0);
+end|
+
+insert into t1 values ("into3", 19)|
+# Two call needed for bug test
+call into_test3()|
+call into_test3()|
+select * from t2|
+delete from t1|
+delete from t2|
+drop procedure into_test3|
+
+
+# SELECT INTO with no data is a warning ("no data", which we will
+# not see normally). When not caught, execution proceeds.
+--disable_warnings
+drop procedure if exists into_test4|
+--enable_warnings
+create procedure into_test4()
+begin
+ declare x int;
+
+ select data into x from test.t1 limit 1;
+ insert into test.t3 values ("into4", x);
+end|
+
+delete from t1|
+create table t3 ( s char(16), d int)|
+call into_test4()|
+select * from t3|
+insert into t1 values ("i4", 77)|
+call into_test4()|
+select * from t3|
+delete from t1|
+drop table t3|
+drop procedure into_test4|
+
+
+# These two (and the two procedures above) caused an assert() to fail in
+# sql_base.cc:lock_tables() at some point.
+--disable_warnings
+drop procedure if exists into_outfile|
+--enable_warnings
+create procedure into_outfile(x char(16), y int)
+begin
+ insert into test.t1 values (x, y);
+ select * into outfile "../tmp/spout" from test.t1;
+ insert into test.t1 values (concat(x, "2"), y+2);
+end|
+
+--system rm -f $MYSQLTEST_VARDIR/tmp/spout
+call into_outfile("ofile", 1)|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spout
+delete from t1|
+drop procedure into_outfile|
+
+--disable_warnings
+drop procedure if exists into_dumpfile|
+--enable_warnings
+create procedure into_dumpfile(x char(16), y int)
+begin
+ insert into test.t1 values (x, y);
+ select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
+ insert into test.t1 values (concat(x, "2"), y+2);
+end|
+
+--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
+call into_dumpfile("dfile", 1)|
+--system rm -f $MYSQLTEST_VARDIR/tmp/spdump
+delete from t1|
+drop procedure into_dumpfile|
+
+--disable_warnings
+drop procedure if exists create_select|
+--enable_warnings
+create procedure create_select(x char(16), y int)
+begin
+ insert into test.t1 values (x, y);
+ create temporary table test.t3 select * from test.t1;
+ insert into test.t3 values (concat(x, "2"), y+2);
+end|
+
+call create_select("cs", 90)|
+select * from t1, t3|
+drop table t3|
+delete from t1|
+drop procedure create_select|
+
+
+# A minimal, constant FUNCTION.
+--disable_warnings
+drop function if exists e|
+--enable_warnings
+create function e() returns double
+ return 2.7182818284590452354|
+
+set @e = e()|
+select e(), @e|
+
+# A minimal function with one argument
+--disable_warnings
+drop function if exists inc|
+--enable_warnings
+create function inc(i int) returns int
+ return i+1|
+
+select inc(1), inc(99), inc(-71)|
+
+# A minimal function with two arguments
+--disable_warnings
+drop function if exists mul|
+--enable_warnings
+create function mul(x int, y int) returns int
+ return x*y|
+
+select mul(1,1), mul(3,5), mul(4711, 666)|
+
+# A minimal string function
+--disable_warnings
+drop function if exists append|
+--enable_warnings
+create function append(s1 char(8), s2 char(8)) returns char(16)
+ return concat(s1, s2)|
+
+select append("foo", "bar")|
+
+# A function with flow control
+--disable_warnings
+drop function if exists fac|
+--enable_warnings
+create function fac(n int unsigned) returns bigint unsigned
+begin
+ declare f bigint unsigned default 1;
+
+ while n > 1 do
+ set f = f * n;
+ set n = n - 1;
+ end while;
+ return f;
+end|
+
+select fac(1), fac(2), fac(5), fac(10)|
+
+# Nested calls
+--disable_warnings
+drop function if exists fun|
+--enable_warnings
+create function fun(d double, i int, u int unsigned) returns double
+ return mul(inc(i), fac(u)) / e()|
+
+select fun(2.3, 3, 5)|
+
+
+# Various function calls in differen statements
+
+insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
+insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
+
+# Disable PS because double's give a bit different values
+--disable_ps_protocol
+select * from t2 where s = append("a", "b")|
+select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
+select * from t2 where d = e()|
+select * from t2|
+--enable_ps_protocol
+delete from t2|
+
+drop function e|
+drop function inc|
+drop function mul|
+drop function append|
+drop function fun|
+
+
+#
+# CONDITIONs and HANDLERs
+#
+
+--disable_warnings
+drop procedure if exists hndlr1|
+--enable_warnings
+create procedure hndlr1(val int)
+begin
+ declare x int default 0;
+ declare foo condition for 1136;
+ declare bar condition for sqlstate '42S98'; # Just for testing syntax
+ declare zip condition for sqlstate value '42S99'; # Just for testing syntax
+ declare continue handler for foo set x = 1;
+
+ insert into test.t1 values ("hndlr1", val, 2); # Too many values
+ if (x) then
+ insert into test.t1 values ("hndlr1", val); # This instead then
+ end if;
+end|
+
+call hndlr1(42)|
+select * from t1|
+delete from t1|
+drop procedure hndlr1|
+
+--disable_warnings
+drop procedure if exists hndlr2|
+--enable_warnings
+create procedure hndlr2(val int)
+begin
+ declare x int default 0;
+
+ begin
+ declare exit handler for sqlstate '21S01' set x = 1;
+
+ insert into test.t1 values ("hndlr2", val, 2); # Too many values
+ end;
+
+ insert into test.t1 values ("hndlr2", x);
+end|
+
+call hndlr2(42)|
+select * from t1|
+delete from t1|
+drop procedure hndlr2|
+
+
+--disable_warnings
+drop procedure if exists hndlr3|
+--enable_warnings
+create procedure hndlr3(val int)
+begin
+ declare x int default 0;
+ declare continue handler for sqlexception # Any error
+ begin
+ declare z int;
+
+ set z = 2 * val;
+ set x = 1;
+ end;
+
+ if val < 10 then
+ begin
+ declare y int;
+
+ set y = val + 10;
+ insert into test.t1 values ("hndlr3", y, 2); # Too many values
+ if x then
+ insert into test.t1 values ("hndlr3", y);
+ end if;
+ end;
+ end if;
+end|
+
+call hndlr3(3)|
+select * from t1|
+delete from t1|
+drop procedure hndlr3|
+
+
+# Variables might be uninitialized when using handlers
+# (Otherwise the compiler can detect if a variable is not set, but
+# not in this case.)
+create table t3 ( id char(16), data int )|
+
+--disable_warnings
+drop procedure if exists hndlr4|
+--enable_warnings
+create procedure hndlr4()
+begin
+ declare x int default 0;
+ declare val int; # No default
+ declare continue handler for sqlstate '02000' set x=1;
+
+ select data into val from test.t3 where id='z' limit 1; # No hits
+
+ insert into test.t3 values ('z', val);
+end|
+
+call hndlr4()|
+select * from t3|
+drop table t3|
+drop procedure hndlr4|
+
+
+#
+# Cursors
+#
+--disable_warnings
+drop procedure if exists cur1|
+--enable_warnings
+create procedure cur1()
+begin
+ declare a char(16);
+ declare b int;
+ declare c double;
+ declare done int default 0;
+ declare c cursor for select * from test.t2;
+ declare continue handler for sqlstate '02000' set done = 1;
+
+ open c;
+ repeat
+ fetch c into a, b, c;
+ if not done then
+ insert into test.t1 values (a, b+c);
+ end if;
+ until done end repeat;
+ close c;
+end|
+
+insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)|
+call cur1()|
+select * from t1|
+drop procedure cur1|
+
+create table t3 ( s char(16), i int )|
+
+--disable_warnings
+drop procedure if exists cur2|
+--enable_warnings
+create procedure cur2()
+begin
+ declare done int default 0;
+ declare c1 cursor for select id,data from test.t1;
+ declare c2 cursor for select i from test.t2;
+ declare continue handler for sqlstate '02000' set done = 1;
+
+ open c1;
+ open c2;
+ repeat
+ begin
+ declare a char(16);
+ declare b,c int;
+
+ fetch from c1 into a, b;
+ fetch next from c2 into c;
+ if not done then
+ if b < c then
+ insert into test.t3 values (a, b);
+ else
+ insert into test.t3 values (a, c);
+ end if;
+ end if;
+ end;
+ until done end repeat;
+ close c1;
+ close c2;
+end|
+
+call cur2()|
+select * from t3|
+delete from t1|
+delete from t2|
+drop table t3|
+drop procedure cur2|
+
+
+# The few characteristics we parse
+--disable_warnings
+drop procedure if exists chistics|
+--enable_warnings
+create procedure chistics()
+ language sql
+ modifies sql data
+ not deterministic
+ sql security definer
+ comment 'Characteristics procedure test'
+ insert into t1 values ("chistics", 1)|
+
+show create procedure chistics|
+# Call it, just to make sure.
+call chistics()|
+select * from t1|
+delete from t1|
+alter procedure chistics sql security invoker|
+show create procedure chistics|
+drop procedure chistics|
+
+--disable_warnings
+drop function if exists chistics|
+--enable_warnings
+create function chistics() returns int
+ language sql
+ deterministic
+ sql security invoker
+ comment 'Characteristics procedure test'
+ return 42|
+
+show create function chistics|
+# Call it, just to make sure.
+select chistics()|
+alter function chistics
+ no sql
+ comment 'Characteristics function test'|
+show create function chistics|
+drop function chistics|
+
+
+# Check mode settings
+insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
+
+set @@sql_mode = 'ANSI'|
+delimiter $|
+--disable_warnings
+drop procedure if exists modes$
+--enable_warnings
+create procedure modes(out c1 int, out c2 int)
+begin
+ declare done int default 0;
+ declare x int;
+ declare c cursor for select data from t1;
+ declare continue handler for sqlstate '02000' set done = 1;
+
+ select 1 || 2 into c1;
+ set c2 = 0;
+ open c;
+ repeat
+ fetch c into x;
+ if not done then
+ set c2 = c2 + 1;
+ end if;
+ until done end repeat;
+ close c;
+end$
+delimiter |$
+set @@sql_mode = ''|
+
+set sql_select_limit = 1|
+call modes(@c1, @c2)|
+set sql_select_limit = default|
+
+select @c1, @c2|
+delete from t1|
+drop procedure modes|
+
+
+# Check that dropping a database without routines works.
+# (Dropping with routines is tested in sp-security.test)
+# First an empty db.
+create database sp_db1|
+drop database sp_db1|
+
+# Again, with a table.
+create database sp_db2|
+use sp_db2|
+# Just put something in here...
+create table t3 ( s char(4), t int )|
+insert into t3 values ("abcd", 42), ("dcba", 666)|
+use test|
+drop database sp_db2|
+
+# And yet again, with just a procedure.
+create database sp_db3|
+use sp_db3|
+--disable_warnings
+drop procedure if exists dummy|
+--enable_warnings
+create procedure dummy(out x int)
+ set x = 42|
+use test|
+drop database sp_db3|
+# Check that it's gone
+select type,db,name from mysql.proc where db = 'sp_db3'|
+
+
+# ROW_COUNT() function after a CALL
+# We test the other cases here too, although it's not strictly SP specific
+--disable_warnings
+drop procedure if exists rc|
+--enable_warnings
+create procedure rc()
+begin
+ delete from t1;
+ insert into t1 values ("a", 1), ("b", 2), ("c", 3);
+end|
+
+call rc()|
+select row_count()|
+--disable_ps_protocol
+update t1 set data=42 where id = "b";
+select row_count()|
+--enable_ps_protocol
+delete from t1|
+select row_count()|
+delete from t1|
+select row_count()|
+select * from t1|
+select row_count()|
+drop procedure rc|
+
+
+#
+# Let us test how well new locking scheme works.
+#
+
+# Let us prepare playground
+--disable_warnings
+drop function if exists f0|
+drop function if exists f1|
+drop function if exists f2|
+drop function if exists f3|
+drop function if exists f4|
+drop function if exists f5|
+drop function if exists f6|
+drop function if exists f7|
+drop function if exists f8|
+drop function if exists f9|
+drop function if exists f10|
+drop function if exists f11|
+drop function if exists f12_1|
+drop function if exists f12_2|
+drop view if exists v0|
+drop view if exists v1|
+drop view if exists v2|
+--enable_warnings
+delete from t1|
+delete from t2|
+insert into t1 values ("a", 1), ("b", 2) |
+insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) |
+
+# Test the simplest function using tables
+create function f1() returns int
+ return (select sum(data) from t1)|
+select f1()|
+# This should work too (and give 2 rows as result)
+select id, f1() from t1|
+
+# Function which uses two instances of table simultaneously
+create function f2() returns int
+ return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
+select f2()|
+select id, f2() from t1|
+
+# Function which uses the same table twice in different queries
+create function f3() returns int
+begin
+ declare n int;
+ declare m int;
+ set n:= (select min(data) from t1);
+ set m:= (select max(data) from t1);
+ return n < m;
+end|
+select f3()|
+select id, f3() from t1|
+
+# Calling two functions using same table
+select f1(), f3()|
+select id, f1(), f3() from t1|
+
+# Function which uses two different tables
+create function f4() returns double
+ return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
+select f4()|
+select s, f4() from t2|
+
+# Recursive functions which due to this recursion require simultaneous
+# access to several instance of the same table won't work
+create function f5(i int) returns int
+begin
+ if i <= 0 then
+ return 0;
+ elseif i = 1 then
+ return (select count(*) from t1 where data = i);
+ else
+ return (select count(*) + f5( i - 1) from t1 where data = i);
+ end if;
+end|
+select f5(1)|
+# Since currently recursive functions are disallowed ER_SP_NO_RECURSION
+# error will be returned, once we will allow them error about
+# insufficient number of locked tables will be returned instead.
+--error ER_SP_NO_RECURSION
+select f5(2)|
+--error ER_SP_NO_RECURSION
+select f5(3)|
+
+# OTOH this should work
+create function f6() returns int
+begin
+ declare n int;
+ set n:= f1();
+ return (select count(*) from t1 where data <= f7() and data <= n);
+end|
+create function f7() returns int
+ return (select sum(data) from t1 where data <= f1())|
+select f6()|
+select id, f6() from t1|
+
+#
+# Let us test how new locking work with views
+#
+# The most trivial view
+create view v1 (a) as select f1()|
+select * from v1|
+select id, a from t1, v1|
+select * from v1, v1 as v|
+# A bit more complex construction
+create view v2 (a) as select a*10 from v1|
+select * from v2|
+select id, a from t1, v2|
+select * from v1, v2|
+
+# Nice example where the same view is used on
+# on different expression levels
+create function f8 () returns int
+ return (select count(*) from v2)|
+
+select *, f8() from v1|
+
+# Let us test what will happen if function is missing
+drop function f1|
+--error 1356
+select * from v1|
+
+# And what will happen if we have recursion which involves
+# views and functions ?
+create function f1() returns int
+ return (select sum(data) from t1) + (select sum(data) from v1)|
+--error ER_SP_NO_RECURSION
+select f1()|
+--error ER_SP_NO_RECURSION
+select * from v1|
+--error ER_SP_NO_RECURSION
+select * from v2|
+# Back to the normal cases
+drop function f1|
+create function f1() returns int
+ return (select sum(data) from t1)|
+
+# Let us also test some weird cases where no real tables is used
+create function f0() returns int
+ return (select * from (select 100) as r)|
+select f0()|
+select *, f0() from (select 1) as t|
+create view v0 as select f0()|
+select * from v0|
+select *, f0() from v0|
+
+#
+# Let us test how well prelocking works with explicit LOCK TABLES.
+#
+lock tables t1 read, t1 as t11 read|
+# These should work well
+select f3()|
+select id, f3() from t1 as t11|
+# Degenerate cases work too :)
+select f0()|
+select * from v0|
+select *, f0() from v0, (select 123) as d1|
+# But these should not !
+--error 1100
+select id, f3() from t1|
+--error 1100
+select f4()|
+unlock tables|
+
+# Let us test how LOCK TABLES which implicitly depends on functions
+# works
+lock tables v2 read, mysql.proc read|
+select * from v2|
+select * from v1|
+# These should not work as we have too little instances of tables locked
+--error 1100
+select * from v1, t1|
+--error 1100
+select f4()|
+unlock tables|
+
+# Tests for handling of temporary tables in functions.
+#
+# Unlike for permanent tables we should be able to create, use
+# and drop such tables in functions.
+#
+# Simplest function using temporary table. It is also test case for bug
+# #12198 "Temporary table aliasing does not work inside stored functions"
+create function f9() returns int
+begin
+ declare a, b int;
+ drop temporary table if exists t3;
+ create temporary table t3 (id int);
+ insert into t3 values (1), (2), (3);
+ set a:= (select count(*) from t3);
+ set b:= (select count(*) from t3 t3_alias);
+ return a + b;
+end|
+# This will emit warning as t3 was not existing before.
+select f9()|
+select f9() from t1 limit 1|
+
+# Function which uses both temporary and permanent tables.
+create function f10() returns int
+begin
+ drop temporary table if exists t3;
+ create temporary table t3 (id int);
+ insert into t3 select id from t4;
+ return (select count(*) from t3);
+end|
+# Check that we don't ignore completely tables used in function
+--error ER_NO_SUCH_TABLE
+select f10()|
+create table t4 as select 1 as id|
+select f10()|
+
+# Practical cases which we don't handle well (yet)
+#
+# Function which does not work because of well-known and documented
+# limitation of MySQL. We can't use the several instances of the
+# same temporary table in statement.
+create function f11() returns int
+begin
+ drop temporary table if exists t3;
+ create temporary table t3 (id int);
+ insert into t3 values (1), (2), (3);
+ return (select count(*) from t3 as a, t3 as b);
+end|
+--error ER_CANT_REOPEN_TABLE
+select f11()|
+--error ER_CANT_REOPEN_TABLE
+select f11() from t1|
+# We don't handle temporary tables used by nested functions well
+create function f12_1() returns int
+begin
+ drop temporary table if exists t3;
+ create temporary table t3 (id int);
+ insert into t3 values (1), (2), (3);
+ return f12_2();
+end|
+create function f12_2() returns int
+ return (select count(*) from t3)|
+# We need clean start to get error
+drop temporary table t3|
+--error ER_NO_SUCH_TABLE
+select f12_1()|
+--error ER_NO_SUCH_TABLE
+select f12_1() from t1 limit 1|
+
+# Cleanup
+drop function f0|
+drop function f1|
+drop function f2|
+drop function f3|
+drop function f4|
+drop function f5|
+drop function f6|
+drop function f7|
+drop function f8|
+drop function f9|
+drop function f10|
+drop function f11|
+drop function f12_1|
+drop function f12_2|
+drop view v0|
+drop view v1|
+drop view v2|
+delete from t1 |
+delete from t2 |
+drop table t4|
+
+# End of non-bug tests
+
+
+#
+# Some "real" examples
+#
+
+# fac
+
+--disable_warnings
+drop table if exists t3|
+--enable_warnings
+create table t3 (n int unsigned not null primary key, f bigint unsigned)|
+
+--disable_warnings
+drop procedure if exists ifac|
+--enable_warnings
+create procedure ifac(n int unsigned)
+begin
+ declare i int unsigned default 1;
+
+ if n > 20 then
+ set n = 20; # bigint overflow otherwise
+ end if;
+ while i <= n do
+ begin
+ insert into test.t3 values (i, fac(i));
+ set i = i + 1;
+ end;
+ end while;
+end|
+
+call ifac(20)|
+select * from t3|
+drop table t3|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show function status like '%f%'|
+drop procedure ifac|
+drop function fac|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show function status like '%f%'|
+
+
+# primes
+
+--disable_warnings
+drop table if exists t3|
+--enable_warnings
+
+create table t3 (
+ i int unsigned not null primary key,
+ p bigint unsigned not null
+)|
+
+insert into t3 values
+ ( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
+ ( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
+ (10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
+ (15, 59), (16, 61), (17, 67), (18, 71), (19, 73),
+ (20, 79), (21, 83), (22, 89), (23, 97), (24, 101),
+ (25, 103), (26, 107), (27, 109), (28, 113), (29, 127),
+ (30, 131), (31, 137), (32, 139), (33, 149), (34, 151),
+ (35, 157), (36, 163), (37, 167), (38, 173), (39, 179),
+ (40, 181), (41, 191), (42, 193), (43, 197), (44, 199)|
+
+--disable_warnings
+drop procedure if exists opp|
+--enable_warnings
+create procedure opp(n bigint unsigned, out pp bool)
+begin
+ declare r double;
+ declare b, s bigint unsigned default 0;
+
+ set r = sqrt(n);
+
+ again:
+ loop
+ if s = 45 then
+ set b = b+200, s = 0;
+ else
+ begin
+ declare p bigint unsigned;
+
+ select t.p into p from test.t3 t where t.i = s;
+ if b+p > r then
+ set pp = 1;
+ leave again;
+ end if;
+ if mod(n, b+p) = 0 then
+ set pp = 0;
+ leave again;
+ end if;
+ set s = s+1;
+ end;
+ end if;
+ end loop;
+end|
+
+--disable_warnings
+drop procedure if exists ip|
+--enable_warnings
+create procedure ip(m int unsigned)
+begin
+ declare p bigint unsigned;
+ declare i int unsigned;
+
+ set i=45, p=201;
+
+ while i < m do
+ begin
+ declare pp bool default 0;
+
+ call opp(p, pp);
+ if pp then
+ insert into test.t3 values (i, p);
+ set i = i+1;
+ end if;
+ set p = p+2;
+ end;
+ end while;
+end|
+show create procedure opp|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status like '%p%'|
+
+# This isn't the fastest way in the world to compute prime numbers, so
+# don't be too ambitious. ;-)
+call ip(200)|
+# We don't want to select the entire table here, just pick a few
+# examples.
+# The expected result is:
+# i p
+# --- ----
+# 45 211
+# 100 557
+# 199 1229
+select * from t3 where i=45 or i=100 or i=199|
+drop table t3|
+drop procedure opp|
+drop procedure ip|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status like '%p%'|
+
+
+# Fibonacci, for recursion test. (Yet Another Numerical series :)
+#
+--disable_warnings
+drop table if exists t3|
+--enable_warnings
+create table t3 ( f bigint unsigned not null )|
+
+# We deliberately do it the awkward way, fetching the last two
+# values from the table, in order to exercise various statements
+# and table accesses at each turn.
+--disable_warnings
+drop procedure if exists fib|
+--enable_warnings
+create procedure fib(n int unsigned)
+begin
+ if n > 1 then
+ begin
+ declare x, y bigint unsigned;
+ declare c cursor for select f from t3 order by f desc limit 2;
+
+ open c;
+ fetch c into y;
+ fetch c into x;
+ close c;
+ insert into t3 values (x+y);
+ call fib(n-1);
+ end;
+ end if;
+end|
+
+# Enable recursion
+set @@max_sp_recursion_depth= 20|
+
+# Minimum test: recursion of 3 levels
+
+insert into t3 values (0), (1)|
+
+call fib(3)|
+
+select * from t3 order by f asc|
+
+delete from t3|
+
+# The original test, 20 levels, ran into memory limits on some machines
+# and builds. Try 10 instead...
+
+insert into t3 values (0), (1)|
+
+call fib(10)|
+
+select * from t3 order by f asc|
+drop table t3|
+drop procedure fib|
+set @@max_sp_recursion_depth= 0|
+
+#
+# Comment & suid
+#
+
+--disable_warnings
+drop procedure if exists bar|
+--enable_warnings
+create procedure bar(x char(16), y int)
+ comment "111111111111" sql security invoker
+ insert into test.t1 values (x, y)|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status like 'bar'|
+alter procedure bar comment "2222222222" sql security definer|
+alter procedure bar comment "3333333333"|
+alter procedure bar|
+show create procedure bar|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status like 'bar'|
+drop procedure bar|
+
+#
+# rexecution
+#
+--disable_warnings
+drop procedure if exists p1|
+--enable_warnings
+create procedure p1 ()
+ select (select s1 from t3) from t3|
+
+create table t3 (s1 int)|
+
+call p1()|
+insert into t3 values (1)|
+call p1()|
+drop procedure p1|
+drop table t3|
+
+#
+# backticks
+#
+--disable_warnings
+drop function if exists foo|
+--enable_warnings
+create function `foo` () returns int
+ return 5|
+select `foo` ()|
+drop function `foo`|
+
+#
+# Implicit LOCK/UNLOCK TABLES for table access in functions
+#
+
+--disable_warnings
+drop function if exists t1max|
+--enable_warnings
+create function t1max() returns int
+begin
+ declare x int;
+ select max(data) into x from t1;
+ return x;
+end|
+
+insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
+select t1max()|
+drop function t1max|
+
+create table t3 (
+ v char(16) not null primary key,
+ c int unsigned not null
+)|
+
+create function getcount(s char(16)) returns int
+begin
+ declare x int;
+
+ select count(*) into x from t3 where v = s;
+ if x = 0 then
+ insert into t3 values (s, 1);
+ else
+ update t3 set c = c+1 where v = s;
+ end if;
+ return x;
+end|
+
+select * from t1 where data = getcount("bar")|
+select * from t3|
+select getcount("zip")|
+select getcount("zip")|
+select * from t3|
+select getcount(id) from t1 where data = 3|
+select getcount(id) from t1 where data = 5|
+select * from t3|
+drop table t3|
+drop function getcount|
+
+
+# Test cases for different combinations of condition handlers in nested
+# begin-end blocks in stored procedures.
+#
+# Note that the standard specifies that the most specific handler should
+# be triggered even if it's an outer handler masked by a less specific
+# handler in an inner block.
+# Note also that '02000' is more specific than NOT FOUND; there might be
+# other '02xxx' states, even if we currently do not issue them in any
+# situation (e.g. '02001').
+#
+# The combinations we test are these:
+#
+# Inner
+# errcode sqlstate not found sqlwarning sqlexception
+# Outer +------------+------------+------------+------------+------------+
+#errcode | h_ee (i) | h_es (o) | h_en (o) | h_ew (o) | h_ex (o) |
+#sqlstate | h_se (i) | h_ss (i) | h_sn (o) | h_sw (o) | h_sx (o) |
+#not found | h_ne (i) | h_ns (i) | h_nn (i) | | |
+#sqlwarning | h_we (i) | h_ws (i) | | h_ww (i) | |
+#sqlexception | h_xe (i) | h_xs (i) | | | h_xx (i) |
+# +------------+---------------------------------------------------+
+#
+# (i) means that the inner handler is the one that should be invoked,
+# (o) means that the outer handler should be invoked.
+#
+# ('not found', 'sqlwarning' and 'sqlexception' are mutually exclusive, hence
+# no tests for those combinations.)
+#
+
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists h_ee|
+drop procedure if exists h_es|
+drop procedure if exists h_en|
+drop procedure if exists h_ew|
+drop procedure if exists h_ex|
+drop procedure if exists h_se|
+drop procedure if exists h_ss|
+drop procedure if exists h_sn|
+drop procedure if exists h_sw|
+drop procedure if exists h_sx|
+drop procedure if exists h_ne|
+drop procedure if exists h_ns|
+drop procedure if exists h_nn|
+drop procedure if exists h_we|
+drop procedure if exists h_ws|
+drop procedure if exists h_ww|
+drop procedure if exists h_xe|
+drop procedure if exists h_xs|
+drop procedure if exists h_xx|
+--enable_warnings
+
+# smallint - to get out of range warnings
+# primary key - to get constraint errors
+create table t3 (a smallint primary key)|
+
+insert into t3 (a) values (1)|
+
+create procedure h_ee()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (bad)' as 'h_ee';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_ee';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_es()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (good)' as 'h_es';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (bad)' as 'h_es';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_en()
+ deterministic
+begin
+ declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+ select 'Outer (good)' as 'h_en';
+
+ begin
+ declare x int;
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Inner (bad)' as 'h_en';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_ew()
+ deterministic
+begin
+ declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+ select 'Outer (good)' as 'h_ew';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (bad)' as 'h_ew';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ex()
+ deterministic
+begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Outer (good)' as 'h_ex';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (bad)' as 'h_ex';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_se()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (bad)' as 'h_se';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_se';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_ss()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (bad)' as 'h_ss';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_ss';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_sn()
+ deterministic
+begin
+ -- Note: '02000' is more specific than NOT FOUND ;
+ -- there might be other not found states
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Outer (good)' as 'h_sn';
+
+ begin
+ declare x int;
+ declare continue handler for not found
+ select 'Inner (bad)' as 'h_sn';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_sw()
+ deterministic
+begin
+ -- data exception - numeric value out of range
+ declare continue handler for sqlstate '22003'
+ select 'Outer (good)' as 'h_sw';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (bad)' as 'h_sw';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_sx()
+ deterministic
+begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Outer (good)' as 'h_sx';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (bad)' as 'h_sx';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_ne()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_ne';
+
+ begin
+ declare x int;
+ declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
+ select 'Inner (good)' as 'h_ne';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_ns()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_ns';
+
+ begin
+ declare x int;
+ declare continue handler for sqlstate '02000' -- no data
+ select 'Inner (good)' as 'h_ns';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_nn()
+ deterministic
+begin
+ declare continue handler for not found
+ select 'Outer (bad)' as 'h_nn';
+
+ begin
+ declare x int;
+ declare continue handler for not found
+ select 'Inner (good)' as 'h_nn';
+
+ select a into x from t3 where a = 42;
+ end;
+end|
+
+create procedure h_we()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_we';
+
+ begin
+ declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
+ select 'Inner (good)' as 'h_we';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ws()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_ws';
+
+ begin
+ -- data exception - numeric value out of range
+ declare continue handler for sqlstate '22003'
+ select 'Inner (good)' as 'h_ws';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_ww()
+ deterministic
+begin
+ declare continue handler for sqlwarning
+ select 'Outer (bad)' as 'h_ww';
+
+ begin
+ declare continue handler for sqlwarning
+ select 'Inner (good)' as 'h_ww';
+
+ insert into t3 values (123456789012);
+ end;
+ delete from t3;
+ insert into t3 values (1);
+end|
+
+create procedure h_xe()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xe';
+
+ begin
+ declare continue handler for 1062 -- ER_DUP_ENTRY
+ select 'Inner (good)' as 'h_xe';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_xs()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xs';
+
+ begin
+ -- integrity constraint violation
+ declare continue handler for sqlstate '23000'
+ select 'Inner (good)' as 'h_xs';
+
+ insert into t3 values (1);
+ end;
+end|
+
+create procedure h_xx()
+ deterministic
+begin
+ declare continue handler for sqlexception
+ select 'Outer (bad)' as 'h_xx';
+
+ begin
+ declare continue handler for sqlexception
+ select 'Inner (good)' as 'h_xx';
+
+ insert into t3 values (1);
+ end;
+end|
+
+call h_ee()|
+call h_es()|
+call h_en()|
+call h_ew()|
+call h_ex()|
+call h_se()|
+call h_ss()|
+call h_sn()|
+call h_sw()|
+call h_sx()|
+call h_ne()|
+call h_ns()|
+call h_nn()|
+call h_we()|
+call h_ws()|
+call h_ww()|
+call h_xe()|
+call h_xs()|
+call h_xx()|
+
+drop table t3|
+drop procedure h_ee|
+drop procedure h_es|
+drop procedure h_en|
+drop procedure h_ew|
+drop procedure h_ex|
+drop procedure h_se|
+drop procedure h_ss|
+drop procedure h_sn|
+drop procedure h_sw|
+drop procedure h_sx|
+drop procedure h_ne|
+drop procedure h_ns|
+drop procedure h_nn|
+drop procedure h_we|
+drop procedure h_ws|
+drop procedure h_ww|
+drop procedure h_xe|
+drop procedure h_xs|
+drop procedure h_xx|
+
+
+#
+# Test cases for old bugs
+#
+
+#
+# BUG#822
+#
+--disable_warnings
+drop procedure if exists bug822|
+--enable_warnings
+create procedure bug822(a_id char(16), a_data int)
+begin
+ declare n int;
+ select count(*) into n from t1 where id = a_id and data = a_data;
+ if n = 0 then
+ insert into t1 (id, data) values (a_id, a_data);
+ end if;
+end|
+
+delete from t1|
+call bug822('foo', 42)|
+call bug822('foo', 42)|
+call bug822('bar', 666)|
+select * from t1|
+delete from t1|
+drop procedure bug822|
+
+#
+# BUG#1495
+#
+--disable_warnings
+drop procedure if exists bug1495|
+--enable_warnings
+create procedure bug1495()
+begin
+ declare x int;
+
+ select data into x from t1 order by id limit 1;
+ if x > 10 then
+ insert into t1 values ("less", x-10);
+ else
+ insert into t1 values ("more", x+10);
+ end if;
+end|
+
+insert into t1 values ('foo', 12)|
+call bug1495()|
+delete from t1 where id='foo'|
+insert into t1 values ('bar', 7)|
+call bug1495()|
+delete from t1 where id='bar'|
+select * from t1|
+delete from t1|
+drop procedure bug1495|
+
+#
+# BUG#1547
+#
+--disable_warnings
+drop procedure if exists bug1547|
+--enable_warnings
+create procedure bug1547(s char(16))
+begin
+ declare x int;
+
+ select data into x from t1 where s = id limit 1;
+ if x > 10 then
+ insert into t1 values ("less", x-10);
+ else
+ insert into t1 values ("more", x+10);
+ end if;
+end|
+
+insert into t1 values ("foo", 12), ("bar", 7)|
+call bug1547("foo")|
+call bug1547("bar")|
+select * from t1|
+delete from t1|
+drop procedure bug1547|
+
+#
+# BUG#1656
+#
+--disable_warnings
+drop table if exists t70|
+--enable_warnings
+create table t70 (s1 int,s2 int)|
+insert into t70 values (1,2)|
+
+--disable_warnings
+drop procedure if exists bug1656|
+--enable_warnings
+create procedure bug1656(out p1 int, out p2 int)
+ select * into p1, p1 from t70|
+
+call bug1656(@1, @2)|
+select @1, @2|
+drop table t70|
+drop procedure bug1656|
+
+#
+# BUG#1862
+#
+create table t3(a int)|
+
+--disable_warnings
+drop procedure if exists bug1862|
+--enable_warnings
+create procedure bug1862()
+begin
+ insert into t3 values(2);
+ flush tables;
+end|
+
+call bug1862()|
+# the second call caused a segmentation
+call bug1862()|
+select * from t3|
+drop table t3|
+drop procedure bug1862|
+
+#
+# BUG#1874
+#
+--disable_warnings
+drop procedure if exists bug1874|
+--enable_warnings
+create procedure bug1874()
+begin
+ declare x int;
+ declare y double;
+ select max(data) into x from t1;
+ insert into t2 values ("max", x, 0);
+ select min(data) into x from t1;
+ insert into t2 values ("min", x, 0);
+ select sum(data) into x from t1;
+ insert into t2 values ("sum", x, 0);
+ select avg(data) into y from t1;
+ insert into t2 values ("avg", 0, y);
+end|
+
+insert into t1 (data) values (3), (1), (5), (9), (4)|
+call bug1874()|
+select * from t2|
+delete from t1|
+delete from t2|
+drop procedure bug1874|
+
+#
+# BUG#2260
+#
+--disable_warnings
+drop procedure if exists bug2260|
+--enable_warnings
+create procedure bug2260()
+begin
+ declare v1 int;
+ declare c1 cursor for select data from t1;
+ declare continue handler for not found set @x2 = 1;
+
+ open c1;
+ fetch c1 into v1;
+ set @x2 = 2;
+ close c1;
+end|
+
+call bug2260()|
+select @x2|
+drop procedure bug2260|
+
+#
+# BUG#2267 "Lost connect if stored procedure has SHOW FUNCTION STATUS"
+#
+--disable_warnings
+drop procedure if exists bug2267_1|
+--enable_warnings
+create procedure bug2267_1()
+begin
+ show procedure status;
+end|
+
+--disable_warnings
+drop procedure if exists bug2267_2|
+--enable_warnings
+create procedure bug2267_2()
+begin
+ show function status;
+end|
+
+--disable_warnings
+drop procedure if exists bug2267_3|
+--enable_warnings
+create procedure bug2267_3()
+begin
+ show create procedure bug2267_1;
+end|
+
+--disable_warnings
+drop procedure if exists bug2267_4|
+drop function if exists bug2267_4|
+--enable_warnings
+create procedure bug2267_4()
+begin
+ show create function bug2267_4;
+end|
+create function bug2267_4() returns int return 100|
+
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+call bug2267_1()|
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+call bug2267_2()|
+call bug2267_3()|
+call bug2267_4()|
+
+drop procedure bug2267_1|
+drop procedure bug2267_2|
+drop procedure bug2267_3|
+drop procedure bug2267_4|
+drop function bug2267_4|
+
+#
+# BUG#2227
+#
+--disable_warnings
+drop procedure if exists bug2227|
+--enable_warnings
+create procedure bug2227(x int)
+begin
+ declare y float default 2.6;
+ declare z char(16) default "zzz";
+
+ select 1.3, x, y, 42, z;
+end|
+
+call bug2227(9)|
+drop procedure bug2227|
+
+#
+# BUG#2614 "Stored procedure with INSERT ... SELECT that does not
+# contain any tables crashes server"
+#
+--disable_warnings
+drop procedure if exists bug2614|
+--enable_warnings
+create procedure bug2614()
+begin
+ drop table if exists t3;
+ create table t3 (id int default '0' not null);
+ insert into t3 select 12;
+ insert into t3 select * from t3;
+end|
+
+--disable_warnings
+call bug2614()|
+--enable_warnings
+call bug2614()|
+drop table t3|
+drop procedure bug2614|
+
+#
+# BUG#2674
+#
+--disable_warnings
+drop function if exists bug2674|
+--enable_warnings
+create function bug2674() returns int
+ return @@sort_buffer_size|
+
+set @osbs = @@sort_buffer_size|
+set @@sort_buffer_size = 262000|
+select bug2674()|
+drop function bug2674|
+set @@sort_buffer_size = @osbs|
+
+#
+# BUG#3259
+#
+--disable_warnings
+drop procedure if exists bug3259_1 |
+--enable_warnings
+create procedure bug3259_1 () begin end|
+--disable_warnings
+drop procedure if exists BUG3259_2 |
+--enable_warnings
+create procedure BUG3259_2 () begin end|
+--disable_warnings
+drop procedure if exists Bug3259_3 |
+--enable_warnings
+create procedure Bug3259_3 () begin end|
+
+call BUG3259_1()|
+call BUG3259_1()|
+call bug3259_2()|
+call Bug3259_2()|
+call bug3259_3()|
+call bUG3259_3()|
+
+drop procedure bUg3259_1|
+drop procedure BuG3259_2|
+drop procedure BUG3259_3|
+
+#
+# BUG#2772
+#
+--disable_warnings
+drop function if exists bug2772|
+--enable_warnings
+create function bug2772() returns char(10) character set latin2
+ return 'a'|
+
+select bug2772()|
+drop function bug2772|
+
+#
+# BUG#2776
+#
+--disable_warnings
+drop procedure if exists bug2776_1|
+--enable_warnings
+create procedure bug2776_1(out x int)
+begin
+ declare v int;
+
+ set v = default;
+ set x = v;
+end|
+
+--disable_warnings
+drop procedure if exists bug2776_2|
+--enable_warnings
+create procedure bug2776_2(out x int)
+begin
+ declare v int default 42;
+
+ set v = default;
+ set x = v;
+end|
+
+set @x = 1|
+call bug2776_1(@x)|
+select @x|
+call bug2776_2(@x)|
+select @x|
+drop procedure bug2776_1|
+drop procedure bug2776_2|
+
+#
+# BUG#2780
+#
+create table t3 (s1 smallint)|
+
+insert into t3 values (123456789012)|
+
+--disable_warnings
+drop procedure if exists bug2780|
+--enable_warnings
+create procedure bug2780()
+begin
+ declare exit handler for sqlwarning set @x = 1;
+
+ set @x = 0;
+ insert into t3 values (123456789012);
+ insert into t3 values (0);
+end|
+
+call bug2780()|
+select @x|
+select * from t3|
+
+drop procedure bug2780|
+drop table t3|
+
+#
+# BUG#1863
+#
+create table t3 (content varchar(10) )|
+insert into t3 values ("test1")|
+insert into t3 values ("test2")|
+create table t4 (f1 int, rc int, t3 int)|
+
+--disable_warnings
+drop procedure if exists bug1863|
+--enable_warnings
+create procedure bug1863(in1 int)
+begin
+
+ declare ind int default 0;
+ declare t1 int;
+ declare t2 int;
+ declare t3 int;
+
+ declare rc int default 0;
+ declare continue handler for 1065 set rc = 1;
+
+ drop temporary table if exists temp_t1;
+ create temporary table temp_t1 (
+ f1 int auto_increment, f2 varchar(20), primary key (f1)
+ );
+
+ insert into temp_t1 (f2) select content from t3;
+
+ select f2 into t3 from temp_t1 where f1 = 10;
+
+ if (rc) then
+ insert into t4 values (1, rc, t3);
+ end if;
+
+ insert into t4 values (2, rc, t3);
+
+end|
+
+call bug1863(10)|
+call bug1863(10)|
+select * from t4|
+
+drop procedure bug1863|
+drop temporary table temp_t1;
+drop table t3, t4|
+
+#
+# BUG#2656
+#
+
+create table t3 (
+ OrderID int not null,
+ MarketID int,
+ primary key (OrderID)
+)|
+
+create table t4 (
+ MarketID int not null,
+ Market varchar(60),
+ Status char(1),
+ primary key (MarketID)
+)|
+
+insert t3 (OrderID,MarketID) values (1,1)|
+insert t3 (OrderID,MarketID) values (2,2)|
+insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
+insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
+
+--disable_warnings
+drop procedure if exists bug2656_1|
+--enable_warnings
+create procedure bug2656_1()
+begin
+ select
+ m.Market
+ from t4 m JOIN t3 o
+ ON o.MarketID != 1 and o.MarketID = m.MarketID;
+end |
+
+--disable_warnings
+drop procedure if exists bug2656_2|
+--enable_warnings
+create procedure bug2656_2()
+begin
+ select
+ m.Market
+ from
+ t4 m, t3 o
+ where
+ m.MarketID != 1 and m.MarketID = o.MarketID;
+
+end |
+
+call bug2656_1()|
+call bug2656_1()|
+call bug2656_2()|
+call bug2656_2()|
+drop procedure bug2656_1|
+drop procedure bug2656_2|
+drop table t3, t4|
+
+
+#
+# BUG#3426
+#
+--disable_warnings
+drop procedure if exists bug3426|
+--enable_warnings
+create procedure bug3426(in_time int unsigned, out x int)
+begin
+ if in_time is null then
+ set @stamped_time=10;
+ set x=1;
+ else
+ set @stamped_time=in_time;
+ set x=2;
+ end if;
+end|
+
+call bug3426(1000, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+call bug3426(NULL, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+# Clear SP cache
+alter procedure bug3426 sql security invoker|
+call bug3426(NULL, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+call bug3426(1000, @i)|
+select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
+
+drop procedure bug3426|
+
+#
+# BUG#3448
+#
+--disable_warnings
+create table t3 (
+ a int primary key,
+ ach char(1)
+) engine = innodb|
+
+create table t4 (
+ b int primary key ,
+ bch char(1)
+) engine = innodb|
+--enable_warnings
+
+insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
+insert into t4 values (1 , 'bCh1' )|
+
+--disable_warnings
+drop procedure if exists bug3448|
+--enable_warnings
+create procedure bug3448()
+ select * from t3 inner join t4 on t3.a = t4.b|
+
+select * from t3 inner join t4 on t3.a = t4.b|
+call bug3448()|
+call bug3448()|
+
+drop procedure bug3448|
+drop table t3, t4|
+
+
+#
+# BUG#3734
+#
+create table t3 (
+ id int unsigned auto_increment not null primary key,
+ title VARCHAR(200),
+ body text,
+ fulltext (title,body)
+)|
+
+insert into t3 (title,body) values
+ ('MySQL Tutorial','DBMS stands for DataBase ...'),
+ ('How To Use MySQL Well','After you went through a ...'),
+ ('Optimizing MySQL','In this tutorial we will show ...'),
+ ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
+ ('MySQL vs. YourSQL','In the following database comparison ...'),
+ ('MySQL Security','When configured properly, MySQL ...')|
+
+--disable_warnings
+drop procedure if exists bug3734 |
+--enable_warnings
+create procedure bug3734 (param1 varchar(100))
+ select * from t3 where match (title,body) against (param1)|
+
+call bug3734('database')|
+call bug3734('Security')|
+
+drop procedure bug3734|
+drop table t3|
+
+#
+# BUG#3863
+#
+--disable_warnings
+drop procedure if exists bug3863|
+--enable_warnings
+create procedure bug3863()
+begin
+ set @a = 0;
+ while @a < 5 do
+ set @a = @a + 1;
+ end while;
+end|
+
+call bug3863()|
+select @a|
+call bug3863()|
+select @a|
+
+drop procedure bug3863|
+
+#
+# BUG#2460
+#
+
+create table t3 (
+ id int(10) unsigned not null default 0,
+ rid int(10) unsigned not null default 0,
+ msg text not null,
+ primary key (id),
+ unique key rid (rid, id)
+)|
+
+--disable_warnings
+drop procedure if exists bug2460_1|
+--enable_warnings
+create procedure bug2460_1(in v int)
+begin
+ ( select n0.id from t3 as n0 where n0.id = v )
+ union
+ ( select n0.id from t3 as n0, t3 as n1
+ where n0.id = n1.rid and n1.id = v )
+ union
+ ( select n0.id from t3 as n0, t3 as n1, t3 as n2
+ where n0.id = n1.rid and n1.id = n2.rid and n2.id = v );
+end|
+
+call bug2460_1(2)|
+call bug2460_1(2)|
+insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')|
+call bug2460_1(2)|
+call bug2460_1(2)|
+
+--disable_warnings
+drop procedure if exists bug2460_2|
+--enable_warnings
+create procedure bug2460_2()
+begin
+ drop table if exists t3;
+ create temporary table t3 (s1 int);
+ insert into t3 select 1 union select 1;
+end|
+
+call bug2460_2()|
+call bug2460_2()|
+select * from t3|
+
+drop procedure bug2460_1|
+drop procedure bug2460_2|
+drop table t3|
+
+
+#
+# BUG#2564
+#
+set @@sql_mode = ''|
+--disable_warnings
+drop procedure if exists bug2564_1|
+--enable_warnings
+create procedure bug2564_1()
+ comment 'Joe''s procedure'
+ insert into `t1` values ("foo", 1)|
+
+set @@sql_mode = 'ANSI_QUOTES'|
+--disable_warnings
+drop procedure if exists bug2564_2|
+--enable_warnings
+create procedure bug2564_2()
+ insert into "t1" values ('foo', 1)|
+
+delimiter $|
+set @@sql_mode = ''$
+--disable_warnings
+drop function if exists bug2564_3$
+--enable_warnings
+create function bug2564_3(x int, y int) returns int
+ return x || y$
+
+set @@sql_mode = 'ANSI'$
+--disable_warnings
+drop function if exists bug2564_4$
+--enable_warnings
+create function bug2564_4(x int, y int) returns int
+ return x || y$
+delimiter |$
+
+set @@sql_mode = ''|
+show create procedure bug2564_1|
+show create procedure bug2564_2|
+show create function bug2564_3|
+show create function bug2564_4|
+
+drop procedure bug2564_1|
+drop procedure bug2564_2|
+drop function bug2564_3|
+drop function bug2564_4|
+
+#
+# BUG#3132
+#
+--disable_warnings
+drop function if exists bug3132|
+--enable_warnings
+create function bug3132(s char(20)) returns char(50)
+ return concat('Hello, ', s, '!')|
+
+select bug3132('Bob') union all select bug3132('Judy')|
+drop function bug3132|
+
+#
+# BUG#3843
+#
+--disable_warnings
+drop procedure if exists bug3843|
+--enable_warnings
+create procedure bug3843()
+ analyze table t1|
+
+# Testing for packets out of order
+call bug3843()|
+call bug3843()|
+select 1+2|
+
+drop procedure bug3843|
+
+#
+# BUG#3368
+#
+create table t3 ( s1 char(10) )|
+insert into t3 values ('a'), ('b')|
+
+--disable_warnings
+drop procedure if exists bug3368|
+--enable_warnings
+create procedure bug3368(v char(10))
+begin
+ select group_concat(v) from t3;
+end|
+
+call bug3368('x')|
+call bug3368('yz')|
+drop procedure bug3368|
+drop table t3|
+
+#
+# BUG#4579
+#
+create table t3 (f1 int, f2 int)|
+insert into t3 values (1,1)|
+
+--disable_warnings
+drop procedure if exists bug4579_1|
+--enable_warnings
+create procedure bug4579_1 ()
+begin
+ declare sf1 int;
+
+ select f1 into sf1 from t3 where f1=1 and f2=1;
+ update t3 set f2 = f2 + 1 where f1=1 and f2=1;
+ call bug4579_2();
+end|
+
+--disable_warnings
+drop procedure if exists bug4579_2|
+--enable_warnings
+create procedure bug4579_2 ()
+begin
+end|
+
+call bug4579_1()|
+call bug4579_1()|
+call bug4579_1()|
+
+drop procedure bug4579_1|
+drop procedure bug4579_2|
+drop table t3|
+
+#
+# BUG#2773: Function's data type ignored in stored procedures
+#
+--disable_warnings
+drop procedure if exists bug2773|
+--enable_warnings
+
+create function bug2773() returns int return null|
+create table t3 as select bug2773()|
+show create table t3|
+drop table t3|
+drop function bug2773|
+
+#
+# BUG#3788: Stored procedure packet error
+#
+--disable_warnings
+drop procedure if exists bug3788|
+--enable_warnings
+
+create function bug3788() returns date return cast("2005-03-04" as date)|
+select bug3788()|
+drop function bug3788|
+
+create function bug3788() returns binary(1) return 5|
+select bug3788()|
+drop function bug3788|
+
+
+#
+# BUG#4726
+#
+create table t3 (f1 int, f2 int, f3 int)|
+insert into t3 values (1,1,1)|
+
+--disable_warnings
+drop procedure if exists bug4726|
+--enable_warnings
+create procedure bug4726()
+begin
+ declare tmp_o_id INT;
+ declare tmp_d_id INT default 1;
+
+ while tmp_d_id <= 2 do
+ begin
+ select f1 into tmp_o_id from t3 where f2=1 and f3=1;
+ set tmp_d_id = tmp_d_id + 1;
+ end;
+ end while;
+end|
+
+call bug4726()|
+call bug4726()|
+call bug4726()|
+
+drop procedure bug4726|
+drop table t3|
+
+#
+# BUG#4318
+#
+
+--disable_parsing # Don't know if HANDLER commands can work with SPs, or at all..
+create table t3 (s1 int)|
+insert into t3 values (3), (4)|
+
+--disable_warnings
+drop procedure if exists bug4318|
+--enable_warnings
+create procedure bug4318()
+ handler t3 read next|
+
+handler t3 open|
+# Expect no results, as tables are closed, but there shouldn't be any errors
+call bug4318()|
+call bug4318()|
+handler t3 close|
+
+drop procedure bug4318|
+drop table t3|
+--enable_parsing
+
+#
+# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
+#
+# Added tests for most other show commands we could find too.
+# (Skipping those already tested, and the ones depending on optional handlers.)
+#
+# Note: This will return a large number of results of different formats,
+# which makes it impossible to filter with --replace_column.
+# It's possible that some of these are not deterministic across
+# platforms. If so, just remove the offending command.
+#
+--disable_warnings
+drop procedure if exists bug4902|
+--enable_warnings
+create procedure bug4902()
+begin
+ show charset like 'foo';
+ show collation like 'foo';
+ show column types;
+ show create table t1;
+ show create database test;
+ show databases like 'foo';
+ show errors;
+ show columns from t1;
+ show grants for 'root'@'localhost';
+ show keys from t1;
+ show open tables like 'foo';
+ show privileges;
+ show status like 'foo';
+ show tables like 'foo';
+ show variables like 'foo';
+ show warnings;
+end|
+--disable_parsing
+show binlog events;
+show storage engines;
+show master status;
+show slave hosts;
+show slave status;
+--enable_parsing
+
+call bug4902()|
+call bug4902()|
+
+drop procedure bug4902|
+
+# We need separate SP for SHOW PROCESSLIST since we want use replace_column
+--disable_warnings
+drop procedure if exists bug4902_2|
+--enable_warnings
+create procedure bug4902_2()
+begin
+ show processlist;
+end|
+--replace_column 1 # 6 # 3 localhost
+call bug4902_2()|
+--replace_column 1 # 6 # 3 localhost
+call bug4902_2()|
+drop procedure bug4902_2|
+
+#
+# BUG#4904
+#
+--disable_warnings
+drop procedure if exists bug4904|
+--enable_warnings
+create procedure bug4904()
+begin
+ declare continue handler for sqlstate 'HY000' begin end;
+
+ create table t2 as select * from t3;
+end|
+
+-- error 1146
+call bug4904()|
+
+drop procedure bug4904|
+
+create table t3 (s1 char character set latin1, s2 char character set latin2)|
+
+--disable_warnings
+drop procedure if exists bug4904|
+--enable_warnings
+create procedure bug4904 ()
+begin
+ declare continue handler for sqlstate 'HY000' begin end;
+
+ select s1 from t3 union select s2 from t3;
+end|
+
+call bug4904()|
+
+drop procedure bug4904|
+drop table t3|
+
+#
+# BUG#336
+#
+--disable_warnings
+drop procedure if exists bug336|
+--enable_warnings
+create procedure bug336(out y int)
+begin
+ declare x int;
+ set x = (select sum(t.data) from test.t1 t);
+ set y = x;
+end|
+
+insert into t1 values ("a", 2), ("b", 3)|
+call bug336(@y)|
+select @y|
+delete from t1|
+drop procedure bug336|
+
+#
+# BUG#3157
+#
+--disable_warnings
+drop procedure if exists bug3157|
+--enable_warnings
+create procedure bug3157()
+begin
+ if exists(select * from t1) then
+ set @n= @n + 1;
+ end if;
+ if (select count(*) from t1) then
+ set @n= @n + 1;
+ end if;
+end|
+
+set @n = 0|
+insert into t1 values ("a", 1)|
+call bug3157()|
+select @n|
+delete from t1|
+drop procedure bug3157|
+
+#
+# BUG#5251: mysql changes creation time of a procedure/function when altering
+#
+--disable_warnings
+drop procedure if exists bug5251|
+--enable_warnings
+create procedure bug5251()
+begin
+end|
+
+select created into @c1 from mysql.proc
+ where db='test' and name='bug5251'|
+--sleep 2
+alter procedure bug5251 comment 'foobar'|
+select count(*) from mysql.proc
+ where db='test' and name='bug5251' and created = @c1|
+
+drop procedure bug5251|
+
+#
+# BUG#5279: Stored procedure packets out of order if CHECKSUM TABLE
+#
+--disable_warnings
+drop procedure if exists bug5251|
+--enable_warnings
+create procedure bug5251()
+ checksum table t1|
+
+call bug5251()|
+call bug5251()|
+drop procedure bug5251|
+
+#
+# BUG#5287: Stored procedure crash if leave outside loop
+#
+--disable_warnings
+drop procedure if exists bug5287|
+--enable_warnings
+create procedure bug5287(param1 int)
+label1:
+ begin
+ declare c cursor for select 5;
+
+ loop
+ if param1 >= 0 then
+ leave label1;
+ end if;
+ end loop;
+end|
+call bug5287(1)|
+drop procedure bug5287|
+
+
+#
+# BUG#5307: Stored procedure allows statement after BEGIN ... END
+#
+--disable_warnings
+drop procedure if exists bug5307|
+--enable_warnings
+create procedure bug5307()
+begin
+end; set @x = 3|
+
+call bug5307()|
+select @x|
+drop procedure bug5307|
+
+#
+# BUG#5258: Stored procedure modified date is 0000-00-00
+# (This was a design flaw)
+--disable_warnings
+drop procedure if exists bug5258|
+--enable_warnings
+create procedure bug5258()
+begin
+end|
+
+--disable_warnings
+drop procedure if exists bug5258_aux|
+--enable_warnings
+create procedure bug5258_aux()
+begin
+ declare c, m char(19);
+
+ select created,modified into c,m from mysql.proc where name = 'bug5258';
+ if c = m then
+ select 'Ok';
+ else
+ select c, m;
+ end if;
+end|
+
+call bug5258_aux()|
+
+drop procedure bug5258|
+drop procedure bug5258_aux|
+
+#
+# BUG#4487: Stored procedure connection aborted if uninitialized char
+#
+--disable_warnings
+drop function if exists bug4487|
+--enable_warnings
+create function bug4487() returns char
+begin
+ declare v char;
+ return v;
+end|
+
+select bug4487()|
+drop function bug4487|
+
+
+#
+# BUG#4941: Stored procedure crash fetching null value into variable.
+#
+--disable_warnings
+drop procedure if exists bug4941|
+--enable_warnings
+--disable_warnings
+drop procedure if exists bug4941|
+--enable_warnings
+create procedure bug4941(out x int)
+begin
+ declare c cursor for select i from t2 limit 1;
+ open c;
+ fetch c into x;
+ close c;
+end|
+
+insert into t2 values (null, null, null)|
+set @x = 42|
+call bug4941(@x)|
+select @x|
+delete from t1|
+drop procedure bug4941|
+
+
+#
+# BUG#3583: query cache doesn't work for stored procedures
+#
+--disable_warnings
+drop procedure if exists bug3583|
+--enable_warnings
+--disable_warnings
+drop procedure if exists bug3583|
+--enable_warnings
+create procedure bug3583()
+begin
+ declare c int;
+
+ select * from t1;
+ select count(*) into c from t1;
+ select c;
+end|
+
+insert into t1 values ("x", 3), ("y", 5)|
+set @x = @@query_cache_size|
+set global query_cache_size = 10*1024*1024|
+
+flush status|
+flush query cache|
+show status like 'Qcache_hits'|
+call bug3583()|
+show status like 'Qcache_hits'|
+call bug3583()|
+call bug3583()|
+show status like 'Qcache_hits'|
+
+set global query_cache_size = @x|
+flush status|
+flush query cache|
+delete from t1|
+drop procedure bug3583|
+
+#
+# BUG#4905: Stored procedure doesn't clear for "Rows affected"
+#
+--disable_warnings
+drop procedure if exists bug4905|
+--enable_warnings
+
+create table t3 (s1 int,primary key (s1))|
+
+--disable_warnings
+drop procedure if exists bug4905|
+--enable_warnings
+create procedure bug4905()
+begin
+ declare v int;
+ declare continue handler for sqlstate '23000' set v = 5;
+
+ insert into t3 values (1);
+end|
+
+call bug4905()|
+select row_count()|
+call bug4905()|
+select row_count()|
+call bug4905()|
+select row_count()|
+select * from t3|
+
+drop procedure bug4905|
+drop table t3|
+
+#
+# BUG#6022: Stored procedure shutdown problem with self-calling function.
+#
+
+--disable_parsing # until we implement support for recursive stored functions.
+--disable_warnings
+drop function if exists bug6022|
+--enable_warnings
+
+--disable_warnings
+drop function if exists bug6022|
+--enable_warnings
+create function bug6022(x int) returns int
+begin
+ if x < 0 then
+ return 0;
+ else
+ return bug6022(x-1);
+ end if;
+end|
+
+select bug6022(5)|
+drop function bug6022|
+--enable_parsing
+
+#
+# BUG#6029: Stored procedure specific handlers should have priority
+#
+--disable_warnings
+drop procedure if exists bug6029|
+--enable_warnings
+
+--disable_warnings
+drop procedure if exists bug6029|
+--enable_warnings
+create procedure bug6029()
+begin
+ declare exit handler for 1136 select '1136';
+ declare exit handler for sqlstate '23000' select 'sqlstate 23000';
+ declare continue handler for sqlexception select 'sqlexception';
+
+ insert into t3 values (1);
+ insert into t3 values (1,2);
+end|
+
+create table t3 (s1 int, primary key (s1))|
+insert into t3 values (1)|
+call bug6029()|
+delete from t3|
+call bug6029()|
+
+drop procedure bug6029|
+drop table t3|
+
+#
+# BUG#8540: Local variable overrides an alias
+#
+--disable_warnings
+drop procedure if exists bug8540|
+--enable_warnings
+
+create procedure bug8540()
+begin
+ declare x int default 1;
+ select x as y, x+0 as z;
+end|
+
+call bug8540()|
+drop procedure bug8540|
+
+#
+# BUG#6642: Stored procedure crash if expression with set function
+#
+create table t3 (s1 int)|
+
+--disable_warnings
+drop procedure if exists bug6642|
+--enable_warnings
+
+create procedure bug6642()
+ select abs(count(s1)) from t3|
+
+call bug6642()|
+call bug6642()|
+drop procedure bug6642|
+
+#
+# BUG#7013: Stored procedure crash if group by ... with rollup
+#
+insert into t3 values (0),(1)|
+--disable_warnings
+drop procedure if exists bug7013|
+--enable_warnings
+create procedure bug7013()
+ select s1,count(s1) from t3 group by s1 with rollup|
+call bug7013()|
+call bug7013()|
+drop procedure bug7013|
+
+#
+# BUG#7743: 'Lost connection to MySQL server during query' on Stored Procedure
+#
+--disable_warnings
+drop table if exists t4|
+--enable_warnings
+create table t4 (
+ a mediumint(8) unsigned not null auto_increment,
+ b smallint(5) unsigned not null,
+ c char(32) not null,
+ primary key (a)
+) engine=myisam default charset=latin1|
+insert into t4 values (1, 2, 'oneword')|
+insert into t4 values (2, 2, 'anotherword')|
+
+--disable_warnings
+drop procedure if exists bug7743|
+--enable_warnings
+create procedure bug7743 ( searchstring char(28) )
+begin
+ declare var mediumint(8) unsigned;
+ select a into var from t4 where b = 2 and c = binary searchstring limit 1;
+ select var;
+end|
+
+call bug7743("oneword")|
+call bug7743("OneWord")|
+call bug7743("anotherword")|
+call bug7743("AnotherWord")|
+drop procedure bug7743|
+drop table t4|
+
+#
+# BUG#7992: SELECT .. INTO variable .. within Stored Procedure crashes
+# the server
+#
+delete from t3|
+insert into t3 values(1)|
+drop procedure if exists bug7992_1|
+drop procedure if exists bug7992_2|
+create procedure bug7992_1()
+begin
+ declare i int;
+ select max(s1)+1 into i from t3;
+end|
+create procedure bug7992_2()
+ insert into t3 (s1) select max(t4.s1)+1 from t3 as t4|
+
+call bug7992_1()|
+call bug7992_1()|
+call bug7992_2()|
+call bug7992_2()|
+
+drop procedure bug7992_1|
+drop procedure bug7992_2|
+drop table t3|
+
+#
+# BUG#8116: calling simple stored procedure twice in a row results
+# in server crash
+#
+create table t3 ( userid bigint(20) not null default 0 )|
+
+--disable_warnings
+drop procedure if exists bug8116|
+--enable_warnings
+create procedure bug8116(in _userid int)
+ select * from t3 where userid = _userid|
+
+call bug8116(42)|
+call bug8116(42)|
+drop procedure bug8116|
+drop table t3|
+
+#
+# BUG#6857: current_time() in STORED PROCEDURES
+#
+--disable_warnings
+drop procedure if exists bug6857|
+--enable_warnings
+create procedure bug6857(counter int)
+begin
+ declare t0, t1 int;
+ declare plus bool default 0;
+
+ set t0 = current_time();
+ while counter > 0 do
+ set counter = counter - 1;
+ end while;
+ set t1 = current_time();
+ if t1 > t0 then
+ set plus = 1;
+ end if;
+ select plus;
+end|
+
+# QQ: This is currently disabled. Not only does it slow down a normal test
+# run, it makes running with valgrind (or similar tools) extremely
+# painful.
+# Make sure this takes at least one second on all machines in all builds.
+# 30000 makes it about 3 seconds on an old 1.1GHz linux.
+#call bug6857(300000)|
+
+drop procedure bug6857|
+
+#
+# BUG#8757: Stored Procedures: Scope of Begin and End Statements do not
+# work properly.
+--disable_warnings
+drop procedure if exists bug8757|
+--enable_warnings
+create procedure bug8757()
+begin
+ declare x int;
+ declare c1 cursor for select data from t1 limit 1;
+
+ begin
+ declare y int;
+ declare c2 cursor for select i from t2 limit 1;
+
+ open c2;
+ fetch c2 into y;
+ close c2;
+ select 2,y;
+ end;
+ open c1;
+ fetch c1 into x;
+ close c1;
+ select 1,x;
+end|
+
+delete from t1|
+delete from t2|
+insert into t1 values ("x", 1)|
+insert into t2 values ("y", 2, 0.0)|
+
+call bug8757()|
+
+delete from t1|
+delete from t2|
+drop procedure bug8757|
+
+
+#
+# BUG#8762: Stored Procedures: Inconsistent behavior
+# of DROP PROCEDURE IF EXISTS statement.
+--disable_warnings
+drop procedure if exists bug8762|
+--enable_warnings
+# Doesn't exist
+drop procedure if exists bug8762; create procedure bug8762() begin end|
+# Does exist
+drop procedure if exists bug8762; create procedure bug8762() begin end|
+drop procedure bug8762|
+
+
+#
+# BUG#5240: Stored procedure crash if function has cursor declaration
+#
+--disable_warnings
+drop function if exists bug5240|
+--enable_warnings
+create function bug5240 () returns int
+begin
+ declare x int;
+ declare c cursor for select data from t1 limit 1;
+
+ open c;
+ fetch c into x;
+ close c;
+ return x;
+end|
+
+delete from t1|
+insert into t1 values ("answer", 42)|
+select id, bug5240() from t1|
+drop function bug5240|
+
+#
+# BUG#5278: Stored procedure packets out of order if SET PASSWORD.
+#
+--disable_warnings
+drop function if exists bug5278|
+--enable_warnings
+create function bug5278 () returns char
+begin
+ SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
+ return 'okay';
+end|
+
+--error 1133
+select bug5278()|
+--error 1133
+select bug5278()|
+drop function bug5278|
+
+#
+# BUG#7992: rolling back temporary Item tree changes in SP
+#
+--disable_warnings
+drop procedure if exists p1|
+--enable_warnings
+create table t3(id int)|
+insert into t3 values(1)|
+create procedure bug7992()
+begin
+ declare i int;
+ select max(id)+1 into i from t3;
+end|
+
+call bug7992()|
+call bug7992()|
+drop procedure bug7992|
+drop table t3|
+delimiter ;|
+
+#
+# BUG#8849: problem with insert statement with table alias's
+#
+# Rolling back changes to AND/OR structure of ON and WHERE clauses in SP
+#
+
+delimiter |;
+create table t3 (
+ lpitnumber int(11) default null,
+ lrecordtype int(11) default null
+)|
+
+create table t4 (
+ lbsiid int(11) not null default '0',
+ ltradingmodeid int(11) not null default '0',
+ ltradingareaid int(11) not null default '0',
+ csellingprice decimal(19,4) default null,
+ primary key (lbsiid,ltradingmodeid,ltradingareaid)
+)|
+
+create table t5 (
+ lbsiid int(11) not null default '0',
+ ltradingareaid int(11) not null default '0',
+ primary key (lbsiid,ltradingareaid)
+)|
+
+--disable_warnings
+drop procedure if exists bug8849|
+--enable_warnings
+create procedure bug8849()
+begin
+ insert into t5
+ (
+ t5.lbsiid,
+ t5.ltradingareaid
+ )
+ select distinct t3.lpitnumber, t4.ltradingareaid
+ from
+ t4 join t3 on
+ t3.lpitnumber = t4.lbsiid
+ and t3.lrecordtype = 1
+ left join t4 as price01 on
+ price01.lbsiid = t4.lbsiid and
+ price01.ltradingmodeid = 1 and
+ t4.ltradingareaid = price01.ltradingareaid;
+end|
+
+call bug8849()|
+call bug8849()|
+call bug8849()|
+drop procedure bug8849|
+drop tables t3,t4,t5|
+
+#
+# BUG#8937: Stored Procedure: AVG() works as SUM() in SELECT ... INTO statement
+#
+--disable_warnings
+drop procedure if exists bug8937|
+--enable_warnings
+create procedure bug8937()
+begin
+ declare s,x,y,z int;
+ declare a float;
+
+ select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
+ select s,x,y,z;
+ select avg(data) into a from t1;
+ select a;
+end|
+
+delete from t1|
+insert into t1 (data) values (1), (2), (3), (4), (6)|
+call bug8937()|
+
+drop procedure bug8937|
+delete from t1|
+
+
+#
+# BUG#6900: Stored procedure inner handler ignored
+# BUG#9074: STORED PROC: The scope of every handler declared is not
+# properly applied
+#
+--disable_warnings
+drop procedure if exists bug6900|
+drop procedure if exists bug9074|
+drop procedure if exists bug6900_9074|
+--enable_warnings
+
+create table t3 (w char unique, x char)|
+insert into t3 values ('a', 'b')|
+
+create procedure bug6900()
+begin
+ declare exit handler for sqlexception select '1';
+
+ begin
+ declare exit handler for sqlexception select '2';
+
+ insert into t3 values ('x', 'y', 'z');
+ end;
+end|
+
+create procedure bug9074()
+begin
+ declare x1, x2, x3, x4, x5, x6 int default 0;
+
+ begin
+ declare continue handler for sqlstate '23000' set x5 = 1;
+
+ insert into t3 values ('a', 'b');
+ set x6 = 1;
+ end;
+
+ begin1_label:
+ begin
+ declare continue handler for sqlstate '23000' set x1 = 1;
+
+ insert into t3 values ('a', 'b');
+ set x2 = 1;
+
+ begin2_label:
+ begin
+ declare exit handler for sqlstate '23000' set x3 = 1;
+
+ set x4= 1;
+ insert into t3 values ('a','b');
+ set x4= 0;
+ end begin2_label;
+ end begin1_label;
+
+ select x1, x2, x3, x4, x5, x6;
+end|
+
+create procedure bug6900_9074(z int)
+begin
+ declare exit handler for sqlstate '23000' select '23000';
+
+ begin
+ declare exit handler for sqlexception select 'sqlexception';
+
+ if z = 1 then
+ insert into t3 values ('a', 'b');
+ else
+ insert into t3 values ('x', 'y', 'z');
+ end if;
+ end;
+end|
+
+call bug6900()|
+call bug9074()|
+call bug6900_9074(0)|
+call bug6900_9074(1)|
+
+drop procedure bug6900|
+drop procedure bug9074|
+drop procedure bug6900_9074|
+drop table t3|
+
+
+#
+# BUG#7185: Stored procedure crash if identifier is AVG
+#
+--disable_warnings
+drop procedure if exists avg|
+--enable_warnings
+create procedure avg ()
+begin
+end|
+
+call avg ()|
+drop procedure avg|
+
+
+#
+# BUG#6129: Stored procedure won't display @@sql_mode value
+#
+--disable_warnings
+drop procedure if exists bug6129|
+--enable_warnings
+set @old_mode= @@sql_mode;
+set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO";
+create procedure bug6129()
+ select @@sql_mode|
+call bug6129()|
+set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"|
+call bug6129()|
+set @@sql_mode= "NO_ZERO_IN_DATE"|
+call bug6129()|
+set @@sql_mode=@old_mode;
+
+drop procedure bug6129|
+
+
+#
+# BUG#9856: Stored procedures: crash if handler for sqlexception, not found
+#
+--disable_warnings
+drop procedure if exists bug9856|
+--enable_warnings
+create procedure bug9856()
+begin
+ declare v int;
+ declare c cursor for select data from t1;
+ declare exit handler for sqlexception, not found select '16';
+
+ open c;
+ fetch c into v;
+ select v;
+end|
+
+delete from t1|
+call bug9856()|
+call bug9856()|
+drop procedure bug9856|
+
+
+#
+# BUG##9674: Stored Procs: Using declared vars in algebric operation causes
+# system crash.
+#
+--disable_warnings
+drop procedure if exists bug9674_1|
+drop procedure if exists bug9674_2|
+--enable_warnings
+create procedure bug9674_1(out arg int)
+begin
+ declare temp_in1 int default 0;
+ declare temp_fl1 int default 0;
+
+ set temp_in1 = 100;
+ set temp_fl1 = temp_in1/10;
+ set arg = temp_fl1;
+end|
+
+create procedure bug9674_2()
+begin
+ declare v int default 100;
+
+ select v/10;
+end|
+
+call bug9674_1(@sptmp)|
+call bug9674_1(@sptmp)|
+select @sptmp|
+call bug9674_2()|
+call bug9674_2()|
+drop procedure bug9674_1|
+drop procedure bug9674_2|
+
+
+#
+# BUG#9598: stored procedure call within stored procedure overwrites IN variable
+#
+--disable_warnings
+drop procedure if exists bug9598_1|
+drop procedure if exists bug9598_2|
+--enable_warnings
+create procedure bug9598_1(in var_1 char(16),
+ out var_2 integer, out var_3 integer)
+begin
+ set var_2 = 50;
+ set var_3 = 60;
+end|
+
+create procedure bug9598_2(in v1 char(16),
+ in v2 integer,
+ in v3 integer,
+ in v4 integer,
+ in v5 integer)
+begin
+ select v1,v2,v3,v4,v5;
+ call bug9598_1(v1,@tmp1,@tmp2);
+ select v1,v2,v3,v4,v5;
+end|
+
+call bug9598_2('Test',2,3,4,5)|
+select @tmp1, @tmp2|
+
+drop procedure bug9598_1|
+drop procedure bug9598_2|
+
+
+#
+# BUG#9902: Crash with simple stored function using user defined variables
+#
+--disable_warnings
+drop procedure if exists bug9902|
+--enable_warnings
+create function bug9902() returns int(11)
+begin
+ set @x = @x + 1;
+ return @x;
+end|
+
+set @qcs1 = @@query_cache_size|
+set global query_cache_size = 100000|
+set @x = 1|
+insert into t1 values ("qc", 42)|
+select bug9902() from t1|
+select bug9902() from t1|
+select @x|
+
+set global query_cache_size = @qcs1|
+delete from t1|
+drop function bug9902|
+
+
+#
+# BUG#9102: Stored proccedures: function which returns blob causes crash
+#
+--disable_warnings
+drop function if exists bug9102|
+--enable_warnings
+create function bug9102() returns blob return 'a'|
+select bug9102()|
+drop function bug9102|
+
+
+#
+# BUG#7648: Stored procedure crash when invoking a function that returns a bit
+#
+--disable_warnings
+drop function if exists bug7648|
+--enable_warnings
+create function bug7648() returns bit(8) return 'a'|
+select bug7648()|
+drop function bug7648|
+
+
+#
+# BUG#9775: crash if create function that returns enum or set
+#
+--disable_warnings
+drop function if exists bug9775|
+--enable_warnings
+create function bug9775(v1 char(1)) returns enum('a','b') return v1|
+select bug9775('a'),bug9775('b'),bug9775('c')|
+drop function bug9775|
+create function bug9775(v1 int) returns enum('a','b') return v1|
+select bug9775(1),bug9775(2),bug9775(3)|
+drop function bug9775|
+
+create function bug9775(v1 char(1)) returns set('a','b') return v1|
+select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')|
+drop function bug9775|
+create function bug9775(v1 int) returns set('a','b') return v1|
+select bug9775(1),bug9775(2),bug9775(3),bug9775(4)|
+drop function bug9775|
+
+
+#
+# BUG#8861: If Return is a YEAR data type, value is not shown in year format
+#
+--disable_warnings
+drop function if exists bug8861|
+--enable_warnings
+create function bug8861(v1 int) returns year return v1|
+select bug8861(05)|
+set @x = bug8861(05)|
+select @x|
+drop function bug8861|
+
+
+#
+# BUG#9004: Inconsistent behaviour of SP re. warnings
+#
+--disable_warnings
+drop procedure if exists bug9004_1|
+drop procedure if exists bug9004_2|
+--enable_warnings
+create procedure bug9004_1(x char(16))
+begin
+ insert into t1 values (x, 42);
+ insert into t1 values (x, 17);
+end|
+create procedure bug9004_2(x char(16))
+ call bug9004_1(x)|
+
+# Truncation warnings expected...
+call bug9004_1('12345678901234567')|
+call bug9004_2('12345678901234567890')|
+
+delete from t1|
+drop procedure bug9004_1|
+drop procedure bug9004_2|
+
+#
+# BUG#7293: Stored procedure crash with soundex
+#
+--disable_warnings
+drop procedure if exists bug7293|
+--enable_warnings
+insert into t1 values ('secret', 0)|
+create procedure bug7293(p1 varchar(100))
+begin
+ if exists (select id from t1 where soundex(p1)=soundex(id)) then
+ select 'yes';
+ end if;
+end;|
+call bug7293('secret')|
+call bug7293 ('secrete')|
+drop procedure bug7293|
+delete from t1|
+
+
+#
+# BUG#9841: Unexpected read lock when trying to update a view in a
+# stored procedure
+#
+--disable_warnings
+drop procedure if exists bug9841|
+drop view if exists v1|
+--enable_warnings
+
+create view v1 as select * from t1, t2 where id = s|
+create procedure bug9841 ()
+ update v1 set data = 10|
+call bug9841()|
+
+drop view v1|
+drop procedure bug9841|
+
+
+#
+# BUG#5963 subqueries in SET/IF
+#
+--disable_warnings
+drop procedure if exists bug5963|
+--enable_warnings
+
+create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
+create table t3 (s1 int)|
+insert into t3 values (5)|
+call bug5963_1()|
+call bug5963_1()|
+drop procedure bug5963_1|
+drop table t3|
+
+create procedure bug5963_2 (cfk_value int)
+begin
+ if cfk_value in (select cpk from t3) then
+ set @x = 5;
+ end if;
+ end;
+|
+create table t3 (cpk int)|
+insert into t3 values (1)|
+call bug5963_2(1)|
+call bug5963_2(1)|
+drop procedure bug5963_2|
+drop table t3|
+
+
+#
+# BUG#9559: Functions: Numeric Operations using -ve value gives incorrect
+# results.
+#
+--disable_warnings
+drop function if exists bug9559|
+--enable_warnings
+create function bug9559()
+ returns int
+begin
+ set @y = -6/2;
+ return @y;
+end|
+
+select bug9559()|
+
+drop function bug9559|
+
+
+#
+# BUG#10961: Stored procedures: crash if select * from dual
+#
+--disable_warnings
+drop procedure if exists bug10961|
+--enable_warnings
+# "select * from dual" results in an error, so the cursor will not open
+create procedure bug10961()
+begin
+ declare v char;
+ declare x int;
+ declare c cursor for select * from dual;
+ declare continue handler for sqlexception select x;
+
+ set x = 1;
+ open c;
+ set x = 2;
+ fetch c into v;
+ set x = 3;
+ close c;
+end|
+
+call bug10961()|
+call bug10961()|
+
+drop procedure bug10961|
+
+#
+# BUG #6866: Second call of a stored procedure using a view with on expressions
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug6866|
+--enable_warnings
+
+DROP VIEW IF EXISTS tv|
+DROP TABLE IF EXISTS tt1,tt2,tt3|
+
+CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
+CREATE TABLE tt2 (a2 int, data2 varchar(10))|
+CREATE TABLE tt3 (a3 int, data3 varchar(10))|
+
+INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
+
+INSERT INTO tt2 VALUES (1, 'a')|
+INSERT INTO tt2 VALUES (2, 'b')|
+INSERT INTO tt2 VALUES (3, 'c')|
+
+INSERT INTO tt3 VALUES (4, 'd')|
+INSERT INTO tt3 VALUES (5, 'e')|
+INSERT INTO tt3 VALUES (6, 'f')|
+
+CREATE VIEW tv AS
+SELECT tt1.*, tt2.data2, tt3.data3
+ FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
+ LEFT JOIN tt3 ON tt1.a3 = tt3.a3
+ ORDER BY tt1.a1, tt2.a2, tt3.a3|
+
+CREATE PROCEDURE bug6866 (_a1 int)
+BEGIN
+SELECT * FROM tv WHERE a1 = _a1;
+END|
+
+CALL bug6866(1)|
+CALL bug6866(1)|
+CALL bug6866(1)|
+
+DROP PROCEDURE bug6866;
+
+DROP VIEW tv|
+DROP TABLE tt1, tt2, tt3|
+
+#
+# BUG#10136: items cleunup
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug10136|
+--enable_warnings
+create table t3 ( name char(5) not null primary key, val float not null)|
+insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)|
+create procedure bug10136()
+begin
+ declare done int default 3;
+
+ repeat
+ select * from t3;
+ set done = done - 1;
+ until done <= 0 end repeat;
+
+end|
+call bug10136()|
+call bug10136()|
+call bug10136()|
+drop procedure bug10136|
+drop table t3|
+
+#
+# BUG#11529: crash server after use stored procedure
+#
+--disable_warnings
+drop procedure if exists bug11529|
+--enable_warnings
+create procedure bug11529()
+begin
+ declare c cursor for select id, data from t1 where data in (10,13);
+
+ open c;
+ begin
+ declare vid char(16);
+ declare vdata int;
+ declare exit handler for not found begin end;
+
+ while true do
+ fetch c into vid, vdata;
+ end while;
+ end;
+ close c;
+end|
+
+insert into t1 values
+ ('Name1', 10),
+ ('Name2', 11),
+ ('Name3', 12),
+ ('Name4', 13),
+ ('Name5', 14)|
+
+call bug11529()|
+call bug11529()|
+delete from t1|
+drop procedure bug11529|
+
+
+#
+# BUG#6063: Stored procedure labels are subject to restrictions (partial)
+# BUG#7088: Stored procedures: labels won't work if character set is utf8
+#
+--disable_warnings
+drop procedure if exists bug6063|
+drop procedure if exists bug7088_1|
+drop procedure if exists bug7088_2|
+--enable_warnings
+
+--disable_parsing # temporarily disabled until Bar fixes BUG#11986
+create procedure bug6063()
+ lâbel: begin end|
+call bug6063()|
+# QQ Known bug: this will not show the label correctly.
+show create procedure bug6063|
+
+set character set utf8|
+create procedure bug7088_1()
+ label1: begin end label1|
+create procedure bug7088_2()
+ läbel1: begin end|
+call bug7088_1()|
+call bug7088_2()|
+set character set default|
+show create procedure bug7088_1|
+show create procedure bug7088_2|
+
+drop procedure bug6063|
+drop procedure bug7088_1|
+drop procedure bug7088_2|
+--enable_parsing
+
+#
+# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure
+# is called".
+#
+--disable_warnings
+drop procedure if exists bug9565_sub|
+drop procedure if exists bug9565|
+--enable_warnings
+create procedure bug9565_sub()
+begin
+ select * from t1;
+end|
+create procedure bug9565()
+begin
+ insert into t1 values ("one", 1);
+ call bug9565_sub();
+end|
+call bug9565()|
+delete from t1|
+drop procedure bug9565_sub|
+drop procedure bug9565|
+
+
+#
+# BUG#9538: SProc: Creation fails if we try to SET system variable
+# using @@var_name in proc
+#
+--disable_warnings
+drop procedure if exists bug9538|
+--enable_warnings
+create procedure bug9538()
+ set @@sort_buffer_size = 1000000|
+
+set @x = @@sort_buffer_size|
+set @@sort_buffer_size = 2000000|
+select @@sort_buffer_size|
+call bug9538()|
+select @@sort_buffer_size|
+set @@sort_buffer_size = @x|
+
+drop procedure bug9538|
+
+
+#
+# BUG#8692: Cursor fetch of empty string
+#
+--disable_warnings
+drop procedure if exists bug8692|
+--enable_warnings
+create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))|
+insert into t3 values ('', '', '', '', '', '', NULL)|
+
+create procedure bug8692()
+begin
+ declare v1 VARCHAR(10);
+ declare v2 VARCHAR(10);
+ declare v3 VARCHAR(10);
+ declare v4 VARCHAR(10);
+ declare v5 VARCHAR(10);
+ declare v6 VARCHAR(10);
+ declare v7 VARCHAR(10);
+ declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3;
+ open c8692;
+ fetch c8692 into v1,v2,v3,v4,v5,v6,v7;
+ select v1, v2, v3, v4, v5, v6, v7;
+end|
+
+call bug8692()|
+drop procedure bug8692|
+drop table t3|
+
+#
+# Bug#10055 "Using stored function with information_schema causes empty
+# result set"
+#
+--disable_warnings
+drop function if exists bug10055|
+--enable_warnings
+create function bug10055(v char(255)) returns char(255) return lower(v)|
+# This select should not crash server and should return all fields in t1
+select t.column_name, bug10055(t.column_name)
+from information_schema.columns as t
+where t.table_schema = 'test' and t.table_name = 't1'|
+drop function bug10055|
+
+#
+# Bug #12297 "SP crashes the server if data inserted inside a lon loop"
+# The test for memleak bug, so actually there is no way to test it
+# from the suite. The test below could be used to check SP memory
+# consumption by passing large input parameter.
+#
+
+--disable_warnings
+drop procedure if exists bug12297|
+--enable_warnings
+
+create procedure bug12297(lim int)
+begin
+ set @x = 0;
+ repeat
+ insert into t1(id,data)
+ values('aa', @x);
+ set @x = @x + 1;
+ until @x >= lim
+ end repeat;
+end|
+
+call bug12297(10)|
+drop procedure bug12297|
+
+#
+# Bug #11247 "Stored procedures: Function calls in long loops leak memory"
+# One more memleak bug test. One could use this test to check that the memory
+# isn't leaking by increasing the input value for p_bug11247.
+#
+
+--disable_warnings
+drop function if exists f_bug11247|
+drop procedure if exists p_bug11247|
+--enable_warnings
+
+create function f_bug11247(param int)
+ returns int
+return param + 1|
+
+create procedure p_bug11247(lim int)
+begin
+ declare v int default 0;
+
+ while v < lim do
+ set v= f_bug11247(v);
+ end while;
+end|
+
+call p_bug11247(10)|
+drop function f_bug11247|
+drop procedure p_bug11247|
+#
+# BUG#12168: "'DECLARE CONTINUE HANDLER FOR NOT FOUND ...' in conditional
+# handled incorrectly"
+#
+--disable_warnings
+drop procedure if exists bug12168|
+drop table if exists t3, t4|
+--enable_warnings
+
+create table t3 (a int)|
+insert into t3 values (1),(2),(3),(4)|
+
+create table t4 (a int)|
+
+create procedure bug12168(arg1 char(1))
+begin
+ declare b, c integer;
+ if arg1 = 'a' then
+ begin
+ declare c1 cursor for select a from t3 where a % 2;
+ declare continue handler for not found set b = 1;
+ set b = 0;
+ open c1;
+ c1_repeat: repeat
+ fetch c1 into c;
+ if (b = 1) then
+ leave c1_repeat;
+ end if;
+
+ insert into t4 values (c);
+ until b = 1
+ end repeat;
+ end;
+ end if;
+ if arg1 = 'b' then
+ begin
+ declare c2 cursor for select a from t3 where not a % 2;
+ declare continue handler for not found set b = 1;
+ set b = 0;
+ open c2;
+ c2_repeat: repeat
+ fetch c2 into c;
+ if (b = 1) then
+ leave c2_repeat;
+ end if;
+
+ insert into t4 values (c);
+ until b = 1
+ end repeat;
+ end;
+ end if;
+end|
+
+call bug12168('a')|
+select * from t4|
+truncate t4|
+call bug12168('b')|
+select * from t4|
+truncate t4|
+call bug12168('a')|
+select * from t4|
+truncate t4|
+call bug12168('b')|
+select * from t4|
+truncate t4|
+drop table t3, t4|
+drop procedure if exists bug12168|
+
+#
+# Bug #11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO
+# query"
+# One more memleak bug. Use the test to check memory consumption.
+#
+
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug11333|
+--enable_warnings
+
+create table t3 (c1 char(128))|
+
+insert into t3 values
+ ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')|
+
+
+create procedure bug11333(i int)
+begin
+ declare tmp varchar(128);
+ set @x = 0;
+ repeat
+ select c1 into tmp from t3
+ where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
+ set @x = @x + 1;
+ until @x >= i
+ end repeat;
+end|
+
+call bug11333(10)|
+
+drop procedure bug11333|
+drop table t3|
+
+#
+# BUG#9048: Creating a function with char binary IN parameter fails
+#
+--disable_warnings
+drop function if exists bug9048|
+--enable_warnings
+create function bug9048(f1 char binary) returns char binary
+begin
+ set f1= concat( 'hello', f1 );
+ return f1;
+end|
+drop function bug9048|
+
+# Bug #12849 Stored Procedure: Crash on procedure call with CHAR type
+# 'INOUT' parameter
+#
+
+--disable_warnings
+drop procedure if exists bug12849_1|
+--enable_warnings
+create procedure bug12849_1(inout x char) select x into x|
+set @var='a'|
+call bug12849_1(@var)|
+select @var|
+drop procedure bug12849_1|
+
+--disable_warnings
+drop procedure if exists bug12849_2|
+--enable_warnings
+create procedure bug12849_2(inout foo varchar(15))
+begin
+select concat(foo, foo) INTO foo;
+end|
+set @var='abcd'|
+call bug12849_2(@var)|
+select @var|
+drop procedure bug12849_2|
+
+#
+# BUG#13133: Local variables in stored procedures are not initialized correctly.
+#
+--disable_warnings
+drop procedure if exists bug131333|
+drop function if exists bug131333|
+--enable_warnings
+create procedure bug131333()
+begin
+ begin
+ declare a int;
+
+ select a;
+ set a = 1;
+ select a;
+ end;
+ begin
+ declare b int;
+
+ select b;
+ end;
+end|
+
+create function bug131333()
+ returns int
+begin
+ begin
+ declare a int;
+
+ set a = 1;
+ end;
+ begin
+ declare b int;
+
+ return b;
+ end;
+end|
+
+call bug131333()|
+select bug131333()|
+
+drop procedure bug131333|
+drop function bug131333|
+
+#
+# BUG#12379: PROCEDURE with HANDLER calling FUNCTION with error get
+# strange result
+#
+--disable_warnings
+drop function if exists bug12379|
+drop procedure if exists bug12379_1|
+drop procedure if exists bug12379_2|
+drop procedure if exists bug12379_3|
+drop table if exists t3|
+--enable_warnings
+
+create table t3 (c1 char(1) primary key not null)|
+
+create function bug12379()
+ returns integer
+begin
+ insert into t3 values('X');
+ insert into t3 values('X');
+ return 0;
+end|
+
+create procedure bug12379_1()
+begin
+ declare exit handler for sqlexception select 42;
+
+ select bug12379();
+END|
+create procedure bug12379_2()
+begin
+ declare exit handler for sqlexception begin end;
+
+ select bug12379();
+end|
+create procedure bug12379_3()
+begin
+ select bug12379();
+end|
+
+--error 1062
+select bug12379()|
+select 1|
+call bug12379_1()|
+select 2|
+call bug12379_2()|
+select 3|
+--error 1062
+call bug12379_3()|
+select 4|
+
+drop function bug12379|
+drop procedure bug12379_1|
+drop procedure bug12379_2|
+drop procedure bug12379_3|
+drop table t3|
+
+#
+# Bug #13124 Stored Procedure using SELECT INTO crashes server
+#
+
+--disable_warnings
+drop procedure if exists bug13124|
+--enable_warnings
+create procedure bug13124()
+begin
+ declare y integer;
+ set @x=y;
+end|
+call bug13124()|
+drop procedure bug13124|
+
+#
+# Bug #12979 Stored procedures: crash if inout decimal parameter
+#
+
+# check NULL inout parameters processing
+
+--disable_warnings
+drop procedure if exists bug12979_1|
+--enable_warnings
+create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
+set @bug12979_user_var = NULL|
+call bug12979_1(@bug12979_user_var)|
+drop procedure bug12979_1|
+
+# check NULL local variables processing
+
+--disable_warnings
+drop procedure if exists bug12979_2|
+--enable_warnings
+create procedure bug12979_2()
+begin
+declare internal_var decimal(5);
+set internal_var= internal_var / 2;
+select internal_var;
+end|
+call bug12979_2()|
+drop procedure bug12979_2|
+
+
+#
+# BUG#6127: Stored procedure handlers within handlers don't work
+#
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug6127|
+--enable_warnings
+create table t3 (s1 int unique)|
+
+set @sm=@@sql_mode|
+set sql_mode='traditional'|
+
+create procedure bug6127()
+begin
+ declare continue handler for sqlstate '23000'
+ begin
+ declare continue handler for sqlstate '22003'
+ insert into t3 values (0);
+
+ insert into t3 values (1000000000000000);
+ end;
+
+ insert into t3 values (1);
+ insert into t3 values (1);
+end|
+
+call bug6127()|
+select * from t3|
+--error ER_DUP_ENTRY
+call bug6127()|
+select * from t3|
+set sql_mode=@sm|
+drop table t3|
+drop procedure bug6127|
+
+
+#
+# BUG#12589: Assert when creating temp. table from decimal stored procedure
+# variable
+#
+--disable_warnings
+drop procedure if exists bug12589_1|
+drop procedure if exists bug12589_2|
+drop procedure if exists bug12589_3|
+--enable_warnings
+create procedure bug12589_1()
+begin
+ declare spv1 decimal(3,3);
+ set spv1= 123.456;
+
+ set spv1 = 'test';
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+create procedure bug12589_2()
+begin
+ declare spv1 decimal(6,3);
+ set spv1= 123.456;
+
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+create procedure bug12589_3()
+begin
+ declare spv1 decimal(6,3);
+ set spv1= -123.456;
+
+ create temporary table tm1 as select spv1;
+ show create table tm1;
+ drop temporary table tm1;
+end|
+
+# Note: The type of the field will match the value, not the declared
+# type of the variable. (This is a type checking issue which
+# might be changed later.)
+
+# Warning expected from "set spv1 = 'test'", the value is set to decimal "0".
+call bug12589_1()|
+# No warnings here
+call bug12589_2()|
+call bug12589_3()|
+drop procedure bug12589_1|
+drop procedure bug12589_2|
+drop procedure bug12589_3|
+
+#
+# BUG#7049: Stored procedure CALL errors are ignored
+#
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug7049_1|
+drop procedure if exists bug7049_2|
+drop procedure if exists bug7049_3|
+drop procedure if exists bug7049_4|
+drop function if exists bug7049_1|
+drop function if exists bug7049_2|
+--enable_warnings
+
+create table t3 ( x int unique )|
+
+create procedure bug7049_1()
+begin
+ insert into t3 values (42);
+ insert into t3 values (42);
+end|
+
+create procedure bug7049_2()
+begin
+ declare exit handler for sqlexception
+ select 'Caught it' as 'Result';
+
+ call bug7049_1();
+ select 'Missed it' as 'Result';
+end|
+
+create procedure bug7049_3()
+ call bug7049_1()|
+
+create procedure bug7049_4()
+begin
+ declare exit handler for sqlexception
+ select 'Caught it' as 'Result';
+
+ call bug7049_3();
+ select 'Missed it' as 'Result';
+end|
+
+create function bug7049_1()
+ returns int
+begin
+ insert into t3 values (42);
+ insert into t3 values (42);
+ return 42;
+end|
+
+create function bug7049_2()
+ returns int
+begin
+ declare x int default 0;
+ declare continue handler for sqlexception
+ set x = 1;
+
+ set x = bug7049_1();
+ return x;
+end|
+
+call bug7049_2()|
+select * from t3|
+delete from t3|
+call bug7049_4()|
+select * from t3|
+select bug7049_2()|
+
+drop table t3|
+drop procedure bug7049_1|
+drop procedure bug7049_2|
+drop procedure bug7049_3|
+drop procedure bug7049_4|
+drop function bug7049_1|
+drop function bug7049_2|
+
+
+#
+# BUG#13941: replace() string fuction behaves badly inside stored procedure
+# (BUG#13914: IFNULL is returning garbage in stored procedure)
+#
+--disable_warnings
+drop function if exists bug13941|
+drop procedure if exists bug13941|
+--enable_warnings
+
+create function bug13941(p_input_str text)
+ returns text
+begin
+ declare p_output_str text;
+
+ set p_output_str = p_input_str;
+
+ set p_output_str = replace(p_output_str, 'xyzzy', 'plugh');
+ set p_output_str = replace(p_output_str, 'test', 'prova');
+ set p_output_str = replace(p_output_str, 'this', 'questo');
+ set p_output_str = replace(p_output_str, ' a ', 'una ');
+ set p_output_str = replace(p_output_str, 'is', '');
+
+ return p_output_str;
+end|
+
+create procedure bug13941(out sout varchar(128))
+begin
+ set sout = 'Local';
+ set sout = ifnull(sout, 'DEF');
+end|
+
+# Note: The bug showed different behaviour in different types of builds,
+# giving garbage results in some, and seemingly working in others.
+# Running with valgrind (or purify) is the safe way to check that it's
+# really working correctly.
+select bug13941('this is a test')|
+call bug13941(@a)|
+select @a|
+
+drop function bug13941|
+drop procedure bug13941|
+
+
+#
+# BUG#13095: Cannot create VIEWs in prepared statements
+#
+
+delimiter ;|
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug13095;
+DROP TABLE IF EXISTS bug13095_t1;
+DROP VIEW IF EXISTS bug13095_v1;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE bug13095(tbl_name varchar(32))
+BEGIN
+ SET @str =
+ CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
+ SELECT @str;
+ PREPARE stmt FROM @str;
+ EXECUTE stmt;
+
+ SET @str =
+ CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
+ SELECT @str;
+ PREPARE stmt FROM @str;
+ EXECUTE stmt;
+
+ SET @str =
+ CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
+ SELECT @str;
+ PREPARE stmt FROM @str;
+ EXECUTE stmt;
+
+ SELECT * FROM bug13095_v1;
+
+ SET @str =
+ "DROP VIEW bug13095_v1";
+ SELECT @str;
+ PREPARE stmt FROM @str;
+ EXECUTE stmt;
+END|
+
+delimiter ;|
+
+CALL bug13095('bug13095_t1');
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug13095;
+DROP VIEW IF EXISTS bug13095_v1;
+DROP TABLE IF EXISTS bug13095_t1;
+--enable_warnings
+
+delimiter |;
+
+#
+# BUG#14210: "Simple query with > operator on large table gives server
+# crash"
+# Check that cursors work in case when HEAP tables are converted to
+# MyISAM
+#
+--disable_warnings
+drop procedure if exists bug14210|
+--enable_warnings
+set @@session.max_heap_table_size=16384|
+select @@session.max_heap_table_size|
+# To trigger the memory corruption the original table must be InnoDB.
+# No harm if it's not, so don't warn if the suite is run with --skip-innodb
+--disable_warnings
+create table t3 (a char(255)) engine=InnoDB|
+--enable_warnings
+create procedure bug14210_fill_table()
+begin
+ declare table_size, max_table_size int default 0;
+ select @@session.max_heap_table_size into max_table_size;
+ delete from t3;
+ insert into t3 (a) values (repeat('a', 255));
+ repeat
+ insert into t3 select a from t3;
+ select count(*)*255 from t3 into table_size;
+ until table_size > max_table_size*2 end repeat;
+end|
+call bug14210_fill_table()|
+drop procedure bug14210_fill_table|
+create table t4 like t3|
+
+create procedure bug14210()
+begin
+ declare a char(255);
+ declare done int default 0;
+ declare c cursor for select * from t3;
+ declare continue handler for sqlstate '02000' set done = 1;
+ open c;
+ repeat
+ fetch c into a;
+ if not done then
+ insert into t4 values (upper(a));
+ end if;
+ until done end repeat;
+ close c;
+end|
+call bug14210()|
+select count(*) from t4|
+
+drop table t3, t4|
+drop procedure bug14210|
+set @@session.max_heap_table_size=default|
+
+
+#
+# BUG#1473: Dumping of stored functions seems to cause corruption in
+# the function body
+#
+--disable_warnings
+drop function if exists bug14723|
+drop procedure if exists bug14723|
+--enable_warnings
+
+delimiter ;;|
+/*!50003 create function bug14723()
+ returns bigint(20)
+main_loop: begin
+ return 42;
+end */;;
+show create function bug14723;;
+select bug14723();;
+
+/*!50003 create procedure bug14723()
+main_loop: begin
+ select 42;
+end */;;
+show create procedure bug14723;;
+call bug14723();;
+
+delimiter |;;
+
+drop function bug14723|
+drop procedure bug14723|
+
+#
+# Bug#14845 "mysql_stmt_fetch returns MYSQL_NO_DATA when COUNT(*) is 0"
+# Check that when fetching from a cursor, COUNT(*) works properly.
+#
+create procedure bug14845()
+begin
+ declare a char(255);
+ declare done int default 0;
+ declare c cursor for select count(*) from t1 where 1 = 0;
+ declare continue handler for sqlstate '02000' set done = 1;
+ open c;
+ repeat
+ fetch c into a;
+ if not done then
+ select a;
+ end if;
+ until done end repeat;
+ close c;
+end|
+call bug14845()|
+drop procedure bug14845|
+
+#
+# BUG#13549 "Server crash with nested stored procedures".
+# Server should not crash when during execution of stored procedure
+# we have to parse trigger/function definition and this new trigger/
+# function has more local variables declared than invoking stored
+# procedure and last of these variables is used in argument of NOT
+# operator.
+#
+--disable_warnings
+drop procedure if exists bug13549_1|
+drop procedure if exists bug13549_2|
+--enable_warnings
+CREATE PROCEDURE `bug13549_2`()
+begin
+ call bug13549_1();
+end|
+CREATE PROCEDURE `bug13549_1`()
+begin
+ declare done int default 0;
+ set done= not done;
+end|
+CALL bug13549_2()|
+drop procedure bug13549_2|
+drop procedure bug13549_1|
+
+#
+# BUG#10100: function (and stored procedure?) recursivity problem
+#
+--disable_warnings
+drop function if exists bug10100f|
+drop procedure if exists bug10100p|
+drop procedure if exists bug10100t|
+drop procedure if exists bug10100pt|
+drop procedure if exists bug10100pv|
+drop procedure if exists bug10100pd|
+drop procedure if exists bug10100pc|
+--enable_warnings
+# routines with simple recursion
+create function bug10100f(prm int) returns int
+begin
+ if prm > 1 then
+ return prm * bug10100f(prm - 1);
+ end if;
+ return 1;
+end|
+create procedure bug10100p(prm int, inout res int)
+begin
+ set res = res * prm;
+ if prm > 1 then
+ call bug10100p(prm - 1, res);
+ end if;
+end|
+create procedure bug10100t(prm int)
+begin
+ declare res int;
+ set res = 1;
+ call bug10100p(prm, res);
+ select res;
+end|
+
+# a procedure which use tables and recursion
+create table t3 (a int)|
+insert into t3 values (0)|
+create view v1 as select a from t3;
+create procedure bug10100pt(level int, lim int)
+begin
+ if level < lim then
+ update t3 set a=level;
+ FLUSH TABLES;
+ call bug10100pt(level+1, lim);
+ else
+ select * from t3;
+ end if;
+end|
+# view & recursion
+create procedure bug10100pv(level int, lim int)
+begin
+ if level < lim then
+ update v1 set a=level;
+ FLUSH TABLES;
+ call bug10100pv(level+1, lim);
+ else
+ select * from v1;
+ end if;
+end|
+# dynamic sql & recursion
+prepare stmt2 from "select * from t3;";
+create procedure bug10100pd(level int, lim int)
+begin
+ if level < lim then
+ select level;
+ prepare stmt1 from "update t3 set a=a+2";
+ execute stmt1;
+ FLUSH TABLES;
+ execute stmt1;
+ FLUSH TABLES;
+ execute stmt1;
+ FLUSH TABLES;
+ deallocate prepare stmt1;
+ execute stmt2;
+ select * from t3;
+ call bug10100pd(level+1, lim);
+ else
+ execute stmt2;
+ end if;
+end|
+# cursor & recursion
+create procedure bug10100pc(level int, lim int)
+begin
+ declare lv int;
+ declare c cursor for select a from t3;
+ open c;
+ if level < lim then
+ select level;
+ fetch c into lv;
+ select lv;
+ update t3 set a=level+lv;
+ FLUSH TABLES;
+ call bug10100pc(level+1, lim);
+ else
+ select * from t3;
+ end if;
+ close c;
+end|
+
+set @@max_sp_recursion_depth=4|
+select @@max_sp_recursion_depth|
+-- error ER_SP_NO_RECURSION
+select bug10100f(3)|
+-- error ER_SP_NO_RECURSION
+select bug10100f(6)|
+call bug10100t(5)|
+call bug10100pt(1,5)|
+call bug10100pv(1,5)|
+update t3 set a=1|
+call bug10100pd(1,5)|
+select * from t3|
+update t3 set a=1|
+call bug10100pc(1,5)|
+select * from t3|
+set @@max_sp_recursion_depth=0|
+select @@max_sp_recursion_depth|
+-- error ER_SP_NO_RECURSION
+select bug10100f(5)|
+-- error ER_SP_RECURSION_LIMIT
+call bug10100t(5)|
+
+#end of the stack checking
+set @@max_sp_recursion_depth=255|
+set @var=1|
+#disable log because error about stack overrun contains numbers which
+#depend on a system
+-- disable_result_log
+-- error ER_STACK_OVERRUN_NEED_MORE
+call bug10100p(255, @var)|
+-- error ER_STACK_OVERRUN_NEED_MORE
+call bug10100pt(1,255)|
+-- error ER_STACK_OVERRUN_NEED_MORE
+call bug10100pv(1,255)|
+-- error ER_STACK_OVERRUN_NEED_MORE
+call bug10100pd(1,255)|
+-- error ER_STACK_OVERRUN_NEED_MORE
+call bug10100pc(1,255)|
+-- enable_result_log
+set @@max_sp_recursion_depth=0|
+
+deallocate prepare stmt2|
+
+drop function bug10100f|
+drop procedure bug10100p|
+drop procedure bug10100t|
+drop procedure bug10100pt|
+drop procedure bug10100pv|
+drop procedure bug10100pd|
+drop procedure bug10100pc|
+drop view v1|
+
+#
+# BUG#13729: Stored procedures: packet error after exception handled
+#
+--disable_warnings
+drop procedure if exists bug13729|
+drop table if exists t3|
+--enable_warnings
+
+create table t3 (s1 int, primary key (s1))|
+
+insert into t3 values (1),(2)|
+
+create procedure bug13729()
+begin
+ declare continue handler for sqlexception select 55;
+
+ update t3 set s1 = 1;
+end|
+
+call bug13729()|
+# Used to cause Packets out of order
+select * from t3|
+
+drop procedure bug13729|
+drop table t3|
+
+#
+# BUG#14643: Stored Procedure: Continuing after failed var. initialization
+# crashes server.
+#
+--disable_warnings
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+--enable_warnings
+
+create procedure bug14643_1()
+begin
+ declare continue handler for sqlexception select 'boo' as 'Handler';
+
+ begin
+ declare v int default undefined_var;
+
+ if v = 1 then
+ select 1;
+ else
+ select v, isnull(v);
+ end if;
+ end;
+end|
+
+create procedure bug14643_2()
+begin
+ declare continue handler for sqlexception select 'boo' as 'Handler';
+
+ case undefined_var
+ when 1 then
+ select 1;
+ else
+ select 2;
+ end case;
+
+ select undefined_var;
+end|
+
+call bug14643_1()|
+call bug14643_2()|
+
+drop procedure bug14643_1|
+drop procedure bug14643_2|
+
+#
+# BUG#14304: auto_increment field incorrect set in SP
+#
+--disable_warnings
+drop procedure if exists bug14304|
+drop table if exists t3, t4|
+--enable_warnings
+
+create table t3(a int primary key auto_increment)|
+create table t4(a int primary key auto_increment)|
+
+create procedure bug14304()
+begin
+ insert into t3 set a=null;
+ insert into t4 set a=null;
+ insert into t4 set a=null;
+ insert into t4 set a=null;
+ insert into t4 set a=null;
+ insert into t4 set a=null;
+ insert into t4 select null as a;
+
+ insert into t3 set a=null;
+ insert into t3 set a=null;
+
+ select * from t3;
+end|
+
+call bug14304()|
+
+drop procedure bug14304|
+drop table t3, t4|
+
+#
+# BUG#14376: MySQL crash on scoped variable (re)initialization
+#
+--disable_warnings
+drop procedure if exists bug14376|
+--enable_warnings
+
+create procedure bug14376()
+begin
+ declare x int default x;
+end|
+
+# Not the error we want, but that's what we got for now...
+--error ER_BAD_FIELD_ERROR
+call bug14376()|
+drop procedure bug14376|
+
+create procedure bug14376()
+begin
+ declare x int default 42;
+
+ begin
+ declare x int default x;
+
+ select x;
+ end;
+end|
+
+call bug14376()|
+
+drop procedure bug14376|
+
+create procedure bug14376(x int)
+begin
+ declare x int default x;
+
+ select x;
+end|
+
+call bug14376(4711)|
+
+drop procedure bug14376|
+
+#
+# Bug#5967 "Stored procedure declared variable used instead of column"
+# The bug should be fixed later.
+# Test precedence of names of parameters, variable declarations,
+# variable declarations in nested compound statements, table columns,
+# table columns in cursor declarations.
+# According to the standard, table columns take precedence over
+# variable declarations. In MySQL 5.0 it's vice versa.
+#
+
+--disable_warnings
+drop procedure if exists bug5967|
+drop table if exists t3|
+--enable_warnings
+create table t3 (a varchar(255))|
+insert into t3 (a) values ("a - table column")|
+create procedure bug5967(a varchar(255))
+begin
+ declare i varchar(255);
+ declare c cursor for select a from t3;
+ select a;
+ select a from t3 into i;
+ select i as 'Parameter takes precedence over table column'; open c;
+ fetch c into i;
+ close c;
+ select i as 'Parameter takes precedence over table column in cursors';
+ begin
+ declare a varchar(255) default 'a - local variable';
+ declare c1 cursor for select a from t3;
+ select a as 'A local variable takes precedence over parameter';
+ open c1;
+ fetch c1 into i;
+ close c1;
+ select i as 'A local variable takes precedence over parameter in cursors';
+ begin
+ declare a varchar(255) default 'a - local variable in a nested compound statement';
+ declare c2 cursor for select a from t3;
+ select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement';
+ select a from t3 into i;
+ select i as 'A local variable in a nested compound statement takes precedence over table column';
+ open c2;
+ fetch c2 into i;
+ close c2;
+ select i as 'A local variable in a nested compound statement takes precedence over table column in cursors';
+ end;
+ end;
+end|
+call bug5967("a - stored procedure parameter")|
+drop procedure bug5967|
+
+#
+# Bug#13012 "SP: REPAIR/BACKUP/RESTORE TABLE crashes the server"
+#
+--disable_warnings
+drop procedure if exists bug13012|
+--enable_warnings
+create procedure bug13012()
+BEGIN
+ REPAIR TABLE t1;
+ BACKUP TABLE t1 to '../tmp';
+ DROP TABLE t1;
+ RESTORE TABLE t1 FROM '../tmp';
+END|
+call bug13012()|
+drop procedure bug13012|
+create view v1 as select * from t1|
+create procedure bug13012()
+BEGIN
+ REPAIR TABLE t1,t2,t3,v1;
+ OPTIMIZE TABLE t1,t2,t3,v1;
+ ANALYZE TABLE t1,t2,t3,v1;
+END|
+call bug13012()|
+call bug13012()|
+call bug13012()|
+drop procedure bug13012|
+drop view v1;
+select * from t1|
+
+#
+# A test case for Bug#15392 "Server crashes during prepared statement
+# execute": make sure that stored procedure check for error conditions
+# properly and do not continue execution if an error has been set.
+#
+# It's necessary to use several DBs because in the original code
+# the successful return of mysql_change_db overrode the error from
+# execution.
+drop schema if exists mysqltest1|
+drop schema if exists mysqltest2|
+drop schema if exists mysqltest3|
+create schema mysqltest1|
+create schema mysqltest2|
+create schema mysqltest3|
+use mysqltest3|
+
+create procedure mysqltest1.p1 (out prequestid varchar(100))
+begin
+ call mysqltest2.p2('call mysqltest3.p3(1, 2)');
+end|
+
+create procedure mysqltest2.p2(in psql text)
+begin
+ declare lsql text;
+ set @lsql= psql;
+ prepare lstatement from @lsql;
+ execute lstatement;
+ deallocate prepare lstatement;
+end|
+
+create procedure mysqltest3.p3(in p1 int)
+begin
+ select p1;
+end|
+
+--error ER_SP_WRONG_NO_OF_ARGS
+call mysqltest1.p1(@rs)|
+--error ER_SP_WRONG_NO_OF_ARGS
+call mysqltest1.p1(@rs)|
+--error ER_SP_WRONG_NO_OF_ARGS
+call mysqltest1.p1(@rs)|
+drop schema if exists mysqltest1|
+drop schema if exists mysqltest2|
+drop schema if exists mysqltest3|
+use test|
+
+#
+# Bug#15441 "Running SP causes Server to Crash": check that an SP variable
+# can not be used in VALUES() function.
+#
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug15441|
+--enable_warnings
+create table t3 (id int not null primary key, county varchar(25))|
+insert into t3 (id, county) values (1, 'York')|
+
+# First check that a stored procedure that refers to a parameter in VALUES()
+# function won't parse.
+
+create procedure bug15441(c varchar(25))
+begin
+ update t3 set id=2, county=values(c);
+end|
+--error ER_BAD_FIELD_ERROR
+call bug15441('county')|
+drop procedure bug15441|
+
+# Now check the case when there is an ambiguity between column names
+# and stored procedure parameters: the parser shall resolve the argument
+# of VALUES() function to the column name.
+
+# It's hard to deduce what county refers to in every case (INSERT statement):
+# 1st county refers to the column
+# 2nd county refers to the procedure parameter
+# 3d and 4th county refers to the column, again, but
+# for 4th county it has the value of SP parameter
+
+# In UPDATE statement, just check that values() function returns NULL for
+# non- INSERT...UPDATE statements, as stated in the manual.
+
+create procedure bug15441(county varchar(25))
+begin
+ declare c varchar(25) default "hello";
+
+ insert into t3 (id, county) values (1, county)
+ on duplicate key update county= values(county);
+ select * from t3;
+
+ update t3 set id=2, county=values(id);
+ select * from t3;
+end|
+call bug15441('Yale')|
+drop table t3|
+drop procedure bug15441|
+
+#
+# BUG#14498: Stored procedures: hang if undefined variable and exception
+#
+--disable_warnings
+drop procedure if exists bug14498_1|
+drop procedure if exists bug14498_2|
+drop procedure if exists bug14498_3|
+drop procedure if exists bug14498_4|
+drop procedure if exists bug14498_5|
+--enable_warnings
+
+create procedure bug14498_1()
+begin
+ declare continue handler for sqlexception select 'error' as 'Handler';
+
+ if v then
+ select 'yes' as 'v';
+ else
+ select 'no' as 'v';
+ end if;
+ select 'done' as 'End';
+end|
+
+create procedure bug14498_2()
+begin
+ declare continue handler for sqlexception select 'error' as 'Handler';
+
+ while v do
+ select 'yes' as 'v';
+ end while;
+ select 'done' as 'End';
+end|
+
+create procedure bug14498_3()
+begin
+ declare continue handler for sqlexception select 'error' as 'Handler';
+
+ repeat
+ select 'maybe' as 'v';
+ until v end repeat;
+ select 'done' as 'End';
+end|
+
+create procedure bug14498_4()
+begin
+ declare continue handler for sqlexception select 'error' as 'Handler';
+
+ case v
+ when 1 then
+ select '1' as 'v';
+ when 2 then
+ select '2' as 'v';
+ else
+ select '?' as 'v';
+ end case;
+ select 'done' as 'End';
+end|
+
+create procedure bug14498_5()
+begin
+ declare continue handler for sqlexception select 'error' as 'Handler';
+
+ case
+ when v = 1 then
+ select '1' as 'v';
+ when v = 2 then
+ select '2' as 'v';
+ else
+ select '?' as 'v';
+ end case;
+ select 'done' as 'End';
+end|
+
+call bug14498_1()|
+call bug14498_2()|
+call bug14498_3()|
+call bug14498_4()|
+call bug14498_5()|
+
+drop procedure bug14498_1|
+drop procedure bug14498_2|
+drop procedure bug14498_3|
+drop procedure bug14498_4|
+drop procedure bug14498_5|
+
+#
+# BUG#15231: Stored procedure bug with not found condition handler
+#
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug15231_1|
+drop procedure if exists bug15231_2|
+drop procedure if exists bug15231_3|
+drop procedure if exists bug15231_4|
+--enable_warnings
+
+create table t3 (id int not null)|
+
+create procedure bug15231_1()
+begin
+ declare xid integer;
+ declare xdone integer default 0;
+ declare continue handler for not found set xdone = 1;
+
+ set xid=null;
+ call bug15231_2(xid);
+ select xid, xdone;
+end|
+
+create procedure bug15231_2(inout ioid integer)
+begin
+ select "Before NOT FOUND condition is triggered" as '1';
+ select id into ioid from t3 where id=ioid;
+ select "After NOT FOUND condtition is triggered" as '2';
+
+ if ioid is null then
+ set ioid=1;
+ end if;
+end|
+
+create procedure bug15231_3()
+begin
+ declare exit handler for sqlwarning
+ select 'Caught it (wrong)' as 'Result';
+
+ call bug15231_4();
+end|
+
+create procedure bug15231_4()
+begin
+ declare x decimal(2,1);
+
+ set x = 'zap';
+ select 'Missed it (correct)' as 'Result';
+end|
+
+call bug15231_1()|
+call bug15231_3()|
+
+drop table if exists t3|
+drop procedure if exists bug15231_1|
+drop procedure if exists bug15231_2|
+drop procedure if exists bug15231_3|
+drop procedure if exists bug15231_4|
+
+
+#
+# BUG#15011: error handler in nested block not activated
+#
+--disable_warnings
+drop procedure if exists bug15011|
+--enable_warnings
+
+create table t3 (c1 int primary key)|
+
+insert into t3 values (1)|
+
+create procedure bug15011()
+ deterministic
+begin
+ declare continue handler for 1062
+ select 'Outer' as 'Handler';
+
+ begin
+ declare continue handler for 1062
+ select 'Inner' as 'Handler';
+
+ insert into t3 values (1);
+ end;
+end|
+
+call bug15011()|
+
+drop procedure bug15011|
+drop table t3|
+
+
+#
+# BUG#NNNN: New bug synopsis
+#
+#--disable_warnings
+#drop procedure if exists bugNNNN|
+#--enable_warnings
+#create procedure bugNNNN...
+
+# Add bugs above this line. Use existing tables t1 and t2 when
+# practical, or create table t3, t4 etc temporarily (and drop them).
+delimiter ;|
+drop table t1,t2;
diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test
index f7ba9803fda..3854297ec0c 100644
--- a/mysql-test/t/sp_notembedded.test
+++ b/mysql-test/t/sp_notembedded.test
@@ -128,6 +128,7 @@ call bug6807()|
drop procedure bug6807|
+
#
# BUG#10100: function (and stored procedure?) recursivity problem
#
@@ -152,7 +153,7 @@ create procedure bug10100p(prm int, inout res int)
begin
set res = res * prm;
if prm > 1 then
- call bug10100p(prm - 1, res);
+ call bug10100p(prm - 1, res);
end if;
end|
create procedure bug10100t(prm int)
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 9e09b215951..733403f482e 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1963,12 +1963,6 @@ select * from (select max(fld) from t1) as foo;
drop table t1;
#
-# BUG #10308: purge log with subselect
-#
-
-purge master logs before (select adddate(current_timestamp(), interval -4 day));
-
-#
# Test for bug #11762: subquery with an aggregate function in HAVING
#
diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test
index 18e1efb3120..14132f5af11 100644
--- a/mysql-test/t/system_mysql_db_fix.test
+++ b/mysql-test/t/system_mysql_db_fix.test
@@ -81,7 +81,8 @@ engine=MyISAM;
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N');
--- exec $MYSQL_FIX_SYSTEM_TABLES --database=test
+# Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system
+-- system $MYSQL_FIX_SYSTEM_TABLES --database=test > /dev/null
-- enable_query_log
-- enable_result_log
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 2d505fdfece..9121283fb32 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -1,3 +1,5 @@
+# mysqltest should be fixed
+-- source include/not_embedded.inc
#
# Test of temporary tables
#
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index c3cc8e3f8e8..0ac57394c2f 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -3,7 +3,7 @@
#
--disable_warnings
-drop table if exists t1, t2, t3;
+drop table if exists t1, t2, t3, t4;
drop view if exists v1;
drop database if exists mysqltest;
drop function if exists f1;
@@ -959,6 +959,92 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0;
drop trigger t1_bi;
connection default;
+#
+# Test for bug #13525 "Rename table does not keep info of triggers"
+#
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+insert into t1 values (101);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+rename table t1 to t2;
+# Trigger should work after rename
+insert into t2 values (102);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+# Let us check that the same works for simple ALTER TABLE ... RENAME
+alter table t2 rename to t3;
+insert into t3 values (103);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+# And for more complex ALTER TABLE
+alter table t3 rename to t4, add column val int default 0;
+insert into t4 values (104, 1);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+# .TRN file should be updated with new table name
+drop trigger t1_bi;
+drop table t4;
+# Rename between different databases if triggers exist should fail
+create database mysqltest;
+use mysqltest;
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+insert into t1 values (101);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' or event_object_schema = 'mysqltest';
+--error ER_TRG_IN_WRONG_SCHEMA
+rename table t1 to test.t2;
+insert into t1 values (102);
+select @a;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' or event_object_schema = 'mysqltest';
+# There should be no fantom .TRN files
+--error ER_TRG_DOES_NOT_EXIST
+drop trigger test.t1_bi;
+drop trigger t1_bi;
+drop table t1;
+drop database mysqltest;
+use test;
+# And now let us check that the properly handle rename if there is some
+# error during it (that we rollback such renames completely).
+create table t1 (id int);
+create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+create trigger t1_ai after insert on t1 for each row set @b:=new.id;
+insert into t1 values (101);
+select @a, @b;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+# Trick which makes update of second .TRN file impossible
+system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+--error 1
+rename table t1 to t2;
+# 't1' should be still there and triggers should work correctly
+insert into t1 values (102);
+select @a, @b;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test';
+system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+# Let us check that updates to .TRN files were rolled back too
+drop trigger t1_bi;
+drop trigger t1_ai;
+drop table t1;
+
# Test for bug #16829 "Firing trigger with RETURN crashes the server"
# RETURN is not supposed to be used anywhere except functions, so error
# should be returned when one attempts to create trigger with RETURN.
diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test
index 826f486e4c0..42e32b686c2 100644
--- a/mysql-test/t/upgrade.test
+++ b/mysql-test/t/upgrade.test
@@ -1,28 +1,31 @@
+-- source include/not_embedded.inc
+
--disable_warnings
-drop database if exists `testdb1`;
-drop database if exists `testdb-1`;
-drop database if exists `#mysql50#testdb-1`;
+drop database if exists `mysqltest1`;
+drop database if exists `mysqltest-1`;
+drop database if exists `#mysql50#mysqltest-1`;
--enable_warnings
-create database `testdb1`;
-create database `#mysql50#testdb-1`;
-create table `testdb1`.`t1` (a int);
-create table `testdb1`.`#mysql50#t-1` (a int);
-create table `#mysql50#testdb-1`.`t1` (a int);
-create table `#mysql50#testdb-1`.`#mysql50#t-1` (a int);
-show create database `testdb1`;
+
+create database `mysqltest1`;
+create database `#mysql50#mysqltest-1`;
+create table `mysqltest1`.`t1` (a int);
+create table `mysqltest1`.`#mysql50#t-1` (a int);
+create table `#mysql50#mysqltest-1`.`t1` (a int);
+create table `#mysql50#mysqltest-1`.`#mysql50#t-1` (a int);
+show create database `mysqltest1`;
--error 1049
-show create database `testdb-1`;
-show create database `#mysql50#testdb-1`;
-show tables in `testdb1`;
-show tables in `#mysql50#testdb-1`;
+show create database `mysqltest-1`;
+show create database `#mysql50#mysqltest-1`;
+show tables in `mysqltest1`;
+show tables in `#mysql50#mysqltest-1`;
--exec $MYSQL_CHECK --all-databases --fix-db-names --fix-table-names
-show create database `testdb1`;
-show create database `testdb-1`;
+show create database `mysqltest1`;
+show create database `mysqltest-1`;
--error 1049
-show create database `#mysql50#testdb-1`;
-show tables in `testdb1`;
-show tables in `testdb-1`;
-drop database `testdb1`;
-drop database `testdb-1`;
+show create database `#mysql50#mysqltest-1`;
+show tables in `mysqltest1`;
+show tables in `mysqltest-1`;
+drop database `mysqltest1`;
+drop database `mysqltest-1`;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 5d1b5a80a9b..294a254390f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2375,3 +2375,18 @@ SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x;
DROP VIEW v1;
DROP TABLE t1;
+
+#
+# BUG#15943: mysql_next_result hangs on invalid SHOW CREATE VIEW
+#
+
+delimiter //;
+drop table if exists t1;
+drop view if exists v1;
+create table t1 (id int);
+create view v1 as select * from t1;
+drop table t1;
+show create view v1;
+drop view v1;
+//
+delimiter ;//
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 1327436d6c3..a3a8aa6a4c3 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -717,3 +717,5 @@ create definer=some_user@`` sql security invoker view v1 as select 1;
create definer=some_user@localhost sql security invoker view v1 as select 1;
show create view v1;
drop view v1;
+
+
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index e88d95674ed..f7ce987f29d 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -23,6 +23,7 @@ SELECT extractValue(@xml,'/*/*');
SELECT extractValue(@xml,'/*/*/*');
SELECT extractValue(@xml,'/a/child::*');
+SELECT extractValue(@xml,'/a/self::*');
SELECT extractValue(@xml,'/a/descendant::*');
SELECT extractValue(@xml,'/a/descendant-or-self::*');
SELECT extractValue(@xml,'/a/attribute::*');
@@ -231,3 +232,33 @@ select extractvalue('<a><b>B</b></a>','/a|b');
select extractvalue('<a>a<b>B</b></a>','/a|/b');
select extractvalue('<a>a<b>B</b></a>','/a|b');
select extractvalue('<a>a<b>B</b></a>','a|/b');
+
+#
+# Bug#16312 XML: extractvalue() crash if angle brackets
+#
+--error 1105
+select extractvalue('<a>A</a>','/<a>');
+
+#
+# Bug#16313 XML: extractvalue() ignores '!' in names
+#
+--error 1105
+select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
+
+#
+# Bug #16315 XML: extractvalue() handles self badly
+#
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
+# Bug #16320 XML: extractvalue() won't accept names containing underscores
+#
+select extractvalue('<A_B>A</A_B>','/A_B');
+
+#
+# Bug#16316: XML: extractvalue() is case-sensitive with contains()
+#
+select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
+select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');