summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorunknown <tsmith@quadxeon.mysql.com>2007-03-22 01:04:39 +0100
committerunknown <tsmith@quadxeon.mysql.com>2007-03-22 01:04:39 +0100
commitb636ad25c7cb672ec8559ff61cc19a0cee83fb05 (patch)
tree34885ae893c0a3acb95069f2687f5e289554a05c /mysql-test/t
parent9e6d54e4a5ddf0aae5b23a9b51507e7bb6b5d5f5 (diff)
parent8ed9a54008fae160d63dc27fa02b9ae4348238e7 (diff)
downloadmariadb-git-b636ad25c7cb672ec8559ff61cc19a0cee83fb05.tar.gz
Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1
into quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/51 include/my_global.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/help.result: Auto merged mysql-test/t/help.test: Auto merged sql/mysql_priv.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/events.test19
-rw-r--r--mysql-test/t/events_bugs.test11
-rw-r--r--mysql-test/t/events_logs_tests.test6
-rw-r--r--mysql-test/t/events_restart_phase1.test4
-rw-r--r--mysql-test/t/events_time_zone.test463
-rw-r--r--mysql-test/t/grant_cache.test26
-rw-r--r--mysql-test/t/help.test23
-rw-r--r--mysql-test/t/lock.test44
-rw-r--r--mysql-test/t/ndb_cache_multi2.test31
-rw-r--r--mysql-test/t/ps.test57
-rw-r--r--mysql-test/t/query_cache.test20
-rw-r--r--mysql-test/t/query_cache_sql_prepare.test144
-rw-r--r--mysql-test/t/skip_grants.test6
-rw-r--r--mysql-test/t/sp-error.test68
-rw-r--r--mysql-test/t/sp.test175
-rw-r--r--mysql-test/t/timezone2.test28
-rw-r--r--mysql-test/t/view.test32
17 files changed, 1147 insertions, 10 deletions
diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test
index 6eb514fc13c..24f4b4eccab 100644
--- a/mysql-test/t/events.test
+++ b/mysql-test/t/events.test
@@ -122,43 +122,62 @@ set names utf8;
# SHOW CREATE EVENT test begin
#
CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root6;
create event root7 on schedule every 2 year do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root7;
create event root8 on schedule every '2:5' year_month do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root8;
create event root8_1 on schedule every '2:15' year_month do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root8_1;
create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root9;
create event root10 on schedule every '20:5' day_hour do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root10;
create event root11 on schedule every '20:25' day_hour do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root11;
create event root12 on schedule every '20:25' hour_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root12;
create event root13 on schedule every '25:25' hour_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root13;
create event root13_1 on schedule every '11:65' hour_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root13_1;
create event root14 on schedule every '35:35' minute_second do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root14;
create event root15 on schedule every '35:66' minute_second do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root15;
create event root16 on schedule every '35:56' day_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root16;
create event root17 on schedule every '35:12:45' day_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root17;
create event root17_1 on schedule every '35:25:65' day_minute do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root17_1;
create event root18 on schedule every '35:12:45' hour_second do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root18;
create event root19 on schedule every '15:59:85' hour_second do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root19;
create event root20 on schedule every '50:20:12:45' day_second do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT root20;
set names cp1251;
create event ðóóò21 on schedule every '50:23:59:95' day_second COMMENT 'òîâà å 1251 êîìåíòàð' do select 1;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
SHOW CREATE EVENT ðóóò21;
insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND");
--error ER_NOT_SUPPORTED_YET
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index 0790999d720..c1016f1752b 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -45,10 +45,17 @@ create event e_55 on schedule at 99990101000000 do drop table t;
create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t;
--error ER_EVENT_ENDS_BEFORE_STARTS
create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t;
---error ER_EVENT_EXEC_TIME_IN_THE_PAST
+--error ER_WRONG_VALUE
create event e_55 on schedule at 10000101000000 do drop table t;
---error ER_EVENT_EXEC_TIME_IN_THE_PAST
+
+# For the purpose of backup we allow times in the past. Here, no
+# error will be given, but the event won't be created. One may think
+# of that as if the event was created, then it turned out it's in the
+# past, so it was dropped because of implicit ON COMPLETION NOT
+# PRESERVE.
create event e_55 on schedule at 20000101000000 do drop table t;
+show events;
+
--error ER_PARSE_ERROR
create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t;
--error ER_PARSE_ERROR
diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test
index 64ce4a5c3df..25b75f13f01 100644
--- a/mysql-test/t/events_logs_tests.test
+++ b/mysql-test/t/events_logs_tests.test
@@ -89,10 +89,12 @@ DROP EVENT long_event;
SET GLOBAL long_query_time=1;
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 2.5
+let $wait_timeout= 30;
+let $wait_condition= SELECT COUNT(*) = 1 FROM mysql.slow_log;
+--source include/wait_condition.inc
--echo "Check our table. Should see 2 rows"
SELECT * FROM slow_event_test;
---echo "Check slow log. Should see 1 row because 4 is over the threshold of 3 for GLOBAL, though under SESSION which is 10"
+--echo "Check slow log. Should see 1 row because 2 is over the threshold of 1 for GLOBAL, though under SESSION which is 10"
--replace_column 1 USER_HOST 2 SLEEPVAL
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
DROP EVENT long_event2;
diff --git a/mysql-test/t/events_restart_phase1.test b/mysql-test/t/events_restart_phase1.test
index 92783ddaef7..0a84f6c4966 100644
--- a/mysql-test/t/events_restart_phase1.test
+++ b/mysql-test/t/events_restart_phase1.test
@@ -14,6 +14,6 @@ create event abc3 on schedule every 1 second do insert into execution_log value(
--sleep 1.5
select name from execution_log;
-insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1');
-insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2');
+insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1','SYSTEM');
+insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2','SYSTEM');
--echo "Now we restart the server"
diff --git a/mysql-test/t/events_time_zone.test b/mysql-test/t/events_time_zone.test
new file mode 100644
index 00000000000..fff84c7a995
--- /dev/null
+++ b/mysql-test/t/events_time_zone.test
@@ -0,0 +1,463 @@
+# This test case is sensitive to execution timing. You may control
+# this sensitivity by the parameter below. Small values will result
+# in fast but more unstable execution, large values will improve
+# stability at the cost of speed. Basically, N is a number of seconds
+# to wait for operation to complete. Should be positive. Test runs
+# about 25*N seconds (it sleeps most of the time, so CPU speed is not
+# relevant).
+let $N = 5;
+
+--source include/big_test.inc
+
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_db1;
+--enable_warnings
+
+CREATE DATABASE mysqltest_db1;
+
+let $old_db= `SELECT DATABASE()`;
+USE mysqltest_db1;
+
+SET GLOBAL EVENT_SCHEDULER= OFF;
+
+
+#
+# BUG#16420: Events: timestamps become UTC
+# BUG#26429: SHOW CREATE EVENT is incorrect for an event that
+# STARTS NOW()
+# BUG#26431: Impossible to re-create an event from backup if its
+# STARTS clause is in the past
+# WL#3698: Events: execution in local time zone
+#
+
+SET @save_time_zone= @@TIME_ZONE;
+
+#----------------------------------------------------------------------
+
+# We will use a separate connection because SET TIMESTAMP will stop
+# the clock in that connection.
+
+connect (conn1, localhost, root, , mysqltest_db1);
+
+SET TIME_ZONE= '+00:00';
+SET TIMESTAMP= UNIX_TIMESTAMP('2005-12-31 23:58:59');
+
+
+# Test when event time zone is updated on ALTER EVENT.
+#
+
+CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+SHOW EVENTS;
+
+# Test storing and updating of the event time zone.
+#
+SET TIME_ZONE= '-01:00';
+ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:00';
+SHOW EVENTS;
+
+# This will update event time zone.
+SET TIME_ZONE= '+02:00';
+ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00'
+ ON COMPLETION PRESERVE DISABLE;
+SHOW EVENTS;
+
+# This will update event time zone.
+SET TIME_ZONE= '-03:00';
+ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY ENDS '2030-01-03 00:00:00'
+ ON COMPLETION PRESERVE DISABLE;
+SHOW EVENTS;
+
+# This will not update event time zone, as no time is being adjusted.
+SET TIME_ZONE= '+04:00';
+ALTER EVENT e1 DO SELECT 2;
+SHOW EVENTS;
+
+DROP EVENT e1;
+
+#----------------------------------------------------------------------
+
+# Create some events.
+SET TIME_ZONE='+05:00';
+CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
+ SELECT 1;
+
+SET TIMESTAMP= @@TIMESTAMP + 1;
+
+SET TIME_ZONE='-05:00';
+CREATE EVENT e2 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
+ SELECT 1;
+
+SET TIMESTAMP= @@TIMESTAMP + 1;
+
+SET TIME_ZONE='+00:00';
+CREATE EVENT e3 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
+ SELECT 1;
+
+
+# Test INFORMATION_SCHEMA.EVENTS.
+#
+
+SELECT * FROM INFORMATION_SCHEMA.EVENTS;
+
+
+# Test SHOW EVENTS.
+#
+
+SHOW EVENTS;
+
+
+# Test SHOW CREATE EVENT.
+#
+
+SHOW CREATE EVENT e1;
+SHOW CREATE EVENT e2;
+SHOW CREATE EVENT e3;
+
+#----------------------------------------------------------------------
+
+# Test times in the past.
+#
+
+--echo The following should fail, and nothing should be altered.
+
+--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST
+ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00';
+
+--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST
+ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' DISABLE;
+
+--echo The following should give warnings, and nothing should be created.
+
+CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00'
+DO
+ SELECT 1;
+
+CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' DISABLE
+DO
+ SELECT 1;
+
+CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO
+ SELECT 1;
+
+CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE
+DO
+ SELECT 1;
+
+SHOW EVENTS;
+
+--echo The following should succeed giving a warning.
+
+ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE;
+
+CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE
+DO
+ SELECT 1;
+
+CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00'
+ ON COMPLETION PRESERVE
+DO
+ SELECT 1;
+
+--echo The following should succeed without warnings.
+
+ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00';
+
+ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE;
+
+CREATE EVENT e6 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO
+ SELECT 1;
+
+CREATE EVENT e7 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
+ ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE
+DO
+ SELECT 1;
+
+CREATE EVENT e8 ON SCHEDULE AT '1999-01-01 00:00:00'
+ ON COMPLETION PRESERVE DISABLE
+DO
+ SELECT 1;
+
+SHOW EVENTS;
+
+
+DROP EVENT e8;
+DROP EVENT e7;
+DROP EVENT e6;
+DROP EVENT e5;
+DROP EVENT e4;
+DROP EVENT e3;
+DROP EVENT e2;
+DROP EVENT e1;
+
+
+disconnect conn1;
+connection default;
+
+#----------------------------------------------------------------------
+
+# Create rounding function.
+
+# Disable query log to hide actual value of $N.
+--disable_query_log
+eval SET @step= $N;
+--enable_query_log
+
+# Since we are working in a separate database, we may use any names we
+# like.
+CREATE TABLE t_step (step INT);
+INSERT INTO t_step VALUES (@step);
+
+# We can't use @variables in function, because it will be called from
+# the event thread, and 'eval' doesn't work for multi-statements, so
+# we can't interpolate $variables either, hence we fetch the step
+# value from the table.
+delimiter //;
+CREATE FUNCTION round_to_step(i INT, n INT) RETURNS INT
+BEGIN
+ DECLARE step INT;
+
+ SELECT * INTO step FROM t_step;
+
+ # We add 0.1 as a protection from inexact division.
+ RETURN FLOOR((i % (step * n) + 0.1) / step);
+END//
+delimiter ;//
+
+
+# Test time computations wrt Daylight Saving Time shifts. We also
+# test here that the event operates in its time zone (see what NOW()
+# returns).
+#
+
+# Create a fake time zone with time transitions every 3*$N second.
+
+SET @step3= @step * 3;
+SET @step6= @step * 6;
+
+# Disable query log to hide current time.
+--disable_query_log
+SET @unix_time= UNIX_TIMESTAMP() - 1;
+--enable_query_log
+
+SET @unix_time= @unix_time - @unix_time % @step6;
+
+INSERT INTO mysql.time_zone VALUES (NULL, 'N');
+SET @tzid= LAST_INSERT_ID();
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 0, 0, 0, 'b16420_0');
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 1, @step3 - @step, 1, 'b16420_1');
+
+let $transition_unix_time= `SELECT @unix_time`;
+let $count= 30;
+--disable_query_log
+while ($count)
+{
+ eval INSERT INTO mysql.time_zone_transition
+ VALUES (@tzid, $transition_unix_time,
+ $transition_unix_time % @step6 = 0);
+ let $transition_unix_time= `SELECT $transition_unix_time + @step3`;
+ dec $count;
+}
+--enable_query_log
+INSERT INTO mysql.time_zone_name VALUES ('bug16420', @tzid);
+
+CREATE TABLE t1 (count INT, unix_time INT, local_time INT, comment CHAR(80));
+CREATE TABLE t2 (count INT);
+INSERT INTO t2 VALUES (1);
+
+delimiter //;
+CREATE FUNCTION f1(comment CHAR(80)) RETURNS INT
+BEGIN
+ DECLARE orig_tz CHAR(64);
+ DECLARE unix_time INT;
+ DECLARE local_now DATETIME;
+ DECLARE utc_now DATETIME;
+ DECLARE local_time INT;
+
+ SET unix_time= UNIX_TIMESTAMP();
+ SET local_now= FROM_UNIXTIME(unix_time);
+ SET orig_tz= @@TIME_ZONE;
+ SET TIME_ZONE = '+00:00';
+ SET utc_now= FROM_UNIXTIME(unix_time);
+ SET TIME_ZONE= orig_tz;
+ SET local_time = unix_time + TIMESTAMPDIFF(SECOND, utc_now, local_now);
+
+ SET unix_time= round_to_step(unix_time, 6);
+ SET local_time= round_to_step(local_time, 6);
+
+ INSERT INTO t1 VALUES ((SELECT count FROM t2),
+ unix_time, local_time, comment);
+ RETURN 0;
+END//
+delimiter ;//
+
+SET TIME_ZONE= '+00:00';
+CREATE EVENT e1 ON SCHEDULE EVERY @step SECOND
+ STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e1>");
+
+SET TIME_ZONE= 'bug16420';
+CREATE EVENT e2 ON SCHEDULE EVERY @step SECOND
+ STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e2>");
+
+# We want to start at the beginning of the DST cycle, so we wait
+# untill current time divides by @step6.
+let $wait_timeout= `SELECT @step6 + 1`;
+let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = @step6 - 1;
+--source include/wait_condition.inc
+# The second wait is needed because after the first wait we may end up
+# on the ending edge of a second. Second wait will bring us to the
+# beginning edge.
+let $wait_timeout= `SELECT @step + 1`;
+let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = 0;
+--source include/wait_condition.inc
+
+# Note that after the scheduler is enabled, the event will be
+# scheduled only for the next second.
+SET GLOBAL EVENT_SCHEDULER= ON;
+
+# We want to run after the events are executed.
+SELECT SLEEP(@step / 2);
+
+let $count= 7;
+--disable_query_log
+--disable_result_log
+while ($count)
+{
+ SELECT SLEEP(@step);
+
+ eval SELECT CASE $count
+ WHEN 5 THEN f1(CONCAT("Second pass after backward -2 step shift,",
+ " e2 should not be executed"))
+ WHEN 4 THEN f1(CONCAT("Second pass after backward -2 step shift,",
+ " e2 should not be executed"))
+ WHEN 2 THEN f1(CONCAT("Forward +2 step shift, local 0, 1 are skipped,",
+ " e2 should be executed"))
+ ELSE f1("e2 should be executed")
+ END;
+ UPDATE t2 SET count= count + 1;
+
+ dec $count;
+}
+--enable_result_log
+--enable_query_log
+
+SET GLOBAL EVENT_SCHEDULER= OFF;
+
+SELECT * FROM t1 ORDER BY count, comment;
+
+SET TIME_ZONE= @save_time_zone;
+
+DROP EVENT e2;
+DROP EVENT e1;
+DROP FUNCTION f1;
+DROP TABLE t1, t2;
+
+DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid;
+
+#----------------------------------------------------------------------
+
+# Test MONTH interval.
+#
+
+SET TIME_ZONE= '+00:00';
+
+CREATE TABLE t1 (event CHAR(2), dt DATE, offset INT);
+
+INSERT INTO mysql.time_zone VALUES (NULL, 'N');
+SET @tzid= LAST_INSERT_ID();
+
+SET @now= UNIX_TIMESTAMP();
+SET @offset_month_01= UNIX_TIMESTAMP('2030-01-31 12:00:00') - @now;
+SET @offset_month_02= UNIX_TIMESTAMP('2030-02-28 12:00:00') - @now - 5*@step;
+SET @offset_month_03= UNIX_TIMESTAMP('2030-03-31 12:00:00') - @now - 5*@step;
+SET @offset_month_04= UNIX_TIMESTAMP('2030-04-30 12:00:00') - @now - 13*@step;
+
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 0, @offset_month_01, 0, 'b16420_0');
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 1, @offset_month_02, 1, 'b16420_1');
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 2, @offset_month_03, 1, 'b16420_2');
+INSERT INTO mysql.time_zone_transition_type
+ VALUES (@tzid, 3, @offset_month_04, 1, 'b16420_3');
+INSERT INTO mysql.time_zone_transition
+ VALUES (@tzid, @now, 0);
+INSERT INTO mysql.time_zone_transition
+ VALUES (@tzid, @now + 3 * @step, 1);
+INSERT INTO mysql.time_zone_transition
+ VALUES (@tzid, @now + 7 * @step, 2);
+INSERT INTO mysql.time_zone_transition
+ VALUES (@tzid, @now + 12 * @step, 3);
+# We have to user a new time zone name, because 'bug16420' has been
+# cached already.
+INSERT INTO mysql.time_zone_name VALUES ('bug16420_2', @tzid);
+
+SET TIME_ZONE= 'bug16420_2';
+
+SET GLOBAL EVENT_SCHEDULER= ON;
+
+let $now= `SELECT @now`;
+--disable_query_log
+eval CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH
+ STARTS FROM_UNIXTIME($now - @step) DO
+ INSERT INTO t1 VALUES
+ ("e1", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1);
+eval CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH
+ STARTS FROM_UNIXTIME($now + @step) DO
+ INSERT INTO t1 VALUES
+ ("e2", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1);
+--enable_query_log
+
+let $wait_timeout= `SELECT 16 * @step`;
+let $wait_condition= SELECT COUNT(*) = 7 FROM t1;
+--source include/wait_condition.inc
+
+SET GLOBAL EVENT_SCHEDULER= OFF;
+
+--echo Below we should see the following:
+--echo - On Jan 31 only e2 is executed, because we started later than
+--echo e1 should have been executed. Offset of e2 is 0 because of
+--echo the late start, not 1.
+--echo - The next execution is on Feb 28 (last day of Feb). Both events
+--echo are executed in their times, offsets are -1 and 1.
+--echo - The next time is Mar 31. Because the time of event
+--echo execution was skipped over, events are executed right away,
+--echo offsets are 2 and 2.
+--echo - The next time is Apr 30. Events are again executed in their
+--echo appointed times, offsets are -1 and 1.
+SELECT * FROM t1 ORDER BY dt, event;
+
+DROP EVENT e2;
+DROP EVENT e1;
+DROP TABLE t1;
+
+SET TIME_ZONE= @save_time_zone;
+
+DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid;
+DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid;
+
+DROP FUNCTION round_to_step;
+DROP TABLE t_step;
+
+
+DROP DATABASE mysqltest_db1;
+--disable_query_log
+eval USE $old_db;
+--enable_query_log
+
+
+--echo End of 5.1 tests.
diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test
index c2e31621744..10e571fc5f5 100644
--- a/mysql-test/t/grant_cache.test
+++ b/mysql-test/t/grant_cache.test
@@ -1,6 +1,8 @@
# Grant tests not performed with embedded server
-- source include/not_embedded.inc
-- source include/have_query_cache.inc
+# See at the end of the test why we disable the ps protocol (*)
+-- disable_ps_protocol
--source include/add_anonymous_users.inc
@@ -157,3 +159,27 @@ set GLOBAL query_cache_size=default;
# End of 4.1 tests
+
+# (*) Why we disable the ps protocol: because in normal protocol,
+# a SELECT failing due to insufficient privileges increments
+# Qcache_not_cached, while in ps-protocol, no.
+# In detail: in normal protocol,
+# the "access denied" errors on SELECT are issued at (stack trace):
+# mysql_parse/mysql_execute_command/execute_sqlcom_select/handle_select/
+# mysql_select/JOIN::prepare/setup_wild/insert_fields/
+# check_grant_all_columns/my_error/my_message_sql, which then calls
+# push_warning/query_cache_abort: at this moment,
+# query_cache_store_query() has been called, so query exists in cache,
+# so thd->net.query_cache_query!=NULL, so query_cache_abort() removes
+# the query from cache, which causes a query_cache.refused++ (thus,
+# a Qcache_not_cached++).
+# While in ps-protocol, the error is issued at prepare time;
+# for this mysql_test_select() is called, not execute_sqlcom_select()
+# (and that also leads to JOIN::prepare/etc). Thus, as
+# query_cache_store_query() has not been called,
+# thd->net.query_cache_query==NULL, so query_cache_abort() does nothing:
+# Qcache_not_cached is not incremented.
+# As this test prints Qcache_not_cached after SELECT failures,
+# we cannot enable this test in ps-protocol.
+
+--enable_ps_protocol
diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test
index de0cefab76c..71821e46771 100644
--- a/mysql-test/t/help.test
+++ b/mysql-test/t/help.test
@@ -114,4 +114,25 @@ delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topi
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
-# End of 4.1 tests
+--echo End of 4.1 tests.
+
+#
+# Test that we can use HELP even under LOCK TABLES. See bug#9953:
+# CONVERT_TZ requires mysql.time_zone_name to be locked.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+LOCK TABLES t1 WRITE;
+
+HELP no_such_topic;
+
+UNLOCK TABLES;
+
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests.
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index fb5e45433e9..2b8b430f096 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -92,7 +92,8 @@ delete from t2 using t1,t2 where t1.a=t2.a;
delete t2 from t1,t2 where t1.a=t2.a;
drop table t1,t2;
-# End of 4.1 tests
+--echo End of 4.1 tests.
+
#
# Bug#18884 "lock table + global read lock = crash"
@@ -108,3 +109,44 @@ flush tables with read lock;
unlock tables;
drop table t1;
+
+#
+# Test LOCK TABLE on system tables. See bug#9953: CONVERT_TZ requires
+# mysql.time_zone_name to be locked.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+LOCK TABLES mysql.time_zone READ, mysql.proc READ, t1 READ;
+UNLOCK TABLES;
+
+LOCK TABLES mysql.time_zone READ, mysql.proc READ, t1 WRITE;
+UNLOCK TABLES;
+
+LOCK TABLES mysql.time_zone READ, mysql.proc READ;
+UNLOCK TABLES;
+
+LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE;
+UNLOCK TABLES;
+
+# If at least one system table is locked for WRITE, then all other
+# tables should be system tables locked also for WRITE.
+--error ER_WRONG_LOCK_OF_SYSTEM_TABLE
+LOCK TABLES mysql.time_zone READ, mysql.proc WRITE, t1 READ;
+
+--error ER_WRONG_LOCK_OF_SYSTEM_TABLE
+LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE, t1 READ;
+
+--error ER_WRONG_LOCK_OF_SYSTEM_TABLE
+LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE, t1 WRITE;
+
+--error ER_WRONG_LOCK_OF_SYSTEM_TABLE
+LOCK TABLES mysql.time_zone READ, mysql.proc WRITE;
+
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests.
diff --git a/mysql-test/t/ndb_cache_multi2.test b/mysql-test/t/ndb_cache_multi2.test
index 4abb537624a..2afcf0c18f7 100644
--- a/mysql-test/t/ndb_cache_multi2.test
+++ b/mysql-test/t/ndb_cache_multi2.test
@@ -36,7 +36,11 @@ insert into t1 value (2);
insert into t2 value (3);
select * from t1;
# Run the check query once to load it into qc on server1
+# See at the end of this test why we need to disable ps-protocol for
+# this query (*)
+--disable_ps_protocol
select a != 3 from t1;
+--enable_ps_protocol
select * from t2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
@@ -93,3 +97,30 @@ set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
reset query cache;
flush status;
+
+# (*) Why we need to execute the query in non-ps mode.
+# The principle of this test is: two mysqlds connected to one cluster,
+# both using their query cache. Queries are cached in server1
+# ("select a!=3 from t1", "select * from t1"),
+# table t1 is modified in server2, we want to see that this invalidates
+# the query cache of server1. Invalidation with NDB works like this:
+# when a query is found in the query cache, NDB is asked if the tables
+# have changed. In this test, ha_ndbcluster calls NDB every millisecond
+# to collect change information about tables.
+# Due to this millisecond delay, there is need for a loop ("while...")
+# in this test, which waits until a query1 ("select a!=3 from t1") is
+# invalidated (which is equivalent to it returning
+# up-to-date results), and then expects query2 ("select * from t1")
+# to have been invalidated (see up-to-date results).
+# But when enabling --ps-protocol in this test, the logic breaks,
+# because query1 is still done via mysql_real_query() (see mysqltest.c:
+# eval_expr() always uses mysql_real_query()). So, query1 returning
+# up-to-date results is not a sign of it being invalidated in the cache,
+# because it was NOT in the cache ("select a!=3 from t1" on line 39
+# was done with prep stmts, while `select a!=3 from t1` is not,
+# thus the second does not see the first in the cache). Thus, we may run
+# query2 when cache still has not been invalidated.
+# The solution is to make the initial "select a!=3 from t1" run
+# as a normal query, this repairs the broken logic.
+# But note, "select * from t1" is still using prepared statements
+# which was the goal of this test with --ps-protocol.
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 14ee30f6026..9f670f9973f 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -2516,3 +2516,60 @@ set @to_format="10000";
execute stmt2 using @to_format, @dec;
deallocate prepare stmt2;
+
+#
+# BUG#18326: Do not lock table for writing during prepare of statement
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i INT);
+INSERT INTO t2 VALUES (2);
+
+LOCK TABLE t1 READ, t2 WRITE;
+
+connect (conn1, localhost, root, , );
+
+# Prepare never acquires the lock, and thus should not block.
+PREPARE stmt1 FROM "SELECT i FROM t1";
+PREPARE stmt2 FROM "INSERT INTO t2 (i) VALUES (3)";
+
+# This should not block because READ lock on t1 is shared.
+EXECUTE stmt1;
+
+# This should block because WRITE lock on t2 is exclusive.
+send EXECUTE stmt2;
+
+connection default;
+
+SELECT * FROM t2;
+UNLOCK TABLES;
+let $wait_condition= SELECT COUNT(*) = 2 FROM t2;
+--source include/wait_condition.inc
+SELECT * FROM t2;
+
+# DDL and DML works even if some client have a prepared statement
+# referencing the table.
+ALTER TABLE t1 ADD COLUMN j INT;
+ALTER TABLE t2 ADD COLUMN j INT;
+INSERT INTO t1 VALUES (4, 5);
+INSERT INTO t2 VALUES (4, 5);
+
+connection conn1;
+
+reap;
+EXECUTE stmt1;
+EXECUTE stmt2;
+SELECT * FROM t2;
+
+disconnect conn1;
+
+connection default;
+
+DROP TABLE t1, t2;
+
+
+--echo End of 5.1 tests.
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 87e2ef511d9..8920b424021 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -907,4 +907,24 @@ start transaction;
insert into t1(c1) select c1 from v1;
drop table t1, t2, t3;
drop view v1;
+
+
+#
+# If running with --ps-protocol:
+# see if a query from the text protocol is served with results cached
+# from a query which used the binary (which would be wrong, results
+# are in different formats); if that happens, the results will
+# be incorrect and the test will fail.
+#
+
+create table t1(c1 int);
+insert into t1 values(1),(10),(100);
+select * from t1;
+-- disable_ps_protocol
+select * from t1;
+select * from t1;
+-- enable_ps_protocol
+select * from t1;
+drop table t1;
+
set global query_cache_size=0;
diff --git a/mysql-test/t/query_cache_sql_prepare.test b/mysql-test/t/query_cache_sql_prepare.test
new file mode 100644
index 00000000000..69b504e2fd1
--- /dev/null
+++ b/mysql-test/t/query_cache_sql_prepare.test
@@ -0,0 +1,144 @@
+# This is to see how statements prepared via the PREPARE SQL command
+# go into the query cache: if using parameters they cannot; if not
+# using parameters they can.
+# Query cache is abbreviated as "QC"
+
+-- source include/have_query_cache.inc
+
+connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connection default;
+
+set global query_cache_size=100000;
+flush status;
+create table t1(c1 int);
+insert into t1 values(1),(10),(100);
+
+# Prepared statements has no parameters, query caching should happen
+prepare stmt1 from "select * from t1 where c1=10";
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+# Another prepared statement (same text, same connection), should hit the QC
+prepare stmt2 from "select * from t1 where c1=10";
+execute stmt2;
+show status like 'Qcache_hits';
+execute stmt2;
+show status like 'Qcache_hits';
+execute stmt2;
+show status like 'Qcache_hits';
+# Another prepared statement (same text, other connection), should hit the QC
+connection con1;
+prepare stmt3 from "select * from t1 where c1=10";
+execute stmt3;
+show status like 'Qcache_hits';
+execute stmt3;
+show status like 'Qcache_hits';
+execute stmt3;
+show status like 'Qcache_hits';
+connection default;
+# A non-prepared statement (same text, same connection), should hit
+# the QC (as it uses the text protocol like SQL EXECUTE).
+# But if it uses the binary protocol, it will not hit. So we make sure
+# that it uses the text protocol:
+-- disable_ps_protocol
+select * from t1 where c1=10;
+show status like 'Qcache_hits';
+ # A non-prepared statement (same text, other connection), should hit
+# the QC. To test that it hits the result of SQL EXECUTE, we need to
+# empty/repopulate the QC (to remove the result from the non-prepared
+# SELECT just above).
+flush tables;
+execute stmt1;
+show status like 'Qcache_hits';
+connection con1;
+select * from t1 where c1=10;
+show status like 'Qcache_hits';
+-- enable_ps_protocol
+connection default;
+
+# Prepared statement has parameters, query caching should not happen
+prepare stmt1 from "select * from t1 where c1=?";
+show status like 'Qcache_hits';
+set @a=1;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+set @a=100;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+set @a=10;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+
+# See if enabling/disabling the query cache between PREPARE and
+# EXECUTE is an issue; the expected result is that the query cache
+# will not be used.
+# Indeed, decision to read/write the query cache is taken at PREPARE
+# time, so if the query cache was disabled at PREPARE time then no
+# execution of the statement will read/write the query cache.
+# If the query cache was enabled at PREPARE time, but disabled at
+# EXECUTE time, at EXECUTE time the query cache internal functions do
+# nothing so again the query cache is not read/written. But if the
+# query cache is re-enabled before another execution then that
+# execution will read/write the query cache.
+
+# QC is enabled at PREPARE
+prepare stmt1 from "select * from t1 where c1=10";
+# then QC is disabled at EXECUTE
+set global query_cache_size=0;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+# then QC is re-enabled for more EXECUTE.
+set global query_cache_size=100000;
+# Note that this execution will not hit results from the
+# beginning of the test (because QC has been emptied meanwhile by
+# setting its size to 0).
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+
+# QC is disabled at PREPARE
+set global query_cache_size=0;
+prepare stmt1 from "select * from t1 where c1=10";
+# then QC is enabled at EXECUTE
+set global query_cache_size=100000;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+execute stmt1;
+show status like 'Qcache_hits';
+
+# QC is disabled at PREPARE
+set global query_cache_size=0;
+prepare stmt1 from "select * from t1 where c1=?";
+# then QC is enabled at EXECUTE
+set global query_cache_size=100000;
+show status like 'Qcache_hits';
+set @a=1;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+set @a=100;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+set @a=10;
+execute stmt1 using @a;
+show status like 'Qcache_hits';
+
+
+drop table t1;
+
+set global query_cache_size=0;
+flush status; # reset Qcache status variables for next tests
diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test
index 75694672a17..5e0fc65bc34 100644
--- a/mysql-test/t/skip_grants.test
+++ b/mysql-test/t/skip_grants.test
@@ -110,6 +110,12 @@ DROP FUNCTION f2;
DROP FUNCTION f3;
#
+# Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server
+#
+--error ER_OPTION_PREVENTS_STATEMENT
+set global event_scheduler=1;
+
+#
# Bug#26285 Selecting information_schema crahes server
#
select count(*) from information_schema.COLUMN_PRIVILEGES;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 6dc94869f04..e5de4a570cb 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -2068,6 +2068,74 @@ drop function bug20701;
#
+# Bug#26503 (Illegal SQL exception handler code causes the server to crash)
+#
+
+delimiter //;
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_1()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ begin
+ iterate retry;
+ end
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_2()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ iterate retry;
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_3()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ begin
+ leave retry;
+ end
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_4()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ leave retry;
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+delimiter ;//
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 884519801e2..d49f36fd6d7 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -6564,6 +6564,46 @@ call proc_21462_b(1)|
drop procedure proc_21462_a|
drop procedure proc_21462_b|
+
+#
+# BUG#20492: Subsequent calls to stored procedure yeild incorrect
+# result if join is used
+#
+# Optimized ON expression in join wasn't properly saved for reuse.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1|
+DROP VIEW IF EXISTS v1, v2|
+DROP TABLE IF EXISTS t3, t4|
+--enable_warnings
+
+CREATE TABLE t3 (t3_id INT)|
+
+INSERT INTO t3 VALUES (0)|
+INSERT INTO t3 VALUES (1)|
+
+CREATE TABLE t4 (t4_id INT)|
+
+INSERT INTO t4 VALUES (2)|
+
+CREATE VIEW v1 AS
+SELECT t3.t3_id, t4.t4_id
+FROM t3 JOIN t4 ON t3.t3_id = 0|
+
+CREATE VIEW v2 AS
+SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id
+FROM t3 LEFT JOIN v1 ON t3.t3_id = 0|
+
+CREATE PROCEDURE p1() SELECT * FROM v2|
+
+# Results should not differ.
+CALL p1()|
+CALL p1()|
+
+DROP PROCEDURE p1|
+DROP VIEW v1, v2|
+DROP TABLE t3, t4|
+
--echo End of 5.0 tests
--echo Begin of 5.1 tests
@@ -6828,6 +6868,141 @@ drop function func_8407_a|
drop function func_8407_b|
#
+# Bug#26503 (Illegal SQL exception handler code causes the server to crash)
+#
+
+--disable_warnings
+drop table if exists table_26503|
+drop procedure if exists proc_26503_ok_1|
+drop procedure if exists proc_26503_ok_2|
+drop procedure if exists proc_26503_ok_3|
+drop procedure if exists proc_26503_ok_4|
+--enable_warnings
+
+create table table_26503(a int unique)|
+
+create procedure proc_26503_ok_1(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ iterate retry;
+ select 'dead code';
+ end;
+ end while retry;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+end|
+
+create procedure proc_26503_ok_2(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ leave retry;
+ select 'dead code';
+ end;
+ end while;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+end|
+
+## The outer retry label should not prevent using the inner label.
+
+create procedure proc_26503_ok_3(v int)
+begin
+ declare i int default 5;
+
+retry:
+ begin
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ iterate retry;
+ select 'dead code';
+ end;
+ end while retry;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+ end;
+end|
+
+## The outer retry label should not prevent using the inner label.
+
+create procedure proc_26503_ok_4(v int)
+begin
+ declare i int default 5;
+
+retry:
+ begin
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ leave retry;
+ select 'dead code';
+ end;
+ end while;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+ end;
+end|
+
+call proc_26503_ok_1(1)|
+call proc_26503_ok_2(2)|
+call proc_26503_ok_3(3)|
+call proc_26503_ok_4(4)|
+
+drop table table_26503|
+drop procedure proc_26503_ok_1|
+drop procedure proc_26503_ok_2|
+drop procedure proc_26503_ok_3|
+drop procedure proc_26503_ok_4|
+
+#
# Bug#25373: Stored functions wasn't compared correctly which leads to a wrong
# result.
#
diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test
index 5e1f74d388f..4f70539ca8d 100644
--- a/mysql-test/t/timezone2.test
+++ b/mysql-test/t/timezone2.test
@@ -246,3 +246,31 @@ drop function f1;
SET GLOBAL log_bin_trust_function_creators = 0;
# End of 5.0 tests
+
+
+#
+# BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked
+# BUG#19339: CONVERT_TZ(): overly aggressive in locking time_zone_name
+# table
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (t TIMESTAMP);
+INSERT INTO t1 VALUES (NULL), (NULL);
+
+LOCK TABLES t1 WRITE;
+
+# The following two queries should not return error that time zone
+# tables aren't locked. We use IS NULL below to supress timestamp
+# result.
+SELECT CONVERT_TZ(NOW(), 'UTC', 'Europe/Moscow') IS NULL;
+UPDATE t1 SET t = CONVERT_TZ(t, 'UTC', 'Europe/Moscow');
+
+UNLOCK TABLES;
+
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 9771c5bc96e..026a08bf365 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -832,6 +832,7 @@ drop table t1;
#
create table t1 (col1 int);
create table t2 (col1 int);
+create table t3 (col1 datetime not null);
create view v1 as select * from t1;
create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
@@ -938,7 +939,7 @@ insert into v3 (col1) values ((select max(col1) from v2));
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2));
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
-- error 1048
-insert into mysql.time_zone values ('', (select CONVERT_TZ('20050101000000','UTC','MET') from t2));
+insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
# temporary table algorithm view should be equal to subquery in the from clause
create algorithm=temptable view v4 as select * from t1;
insert into t1 values (1),(2),(3);
@@ -946,7 +947,7 @@ insert into t1 (col1) values ((select max(col1) from v4));
select * from t1;
drop view v4,v3,v2,v1;
-drop table t1,t2;
+drop table t1,t2,t3;
#
# HANDLER with VIEW
@@ -3214,3 +3215,30 @@ DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
+
+
+#
+# Test that ALTER VIEW accepts DEFINER and ALGORITHM, see bug#16425.
+#
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+ALTER VIEW v1 AS SELECT * FROM t1;
+SHOW CREATE VIEW v1;
+ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
+SHOW CREATE VIEW v1;
+ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
+SHOW CREATE VIEW v1;
+ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests.