Commit a70f7aa5 authored by Igor Babaev's avatar Igor Babaev

Backported the fix and the test case for bug 12822678 from the mysql-5.6 code line.

Fixed a bug in select_describe.
Adjusted results for affected test cases.
parent 0efacfcf
...@@ -614,6 +614,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); ...@@ -614,6 +614,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # BUG#12822678 - ICP WITH STRAIGHT_JOIN
--echo #
CREATE TABLE t1 (
i1 INTEGER NOT NULL,
d1 DOUBLE,
KEY k1 (d1)
);
INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL);
CREATE TABLE t2 (
pk INTEGER NOT NULL,
i1 INTEGER NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t2 VALUES (4,1);
EXPLAIN
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
DROP TABLE t1, t2;
--echo # --echo #
--echo # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 --echo # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
--echo # --echo #
......
...@@ -575,6 +575,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); ...@@ -575,6 +575,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
col999 col999
DROP TABLE t1; DROP TABLE t1;
# #
# BUG#12822678 - ICP WITH STRAIGHT_JOIN
#
CREATE TABLE t1 (
i1 INTEGER NOT NULL,
d1 DOUBLE,
KEY k1 (d1)
);
INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL);
CREATE TABLE t2 (
pk INTEGER NOT NULL,
i1 INTEGER NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t2 VALUES (4,1);
EXPLAIN
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k1 9 NULL 3 Using index
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
d1 pk i1
1 4 1
DROP TABLE t1, t2;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
# #
CREATE TABLE t1 ( f11 int) ; CREATE TABLE t1 ( f11 int) ;
......
...@@ -581,6 +581,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); ...@@ -581,6 +581,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
col999 col999
DROP TABLE t1; DROP TABLE t1;
# #
# BUG#12822678 - ICP WITH STRAIGHT_JOIN
#
CREATE TABLE t1 (
i1 INTEGER NOT NULL,
d1 DOUBLE,
KEY k1 (d1)
);
INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL);
CREATE TABLE t2 (
pk INTEGER NOT NULL,
i1 INTEGER NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t2 VALUES (4,1);
EXPLAIN
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k1 9 NULL 3 Using index
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
d1 pk i1
1 4 1
DROP TABLE t1, t2;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
# #
CREATE TABLE t1 ( f11 int) ; CREATE TABLE t1 ( f11 int) ;
......
...@@ -579,6 +579,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); ...@@ -579,6 +579,32 @@ SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
col999 col999
DROP TABLE t1; DROP TABLE t1;
# #
# BUG#12822678 - ICP WITH STRAIGHT_JOIN
#
CREATE TABLE t1 (
i1 INTEGER NOT NULL,
d1 DOUBLE,
KEY k1 (d1)
);
INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL);
CREATE TABLE t2 (
pk INTEGER NOT NULL,
i1 INTEGER NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t2 VALUES (4,1);
EXPLAIN
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k1 9 NULL 3 Using index
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
d1 pk i1
1 4 1
DROP TABLE t1, t2;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
# #
CREATE TABLE t1 ( f11 int) ; CREATE TABLE t1 ( f11 int) ;
......
...@@ -369,7 +369,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo ...@@ -369,7 +369,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index
4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index condition 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))
......
...@@ -374,7 +374,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo ...@@ -374,7 +374,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index
4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index condition 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))
......
...@@ -370,7 +370,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo ...@@ -370,7 +370,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index
4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index condition 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))
......
...@@ -373,7 +373,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo ...@@ -373,7 +373,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index
4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index condition 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))
......
...@@ -370,7 +370,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo ...@@ -370,7 +370,7 @@ EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index
4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index condition 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))
......
...@@ -322,7 +322,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) ...@@ -322,7 +322,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
HA_DO_INDEX_COND_PUSHDOWN) && HA_DO_INDEX_COND_PUSHDOWN) &&
optimizer_flag(tab->join->thd, OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN) && optimizer_flag(tab->join->thd, OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN) &&
tab->join->thd->lex->sql_command != SQLCOM_UPDATE_MULTI && tab->join->thd->lex->sql_command != SQLCOM_UPDATE_MULTI &&
tab->join->thd->lex->sql_command != SQLCOM_DELETE_MULTI) tab->join->thd->lex->sql_command != SQLCOM_DELETE_MULTI &&
tab->type != JT_CONST && tab->type != JT_SYSTEM)
{ {
DBUG_EXECUTE("where", DBUG_EXECUTE("where",
print_where(tab->select_cond, "full cond", QT_ORDINARY);); print_where(tab->select_cond, "full cond", QT_ORDINARY););
......
...@@ -20750,7 +20750,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -20750,7 +20750,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
keylen_str_buf); keylen_str_buf);
tmp3.append(keylen_str_buf, length, cs); tmp3.append(keylen_str_buf, length, cs);
} }
if (tab->select && tab->select->quick) if (tab->type != JT_CONST && tab->select && tab->select->quick)
tab->select->quick->add_keys_and_lengths(&tmp2, &tmp3); tab->select->quick->add_keys_and_lengths(&tmp2, &tmp3);
if (key_info || (tab->select && tab->select->quick)) if (key_info || (tab->select && tab->select->quick))
{ {
......
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