Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
11.0
-
None
Description
Assuming the query printed by dbug_print(select_lex) should produce the same result as the original query, the following example shows dbug_print does not always follow this rule:
CREATE TABLE tbl_a ( |
a int, |
primary key (a) |
);
|
|
|
CREATE TABLE tbl_b ( |
c int, |
d int, |
primary key (c, d) |
);
|
|
|
INSERT INTO tbl_a VALUES (1), (2), (3); |
INSERT INTO tbl_b VALUES (1, 11), (2, 22), (3, 33); |
|
|
# original query
|
SELECT d FROM tbl_a JOIN tbl_b ON a = c WHERE a IN (1); |
# dbug_print(join->select_lex) before join->optimize(), ok: prduces one row |
select tbl_b.d AS d from (tbl_a join tbl_b on(tbl_a.a = tbl_b.c)) where tbl_a.a = 1; |
# dbug_print(join->select_lex) before join->exec(), not equivalent: produces three rows |
select tbl_b.d AS d from tbl_a join tbl_b where tbl_b.c = 1; |
|
|
drop table tbl_a,tbl_b; |
The table tbl_a was optimised into a const table, which might be why dbug_print prints a inequivalent query because the query does not capture this piece of information.