diff --git a/mysql-test/r/explain_other.result-pq b/mysql-test/r/explain_other.result-pq index 4c8791b051b8..5ce93e7649c6 100644 --- a/mysql-test/r/explain_other.result-pq +++ b/mysql-test/r/explain_other.result-pq @@ -32,11 +32,13 @@ id select_type table partitions type possible_keys key key_len ref rows filtered 2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt' id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)' id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL -1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1' id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL @@ -100,34 +102,27 @@ EXPLAIN "query_cost": "0.45" }, "table": { - "table_name": "t1", + "table_name": "", "access_type": "ALL", "rows_examined_per_scan": 2, "rows_produced_per_join": 2, "filtered": "100.00", + "parallel_execute": "4 workers", "cost_info": { "read_cost": "0.25", "eval_cost": "0.20", "prefix_cost": "0.45", - "data_read_per_join": "16" + "data_read_per_join": "32" }, "used_columns": [ "f1" - ] - } - } -} -EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)' -EXPLAIN -{ - "query_block": { - "select_id": 1, - "cost_info": { - "query_cost": "1.10" - }, - "nested_loop": [ - { + ], + "query_block": { + "cost_info": { + "query_cost": "0.45" + }, "table": { + "select_id": 2, "table_name": "t1", "access_type": "ALL", "rows_examined_per_scan": 2, @@ -143,29 +138,83 @@ EXPLAIN "f1" ] } + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" }, - { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows_examined_per_scan": 2, - "rows_produced_per_join": 2, - "filtered": "50.00", - "using_where": true, - "first_match": "t1", - "using_join_buffer": "hash join", - "cost_info": { - "read_cost": "0.25", - "eval_cost": "0.20", - "prefix_cost": "1.10", - "data_read_per_join": "16" + "used_columns": [ + "f1" + ], + "query_block": { + "cost_info": { + "query_cost": "1.10" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } }, - "used_columns": [ - "f1" - ] - } + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_where": true, + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + ] } - ] + } } } EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1' diff --git a/mysql-test/r/subselect_debug.result-pq b/mysql-test/r/subselect_debug.result-pq new file mode 100644 index 000000000000..5218bcaf01bd --- /dev/null +++ b/mysql-test/r/subselect_debug.result-pq @@ -0,0 +1,77 @@ +CREATE TABLE t1(id INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; +SET @orig_debug = @@debug; +SET SESSION debug="d,subselect_exec_fail"; +SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; +SUM(EXISTS(SELECT RAND() FROM t1)) +0 +SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); +REVERSE(EXISTS(SELECT RAND() FROM t1)) +0 +SET SESSION debug=@orig_debug; +DROP TABLE t1; +# +# Bug#21383882 ASSERTION FAILED: 0 IN SELECT_LEX::PRINT() +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(1); +SELECT ((SELECT 1 FROM t1) IN (SELECT 1 FROM t1)) - (11111111111111111111); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#26679495: SIG 11 IN SUBSELECT_HASH_SJ_ENGINE::CLEANUP +# +CREATE TABLE t (x INT); +INSERT INTO t VALUES (1), (2), (3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +# The subquery should be materialized so that we +# use subselect_hash_sj_engine. +EXPLAIN SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` where (`test`.`t`.`x`,`test`.`t`.`x` in ( (/* select#2 */ select count(0) from `test`.`t` group by `test`.`t`.`x` having true ), (`test`.`t`.`x` in on where ((`test`.`t`.`x` = ``.`COUNT(*)`))))) +SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +x +1 +# Execute the query with a simulated error in +# subselect_hash_sj_engine::setup(). +SET DEBUG='+d,hash_semijoin_fail_in_setup'; +SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +ERROR HY000: Unknown error +SET DEBUG='-d,hash_semijoin_fail_in_setup'; +DROP TABLE t; +# +# Bug#26679983: SIG 11 IN MAKE_JOIN_READINFO|SQL/SQL_SELECT.CC +# +CREATE TABLE t (x INT); +INSERT INTO t VALUES (1), (2), (3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +# We want nested loop with duplicate weedout to reproduce the bug. +SET optimizer_switch = 'firstmatch=off,materialization=off'; +EXPLAIN SELECT * FROM t WHERE x IN (SELECT x FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` semi join (`test`.`t`) where (`test`.`t`.`x` = `test`.`t`.`x`) +SELECT * FROM t WHERE x IN (SELECT x FROM t); +x +1 +2 +3 +# Execute the query with a simulated error in +# create_duplicate_weedout_tmp_table(). +SET DEBUG='+d,create_duplicate_weedout_tmp_table_error'; +SELECT * FROM t WHERE x IN (SELECT x FROM t); +ERROR HY000: Unknown error +SET DEBUG='-d,create_duplicate_weedout_tmp_table_error'; +DROP TABLE t; +SET optimizer_switch = DEFAULT; diff --git a/mysql-test/suite/parallel_query/r/pq_variables.result-pq b/mysql-test/suite/parallel_query/r/pq_variables.result-pq index e31cfd461afc..6ae23315b268 100644 --- a/mysql-test/suite/parallel_query/r/pq_variables.result-pq +++ b/mysql-test/suite/parallel_query/r/pq_variables.result-pq @@ -61,12 +61,14 @@ Warnings: Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` explain select/*+ PQ */ sum(id) from t1; id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL Warnings: Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` explain select/*+ PQ(10) */ sum(id) from t1; id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL Warnings: Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` ### test force_parallel query