summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorcmiller@zippy.(none) <>2006-07-05 16:16:09 -0400
committercmiller@zippy.(none) <>2006-07-05 16:16:09 -0400
commit91b8b264111df590cd8659b04e763f8148af066d (patch)
treea0c67909c6e1a1b67caf4558144a68911d8dfb15 /mysql-test/t
parent283d51b6bac2f17cbd2c410ecba1753409644dc5 (diff)
parent267aeffca33581590b5123133e981a7135c7cce4 (diff)
downloadmariadb-git-91b8b264111df590cd8659b04e763f8148af066d.tar.gz
Merge zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1
into zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1-new-maint
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/archive.test3
-rw-r--r--mysql-test/t/auto_increment.test17
-rw-r--r--mysql-test/t/bdb.test1
-rw-r--r--mysql-test/t/ctype_latin1.test11
-rw-r--r--mysql-test/t/ctype_ucs.test26
-rw-r--r--mysql-test/t/ctype_utf8.test114
-rw-r--r--mysql-test/t/delayed.test49
-rw-r--r--mysql-test/t/disabled.def9
-rw-r--r--mysql-test/t/distinct.test28
-rw-r--r--mysql-test/t/events.test9
-rw-r--r--mysql-test/t/events_bugs.test37
-rw-r--r--mysql-test/t/events_grant.test21
-rw-r--r--mysql-test/t/events_logs_tests.test16
-rw-r--r--mysql-test/t/events_microsec.test6
-rw-r--r--mysql-test/t/events_scheduling.test3
-rw-r--r--mysql-test/t/events_stress.test26
-rw-r--r--mysql-test/t/federated.test6
-rw-r--r--mysql-test/t/fulltext2.test10
-rw-r--r--mysql-test/t/fulltext_left_join.test15
-rw-r--r--mysql-test/t/func_concat.test15
-rw-r--r--mysql-test/t/func_group.test28
-rw-r--r--mysql-test/t/func_str.test12
-rw-r--r--mysql-test/t/func_time.test37
-rw-r--r--mysql-test/t/func_timestamp.test6
-rw-r--r--mysql-test/t/im_cmd_line.imtest4
-rw-r--r--mysql-test/t/im_daemon_life_cycle.imtest17
-rw-r--r--mysql-test/t/im_instance_conf.imtest49
-rw-r--r--mysql-test/t/im_life_cycle.imtest55
-rw-r--r--mysql-test/t/im_options.imtest10
-rw-r--r--mysql-test/t/im_utils.imtest16
-rw-r--r--mysql-test/t/information_schema.test85
-rw-r--r--mysql-test/t/innodb.test13
-rw-r--r--mysql-test/t/innodb_mysql.test8
-rw-r--r--mysql-test/t/insert.test33
-rw-r--r--mysql-test/t/insert_select.test22
-rw-r--r--mysql-test/t/join.test26
-rw-r--r--mysql-test/t/key.test12
-rwxr-xr-xmysql-test/t/kill_n_check.sh109
-rw-r--r--mysql-test/t/lock_multi.test58
-rw-r--r--mysql-test/t/log_state-master.opt1
-rw-r--r--mysql-test/t/log_state.test122
-rw-r--r--mysql-test/t/lowercase_table2.test11
-rw-r--r--mysql-test/t/merge.test9
-rw-r--r--mysql-test/t/multi_update.test8
-rw-r--r--mysql-test/t/myisam.test22
-rw-r--r--mysql-test/t/mysqldump.test51
-rw-r--r--mysql-test/t/ndb_alter_table.test13
-rw-r--r--mysql-test/t/ndb_binlog_multi.test11
-rw-r--r--mysql-test/t/ndb_blob_partition.test93
-rw-r--r--mysql-test/t/ndb_condition_pushdown.test22
-rw-r--r--mysql-test/t/ndb_dd_backuprestore.test170
-rw-r--r--mysql-test/t/ndb_dd_ddl.test97
-rw-r--r--mysql-test/t/ndb_loaddatalocal.test70
-rw-r--r--mysql-test/t/ndb_partition_error.test71
-rw-r--r--mysql-test/t/ndb_partition_key.test198
-rw-r--r--mysql-test/t/ndb_partition_list.test64
-rw-r--r--mysql-test/t/ndb_partition_range.test260
-rw-r--r--mysql-test/t/ndb_replace.test30
-rw-r--r--mysql-test/t/ndb_restore_partition-master.opt1
-rw-r--r--mysql-test/t/ndb_restore_partition.test375
-rw-r--r--mysql-test/t/partition.test115
-rw-r--r--mysql-test/t/partition_error.test38
-rw-r--r--mysql-test/t/partition_list.test12
-rw-r--r--mysql-test/t/partition_mgm.test7
-rw-r--r--mysql-test/t/partition_range.test25
-rw-r--r--mysql-test/t/ps_1general.test3
-rw-r--r--mysql-test/t/query_cache.test3
-rw-r--r--mysql-test/t/range.test2
-rw-r--r--mysql-test/t/renamedb.test8
-rw-r--r--mysql-test/t/replace.test10
-rw-r--r--mysql-test/t/rpl_auto_increment_11932.test63
-rw-r--r--mysql-test/t/rpl_ndb_auto_inc.test3
-rw-r--r--mysql-test/t/rpl_ndb_dd_partitions.test310
-rw-r--r--mysql-test/t/rpl_openssl.test4
-rw-r--r--mysql-test/t/rpl_rbr_to_sbr.test1
-rw-r--r--mysql-test/t/rpl_row_basic_11bugs.test18
-rw-r--r--mysql-test/t/rpl_row_basic_8partition.test1
-rw-r--r--mysql-test/t/rpl_row_create_table.test8
-rw-r--r--mysql-test/t/rpl_row_inexist_tbl-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_inexist_tbl.test14
-rw-r--r--mysql-test/t/rpl_sp_effects.test4
-rw-r--r--mysql-test/t/rpl_truncate_2myisam.test4
-rw-r--r--mysql-test/t/rpl_truncate_3innodb.test5
-rw-r--r--mysql-test/t/rpl_truncate_7ndb.test69
-rw-r--r--mysql-test/t/rpl_truncate_7ndb_2-master.opt1
-rw-r--r--mysql-test/t/rpl_truncate_7ndb_2.test6
-rw-r--r--mysql-test/t/select.test146
-rw-r--r--mysql-test/t/show_check.test19
-rw-r--r--mysql-test/t/sp-error.test6
-rw-r--r--mysql-test/t/sp-prelocking.test31
-rw-r--r--mysql-test/t/sp.test114
-rw-r--r--mysql-test/t/sql_mode.test3
-rw-r--r--mysql-test/t/status.test34
-rw-r--r--mysql-test/t/timezone2.test10
-rw-r--r--mysql-test/t/trigger-grant.test4
-rw-r--r--mysql-test/t/trigger.test40
-rw-r--r--mysql-test/t/type_datetime.test2
-rw-r--r--mysql-test/t/type_newdecimal.test8
-rw-r--r--mysql-test/t/type_ranges.test2
-rw-r--r--mysql-test/t/type_timestamp.test14
-rw-r--r--mysql-test/t/udf.test12
-rw-r--r--mysql-test/t/union.test48
-rw-r--r--mysql-test/t/view.test10
-rw-r--r--mysql-test/t/view_grant.test59
-rwxr-xr-xmysql-test/t/wait_for_process.sh66
-rw-r--r--mysql-test/t/wait_timeout.test1
-rw-r--r--mysql-test/t/xml.test13
107 files changed, 3735 insertions, 363 deletions
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index c89d31c69b9..294e7730e07 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -3,6 +3,7 @@
# Taken FROM the select test
#
-- source include/have_archive.inc
+-- source include/have_binlog_format_statement.inc
--disable_warnings
drop table if exists t1,t2,t3;
@@ -1330,12 +1331,14 @@ SELECT * FROM t2;
#
# For bug #12836
# Delete was allowing all rows to be removed
+--error 1031
DELETE FROM t2;
SELECT * FROM t2;
INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W');
INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring','');
INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
SELECT * FROM t2;
+--error 1031
TRUNCATE TABLE t2;
SELECT * FROM t2;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index e0b024d021b..2674639d0ac 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -238,6 +238,23 @@ SHOW CREATE TABLE `t1`;
DROP TABLE `t1`;
+#
+# Bug #6880: LAST_INSERT_ID() within a statement
+#
+
+create table t1(a int not null auto_increment primary key);
+create table t2(a int not null auto_increment primary key, t1a int);
+insert into t1 values(NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+select * from t2;
+drop table t1, t2;
+
--echo End of 4.1 tests
#
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index dbf5559943a..ebee341907c 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -1045,6 +1045,7 @@ commit;
alter table t1 add primary key(a);
drop table t1;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index dead9a7a0bc..0a112233ffb 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -110,3 +110,14 @@ SELECT convert(@str collate latin1_german2_ci using utf8);
SELECT convert(@str collate latin1_swedish_ci using utf8);
# End of 4.1 tests
+
+SET NAMES latin1;
+--disable_warnings
+DROP TABLE IF EXISTS `abcÿdef`;
+--enable_warnings
+CREATE TABLE `abcÿdef` (i int);
+INSERT INTO `abcÿdef` VALUES (1);
+INSERT INTO abcÿdef VALUES (2);
+SELECT * FROM `abcÿdef`;
+SELECT * FROM abcÿdef;
+DROP TABLE `abcÿdef`;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index c7662f4f85a..eea0b06b224 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -439,6 +439,32 @@ insert into t1 values('a');
create index t1f1 on t1(f1);
select f1 from t1 where f1 like 'a%';
drop table t1;
+
+#
+# Bug#9442 Set parameter make query fail if column character set is UCS2
+#
+create table t1 (utext varchar(20) character set ucs2);
+insert into t1 values ("lily");
+insert into t1 values ("river");
+prepare stmt from 'select utext from t1 where utext like ?';
+set @param1='%%';
+execute stmt using @param1;
+execute stmt using @param1;
+select utext from t1 where utext like '%%';
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
+# over a 'ucs2' field uses a temporary table
+#
+
+CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
+INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
+
+SELECT id, MIN(s) FROM t1 GROUP BY id;
+
+DROP TABLE t1;
# End of 4.1 tests
#
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 5ca1f58d233..77b76a14171 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -912,6 +912,120 @@ INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbb
check table t1;
drop table t1;
+#
+# Bug#14896: Comparison with a key in a partial index over mb chararacter field
+#
+
+SET NAMES utf8;
+CREATE TABLE t1 (id int PRIMARY KEY,
+ a varchar(16) collate utf8_unicode_ci NOT NULL default '',
+ b int,
+ f varchar(128) default 'XXX',
+ INDEX (a(4))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+ (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+ (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+ (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+ (10, 'eeeee', 40), (11, 'bbbbbb', 60);
+
+SELECT id, a, b FROM t1;
+
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+
+DROP TABLE t1;
+
+#
+# Bug#16674: LIKE predicate for a utf8 character set column
+#
+
+SET NAMES utf8;
+
+CREATE TABLE t1 (
+ a CHAR(13) DEFAULT '',
+ INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+INSERT INTO t1 VALUES
+ ('Käli Käli 2-4'), ('Käli Käli 2-4'),
+ ('Käli Käli 2+4'), ('Käli Käli 2+4'),
+ ('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+
+CREATE TABLE t2 (
+ a CHAR(13) DEFAULT '',
+ INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+INSERT INTO t2 VALUES
+ ('Kali Kali 2-4'), ('Kali Kali 2-4'),
+ ('Kali Kali 2+4'), ('Kali Kali 2+4'),
+ ('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+
+DROP TABLE t1,t2;
+
+CREATE TABLE t1 (
+ a char(255) DEFAULT '',
+ KEY(a(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a char(255) DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+DROP TABLE t1;
+
+#
+# Bug#18359: LIKE predicate for a 'utf8' text column with a partial index
+# (see bug #16674 as well)
+#
+
+SET NAMES latin2;
+
+CREATE TABLE t1 (
+ id int(11) NOT NULL default '0',
+ tid int(11) NOT NULL default '0',
+ val text NOT NULL,
+ INDEX idx(tid, val(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+INSERT INTO t1 VALUES
+ (40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'),
+ (41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'),
+ (41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'),
+ (42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'),
+ (42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL');
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL';
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL';
+SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL';
+
+ALTER TABLE t1 DROP KEY idx;
+ALTER TABLE t1 ADD KEY idx (tid,val(11));
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL';
+
+DROP TABLE t1;
# End of 4.1 tests
#
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index 5ae757b1fde..55e8f81f763 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -50,3 +50,52 @@ insert into t1 values (1);
insert delayed into t1 values (1);
select * from t1;
drop table t1;
+
+#
+# Bug #20195: INSERT DELAYED with auto_increment is assigned wrong values
+#
+CREATE TABLE t1 ( a int(10) NOT NULL auto_increment, PRIMARY KEY (a));
+
+# Make one delayed insert to start the separate thread
+insert delayed into t1 values(null);
+
+# Do some normal inserts
+insert into t1 values(null);
+insert into t1 values(null);
+
+# Discarded, since the delayed-counter is 2, which is already used
+insert delayed into t1 values(null);
+
+# Discarded, since the delayed-counter is 3, which is already used
+insert delayed into t1 values(null);
+
+# Works, since the delayed-counter is 4, which is unused
+insert delayed into t1 values(null);
+
+# Do some more inserts
+insert into t1 values(null);
+insert into t1 values(null);
+insert into t1 values(null);
+
+# Delete one of the above to make a hole
+delete from t1 where a=6;
+
+# Discarded, since the delayed-counter is 5, which is already used
+insert delayed into t1 values(null);
+
+# Works, since the delayed-counter is 6, which is unused (the row we deleted)
+insert delayed into t1 values(null);
+
+# Discarded, since the delayed-counter is 7, which is already used
+insert delayed into t1 values(null);
+
+# Works, since the delayed-counter is 8, which is unused
+insert delayed into t1 values(null);
+
+# Check what we have now
+# must wait so that the delayed thread finishes
+# Note: this must be increased if the test fails
+--sleep 1
+select * from t1 order by a;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 96f31133e65..6f26847f8d7 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -13,9 +13,9 @@
#events_stress : BUG#17619 2006-02-21 andrey Race conditions
#events : BUG#17619 2006-02-21 andrey Race conditions
#events_scheduling : BUG#19170 2006-04-26 andrey Test case of 19170 fails on some platforms. Has to be checked.
-im_instance_conf : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly
-im_options : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly
-im_life_cycle : Bug#20368 2006-06-10 alik im_life_cycle test fails
+#im_instance_conf : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly
+#im_options : Bug#20294 2006-06-06 monty Instance manager test im_instance_conf fails randomly
+#im_life_cycle : Bug#20368 2006-06-10 alik im_life_cycle test fails
ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
#ndb_binlog_discover : BUG#19395 2006-04-28 tomas/knielsen mysqld does not always detect cluster shutdown
@@ -26,7 +26,6 @@ partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when up
ps_7ndb : BUG#18950 2006-02-16 jmiller create table like does not obtain LOCK_open
rpl_ndb_2innodb : BUG#19227 2006-04-20 pekka pk delete apparently not replicated
rpl_ndb_2myisam : BUG#19227 Seems to pass currently
-rpl_ndb_auto_inc : BUG#17086 2006-02-16 jmiller CR: auto_increment_increment and auto_increment_offset produce duplicate key er
#rpl_ndb_commit_afterflush : BUG#19328 2006-05-04 tomas Slave timeout with COM_REGISTER_SLAVE error causing stop
rpl_ndb_dd_partitions : BUG#19259 2006-04-21 rpl_ndb_dd_partitions fails on s/AMD
rpl_ndb_ddl : BUG#18946 result file needs update + test needs to checked
@@ -36,8 +35,8 @@ rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fa
rpl_switch_stm_row_mixed : BUG#18590 2006-03-28 brian
rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly
rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed
-rpl_row_inexist_tbl : BUG#18948 2006-03-09 mats Disabled since patch makes this test wait forever
rpl_sp : BUG#16456 2006-02-16 jmiller
+rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index 09f07c2852f..61250a7105e 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -349,6 +349,34 @@ SELECT DISTINCT 2, a, b FROM t2;
SELECT DISTINCT a, 2, b FROM t2;
DROP TABLE t1,t2;
+#
+# Bug#16458: Simple SELECT FOR UPDATE causes "Result Set not updatable"
+# error.
+#
+CREATE TABLE t1(a INT PRIMARY KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1);
+EXPLAIN SELECT DISTINCT a FROM t1;
+EXPLAIN SELECT DISTINCT a,b FROM t1;
+EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2;
+EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2
+ WHERE t1_1.a = t1_2.a;
+EXPLAIN SELECT a FROM t1 GROUP BY a;
+EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
+EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
+
+CREATE TABLE t2(a INT, b INT, c INT, d INT, PRIMARY KEY (a,b));
+INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
+EXPLAIN SELECT DISTINCT a FROM t2;
+EXPLAIN SELECT DISTINCT a,a FROM t2;
+EXPLAIN SELECT DISTINCT b,a FROM t2;
+EXPLAIN SELECT DISTINCT a,c FROM t2;
+EXPLAIN SELECT DISTINCT c,a,b FROM t2;
+
+EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
+CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
+EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
+
+DROP TABLE t1,t2;
# Bug 9784 DISTINCT IFNULL truncates data
#
diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test
index a3e2bbc0998..aac13a55dd3 100644
--- a/mysql-test/t/events.test
+++ b/mysql-test/t/events.test
@@ -1,3 +1,6 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
create database if not exists events_test;
use events_test;
@@ -327,15 +330,15 @@ on schedule every 10 hour
disable
do
select 1;
-select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
drop event white_space;
create event white_space on schedule every 10 hour disable do
select 2;
-select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
drop event white_space;
create event white_space on schedule every 10 hour disable do select 3;
-select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space';
drop event white_space;
#
# END: BUG #17453: Creating Event crash the server
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index e3b79a6bd13..9434de7be7d 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -1,3 +1,6 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
create database if not exists events_test;
use events_test;
@@ -172,4 +175,38 @@ set sql_mode=@old_sql_mode;
#
# End - 16407: Events: Changes in sql_mode won't be taken into account
#
+
+#
+# START - 18897: Events: unauthorized action possible with alter event rename
+#
+set global event_scheduler=2;
+--disable_warnings
+delete from mysql.user where User like 'mysqltest_%';
+delete from mysql.db where User like 'mysqltest_%';
+flush privileges;
+drop database if exists mysqltest_db1;
+--enable_warnings
+create user mysqltest_user1@localhost;
+create database mysqltest_db1;
+grant event on events_test.* to mysqltest_user1@localhost;
+connect (conn2,localhost,mysqltest_user1,,events_test);
+create event mysqltest_user1 on schedule every 10 second do select 42;
+--error ER_DBACCESS_DENIED_ERROR
+alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1;
+--echo "Let's test now rename when there is no select DB"
+disconnect conn2;
+connect (conn2,localhost,mysqltest_user1,,*NO-ONE*);
+select database();
+--error ER_NO_DB_ERROR
+alter event events_test.mysqltest_user1 rename to mysqltest_user1;
+select event_schema, event_name, definer, event_type, status from information_schema.events;
+drop event events_test.mysqltest_user1;
+disconnect conn2;
+connection default;
+drop user mysqltest_user1@localhost;
+drop database mysqltest_db1;
+#
+# END - 18897: Events: unauthorized action possible with alter event rename
+#
+
drop database events_test;
diff --git a/mysql-test/t/events_grant.test b/mysql-test/t/events_grant.test
index ba94944a3cf..3ead141c27c 100644
--- a/mysql-test/t/events_grant.test
+++ b/mysql-test/t/events_grant.test
@@ -1,3 +1,6 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
CREATE DATABASE IF NOT EXISTS events_test;
use events_test;
#
@@ -6,7 +9,7 @@ use events_test;
CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
--replace_column 8 # 9 #
SHOW EVENTS;
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
CREATE DATABASE events_test2;
CREATE USER ev_test@localhost;
GRANT ALL ON events_test.* to ev_test@localhost;
@@ -52,10 +55,10 @@ CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
connection default;
USE events_test;
--echo "We should see 4 events : one_event, two_event, three_event & four_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
DROP DATABASE events_test2;
--echo "We should see 3 events : one_event, two_event, three_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
connection default;
CREATE DATABASE events_test2;
@@ -64,27 +67,27 @@ CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
connection ev_con1;
--echo "Should see 4 events - one, two, three & five"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
connection default;
REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
connection ev_con1;
USE test;
--echo "Should see 3 events - one, two & three"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
--echo "Let's test ALTER EVENT which changes the definer"
USE events_test;
ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
--echo "The definer should be ev_test@localhost"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
connection default;
USE events_test;
ALTER EVENT one_event COMMENT "comment";
connection ev_con1;
--echo "The definer should be root@localhost"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
ALTER EVENT one_event DO SELECT 12;
--echo "The definer should be ev_test@localhost"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
connection default;
--echo "make the definer again root@localhost"
ALTER EVENT one_event COMMENT "new comment";
@@ -93,7 +96,7 @@ connection ev_con1;
DROP EVENT one_event;
connection default;
--echo "One event should not be there"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
disconnect ev_con1;
connection default;
DROP USER ev_test@localhost;
diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test
index 6d3b3292630..5f4ec852cd3 100644
--- a/mysql-test/t/events_logs_tests.test
+++ b/mysql-test/t/events_logs_tests.test
@@ -1,3 +1,6 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
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"
@@ -51,6 +54,8 @@ 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;
+--echo "Make it quite long"
+SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
--replace_column 1 USER_HOST
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
@@ -61,7 +66,10 @@ SET SESSION long_query_time=1;
SELECT SLEEP(2);
--replace_column 1 USER_HOST 2 SLEEPVAL
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+SET SESSION long_query_time=300;
+--echo "Make it quite long"
TRUNCATE mysql.slow_log;
+SET SESSION long_query_time=1;
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);
@@ -75,9 +83,9 @@ 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"
+DROP EVENT long_event;
SET SESSION long_query_time=10;
SET GLOBAL long_query_time=1;
-DROP EVENT long_event;
CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2);
--echo "Sleep some more time than the actual event run will take"
--sleep 3
@@ -87,9 +95,11 @@ SELECT * FROM slow_event_test;
--replace_column 1 USER_HOST 2 SLEEPVAL
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;
+--echo "Make it quite long"
+SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;
+SET GLOBAL long_query_time =@old_global_long_query_time;
+SET SESSION long_query_time =@old_session_long_query_time;
drop database events_test;
diff --git a/mysql-test/t/events_microsec.test b/mysql-test/t/events_microsec.test
index e01120a0756..3e9abf6ec56 100644
--- a/mysql-test/t/events_microsec.test
+++ b/mysql-test/t/events_microsec.test
@@ -1,4 +1,10 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
+--disable_warnings
create database if not exists events_test;
+--enable_warnings
+
use events_test;
--error ER_NOT_SUPPORTED_YET
diff --git a/mysql-test/t/events_scheduling.test b/mysql-test/t/events_scheduling.test
index c688864a1e6..987939bc162 100644
--- a/mysql-test/t/events_scheduling.test
+++ b/mysql-test/t/events_scheduling.test
@@ -1,3 +1,6 @@
+# Can't test with embedded server that doesn't support grants
+-- source include/not_embedded.inc
+
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
CREATE TABLE table_1(a int);
diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test
index 8d0034c232e..6546bce3a76 100644
--- a/mysql-test/t/events_stress.test
+++ b/mysql-test/t/events_stress.test
@@ -1,9 +1,17 @@
+# Can't test with embedded server that doesn't support grants
+--source include/not_embedded.inc
+--source include/big_test.inc
+
CREATE DATABASE IF NOT EXISTS events_test;
#
# DROP DATABASE test start (bug #16406)
#
CREATE DATABASE events_conn1_test2;
-CREATE TABLE events_test.fill_it(test_name varchar(20), occur datetime);
+# BUG#20676: MySQL in debug mode has a limit of 100 waiters
+# (in mysys/thr_lock.c), so use three different tables to insert into.
+CREATE TABLE events_test.fill_it1(test_name varchar(20), occur datetime);
+CREATE TABLE events_test.fill_it2(test_name varchar(20), occur datetime);
+CREATE TABLE events_test.fill_it3(test_name varchar(20), occur datetime);
CREATE USER event_user2@localhost;
CREATE DATABASE events_conn2_db;
GRANT ALL ON *.* TO event_user2@localhost;
@@ -16,7 +24,7 @@ connect (conn2,localhost,event_user2,,events_conn2_db);
let $1= 50;
while ($1)
{
- eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn2_ev$1", NOW());
+ eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn2_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -26,7 +34,7 @@ connect (conn3,localhost,event_user3,,events_conn3_db);
let $1= 50;
while ($1)
{
- eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn3_ev$1", NOW());
+ eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn3_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -48,7 +56,7 @@ USE events_conn1_test2;
let $1= 50;
while ($1)
{
- eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round1_ev$1", NOW());
+ eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round1_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -65,7 +73,7 @@ USE events_conn1_test3;
let $1= 50;
while ($1)
{
- eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round2_ev$1", NOW());
+ eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round2_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -77,7 +85,7 @@ USE events_conn1_test4;
let $1= 50;
while ($1)
{
- eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round3_ev$1", NOW());
+ eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round3_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -88,7 +96,7 @@ USE events_conn1_test2;
let $1= 50;
while ($1)
{
- eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round4_ev$1", NOW());
+ eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round4_ev$1", NOW());
dec $1;
}
--enable_query_log
@@ -115,7 +123,9 @@ reap;
disconnect conn3;
connection default;
USE events_test;
-DROP TABLE fill_it;
+DROP TABLE fill_it1;
+DROP TABLE fill_it2;
+DROP TABLE fill_it3;
--disable_query_log
DROP USER event_user2@localhost;
DROP USER event_user3@localhost;
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index f6799f3630a..5f5c8d44f35 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -83,7 +83,7 @@ eval SHOW CREATE TABLE federated.t2;
INSERT INTO federated.t2 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t2 (id, name) VALUES (2, 'fee');
-SELECT * FROM federated.t2;
+SELECT * FROM federated.t2 ORDER BY id, name;
DROP TABLE federated.t2;
connection slave;
@@ -110,7 +110,7 @@ eval CREATE TABLE federated.t1 (
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'fee');
-SELECT * FROM federated.t1;
+SELECT * FROM federated.t1 ORDER BY id,name;
DELETE FROM federated.t1;
DROP TABLE IF EXISTS federated.t1;
@@ -125,7 +125,7 @@ eval CREATE TABLE federated.`t1%` (
INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo');
INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee');
-SELECT * FROM federated.`t1%`;
+SELECT * FROM federated.`t1%` ORDER BY id, name;
DELETE FROM federated.`t1%`;
DROP TABLE IF EXISTS federated.`t1%`;
diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test
index fd97f795534..88967a5dd04 100644
--- a/mysql-test/t/fulltext2.test
+++ b/mysql-test/t/fulltext2.test
@@ -221,3 +221,13 @@ drop table t1;
set names latin1;
# End of 4.1 tests
+
+#
+# BUG#19580 - FULLTEXT search produces wrong results on UTF-8 columns
+#
+SET NAMES utf8;
+CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+INSERT INTO t1 VALUES('„MySQL“');
+SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE);
+DROP TABLE t1;
+SET NAMES latin1;
diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test
index 3bb1f0b7309..7c22f49ed8c 100644
--- a/mysql-test/t/fulltext_left_join.test
+++ b/mysql-test/t/fulltext_left_join.test
@@ -32,7 +32,7 @@ select match(t1.texte,t1.sujet,t1.motsclefs) against('droit' IN BOOLEAN MODE)
drop table t1, t2;
#
-# Bug #484, reported by Stephen Brandon <stephen@brandonitconsulting.co.uk>
+# BUG#484, reported by Stephen Brandon <stephen@brandonitconsulting.co.uk>
#
create table t1 (venue_id int(11) default null, venue_text varchar(255) default null, dt datetime default null) engine=myisam;
@@ -45,4 +45,17 @@ select * from t1 left join t2 on (venue_id = entity_id and match(name) against('
select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00';
drop table t1,t2;
+#
+# BUG#14708
+# Inconsistent treatment of NULLs in LEFT JOINed FULLTEXT matching without index
+#
+
+create table t1 (id int not null primary key, d char(200) not null, e char(200));
+insert into t1 values (1, 'aword', null), (2, 'aword', 'bword'), (3, 'bword', null), (4, 'bword', 'aword'), (5, 'aword and bword', null);
+select * from t1 where match(d, e) against ('+aword +bword' in boolean mode);
+create table t2 (m_id int not null, f char(200), key (m_id));
+insert into t2 values (1, 'bword'), (3, 'aword'), (5, '');
+select * from t1 left join t2 on m_id = id where match(d, e, f) against ('+aword +bword' in boolean mode);
+drop table t1,t2;
+
# End of 4.1 tests
diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test
index 37fc0e105b8..5487ad9c56b 100644
--- a/mysql-test/t/func_concat.test
+++ b/mysql-test/t/func_concat.test
@@ -52,4 +52,19 @@ select 'a' union select concat('a', -0.0);
--replace_result a-0.0000 a0.0000
select 'a' union select concat('a', -0.0000);
+#
+# Bug#16716: subselect in concat() may lead to a wrong result
+#
+select concat((select x from (select 'a' as x) as t1 ),
+ (select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
+ as t3;
+
# End of 4.1 tests
+
+#
+# Bug#15962: CONCAT() in UNION may lead to a data trucation.
+#
+create table t1(f1 varchar(6)) charset=utf8;
+insert into t1 values ("123456");
+select concat(f1, 2) a from t1 union select 'x' a from t1;
+drop table t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index eacc4fc6710..760745dc14e 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -546,6 +546,34 @@ DROP TABLE t1;
# Bug #12882 min/max inconsistent on empty table
#
# Test case moved to func_group_innodb
+#
+# Bug #18206: min/max optimization cannot be applied to partial index
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b));
+INSERT INTO t1 VALUES (1,'xx'), (2,'aa');
+SELECT * FROM t1;
+
+SELECT MAX(b) FROM t1 WHERE b < 'ppppp';
+SHOW WARNINGS;
+SELECT MAX(b) FROM t1 WHERE b < 'pp';
+DROP TABLE t1;
+
+CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4)));
+INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa');
+SELECT MAX(b) FROM t1;
+EXPLAIN SELECT MAX(b) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (id int , b varchar(512), INDEX(b(250))) COLLATE latin1_bin;
+INSERT INTO t1 VALUES
+ (1,CONCAT(REPEAT('_', 250), "qq")), (1,CONCAT(REPEAT('_', 250), "zz")),
+ (1,CONCAT(REPEAT('_', 250), "aa")), (1,CONCAT(REPEAT('_', 250), "ff"));
+
+SELECT MAX(b) FROM t1;
+EXPLAIN SELECT MAX(b) FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests
#
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 7f809dbc4a1..b13fe039261 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -673,6 +673,18 @@ drop table t1;
select load_file("lkjlkj");
select ifnull(load_file("lkjlkj"),"it's null");
+#
+# Bug#15351: Wrong collation used for comparison of md5() and sha()
+# parameter can lead to a wrong result.
+#
+create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2));
+insert into t1 values ( 'test',md5('test')), ('test', sha('test'));
+select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST"));
+select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test"));
+select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
+select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
+drop table t1;
+
--echo End of 4.1 tests
#
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index e6c1ddfcf1f..7428ac45422 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -5,6 +5,9 @@
drop table if exists t1,t2,t3;
--enable_warnings
+# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
+set time_zone="+03:00";
+
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
select period_add("9602",-12),period_diff(199505,"9404") ;
@@ -335,6 +338,7 @@ select last_day("1997-12-1")+0.0;
# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
# TZ variable set to GMT-3
+
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
@@ -367,6 +371,36 @@ select last_day('2005-01-00');
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
+#
+# Bug#16377 result of DATE/TIME functions were compared as strings which
+# can lead to a wrong result.
+#
+create table t1(f1 date, f2 time, f3 datetime);
+insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
+insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
+select f1 from t1 where f1 between "2006-1-1" and 20060101;
+select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
+select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
+select f2 from t1 where f2 between "12:1:2" and "12:2:2";
+select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
+select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f1 from t1 where "2006-1-1" between f1 and f3;
+select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
+select f1 from t1 where "2006-1-1" between f1 and 'zzz';
+select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
+select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
+drop table t1;
+
+#
+# Bug #16546
+#
+
+create table t1 select now() - now(), curtime() - curtime(),
+ sec_to_time(1) + 0, from_unixtime(1) + 0;
+show create table t1;
+drop table t1;
+
--echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
@@ -475,6 +509,9 @@ SELECT * FROM t1, t2
DROP TABLE t1,t2;
+
+# Restore timezone to default
+set time_zone= @@global.time_zone;
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test
index e1bb7e878ee..05a91b06d28 100644
--- a/mysql-test/t/func_timestamp.test
+++ b/mysql-test/t/func_timestamp.test
@@ -6,6 +6,9 @@
drop table if exists t1;
--enable_warnings
+# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
+set time_zone="+03:00";
+
create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null,
Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998);
@@ -15,3 +18,6 @@ FROM t1;
drop table t1;
# End of 4.1 tests
+
+# Restore timezone to default
+set time_zone= @@global.time_zone;
diff --git a/mysql-test/t/im_cmd_line.imtest b/mysql-test/t/im_cmd_line.imtest
index 00e8351535e..29ed420439d 100644
--- a/mysql-test/t/im_cmd_line.imtest
+++ b/mysql-test/t/im_cmd_line.imtest
@@ -26,7 +26,7 @@
--echo
--echo --> Printing out line for 'testuser'...
---exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=abc | tail -1
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=abc | tail -1
--echo
--echo --> Listing users...
@@ -45,7 +45,7 @@
--echo
--echo --> Printing out line for 'testuser'...
---exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=xyz | tail -1
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=xyz | tail -1
--echo
--echo --> Listing users...
diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest
index d173ce2a6e2..3afc36935f8 100644
--- a/mysql-test/t/im_daemon_life_cycle.imtest
+++ b/mysql-test/t/im_daemon_life_cycle.imtest
@@ -10,9 +10,22 @@
###########################################################################
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
--sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
SHOW INSTANCES;
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted
+###########################################################################
+
+# Kill the IM main process and check that the IM Angel will restart the main
+# process.
+
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
diff --git a/mysql-test/t/im_instance_conf.imtest b/mysql-test/t/im_instance_conf.imtest
index 17703fdd303..3d254b16ca5 100644
--- a/mysql-test/t/im_instance_conf.imtest
+++ b/mysql-test/t/im_instance_conf.imtest
@@ -21,6 +21,9 @@
# - DROP INSTANCE fails for active instance.
# - DROP INSTANCE updates both config file and internal configuration cache;
#
+# NOTE: each CREATE INSTANCE statement must specify socket-file-name, otherwise
+# this results of the test can be affected by another running test suite.
+#
###########################################################################
--source include/im_check_os.inc
@@ -69,7 +72,9 @@ SHOW VARIABLES LIKE 'server_id';
# Check that CREATE INSTANCE succeeds for non-existing instance and also check
# that both config file and internal configuration cache have been updated.
-CREATE INSTANCE mysqld3;
+CREATE INSTANCE mysqld3
+ server_id = 3,
+ socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
SHOW INSTANCES;
@@ -99,7 +104,10 @@ CREATE INSTANCE mysqld3;
--exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
-CREATE INSTANCE mysqld4 nonguarded;
+CREATE INSTANCE mysqld4
+ nonguarded,
+ server_id = 4,
+ socket = "$MYSQL_TMP_DIR/mysqld_4.sock";
SHOW INSTANCES;
@@ -115,7 +123,11 @@ SHOW INSTANCES;
--exec grep test-B $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
-CREATE INSTANCE mysqld5 test-A = 000, test-B = test;
+CREATE INSTANCE mysqld5
+ test-A = 000,
+ test-B = test,
+ server_id = 5,
+ socket = "$MYSQL_TMP_DIR/mysqld_5.sock";
SHOW INSTANCES;
@@ -135,7 +147,11 @@ SHOW INSTANCES;
--exec grep test-C $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
-CREATE INSTANCE mysqld6 test-C1 = 10 , test-C2 = 02 ;
+CREATE INSTANCE mysqld6
+ test-C1 = 10 ,
+ test-C2 = 02 ,
+ server_id = 6,
+ socket = "$MYSQL_TMP_DIR/mysqld_6.sock";
SHOW INSTANCES;
@@ -183,22 +199,37 @@ SHOW INSTANCES;
--exec grep test-4 $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
-CREATE INSTANCE mysqld9 test-1=" hello world ", test-2=' ';
+CREATE INSTANCE mysqld9
+ test-1=" hello world ",
+ test-2=' ',
+ server_id = 9,
+ socket = "$MYSQL_TMP_DIR/mysqld_9.sock";
SHOW INSTANCES;
-CREATE INSTANCE mysqld9a test-3='\b\babc\sdef';
+CREATE INSTANCE mysqld10
+ test-3='\b\babc\sdef',
+ server_id = 10,
+ socket = "$MYSQL_TMP_DIR/mysqld_10.sock";
# test-3='abc def'
SHOW INSTANCES;
-CREATE INSTANCE mysqld9b test-4='abc\tdef', test-5='abc\ndef';
+CREATE INSTANCE mysqld11
+ test-4='abc\tdef',
+ test-5='abc\ndef',
+ server_id = 11,
+ socket = "$MYSQL_TMP_DIR/mysqld_11.sock";
SHOW INSTANCES;
-CREATE INSTANCE mysqld9c test-6="abc\rdef", test-7="abc\\def";
+CREATE INSTANCE mysqld12
+ test-6="abc\rdef",
+ test-7="abc\\def",
+ server_id = 12,
+ socket = "$MYSQL_TMP_DIR/mysqld_12.sock";
# test-6=abc
SHOW INSTANCES;
--error ER_SYNTAX_ERROR
-CREATE INSTANCE mysqld10 test-bad=' \ ';
+CREATE INSTANCE mysqld13 test-bad=' \ ';
SHOW INSTANCES;
--echo --------------------------------------------------------------------
diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest
index d71cdc86624..2cbe53a7b28 100644
--- a/mysql-test/t/im_life_cycle.imtest
+++ b/mysql-test/t/im_life_cycle.imtest
@@ -22,8 +22,16 @@
--echo -- 1.1.1.
--echo --------------------------------------------------------------------
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
--sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
SHOW INSTANCES;
@@ -44,10 +52,12 @@ SHOW INSTANCES;
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
-SHOW INSTANCES;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
--connection mysql_con
@@ -74,14 +84,12 @@ SHOW VARIABLES LIKE 'port';
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to stop instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
-SHOW INSTANCES;
---replace_column 3 VERSION_NUMBER 4 VERSION
-SHOW INSTANCE STATUS mysqld1;
---replace_column 3 VERSION_NUMBER 4 VERSION
-SHOW INSTANCE STATUS mysqld2;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
###########################################################################
#
@@ -140,10 +148,14 @@ STOP INSTANCE mysqld3;
SHOW INSTANCES;
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
+
+# Give some time to IM to detect that mysqld was restarted. It should be longer
+# than monitoring interval.
--sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+SHOW INSTANCES;
###########################################################################
#
@@ -156,18 +168,21 @@ SHOW INSTANCES;
--echo -- 1.1.7.
--echo --------------------------------------------------------------------
-SHOW INSTANCES;
-
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
-SHOW INSTANCES;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
-SHOW INSTANCES;
+# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
+# synchronous. Even waiting for mysqld to start by looking at its pid file is
+# not enough, because IM may not detect that mysqld has started.
+# SHOW INSTANCES;
###########################################################################
#
diff --git a/mysql-test/t/im_options.imtest b/mysql-test/t/im_options.imtest
index cd905416cda..55bd29c9ee1 100644
--- a/mysql-test/t/im_options.imtest
+++ b/mysql-test/t/im_options.imtest
@@ -21,12 +21,15 @@
# - server_id
# - port
# - nonguarded
-
+#
# Let's test SET statement on the option 'server_id'. It's expected that
# originally the instances have the following server ids and states:
# - mysqld1: server_id: 1; running (online)
# - mysqld2: server_id: 2; stopped (offline)
#
+# NOTE: each CREATE INSTANCE statement must specify socket-file-name, otherwise
+# this results of the test can be affected by another running test suite.
+#
###########################################################################
--source include/im_check_os.inc
@@ -76,7 +79,10 @@ SET mysqld1.server_id = 11;
# - start it;
# - try to set/unset options;
-CREATE INSTANCE mysqld3 datadir = '/';
+CREATE INSTANCE mysqld3
+ datadir = '/',
+ server_id = 3,
+ socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
START INSTANCE mysqld3;
# FIXME: START INSTANCE should be synchronous.
diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest
index 8e8d475cfee..47902eeba52 100644
--- a/mysql-test/t/im_utils.imtest
+++ b/mysql-test/t/im_utils.imtest
@@ -17,8 +17,16 @@
# - the second instance is offline;
#
+# Wait for mysqld1 (guarded instance) to start.
+
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
--sleep 3
-# should be longer than monitoring interval and enough to start instance.
+
+# Check that start conditions are as expected.
SHOW INSTANCES;
@@ -43,12 +51,10 @@ SHOW INSTANCE OPTIONS mysqld2;
#
START INSTANCE mysqld2;
-
-# FIXME: START INSTANCE should be synchronous.
---sleep 3
-# should be longer than monitoring interval and enough to start instance.
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
STOP INSTANCE mysqld2;
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
#
# Check 'SHOW LOG FILES' command:
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index acb877e1e74..73aea01dfa2 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -80,6 +80,8 @@ connect (user4,localhost,mysqltest_3,,mysqltest);
connection user4;
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 'v1';
+--error 1345
+explain select * from v1;
connection default;
drop view v1, mysqltest.v1;
@@ -580,28 +582,32 @@ connect (con2,localhost,user2,,mysqltest);
connect (con3,localhost,user3,,mysqltest);
connect (con4,localhost,user4,,);
connection con1;
-select * from information_schema.column_privileges;
-select * from information_schema.table_privileges;
-select * from information_schema.schema_privileges;
-select * from information_schema.user_privileges;
+select * from information_schema.column_privileges order by grantee;
+select * from information_schema.table_privileges order by grantee;
+select * from information_schema.schema_privileges order by grantee;
+select * from information_schema.user_privileges order by grantee;
show grants;
connection con2;
-select * from information_schema.column_privileges;
-select * from information_schema.table_privileges;
-select * from information_schema.schema_privileges;
-select * from information_schema.user_privileges;
+select * from information_schema.column_privileges order by grantee;
+select * from information_schema.table_privileges order by grantee;
+select * from information_schema.schema_privileges order by grantee;
+select * from information_schema.user_privileges order by grantee;
show grants;
connection con3;
-select * from information_schema.column_privileges;
-select * from information_schema.table_privileges;
-select * from information_schema.schema_privileges;
-select * from information_schema.user_privileges;
+select * from information_schema.column_privileges order by grantee;
+select * from information_schema.table_privileges order by grantee;
+select * from information_schema.schema_privileges order by grantee;
+select * from information_schema.user_privileges order by grantee;
show grants;
connection con4;
-select * from information_schema.column_privileges where grantee like '%user%';
-select * from information_schema.table_privileges where grantee like '%user%';
-select * from information_schema.schema_privileges where grantee like '%user%';
-select * from information_schema.user_privileges where grantee like '%user%';
+select * from information_schema.column_privileges where grantee like '%user%'
+order by grantee;
+select * from information_schema.table_privileges where grantee like '%user%'
+order by grantee;
+select * from information_schema.schema_privileges where grantee like '%user%'
+order by grantee;
+select * from information_schema.user_privileges where grantee like '%user%'
+order by grantee;
show grants;
connection default;
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
@@ -825,25 +831,6 @@ delete from proc where name='';
use test;
#
-# End of 5.0 tests.
-#
-# Show engines
-#
-
-select * from information_schema.engines WHERE ENGINE="MyISAM";
-
-#
-# INFORMATION_SCHEMA.PROCESSLIST
-#
-
-grant select on *.* to user3148@localhost;
-connect (con3148,localhost,user3148,,test);
-connection con3148;
-select user,db from information_schema.processlist;
-connection default;
-drop user user3148@localhost;
-
-#
# Bug#16681 information_schema shows forbidden VIEW details
#
grant select on test.* to mysqltest_1@localhost;
@@ -862,3 +849,31 @@ drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
+#
+# Bug#19599 duplication of information_schema column value in a CONCAT expr with user var
+#
+set @a:= '.';
+create table t1(f1 char(5));
+create table t2(f1 char(5));
+select concat(@a, table_name), @a, table_name
+from information_schema.tables where table_schema = 'test';
+drop table t1,t2;
+
+# End of 5.0 tests.
+#
+# Show engines
+#
+
+select * from information_schema.engines WHERE ENGINE="MyISAM";
+
+#
+# INFORMATION_SCHEMA.PROCESSLIST
+#
+
+grant select on *.* to user3148@localhost;
+connect (con3148,localhost,user3148,,test);
+connection con3148;
+select user,db from information_schema.processlist;
+connection default;
+drop user user3148@localhost;
+
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 92e060eed92..5b1b374e487 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -2510,3 +2510,16 @@ BEGIN;
INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1;
DROP TABLE t1;
+
+#######################################################################
+# #
+# Please, DO NOT TOUCH this file as well as the innodb.result file. #
+# These files are to be modified ONLY BY INNOBASE guys. #
+# #
+# Use innodb_mysql.[test|result] files instead. #
+# #
+# If nevertheless you need to make some changes here, please, forward #
+# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
+# (otherwise your changes may be erased). #
+# #
+#######################################################################
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index bea2d3bc8e0..6796840f2d2 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -4,6 +4,14 @@
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
--enable_warnings
+#
+# 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;
+
# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer
# (repeatable only w/innodb).
create table t1 (
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index e2514083ea7..3711e2986ed 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -201,3 +201,36 @@ insert into t1 (b,b) select 1,2;
--error 1110
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
drop table t1;
+# Test for INSERT DELAYED INTO a <view>
+# BUG#13683: INSERT DELAYED into a view creates an infinite loop
+#
+
+create table t1 (n int);
+create view v1 as select * from t1;
+--error 1347
+insert delayed into v1 values (1);
+drop table t1;
+drop view v1;
+
+#
+# Test for values returned by ROW_COUNT() function
+# (and thus for values returned by mysql_affected_rows())
+# for various forms of INSERT
+#
+create table t1 (id int primary key, data int);
+insert into t1 values (1, 1), (2, 2), (3, 3);
+select row_count();
+insert ignore into t1 values (1, 1);
+select row_count();
+# Reports that 2 rows are affected (1 deleted + 1 inserted)
+replace into t1 values (1, 11);
+select row_count();
+replace into t1 values (4, 4);
+select row_count();
+# Reports that 2 rows are affected. This conforms to documentation.
+# (Useful for differentiating inserts from updates).
+insert into t1 values (2, 2) on duplicate key update data= data + 10;
+select row_count();
+insert into t1 values (5, 5) on duplicate key update data= data + 10;
+select row_count();
+drop table t1;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 5dd6f338865..05953a1fd49 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -224,4 +224,26 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
drop table t1,t2;
+#
+# Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
+# tables
+#
+
+#Note: not an exsaustive test : just a check of the code path.
+CREATE TABLE t1 (a int PRIMARY KEY);
+INSERT INTO t1 values (1), (2);
+
+INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+
+DROP TABLE t1;
+
# End of 4.1 tests
+
+#
+# Bug #18080: INSERT ... SELECT ... JOIN results in ambiguous field list error
+#
+CREATE TABLE t1 (x int, y int);
+CREATE TABLE t2 (z int, y int);
+CREATE TABLE t3 (a int, b int);
+INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
+DROP TABLE IF EXISTS t1,t2,t3;
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index f6a57d5e230..e156ccd82a8 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -520,6 +520,7 @@ select * from v1a join v1b on t1.b = t2.b;
#
# Bug #17523 natural join and information_schema
#
+--replace_column 31 #
select * from information_schema.statistics join information_schema.columns
using(table_name,column_name) where table_name='user';
@@ -563,4 +564,29 @@ select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4;
drop table t1,t2,t3,t4;
+#
+# BUG#15355: Common natural join column not resolved in prepared statement nested query
+#
+create table t1 (c int, b int);
+create table t2 (a int, b int);
+create table t3 (b int, c int);
+create table t4 (y int, c int);
+create table t5 (y int, z int);
+
+insert into t1 values (3,2);
+insert into t2 values (1,2);
+insert into t3 values (2,3);
+insert into t4 values (1,3);
+insert into t5 values (1,4);
+
+-- this fails
+prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2))
+natural join t4) natural join t5";
+execute stmt1;
+
+-- this works
+select * from ((t3 natural join (t1 natural join t2)) natural join t4)
+ natural join t5;
+drop table t1, t2, t3, t4, t5;
+
# End of tests for WL#2486 - natural/using join
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index f95cee8e8eb..7c6b38cb871 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -326,6 +326,18 @@ alter table t1 add key (c1,c1,c2);
drop table t1;
#
+# Bug#11228: DESC shows arbitrary column as "PRI"
+#
+create table t1 (
+ i1 INT NOT NULL,
+ i2 INT NOT NULL,
+ UNIQUE i1idx (i1),
+ UNIQUE i2idx (i2));
+desc t1;
+show create table t1;
+drop table t1;
+
+#
# Bug#12565 - ERROR 1034 when running simple UPDATE or DELETE
# on large MyISAM table
#
diff --git a/mysql-test/t/kill_n_check.sh b/mysql-test/t/kill_n_check.sh
index e722b3a180d..64cc869d1ec 100755
--- a/mysql-test/t/kill_n_check.sh
+++ b/mysql-test/t/kill_n_check.sh
@@ -1,66 +1,115 @@
#!/bin/sh
-if [ $# -ne 2 ]; then
- echo "Usage: kill_n_check.sh <pid file path> killed|restarted"
+###########################################################################
+
+# NOTE: this script returns 0 (success) even in case of failure. This is
+# because this script is executed under mysql-test-run[.pl] and it's better to
+# examine particular problem in log file, than just having said that the test
+# case has failed.
+
+###########################################################################
+
+check_restart()
+{
+ if [ ! -r "$pid_path" ]; then
+ user_msg='the process was killed'
+ return 1
+ fi
+
+ new_pid=`cat "$pid_path" 2>/dev/null`
+
+ if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then
+ user_msg='the process was not restarted'
+ return 1
+ fi
+
+ user_msg='the process was restarted'
+ return 0
+}
+
+###########################################################################
+
+if [ $# -ne 3 ]; then
+ echo "Usage: kill_n_check.sh <pid file path> killed|restarted <timeout>"
exit 0
fi
pid_path="$1"
expected_result="$2"
+total_timeout="$3"
-if [ -z "$pid_path" -o ! -r "$pid_path" ]; then
- echo "Error: invalid PID path ($pid_path) or PID file does not exist."
+if [ "$expected_result" != 'killed' -a \
+ "$expected_result" != 'restarted' ]; then
+ echo "Error: invalid second argument ('killed' or 'restarted' expected)."
exit 0
fi
-if [ "$expected_result" != "killed" -a \
- "$expected_result" != "restarted" ]; then
- echo "Error: expected result must be either 'killed' or 'restarted'."
+if [ -z "$pid_path" ]; then
+ echo "Error: invalid PID path ($pid_path)."
exit 0
fi
-# echo "PID path: '$pid_path'"
+if [ $expected_result = 'killed' -a ! -r "$pid_path" ]; then
+ echo "Error: PID file ($pid_path) does not exist."
+ exit 0
+fi
-original_pid=`cat "$pid_path"`
+if [ -z "$total_timeout" ]; then
+ echo "Error: timeout is not specified."
+ exit 0
+fi
-# echo "Original PID: $original_pid"
+###########################################################################
+
+original_pid=`cat "$pid_path"`
echo "Killing the process..."
kill -9 $original_pid
+###########################################################################
+
echo "Sleeping..."
-sleep 3
+if [ "$expected_result" = "restarted" ]; then
-new_pid=""
+ # Wait for the process to restart.
-[ -r "$pid_path" ] && new_pid=`cat "$pid_path"`
+ cur_attempt=1
-# echo "New PID: $new_pid"
+ while true; do
-if [ "$expected_result" = "restarted" ]; then
+ if check_restart; then
+ echo "Success: $user_msg."
+ exit 0
+ fi
- if [ -z "$new_pid" ]; then
- echo "Error: the process was killed."
- exit 0
- fi
+ [ $cur_attempt -ge $total_timeout ] && break
- if [ "$original_pid" -eq "$new_pid" ]; then
- echo "Error: the process was not restarted."
- exit 0
- fi
-
- echo "Success: the process was restarted."
+ sleep 1
+
+ cur_attempt=`expr $cur_attempt + 1`
+
+ done
+
+ echo "Error: $user_msg."
exit 0
-
-else # $expected_result = killed
-
+
+else # $expected_result == killed
+
+ # Here we have to sleep for some long time to ensure that the process will
+ # not be restarted.
+
+ sleep $total_timeout
+
+ new_pid=`cat "$pid_path" 2>/dev/null`
+
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
echo "Error: the process was restarted."
- exit 0
+ else
+ echo "Success: the process was killed."
fi
- echo "Success: the process was killed."
exit 0
+
fi
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 7fc65f52214..5bebec49b88 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -128,6 +128,36 @@ unlock tables;
drop table t1;
#
+# Bug#16986 - Deadlock condition with MyISAM tables
+#
+connection locker;
+use mysql;
+LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
+FLUSH TABLES;
+--sleep 1
+#
+connection reader;
+use mysql;
+#NOTE: This must be a multi-table select, otherwise the deadlock will not occur
+send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
+--sleep 1
+#
+connection locker;
+# Make test case independent from earlier grants.
+--replace_result "Table is already up to date" "OK"
+OPTIMIZE TABLES columns_priv, db, host, user;
+UNLOCK TABLES;
+#
+connection reader;
+reap;
+use test;
+#
+connection locker;
+use test;
+#
+connection default;
+
+#
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
#
connect (con1,localhost,root,,);
@@ -161,6 +191,33 @@ disconnect con2;
--error ER_DB_DROP_EXISTS
DROP DATABASE mysqltest_1;
+#
+# Bug #17264: MySQL Server freeze
+#
+connection locker;
+create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
+lock tables t1 write;
+connection writer;
+--sleep 2
+delimiter //;
+send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
+delimiter ;//
+connection reader;
+--sleep 2
+delimiter //;
+send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
+delimiter ;//
+connection locker;
+--sleep 2
+unlock tables;
+connection writer;
+reap;
+connection reader;
+reap;
+connection locker;
+drop table t1;
+
+# End of 5.0 tests
# Bug#16986 - Deadlock condition with MyISAM tables
#
connection locker;
@@ -190,4 +247,3 @@ use test;
#
connection default;
-# End of 5.0 tests
diff --git a/mysql-test/t/log_state-master.opt b/mysql-test/t/log_state-master.opt
new file mode 100644
index 00000000000..445c6223d47
--- /dev/null
+++ b/mysql-test/t/log_state-master.opt
@@ -0,0 +1 @@
+--log-output=TABLE,FILE --log --general-log=0 --log-slow-queries --slow-query-log=0
diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test
new file mode 100644
index 00000000000..41fbd068dce
--- /dev/null
+++ b/mysql-test/t/log_state.test
@@ -0,0 +1,122 @@
+-- source include/not_embedded.inc
+--source include/have_csv.inc
+
+--disable_ps_protocol
+set global general_log= OFF;
+truncate table mysql.general_log;
+truncate table mysql.slow_log;
+show global variables
+where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
+Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+flush logs;
+set global general_log= ON;
+create table t1(f1 int);
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+set global general_log= OFF;
+drop table t1;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+set global general_log= ON;
+flush logs;
+show global variables
+where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
+Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+
+connect (con1,localhost,root,,);
+connection con1;
+set session long_query_time=1;
+select sleep(2);
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+select * from mysql.slow_log;
+connection default;
+
+set global slow_query_log= ON;
+connection con1;
+set session long_query_time=1;
+select sleep(2);
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+select * from mysql.slow_log;
+disconnect con1;
+connection default;
+show global variables
+where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
+Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+
+set global general_log= ON;
+set global general_log= OFF;
+set global general_log= OFF;
+set global slow_query_log= ON;
+set global slow_query_log= OFF;
+set global slow_query_log= OFF;
+
+set global general_log= ON;
+truncate table mysql.general_log;
+create table t1(f1 int);
+drop table t1;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+set global general_log= OFF;
+truncate table mysql.general_log;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+set global general_log= ON;
+show global variables
+where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
+Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+
+--replace_column 2 #
+show variables like 'general_log_file';
+--replace_column 2 #
+show variables like 'slow_query_log_file';
+show variables like 'log_output';
+
+--error 1231
+set global general_log_file='/not exiting path/log.master';
+--error 1231
+set global general_log_file='/tmp';
+--error 1231
+set global general_log_file='';
+--replace_column 2 #
+show variables like 'general_log_file';
+set global general_log= OFF;
+set global general_log_file='/tmp/log.master';
+set global general_log= ON;
+create table t1(f1 int);
+drop table t1;
+set global general_log= OFF;
+set global general_log_file=default;
+set global general_log= ON;
+create table t1(f1 int);
+drop table t1;
+--replace_column 2 #
+show variables like 'general_log_file';
+--replace_column 2 #
+show variables like 'slow_query_log_file';
+
+set global general_log= default;
+set global slow_query_log= default;
+set global general_log_file= default;
+set global slow_query_log_file= default;
+show variables like 'general_log';
+show variables like 'slow_query_log';
+set global general_log=ON;
+set global log_output=default;
+show variables like 'log_output';
+set global general_log=OFF;
+set global log_output=FILE;
+truncate table mysql.general_log;
+show variables like 'log_output';
+set global general_log=ON;
+create table t1(f1 int);
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+set global general_log=OFF;
+set global log_output="FILE,TABLE";
+show variables like 'log_output';
+set global general_log=ON;
+drop table t1;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 #
+select * from mysql.general_log;
+
+--enable_ps_protocol
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index c02ae8f5073..521df01cc9b 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -139,3 +139,14 @@ select t1Aa.col1 from t1aA,t2Aa where t1Aa.col1 = t2aA.col1;
drop table t2aA, t1Aa;
# End of 4.1 tests
+
+#
+# Bug#17661 information_schema.SCHEMATA returns uppercase with lower_case_table_names = 1
+#
+create database mysqltest_LC2;
+use mysqltest_LC2;
+create table myUC (i int);
+select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES
+where TABLE_SCHEMA ='mysqltest_LC2';
+use test;
+drop database mysqltest_LC2;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 9fee4a03b81..c211ff2ac29 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -393,4 +393,13 @@ insert into t1 values ("Monty"),("WAX"),("Walrus");
alter table t1 engine=MERGE;
drop table t1;
+#
+# BUG#19648 - Merge table does not work with bit types
+#
+create table t1 (b bit(1));
+create table t2 (b bit(1));
+create table tm (b bit(1)) engine = merge union = (t1,t2);
+select * from tm;
+drop table tm, t1, t2;
+
# End of 5.0 tests
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 04c33e9d709..21271517564 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -452,6 +452,14 @@ insert into t2 values(1,null);
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
drop table t1, t2;
+#
+# Bug#19225: unchecked error leads to server crash
+#
+create table t1(a int);
+create table t2(a int);
+--error 1093
+delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
+drop table t1, t2;
# End of 4.1 tests
#
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index a77537f3ff5..9936b8bfc44 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -697,6 +697,27 @@ select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10;
drop table t1;
+#
+# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
+# in queries
+#
+CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES(1);
+SELECT MAX(a) FROM t1 IGNORE INDEX(a);
+ALTER TABLE t1 DISABLE KEYS;
+SELECT MAX(a) FROM t1;
+SELECT MAX(a) FROM t1 IGNORE INDEX(a);
+DROP TABLE t1;
+
+#
+# BUG#18036 - update of table joined to self reports table as crashed
+#
+CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
+INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
+UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
+SELECT * FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests
#
@@ -869,4 +890,3 @@ drop table t1;
create table t1 (a int not null, key key_block_size=1024 (a));
--error 1064
create table t1 (a int not null, key `a` key_block_size=1024 (a));
-
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 98e881b67d5..74c3bb2e1d5 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1159,6 +1159,27 @@ drop table t1, t2;
#
+# Bug#18462 mysqldump does not dump view structures correctly
+#
+#
+create table t (qty int, price int);
+insert into t values(3, 50);
+insert into t values(5, 51);
+create view v1 as select qty, price, qty*price as value from t;
+create view v2 as select qty from v1;
+--echo mysqldump {
+--exec $MYSQL_DUMP --compact -F --tab . test
+--exec cat v1.sql
+--echo } mysqldump {
+--exec cat v2.sql
+--echo } mysqldump
+--rm v.sql t.sql t.txt
+drop view v1;
+drop view v2;
+drop table t;
+
+
+#
# Bug#14857 Reading dump files with single statement stored routines fails.
# fixed by patch for bug#16878
#
@@ -1174,6 +1195,19 @@ show create procedure p;
drop function f;
drop procedure p;
+#
+# Bug #17371 Unable to dump a schema with invalid views
+#
+#
+create table t1 ( id serial );
+create view v1 as select * from t1;
+drop table t1;
+# mysqldump gets 1356 from server, but gives us 2
+--echo mysqldump {
+--error 2
+--exec $MYSQL_DUMP --force -N --compact --skip-comments test
+--echo } mysqldump
+drop view v1;
# Added for use-thread option
#
create table t1 (a text , b text);
@@ -1252,3 +1286,20 @@ set time_zone = 'SYSTEM';
use test;
#####
+#
+# BUG#17201 Spurious 'DROP DATABASE' in output,
+# also confusion between tables and views.
+# Example code from Markus Popp
+
+create database mysqldump_test_db;
+use mysqldump_test_db;
+create table t1 (id int);
+create view v1 as select * from t1;
+insert into t1 values (1232131);
+insert into t1 values (4711);
+insert into t1 values (3231);
+insert into t1 values (0815);
+--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db
+drop view v1;
+drop table t1;
+drop database mysqldump_test_db;
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index 8e3b4a6ca89..73c612b203f 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -367,12 +367,23 @@ CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(
LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables;
--enable_warnings
+# Ndb doesn't support renaming attributes on-line
set @t1_id = (select id from ndb_show_tables where name like '%t1%');
truncate ndb_show_tables;
alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL;
+--disable_warnings
+--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat
+LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables;
+--enable_warnings
+
+select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%';
+
+set @t1_id = (select id from ndb_show_tables where name like '%t1%');
+truncate ndb_show_tables;
+
create index i1 on t1(medium);
-alter table t1 add index i2(long_int);
+alter table t1 add index i2(new_tiny);
drop index i1 on t1;
--disable_warnings
diff --git a/mysql-test/t/ndb_binlog_multi.test b/mysql-test/t/ndb_binlog_multi.test
index 6adacf73208..e023a54b61c 100644
--- a/mysql-test/t/ndb_binlog_multi.test
+++ b/mysql-test/t/ndb_binlog_multi.test
@@ -4,11 +4,18 @@
--disable_warnings
connection server2;
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
connection server1;
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
+# Dummy table create/drop to avoid a race where table is created
+# before event subscription is set up, causing test failure (BUG#20677).
+connection server2;
+CREATE TABLE t3 (dummy INT PRIMARY KEY) ENGINE = NDB;
+connection server1;
+DROP TABLE t3;
+
# reset for test
connection server1;
reset master;
diff --git a/mysql-test/t/ndb_blob_partition.test b/mysql-test/t/ndb_blob_partition.test
new file mode 100644
index 00000000000..a3948cc9491
--- /dev/null
+++ b/mysql-test/t/ndb_blob_partition.test
@@ -0,0 +1,93 @@
+--source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Minimal NDB blobs test with range partitions.
+#
+
+create table t1 (
+ a mediumint not null,
+ b text not null,
+ c int not null,
+ d longblob,
+ primary key using hash (a,c),
+ unique key (c)
+)
+ engine=ndb
+ partition by range (c)
+ partitions 3
+ ( partition p1 values less than (200),
+ partition p2 values less than (300),
+ partition p3 values less than (400));
+
+--disable_query_log
+sleep 1;
+
+# length 61
+set @s0 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau';
+set @s1 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz';
+set @s2 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah';
+
+set @v1 = repeat(@s0, 100); -- 1d42dd9090cf78314a06665d4ea938c35cc760f4
+set @v2 = repeat(@s1, 200); -- 10d3c783026b310218d10b7188da96a2401648c6
+set @v3 = repeat(@s2, 300); -- a33549d9844092289a58ac348dd59f09fc28406a
+set @v4 = repeat(@s0, 400); -- daa61c6de36a0526f0d47dc29d6b9de7e6d2630c
+set @v5 = repeat(@s1, 500); -- 70fc9a7d08beebc522258bfb02000a30c77a8f1d
+set @v6 = repeat(@s2, 600); -- 090565c580809efed3d369481a4bbb168b20713e
+set @v7 = repeat(@s0, 700); -- 1e0070bec426871a46291de27b9bd6e4255ab4e5
+set @v8 = repeat(@s1, 800); -- acbaba01bc2e682f015f40e79d9cbe475db3002e
+set @v9 = repeat(@s2, 900); -- 9ee30d99162574f79c66ae95cdf132dcf9cbc259
+--enable_query_log
+
+# -- insert --
+insert into t1 values (1, @v1, 101, @v2);
+insert into t1 values (1, @v2, 102, @v3);
+insert into t1 values (1, @v3, 103, @v4);
+insert into t1 values (2, @v4, 201, @v5);
+insert into t1 values (2, @v5, 202, @v6);
+insert into t1 values (2, @v6, 203, @v7);
+insert into t1 values (3, @v7, 301, @v8);
+insert into t1 values (3, @v8, 302, @v9);
+insert into t1 values (3, @v9, 303, @v1);
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- pk read --
+select a, sha1(b), c, sha1(d) from t1 where a = 1 and c = 101;
+select a, sha1(b), c, sha1(d) from t1 where a = 2 and c = 201;
+select a, sha1(b), c, sha1(d) from t1 where a = 3 and c = 301;
+
+# -- pk update --
+update t1 set b = @v3, d = @v4 where a = 1 and c = 102;
+update t1 set b = @v6, d = @v7 where a = 2 and c = 202;
+update t1 set b = @v9, d = @v1 where a = 3 and c = 302;
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- hash index update --
+update t1 set b = @v4, d = @v5 where c = 103;
+update t1 set b = @v7, d = @v8 where c = 203;
+update t1 set b = @v1, d = @v2 where c = 303;
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- full scan update --
+update t1 set b = @v5, d = @v6;
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- range scan update
+update t1 set b = @v1, d = @v2 where 100 < c and c < 200;
+update t1 set b = @v4, d = @v5 where 200 < c and c < 300;
+update t1 set b = @v7, d = @v8 where 300 < c and c < 400;
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- delete --
+delete from t1 where a = 1 and c = 101;
+delete from t1 where c = 102;
+# delete from t1 where c < 300; # XXX coredump
+delete from t1;
+select a, sha1(b), c, sha1(d) from t1 order by a;
+
+# -- clean up --
+drop table t1;
diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test
index 3b53f7b3431..9795c831161 100644
--- a/mysql-test/t/ndb_condition_pushdown.test
+++ b/mysql-test/t/ndb_condition_pushdown.test
@@ -1686,5 +1686,27 @@ select * from t1 where b like 'ab' or b like 'ab';
select * from t1 where b like 'abc';
select * from t1 where b like 'abc' or b like 'abc';
+# bug#20406 (maybe same as bug#17421 -1, not seen on 32-bit x86)
+drop table t1;
+create table t1 ( fname varchar(255), lname varchar(255) )
+engine=ndbcluster;
+insert into t1 values ("Young","Foo");
+
+set engine_condition_pushdown = 0;
+SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
+set engine_condition_pushdown = 1;
+SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
+
+# make sure optimizer does not do some crazy shortcut
+insert into t1 values ("aaa", "aaa");
+insert into t1 values ("bbb", "bbb");
+insert into t1 values ("ccc", "ccc");
+insert into t1 values ("ddd", "ddd");
+
+set engine_condition_pushdown = 0;
+SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
+set engine_condition_pushdown = 1;
+SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
+
set engine_condition_pushdown = @old_ecpd;
DROP TABLE t1,t2,t3,t4,t5;
diff --git a/mysql-test/t/ndb_dd_backuprestore.test b/mysql-test/t/ndb_dd_backuprestore.test
index 1508cccb46d..be6d73e27b4 100644
--- a/mysql-test/t/ndb_dd_backuprestore.test
+++ b/mysql-test/t/ndb_dd_backuprestore.test
@@ -159,15 +159,185 @@ DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE test.t3;
DROP TABLE test.t4;
+###################### Adding partition #################################
+-- echo **** 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 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;
+
+SHOW CREATE TABLE test.t2;
+
+SHOW CREATE TABLE test.t3;
+
+SHOW CREATE TABLE test.t4;
+
+SHOW CREATE TABLE test.t5;
+
+SHOW CREATE TABLE test.t6;
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't1';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't2';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't3';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't4';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't5';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't6';
+
+
+let $j= 500;
+--disable_query_log
+while ($j)
+{
+ eval INSERT INTO test.t1 VALUES (NULL, "Sweden, Texas", $j, b'0');
+ eval INSERT INTO test.t4 VALUES (NULL, "Sweden, Texas", $j, b'0');
+ dec $j;
+ eval INSERT INTO test.t2 VALUES (NULL, "Sweden, Texas, ITALY, Kyle, JO, JBM,TU", $j, b'1');
+ eval INSERT INTO test.t5 VALUES (NULL, "Sweden, Texas, ITALY, Kyle, JO, JBM,TU", $j, b'1');
+ dec $j;
+ eval INSERT INTO test.t3 VALUES (NULL, "TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU", $j, b'1');
+ eval INSERT INTO test.t6 VALUES (NULL, "TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU", $j, b'1'); } --enable_query_log
+
+SELECT COUNT(*) FROM test.t1;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t2;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t3;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t4;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t5;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t6;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5;
+
+-- source include/ndb_backup.inc
+
+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'
+ENGINE = NDB;
+
DROP TABLESPACE table_space1
ENGINE = NDB;
+DROP TABLESPACE table_space2
+ENGINE = NDB;
+
DROP LOGFILE GROUP log_group1
ENGINE =NDB;
+-- source include/ndb_restore_master.inc
+
+
+SHOW CREATE TABLE test.t1;
+
+SHOW CREATE TABLE test.t2;
+
+SHOW CREATE TABLE test.t3;
+
+SHOW CREATE TABLE test.t4;
+
+SHOW CREATE TABLE test.t5;
+
+SHOW CREATE TABLE test.t6;
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't1';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't2';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't3';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't4';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't5';
+
+SELECT * FROM information_schema.partitions WHERE table_name= 't6';
+
+SELECT COUNT(*) FROM test.t1;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t2;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t3;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t4;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t5;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t6;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5;
+
+# Cleanup
+
+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' ENGINE=NDB;
+
+DROP TABLESPACE table_space1 ENGINE = NDB;
+
+DROP TABLESPACE table_space2 ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1 ENGINE = NDB;
+
#End 5.1 test case
+
+
diff --git a/mysql-test/t/ndb_dd_ddl.test b/mysql-test/t/ndb_dd_ddl.test
index 339f7bc2f22..1a470d52c6c 100644
--- a/mysql-test/t/ndb_dd_ddl.test
+++ b/mysql-test/t/ndb_dd_ddl.test
@@ -40,7 +40,7 @@ CREATE DATABASE mysqltest;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
-INITIAL_SIZE 16M
+INITIAL_SIZE 1M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;
@@ -48,7 +48,7 @@ ENGINE=NDB;
--error ER_CREATE_FILEGROUP_FAILED
CREATE LOGFILE GROUP lg2
ADD UNDOFILE 'undofile2.dat'
-INITIAL_SIZE 16M
+INITIAL_SIZE 1M
UNDO_BUFFER_SIZE 1M
ENGINE NDB;
SHOW WARNINGS;
@@ -56,42 +56,42 @@ SHOW WARNINGS;
--error ER_CREATE_FILEGROUP_FAILED
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
-INITIAL_SIZE 16M
+INITIAL_SIZE 1M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
-INITIAL_SIZE 4M ENGINE NDB;
+INITIAL_SIZE 1M ENGINE NDB;
--error ER_ALTER_FILEGROUP_FAILED
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
-INITIAL_SIZE 4M ENGINE=NDB;
+INITIAL_SIZE 1M ENGINE=NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE NDB;
--error ER_CREATE_FILEGROUP_FAILED
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE NDB;
ALTER TABLESPACE ts1
ADD DATAFILE 'datafile2.dat'
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE=NDB;
--error ER_ALTER_FILEGROUP_FAILED
ALTER TABLESPACE ts1
ADD DATAFILE 'datafile2.dat'
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE=NDB;
CREATE TABLE mysqltest.t1
@@ -155,23 +155,23 @@ DROP DATABASE IF EXISTS mysqltest;
creaTE LOgfilE GrOuP lg1
adD undoFILE 'undofile.dat'
-initiAL_siZE 16M
+initiAL_siZE 1M
UnDo_BuFfEr_SiZe = 1M
ENGInE=NDb;
altER LOgFiLE GrOUp lg1
AdD UnDOfILe 'uNdOfiLe02.daT'
-INItIAl_SIzE 4M ENgINE nDB;
+INItIAl_SIzE 1M ENgINE nDB;
CrEAtE TABLEspaCE ts1
ADD DATAfilE 'datafile.dat'
UsE LoGFiLE GRoUP lg1
-INITiaL_SizE 12M
+INITiaL_SizE 1M
ENGiNe NDb;
AlTeR tAbLeSpAcE ts1
AdD DaTaFiLe 'dAtAfiLe2.daT'
-InItIaL_SiZe 12M
+InItIaL_SiZe 1M
EnGiNe=NDB;
CREATE TABLE t1
@@ -203,24 +203,24 @@ EnGiNe=nDb;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
-INITIAL_SIZE=16M
+INITIAL_SIZE=1M
UNDO_BUFFER_SIZE=1M
ENGINE=NDB;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
-INITIAL_SIZE=4M
+INITIAL_SIZE=1M
ENGINE=NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
-INITIAL_SIZE=12M
+INITIAL_SIZE=1M
ENGINE=NDB;
ALTER TABLESPACE ts1
ADD DATAFILE 'datafile2.dat'
-INITIAL_SIZE=12M
+INITIAL_SIZE=1M
ENGINE=NDB;
CREATE TABLE t1
@@ -250,24 +250,24 @@ ENGINE=NDB;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
-INITIAL_SIZE 16M
+INITIAL_SIZE 1M
UNDO_BUFFER_SIZE 1M
ENGINE NDB;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
-INITIAL_SIZE 4M
+INITIAL_SIZE 1M
ENGINE NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE NDB;
ALTER TABLESPACE ts1
ADD DATAFILE 'datafile2.dat'
-INITIAL_SIZE 12M
+INITIAL_SIZE 1M
ENGINE NDB;
CREATE TABLE t1
@@ -280,6 +280,25 @@ CREATE INDEX bc_i on t1(b, c);
DROP TABLE t1;
+# bug#20053
+
+CREATE TABLESPACE ts2
+ADD DATAFILE 'datafile3.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 1M
+ENGINE NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile3.dat'
+ENGINE NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile2.dat'
+ENGINE NDB;
+# bug#20053
+
ALTER TABLESPACE ts1
DROP DATAFILE 'datafile2.dat'
ENGINE NDB;
@@ -291,11 +310,45 @@ ENGINE NDB;
DROP TABLESPACE ts1
ENGINE NDB;
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile3.dat'
+ENGINE NDB;
+
+DROP TABLESPACE ts2
+ENGINE NDB;
+
DROP LOGFILE GROUP lg1
ENGINE NDB;
--echo **** End = And No = ****
############ End = And No = ##################
-# End 5.1 test
+###
+#
+# bug#16341
+create table t1 (a int primary key) engine = myisam;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CREATE_FILEGROUP_FAILED
+--eval create logfile group lg1 add undofile '$MYSQLTEST_VARDIR/master-data/test/t1.frm' initial_size 1M undo_buffer_size = 1M engine=ndb;
+
+create logfile group lg1
+add undofile 'undofile.dat'
+initial_size 1M
+undo_buffer_size = 1M
+engine=ndb;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CREATE_FILEGROUP_FAILED
+--eval create tablespace ts1 add datafile '$MYSQLTEST_VARDIR/master-data/test/t1.frm' use logfile group lg1 initial_size 1M engine ndb;
+
+--error ER_DROP_FILEGROUP_FAILED
+drop tablespace ts1
+engine ndb;
+
+drop logfile group lg1
+engine ndb;
+
+drop table t1;
+
+# End 5.1 test
diff --git a/mysql-test/t/ndb_loaddatalocal.test b/mysql-test/t/ndb_loaddatalocal.test
new file mode 100644
index 00000000000..47054ecfbf5
--- /dev/null
+++ b/mysql-test/t/ndb_loaddatalocal.test
@@ -0,0 +1,70 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+create table t1(a int) engine=myisam;
+let $1=10000;
+disable_query_log;
+set SQL_LOG_BIN=0;
+while ($1)
+{
+ insert into t1 values(1);
+ dec $1;
+}
+set SQL_LOG_BIN=1;
+enable_query_log;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1;
+#This will generate a 20KB file, now test LOAD DATA LOCAL
+drop table t1;
+
+create table t1(a int) engine=ndb;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
+select count(*) from t1;
+system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile ;
+drop table t1;
+
+create table t1(a int) engine=myisam;
+insert into t1 values (1), (2), (2), (3);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1;
+drop table t1;
+
+create table t1(a int primary key) engine=ndb;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
+system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+select * from t1 order by a;
+drop table t1;
+
+create table t1(a int) engine=myisam;
+insert into t1 values (1), (1), (2), (3);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1;
+drop table t1;
+
+create table t1(a int primary key) engine=ndb;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
+system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+select * from t1 order by a;
+drop table t1;
+
+create table t1(a int) engine=myisam;
+insert into t1 values (1), (2), (3), (3);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1;
+drop table t1;
+
+create table t1(a int primary key) engine=ndb;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
+system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+select * from t1 order by a;
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/ndb_partition_error.test b/mysql-test/t/ndb_partition_error.test
new file mode 100644
index 00000000000..06581f1270f
--- /dev/null
+++ b/mysql-test/t/ndb_partition_error.test
@@ -0,0 +1,71 @@
+-- source include/have_ndb.inc
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Focuses on range partitioning tests
+#
+#-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by range, generate node group error
+#
+--error 1005
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b),
+index (a))
+engine = ndb
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) nodegroup 12,
+ partition x2 values less than (10) nodegroup 13,
+ partition x3 values less than (20) nodegroup 14);
+show warnings;
+
+#
+# Partition by range, create normal valid table
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a))
+engine = ndb
+partition by range (a)
+partitions 3
+(partition x1 values less than (5),
+ partition x2 values less than (10),
+ 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;
+
+#
+# NULL for LIST partition
+#
+create table t1 (a int,b int, c int)
+engine = ndb
+partition by list(a)
+partitions 2
+(partition x123 values in (11, 12),
+ partition x234 values in (5, 1));
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (NULL,1,1);
+drop table t1;
diff --git a/mysql-test/t/ndb_partition_key.test b/mysql-test/t/ndb_partition_key.test
new file mode 100644
index 00000000000..fb0581eb6f6
--- /dev/null
+++ b/mysql-test/t/ndb_partition_key.test
@@ -0,0 +1,198 @@
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# Basic syntax test
+#
+
+# Support for partition key verified
+CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c))
+ ENGINE = NDB
+ PARTITION BY KEY (a,b);
+
+insert into t1 values (1,1,1,1);
+select * from t1;
+update t1 set d = 2 where a = 1 and b = 1 and c = 1;
+select * from t1;
+delete from t1;
+select * from t1;
+
+drop table t1;
+
+# only support for partition key on primary key
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b))
+ ENGINE = NDB
+ PARTITION BY KEY (c);
+
+CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b))
+ ENGINE = NDB
+ PARTITION BY KEY (a);
+
+insert into t1 values
+ (1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3),
+ (1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3);
+
+select * from t1 order by b;
+
+DROP TABLE t1;
+
+#
+# Test partition and char support
+#
+
+CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT,
+ PRIMARY KEY (a,b,c) USING HASH)
+ ENGINE=NDB
+ DEFAULT CHARSET=latin1
+ PARTITION BY KEY (b);
+
+insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1);
+
+# should show only one attribute with DISTRIBUTION KEY
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | sed 's/Version: [0-9]*//' | sed 's/\(Length of frm data: \)[0-9]*/\1#/'
+
+#
+# Test that explicit partition info is not shown in show create table
+# result should not contain (PARTITION P0 ... etc) since this is what shows up in
+# mysqldump, and we don't want that info there
+#
+show create table t1;
+
+DROP TABLE t1;
+
+#
+# Bug #13155: Problem in Create Table using SHOW CREATE TABLE syntax
+#
+CREATE TABLE t1 (a int not null primary key)
+PARTITION BY KEY(a)
+(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
+
+drop table t1;
+
+CREATE TABLE t1 (a int not null primary key);
+ALTER TABLE t1
+PARTITION BY KEY(a)
+(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
+
+drop table t1;
+
+#
+# Bug #17754 Improper handling of removal of partitioning in ALTER TABLE
+# Also added a number of general test cases in the same area
+#
+create table t1 (a int)
+engine=ndb
+partition by key(a)
+(partition p0, partition p1);
+show create table t1;
+
+alter table t1 engine=heap;
+show create table t1;
+
+alter table t1 engine=ndb;
+show create table t1;
+
+alter table t1 engine=heap remove partitioning;
+show create table t1;
+
+alter table t1 engine=ndb
+partition by key(a)
+(partition p0, partition p1 engine = ndb);
+show create table t1;
+
+alter table t1
+partition by key (a)
+(partition p0 engine=ndb, partition p1 engine=ndb);
+show create table t1;
+
+alter table t1 remove partitioning;
+show create table t1;
+
+--error ER_MIX_HANDLER_ERROR
+alter table t1
+partition by key(a)
+(partition p0 engine=ndb, partition p1);
+
+alter table t1
+engine=ndb
+partition by key(a)
+(partition p0 engine=ndb, partition p1 engine = ndb);
+show create table t1;
+
+drop table t1;
+
+#
+# BUG 16810 Out of memory when coalesce partition
+#
+CREATE TABLE t1 (
+ c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
+ c2 TEXT NOT NULL,
+ c3 INT NOT NULL,
+ c4 BIT NOT NULL,
+ c5 FLOAT,
+ c6 VARCHAR(255),
+ c7 TIMESTAMP,
+ PRIMARY KEY(c1,c3))
+ ENGINE=NDB
+ PARTITION BY KEY(c3) PARTITIONS 5;
+
+let $j= 11;
+--disable_query_log
+while ($j)
+{
+ eval INSERT INTO t1 VALUES (NULL, "Tested Remotely from Texas, USA", $j,
+b'0',
+ $j.00,"By JBM $j","2006-01-26");
+ dec $j;
+}
+--enable_query_log
+ALTER TABLE t1 COALESCE PARTITION 4;
+
+DROP TABLE t1;
+
+#
+# Bug 16822: OPTIMIZE TABLE hangs test
+#
+CREATE TABLE t1 (a int primary key)
+ENGINE=NDB
+PARTITION BY KEY(a);
+--error 1031
+ALTER TABLE t1 OPTIMIZE PARTITION p0;
+--error 1031
+ALTER TABLE t1 CHECK PARTITION p0;
+--error 1031
+ALTER TABLE t1 REPAIR PARTITION p0;
+--error 1031
+ALTER TABLE t1 ANALYZE PARTITION p0;
+--error 1031
+ALTER TABLE t1 REBUILD PARTITION p0;
+DROP TABLE t1;
+
+#
+# BUG 16806: ALTER TABLE fails
+#
+CREATE TABLE t1 (
+ c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
+ c2 TEXT NOT NULL,
+ c3 INT NOT NULL,
+ PRIMARY KEY(c1,c3))
+ ENGINE=NDB
+ PARTITION BY KEY(c3) PARTITIONS 5;
+
+ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
+ c2 TEXT NOT NULL,
+ c3 INT NOT NULL,
+ PRIMARY KEY(c1,c3))
+ ENGINE=NDB
+ PARTITION BY KEY(c3);
+
+ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ndb_partition_list.test b/mysql-test/t/ndb_partition_list.test
new file mode 100644
index 00000000000..2ad37b8768c
--- /dev/null
+++ b/mysql-test/t/ndb_partition_list.test
@@ -0,0 +1,64 @@
+--source include/have_ndb.inc
+#
+# Simple test for the partition storage engine
+# Focuses on range partitioning tests
+#
+#-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by list, basic
+#
+
+CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL,
+ f_char1 CHAR(10),
+ f_char2 CHAR(10), f_charbig VARCHAR(1000),
+PRIMARY KEY (f_int1,f_int2))
+ENGINE = NDB
+PARTITION BY LIST(MOD(f_int1 + f_int2,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3,4,5));
+
+INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20===';
+INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+
+SELECT * FROM t1 ORDER BY f_int1;
+
+DROP TABLE t1;
+
+#
+# Partition by list, no pk
+#
+
+CREATE TABLE t1 ( f_int1 INTEGER, f_int2 INTEGER, f_char1 CHAR(10),
+ f_char2 CHAR(10), f_charbig VARCHAR(1000))
+ENGINE = NDB
+PARTITION BY LIST(f_int1)
+(PARTITION part_1 VALUES IN (-1),
+ PARTITION part0 VALUES IN (0,1),
+ PARTITION part1 VALUES IN (2));
+
+INSERT INTO t1 SET f_int1 = -1, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20===';
+INSERT INTO t1 SET f_int1 = 0, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20===';
+INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
+
+SELECT * FROM t1 ORDER BY f_int1;
+
+DROP TABLE t1;
+
diff --git a/mysql-test/t/ndb_partition_range.test b/mysql-test/t/ndb_partition_range.test
new file mode 100644
index 00000000000..981467d4055
--- /dev/null
+++ b/mysql-test/t/ndb_partition_range.test
@@ -0,0 +1,260 @@
+-- source include/have_ndb.inc
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Focuses on range partitioning tests
+#
+#-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by range, basic
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b),
+index (a))
+engine = ndb
+partition by range (a)
+partitions 3
+(partition x1 values less than (5),
+ partition x2 values less than (10),
+ partition x3 values less than (20));
+
+# Simple insert and verify test
+INSERT into t1 values (1, 1, 1);
+INSERT into t1 values (6, 1, 1);
+INSERT into t1 values (10, 1, 1);
+INSERT into t1 values (15, 1, 1);
+
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_name= 't1';
+
+select * from t1 order by a;
+
+select * from t1 where a=1 order by a;
+select * from t1 where a=15 and b=1 order by a;
+select * from t1 where a=21 and b=1 order by a;
+select * from t1 where a=21 order by a;
+select * from t1 where a in (1,6,10,21) order by a;
+select * from t1 where b=1 and a in (1,6,10,21) order by a;
+
+drop table t1;
+
+#
+# Partition by range, basic
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(b),
+unique (a))
+engine = ndb
+partition by range (b)
+partitions 3
+(partition x1 values less than (5),
+ partition x2 values less than (10),
+ partition x3 values less than (20));
+
+# Simple insert and verify test
+INSERT into t1 values (1, 1, 1);
+INSERT into t1 values (2, 6, 1);
+INSERT into t1 values (3, 10, 1);
+INSERT into t1 values (4, 15, 1);
+
+select * from t1 order by a;
+UPDATE t1 set a = 5 WHERE b = 15;
+select * from t1 order by a;
+UPDATE t1 set a = 6 WHERE a = 5;
+select * from t1 order by a;
+
+select * from t1 where b=1 order by b;
+select * from t1 where b=15 and a=1 order by b;
+select * from t1 where b=21 and a=1 order by b;
+select * from t1 where b=21 order by b;
+select * from t1 where b in (1,6,10,21) order by b;
+select * from t1 where a in (1,2,5,6) order by b;
+select * from t1 where a=1 and b in (1,6,10,21) order by b;
+
+DELETE from t1 WHERE b = 6;
+DELETE from t1 WHERE a = 6;
+
+#
+# Test that explicit partition info _is_ shown in show create table
+# result _should_ contain (PARTITION x1 ... etc)
+#
+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_replace.test b/mysql-test/t/ndb_replace.test
index 6cad80ef8ea..94a11f7dfb2 100644
--- a/mysql-test/t/ndb_replace.test
+++ b/mysql-test/t/ndb_replace.test
@@ -6,7 +6,7 @@
#
--disable_warnings
-drop table if exists t1;
+drop table if exists t1,t2;
--enable_warnings
CREATE TABLE t1 (
@@ -27,6 +27,8 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1 order by gesuchnr;
drop table t1;
+# End of 4.1 tests
+
# bug#17431
CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT,
j INT,
@@ -38,4 +40,28 @@ REPLACE INTO t1 (j,k) VALUES (1,42);
REPLACE INTO t1 (i,j) VALUES (17,2);
SELECT * from t1 ORDER BY i;
-# End of 4.1 tests
+# bug#19906
+CREATE TABLE t2 (a INT(11) NOT NULL,
+ b INT(11) NOT NULL,
+ c INT(11) NOT NULL,
+ x TEXT,
+ y TEXT,
+ z TEXT,
+ id INT(10) unsigned NOT NULL AUTO_INCREMENT,
+ i INT(11) DEFAULT NULL,
+ PRIMARY KEY (id),
+ UNIQUE KEY a (a,b,c)
+) ENGINE=ndbcluster;
+
+REPLACE INTO t2 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3);
+
+SELECT * FROM t2 ORDER BY id;
+
+REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1);
+REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2);
+
+SELECT * FROM t2 ORDER BY id;
+
+DROP TABLE t2;
+
+
diff --git a/mysql-test/t/ndb_restore_partition-master.opt b/mysql-test/t/ndb_restore_partition-master.opt
new file mode 100644
index 00000000000..075c6392dde
--- /dev/null
+++ b/mysql-test/t/ndb_restore_partition-master.opt
@@ -0,0 +1 @@
+--new
diff --git a/mysql-test/t/ndb_restore_partition.test b/mysql-test/t/ndb_restore_partition.test
new file mode 100644
index 00000000000..f11324492c2
--- /dev/null
+++ b/mysql-test/t/ndb_restore_partition.test
@@ -0,0 +1,375 @@
+-- source include/have_ndb.inc
+-- source include/ndb_default_cluster.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+use test;
+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;
+--enable_warnings
+
+CREATE TABLE `t1_c` (
+ `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
+ `goaledatta` char(2) NOT NULL default '',
+ `maturegarbagefa` varchar(32) NOT NULL default '',
+ PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt');
+
+CREATE TABLE `t2_c` (
+ `capgotod` smallint(5) unsigned NOT NULL auto_increment,
+ `gotod` smallint(5) unsigned NOT NULL default '0',
+ `goaledatta` char(2) default NULL,
+ `maturegarbagefa` varchar(32) default NULL,
+ `descrpooppo` varchar(64) default NULL,
+ `svcutonsa` varchar(64) NOT NULL default '',
+ PRIMARY KEY (`capgotod`),
+ KEY `i_quadaddsvr` (`gotod`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
+
+CREATE TABLE `t3_c` (
+ `CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
+ `capgotod` smallint(5) unsigned NOT NULL default '0',
+ PRIMARY KEY (`capgotod`,`CapGoaledatta`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3);
+
+CREATE TABLE `t4_c` (
+ `capfa` bigint(20) unsigned NOT NULL auto_increment,
+ `realm` varchar(32) NOT NULL default '',
+ `authpwchap` varchar(32) default NULL,
+ `fa` varchar(32) NOT NULL default '',
+ `payyingatta` tinyint(4) NOT NULL default '0',
+ `status` char(1) default NULL,
+ PRIMARY KEY (`fa`,`realm`),
+ KEY `capfa` (`capfa`),
+ KEY `i_quadentity` (`fa`,`realm`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
+
+CREATE TABLE `t5_c` (
+ `capfa` bigint(20) unsigned NOT NULL default '0',
+ `gotod` smallint(5) unsigned NOT NULL default '0',
+ `orderutonsa` varchar(64) NOT NULL default '',
+ PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,'');
+
+CREATE TABLE `t6_c` (
+ `capfa_parent` bigint(20) unsigned NOT NULL default '0',
+ `capfa_child` bigint(20) unsigned NOT NULL default '0',
+ `relatta` smallint(5) unsigned NOT NULL default '0',
+ PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0);
+
+CREATE TABLE `t7_c` (
+ `dardpo` char(15) NOT NULL default '',
+ `dardtestard` tinyint(3) unsigned NOT NULL default '0',
+ `FastFA` char(5) NOT NULL default '',
+ `FastCode` char(6) NOT NULL default '',
+ `Fastca` char(1) NOT NULL default '',
+ `Fastmag` char(1) NOT NULL default '',
+ `Beareratta` char(2) NOT NULL default '',
+ PRIMARY KEY (`dardpo`,`dardtestard`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3');
+
+CREATE TABLE `t8_c` (
+ `kattjame` varchar(32) NOT NULL default '',
+ `realm` varchar(32) NOT NULL default '',
+ `realm_entered` varchar(32) NOT NULL default '',
+ `maturegarbagefa` varchar(32) NOT NULL default '',
+ `hunderaaarbagefa_parent` varchar(32) NOT NULL default '',
+ `kattjame_entered` varchar(32) NOT NULL default '',
+ `hunderaaarbagefa` varchar(32) NOT NULL default '',
+ `gest` varchar(16) default NULL,
+ `hassetino` varchar(16) NOT NULL default '',
+ `aaaproxysessfa` varchar(255) default NULL,
+ `autologonallowed` char(1) default NULL,
+ `squardporoot` varchar(15) NOT NULL default '',
+ `naspo` varchar(15) default NULL,
+ `beareratta` char(2) default NULL,
+ `fastCode` varchar(6) default NULL,
+ `fastFA` varchar(5) default NULL,
+ `fastca` char(1) default NULL,
+ `fastmag` char(1) default NULL,
+ `lastupdate` datetime default NULL,
+ `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00',
+ `accthassetitime` int(10) unsigned default NULL,
+ `acctoutputoctets` bigint(20) unsigned default NULL,
+ `acctinputoctets` bigint(20) unsigned default NULL,
+ PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`),
+ KEY `squardporoot` (`squardporoot`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565);
+
+CREATE TABLE `t9_c` (
+ `kattjame` varchar(32) NOT NULL default '',
+ `kattjame_entered` varchar(32) NOT NULL default '',
+ `realm` varchar(32) NOT NULL default '',
+ `realm_entered` varchar(32) NOT NULL default '',
+ `maturegarbagefa` varchar(32) NOT NULL default '',
+ `hunderaaarbagefa` varchar(32) NOT NULL default '',
+ `hunderaaarbagefa_parent` varchar(32) NOT NULL default '',
+ `gest` varchar(16) default NULL,
+ `hassetino` varchar(16) NOT NULL default '',
+ `squardporoot` varchar(15) NOT NULL default '',
+ `naspo` varchar(15) default NULL,
+ `beareratta` char(2) default NULL,
+ `fastCode` varchar(6) default NULL,
+ `fastFA` varchar(5) default NULL,
+ `fastca` char(1) default NULL,
+ `fastmag` char(1) default NULL,
+ `lastupdate` datetime default NULL,
+ `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00',
+ `accthassetitime` int(10) unsigned default NULL,
+ `actcoutpuocttets` bigint(20) unsigned default NULL,
+ `actinputocctets` bigint(20) unsigned default NULL,
+ `terminateraste` tinyint(3) unsigned default NULL,
+ PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
+
+create table t1 engine=myisam as select * from t1_c;
+create table t2 engine=myisam as select * from t2_c;
+create table t3 engine=myisam as select * from t3_c;
+create table t4 engine=myisam as select * from t4_c;
+create table t5 engine=myisam as select * from t5_c;
+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;
+
+
+--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 $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;
+
+select count(*) from t1;
+select count(*) from t1_c;
+select count(*)
+ from (select * from t1 union
+ select * from t1_c) a;
+
+select count(*) from t2;
+select count(*) from t2_c;
+select count(*)
+ from (select * from t2 union
+ select * from t2_c) a;
+
+select count(*) from t3;
+select count(*) from t3_c;
+select count(*)
+ from (select * from t3 union
+ select * from t3_c) a;
+
+select count(*) from t4;
+select count(*) from t4_c;
+select count(*)
+ from (select * from t4 union
+ select * from t4_c) a;
+
+select count(*) from t5;
+select count(*) from t5_c;
+select count(*)
+ from (select * from t5 union
+ select * from t5_c) a;
+
+select count(*) from t6;
+select count(*) from t6_c;
+select count(*)
+ from (select * from t6 union
+ select * from t6_c) a;
+
+select count(*) from t7;
+select count(*) from t7_c;
+select count(*)
+ from (select * from t7 union
+ select * from t7_c) a;
+
+select count(*) from t8;
+select count(*) from t8_c;
+select count(*)
+ from (select * from t8 union
+ select * from t8_c) a;
+
+select count(*) from t9;
+select count(*) from t9_c;
+select count(*)
+ from (select * from t9 union
+ select * from t9_c) a;
+
+#
+# Try Partitioned tables as well
+#
+ALTER TABLE t1_c
+PARTITION BY RANGE (`capgoaledatta`)
+(PARTITION p0 VALUES LESS THAN MAXVALUE);
+
+ALTER TABLE t2_c
+PARTITION BY LIST(`capgotod`)
+(PARTITION p0 VALUES IN (0,1,2,3,4,5,6));
+
+ALTER TABLE t3_c
+PARTITION BY HASH (`CapGoaledatta`);
+
+ALTER TABLE t5_c
+PARTITION BY HASH (`capfa`)
+PARTITIONS 4;
+
+ALTER TABLE t6_c
+PARTITION BY LINEAR HASH (`relatta`)
+PARTITIONS 4;
+
+ALTER TABLE t7_c
+PARTITION BY LINEAR KEY (`dardtestard`);
+
+--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 $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;
+select count(*)
+ from (select * from t1 union
+ select * from t1_c) a;
+
+select count(*) from t2;
+select count(*) from t2_c;
+select count(*)
+ from (select * from t2 union
+ select * from t2_c) a;
+
+select count(*) from t3;
+select count(*) from t3_c;
+select count(*)
+ from (select * from t3 union
+ select * from t3_c) a;
+
+select count(*) from t4;
+select count(*) from t4_c;
+select count(*)
+ from (select * from t4 union
+ select * from t4_c) a;
+
+select count(*) from t5;
+select count(*) from t5_c;
+select count(*)
+ from (select * from t5 union
+ select * from t5_c) a;
+
+select count(*) from t6;
+select count(*) from t6_c;
+select count(*)
+ from (select * from t6 union
+ select * from t6_c) a;
+
+select count(*) from t7;
+select count(*) from t7_c;
+select count(*)
+ from (select * from t7 union
+ select * from t7_c) a;
+
+select count(*) from t8;
+select count(*) from t8_c;
+select count(*)
+ from (select * from t8 union
+ select * from t8_c) a;
+
+select count(*) from t9;
+select count(*) from t9_c;
+select count(*)
+ from (select * from t9 union
+ 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 $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;
+select count(*)
+ from (select * from t1 union
+ select * from t1_c) a;
+
+select count(*) from t2;
+select count(*) from t2_c;
+select count(*)
+ from (select * from t2 union
+ select * from t2_c) a;
+
+select count(*) from t3;
+select count(*) from t3_c;
+select count(*)
+ from (select * from t3 union
+ select * from t3_c) a;
+
+select count(*) from t4;
+select count(*) from t4_c;
+select count(*)
+ from (select * from t4 union
+ select * from t4_c) a;
+
+select count(*) from t5;
+select count(*) from t5_c;
+select count(*)
+ from (select * from t5 union
+ select * from t5_c) a;
+
+select count(*) from t6;
+select count(*) from t6_c;
+select count(*)
+ from (select * from t6 union
+ select * from t6_c) a;
+
+select count(*) from t7;
+select count(*) from t7_c;
+select count(*)
+ from (select * from t7 union
+ select * from t7_c) a;
+
+select count(*) from t8;
+select count(*) from t8_c;
+select count(*)
+ from (select * from t8 union
+ select * from t8_c) a;
+
+select count(*) from t9;
+select count(*) from t9_c;
+select count(*)
+ from (select * from t9 union
+ select * from t9_c) a;
+
+#
+# Drop all table except t2_c
+# This to make sure that error returned from ndb_restore above is
+# guaranteed to be from t2_c, this since order of tables in backup
+# is none deterministic
+#
+drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
+--source include/ndb_backup.inc
+--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
+#
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+drop table if exists t2_c;
+--enable_warnings
+
+#
+# Test BUG#10287
+#
+
+--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 6e5ea515710..5056a7f9b91 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -10,6 +10,59 @@ drop table if exists t1;
--enable_warnings
#
+# Bug 19309 Partitions: Crash if double procedural alter
+#
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+
+create procedure pz()
+alter table t1 engine = myisam;
+
+call pz();
+call pz();
+drop procedure pz;
+drop table t1;
+
+#
+# Bug 19307: CSV engine crashes
+#
+--error ER_PARTITION_MERGE_ERROR
+create table t1 (a int)
+engine = csv
+partition by list (a)
+(partition p0 values in (null));
+
+#
+# BUG 16002: Handle unsigned integer functions properly
+#
+--error 1064
+create table t1 (a bigint)
+partition by range (a)
+(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
+ partition p1 values less than (10));
+--error 1064
+create table t1 (a bigint)
+partition by list (a)
+(partition p0 values in (0xFFFFFFFFFFFFFFFF),
+ partition p1 values in (10));
+
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (100),
+ partition p1 values less than MAXVALUE);
+insert into t1 values (1);
+drop table t1;
+
+create table t1 (a bigint unsigned)
+partition by hash (a);
+insert into t1 values (0xFFFFFFFFFFFFFFFD);
+insert into t1 values (0xFFFFFFFFFFFFFFFE);
+select * from t1 where (a + 1) < 10;
+select * from t1 where (a + 1) > 10;
+drop table t1;
+
+#
# Bug 19307: CSV engine crashes
#
--error ER_PARTITION_MERGE_ERROR
@@ -19,6 +72,7 @@ partition by list (a)
(partition p0 values in (null));
#
+# Added test case
#
create table t1 (a int)
partition by key(a)
@@ -913,6 +967,12 @@ create table t1 (f1 smallint)
partition by list (f1) (partition p0 values in (null));
insert into t1 values (null);
select * from t1 where f1 is null;
+select * from t1 where f1 < 1;
+select * from t1 where f1 <= NULL;
+select * from t1 where f1 < NULL;
+select * from t1 where f1 >= NULL;
+select * from t1 where f1 > NULL;
+select * from t1 where f1 > 1;
drop table t1;
create table t1 (f1 smallint)
@@ -980,6 +1040,23 @@ SHOW TABLE STATUS;
DROP TABLE t1;
#
+#BUG 16002 Erroneus handling of unsigned partition functions
+#
+--error ER_PARTITION_CONST_DOMAIN_ERROR
+create table t1 (a bigint unsigned)
+partition by list (a)
+(partition p0 values in (0-1));
+
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (10));
+
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (0xFFFFFFFFFFFFFFFF);
+
+drop table t1;
+
+#
#BUG 18750 Problems with partition names
#
create table t1 (a int)
@@ -1140,4 +1217,42 @@ alter table t1 drop partition p2;
use test;
drop database db99;
+#
+#BUG 17138 Problem with stored procedure and analyze partition
+#
+--disable_warnings
+drop procedure if exists mysqltest_1;
+--enable_warnings
+
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (0));
+
+insert into t1 values (0);
+delimiter //;
+
+create procedure mysqltest_1 ()
+begin
+ begin
+ declare continue handler for sqlexception begin end;
+ update ignore t1 set a = 1 where a = 0;
+ end;
+ prepare stmt1 from 'alter table t1';
+ execute stmt1;
+end//
+
+call mysqltest_1()//
+delimiter ;//
+drop table t1;
+drop procedure mysqltest_1;
+
+#
+# Bug 20583 Partitions: Crash using index_last
+#
+create table t1 (a int, index(a))
+partition by hash(a);
+insert into t1 values (1),(2);
+select * from t1 ORDER BY a DESC;
+drop table t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 659f0b8cef4..d0e3f355292 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -9,6 +9,24 @@ drop table if exists t1;
--enable_warnings
#
+# Bug 20397: Partitions: Crash when using non-existing engine
+#
+create table t1 (a int)
+engine = x
+partition by key (a);
+show create table t1;
+drop table t1;
+
+create table t1 (a int)
+engine = innodb
+partition by list (a)
+(partition p0 values in (0));
+
+alter table t1 engine = x;
+show create table t1;
+drop table t1;
+
+#
# Partition by key stand-alone error
#
--error 1064
@@ -89,6 +107,8 @@ partitions 3
(partition x1 tablespace ts1,
partition x2 tablespace ts2,
partition x3 tablespace ts3);
+
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, invalid field in function
#
@@ -184,6 +204,7 @@ partition by hash (a)
partitions 2
(partition x1 values less than (4),
partition x2 values less than (5));
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, values in error
@@ -198,6 +219,7 @@ partition by hash (a)
partitions 2
(partition x1 values in (4),
partition x2 values in (5));
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by hash, values in error
@@ -212,6 +234,7 @@ partition by hash (a)
partitions 2
(partition x1 values in (4,6),
partition x2 values in (5,7));
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, single field
@@ -224,6 +247,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, list of fields
@@ -236,6 +260,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined
@@ -248,6 +273,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, single field
@@ -260,6 +286,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by key, no partitions defined, list of fields
@@ -272,6 +299,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by key (a, b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined
@@ -284,6 +312,7 @@ c int not null,
primary key (a,b))
partition by key (a)
subpartition by hash (a+b);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
@@ -310,6 +339,7 @@ partition by key (a)
subpartition by hash (sin(a+b))
(partition x1 (subpartition x11, subpartition x12),
partition x2 (subpartition x21, subpartition x22));
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
@@ -338,6 +368,7 @@ partition by range (a)
subpartition by key (a,d)
(partition x1 values less than (1) (subpartition x11, subpartition x12),
partition x2 values less than (2) (subpartition x21, subpartition x22));
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
@@ -375,6 +406,7 @@ b int not null,
c int not null,
primary key(a,b))
partition by range (a);
+select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par');
#
# Partition by range, invalid field in function
@@ -748,6 +780,10 @@ CREATE TABLE t1(a int)
insert into t1 values (10);
drop table t1;
+--error ER_PARTITION_CONST_DOMAIN_ERROR
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (-1));
#
# Bug 18198 Partitions: Verify that erroneus partition functions doesn't work
#
@@ -775,3 +811,5 @@ partition by range (a + (select count(*) from t1))
-- error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
create table t1 (a char(10))
partition by hash (extractvalue(a,'a'));
+
+
diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test
index 3e0eaa45f32..e243ec468e1 100644
--- a/mysql-test/t/partition_list.test
+++ b/mysql-test/t/partition_list.test
@@ -124,3 +124,15 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
SELECT COUNT(*) FROM t1 WHERE s1 < 3;
DROP TABLE t1;
+#
+# Bug 19281 Partitions: Auto-increment value lost
+#
+create table t1 (a int auto_increment primary key)
+auto_increment=100
+partition by list (a)
+(partition p0 values in (1, 100));
+create index inx on t1 (a);
+insert into t1 values (null);
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test
index 67c0619f28c..cfb76192de4 100644
--- a/mysql-test/t/partition_mgm.test
+++ b/mysql-test/t/partition_mgm.test
@@ -1,3 +1,4 @@
+-- source include/have_partition.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
@@ -5,10 +6,12 @@ CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1;
-#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
+--replace_result $MYSQLTEST_VARDIR "hello"
+--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1;
-#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
+--replace_result $MYSQLTEST_VARDIR "hello"
+--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test
index 42ce4e0d879..8e1e2e72e69 100644
--- a/mysql-test/t/partition_range.test
+++ b/mysql-test/t/partition_range.test
@@ -389,6 +389,31 @@ SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31';
DROP TABLE t1;
#
+# BUG 16002: Unsigned partition functions not handled correctly
+#
+--error ER_RANGE_NOT_INCREASING_ERROR
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (10),
+ partition p1 values less than (0));
+
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (0),
+ partition p1 values less than (10));
+show create table t1;
+drop table t1;
+
+create table t1 (a bigint unsigned)
+partition by range (a)
+(partition p0 values less than (2),
+ partition p1 values less than (10));
+show create table t1;
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (0xFFFFFFFFFFFFFFFF);
+drop table t1;
+
+#
# BUG 18962 Errors in DROP PARTITION
#
create table t1 (a int)
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 79bb09605fe..5e5211ffa09 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -325,11 +325,12 @@ execute stmt4;
# That is the reason why, we switch the output here off.
# (The real output will be tested in ps_6bdb.test)
--disable_warnings
+prepare stmt4 from ' show engine bdb logs ';
+--enable_warnings
--disable_result_log
prepare stmt4 from ' show engine bdb logs ';
execute stmt4;
--enable_result_log
---enable_warnings
prepare stmt4 from ' show grants for user ';
--error 1295
prepare stmt4 from ' show create table t2 ';
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index e2ff20e6ecc..2c94fe63c04 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -765,6 +765,9 @@ drop table t1;
create table t1 (a int);
insert into t1 values (1),(2);
+--disable_warnings
+drop procedure if exists p1;
+--enable_warnings
delimiter //;
CREATE PROCEDURE `p1`()
begin
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index f6493bac244..d1ce1104322 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -370,7 +370,7 @@ insert into t2(uid, name) values
(25, CHAR(64+25)),
(26, CHAR(64+26));
-insert into t1(uid, name) select uid, name from t2;
+insert into t1(uid, name) select uid, name from t2 order by uid;
delete from t2;
insert into t2(id, uid, name) select id, uid, name from t1;
diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test
index 5cfb2ce0c12..1e71adb3bf3 100644
--- a/mysql-test/t/renamedb.test
+++ b/mysql-test/t/renamedb.test
@@ -16,3 +16,11 @@ select database();
show tables;
select a from t1 order by a;
drop database testdb2;
+
+#
+# Bug#19392 Rename Database: Crash if case change
+#
+create database testdb1;
+--error 1007
+rename database testdb1 to testdb1;
+drop database testdb1;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index 10703eaafb8..269854fb180 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -35,3 +35,13 @@ select * from t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
+#
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1 WHERE f1 = 0 WITH CHECK OPTION;
+--error 1369
+REPLACE INTO v1 (f1) VALUES (1);
+DROP TABLE t1;
+DROP VIEW v1;
diff --git a/mysql-test/t/rpl_auto_increment_11932.test b/mysql-test/t/rpl_auto_increment_11932.test
new file mode 100644
index 00000000000..d4b7872fb2b
--- /dev/null
+++ b/mysql-test/t/rpl_auto_increment_11932.test
@@ -0,0 +1,63 @@
+#
+# Test of auto_increment
+# BUG#11932
+#
+# Bug reported that master and slave get out of sync after TRUNCATE
+# TABLE.
+#
+# Test supplied by Are Casilla
+
+source include/master-slave.inc;
+--disable_warnings
+connection master;
+drop database if exists test1;
+--enable_warnings
+create database test1;
+use test1;
+
+CREATE TABLE `t1` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `fname` varchar(100) default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
+
+INSERT INTO `t1` VALUES (1, 'blablabla');
+
+CREATE TABLE `t2` (
+ `id` int(10) NOT NULL auto_increment,
+ `comment` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=3 ;
+
+INSERT INTO `t2` VALUES (1, 'testtest 1');
+INSERT INTO `t2` VALUES (2, 'test 2');
+
+DELIMITER $;
+CREATE PROCEDURE simpleproc3 ()
+ NOT DETERMINISTIC
+ BEGIN
+ INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
+ INSERT INTO t1 (fname) VALUES('test');
+ END
+ $
+DELIMITER ;$
+
+CALL simpleproc3();
+
+select * from t2;
+
+TRUNCATE TABLE `t1`;
+CALL simpleproc3();
+
+select * from t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+use test1;
+select * from t1;
+
+drop database test1;
+connection master;
+drop database test1;
diff --git a/mysql-test/t/rpl_ndb_auto_inc.test b/mysql-test/t/rpl_ndb_auto_inc.test
index a9cc9563d88..0fc31de9b3a 100644
--- a/mysql-test/t/rpl_ndb_auto_inc.test
+++ b/mysql-test/t/rpl_ndb_auto_inc.test
@@ -6,7 +6,8 @@
# Date: 2006-02-10
# Change: Augmented test to use with cluster
#####################################
--- source include/master-slave.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_mixed_or_row.inc
--echo ***************** Test 1 ************************
--echo
diff --git a/mysql-test/t/rpl_ndb_dd_partitions.test b/mysql-test/t/rpl_ndb_dd_partitions.test
new file mode 100644
index 00000000000..9291f38e8db
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_dd_partitions.test
@@ -0,0 +1,310 @@
+#######################################
+# Author: JBM #
+# Date: 2006-03-09 #
+# Purpose: To test the replication of #
+# Cluster Disk Data using partitions #
+#######################################
+
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+--echo --- Doing pre test cleanup ---
+
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_query_log
+
+
+# Start by creating a logfile group
+##################################
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+###################################################
+# Create a tablespace connected to the logfile group
+###################################################
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+#################################################################
+
+--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(63),
+ bc CHAR(63), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ TABLESPACE ts1 STORAGE DISK
+ 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);
+
+--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 VARCHAR(255);
+
+--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 ---
+#################################################
+
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63),
+ bc CHAR(63), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ TABLESPACE ts1 STORAGE DISK
+ ENGINE=NDB
+ 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 VARCHAR(255);
+
+--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 ---
+#################################################
+
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63),
+ bc CHAR(63), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ TABLESPACE ts1 STORAGE DISK
+ ENGINE=NDB
+ 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 VARCHAR(255);
+
+--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 ---
+
+#################################################
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63),
+ bc CHAR(63), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE,PRIMARY KEY(id))
+ TABLESPACE ts1 STORAGE DISK
+ ENGINE=NDB
+ 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 VARCHAR(255);
+
+--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;
+alter tablespace ts1
+drop datafile 'datafile.dat'
+engine=ndb;
+alter tablespace ts1
+drop datafile 'datafile02.dat'
+engine=ndb;
+DROP TABLESPACE ts1 ENGINE=NDB;
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+--sync_slave_with_master
+
+# End of 5.1 test case
diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test
index 00ae5c935bf..313e22193f5 100644
--- a/mysql-test/t/rpl_openssl.test
+++ b/mysql-test/t/rpl_openssl.test
@@ -1,3 +1,7 @@
+# TODO: THIS TEST DOES NOT WORK ON WINDOWS
+# This should be fixed.
+--source include/not_windows.inc
+
source include/have_openssl.inc;
source include/master-slave.inc;
diff --git a/mysql-test/t/rpl_rbr_to_sbr.test b/mysql-test/t/rpl_rbr_to_sbr.test
index f04caf05057..c10199f8ff5 100644
--- a/mysql-test/t/rpl_rbr_to_sbr.test
+++ b/mysql-test/t/rpl_rbr_to_sbr.test
@@ -1,3 +1,4 @@
+-- source include/have_row_based.inc
-- source include/have_binlog_format_statement.inc
-- source include/master-slave.inc
diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test
index 3a686ea6b3d..af7e9af4005 100644
--- a/mysql-test/t/rpl_row_basic_11bugs.test
+++ b/mysql-test/t/rpl_row_basic_11bugs.test
@@ -2,6 +2,8 @@
--source include/have_binlog_format_row.inc
+let $SERVER_VERSION=`select version()`;
+
#This test case is not written for NDB, the result files
#will not match when NDB is the default engine
-- source include/not_ndb_default.inc
@@ -36,3 +38,19 @@ USE test_ignore;
connection master;
DROP DATABASE test_ignore;
sync_slave_with_master;
+
+# Bug#19995: Extreneous table maps generated for statements that does
+# not generate rows
+--disable_query_log
+--source include/master-slave-reset.inc
+--enable_query_log
+
+connection master;
+CREATE TABLE t1 (a INT);
+DELETE FROM t1;
+INSERT INTO t1 VALUES (1),(2);
+DELETE FROM t1 WHERE a = 0;
+UPDATE t1 SET a=99 WHERE a = 0;
+--replace_result $SERVER_VERSION SERVER_VERSION
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
diff --git a/mysql-test/t/rpl_row_basic_8partition.test b/mysql-test/t/rpl_row_basic_8partition.test
index 8cad2226d4a..640a420c10e 100644
--- a/mysql-test/t/rpl_row_basic_8partition.test
+++ b/mysql-test/t/rpl_row_basic_8partition.test
@@ -7,6 +7,7 @@
# partition tables with same engine (MyISAM) in both ends. #
############################################################
+--source include/have_row_based.inc
--source include/have_partition.inc
--source include/master-slave.inc
connection master;
diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test
index 0cb0fd766a3..a42089441d2 100644
--- a/mysql-test/t/rpl_row_create_table.test
+++ b/mysql-test/t/rpl_row_create_table.test
@@ -67,7 +67,7 @@ connection master;
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
# Shouldn't be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1326;
+SHOW BINLOG EVENTS FROM 1256;
# Test that INSERT-SELECT works the same way as for SBR.
CREATE TABLE t7 (a INT, b INT UNIQUE);
@@ -76,7 +76,7 @@ INSERT INTO t7 SELECT a,b FROM tt3;
SELECT * FROM t7 ORDER BY a,b;
# Should be written to the binary log
--replace_regex /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1326;
+SHOW BINLOG EVENTS FROM 1118;
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a,b;
@@ -87,7 +87,7 @@ BEGIN;
INSERT INTO t7 SELECT a,b FROM tt4;
ROLLBACK;
--replace_regex /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1522;
+SHOW BINLOG EVENTS FROM 1314;
SELECT * FROM t7 ORDER BY a,b;
sync_slave_with_master;
SELECT * FROM t7 ORDER BY a,b;
@@ -101,7 +101,7 @@ CREATE TEMPORARY TABLE tt6 LIKE tt4;
--query_vertical SHOW CREATE TABLE t8
--query_vertical SHOW CREATE TABLE t9
--replace_regex /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1618;
+SHOW BINLOG EVENTS FROM 1410;
sync_slave_with_master;
--echo **** On Slave ****
--query_vertical SHOW CREATE TABLE t8
diff --git a/mysql-test/t/rpl_row_inexist_tbl-slave.opt b/mysql-test/t/rpl_row_inexist_tbl-slave.opt
new file mode 100644
index 00000000000..abd717f8222
--- /dev/null
+++ b/mysql-test/t/rpl_row_inexist_tbl-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.t2
diff --git a/mysql-test/t/rpl_row_inexist_tbl.test b/mysql-test/t/rpl_row_inexist_tbl.test
index e77ea216571..741cc8b7ba3 100644
--- a/mysql-test/t/rpl_row_inexist_tbl.test
+++ b/mysql-test/t/rpl_row_inexist_tbl.test
@@ -6,15 +6,23 @@ source include/master-slave.inc;
connection master;
create table t1 (a int not null primary key);
+insert into t1 values (1);
+create table t2 (a int);
+insert into t2 values (1);
+update t1, t2 set t1.a = 0 where t1.a = t2.a;
+
sync_slave_with_master;
+# t2 should not have been replicated
+# t1 should have been properly updated
+show tables;
+select * from t1;
drop table t1;
connection master;
insert into t1 values (1);
-insert into t1 values (2);
connection slave;
-# slave should have stopped because can't find table
+# slave should have stopped because can't find table t1
wait_for_slave_to_stop;
# see if we have a good error message:
--replace_result $MASTER_MYPORT MASTER_MYPORT
@@ -24,4 +32,4 @@ show slave status;
# cleanup
connection master;
-drop table t1;
+drop table t1, t2;
diff --git a/mysql-test/t/rpl_sp_effects.test b/mysql-test/t/rpl_sp_effects.test
index 40c9a5d0b74..e1746682b76 100644
--- a/mysql-test/t/rpl_sp_effects.test
+++ b/mysql-test/t/rpl_sp_effects.test
@@ -106,8 +106,8 @@ delete from t2;
# 4. VIEWs
delete from t1;
insert into t2 values(1),(2);
-create view v1 as select f1(a) from t2;
-select * from v1;
+create view v1 as select f1(a) as f from t2;
+select * from v1 order by f;
SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_truncate_2myisam.test b/mysql-test/t/rpl_truncate_2myisam.test
new file mode 100644
index 00000000000..1a2cb1d0fb3
--- /dev/null
+++ b/mysql-test/t/rpl_truncate_2myisam.test
@@ -0,0 +1,4 @@
+
+let $engine=MyISAM;
+--source extra/rpl_tests/rpl_truncate.test
+
diff --git a/mysql-test/t/rpl_truncate_3innodb.test b/mysql-test/t/rpl_truncate_3innodb.test
new file mode 100644
index 00000000000..7f3145feb1b
--- /dev/null
+++ b/mysql-test/t/rpl_truncate_3innodb.test
@@ -0,0 +1,5 @@
+
+--source include/have_innodb.inc
+
+let $engine=InnoDB;
+--source extra/rpl_tests/rpl_truncate.test
diff --git a/mysql-test/t/rpl_truncate_7ndb.test b/mysql-test/t/rpl_truncate_7ndb.test
new file mode 100644
index 00000000000..2921e7df45a
--- /dev/null
+++ b/mysql-test/t/rpl_truncate_7ndb.test
@@ -0,0 +1,69 @@
+
+--source include/have_ndb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_mixed_or_row.inc
+
+--disable_query_log
+--disable_warnings
+connection slave;
+STOP SLAVE;
+connection master;
+DROP TABLE IF EXISTS t1;
+RESET MASTER;
+connection slave;
+DROP TABLE IF EXISTS t1;
+RESET SLAVE;
+START SLAVE;
+--enable_warnings
+--enable_query_log
+
+--echo **** On Master ****
+connection master;
+CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,1), (2,2);
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Slave ****
+# This is silly, but NDB doesn't add to the binlog fast enough
+--real_sleep 10
+sync_slave_with_master;
+INSERT INTO t1 VALUE (3,3);
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Master ****
+connection master;
+TRUNCATE TABLE t1;
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Slave ****
+sync_slave_with_master;
+# Should be empty
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Master ****
+connection master;
+DROP TABLE t1;
+--replace_regex /\/\* xid=[0-9]+ \*\//\/* xid= *\// /table_id: [0-9]+/table_id: #/
+--replace_result $SERVER_VERSION SERVER_VERSION
+SHOW BINLOG EVENTS;
+
+--echo **** On Master ****
+connection master;
+CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,1), (2,2);
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Slave ****
+sync_slave_with_master;
+INSERT INTO t1 VALUE (3,3);
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Master ****
+connection master;
+DELETE FROM t1;
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Slave ****
+sync_slave_with_master;
+# Should be empty
+SELECT * FROM t1 ORDER BY a,b;
+--echo **** On Master ****
+connection master;
+DROP TABLE t1;
+--replace_regex /table_id: [0-9]+/table_id: #/
+--replace_result $SERVER_VERSION SERVER_VERSION
+SHOW BINLOG EVENTS;
+
diff --git a/mysql-test/t/rpl_truncate_7ndb_2-master.opt b/mysql-test/t/rpl_truncate_7ndb_2-master.opt
new file mode 100644
index 00000000000..01cf3e0520f
--- /dev/null
+++ b/mysql-test/t/rpl_truncate_7ndb_2-master.opt
@@ -0,0 +1 @@
+--binlog-format=mixed
diff --git a/mysql-test/t/rpl_truncate_7ndb_2.test b/mysql-test/t/rpl_truncate_7ndb_2.test
new file mode 100644
index 00000000000..4ee6c98d463
--- /dev/null
+++ b/mysql-test/t/rpl_truncate_7ndb_2.test
@@ -0,0 +1,6 @@
+# Same test as rpl_truncate_7ndb.test, but with mixed mode
+# This is marked with 'big_test' just because the rpl_truncate_7ndb test is
+# so slow...
+
+--source include/big_test.inc
+--source t/rpl_truncate_7ndb.test
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 8cd15463c62..b75d0dd8bb6 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2217,15 +2217,6 @@ show table status like 't1%';
select 123 as a from t1 where f1 is null;
drop table t1,t11;
-# Bug 7672 Unknown column error in order clause
-#
-CREATE TABLE t1 (a INT, b INT);
-(SELECT a, b AS c FROM t1) ORDER BY c+1;
-(SELECT a, b AS c FROM t1) ORDER BY b+1;
-SELECT a, b AS c FROM t1 ORDER BY c+1;
-SELECT a, b AS c FROM t1 ORDER BY b+1;
-drop table t1;
-
#
# Bug #3874 (function in GROUP and LEFT JOIN)
#
@@ -2265,6 +2256,21 @@ select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 fro
drop table t1,t2;
#
+# Bug #4981: 4.x and 5.x produce non-optimal execution path, 3.23 regression test failure
+#
+CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));
+insert into t1 values (1,0,0),(2,0,0);
+CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));
+insert into t2 values (1,'',''), (2,'','');
+CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
+insert into t3 values (1,1),(1,2);
+# must have "range checked" for t2
+explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
+ where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
+ t2.b like '%%' order by t2.b limit 0,1;
+DROP TABLE t1,t2,t3;
+
+#
# Bug #17873: confusing error message when IGNORE INDEX refers a column name
#
@@ -2279,49 +2285,26 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
-# End of 4.1 tests
-
#
-# Test case for bug 7098: substitution of a constant for a string field
+# Bug #18759 "Incorrect string to numeric conversion"
#
-
-CREATE TABLE t1 ( city char(30) );
-INSERT INTO t1 VALUES ('London');
-INSERT INTO t1 VALUES ('Paris');
-
-SELECT * FROM t1 WHERE city='London';
-SELECT * FROM t1 WHERE city='london';
-EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
-SELECT * FROM t1 WHERE city='London' AND city='london';
-EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
-SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
-
-DROP TABLE t1;
-
+# This test is here so that the behavior will not be changed to 4.1
+# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
+# will be converted internally to real (double) value and it is not
+# as accurate as bigint (longlong) for integers. Thus the results may
+# vary. In 5.1 internally it is decimal, which is a string type and
+# will be more accurate. Due to rather big changes needed to fix this
+# in 4.1 or 5.0 it is not desired to do it in the stable versions.
#
-# Bug#7425 inconsistent sort order on unsigned columns result of substraction
+# This test is here only to make sure that behavior is not changed in
+# 4.1 and 5.0
#
+CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
+INSERT INTO t1 VALUES (10);
+SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
+DROP TABLE t1;
-create table t1 (a int(11) unsigned, b int(11) unsigned);
-insert into t1 values (1,0), (1,1), (1,2);
-select a-b from t1 order by 1;
-select a-b , (a-b < 0) from t1 order by 1;
-select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
-select cast((a - b) as unsigned) from t1 order by 1;
-drop table t1;
-
-
-#
-# Bug#8733 server accepts malformed query (multiply mentioned distinct)
-#
-create table t1 (a int(11));
-select all all * from t1;
-select distinct distinct * from t1;
---error 1221
-select all distinct * from t1;
---error 1221
-select distinct all * from t1;
-drop table t1;
+# End of 4.1 tests
#
# Test for bug #6474
@@ -2358,21 +2341,6 @@ SELECT K2C4, K4N4, F2I4 FROM t1
DROP TABLE t1;
#
-# Test case for bug 7520: a wrong cost of the index for a BLOB field
-#
-
-CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
-CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
-
-INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
-INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
-
-EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
-EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
-
-DROP TABLE t1, t2;
-
-#
# Bug#8670
#
create table t1 (a int, b int);
@@ -2411,34 +2379,6 @@ drop table t1;
#
-# Bug#8733 server accepts malformed query (multiply mentioned distinct)
-#
-create table t1 (a int(11));
-select all all * from t1;
-select distinct distinct * from t1;
---error 1221
-select all distinct * from t1;
---error 1221
-select distinct all * from t1;
-drop table t1;
-
-
-#
-# Test case for bug 7520: a wrong cost of the index for a BLOB field
-#
-
-CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
-CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
-
-INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
-INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
-
-EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
-EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
-
-DROP TABLE t1, t2;
-
-#
# Test for bug #10084: STRAIGHT_JOIN with ON expression
#
@@ -2935,3 +2875,29 @@ EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0;
DROP TABLE t1, t2;
+
+#
+# Bug #18895: BIT values cause joins to fail
+#
+create table t1 (
+ a int unsigned not null auto_increment primary key,
+ b bit not null,
+ c bit not null
+);
+
+create table t2 (
+ a int unsigned not null auto_increment primary key,
+ b bit not null,
+ c int unsigned not null,
+ d varchar(50)
+);
+
+insert into t1 (b,c) values (0,1), (0,1);
+insert into t2 (b,c) values (0,1);
+
+-- Row 1 should succeed. Row 2 should fail. Both fail.
+select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d
+from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1
+where t1.b <> 1 order by t1.a;
+
+drop table t1,t2;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index a7b24a5e06c..94894ef50de 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -255,9 +255,9 @@ delete from t2 where b=3;
delete from t3 where a=3;
--replace_column 6 # 7 # 8 # 9 # 10 #
show table status;
-delete from t1;
-delete from t2;
-delete from t3;
+truncate table t1;
+truncate table t2;
+truncate table t3;
--replace_column 6 # 7 # 8 # 9 #
show table status;
insert into t1 values (5);
@@ -445,4 +445,17 @@ delete from mysql.tables_priv where user='mysqltest_4';
flush privileges;
drop database mysqltest;
+#
+# Ensure that show plugin code is tested
+#
+
+--disable_result_log
+show full plugin;
+--enable_result_log
+show warnings;
+--disable_result_log
+show plugin;
+show plugins;
+--enable_result_log
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index c9ce26b6dda..24b0d4674c5 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -508,7 +508,7 @@ end|
insert into t1 values (666, 51.3)|
--error 1054
call bug2272()|
-delete from t1|
+truncate table t1|
drop procedure bug2272|
#
@@ -742,7 +742,7 @@ begin
fetch c into v;
end|
-delete from t1|
+truncate table t1|
--error ER_SP_FETCH_NO_DATA
call bug7299()|
drop procedure bug7299|
@@ -871,7 +871,7 @@ insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
select *,bug8408() from t1|
drop function bug8408|
-delete from t1|
+truncate table t1|
#
diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test
index 6287950d216..b94de6236d3 100644
--- a/mysql-test/t/sp-prelocking.test
+++ b/mysql-test/t/sp-prelocking.test
@@ -271,6 +271,35 @@ deallocate prepare stmt;
drop table t1;
drop view v1, v2, v3;
drop function bug15683;
+
+
#
-# End of 5.0 tests
+# Bug#19634 "Re-execution of multi-delete which involve trigger/stored
+# function crashes server"
#
+--disable_warnings
+drop table if exists t1, t2, t3;
+drop function if exists bug19634;
+--enable_warnings
+create table t1 (id int, data int);
+create table t2 (id int);
+create table t3 (data int);
+create function bug19634() returns int return (select count(*) from t3);
+prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id and bug19634()";
+# This should not crash server
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+create trigger t1_bi before delete on t1 for each row insert into t3 values (old.data);
+prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id";
+
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+drop function bug19634;
+drop table t1, t2, t3;
+
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 885d76ff3f9..201d362f2da 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -143,7 +143,7 @@ begin
end|
call setcontext()|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure setcontext|
@@ -287,7 +287,7 @@ create procedure inc(inout io int)
set io = io + 1|
call iotest("io1", "io2", 1)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure iotest|
drop procedure inc2|
@@ -333,7 +333,7 @@ begin
end|
call cbv1()|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure cbv1|
drop procedure cbv2|
@@ -371,7 +371,7 @@ call sub1("sub1b", (select max(i) from t2))|
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 * from t1 order by id|
select sub3((select max(i) from t2))|
drop procedure sub1|
drop procedure sub2|
@@ -392,7 +392,7 @@ while x do
end while|
call a0(3)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure a0|
@@ -408,7 +408,7 @@ while x > 0 do
end while|
call a(3)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure a|
@@ -424,7 +424,7 @@ repeat
until x = 0 end repeat|
call b(3)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure b|
@@ -456,7 +456,7 @@ hmm: while x > 0 do
end while hmm|
call c(3)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure c|
@@ -493,7 +493,7 @@ foo: loop
end loop foo|
call e(3)|
-select * from t1|
+select * from t1 order by data desc|
delete from t1|
drop procedure e|
@@ -514,7 +514,7 @@ end if|
call f(-2)|
call f(0)|
call f(4)|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure f|
@@ -536,7 +536,7 @@ end case|
call g(-42)|
call g(0)|
call g(1)|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure g|
@@ -558,7 +558,7 @@ end case|
call h(0)|
call h(1)|
call h(17)|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure h|
@@ -592,7 +592,7 @@ drop procedure if exists sel1|
--enable_warnings
create procedure sel1()
begin
- select * from t1;
+ select * from t1 order by data;
end|
call sel1()|
@@ -603,8 +603,8 @@ drop procedure if exists sel2|
--enable_warnings
create procedure sel2()
begin
- select * from t1;
- select * from t2;
+ select * from t1 order by data;
+ select * from t2 order by s;
end|
call sel2()|
@@ -624,7 +624,7 @@ begin
end|
call into_test("into", 100)|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure into_test|
@@ -641,7 +641,7 @@ begin
end|
call into_test2("into", 100)|
-select id,data,@z from t1|
+select id,data,@z from t1 order by data|
delete from t1|
drop procedure into_test2|
@@ -819,9 +819,9 @@ 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 i = mul(4,3) or i = mul(mul(3,4),2) order by i|
select * from t2 where d = e()|
-select * from t2|
+select * from t2 order by i|
--enable_ps_protocol
delete from t2|
@@ -976,8 +976,8 @@ 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 c1 cursor for select id,data from test.t1 order by id,data;
+ declare c2 cursor for select i from test.t2 order by i;
declare continue handler for sqlstate '02000' set done = 1;
open c1;
@@ -1003,7 +1003,7 @@ begin
end|
call cur2()|
-select * from t3|
+select * from t3 order by i,s|
delete from t1|
delete from t2|
drop table t3|
@@ -1178,13 +1178,13 @@ 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|
+select id, f1() from t1 order by id|
# 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)|
+ return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)|
select f2()|
-select id, f2() from t1|
+select id, f2() from t1 order by id|
# Function which uses the same table twice in different queries
create function f3() returns int
@@ -1196,17 +1196,17 @@ begin
return n < m;
end|
select f3()|
-select id, f3() from t1|
+select id, f3() from t1 order by id|
# Calling two functions using same table
select f1(), f3()|
-select id, f1(), f3() from t1|
+select id, f1(), f3() from t1 order by id|
# 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|
+select s, f4() from t2 order by s|
# Recursive functions which due to this recursion require simultaneous
# access to several instance of the same table won't work
@@ -1239,7 +1239,7 @@ end|
create function f7() returns int
return (select sum(data) from t1 where data <= f1())|
select f6()|
-select id, f6() from t1|
+select id, f6() from t1 order by id|
#
# Let us test how new locking work with views
@@ -1247,12 +1247,12 @@ select id, f6() from t1|
# The most trivial view
create view v1 (a) as select f1()|
select * from v1|
-select id, a from t1, v1|
+select id, a from t1, v1 order by id|
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 id, a from t1, v2 order by id|
select * from v1, v2|
# Nice example where the same view is used on
@@ -1297,7 +1297,7 @@ select *, f0() from v0|
lock tables t1 read, t1 as t11 read|
# These should work well
select f3()|
-select id, f3() from t1 as t11|
+select id, f3() from t1 as t11 order by id|
# Degenerate cases work too :)
select f0()|
select * from v0|
@@ -1407,8 +1407,8 @@ drop function f12_2|
drop view v0|
drop view v1|
drop view v2|
-delete from t1 |
-delete from t2 |
+truncate table t1 |
+truncate table t2 |
drop table t4|
# End of non-bug tests
@@ -1596,7 +1596,7 @@ call fib(3)|
select * from t3 order by f asc|
-delete from t3|
+truncate table t3|
# The original test, 20 levels, ran into memory limits on some machines
# and builds. Try 10 instead...
@@ -1693,7 +1693,6 @@ begin
end if;
return x;
end|
-
select * from t1 where data = getcount("bar")|
select * from t3|
select getcount("zip")|
@@ -2120,7 +2119,7 @@ delete from t1|
call bug822('foo', 42)|
call bug822('foo', 42)|
call bug822('bar', 666)|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure bug822|
@@ -2148,7 +2147,7 @@ delete from t1 where id='foo'|
insert into t1 values ('bar', 7)|
call bug1495()|
delete from t1 where id='bar'|
-select * from t1|
+select * from t1 order by data|
delete from t1|
drop procedure bug1495|
@@ -2173,7 +2172,7 @@ end|
insert into t1 values ("foo", 12), ("bar", 7)|
call bug1547("foo")|
call bug1547("bar")|
-select * from t1|
+select * from t1 order by id|
delete from t1|
drop procedure bug1547|
@@ -2240,7 +2239,7 @@ end|
insert into t1 (data) values (3), (1), (5), (9), (4)|
call bug1874()|
-select * from t2|
+select * from t2 order by i|
delete from t1|
delete from t2|
drop procedure bug1874|
@@ -5260,7 +5259,7 @@ call bug13012()|
call bug13012()|
drop procedure bug13012|
drop view v1;
-select * from t1|
+select * from t1 order by data|
#
# A test case for Bug#15392 "Server crashes during prepared statement
@@ -5652,7 +5651,7 @@ create procedure bug16474_1()
begin
declare x int;
- select id from t1 order by x;
+ select id from t1 order by x, id;
end|
#
@@ -5672,7 +5671,7 @@ drop procedure bug14945|
# This does NOT order by column index; variable is an expression.
create procedure bug16474_2(x int)
- select id from t1 order by x|
+ select id from t1 order by x, id|
call bug16474_1()|
call bug16474_2(1)|
@@ -5682,7 +5681,7 @@ drop procedure bug16474_2|
# For reference: user variables are expressions too and do not affect ordering.
set @x = 2|
-select * from t1 order by @x|
+select * from t1 order by @x, data|
delete from t1|
@@ -5877,6 +5876,33 @@ DROP FUNCTION bug18037_f1|
DROP PROCEDURE bug18037_p1|
DROP PROCEDURE bug18037_p2|
+#
+# Bug#15217 "Using a SP cursor on a table created with PREPARE fails with
+# weird error". Check that the code that is supposed to work at
+# the first execution of a stored procedure actually works for
+# sp_instr_copen.
+
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug15217|
+--enable_warnings
+create table t3 as select 1|
+create procedure bug15217()
+begin
+ declare var1 char(255);
+ declare cur1 cursor for select * from t3;
+ open cur1;
+ fetch cur1 into var1;
+ select concat('data was: /', var1, '/');
+ close cur1;
+end |
+# Returns expected result
+call bug15217()|
+flush tables |
+# Returns error with garbage as column name
+call bug15217()|
+drop table t3|
+drop procedure bug15217|
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
index b4225ef8c4e..8542c2b7927 100644
--- a/mysql-test/t/sql_mode.test
+++ b/mysql-test/t/sql_mode.test
@@ -258,6 +258,9 @@ drop table t1, t2;
select @@sql_mode;
set sql_mode=2097152;
select @@sql_mode;
+# BUG#14675
+set sql_mode=4194304;
+select @@sql_mode;
set sql_mode=16384+(65536*4);
select @@sql_mode;
--error 1231
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 1a71425d2a7..55f9d95adc5 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -48,6 +48,19 @@ connection default;
select 1;
show status like 'last_query_cost';
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+select * from t1 where a=6;
+show status like 'last_query_cost';
+# Ensure value dosn't change by second status call
+show status like 'last_query_cost';
+select 1;
+show status like 'last_query_cost';
+drop table t1;
#
# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
@@ -144,3 +157,24 @@ disconnect con2;
disconnect con1;
# End of 5.0 tests
+
+#
+# Ensure that SHOW STATUS only changes global status variables
+#
+
+connect (con1,localhost,root,,);
+let $rnd_next = `show global status like 'handler_read_rnd_next'`;
+let $tmp_table = `show global status like 'Created_tmp_tables'`;
+show status like 'com_show_status';
+show status like 'hand%write%';
+show status like '%tmp%';
+show status like 'hand%write%';
+show status like '%tmp%';
+show status like 'com_show_status';
+let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
+let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
+--disable_query_log
+eval select substring_index('$rnd_next2',0x9,-1)-substring_index('$rnd_next',0x9,-1) as rnd_diff, substring_index('$tmp_table2',0x9,-1)-substring_index('$tmp_table',0x9,-1) as tmp_table_diff;
+--enable_query_log
+
+# End of 5.1 tests
diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test
index bfc909d6995..bad1df554d9 100644
--- a/mysql-test/t/timezone2.test
+++ b/mysql-test/t/timezone2.test
@@ -69,7 +69,7 @@ set time_zone='UTC';
select * from t1;
-delete from t1;
+truncate table t1;
# Simple check for 'Europe/Moscow' time zone just for showing that it works
set time_zone='Europe/Moscow';
@@ -79,7 +79,7 @@ insert into t1 (i, ts) values
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
select * from t1;
-delete from t1;
+truncate table t1;
#
@@ -94,7 +94,7 @@ insert into t1 (i, ts) values
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
select * from t1;
-delete from t1;
+truncate table t1;
# Let us test leap jump
insert into t1 (i, ts) values
(unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
@@ -115,14 +115,14 @@ insert into t1 values ('0000-00-00 00:00:00'),('1969-12-31 23:59:59'),
('1970-01-01 00:00:00'),('1970-01-01 00:00:01'),
('2037-12-31 23:59:59'),('2038-01-01 00:00:00');
select * from t1;
-delete from t1;
+truncate table t1;
# MET time zone has range shifted by one hour
set time_zone='MET';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'),
('1970-01-01 01:00:00'),('1970-01-01 01:00:01'),
('2038-01-01 00:59:59'),('2038-01-01 01:00:00');
select * from t1;
-delete from t1;
+truncate table t1;
# same for +01:30 time zone
set time_zone='+01:30';
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'),
diff --git a/mysql-test/t/trigger-grant.test b/mysql-test/t/trigger-grant.test
index 8ca8ffe904b..6dd0c83dc92 100644
--- a/mysql-test/t/trigger-grant.test
+++ b/mysql-test/t/trigger-grant.test
@@ -151,8 +151,8 @@ INSERT INTO t1 VALUES(0);
# Cleanup for further tests.
DROP TRIGGER trg1;
-DELETE FROM t1;
-DELETE FROM t2;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
--disconnect wl2818_definer_con
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index a87f289e94e..58adffc6e87 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -185,24 +185,26 @@ select @log;
set @log:= "";
insert ignore t1 values (1, 2);
select @log;
-# REPLACE: before insert trigger should be called for both records,
-# but then for first one update will be executed (and both update
-# triggers should fire). For second after insert trigger will be
-# called as for usual insert
+# INSERT ... ON DUPLICATE KEY UPDATE ...
set @log:= "";
-replace t1 values (1, 3), (2, 2);
+insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
select @log;
-# Now let us change table in such way that REPLACE on won't be executed
-# using update.
-alter table t1 add ts timestamp default now();
+# REPLACE (also test for bug#13479 "REPLACE activates UPDATE trigger,
+# not the DELETE and INSERT triggers")
+# We define REPLACE as INSERT which DELETEs old rows which conflict with
+# row being inserted. So for the first record in statement below we will
+# call before insert trigger, then delete will be executed (and both delete
+# triggers should fire). Finally after insert trigger will be called.
+# For the second record we will just call both on insert triggers.
set @log:= "";
-# This REPLACE should be executed via DELETE and INSERT so proper
-# triggers should be invoked.
-replace t1 (id, data) values (1, 4);
+replace t1 values (1, 4), (3, 3);
select @log;
-# Finally let us test INSERT ... ON DUPLICATE KEY UPDATE ...
+# Now we will drop ON DELETE triggers to test REPLACE which is internally
+# executed via update
+drop trigger t1_bd;
+drop trigger t1_ad;
set @log:= "";
-insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2;
+replace t1 values (1, 5);
select @log;
# This also drops associated triggers
@@ -531,14 +533,11 @@ alter table t1 add primary key (i);
--error 1054
insert into t1 values (3, 4) on duplicate key update k= k + 10;
select * from t1;
+# The following statement will delete old row and won't
+# insert new one since after delete trigger will fail.
--error 1054
replace into t1 values (3, 3);
select * from t1;
-# Change table in such way that REPLACE will delete row
-alter table t1 add ts timestamp default now();
---error 1054
-replace into t1 (i, k) values (3, 13);
-select * from t1;
# Also drops all triggers
drop table t1, t2;
@@ -594,11 +593,6 @@ select * from t1;
--error 1054
replace into t1 values (2, 4);
select * from t1;
-# Change table in such way that REPLACE will delete row
-alter table t1 add ts timestamp default now();
---error 1054
-replace into t1 (i, k) values (2, 11);
-select * from t1;
# Also drops all triggers
drop table t1, t2;
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 4b6741b4242..f8953686c89 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -98,7 +98,7 @@ insert into t1 values
select * from t1;
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
-select * from t1;
+select * from t1 order by t;
drop table t1;
#
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 22f746d0220..404a26324ed 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1105,4 +1105,12 @@ insert into t1 values(123.12);
select * from t1;
alter table t1 modify a decimal(10,2);
select * from t1;
+
+#
+# Bug#19667 group by a decimal expression yields wrong result
+#
+create table t1 (i int, j int);
+insert into t1 values (1,1), (1,2), (2,3), (2,4);
+select i, count(distinct j) from t1 group by i;
+select i+0.0 as i2, count(distinct j) from t1 group by i2;
drop table t1;
diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test
index 03ee91f14d8..4a897c1e440 100644
--- a/mysql-test/t/type_ranges.test
+++ b/mysql-test/t/type_ranges.test
@@ -162,7 +162,7 @@ select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
select * from t3;
-delete from t3;
+truncate table t3;
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
drop table t3;
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index f96beedbebc..6873569d0e9 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -6,6 +6,9 @@
drop table if exists t1,t2;
--enable_warnings
+# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
+set time_zone="+03:00";
+
CREATE TABLE t1 (a int, t timestamp);
CREATE TABLE t2 (a int, t datetime);
SET TIMESTAMP=1234;
@@ -41,7 +44,7 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
select ix+0 from t1;
-delete from t1;
+truncate table t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000");
select ix+0 from t1;
drop table t1;
@@ -82,10 +85,10 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
select ix+0 from t1;
-delete from t1;
+truncate table t1;
insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
select ix+0 from t1;
-delete from t1;
+truncate table t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select ix+0 from t1;
drop table t1;
@@ -186,7 +189,7 @@ insert into t1 (t1) values (default);
select * from t1;
show create table t1;
show columns from t1;
-delete from t1;
+truncate table t1;
#
# Let us test some cases when auto-set should be disabled or influence
@@ -322,3 +325,6 @@ select * from t1;
drop table t1;
# End of 4.1 tests
+
+# Restore timezone to default
+set time_zone= @@global.time_zone;
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index e2556692612..f3be08c8537 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -99,6 +99,17 @@ delimiter ;//
call XXX2();
drop procedure xxx2;
+#
+# Bug#19904: UDF: not initialized *is_null per row
+#
+
+CREATE TABLE bug19904(n INT, v varchar(10));
+INSERT INTO bug19904 VALUES (1,'one'),(2,'two'),(NULL,NULL),(3,'three'),(4,'four');
+SELECT myfunc_double(n) AS f FROM bug19904;
+SELECT metaphon(v) AS f FROM bug19904;
+DROP TABLE bug19904;
+
+--echo End of 5.0 tests.
#
# Drop the example functions from udf_example
@@ -114,3 +125,4 @@ DROP FUNCTION lookup;
DROP FUNCTION reverse_lookup;
DROP FUNCTION avgcost;
+
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 692f1f509fa..7dfe4ac482f 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -793,3 +793,51 @@ select id from t1 union all select 99 order by 1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#18175: Union select over 129 tables with a sum function fails.
+#
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1)) union
+(select avg(1)) union (select avg(1)) union (select avg(1));
+
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 0db97f6d4af..b432a4c39ca 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1035,18 +1035,18 @@ create table t2 (a int);
insert into t2 values (2),(3),(0);
# INSERT SELECT with ignore test
insert ignore into v1 SELECT a from t2;
-select * from t1;
+select * from t1 order by a desc;
#simple UPDATE test
update v1 set a=-1 where a=0;
-- error 1369
update v1 set a=2 where a=1;
-select * from t1;
+select * from t1 order by a desc;
# prepare data for next check
update v1 set a=0 where a=0;
insert into t2 values (1);
# multiupdate test
update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a;
-select * from t1;
+select * from t1 order by a desc;
# prepare data for next check
update v1 set a=a+1;
# multiupdate with ignore test
@@ -1226,8 +1226,8 @@ select * from t1;
select * from v1;
delete from t1;
load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
-select * from t1;
-select * from v1;
+select * from t1 order by a,b;
+select * from v1 order by a,b;
drop view v1;
drop table t1;
# variable length fields
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index aa420689149..801bd13fab7 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -813,3 +813,62 @@ SELECT * FROM v;
DROP VIEW v;
DROP TABLE t1;
USE test;
+
+#
+# Bug#20363: Create view on just created view is now denied
+#
+eval CREATE USER mysqltest_db1@localhost identified by 'PWD';
+eval GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION;
+
+# The session with the non root user is needed.
+--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
+connect (session1,localhost,mysqltest_db1,PWD,test);
+
+CREATE SCHEMA mysqltest_db1 ;
+USE mysqltest_db1 ;
+
+CREATE TABLE t1 (f1 INTEGER);
+
+CREATE VIEW view1 AS
+SELECT * FROM t1;
+SHOW CREATE VIEW view1;
+
+CREATE VIEW view2 AS
+SELECT * FROM view1;
+--echo # Here comes a suspicious warning
+SHOW CREATE VIEW view2;
+--echo # But the view view2 is usable
+SELECT * FROM view2;
+
+CREATE VIEW view3 AS
+SELECT * FROM view2;
+
+SELECT * from view3;
+
+connection default;
+DROP VIEW mysqltest_db1.view3;
+DROP VIEW mysqltest_db1.view2;
+DROP VIEW mysqltest_db1.view1;
+DROP TABLE mysqltest_db1.t1;
+DROP SCHEMA mysqltest_db1;
+DROP USER mysqltest_db1@localhost;
+#
+# BUG#20482: failure on Create join view with sources views/tables
+# in different schemas
+#
+--disable_warnings
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+--enable_warnings
+
+CREATE TABLE test1.t0 (a VARCHAR(20));
+CREATE TABLE test2.t1 (a VARCHAR(20));
+CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
+CREATE OR REPLACE VIEW test.v1 AS
+ SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
+
+DROP VIEW test.v1;
+DROP VIEW test2.t3;
+DROP TABLE test2.t1, test1.t0;
+DROP DATABASE test2;
+DROP DATABASE test1;
diff --git a/mysql-test/t/wait_for_process.sh b/mysql-test/t/wait_for_process.sh
new file mode 100755
index 00000000000..df0f4a17e3a
--- /dev/null
+++ b/mysql-test/t/wait_for_process.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+###########################################################################
+
+pid_path="$1"
+total_attempts="$2"
+event="$3"
+
+case "$3" in
+ started)
+ check_fn='check_started';
+ ;;
+
+ stopped)
+ check_fn='check_stopped';
+ ;;
+
+ *)
+ echo "Error: invalid third argument ('started' or 'stopped' expected)."
+ exit 0
+esac
+
+###########################################################################
+
+check_started()
+{
+ [ ! -r "$pid_path" ] && return 1
+
+ new_pid=`cat "$pid_path" 2>/dev/null`
+
+ [ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1
+
+ return 0
+}
+
+###########################################################################
+
+check_stopped()
+{
+ [ -r "$pid_path" ] && return 1
+
+ return 0
+}
+
+###########################################################################
+
+cur_attempt=1
+
+while true; do
+
+ if ( eval $check_fn ); then
+ echo "Success: the process has been $event."
+ exit 0
+ fi
+
+ [ $cur_attempt -ge $total_attempts ] && break
+
+ sleep 1
+
+ cur_attempt=`expr $cur_attempt + 1`
+
+done
+
+echo "Error: the process has not been $event in $total_attempts secs."
+exit 0
+
diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test
index b17e5314d36..fef77f7cdc7 100644
--- a/mysql-test/t/wait_timeout.test
+++ b/mysql-test/t/wait_timeout.test
@@ -11,6 +11,7 @@
connect (wait_con,localhost,root,,test,,);
flush status; # Reset counters
connection wait_con;
+set session wait_timeout=100;
let $retries=300;
let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`;
set @aborted_clients= 0;
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 65d0a40291f..c20c4cbccc1 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -53,7 +53,7 @@ SELECT extractValue(@xml,'/a//@x');
SELECT extractValue(@xml,'/a//@x[1]');
SELECT extractValue(@xml,'/a//@x[2]');
-SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b>/a>';
+SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>';
SELECT extractValue(@xml,'//b[1]');
SELECT extractValue(@xml,'/descendant::b[1]');
@@ -299,6 +299,17 @@ select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
#
+# Bug#18201: XML: ExtractValue works even if the xml fragment
+# is not well-formed xml
+#
+select extractValue('<a>a','/a');
+select extractValue('<a>a<','/a');
+select extractValue('<a>a</','/a');
+select extractValue('<a>a</a','/a');
+select extractValue('<a>a</a></b>','/a');
+select extractValue('<a b=>a</a>','/a');
+
+#
# Bug #18171 XML: ExtractValue: the XPath position()
# function crashes the server!
#