[Maria-developers] [psergey@askmonty.org: [Commits] Rev 2921: BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) in file:///home/psergey/dev2/5.3/]
Hi Timour, Could you please review the below? (Asking you because the fix is in the loose index scan optimizer) ----- Forwarded message from Sergey Petrunya <psergey@askmonty.org> ----- From: Sergey Petrunya <psergey@askmonty.org> To: commits@mariadb.org X-Mailer: mail (GNU Mailutils 1.2) Date: Fri, 25 Feb 2011 12:59:00 +0300 (MSK) Subject: [Commits] Rev 2921: BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) in file:///home/psergey/dev2/5.3/ At file:///home/psergey/dev2/5.3/ ------------------------------------------------------------ revno: 2921 revision-id: psergey@askmonty.org-20110225095856-qgykwziqv5h1suqr parent: psergey@askmonty.org-20110224203200-4uf4e4kngwdmtmgw committer: Sergey Petrunya <psergey@askmonty.org> branch nick: 5.3 timestamp: Fri 2011-02-25 12:58:56 +0300 message: BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) - Make get_constant_key_infix() take into account that there may be SEL_TREEs with type=SEL_ARG::MAYBE_KEY, which it cannot process. check_quick_select() already has a check for such condition. === modified file 'mysql-test/r/subselect4.result' --- a/mysql-test/r/subselect4.result 2011-02-10 08:36:43 +0000 +++ b/mysql-test/r/subselect4.result 2011-02-25 09:58:56 +0000 @@ -689,3 +689,21 @@ 2 DEPENDENT SUBQUERY X ALL NULL NULL NULL NULL 10 2 DEPENDENT SUBQUERY B ALL a,b NULL NULL NULL 1000 Range checked for each record (index map: 0x3) drop table t1, t2; +# +# BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) +# +CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ; +INSERT INTO t1 VALUES ('8','c'),('5','f'); +ALTER TABLE t1 ADD KEY (f3,f1); +CREATE TABLE t2 ( f4 varchar(1)) ; +INSERT INTO t2 VALUES ('f'),('d'); +SELECT * FROM t2 +WHERE EXISTS ( +SELECT DISTINCT f3 +FROM t1 +WHERE f3 <= t2.f4 +); +f4 +f +d +drop table t1,t2; === modified file 'mysql-test/t/subselect4.test' --- a/mysql-test/t/subselect4.test 2011-02-10 08:36:43 +0000 +++ b/mysql-test/t/subselect4.test 2011-02-25 09:58:56 +0000 @@ -619,3 +619,24 @@ from t1 A; drop table t1, t2; + +--echo # +--echo # BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) +--echo # +CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ; +INSERT INTO t1 VALUES ('8','c'),('5','f'); + +ALTER TABLE t1 ADD KEY (f3,f1); + +CREATE TABLE t2 ( f4 varchar(1)) ; +INSERT INTO t2 VALUES ('f'),('d'); + +SELECT * FROM t2 +WHERE EXISTS ( + SELECT DISTINCT f3 + FROM t1 + WHERE f3 <= t2.f4 +); + +drop table t1,t2; + === modified file 'sql/opt_range.cc' --- a/sql/opt_range.cc 2011-02-22 09:15:47 +0000 +++ b/sql/opt_range.cc 2011-02-25 09:58:56 +0000 @@ -11857,7 +11857,8 @@ Find the range tree for the current keypart. We assume that index_range_tree points to the leftmost keypart in the index. */ - for (cur_range= index_range_tree; cur_range; + for (cur_range= index_range_tree; + cur_range && cur_range->type == SEL_ARG::KEY_RANGE; cur_range= cur_range->next_key_part) { if (cur_range->field->eq(cur_part->field)) _______________________________________________ commits mailing list commits@mariadb.org https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits ----- End forwarded message ----- -- BR Sergey -- Sergey Petrunia, Software Developer Monty Program AB, http://askmonty.org Blog: http://s.petrunia.net/blog
Sergey, I only suggest to change the comment so that it says that loose scan can process only range conditions, not that it cannot process SEL_TREEs with type=SEL_ARG::MAYBE_KEY. Ok to push. Timour
Hi Timour,
Could you please review the below? (Asking you because the fix is in the loose index scan optimizer)
----- Forwarded message from Sergey Petrunya<psergey@askmonty.org> -----
From: Sergey Petrunya<psergey@askmonty.org> To: commits@mariadb.org X-Mailer: mail (GNU Mailutils 1.2) Date: Fri, 25 Feb 2011 12:59:00 +0300 (MSK) Subject: [Commits] Rev 2921: BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) in file:///home/psergey/dev2/5.3/
At file:///home/psergey/dev2/5.3/
------------------------------------------------------------ revno: 2921 revision-id: psergey@askmonty.org-20110225095856-qgykwziqv5h1suqr parent: psergey@askmonty.org-20110224203200-4uf4e4kngwdmtmgw committer: Sergey Petrunya<psergey@askmonty.org> branch nick: 5.3 timestamp: Fri 2011-02-25 12:58:56 +0300 message: BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) - Make get_constant_key_infix() take into account that there may be SEL_TREEs with type=SEL_ARG::MAYBE_KEY, which it cannot process. check_quick_select() already has a check for such condition. === modified file 'mysql-test/r/subselect4.result' --- a/mysql-test/r/subselect4.result 2011-02-10 08:36:43 +0000 +++ b/mysql-test/r/subselect4.result 2011-02-25 09:58:56 +0000 @@ -689,3 +689,21 @@ 2 DEPENDENT SUBQUERY X ALL NULL NULL NULL NULL 10 2 DEPENDENT SUBQUERY B ALL a,b NULL NULL NULL 1000 Range checked for each record (index map: 0x3) drop table t1, t2; +# +# BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) +# +CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ; +INSERT INTO t1 VALUES ('8','c'),('5','f'); +ALTER TABLE t1 ADD KEY (f3,f1); +CREATE TABLE t2 ( f4 varchar(1)) ; +INSERT INTO t2 VALUES ('f'),('d'); +SELECT * FROM t2 +WHERE EXISTS ( +SELECT DISTINCT f3 +FROM t1 +WHERE f3<= t2.f4 +); +f4 +f +d +drop table t1,t2;
=== modified file 'mysql-test/t/subselect4.test' --- a/mysql-test/t/subselect4.test 2011-02-10 08:36:43 +0000 +++ b/mysql-test/t/subselect4.test 2011-02-25 09:58:56 +0000 @@ -619,3 +619,24 @@ from t1 A; drop table t1, t2;
+ +--echo # +--echo # BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT ) +--echo # +CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ; +INSERT INTO t1 VALUES ('8','c'),('5','f'); + +ALTER TABLE t1 ADD KEY (f3,f1); + +CREATE TABLE t2 ( f4 varchar(1)) ; +INSERT INTO t2 VALUES ('f'),('d'); + +SELECT * FROM t2 +WHERE EXISTS ( + SELECT DISTINCT f3 + FROM t1 + WHERE f3<= t2.f4 +); + +drop table t1,t2; +
=== modified file 'sql/opt_range.cc' --- a/sql/opt_range.cc 2011-02-22 09:15:47 +0000 +++ b/sql/opt_range.cc 2011-02-25 09:58:56 +0000 @@ -11857,7 +11857,8 @@ Find the range tree for the current keypart. We assume that index_range_tree points to the leftmost keypart in the index. */ - for (cur_range= index_range_tree; cur_range; + for (cur_range= index_range_tree; + cur_range&& cur_range->type == SEL_ARG::KEY_RANGE; cur_range= cur_range->next_key_part) { if (cur_range->field->eq(cur_part->field))
_______________________________________________ commits mailing list commits@mariadb.org https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits
----- End forwarded message -----
participants (2)
-
Sergey Petrunya
-
Timour Katchaounov