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

774 lines
12 KiB

drop table if exists t1,t2,t3;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
Warnings:
Warning 1062 Duplicate entry '16' for key 'PRIMARY'
Warning 1062 Duplicate entry '22' for key 'PRIMARY'
select * from t2;
payoutID
1
4
6
9
10
11
12
14
16
19
20
22
drop table t1,t2;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
insert into t1 values (a+2);
insert into t1 values (a+3);
insert into t1 values (4),(a+5);
insert into t1 select * from t1;
select * from t1;
a
1
1
2
2
3
3
4
4
5
5
insert into t1 select * from t1 as t2;
select * from t1;
a
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
5
5
5
5
insert into t2 select * from t1 as t2;
select * from t1;
a
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
5
5
5
5
insert into t1 select t2.a from t1,t2;
select * from t1;
a
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
insert into t1 select * from t1,t1;
ERROR 42000: Not unique table/alias: 't1'
drop table t1,t2;
create table t1 (a int not null primary key, b char(10));
create table t2 (a int not null, b char(10));
insert into t1 values (1,"t1:1"),(3,"t1:3");
insert into t2 values (2,"t2:2"), (3,"t2:3");
insert into t1 select * from t2;
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
select * from t1;
a b
1 t1:1
3 t1:3
replace into t1 select * from t2;
select * from t1;
a b
1 t1:1
2 t2:2
3 t2:3
drop table t1,t2;
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2;
create table t1 (f1 int);
create table t2 (ff1 int unique, ff2 int default 1);
insert into t1 values (1),(1),(2);
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
select * from t2;
ff1 ff2
1 2
2 1
drop table t1, t2;
create table t1 (a int unique);
create table t2 (a int, b int);
create table t3 (c int, d int);
insert into t1 values (1),(2);
insert into t2 values (1,2);
insert into t3 values (1,6),(3,7);
select * from t1;
a
1
2
insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
select * from t1;
a
2
3
insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
select * from t1;
a
3
5
insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
select * from t1;
a
1
10
5
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
ERROR 23000: Column 'a' in field list is ambiguous
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
ERROR 42S22: Unknown column 't2.a' in 'field list'
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
ERROR 42S22: Unknown column 't2.b' in 'field list'
drop table t1,t2,t3;
create table t1(f1 varchar(5) key);
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
select * from t1;
f1
2000
2001
2002
drop table t1;
create table t1(x int, y int);
create table t2(x int, z int);
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
ERROR 42S22: Unknown column 'z' in 'field list'
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
ERROR 42S22: Unknown column 't2.x' in 'field list'
drop table t1,t2;
CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 values (1), (2);
flush status;
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
show status like 'Handler_read%';
Variable_name Value
Handler_read_first 1
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 1
DROP TABLE t1;
CREATE TABLE t1 (
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
f2 varchar(100) NOT NULL default ''
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
CREATE TABLE t2 (
f1 varchar(10) NOT NULL default '',
f2 char(3) NOT NULL default '',
PRIMARY KEY (`f1`),
KEY `k1` (`f2`, `f1`)
);
INSERT INTO t1 values(NULL, '');
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
min(t2.f1)
INSERT INTO t1 (f2)
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT * FROM t1;
f1 f2
1
DROP TABLE t1, t2;
CREATE TABLE t1 (x int, y int);
CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
CREATE DATABASE bug21774_1;
CREATE DATABASE bug21774_2;
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
use bug21774_1;
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
DROP DATABASE bug21774_1;
DROP DATABASE bug21774_2;
USE test;
create table t1(f1 int primary key, f2 int);
insert into t1 values (1,1);
affected rows: 1
insert into t1 values (1,1) on duplicate key update f2=1;
affected rows: 0
insert into t1 values (1,1) on duplicate key update f2=2;
affected rows: 2
select * from t1;
f1 f2
1 2
drop table t1;
CREATE TABLE t1 (f1 INT, f2 INT );
CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT);
INSERT INTO t1 VALUES (1,1),(2,2),(10,10);
INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1;
INSERT INTO t2 (f1, f2)
SELECT f1, f1 FROM t2 src WHERE f1 < 2
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
SELECT * FROM t2;
f1 f2
2 2
10 10
101 1
DROP TABLE t1, t2;
CREATE TABLE t1 ( a INT KEY, b INT );
INSERT INTO t1 VALUES ( 0, 1 );
INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
DROP TABLE t1;
SET SQL_MODE=default;
CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10))) charset utf8mb4;
CREATE TABLE t2 (d VARCHAR(10));
INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters');
EXPLAIN
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 NULL index NULL ix_c 43 NULL 2 100.00 Using index
2 SUBQUERY t1 NULL ref ix_c ix_c 43 const 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select (/* select#2 */ select sum(length(`test`.`t1`.`c`)) from `test`.`t1` where (`test`.`t1`.`c` = '13_characters')) AS `(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')` from `test`.`t1`
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')
13
13
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
INSERT INTO t2 (d)
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1))
FROM t1;
SELECT * FROM t2;
d
13
13
7
7
20
20
DROP TABLE t1,t2;
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
prev_id INT,
join_id INT DEFAULT 0);
INSERT INTO t1 (prev_id) VALUES (NULL), (1), (2);
SELECT * FROM t1;
id prev_id join_id
1 NULL 0
2 1 0
3 2 0
CREATE TABLE t2 (join_id INT);
INSERT INTO t2 (join_id) VALUES (0);
INSERT INTO t1 (prev_id) SELECT id
FROM t2 LEFT JOIN t1 ON t1.join_id = t2.join_id
ORDER BY id DESC LIMIT 1;
SELECT * FROM t1;
id prev_id join_id
1 NULL 0
2 1 0
3 2 0
4 3 0
DROP TABLE t1,t2;
##################################################################
End of 5.0 tests
#
# Bug #21441405: DASH '-' IS NOT RECOGNIZED IN CHARSET
# ARMSCII8 ON SELECT WHERE QUERY
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
a VARCHAR(100) CHARACTER SET ARMSCII8
);
INSERT INTO t1 (a) VALUES('abc-def');
INSERT INTO t1 (a) VALUES(x'616263AC646566');
INSERT INTO t1 (a) VALUES('\'(),-.');
INSERT INTO t1 (a) VALUES(x'FFA5A4ABACA9');
SELECT *, HEX(a) FROM t1;
id a HEX(a)
1 abc-def 6162632D646566
2 abc-def 616263AC646566
3 '(),-. 2728292C2D2E
4 '(),-. FFA5A4ABACA9
SELECT *, HEX(a) FROM t1 WHERE a = 'abc-def';
id a HEX(a)
1 abc-def 6162632D646566
SELECT *, HEX(a) FROM t1 WHERE a = x'616263AC646566';
id a HEX(a)
2 abc-def 616263AC646566
SELECT *, HEX(a) FROM t1 WHERE a = '\'(),-.';
id a HEX(a)
3 '(),-. 2728292C2D2E
SELECT *, HEX(a) FROM t1 WHERE a = x'FFA5A4ABACA9';
id a HEX(a)
4 '(),-. FFA5A4ABACA9
DROP TABLE t1;