Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
12.1
-
None
-
Unexpected results
Description
I got interesting behavior when doing multiple DELETE from three tables when there was data to delete: there was an empty ddl in information_schema.optimizer_trace, but if I use "explain delete ..." or conditions under which there was no data to delete , I got a normal table description.
Testcase:
set optimizer_trace=1; |
set optimizer_record_context=ON; |
 |
create table t1(id1 int not null auto_increment primary key, t char(12)); |
create table t2(id2 int not null, t char(12)); |
create table t3(id3 int not null, t char(12)); |
--disable_query_log
|
begin; |
let $1 = 100;
|
while ($1)
|
{
|
let $2 = 5;
|
eval insert into t1(t) values ('$1'); |
while ($2)
|
{
|
eval insert into t2(id2,t) values ($1,'$2'); |
let $3 = 10;
|
while ($3)
|
{
|
eval insert into t3(id3,t) values ($1,'$2'); |
dec $3; |
}
|
dec $2; |
}
|
dec $1; |
}
|
commit; |
--enable_query_log
|
 |
select count(*) from t1 where id1 > 95; |
select count(*) from t2 where id2 > 95; |
select count(*) from t3 where id3 > 95; |
 |
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; |
set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace); |
select ddl |
from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt; |
 |
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; |
set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace); |
select ddl |
from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt; |
 |
drop table t1, t2, t3; |
Actual result:
First call of DELETE - there is no data in the dll, the second - there is:
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; |
set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace); |
select ddl |
from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt; |
ddl
|
delete t1.*, t2.*, t3.* from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3 and t1.id1 > 95; |
set @ddls= (select json_detailed(json_extract(trace, '$**.ddl')) from information_schema.optimizer_trace); |
select ddl |
from json_table(@ddls, '$[*]' columns(ddl text path '$')) as jt; |
ddl
|
CREATE TABLE `t3` ( |
`id3` int(11) NOT NULL, |
`t` char(12) DEFAULT NULL |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
CREATE TABLE `t2` ( |
`id2` int(11) NOT NULL, |
`t` char(12) DEFAULT NULL |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
CREATE TABLE `t1` ( |
`id1` int(11) NOT NULL AUTO_INCREMENT, |
`t` char(12) DEFAULT NULL, |
PRIMARY KEY (`id1`) |
) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
Attachments
Issue Links
- is caused by
-
MDEV-36483 Optimizer Trace Replay step #1: dump DDLs of tables/views
-
- Closed
-