Commit 2ae8dc24 authored by Igor Babaev's avatar Igor Babaev

Adjusted test results after rebase against 11.0.1

parent 12840543
......@@ -583,8 +583,7 @@ explain delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
select *from t1;
......@@ -600,8 +599,7 @@ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
order by c2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
1 PRIMARY a ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t1)
delete from t1
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
order by c2;
......
This diff is collapsed.
......@@ -13134,20 +13134,7 @@ EXPLAIN
"materialized": {
"query_block": {
"select_id": 3,
<<<<<<< 2ad65c4dbcb291867725d50d1f53c8da8549afb3
"cost": "COST_REPLACED",
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 2,
"cost": "COST_REPLACED",
"filtered": 100,
"attached_condition": "t1.f2 < 2"
}
=======
"filesort": {
"sort_key": "t1.f2",
"temporary_table": {
......@@ -13156,7 +13143,9 @@ EXPLAIN
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 2,
"cost": "COST_REPLACED",
"filtered": 100,
"attached_condition": "t1.f2 < 2"
}
......
......@@ -243,7 +243,7 @@ rows_examined sql_text
4 UPDATE t1 SET a=a+sleep(.02) WHERE a>2
8 UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC
1 UPDATE t2 set b=b+sleep(.02) limit 1
10 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2
disconnect con2;
connection default;
......
......@@ -1270,6 +1270,7 @@ DROP TABLES t1, t2;
# End of 10.3 tests
#
# MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
#
create table t1 (c1 int, c2 int, c3 int, index idx(c2));
insert into t1 values
(1,1,1),(3,2,2),(1,3,3),
......
......@@ -218,16 +218,14 @@ INSERT INTO t2 VALUES (1), (2), (3);
#
EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 Using where
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
......@@ -248,9 +246,9 @@ Handler_read_key 4
Handler_read_rnd_next 5
# Status of testing query execution:
Variable_name Value
Handler_read_key 5
Handler_read_key 4
Handler_read_rnd 3
Handler_read_rnd_next 12
Handler_read_rnd_next 9
Handler_update 3
DROP TABLE t1, t2;
......@@ -904,15 +902,13 @@ INSERT INTO t2 VALUES (1), (2), (3), (1000);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1)
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(t1)
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 4
......@@ -933,8 +929,8 @@ Handler_read_key 4
Handler_read_rnd_next 9
# Status of testing query execution:
Variable_name Value
Handler_read_key 7
Handler_read_rnd_next 8
Handler_read_key 4
Handler_read_rnd_next 10
Handler_update 3
DROP TABLE t1, t2;
......@@ -2828,14 +2824,14 @@ INSERT INTO t2 VALUES (1), (2), (3);
EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 FirstMatch(t1)
1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1
3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
# Status of EXPLAIN EXTENDED query
Variable_name Value
......
......@@ -4495,7 +4495,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"rowid_filters": [
{
"key": "a",
"build_cost": 0.174715752,
"build_cost": 0.001129926,
"rows": 3
}
]
......@@ -4570,7 +4570,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"rowid_filters": [
{
"key": "a",
"build_cost": 0.174715752,
"build_cost": 0.001129926,
"rows": 3
}
]
......
......@@ -634,6 +634,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -387,6 +387,12 @@ insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
select * from t12;
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
select * from t12;
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
-- error ER_SUBQUERY_NO_1_ROW
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -638,6 +638,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -641,6 +641,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -637,6 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -640,6 +640,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -637,6 +637,18 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
delete from t11;
delete from t12;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
......
......@@ -15,8 +15,9 @@ use dbt3_s001;
--enable_query_log
create index i_n_name on nation(n_name);
analyze table nation;
analyze table
nation, lineitem, customer, orders, part, supplier, partsupp, region
persistent for all;
--echo # Pullout
--echo # =======
......@@ -209,117 +210,148 @@ select c_name, c_acctbal from customer where $c6;
--echo # Materialization
--echo # ===============
set optimizer_switch='firstmatch=off';
let $c7=
c_nationkey in (select n_nationkey from nation where
n_name in ('JAPAN', 'INDONESIA', 'PERU', 'ARGENTINA'))
and
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08');
where o_orderDATE between "1992-01-09" and "1995-01-08");
eval
explain
select c_name, c_acctbal from customer where $c7;
eval
explain format=json
select c_name, c_acctbal from customer where $c7;
eval
select c_name, c_acctbal from customer where $c7;
eval
explain
update customer set c_acctbal = c_acctbal+5 where $c7;
update customer set c_acctbal = c_acctbal+20 where $c7;
eval
explain format=json
update customer set c_acctbal = c_acctbal+5 where $c7;
eval
update customer set c_acctbal = c_acctbal+5 where $c7;
update customer set c_acctbal = c_acctbal+20 where $c7;
eval
select c_name, c_acctbal from customer where $c7;
eval
update customer set c_acctbal = c_acctbal-5 where $c7;
update customer set c_acctbal = c_acctbal-20 where $c7;
eval
select c_name, c_acctbal from customer where $c7;
set optimizer_switch='firstmatch=default';
let $c8=
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-06-09' and '1993-01-08');
where o_orderDATE between '1992-01-09' and '1993-03-08');
eval
explain
select c_name, c_acctbal from customer where $c8;
eval
explain format=json
select c_name, c_acctbal from customer where $c8;
eval
select c_name, c_acctbal from customer where $c8;
eval
explain
update customer set c_acctbal = c_acctbal+1 where $c8;
update customer set c_acctbal = c_acctbal+5 where $c8;
eval
update customer set c_acctbal = c_acctbal+1 where $c8;
explain format=json
update customer set c_acctbal = c_acctbal+5 where $c8;
eval
update customer set c_acctbal = c_acctbal+5 where $c8;
eval
select c_name, c_acctbal from customer where $c8;
eval
update customer set c_acctbal = c_acctbal-1 where $c8;
update customer set c_acctbal = c_acctbal-5 where $c8;
eval
select c_name, c_acctbal from customer where $c8;
let $c9=
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-06-09' and '1993-01-08');
eval
explain
select c_name, c_acctbal from customer where $c9;
eval
select c_name, c_acctbal from customer where $c9;
eval
explain
update customer set c_acctbal = c_acctbal+1 where $c9;
eval
update customer set c_acctbal = c_acctbal+1 where $c9;
eval
select c_name, c_acctbal from customer where $c9;
eval
update customer set c_acctbal = c_acctbal-1 where $c9;
eval
select c_name, c_acctbal from customer where $c9;
--echo # Materialization SJM
--echo # ===================
let $c9=
let $c10=
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1992-03-08'
group by o_custkey having count(o_custkey) > 1);
eval
explain
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
eval
explain format=json
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
eval
explain
update customer set c_acctbal = c_acctbal-5 where $c9;
update customer set c_acctbal = c_acctbal-5 where $c10;
eval
explain format=json
update customer set c_acctbal = c_acctbal-5 where $c9;
update customer set c_acctbal = c_acctbal-5 where $c10;
eval
update customer set c_acctbal = c_acctbal-5 where $c9;
update customer set c_acctbal = c_acctbal-5 where $c10;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
eval
update customer set c_acctbal = c_acctbal+5 where $c9;
update customer set c_acctbal = c_acctbal+5 where $c10;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
let $c10=
let $c11=
c_custkey in (select o_custkey from orders
where o_orderDATE between '1992-01-09' and '1993-03-08'
group by o_custkey having count(o_custkey) > 5);
eval
explain
select c_name, c_acctbal from customer where $c10;
select c_name, c_acctbal from customer where $c11;
eval
select c_name, c_acctbal from customer where $c10;
select c_name, c_acctbal from customer where $c11;
eval
explain
update customer set c_acctbal = c_acctbal-1 where $c10;
update customer set c_acctbal = c_acctbal-1 where $c11;
eval
update customer set c_acctbal = c_acctbal-1 where $c10;
update customer set c_acctbal = c_acctbal-1 where $c11;
eval
select c_name, c_acctbal from customer where $c10;
select c_name, c_acctbal from customer where $c11;
eval
update customer set c_acctbal = c_acctbal+1 where $c10;
update customer set c_acctbal = c_acctbal+1 where $c11;
eval
select c_name, c_acctbal from customer where $c10;
select c_name, c_acctbal from customer where $c11;
--echo # Pullout PS
......@@ -350,6 +382,8 @@ deallocate prepare stmt;
--echo # FirstMatch PS
--echo # =============
set optimizer_switch='materialization=off';
eval
prepare stmt from "
update customer set c_acctbal = c_acctbal+? where $c5;
......@@ -371,28 +405,29 @@ select c_name, c_acctbal from customer where $c5;
deallocate prepare stmt;
set optimizer_switch='materialization=default';
--echo # Materialization PS
--echo # ==================
eval
prepare stmt from "
update customer set c_acctbal = c_acctbal+? where $c7;
update customer set c_acctbal = c_acctbal+? where $c8;
";
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
set @a1=7;
execute stmt using @a1;
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
set @a2=3;
execute stmt using @a2;
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
execute stmt using -(@a1+@a2);
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
deallocate prepare stmt;
......@@ -402,22 +437,22 @@ deallocate prepare stmt;
eval
prepare stmt from "
update customer set c_acctbal = c_acctbal+? where $c9;
update customer set c_acctbal = c_acctbal+? where $c10;
";
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
set @a1=-2;
execute stmt using @a1;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
set @a2=-1;
execute stmt using @a2;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
execute stmt using -(@a1+@a2);
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
deallocate prepare stmt;
......@@ -447,6 +482,8 @@ drop procedure p;
--echo # FirstMatch SP
--echo # =============
set optimizer_switch='materialization=off';
eval
create procedure p(d int)
update customer set c_acctbal = c_acctbal+d where $c5;
......@@ -465,25 +502,27 @@ select c_name, c_acctbal from customer where $c5;
drop procedure p;
set optimizer_switch='materialization=default';
--echo # Materialization SP
--echo # ==================
eval
create procedure p(d int)
update customer set c_acctbal = c_acctbal+d where $c7;
update customer set c_acctbal = c_acctbal+d where $c8;
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
call p(3);
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
call p(7);
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
call p(-(3+7));
eval
select c_name, c_acctbal from customer where $c7;
select c_name, c_acctbal from customer where $c8;
drop procedure p;
......@@ -493,19 +532,19 @@ drop procedure p;
eval
create procedure p(d int)
update customer set c_acctbal = c_acctbal+d where $c9;
update customer set c_acctbal = c_acctbal+d where $c10;
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
call p(-1);
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
call p(-2);
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
call p(1+2);
eval
select c_name, c_acctbal from customer where $c9;
select c_name, c_acctbal from customer where $c10;
drop procedure p;
......
......@@ -316,7 +316,7 @@ rollback;
#
explain update t1 set c1=0 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 2 Using where
1 PRIMARY t1 range t1_c2 t1_c2 5 NULL 2 Using index condition
1 PRIMARY a ref t1_c2 t1_c2 5 test.t1.c2 8 Using index; FirstMatch(t1)
start transaction;
update t1 set c1=c1+10 where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
......
......@@ -32592,7 +32592,8 @@ bool Sql_cmd_dml::execute_inner(THD *thd)
if (unlikely(thd->is_error()))
goto err;
join->exec();
if (join->exec())
goto err;
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment