summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-01-05 20:44:26 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-01-05 20:44:26 +0200
commit4ce579d27fc4bbebd38958359eadafdfeffaba21 (patch)
treeb043505a502bd8dc59e23a9593125ea849db674d /mysql-test
parent11b7dff5eba0923d520c58b951dd801394c7b053 (diff)
parent8049d2e9d98388296c86854d1291aa69afc78f44 (diff)
downloadmariadb-git-4ce579d27fc4bbebd38958359eadafdfeffaba21.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/view.result25
-rw-r--r--mysql-test/suite/rpl/r/sec_behind_master-5114.result5
-rw-r--r--mysql-test/suite/rpl/t/sec_behind_master-5114.test42
-rw-r--r--mysql-test/t/view.test22
4 files changed, 90 insertions, 4 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 78cb251ad11..f7968015d48 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -5848,6 +5848,31 @@ f1 f2
drop table t1, t2;
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
ERROR 42S22: Unknown column 'SOME_GARBAGE.b.a' in 'field list'
+#
+# MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
+# FOR UPDATE
+#
+CREATE TABLE t1 (a INT);
+insert into t1 values (1),(2);
+CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
+SHOW CREATE VIEW v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` for update latin1 latin1_swedish_ci
+select * from v1;
+a
+1
+2
+DROP VIEW v1;
+CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
+SHOW CREATE VIEW v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` lock in share mode latin1 latin1_swedish_ci
+select * from v1;
+a
+1
+2
+DROP VIEW v1;
+DROP TABLE t1;
# -----------------------------------------------------------------
# -- End of 10.0 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/suite/rpl/r/sec_behind_master-5114.result b/mysql-test/suite/rpl/r/sec_behind_master-5114.result
index 503f519cb4d..97e07a09f39 100644
--- a/mysql-test/suite/rpl/r/sec_behind_master-5114.result
+++ b/mysql-test/suite/rpl/r/sec_behind_master-5114.result
@@ -2,9 +2,12 @@ include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log");
CREATE TABLE t1 (a int);
+connection slave;
+connection master;
INSERT INTO t1 VALUES(SLEEP(2));
connection slave;
-Seconds_Behind_Master: 1
+Seconds_Behind_Master_is_less_than_100
+1
connection master;
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave
diff --git a/mysql-test/suite/rpl/t/sec_behind_master-5114.test b/mysql-test/suite/rpl/t/sec_behind_master-5114.test
index 8c70da4f0a8..ff8cab54c4f 100644
--- a/mysql-test/suite/rpl/t/sec_behind_master-5114.test
+++ b/mysql-test/suite/rpl/t/sec_behind_master-5114.test
@@ -3,24 +3,60 @@ source include/have_binlog_format_statement.inc;
call mtr.add_suppression("Unsafe statement written to the binary log");
+
+# Make sure that the start time of the first event is certainly different
+# from the next event
+--let $timestamp= `SELECT @@timestamp`
+--disable_query_log
+eval SET TIMESTAMP= $timestamp-100;
+--enable_query_log
CREATE TABLE t1 (a int);
+
+# Make sure that the slave is done with the first event, and all checks
+# that we'll perform later will be really against the second event
+sync_slave_with_master;
+
+connection master;
+
+# Restore the timestamp now. It doesn't matter that it's not precise,
+# it just needs to be very different from the earlier event
+--disable_query_log
+eval SET TIMESTAMP= $timestamp;
+--enable_query_log
+
send INSERT INTO t1 VALUES(SLEEP(2));
connection slave;
-let $run = 10;
+
+# When the slave starts executing the event, Seconds_Behind_Master
+# should start growing steadilly. The bugfix ensures that they are
+# calculated based on the start time of the current event, rather
+# than the start time of the previous event. To check it, we only need
+# the first non-zero value
+
+let $run = 20;
while ($run)
{
dec $run;
let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1);
# for debugging uncomment echo and remove the if()
- #echo Seconds_Behind_Master: $sbm;
+# echo Seconds_Behind_Master: $sbm;
if ($sbm)
{
let $run = 0;
}
sleep 0.5;
}
-echo Seconds_Behind_Master: $sbm;
+
+# Normally the first non-zero value should be 1. However, due to race
+# conditions on slow servers, sometimes the check might miss the value 1,
+# and only catch a higher one. It does not matter, we just need to make
+# sure it didn't start with 100+, as it would have with bug MDEV-5114
+
+--disable_query_log
+eval SELECT $sbm > 0 and $sbm < 99 AS Seconds_Behind_Master_is_less_than_100;
+--enable_query_log
+
connection master;
reap;
drop table t1;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index c3f462eab18..af509eb7b85 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -5702,6 +5702,28 @@ drop table t1, t2;
--error ER_BAD_FIELD_ERROR
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
+
+--echo #
+--echo # MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
+--echo # FOR UPDATE
+--echo #
+
+CREATE TABLE t1 (a INT);
+insert into t1 values (1),(2);
+
+CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
+SHOW CREATE VIEW v1;
+select * from v1;
+DROP VIEW v1;
+
+CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
+SHOW CREATE VIEW v1;
+select * from v1;
+DROP VIEW v1;
+
+DROP TABLE t1;
+
+
--echo # -----------------------------------------------------------------
--echo # -- End of 10.0 tests.
--echo # -----------------------------------------------------------------