summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test2
-rw-r--r--mysql-test/include/mix1.inc55
-rw-r--r--mysql-test/include/ps_modify.inc1
-rw-r--r--mysql-test/r/auto_increment.result12
-rw-r--r--mysql-test/r/group_by.result36
-rw-r--r--mysql-test/r/innodb_mysql.result27
-rw-r--r--mysql-test/r/null.result8
-rw-r--r--mysql-test/r/parser.result20
-rw-r--r--mysql-test/r/ps_2myisam.result5
-rw-r--r--mysql-test/r/ps_3innodb.result5
-rw-r--r--mysql-test/r/ps_4heap.result5
-rw-r--r--mysql-test/r/ps_5merge.result10
-rw-r--r--mysql-test/r/query_cache_debug.result24
-rw-r--r--mysql-test/r/sp-code.result109
-rw-r--r--mysql-test/r/sp-error.result48
-rw-r--r--mysql-test/r/sp.result58
-rw-r--r--mysql-test/r/subselect.result48
-rw-r--r--mysql-test/r/type_decimal.result63
-rw-r--r--mysql-test/r/view.result16
-rw-r--r--mysql-test/r/warnings.result3
-rw-r--r--mysql-test/suite/ndb/r/ps_7ndb.result5
-rw-r--r--mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result12
-rw-r--r--mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result12
-rw-r--r--mysql-test/suite/rpl/t/rpl_err_ignoredtable.test2
-rw-r--r--mysql-test/t/auto_increment.test2
-rw-r--r--mysql-test/t/group_by.test51
-rw-r--r--mysql-test/t/null.test2
-rw-r--r--mysql-test/t/parser.test20
-rw-r--r--mysql-test/t/query_cache.test1
-rw-r--r--mysql-test/t/query_cache_debug.test46
-rw-r--r--mysql-test/t/sp-code.test77
-rw-r--r--mysql-test/t/sp-error.test63
-rw-r--r--mysql-test/t/sp.test85
-rw-r--r--mysql-test/t/subselect.test55
-rw-r--r--mysql-test/t/type_decimal.test43
-rw-r--r--mysql-test/t/view.test14
-rw-r--r--mysql-test/t/warnings.test1
37 files changed, 972 insertions, 74 deletions
diff --git a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
index efca53d5698..5abd04b98ef 100644
--- a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
+++ b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
@@ -419,7 +419,7 @@ connection master;
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
- update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+ update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
--echo
--echo ** Delete from Master **
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index 3005e67935b..703dfa44df0 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -723,20 +723,6 @@ set @@sort_buffer_size=default;
DROP TABLE t1,t2;
-#
-# Bug #32815: query with ORDER BY and a possible ref_or_null access
-#
-
-CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES
- (191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
-
-EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
-SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
-
-DROP TABLE t1;
-
-
# Test of behaviour with CREATE ... SELECT
#
@@ -1091,6 +1077,19 @@ desc t1;
show create table t1;
drop table t1;
+#
+# Bug #32815: query with ORDER BY and a possible ref_or_null access
+#
+
+CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+ (191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
+
+EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
@@ -1383,4 +1382,32 @@ create table t1 (a int auto_increment primary key) engine=innodb;
alter table t1 order by a;
drop table t1;
+#
+# Bug #33697: ORDER BY primary key DESC vs. ref access + filesort
+# (reproduced only with InnoDB tables)
+#
+
+CREATE TABLE t1
+ (vid integer NOT NULL,
+ tid integer NOT NULL,
+ idx integer NOT NULL,
+ name varchar(128) NOT NULL,
+ type varchar(128) NULL,
+ PRIMARY KEY(idx, vid, tid),
+ UNIQUE(vid, tid, name)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES
+ (1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL),
+ (5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL),
+ (4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL),
+ (4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
+ (2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
+
+EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
+
+SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc
index f66f888261d..4cde18b97d1 100644
--- a/mysql-test/include/ps_modify.inc
+++ b/mysql-test/include/ps_modify.inc
@@ -108,6 +108,7 @@ execute stmt1 using @arg00, @arg01;
select a,b from t1 where a=@arg00;
set @arg00=NULL;
set @arg01=2;
+--error 1048
execute stmt1 using @arg00, @arg01;
select a,b from t1 order by a;
set @arg00=0;
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 54c2df34a7f..bc9daf43f14 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -231,8 +231,7 @@ a b
204 7
delete from t1 where a=0;
update t1 set a=NULL where b=6;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
update t1 set a=300 where b=7;
SET SQL_MODE='';
insert into t1(a,b)values(NULL,8);
@@ -247,7 +246,7 @@ a b
1 1
200 2
201 4
-0 6
+203 6
300 7
301 8
400 9
@@ -263,6 +262,7 @@ a b
1 1
200 2
201 4
+203 6
300 7
301 8
400 9
@@ -273,20 +273,20 @@ a b
405 14
delete from t1 where a=0;
update t1 set a=NULL where b=13;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
update t1 set a=500 where b=14;
select * from t1 order by b;
a b
1 1
200 2
201 4
+203 6
300 7
301 8
400 9
401 10
402 11
-0 13
+404 13
500 14
drop table t1;
create table t1 (a bigint);
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 1472fdfdd7a..268f290ddca 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1478,3 +1478,39 @@ NULL
1
2
DROP TABLE t1;
+CREATE TABLE t1 ( a INT, b INT );
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42S22: Reference 'c' not supported (reference to group function)
+SET @old_sql_mode = @@sql_mode;
+SET @@sql_mode='ONLY_FULL_GROUP_BY';
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42000: non-grouping field 'b' is used in HAVING clause
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42S22: Reference 'c' not supported (reference to group function)
+INSERT INTO t1 VALUES (1, 1);
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+1 1
+INSERT INTO t1 VALUES (2, 1);
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 87cf1acc10c..e9f00a667c0 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -1349,7 +1349,7 @@ INSERT INTO t1 VALUES
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t1 ALL idx NULL NULL NULL 4 Using where; Using filesort
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
id type d
191 member 1
@@ -1609,4 +1609,29 @@ alter table t1 order by a;
Warnings:
Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1'
drop table t1;
+CREATE TABLE t1
+(vid integer NOT NULL,
+tid integer NOT NULL,
+idx integer NOT NULL,
+name varchar(128) NOT NULL,
+type varchar(128) NULL,
+PRIMARY KEY(idx, vid, tid),
+UNIQUE(vid, tid, name)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL),
+(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL),
+(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL),
+(4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
+(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
+EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index vid PRIMARY 12 NULL 16 Using where
+SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
+vid tid idx name type
+3 1 4 c_extra NULL
+3 1 3 c2 NULL
+3 1 2 c1 NULL
+3 1 1 pk NULL
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index 345c9b07b98..5a2ebc37cc8 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -93,11 +93,9 @@ INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=1/NULL;
-Warnings:
-Warning 1265 Data truncated for column 'd' at row 1
+ERROR 23000: Column 'd' cannot be null
UPDATE t1 SET d=NULL;
-Warnings:
-Warning 1048 Column 'd' cannot be null
+ERROR 23000: Column 'd' cannot be null
INSERT INTO t1 (a) values (null);
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (1/null);
@@ -132,7 +130,7 @@ Warning 1048 Column 'd' cannot be null
Warning 1048 Column 'd' cannot be null
select * from t1;
a b c d
- 0 0000-00-00 00:00:00 0
+ 0 0000-00-00 00:00:00 2003
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index ef53f227ec0..e10bcba36c2 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -527,3 +527,23 @@ SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1;
a b
3 1998-01-01 00:00:00
DROP TABLE t1;
+DROP TABLE IF EXISTS t1,t2,t3;
+CREATE TABLE t1 (a1 INT, a2 INT, a3 INT, a4 DATETIME);
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+SELECT t1.* FROM t1 AS t0, { OJ t2 INNER JOIN t1 ON (t1.a1=t2.a1) } WHERE t0.a3=2;
+a1 a2 a3 a4
+SELECT t1.*,t2.* FROM { OJ ((t1 INNER JOIN t2 ON (t1.a1=t2.a2)) LEFT OUTER JOIN t3 ON t3.a3=t2.a1)};
+a1 a2 a3 a4 a1 a2 a3 a4
+SELECT t1.*,t2.* FROM { OJ ((t1 LEFT OUTER JOIN t2 ON t1.a3=t2.a2) INNER JOIN t3 ON (t3.a1=t2.a2))};
+a1 a2 a3 a4 a1 a2 a3 a4
+SELECT t1.*,t2.* FROM { OJ (t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a2) CROSS JOIN t3 ON (t3.a2=t2.a3)};
+a1 a2 a3 a4 a1 a2 a3 a4
+SELECT * FROM {oj t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a3} WHERE t1.a2 > 10;
+a1 a2 a3 a4 a1 a2 a3 a4
+SELECT {fn CONCAT(a1,a2)} FROM t1;
+{fn CONCAT(a1,a2)}
+UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0;
+SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')};
+a1 a4
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index fbc6781e5e7..06bfd78a351 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -1303,12 +1303,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index fcd0b5de9a0..f56b1d37a2c 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -1286,12 +1286,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 862c0ff75c1..0c643facf72 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1287,12 +1287,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 51393cc8bc3..bd3cd4ac1fc 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -1329,12 +1329,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
@@ -4351,12 +4350,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/query_cache_debug.result b/mysql-test/r/query_cache_debug.result
new file mode 100644
index 00000000000..f177bfac836
--- /dev/null
+++ b/mysql-test/r/query_cache_debug.result
@@ -0,0 +1,24 @@
+flush status;
+set query_cache_type=DEMAND;
+set global query_cache_size= 1024*1024*512;
+drop table if exists t1;
+create table t1 (a varchar(100));
+insert into t1 values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+Activate debug hook and attempt to retrieve the statement from the cache.
+set session debug='+d,wait_in_query_cache_insert';
+select SQL_CACHE * from t1;;
+On a second connection; clear the query cache.
+show status like 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 1
+set global query_cache_size= 0;
+Signal the debug hook to release the lock.
+select id from information_schema.processlist where state='wait_in_query_cache_insert' into @thread_id;
+kill query @thread_id;
+Show query cache status.
+show status like 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 0
+set global query_cache_size= 0;
+use test;
+drop table t1;
diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result
index 018173e723d..ca5c5b42102 100644
--- a/mysql-test/r/sp-code.result
+++ b/mysql-test/r/sp-code.result
@@ -733,6 +733,115 @@ optimizer: keep hreturn
drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
+drop procedure if exists proc_33618_h;
+drop procedure if exists proc_33618_c;
+create procedure proc_33618_h(num int)
+begin
+declare count1 int default '0';
+declare vb varchar(30);
+declare last_row int;
+while(num>=1) do
+set num=num-1;
+begin
+declare cur1 cursor for select `a` from t_33618;
+declare continue handler for not found set last_row = 1;
+set last_row:=0;
+open cur1;
+rep1:
+repeat
+begin
+declare exit handler for 1062 begin end;
+fetch cur1 into vb;
+if (last_row = 1) then
+## should generate a hpop instruction here
+leave rep1;
+end if;
+end;
+until last_row=1
+end repeat;
+close cur1;
+end;
+end while;
+end//
+create procedure proc_33618_c(num int)
+begin
+declare count1 int default '0';
+declare vb varchar(30);
+declare last_row int;
+while(num>=1) do
+set num=num-1;
+begin
+declare cur1 cursor for select `a` from t_33618;
+declare continue handler for not found set last_row = 1;
+set last_row:=0;
+open cur1;
+rep1:
+repeat
+begin
+declare cur2 cursor for select `b` from t_33618;
+fetch cur1 into vb;
+if (last_row = 1) then
+## should generate a cpop instruction here
+leave rep1;
+end if;
+end;
+until last_row=1
+end repeat;
+close cur1;
+end;
+end while;
+end//
+show procedure code proc_33618_h;
+Pos Instruction
+0 set count1@1 _latin1'0'
+1 set vb@2 NULL
+2 set last_row@3 NULL
+3 jump_if_not 24(24) (num@0 >= 1)
+4 set num@0 (num@0 - 1)
+5 cpush cur1@0
+6 hpush_jump 9 4 CONTINUE
+7 set last_row@3 1
+8 hreturn 4
+9 set last_row@3 0
+10 copen cur1@0
+11 hpush_jump 13 4 EXIT
+12 hreturn 0 17
+13 cfetch cur1@0 vb@2
+14 jump_if_not 17(17) (last_row@3 = 1)
+15 hpop 1
+16 jump 19
+17 hpop 1
+18 jump_if_not 11(19) (last_row@3 = 1)
+19 cclose cur1@0
+20 hpop 1
+21 cpop 1
+22 jump 3
+show procedure code proc_33618_c;
+Pos Instruction
+0 set count1@1 _latin1'0'
+1 set vb@2 NULL
+2 set last_row@3 NULL
+3 jump_if_not 23(23) (num@0 >= 1)
+4 set num@0 (num@0 - 1)
+5 cpush cur1@0
+6 hpush_jump 9 4 CONTINUE
+7 set last_row@3 1
+8 hreturn 4
+9 set last_row@3 0
+10 copen cur1@0
+11 cpush cur2@1
+12 cfetch cur1@0 vb@2
+13 jump_if_not 16(16) (last_row@3 = 1)
+14 cpop 1
+15 jump 18
+16 cpop 1
+17 jump_if_not 11(18) (last_row@3 = 1)
+18 cclose cur1@0
+19 hpop 1
+20 cpop 1
+21 jump 3
+drop procedure proc_33618_h;
+drop procedure proc_33618_c;
End of 5.0 tests.
CREATE PROCEDURE p1()
BEGIN
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index b81f8ea64c9..c33c378340e 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1579,3 +1579,51 @@ drop function f2;
drop table t2;
ERROR 42S02: Unknown table 't2'
End of 5.1 tests
+drop procedure if exists proc_33983_a;
+drop procedure if exists proc_33983_b;
+drop procedure if exists proc_33983_c;
+drop procedure if exists proc_33983_d;
+create procedure proc_33983_a()
+begin
+label1:
+begin
+label2:
+begin
+select 1;
+end label1;
+end;
+end|
+ERROR 42000: End-label label1 without match
+create procedure proc_33983_b()
+begin
+label1:
+repeat
+label2:
+repeat
+select 1;
+until FALSE end repeat label1;
+until FALSE end repeat;
+end|
+ERROR 42000: End-label label1 without match
+create procedure proc_33983_c()
+begin
+label1:
+while TRUE do
+label2:
+while TRUE do
+select 1;
+end while label1;
+end while;
+end|
+ERROR 42000: End-label label1 without match
+create procedure proc_33983_d()
+begin
+label1:
+loop
+label2:
+loop
+select 1;
+end loop label1;
+end loop;
+end|
+ERROR 42000: End-label label1 without match
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 68aa278585f..50ece83b258 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -6812,7 +6812,59 @@ DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a;
DROP DATABASE db28318_b;
use test;
-End of 5.0 tests
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS bug29770;
+CREATE TABLE t1(a int);
+CREATE PROCEDURE bug29770()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @state:= 'run';
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run';
+SELECT x FROM t1;
+END|
+CALL bug29770();
+SELECT @state, @exception;
+@state @exception
+run NULL
+DROP TABLE t1;
+DROP PROCEDURE bug29770;
+use test;
+drop table if exists t_33618;
+drop procedure if exists proc_33618;
+create table t_33618 (`a` int, unique(`a`), `b` varchar(30)) engine=myisam;
+insert into t_33618 (`a`,`b`) values (1,'1'),(2,'2');
+create procedure proc_33618(num int)
+begin
+declare count1 int default '0';
+declare vb varchar(30);
+declare last_row int;
+while(num>=1) do
+set num=num-1;
+begin
+declare cur1 cursor for select `a` from t_33618;
+declare continue handler for not found set last_row = 1;
+set last_row:=0;
+open cur1;
+rep1:
+repeat
+begin
+declare exit handler for 1062 begin end;
+fetch cur1 into vb;
+if (last_row = 1) then
+leave rep1;
+end if;
+end;
+until last_row=1
+end repeat;
+close cur1;
+end;
+end while;
+end//
+call proc_33618(20);
+drop table t_33618;
+drop procedure proc_33618;
+# ------------------------------------------------------------------
+# -- End of 5.0 tests
+# ------------------------------------------------------------------
#
# Bug#20550.
@@ -6911,4 +6963,6 @@ END latin1 latin1_swedish_ci latin1_swedish_ci
DROP FUNCTION f1;
-End of 5.1 tests
+# ------------------------------------------------------------------
+# -- End of 5.1 tests
+# ------------------------------------------------------------------
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 762457d57a6..20d44933128 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -4291,6 +4291,54 @@ select count(*) from t1 where f12 =
count(*)
3
drop table t1,t2;
+CREATE TABLE t4 (
+f7 varchar(32) collate utf8_bin NOT NULL default '',
+f10 varchar(32) collate utf8_bin default NULL,
+PRIMARY KEY (f7)
+);
+INSERT INTO t4 VALUES(1,1), (2,null);
+CREATE TABLE t2 (
+f4 varchar(32) collate utf8_bin NOT NULL default '',
+f2 varchar(50) collate utf8_bin default NULL,
+f3 varchar(10) collate utf8_bin default NULL,
+PRIMARY KEY (f4),
+UNIQUE KEY uk1 (f2)
+);
+INSERT INTO t2 VALUES(1,1,null), (2,2,null);
+CREATE TABLE t1 (
+f8 varchar(32) collate utf8_bin NOT NULL default '',
+f1 varchar(10) collate utf8_bin default NULL,
+f9 varchar(32) collate utf8_bin default NULL,
+PRIMARY KEY (f8)
+);
+INSERT INTO t1 VALUES (1,'P',1), (2,'P',1), (3,'R',2);
+CREATE TABLE t3 (
+f6 varchar(32) collate utf8_bin NOT NULL default '',
+f5 varchar(50) collate utf8_bin default NULL,
+PRIMARY KEY (f6)
+);
+INSERT INTO t3 VALUES (1,null), (2,null);
+SELECT
+IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
+IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,
+SUM(
+IF(
+(SELECT VPC.f2
+FROM t2 VPC, t4 a2, t2 a3
+WHERE
+VPC.f4 = a2.f10 AND a3.f2 = a4
+LIMIT 1) IS NULL,
+0,
+t3.f5
+)
+) AS a6
+FROM
+t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
+GROUP BY a4;
+a4 f3 a6
+1 NULL NULL
+2 NULL NULL
+DROP TABLE t1, t2, t3, t4;
End of 5.0 tests.
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index a25ffc4c6fc..3e5f6a9b504 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -794,7 +794,7 @@ dps tinyint(3) unsigned default NULL
INSERT INTO t1 VALUES (1.1325,3);
SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
ROUND(qty,3) dps ROUND(qty,dps)
-1.133 3 1.133
+1.133 3 1.133000
DROP TABLE t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
%
@@ -885,4 +885,65 @@ c
1000
1234567890
DROP TABLE t1, t2, t3, t4;
+CREATE TABLE t1( a DECIMAL(4, 3), b INT );
+INSERT INTO t1 VALUES ( 1, 5 ), ( 2, 4 ), ( 3, 3 ), ( 4, 2 ), ( 5, 1 );
+SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c;
+a b c
+1.000 5 1.000
+2.000 4 2.000
+3.000 3 3.000
+4.000 2 4.000
+5.000 1 5.000
+SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c DESC;
+a b c
+5.000 1 5.000
+4.000 2 4.000
+3.000 3 3.000
+2.000 4 2.000
+1.000 5 1.000
+CREATE TABLE t2 ( a INT, b INT, c DECIMAL(5, 4) );
+INSERT INTO t2 VALUES ( 0, 1, 1.2345 ), ( 1, 2, 1.2345 ),
+( 3, 3, 1.2345 ), ( 2, 4, 1.2345 );
+SELECT a, b, MAX(ROUND(c, a))
+FROM t2
+GROUP BY a, b
+ORDER BY b;
+a b MAX(ROUND(c, a))
+0 1 1.0000
+1 2 1.2000
+3 3 1.2350
+2 4 1.2300
+SELECT a, b, ROUND(c, a)
+FROM t2;
+a b ROUND(c, a)
+0 1 1.0000
+1 2 1.2000
+3 3 1.2350
+2 4 1.2300
+CREATE TABLE t3( a INT, b DECIMAL(6, 3) );
+INSERT INTO t3 VALUES( 0, 1.5 );
+SELECT ROUND( b, a ) FROM t3;
+ROUND( b, a )
+2.000
+CREATE TABLE t4( a INT, b DECIMAL( 12, 0) );
+INSERT INTO t4 VALUES( -9, 1.5e9 );
+SELECT ROUND( b, a ) FROM t4;
+ROUND( b, a )
+2000000000
+CREATE TABLE t5( a INT, b DECIMAL( 13, 12 ) );
+INSERT INTO t5 VALUES( 0, 1.5 );
+INSERT INTO t5 VALUES( 9, 1.5e-9 );
+SELECT ROUND( b, a ) FROM t5;
+ROUND( b, a )
+2.000000000000
+0.000000002000
+CREATE TABLE t6( a INT );
+INSERT INTO t6 VALUES( 6 / 8 );
+SELECT * FROM t6;
+a
+1
+SELECT ROUND(20061108085411.000002);
+ROUND(20061108085411.000002)
+20061108085411
+DROP TABLE t1, t2, t3, t4, t5, t6;
End of 5.0 tests
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 2971af7347d..09b997797b4 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3597,6 +3597,22 @@ DROP VIEW v1;
DROP VIEW v2;
DROP VIEW v3;
DROP TABLE t1;
+#
+# Bug#29477: Not all fields of the target table were checked to have
+# a default value when inserting into a view.
+#
+create table t1(f1 int, f2 int not null);
+create view v1 as select f1 from t1;
+insert into v1 values(1);
+Warnings:
+Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value
+set @old_mode=@@sql_mode;
+set @@sql_mode=traditional;
+insert into v1 values(1);
+ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value
+set @@sql_mode=@old_mode;
+drop view v1;
+drop table t1;
End of 5.0 tests.
DROP DATABASE IF EXISTS `d-1`;
CREATE DATABASE `d-1`;
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 2929328a9b1..249cd583345 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -98,8 +98,7 @@ Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'c' at row 2
alter table t1 add d char(2);
update t1 set a=NULL where a=10;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
update t1 set c='mysql ab' where c='test';
Warnings:
Warning 1265 Data truncated for column 'c' at row 4
diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result
index 6e2e61bbc5e..3cbc1a0e76f 100644
--- a/mysql-test/suite/ndb/r/ps_7ndb.result
+++ b/mysql-test/suite/ndb/r/ps_7ndb.result
@@ -1286,12 +1286,11 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-Warnings:
-Warning 1048 Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
select a,b from t1 order by a;
a b
-0 two
1 one
+2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result b/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
index ad67f96db71..86648ba12c3 100644
--- a/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
@@ -454,9 +454,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
@@ -1595,9 +1593,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
@@ -2736,9 +2732,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
diff --git a/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result b/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
index 8859a8e24e3..96d4ca237d1 100644
--- a/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
@@ -454,9 +454,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
@@ -1595,9 +1593,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
@@ -2736,9 +2732,7 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
-Warnings:
-Warning 1048 Column 'f3' cannot be null
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
** Delete from Master **
diff --git a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
index 4e06a6a7096..a36cfb11dae 100644
--- a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
+++ b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
@@ -49,7 +49,7 @@ kill @id;
drop table t2,t3;
insert into t4 values (3),(4);
connection master;
---error 0,1053,2013
+--error 0,1053,2013,1048
reap;
connection master1;
save_master_pos;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 99e9b783d55..ff92c743960 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -149,6 +149,7 @@ delete from t1 where a=0;
update t1 set a=0 where b=5;
select * from t1 order by b;
delete from t1 where a=0;
+--error 1048
update t1 set a=NULL where b=6;
update t1 set a=300 where b=7;
SET SQL_MODE='';
@@ -164,6 +165,7 @@ delete from t1 where a=0;
update t1 set a=0 where b=12;
select * from t1 order by b;
delete from t1 where a=0;
+--error 1048
update t1 set a=NULL where b=13;
update t1 set a=500 where b=14;
select * from t1 order by b;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 94c2b463aaa..3211db5d6ed 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -790,8 +790,6 @@ drop table t1;
SET SQL_MODE = '';
#
-
-#
# Bug #32202: ORDER BY not working with GROUP BY
#
@@ -824,6 +822,7 @@ SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC;
DROP TABLE t1;
+
--echo End of 5.0 tests
# Bug #21174: Index degrades sort performance and
# optimizer does not honor IGNORE INDEX.
@@ -946,3 +945,51 @@ EXPLAIN SELECT b from t2 GROUP BY b;
SELECT b from t2 GROUP BY b;
DROP TABLE t1;
+
+#
+# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING
+#
+CREATE TABLE t1 ( a INT, b INT );
+
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+
+--error ER_ILLEGAL_REFERENCE
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+
+SET @old_sql_mode = @@sql_mode;
+SET @@sql_mode='ONLY_FULL_GROUP_BY';
+
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+
+--error ER_NON_GROUPING_FIELD_USED
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+
+--error ER_ILLEGAL_REFERENCE
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+
+INSERT INTO t1 VALUES (1, 1);
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+
+INSERT INTO t1 VALUES (2, 1);
+--error ER_SUBQUERY_NO_1_ROW
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
+
+
+
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index 2878b54c357..ddf6b8870fa 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -61,7 +61,9 @@ drop table t1;
#
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
+--error 1048
UPDATE t1 SET d=1/NULL;
+--error 1048
UPDATE t1 SET d=NULL;
--error 1048
INSERT INTO t1 (a) values (null);
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index 9170308a4f2..800d717cf6b 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -657,3 +657,23 @@ CREATE TABLE t1 (a INT, b DATETIME);
INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND);
SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1;
DROP TABLE t1;
+
+#
+# Bug#28317 Left Outer Join with {oj outer-join}
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+--enable_warnings
+CREATE TABLE t1 (a1 INT, a2 INT, a3 INT, a4 DATETIME);
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+SELECT t1.* FROM t1 AS t0, { OJ t2 INNER JOIN t1 ON (t1.a1=t2.a1) } WHERE t0.a3=2;
+SELECT t1.*,t2.* FROM { OJ ((t1 INNER JOIN t2 ON (t1.a1=t2.a2)) LEFT OUTER JOIN t3 ON t3.a3=t2.a1)};
+SELECT t1.*,t2.* FROM { OJ ((t1 LEFT OUTER JOIN t2 ON t1.a3=t2.a2) INNER JOIN t3 ON (t3.a1=t2.a2))};
+SELECT t1.*,t2.* FROM { OJ (t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a2) CROSS JOIN t3 ON (t3.a2=t2.a3)};
+SELECT * FROM {oj t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a3} WHERE t1.a2 > 10;
+SELECT {fn CONCAT(a1,a2)} FROM t1;
+UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0;
+SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')};
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 9e250372d51..771a32e8cd7 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -1316,6 +1316,5 @@ SELECT 1 FROM t1 GROUP BY
(SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1);
DROP TABLE t1;
-
--echo End of 5.1 tests
diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test
new file mode 100644
index 00000000000..b741eea0b29
--- /dev/null
+++ b/mysql-test/t/query_cache_debug.test
@@ -0,0 +1,46 @@
+--source include/not_embedded.inc
+--source include/have_query_cache.inc
+--source include/have_debug.inc
+
+#
+# Bug #30887 Server crashes on SET GLOBAL query_cache_size=0
+#
+flush status;
+set query_cache_type=DEMAND;
+set global query_cache_size= 1024*1024*512;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a varchar(100));
+insert into t1 values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+connect (bug30887con1, localhost, root, ,test);
+connect (bug30887con2, localhost, root, ,test);
+
+connection bug30887con1;
+--echo Activate debug hook and attempt to retrieve the statement from the cache.
+set session debug='+d,wait_in_query_cache_insert';
+--send select SQL_CACHE * from t1;
+
+connection default;
+let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'wait_in_query_cache_insert';
+--source include/wait_condition.inc
+
+connection bug30887con2;
+--echo On a second connection; clear the query cache.
+show status like 'Qcache_queries_in_cache';
+set global query_cache_size= 0;
+
+connection default;
+--echo Signal the debug hook to release the lock.
+select id from information_schema.processlist where state='wait_in_query_cache_insert' into @thread_id;
+kill query @thread_id;
+
+--echo Show query cache status.
+show status like 'Qcache_queries_in_cache';
+
+disconnect bug30887con1;
+disconnect bug30887con2;
+set global query_cache_size= 0;
+use test;
+drop table t1;
+
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 66d5323d2e2..84f0201c808 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -520,6 +520,83 @@ drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
+#
+# Bug#33618 Crash in sp_rcontext
+#
+
+--disable_warnings
+drop procedure if exists proc_33618_h;
+drop procedure if exists proc_33618_c;
+--enable_warnings
+
+delimiter //;
+
+create procedure proc_33618_h(num int)
+begin
+ declare count1 int default '0';
+ declare vb varchar(30);
+ declare last_row int;
+
+ while(num>=1) do
+ set num=num-1;
+ begin
+ declare cur1 cursor for select `a` from t_33618;
+ declare continue handler for not found set last_row = 1;
+ set last_row:=0;
+ open cur1;
+ rep1:
+ repeat
+ begin
+ declare exit handler for 1062 begin end;
+ fetch cur1 into vb;
+ if (last_row = 1) then
+ ## should generate a hpop instruction here
+ leave rep1;
+ end if;
+ end;
+ until last_row=1
+ end repeat;
+ close cur1;
+ end;
+ end while;
+end//
+
+create procedure proc_33618_c(num int)
+begin
+ declare count1 int default '0';
+ declare vb varchar(30);
+ declare last_row int;
+
+ while(num>=1) do
+ set num=num-1;
+ begin
+ declare cur1 cursor for select `a` from t_33618;
+ declare continue handler for not found set last_row = 1;
+ set last_row:=0;
+ open cur1;
+ rep1:
+ repeat
+ begin
+ declare cur2 cursor for select `b` from t_33618;
+ fetch cur1 into vb;
+ if (last_row = 1) then
+ ## should generate a cpop instruction here
+ leave rep1;
+ end if;
+ end;
+ until last_row=1
+ end repeat;
+ close cur1;
+ end;
+ end while;
+end//
+delimiter ;//
+
+show procedure code proc_33618_h;
+show procedure code proc_33618_c;
+
+drop procedure proc_33618_h;
+drop procedure proc_33618_c;
--echo End of 5.0 tests.
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 606c2a673bc..286722df65c 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -2306,6 +2306,69 @@ drop table t2;
--echo End of 5.1 tests
#
+# Bug#33983 (Stored Procedures: wrong end <label> syntax is accepted)
+#
+
+--disable_warnings
+drop procedure if exists proc_33983_a;
+drop procedure if exists proc_33983_b;
+drop procedure if exists proc_33983_c;
+drop procedure if exists proc_33983_d;
+--enable_warnings
+
+delimiter |;
+
+--error ER_SP_LABEL_MISMATCH
+create procedure proc_33983_a()
+begin
+ label1:
+ begin
+ label2:
+ begin
+ select 1;
+ end label1;
+ end;
+end|
+
+--error ER_SP_LABEL_MISMATCH
+create procedure proc_33983_b()
+begin
+ label1:
+ repeat
+ label2:
+ repeat
+ select 1;
+ until FALSE end repeat label1;
+ until FALSE end repeat;
+end|
+
+--error ER_SP_LABEL_MISMATCH
+create procedure proc_33983_c()
+begin
+ label1:
+ while TRUE do
+ label2:
+ while TRUE do
+ select 1;
+ end while label1;
+ end while;
+end|
+
+--error ER_SP_LABEL_MISMATCH
+create procedure proc_33983_d()
+begin
+ label1:
+ loop
+ label2:
+ loop
+ select 1;
+ end loop label1;
+ end loop;
+end|
+
+delimiter ;|
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 004e1c4ddd2..6dc2f906d45 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -7902,7 +7902,86 @@ use test;
###########################################################################
---echo End of 5.0 tests
+#
+# Bug#29770 Two handlers are allowed to catch an error in an stored procedure.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS bug29770;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+delimiter |;
+CREATE PROCEDURE bug29770()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @state:= 'run';
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run';
+ SELECT x FROM t1;
+END|
+delimiter ;|
+CALL bug29770();
+SELECT @state, @exception;
+DROP TABLE t1;
+DROP PROCEDURE bug29770;
+
+#
+# Bug#33618 Crash in sp_rcontext
+#
+
+use test;
+
+--disable_warnings
+drop table if exists t_33618;
+drop procedure if exists proc_33618;
+--enable_warnings
+
+create table t_33618 (`a` int, unique(`a`), `b` varchar(30)) engine=myisam;
+insert into t_33618 (`a`,`b`) values (1,'1'),(2,'2');
+
+delimiter //;
+
+create procedure proc_33618(num int)
+begin
+ declare count1 int default '0';
+ declare vb varchar(30);
+ declare last_row int;
+
+ while(num>=1) do
+ set num=num-1;
+ begin
+ declare cur1 cursor for select `a` from t_33618;
+ declare continue handler for not found set last_row = 1;
+ set last_row:=0;
+ open cur1;
+ rep1:
+ repeat
+ begin
+ declare exit handler for 1062 begin end;
+ fetch cur1 into vb;
+ if (last_row = 1) then
+ leave rep1;
+ end if;
+ end;
+ until last_row=1
+ end repeat;
+ close cur1;
+ end;
+ end while;
+end//
+
+delimiter ;//
+
+call proc_33618(20);
+
+drop table t_33618;
+drop procedure proc_33618;
+
+###########################################################################
+
+--echo # ------------------------------------------------------------------
+--echo # -- End of 5.0 tests
+--echo # ------------------------------------------------------------------
###########################################################################
@@ -8056,4 +8135,6 @@ DROP FUNCTION f1;
###########################################################################
---echo End of 5.1 tests
+--echo # ------------------------------------------------------------------
+--echo # -- End of 5.1 tests
+--echo # ------------------------------------------------------------------
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index ad940f3f5ad..c86b0fefbdc 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -3159,6 +3159,60 @@ select count(*) from t1 where f12 =
drop table t1,t2;
+#
+# BUG#33794 "MySQL crashes executing specific query on specific dump"
+#
+CREATE TABLE t4 (
+ f7 varchar(32) collate utf8_bin NOT NULL default '',
+ f10 varchar(32) collate utf8_bin default NULL,
+ PRIMARY KEY (f7)
+);
+INSERT INTO t4 VALUES(1,1), (2,null);
+
+CREATE TABLE t2 (
+ f4 varchar(32) collate utf8_bin NOT NULL default '',
+ f2 varchar(50) collate utf8_bin default NULL,
+ f3 varchar(10) collate utf8_bin default NULL,
+ PRIMARY KEY (f4),
+ UNIQUE KEY uk1 (f2)
+);
+INSERT INTO t2 VALUES(1,1,null), (2,2,null);
+
+CREATE TABLE t1 (
+ f8 varchar(32) collate utf8_bin NOT NULL default '',
+ f1 varchar(10) collate utf8_bin default NULL,
+ f9 varchar(32) collate utf8_bin default NULL,
+ PRIMARY KEY (f8)
+);
+INSERT INTO t1 VALUES (1,'P',1), (2,'P',1), (3,'R',2);
+
+CREATE TABLE t3 (
+ f6 varchar(32) collate utf8_bin NOT NULL default '',
+ f5 varchar(50) collate utf8_bin default NULL,
+ PRIMARY KEY (f6)
+);
+INSERT INTO t3 VALUES (1,null), (2,null);
+
+SELECT
+ IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
+ IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,
+ SUM(
+ IF(
+ (SELECT VPC.f2
+ FROM t2 VPC, t4 a2, t2 a3
+ WHERE
+ VPC.f4 = a2.f10 AND a3.f2 = a4
+ LIMIT 1) IS NULL,
+ 0,
+ t3.f5
+ )
+ ) AS a6
+FROM
+ t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
+GROUP BY a4;
+
+DROP TABLE t1, t2, t3, t4;
+
--echo End of 5.0 tests.
#
@@ -3194,3 +3248,4 @@ CREATE TABLE t1 (s1 char(1));
INSERT INTO t1 VALUES ('a');
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
DROP TABLE t1;
+
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 807d1e6b01e..6841b3cdd68 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -478,4 +478,47 @@ select round(a,b) as c from t1 order by c;
DROP TABLE t1, t2, t3, t4;
+#
+# Bug #33143: Incorrect ORDER BY for ROUND()/TRUNCATE() result
+#
+
+CREATE TABLE t1( a DECIMAL(4, 3), b INT );
+INSERT INTO t1 VALUES ( 1, 5 ), ( 2, 4 ), ( 3, 3 ), ( 4, 2 ), ( 5, 1 );
+SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c;
+SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c DESC;
+
+CREATE TABLE t2 ( a INT, b INT, c DECIMAL(5, 4) );
+
+INSERT INTO t2 VALUES ( 0, 1, 1.2345 ), ( 1, 2, 1.2345 ),
+ ( 3, 3, 1.2345 ), ( 2, 4, 1.2345 );
+
+SELECT a, b, MAX(ROUND(c, a))
+FROM t2
+GROUP BY a, b
+ORDER BY b;
+
+SELECT a, b, ROUND(c, a)
+FROM t2;
+
+CREATE TABLE t3( a INT, b DECIMAL(6, 3) );
+INSERT INTO t3 VALUES( 0, 1.5 );
+SELECT ROUND( b, a ) FROM t3;
+
+CREATE TABLE t4( a INT, b DECIMAL( 12, 0) );
+INSERT INTO t4 VALUES( -9, 1.5e9 );
+SELECT ROUND( b, a ) FROM t4;
+
+CREATE TABLE t5( a INT, b DECIMAL( 13, 12 ) );
+INSERT INTO t5 VALUES( 0, 1.5 );
+INSERT INTO t5 VALUES( 9, 1.5e-9 );
+SELECT ROUND( b, a ) FROM t5;
+
+CREATE TABLE t6( a INT );
+INSERT INTO t6 VALUES( 6 / 8 );
+SELECT * FROM t6;
+
+SELECT ROUND(20061108085411.000002);
+
+DROP TABLE t1, t2, t3, t4, t5, t6;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 7f769c50449..58ef9c1eff1 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3453,6 +3453,20 @@ DROP VIEW v2;
DROP VIEW v3;
DROP TABLE t1;
+--echo #
+--echo # Bug#29477: Not all fields of the target table were checked to have
+--echo # a default value when inserting into a view.
+--echo #
+create table t1(f1 int, f2 int not null);
+create view v1 as select f1 from t1;
+insert into v1 values(1);
+set @old_mode=@@sql_mode;
+set @@sql_mode=traditional;
+--error ER_NO_DEFAULT_FOR_VIEW_FIELD
+insert into v1 values(1);
+set @@sql_mode=@old_mode;
+drop view v1;
+drop table t1;
--echo End of 5.0 tests.
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index b5bae109f5f..d0eaaf1a764 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -65,6 +65,7 @@ create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
alter table t1 modify c char(4);
alter table t1 add d char(2);
+--error 1048
update t1 set a=NULL where a=10;
update t1 set c='mysql ab' where c='test';
update t1 set d=c;