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

892 lines
26 KiB

drop table if exists t1,t2;
create table t1 (a int auto_increment , primary key (a));
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
update t1 set a=a+10 where a > 34;
update t1 set a=a+100 where a > 0;
update t1 set a=a+100 where a=1 and a=2;
update t1 set a=b+100 where a=1 and a=2;
ERROR 42S22: Unknown column 'b' in 'field list'
update t1 set a=b+100 where c=1 and a=2;
ERROR 42S22: Unknown column 'c' in 'where clause'
update t1 set d=a+100 where a=1;
ERROR 42S22: Unknown column 'd' in 'field list'
select * from t1;
a
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
145
146
drop table t1;
CREATE TABLE t1
(
place_id int (10) unsigned NOT NULL,
shows int(10) unsigned DEFAULT '0' NOT NULL,
ishows int(10) unsigned DEFAULT '0' NOT NULL,
ushows int(10) unsigned DEFAULT '0' NOT NULL,
clicks int(10) unsigned DEFAULT '0' NOT NULL,
iclicks int(10) unsigned DEFAULT '0' NOT NULL,
uclicks int(10) unsigned DEFAULT '0' NOT NULL,
ts timestamp,
PRIMARY KEY (place_id,ts)
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts)
VALUES (1,0,0,0,0,0,0,20000928174434);
UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00";
select place_id,shows from t1;
place_id shows
1 1
drop table t1;
create table t1 (a int not null, b int not null, key (a));
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
SET @tmp=0;
update t1 set b=(@tmp:=@tmp+1) order by a;
Warnings:
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
update t1 set b=99 where a=1 order by b asc limit 1;
select * from t1 order by a,b;
a b
1 2
1 3
1 99
2 4
2 5
2 6
3 7
3 8
3 9
3 10
3 11
3 12
update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
a b
2 4
2 5
2 6
3 7
3 8
3 9
3 10
3 11
3 12
13 2
111 100
111 100
create table t2 (a int not null, b int not null);
insert into t2 values (1,1),(1,2),(1,3);
update t1 set b=(select distinct 1 from (select * from t2) a);
drop table t1,t2;
create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid));
insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6),
('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2),
('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4),
('2','2','0',1,7);
delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3);
select * from t1;
F1 F2 F3 cnt groupid
0 0 0 1 6
0 1 2 1 5
0 2 0 1 3
1 0 1 1 2
1 2 1 1 1
2 0 1 2 4
2 2 0 1 7
drop table t1;
CREATE TABLE t1 (
`colA` int(10) unsigned NOT NULL auto_increment,
`colB` int(11) NOT NULL default '0',
PRIMARY KEY (`colA`)
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 VALUES (4433,5424);
CREATE TABLE t2 (
`colC` int(10) unsigned NOT NULL default '0',
`colA` int(10) unsigned NOT NULL default '0',
`colD` int(10) unsigned NOT NULL default '0',
`colE` int(10) unsigned NOT NULL default '0',
`colF` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`colC`,`colA`,`colD`,`colE`)
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
INSERT INTO t2 VALUES (3,4433,10005,495,500);
INSERT INTO t2 VALUES (3,4433,10005,496,500);
INSERT INTO t2 VALUES (3,4433,10009,494,500);
INSERT INTO t2 VALUES (3,4433,10011,494,500);
INSERT INTO t2 VALUES (3,4433,10005,497,500);
INSERT INTO t2 VALUES (3,4433,10013,489,500);
INSERT INTO t2 VALUES (3,4433,10005,494,500);
INSERT INTO t2 VALUES (3,4433,10005,493,500);
INSERT INTO t2 VALUES (3,4433,10005,492,500);
UPDATE IGNORE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF;
Warnings:
Warning 1062 Duplicate entry '3-4433-10005-493' for key 'PRIMARY'
Warning 1062 Duplicate entry '3-4433-10005-494' for key 'PRIMARY'
Warning 1062 Duplicate entry '3-4433-10005-495' for key 'PRIMARY'
Warning 1062 Duplicate entry '3-4433-10005-496' for key 'PRIMARY'
Warning 1062 Duplicate entry '3-4433-10005-497' for key 'PRIMARY'
SELECT * FROM t2;
colC colA colD colE colF
3 4433 10005 492 500
3 4433 10005 493 500
3 4433 10005 494 500
3 4433 10005 495 500
3 4433 10005 496 500
3 4433 10005 498 0
3 4433 10009 495 0
3 4433 10011 495 0
3 4433 10013 490 0
DROP TABLE t1;
DROP TABLE t2;
create table t1 (c1 int, c2 char(6), c3 int);
create table t2 (c1 int, c2 char(6));
insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2;
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
insert into t1 (id_str) values ("test");
update t1 set id_str = concat(id_str, id) where id = last_insert_id();
select * from t1;
id id_str
1 test1
drop table t1;
create table t1 (a int, b char(255), key(a, b(20)));
insert into t1 values (0, '1');
update t1 set b = b + 1 where a = 0;
select * from t1;
a b
0 2
drop table t1;
create table t1(f1 int, f2 int);
create table t2(f3 int, f4 int);
create index idx on t2(f3);
insert into t1 values(1,0),(2,0);
insert into t2 values(1,1),(2,2);
UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
select * from t1;
f1 f2
1 1
2 2
drop table t1,t2;
create table t1(f1 int);
select DATABASE();
DATABASE()
test
update t1 set f1=1 where count(*)=1;
ERROR HY000: Invalid use of group function
select DATABASE();
DATABASE()
test
delete from t1 where count(*)=1;
ERROR HY000: Invalid use of group function
drop table t1;
create table t1 ( a int, b int default 0, index (a) );
insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0);
flush status;
select a from t1 order by a limit 1;
a
0
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 0
flush status;
update t1 set a=9999 order by a limit 1;
update t1 set b=9999 order by a limit 1;
show status like 'handler_read%';
Variable_name Value
Handler_read_first 2
Handler_read_key 4
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 2
Handler_read_rnd_next 18
flush status;
delete from t1 order by a limit 1;
show status like 'handler_read%';
Variable_name Value
Handler_read_first 1
Handler_read_key 2
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 1
Handler_read_rnd_next 9
flush status;
delete from t1 order by a desc limit 1;
show status like 'handler_read%';
Variable_name Value
Handler_read_first 1
Handler_read_key 2
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 1
Handler_read_rnd_next 8
alter table t1 disable keys;
Warnings:
Note 1031 Table storage engine for 't1' doesn't have this option
flush status;
delete from t1 order by a limit 1;
show status like 'handler_read%';
Variable_name Value
Handler_read_first 1
Handler_read_key 3
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
select * from t1;
a b
0 0
0 0
0 0
0 0
0 0
update t1 set a=a+10,b=1 order by a limit 3;
update t1 set a=a+11,b=2 order by a limit 3;
update t1 set a=a+12,b=3 order by a limit 3;
select * from t1 order by a;
a b
11 2
21 2
22 3
22 3
23 3
drop table t1;
create table t1 (f1 int);
create table t2 (f2 int);
insert into t1 values(1),(2);
insert into t2 values(1),(1);
update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1;
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
update t2 set f2=1;
update t1 set f1=1 where f1=3;
update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1;
affected rows: 3
info: Rows matched: 3 Changed: 3 Warnings: 0
drop table t1,t2;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, filler1 char(200), filler2 char(200), key(a));
insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B;
flush status;
update t2 set a=3 where a=2;
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
Handler_read_last 0
Handler_read_next 1
Handler_read_prev 0
Handler_read_rnd 1
Handler_read_rnd_next 0
drop table t1, t2;
create table t1(f1 int, `*f2` int);
insert into t1 values (1,1);
update t1 set `*f2`=1;
drop table t1;
create table t1(f1 int);
update t1 set f2=1 order by f2;
ERROR 42S22: Unknown column 'f2' in 'field list'
drop table t1;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (
request_id int unsigned NOT NULL auto_increment,
user_id varchar(12) default NULL,
time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
ip_address varchar(15) default NULL,
PRIMARY KEY (request_id),
KEY user_id_2 (user_id,time_stamp)
);
INSERT INTO t1 (user_id) VALUES ('user1');
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
INSERT INTO t1(user_id) SELECT user_id FROM t1;
flush status;
SELECT user_id FROM t1 WHERE request_id=9999999999999;
user_id
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999;
user_id
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
DROP TABLE t1;
SET sql_mode = default;
CREATE TABLE t1 (
a INT(11),
quux decimal( 31, 30 ),
UNIQUE KEY bar (a),
KEY quux (quux)
);
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
INSERT INTO
t1 ( a, quux )
VALUES
( 1, 1 ),
( 2, 0.1 );
INSERT INTO t1( a )
SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1;
Warnings:
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
SELECT * FROM t1;
a quux
1 1.000000000000000000000000000000
2 0.100000000000000000000000000000
3 NULL
DROP TABLE t1;
set tmp_table_size=1024;
create table t1 (id int, a int, key idx(a));
create table t2 (id int unsigned not null auto_increment primary key, a int);
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
insert into t2(a) select a from t2;
update t2 set a=id;
insert into t1 select * from t2;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
64
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 0
info: Rows matched: 64 Changed: 0 Warnings: 0
insert into t2(a) select a from t2;
update t2 set a=id;
truncate t1;
insert into t1 select * from t2;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
128
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 0
info: Rows matched: 128 Changed: 0 Warnings: 0
update t1 set a=1;
update t2 set a=1;
select count(*) from t1 join t2 on (t1.a=t2.a);
count(*)
16384
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 127
info: Rows matched: 128 Changed: 127 Warnings: 0
drop table t1,t2;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS INT RETURN f1();
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1);
UPDATE t1 SET i = 3 WHERE f1();
ERROR HY000: Recursive stored functions and triggers are not allowed.
UPDATE t1 SET i = f1();
ERROR HY000: Recursive stored functions and triggers are not allowed.
DROP TABLE t1;
DROP FUNCTION f1;
End of 5.0 tests
#
# Bug #47919 assert in open_table during ALTER temporary table
#
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
CREATE TEMPORARY TABLE t2 LIKE t1;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
ALTER TABLE t2 COMMENT = 'ABC';
UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
ALTER TABLE t2 COMMENT = 'DEF';
DROP TABLE t1, t2;
#
# Bug#50545: Single table UPDATE IGNORE crashes on join view in
# sql_safe_updates mode.
#
CREATE TABLE t1 ( a INT, KEY( a ) );
INSERT INTO t1 VALUES (0), (1);
CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12;
SET SESSION sql_safe_updates = 1;
UPDATE IGNORE v1 SET a = 1;
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
SET SESSION sql_safe_updates = DEFAULT;
DROP TABLE t1;
DROP VIEW v1;
#
# Bug#54734 assert in Diagnostics_area::set_ok_status
#
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
DROP TABLE IF EXISTS t1, not_exists;
DROP FUNCTION IF EXISTS f1;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk;
CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists);
CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13;
UPDATE v1 SET pk = 7 WHERE pk > 0;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v1;
DROP FUNCTION f1;
DROP TABLE t1;
SET sql_mode = default;
#
# Verify that UPDATE does the same number of handler_update
# operations, no matter if there is ORDER BY or not.
#
CREATE TABLE t1 (i INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (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);
CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2),
INDEX idx (a,b(1),c)) ENGINE=INNODB;
INSERT INTO t2 SELECT i, i, i, i FROM t1;
FLUSH STATUS;
START TRANSACTION;
UPDATE t2 SET d = 10 WHERE b = 10 LIMIT 5;
SET @binlog_handler_update= IF(@@global.log_bin AND @@global.binlog_format != 'STATEMENT', 1, 0);
SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE';
VARIABLE_VALUE + @binlog_handler_update
1
ROLLBACK;
FLUSH STATUS;
START TRANSACTION;
UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE';
VARIABLE_VALUE + @binlog_handler_update
1
ROLLBACK;
Same test with a different UPDATE.
ALTER TABLE t2 DROP INDEX idx, ADD INDEX idx2 (a, b);
FLUSH STATUS;
START TRANSACTION;
UPDATE t2 SET c = 10 LIMIT 5;
SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE';
VARIABLE_VALUE + @binlog_handler_update
5
ROLLBACK;
FLUSH STATUS;
START TRANSACTION;
UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;
SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE';
VARIABLE_VALUE + @binlog_handler_update
5
ROLLBACK;
DROP TABLE t1, t2;
# Bug#20454533: Assertion failed: sargables == 0 || *keyfields ...
CREATE TABLE t1(
a int,
c int,
e int,
f int,
g blob,
h int,
i int,
j blob,
unique key (g(221),c),
unique key (c,a,j(148)),
key (i)
) engine=innodb;
UPDATE (SELECT 1 AS a FROM t1 NATURAL JOIN t1 AS t2) AS x, t1
SET t1.e= x.a;
DROP TABLE t1;
# Bug #21143080: UPDATE ON VARCHAR AND TEXT COLUMNS PRODUCE INCORRECT
# RESULTS
CREATE TABLE t1 (a VARCHAR(50), b TEXT, c CHAR(50)) ENGINE=INNODB;
INSERT INTO t1 (a, b, c) VALUES ('start trail', '', 'even longer string');
UPDATE t1 SET b = a, a = 'inject';
SELECT a, b FROM t1;
a b
inject start trail
UPDATE t1 SET b = c, c = 'inject';
SELECT c, b FROM t1;
c b
inject even longer string
DROP TABLE t1;
#
# Bug#18698556: UPDATE ORDER BY DOES A FILESORT IF UPDATING
# A COLUMN IN THE INDEX
#
CREATE TABLE t1 (
a INTEGER,
b INTEGER,
c INTEGER,
d INTEGER,
KEY key1 (a,b,c)
);
INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7),
(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
explain UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1
UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1;
SELECT * FROM t1;
a b c d
1 1 1 4
2 2 72 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
explain UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`d` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1
UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1;
SELECT * FROM t1;
a b c d
1 1 1 4
2 2 72 72
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
INSERT INTO t1 (a,b,c,d) VALUES (5, 5, 1, 1), (5, 5, 2, 1), (5, 5, 4, 1);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
explain UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 3 where (`test`.`t1`.`a` = 5) order by `test`.`t1`.`b` limit 3
UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3;
SELECT * FROM t1;
a b c d
1 1 1 4
2 2 72 72
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
5 5 3 1
5 5 3 1
5 5 3 1
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
explain UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using filesort
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 62 where (`test`.`t1`.`a` > 4) order by `test`.`t1`.`b` limit 3
UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3;
SELECT * FROM t1;
a b c d
1 1 1 4
2 2 72 72
2 3 4 7
3 3 3 9
4 4 4 0
5 5 62 1
5 6 7 3
5 7 9 9
5 5 62 1
5 5 62 1
5 5 3 1
INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7),
(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 1
UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1;
SELECT * FROM t1;
a b c d
1 1 82 4
2 2 72 72
2 3 4 7
3 3 3 9
4 4 4 0
5 5 62 1
5 6 7 3
5 7 9 9
5 5 62 1
5 5 62 1
5 5 3 1
1 1 1 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
explain UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 82 order by `test`.`t1`.`b` limit 1
UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1;
SELECT * FROM t1;
a b c d
82 1 82 4
2 2 72 72
2 3 4 7
3 3 3 9
4 4 4 0
5 5 62 1
5 6 7 3
5 7 9 9
5 5 62 1
5 5 62 1
5 5 3 1
1 1 1 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
explain UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`b` = 82 order by `test`.`t1`.`d` limit 1
UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1;
SELECT * FROM t1;
a b c d
82 1 82 4
2 2 72 72
2 3 4 7
3 3 3 9
4 82 4 0
5 5 62 1
5 6 7 3
5 7 9 9
5 5 62 1
5 5 62 1
5 5 3 1
1 1 1 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7),
(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9);
INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7),
(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary
Warnings:
Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 2
UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2;
SELECT * FROM t1;
a b c d
82 1 82 4
2 2 72 72
2 3 4 7
3 3 3 9
4 82 4 0
5 5 62 1
5 6 7 3
5 7 9 9
5 5 62 1
5 5 62 1
5 5 3 1
1 1 82 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
1 1 82 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
1 1 1 4
2 2 2 5
2 3 4 7
3 3 3 9
4 4 4 0
5 5 5 1
5 6 7 3
5 7 9 9
DROP TABLE t1;
# End of test for Bug#18698556
#
# Bug#21944866: REFACTORING: REMOVE KILL_BAD_DATA
#
CREATE TABLE t1 (a INT PRIMARY KEY, b DATE);
UPDATE t1 SET b= NULL WHERE a < '00:38:47.008761';
ERROR 22007: Truncated incorrect DOUBLE value: '00:38:47.008761'
DROP TABLE t1;
#
# Bug#21032418: PERFORMANCE REGRESSION IN 5.6: UPDATE DOES NOT USE INDEX
#
CREATE TABLE t1(
id INTEGER NOT NULL AUTO_INCREMENT,
token VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id),
KEY token (token)
)DEFAULT CHARSET=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.
INSERT INTO t1 VALUES (1, "abc"), (2, "def");
SET sql_mode='';
UPDATE t1 SET token = X'ad';
Warnings:
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 2
SELECT * FROM t1;
id token
1
2
EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1
Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad)
UPDATE t1 SET token = NULL WHERE token = X'ad';
Warnings:
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1
SET sql_mode=default;
EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1
Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad)
UPDATE t1 SET token = NULL WHERE token = X'ad';
Warnings:
Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1
SELECT * FROM t1;
id token
1
2
DROP TABLE t1;
# End of test for Bug#21032418
#
# Bug #29047894: ASSERTION FAILURE: ROW0MYSQL.CC:2387:TRX->ALLOW_SEMI_CONSISTENT()
#
CREATE TABLE t1 (a INTEGER);
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
INSERT INTO t1 VALUES (0);
UPDATE t1 SET a=1 ORDER BY CAST('invalid' AS DATETIME);
ERROR 22007: Incorrect datetime value: 'invalid'
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
DELETE FROM t1 WHERE a=2;
DROP TABLE t1;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;