diff options
author | Rex <rex.johnston@mariadb.com> | 2023-02-17 08:28:38 +1200 |
---|---|---|
committer | Rex <rex.johnston@mariadb.com> | 2023-02-17 08:28:38 +1200 |
commit | 07c0e1651c6129ad6068be337c8f2e2d2479bfb7 (patch) | |
tree | d985ace37a61a65064b4bb7743f3776833efb5ef | |
parent | 81faf41786cfcded18d5b20d341175367ef1453f (diff) | |
download | mariadb-git-bb-10.4-MDEV-29179.tar.gz |
MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer tracebb-10.4-MDEV-29179
JOIN::optimize_inner(), Condition pushdown from HAVING into WHERE
not shown in optimizer trace.
-rw-r--r-- | mysql-test/main/opt_trace.result | 19 | ||||
-rw-r--r-- | mysql-test/main/opt_trace.test | 11 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 |
3 files changed, 34 insertions, 0 deletions
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 2eef0da62bb..e8cd92274c3 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -8522,5 +8522,24 @@ SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d); a DROP TABLE t1; # +# MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace +# +CREATE TABLE t1 (a INT, b VARCHAR(1), KEY (a), KEY(b,a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES (4,'n'),(1,'h'),(NULL,'w'); +SET optimizer_trace= 'enabled=on'; +SELECT b, a FROM t1 WHERE b <> 'p' OR a = 4 GROUP BY b, a HAVING a <= 7; +b a +h 1 +n 4 +SELECT json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ), JSON_VALID(trace) FROM information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ) JSON_VALID(trace) +[ + { + "conds": "(t1.b <> 'p' or multiple equal(4, t1.a)) and t1.a <= 7", + "having": null + } +] 1 +DROP TABLE t1; +# # End of 10.4 tests # diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 0785d828a07..1a26f6d6f5d 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -678,5 +678,16 @@ SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d); DROP TABLE t1; --echo # +--echo # MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace +--echo # + +CREATE TABLE t1 (a INT, b VARCHAR(1), KEY (a), KEY(b,a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES (4,'n'),(1,'h'),(NULL,'w'); +SET optimizer_trace= 'enabled=on'; +SELECT b, a FROM t1 WHERE b <> 'p' OR a = 4 GROUP BY b, a HAVING a <= 7; +SELECT json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ), JSON_VALID(trace) FROM information_schema.optimizer_trace; +DROP TABLE t1; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0f8ead46ffc..1bbd8331ef3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2118,6 +2118,10 @@ JOIN::optimize_inner() select_lex->attach_to_conds, &cond_value); sel->attach_to_conds.empty(); + Json_writer_object wrapper(thd); + Json_writer_object pushd(thd, "condition_pushdown_from_having"); + pushd.add("conds", conds); + pushd.add("having", having); } } |