用于EagleEye3.0 规则集漏报和误报测试的示例项目,项目收集于github和gitee
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

466 lines
17 KiB

#
# Bug #47412: Valgrind warnings / user can read uninitalized memory
# using SP variables
#
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2 () RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists () ;
END|
CREATE PROCEDURE p3 ( arg1 VARCHAR(32) )
BEGIN
CALL p_not_exists ( );
END|
# should not return valgrind warnings
CALL p3 ( f2 () );
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
DROP SCHEMA testdb;
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2 () RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists () ;
END|
CREATE PROCEDURE p3 ( arg2 INTEGER )
BEGIN
CALL p_not_exists ( );
END|
# should not return valgrind warnings
CALL p3 ( f2 () );
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
DROP SCHEMA testdb;
CREATE SCHEMA testdb;
USE testdb;
CREATE FUNCTION f2 () RETURNS INTEGER
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
RETURN f_not_exists () ;
END|
# should not return valgrind warnings
SELECT f2 ();
f2 ()
NULL
DROP SCHEMA testdb;
USE test;
#
# Bug#50423: Crash on second call of a procedure dropping a trigger
#
DROP TABLE IF EXISTS t1;
DROP TRIGGER IF EXISTS tr1;
DROP PROCEDURE IF EXISTS p1;
CREATE TABLE t1 (f1 INTEGER);
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
CALL p1 ();
CALL p1 ();
ERROR HY000: Trigger does not exist
DROP TABLE t1;
DROP PROCEDURE p1;
#
# Bug#50423: Crash on second call of a procedure dropping a trigger
#
DROP TABLE IF EXISTS t1;
DROP TRIGGER IF EXISTS tr1;
DROP PROCEDURE IF EXISTS p1;
CREATE TABLE t1 (f1 INTEGER);
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
CALL p1 ();
CALL p1 ();
ERROR HY000: Trigger does not exist
DROP TABLE t1;
DROP PROCEDURE p1;
#
# Bug#54375: Error in stored procedure leaves connection
# in different default schema
#
SET @@SQL_MODE = 'STRICT_ALL_TABLES';
DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1;
USE db1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY);
INSERT INTO t1 VALUES (1);
CREATE FUNCTION f1 (
some_value int
)
RETURNS smallint
DETERMINISTIC
BEGIN
INSERT INTO t1 SET c1 = some_value;
RETURN(LAST_INSERT_ID());
END$$
DROP DATABASE IF EXISTS db2;
CREATE DATABASE db2;
USE db2;
SELECT DATABASE();
DATABASE()
db2
SELECT db1.f1(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT DATABASE();
DATABASE()
db2
USE test;
DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
#
# Bug#13105873:valgrind warning:possible crash in foreign
# key handling on subsequent create table if not exists
#
DROP DATABASE IF EXISTS testdb;
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE t1 (id1 INT PRIMARY KEY);
CREATE PROCEDURE `p1`()
BEGIN
CREATE TABLE IF NOT EXISTS t2(id INT PRIMARY KEY,
CONSTRAINT FK FOREIGN KEY (id) REFERENCES t1( id1 ));
END$
CALL p1();
# below stmt should not return valgrind warnings
CALL p1();
Warnings:
Note 1050 Table 't2' already exists
DROP DATABASE testdb;
USE test;
End of 5.1 tests
#
# BUG#13489996 valgrind:conditional jump or move depends on
# uninitialised values-field_blob
#
CREATE FUNCTION sf() RETURNS BLOB RETURN "";
SELECT sf();
sf()
DROP FUNCTION sf;
#
# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
#
SET @@SQL_MODE = '';
CREATE FUNCTION testf_bug11763507() RETURNS INT
BEGIN
RETURN 0;
END
$
CREATE PROCEDURE testp_bug11763507()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END
$
SELECT testf_bug11763507();
testf_bug11763507()
0
SELECT TESTF_bug11763507();
TESTF_bug11763507()
0
SHOW FUNCTION STATUS LIKE 'testf_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW FUNCTION STATUS LIKE 'TESTF_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testf_bug11763507 FUNCTION root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE FUNCTION testf_bug11763507;
Function sql_mode Create Function character_set_client collation_connection Database Collation
testf_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
BEGIN
RETURN 0;
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE FUNCTION TESTF_bug11763507;
Function sql_mode Create Function character_set_client collation_connection Database Collation
testf_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
BEGIN
RETURN 0;
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
CALL testp_bug11763507();
PROCEDURE testp_bug11763507
PROCEDURE testp_bug11763507
CALL TESTP_bug11763507();
PROCEDURE testp_bug11763507
PROCEDURE testp_bug11763507
SHOW PROCEDURE STATUS LIKE 'testp_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW PROCEDURE STATUS LIKE 'TESTP_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test testp_bug11763507 PROCEDURE root@localhost # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE PROCEDURE testp_bug11763507;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
testp_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SHOW CREATE PROCEDURE TESTP_bug11763507;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
testp_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
BEGIN
SELECT "PROCEDURE testp_bug11763507";
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
SPECIFIC_NAME
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
SPECIFIC_NAME
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
SPECIFIC_NAME
testf_bug11763507
SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
SPECIFIC_NAME
testf_bug11763507
DROP PROCEDURE testp_bug11763507;
DROP FUNCTION testf_bug11763507;
#END OF BUG#11763507 test.
#
# Bug#19418619 : SELECT QUERY WITH INVALID TIME WORKS FINE BUT SP FAILS UNDER STRICT MODE
#
SET sql_mode='NO_ENGINE_SUBSTITUTION';
CREATE FUNCTION f1(arg TINYINT UNSIGNED) RETURNS TINYINT
BEGIN
RETURN abs('1abcd');
END|
SELECT f1(-25);
f1(-25)
1
Warnings:
Warning 1264 Out of range value for column 'arg' at row 1
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
SELECT f1(25);
f1(25)
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
SET sql_mode=default;
SELECT f1(-25);
ERROR 22003: Out of range value for column 'arg' at row 1
SELECT f1(10);
f1(10)
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
DROP FUNCTION f1;
SET sql_mode='NO_ENGINE_SUBSTITUTION';
CREATE PROCEDURE f1(IN arg TINYINT UNSIGNED)
BEGIN
DECLARE arg1 TINYINT;
select abs('1abcd') into arg;
END|
CALL f1(-25);
Warnings:
Warning 1264 Out of range value for column 'arg' at row 1
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
CALL f1(25);
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
SET sql_mode=default;
CALL f1(-25);
ERROR 22003: Out of range value for column 'arg' at row 1
CALL f1(10);
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1abcd'
DROP PROCEDURE f1;
SELECT SUBTIME('2006-07-16' , '05:05:02.040778');
SUBTIME('2006-07-16' , '05:05:02.040778')
-04:44:56.040778
Warnings:
Warning 1292 Truncated incorrect time value: '2006-07-16'
SELECT abs('1bcd');
abs('1bcd')
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1bcd'
CREATE PROCEDURE sp1()
BEGIN
SELECT SUBTIME('2006-07-16' , '05:05:02.040778');
END|
CREATE PROCEDURE sp2()
BEGIN
DECLARE v1 TINYINT DEFAULT 450000;
END|
CALL sp1();
SUBTIME('2006-07-16' , '05:05:02.040778')
-04:44:56.040778
Warnings:
Warning 1292 Truncated incorrect time value: '2006-07-16'
CALL sp2();
ERROR 22003: Out of range value for column 'v1' at row 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
CREATE FUNCTION fn1(arg TINYINT UNSIGNED) RETURNS float deterministic RETURN abs('1abcd');
CREATE FUNCTION fn2() RETURNS tinyint
BEGIN
DECLARE v1 TINYINT DEFAULT 450000;
RETURN v1;
END|
SELECT fn1(25);
ERROR 22007: Truncated incorrect DOUBLE value: '1abcd'
SELECT fn1(-25);
ERROR 22003: Out of range value for column 'arg' at row 1
SELECT fn2();
ERROR 22003: Out of range value for column 'v1' at row 1
SET sql_mode='NO_ENGINE_SUBSTITUTION';
SELECT fn1(-25);
ERROR 22007: Truncated incorrect DOUBLE value: '1abcd'
DROP FUNCTION fn1;
DROP FUNCTION fn2;
CREATE FUNCTION fn1() RETURNS float deterministic RETURN floor('1.1a');
SET sql_mode=default;
CREATE TABLE t1(a INT);
CREATE FUNCTION fn2() RETURNS float deterministic RETURN floor('1.1a');
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=fn2();
INSERT INTO t1 VALUES(1);
ERROR 22007: Truncated incorrect DOUBLE value: '1.1a'
DROP TRIGGER tr1;
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=fn1();
INSERT INTO t1 VALUES(1);
DROP FUNCTION fn1;
DROP FUNCTION fn2;
DROP TRIGGER tr1;
DROP TABLE t1;
SET sql_mode=traditional;
SELECT 1/0;
1/0
NULL
Warnings:
Warning 1365 Division by 0
SET sql_mode='';
CREATE PROCEDURE proc_c()
BEGIN
DECLARE div_zero INTEGER;
SET SQL_MODE='TRADITIONAL';
SELECT 1/0;
END|
CALL proc_c();
1/0
NULL
Warnings:
Warning 1365 Division by 0
DROP PROCEDURE proc_c;
SET sql_mode=traditional;
CREATE FUNCTION fn1() RETURNS TINYINT
BEGIN
SET @x=floor('1a');
RETURN 1;
END|
SELECT fn1();
fn1()
1
DROP FUNCTION fn1;
SET sql_mode= default;
#
# Bug#24401273: PROBLEM WITH STORED FUNCTION WHICH GENERATES
# BIGINT UNSIGNED USED IN WHERE CLAUSE
#
# Note: The AND TRUE is to work around Bug #24457368.
#
CREATE FUNCTION crc(_text TEXT) RETURNS BIGINT(20) UNSIGNED DETERMINISTIC
RETURN CONV(LEFT(MD5(_text),16),16,10);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
CREATE TABLE t1 (
id bigint(20) UNSIGNED NOT NULL
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 (id) VALUES (crc('photos'));
INSERT INTO t1 (id) VALUES (crc('photos1'));
ALTER TABLE t1 ADD INDEX idx (id);
SELECT * FROM t1 FORCE INDEX (idx) WHERE (id = crc('photos')) AND TRUE;
id
15460588431078774149
SELECT * FROM t1 IGNORE INDEX (idx) WHERE (id = crc('photos')) AND TRUE;
id
15460588431078774149
DROP FUNCTION crc;
DROP TABLE t1;
# Bug#25398451: Segmentation fault in prepare_inner() at sql_call.cc
CREATE TABLE t1(a INTEGER, b INTEGER);
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW
BEGIN
CALL proc(NEW.a,NEW.b);
END |
CREATE PROCEDURE proc(IN aa INTEGER)
BEGIN
END |
INSERT INTO t1 VALUES (1,10);
ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc; expected 1, got 2
DROP PROCEDURE proc;
DROP TABLE t1;
#
# Bug#28122841 - CREATE EVENT/PROCEDURE/FUNCTION CRASHES WITH ACCENT INSENSITIVE NAMES.
#
SET NAMES utf8;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
#
# Test case to verify stored procedure with case and accent insensitive names.
#
CREATE PROCEDURE cafe() BEGIN END;
# Stored procedure names are case and accent insensitive. So from the
# data-dictionary "cafe" is obtained for the following statement. Since
# MDL key comparison is case and accent sensitive, assert condition to verify
# expected lock with name "test.cafe" fails (lock is obtained on the
# test.café).
CREATE PROCEDURE café() BEGIN END;
ERROR 42000: PROCEDURE café already exists
# Following statement is to verify operation with the upper case name.
CREATE PROCEDURE CAFE() BEGIN END;
ERROR 42000: PROCEDURE CAFE already exists
DROP PROCEDURE CaFé;
# Procedure with NAME_LEN size name.
CREATE PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_e() BEGIN END;
CREATE PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é() BEGIN END;
ERROR 42000: PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é already exists
CREATE PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_E() BEGIN END;
ERROR 42000: PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_E already exists
SHOW CREATE PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_e ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_e`()
BEGIN END utf8 utf8_general_ci utf8mb4_0900_ai_ci
DROP PROCEDURE очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é;
#
# Test case to verify stored function with case and accent insensitive names.
#
CREATE FUNCTION cafe() RETURNS INT return 15081947;
# Stored function names are case and accent insensitive. So from the
# data-dictionary "cafe" is obtained for the following statement. Since
# MDL key comparison is case and accent sensitive, assert condition to verify
# expected lock with name "test.cafe" fails (lock is obtained on the
# test.café).
CREATE FUNCTION café() RETURNS INT return 15081947;
ERROR 42000: FUNCTION café already exists
# Following statement is to verify operation with the upper case name.
CREATE FUNCTION CAFE() RETURNS INT return 15081947;
ERROR 42000: FUNCTION CAFE already exists
SHOW CREATE FUNCTION CaFé;
Function sql_mode Create Function character_set_client collation_connection Database Collation
cafe # # # # #
DROP FUNCTION CaFé;
# Function with NAME_LEN size name.
CREATE FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_e() RETURNS INT return 15081947;
CREATE FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é() RETURNS INT return 15081947;
ERROR 42000: FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é already exists
CREATE FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_E() RETURNS INT return 15081947;
ERROR 42000: FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_E already exists
SHOW CREATE FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é;
Function sql_mode Create Function character_set_client collation_connection Database Collation
очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_e # # # # #
DROP FUNCTION очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_é;
SET NAMES default;