#At file:///home/igor/dev-bzr/mysql-6.0-bka-bug37690/
2637 Igor Babaev 2008-07-03
Fixed bug #37690 in the BKA code.
Wrong choice of the upper limit value in a 'for' statement
within the JOIN_CACHE_BKA_UNIQUE::init function caused
crashes for executed queries if the size of the join buffer
was set less than 256.
modified:
mysql-test/r/join_cache.result
mysql-test/t/join_cache.test
sql/sql_select.cc
per-file messages:
mysql-test/r/join_cache.result
Added a test case for bug #37690.
mysql-test/t/join_cache.test
Added a test case for bug #37690.
sql/sql_select.cc
Fixed the code of JOIN_CACHE_BKA_UNIQUE::init to make
the problematic 'for' statement to work at least once.
=== modified file 'mysql-test/r/join_cache.result'
--- a/mysql-test/r/join_cache.result 2008-06-06 22:03:14 +0000
+++ b/mysql-test/r/join_cache.result 2008-07-04 03:23:40 +0000
@@ -3185,3 +3185,24 @@ a1<>a2 a1 a2 b2 b3 c3 s1 s2
0 6 6 73 73 738
0 6 6 74 74 749
DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (a int, b int, INDEX idx(b));
+CREATE TABLE t2 (a int, b int, INDEX idx(a));
+INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20);
+INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20);
+INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20);
+set join_buffer_size=32;
+Warnings:
+Warning 1292 Truncated incorrect join_buffer_size value: '32'
+set join_cache_level=8;
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL idx NULL NULL NULL 7 Using where
+1 SIMPLE t2 ref idx idx 5 test.t1.a 2 Using join buffer
+SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
+a b a b
+7 40 7 10
+8 30 8 20
+8 30 8 10
+7 40 7 20
+7 40 7 10
+DROP TABLE t1,t2;
=== modified file 'mysql-test/t/join_cache.test'
--- a/mysql-test/t/join_cache.test 2008-06-03 01:49:09 +0000
+++ b/mysql-test/t/join_cache.test 2008-07-04 03:23:40 +0000
@@ -750,3 +750,22 @@ SELECT a1<>a2, a1, a2, b2, b3, c3,
FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7;
DROP TABLE t1,t2,t3;
+
+#
+# Bug #37690: crash with a tiny buffer when using BKA_JOIN_CACHE_UNIQUE
+#
+
+CREATE TABLE t1 (a int, b int, INDEX idx(b));
+CREATE TABLE t2 (a int, b int, INDEX idx(a));
+INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20);
+INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20);
+INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20);
+
+set join_buffer_size=32;
+set join_cache_level=8;
+
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
+SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
+
+DROP TABLE t1,t2;
+
\ No newline at end of file
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2008-06-12 04:27:24 +0000
+++ b/sql/sql_select.cc 2008-07-04 03:23:40 +0000
@@ -18937,9 +18937,10 @@ int JOIN_CACHE_BKA_UNIQUE::init()
/* Take into account a reference to the next record in the key chain */
pack_length+= get_size_of_rec_offset();
- /* Calculate the minimal possible value of size_of_key_ofs greater than 1 */
+ /* Calculate the minimal possible value of size_of_key_ofs greater than 2 */
+ uint max_size_of_key_ofs= max(2, get_size_of_rec_offset());
for (size_of_key_ofs= 2;
- size_of_key_ofs <= get_size_of_rec_offset();
+ size_of_key_ofs <= max_size_of_key_ofs;
size_of_key_ofs+= 2)
{
key_entry_length= get_size_of_rec_offset() + // key chain header
| Thread |
|---|
| • bzr commit into mysql-6.0 branch (igor:2637) Bug#37690 | Igor Babaev | 4 Jul |