用于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.
 
 
 
 
 
 

305 lines
8.1 KiB

--source include/force_myisam_default.inc
--source include/have_myisam.inc
#
# Bug #16502: mysqlcheck tries to check views
#
create table t1 (a int) engine=myisam;
create view v1 as select * from t1;
--replace_result 'Table is already up to date' OK
--exec $MYSQL_CHECK --analyze --databases test
--exec $MYSQL_CHECK --optimize --databases test
--replace_result 'Table is already up to date' OK
--exec $MYSQL_CHECK --all-in-1 --analyze --databases test
--exec $MYSQL_CHECK --all-in-1 --optimize --databases test
drop view v1;
drop table t1;
#
# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
#
create table `t``1`(a int) engine=myisam;
create table `t 1`(a int) engine=myisam;
--replace_result 'Table is already up to date' OK
--exec $MYSQL_CHECK --databases test
drop table `t``1`, `t 1`;
#
# Bug#25347: mysqlcheck -A -r doesn't repair table marked as crashed
#
create database d_bug25347;
use d_bug25347;
create table t_bug25347 (a int) engine=myisam;
create view v_bug25347 as select * from t_bug25347;
insert into t_bug25347 values (1),(2),(3);
flush tables;
let $MYSQLD_DATADIR= `select @@datadir`;
--echo removing and creating
--remove_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
--write_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
EOF
--exec $MYSQL_CHECK --repair --databases d_bug25347
--error 130
insert into t_bug25347 values (4),(5),(6);
--exec $MYSQL_CHECK --repair --use-frm --databases d_bug25347
insert into t_bug25347 values (7),(8),(9);
select * from t_bug25347;
select * from v_bug25347;
drop view v_bug25347;
drop table t_bug25347;
drop database d_bug25347;
use test;
--echo #
--echo # Bug#20868496: MYSQL_UPGRADE IN 5.7.7+ REPAIR LOOKS USER TABLES
--echo # IN TEST WHEN LOAD FROM 50/51/55
--echo #
CREATE DATABASE db1;
CREATE DATABASE db2;
CREATE TABLE db1.t1 (a INT) ENGINE=MYISAM;
--remove_file $MYSQLD_DATADIR/db1/t1.MYI
--write_file $MYSQLD_DATADIR/db1/t1.MYI
EOF
CREATE TABLE db2.t2 (a INT);
--exec $MYSQL_CHECK --auto-repair --databases db1 db2 2>&1
DROP DATABASE db1;
DROP DATABASE db2;
--echo #
--echo # Bug#13926 --order-by-primary fails if PKEY contains quote character
--echo #
--disable_warnings
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a b` INT,
`c"d` INT,
`e``f` INT,
PRIMARY KEY (`a b`, `c"d`, `e``f`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into t1 values (0815, 4711, 2006);
--exec $MYSQL_DUMP --skip-comments --compatible=ansi --order-by-primary test t1
--exec $MYSQL_DUMP --skip-comments --order-by-primary test t1
DROP TABLE `t1`;
--enable_warnings
--echo #
--echo # Test of fix to Bug#12597 mysqldump dumps triggers wrongly
--echo #
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `test2`;
CREATE TABLE `test2` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DELIMITER //;
CREATE TRIGGER `testref` BEFORE INSERT ON `test1` FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1; END //
DELIMITER ;//
INSERT INTO `test1` VALUES (1);
SELECT * FROM `test2`;
# dump
--exec $MYSQL_DUMP --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql
#DROP TRIGGER testref;
#DROP TABLE test1;
#DROP TABLE test2;
# restore
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump.sql
--replace_column 6 #
SHOW TRIGGERS;
SELECT * FROM `test1`;
SELECT * FROM `test2`;
DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqldump.sql
--echo #
--echo # Test of fix to Bug#13146 ansi quotes break loading of triggers
--echo #
--disable_warnings
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
--enable_warnings
CREATE TABLE `t1 test` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `t2 test` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DELIMITER //;
CREATE TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
INSERT INTO `t2 test` SET a2 = NEW.a1; END //
DELIMITER ;//
INSERT INTO `t1 test` VALUES (1);
INSERT INTO `t1 test` VALUES (2);
INSERT INTO `t1 test` VALUES (3);
SELECT * FROM `t2 test`;
# dump with compatible=ansi. Everything except triggers should be double
# quoted
--exec $MYSQL_DUMP --skip-comments --compatible=ansi --triggers test
DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
#
# Bug#25993 crashes with a merge table and -c
#
CREATE TABLE t2 (a INT) ENGINE=MYISAM;
CREATE TABLE t3 (a INT) ENGINE=MYISAM;
CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
--exec $MYSQL_DUMP --skip-comments -c test
DROP TABLE t1, t2, t3;
--echo #
--echo # BUG#11766310 : 59398: MYSQLDUMP 5.1 CAN'T HANDLE A DASH ("-") IN
--echo # DATABASE NAMES IN ALTER DATABASE
--echo #
CREATE DATABASE `test-database`;
USE `test-database`;
CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
DELIMITER |;
CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
END |
DELIMITER ;|
ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
--exec $MYSQL_DUMP --quote-names --compact test-database
DROP DATABASE `test-database`;
# Switching back to test database.
USE test;
--echo #
--echo # BUG#11760384 : 52792: mysqldump in XML mode does not dump routines.
--echo #
CREATE DATABASE BUG52792;
USE BUG52792;
CREATE TABLE t1 (c1 INT, c2 VARCHAR(20)) ENGINE=MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
INSERT INTO t2 VALUES (1),(2),(3);
--echo # Stored Procedures.
DELIMITER //;
CREATE PROCEDURE simpleproc1 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t1;
END//
DELIMITER ;//
DELIMITER //;
CREATE PROCEDURE simpleproc2 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM t2;
END//
DELIMITER ;//
--echo # Events.
SET GLOBAL EVENT_SCHEDULER = OFF;
--source include/no_running_event_scheduler.inc
CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792;
--echo # Functions.
CREATE FUNCTION `hello1` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT('Hello, ' ,s ,'!');
CREATE FUNCTION `hello2` (s CHAR(20))
RETURNS CHAR(50) DETERMINISTIC
RETURN CONCAT(']]>, ' , s ,'!');
--echo # Triggers.
DELIMITER |;
CREATE TRIGGER trig1 BEFORE INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1);
END;
|
DELIMITER ;|
DELIMITER |;
CREATE TRIGGER trig2 AFTER INSERT ON t2
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES(1, ']]>');
INSERT INTO t2 VALUES(2, '<![CDATA]]>');
INSERT INTO t2 VALUES(3, '<![CDATA[');
INSERT INTO t2 VALUES(4, '< > & \ " _');
END;
|
DELIMITER ;|
--echo # Views
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
--echo
--echo # Dumping BUG52792 database in xml format.
--echo
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{2}/--TIMESTAMP--/ /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--exec $MYSQL_DUMP --user=root --compact -R -E --triggers -X BUG52792
--echo
--echo # Dumping BUG52792 database in xml format with comments.
--echo
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{2}/--TIMESTAMP--/ /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--exec $MYSQL_DUMP --comments --user=root -R -E --triggers -X BUG52792
--echo
--echo # Test to check 'Insufficient privileges' error.
--echo
CREATE USER user1;
GRANT ALL PRIVILEGES ON BUG52792.* TO user1;
connect (conn_1, localhost, user1, , BUG52792, $MASTER_MYPORT, $MASTER_MYSOCK);
connection conn_1;
--echo # Running 'replace_regex on timestamp'
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{2}/--TIMESTAMP--/ /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
--error 2
--exec $MYSQL_DUMP --user=user1 -R -E --triggers -X BUG52792
connection default;
disconnect conn_1;
DROP USER user1;
DROP DATABASE BUG52792;
SET NAMES default;
USE test;
SET GLOBAL EVENT_SCHEDULER = ON;
--source include/running_event_scheduler.inc