blob: 228ab42544d15eb77f72c75c7b604b384ef4accf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
--source include/have_innodb.inc
--disable_warnings
drop table if exists t1,t2;
drop procedure if exists p1;
--enable_warnings
--echo #
--echo #MDEV-6985: MariaDB crashes on stored procedure call
--echo #
CREATE TABLE `t1` (
`ID` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB;
CREATE TABLE `t2` (
`ID` int(11) NOT NULL,
`DATE` datetime DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB;
--delimiter ;;
CREATE PROCEDURE `p1`()
BEGIN
DECLARE _mySelect CURSOR FOR
SELECT DISTINCT t1.ID
FROM t1
LEFT JOIN t2 AS t2 ON
t2.ID = t1.ID
AND t2.DATE = (
SELECT MAX(T3.DATE) FROM t2 AS T3 WHERE T3.ID = t2.ID AND T3.DATE<=NOW()
)
WHERE t1.ID = 1;
OPEN _mySelect;
CLOSE _mySelect;
END ;;
--delimiter ;
CALL p1();
CALL p1();
drop procedure p1;
drop table t1,t2;
|