[Maria-developers] Rev 2822: LPBUG#524025 Running RQG outer_join test leads to crash in file:///home/psergey/dev/maria-5.1/
At file:///home/psergey/dev/maria-5.1/ ------------------------------------------------------------ revno: 2822 revision-id: psergey@askmonty.org-20100306120902-0pu47w0ahogzi0fd parent: sergii@pisem.net-20100223120458-fv2gp4qjxpfcqibj committer: Sergey Petrunya <psergey@askmonty.org> branch nick: maria-5.1 timestamp: Sat 2010-03-06 15:09:02 +0300 message: LPBUG#524025 Running RQG outer_join test leads to crash Save no-records constant tables in JOIN::const_table_map before we invoke eliminate_tables(). Failure to do so caused crash when the same table was marked as constant two times === modified file 'mysql-test/r/table_elim.result' --- a/mysql-test/r/table_elim.result 2010-02-18 12:03:52 +0000 +++ b/mysql-test/r/table_elim.result 2010-03-06 12:09:02 +0000 @@ -1,4 +1,4 @@ -drop table if exists t0, t1, t2, t3; +drop table if exists t0, t1, t2, t3, t4, t5, t6; drop view if exists v1, v2; create table t1 (a int); insert into t1 values (0),(1),(2),(3); @@ -464,3 +464,74 @@ HAVING field1 < 216; field1 DROP TABLE t1, t2; +# +# LPBUG#524025 Running RQG outer_join test leads to crash +# +CREATE TABLE t0 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +CREATE TABLE t1 ( +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_10_latin1 varchar(10) DEFAULT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (5,5,1,'t'), (NULL,NULL,2,'y'); +CREATE TABLE t2 ( +col_int int(11) DEFAULT NULL +); +INSERT INTO t2 VALUES (8), (4); +CREATE TABLE t3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1),(8); +CREATE TABLE t4 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1,'o',1), (2,'w',2); +CREATE TABLE t5 ( +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, +col_varchar_10_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t5 VALUES ('k','a','z',1,2),('x','a','w',2,7); +CREATE TABLE t6 ( +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL +); +INSERT INTO t6 VALUES (6,1),(8,3); +SELECT +table3.col_int AS field1, +table1.col_int AS field2, +table1.col_int_key AS field3, +table1.pk AS field4, +table1.col_int AS field5, +table2.col_int AS field6 +FROM +t1 AS table1 +LEFT OUTER JOIN +t4 AS table2 +LEFT JOIN t6 AS table3 +RIGHT JOIN t3 AS table4 +LEFT JOIN t5 AS table5 ON table4.pk = table5.pk +LEFT JOIN t0 AS table6 ON table5.col_int_key = table6.pk +ON table3.col_int_key = table5.pk +ON table2.col_varchar_1024_latin1_key = table5.col_varchar_10_utf8_key +LEFT JOIN t6 AS table7 ON table2.pk = table7.col_int +ON table1.col_varchar_10_latin1 = table5.col_varchar_1024_latin1_key +LEFT JOIN t2 AS table8 ON table3.col_int = table8.col_int +WHERE +table1.col_int_key < table2.pk +HAVING +field4 != 6; +field1 field2 field3 field4 field5 field6 +drop table t0,t1,t2,t3,t4,t5,t6; === modified file 'mysql-test/t/table_elim.test' --- a/mysql-test/t/table_elim.test 2010-02-18 12:03:52 +0000 +++ b/mysql-test/t/table_elim.test 2010-03-06 12:09:02 +0000 @@ -2,7 +2,7 @@ # Table elimination (MWL#17) tests # --disable_warnings -drop table if exists t0, t1, t2, t3; +drop table if exists t0, t1, t2, t3, t4, t5, t6; drop view if exists v1, v2; --enable_warnings @@ -387,3 +387,83 @@ DROP TABLE t1, t2; + +--echo # +--echo # LPBUG#524025 Running RQG outer_join test leads to crash +--echo # + +CREATE TABLE t0 ( + pk int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (pk) +); + +CREATE TABLE t1 ( + col_int int(11) DEFAULT NULL, + col_int_key int(11) DEFAULT NULL, + pk int(11) NOT NULL AUTO_INCREMENT, + col_varchar_10_latin1 varchar(10) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (5,5,1,'t'), (NULL,NULL,2,'y'); + +CREATE TABLE t2 ( + col_int int(11) DEFAULT NULL +); +INSERT INTO t2 VALUES (8), (4); + +CREATE TABLE t3 ( + pk int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1),(8); + +CREATE TABLE t4 ( + pk int(11) NOT NULL AUTO_INCREMENT, + col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, + col_int int(11) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1,'o',1), (2,'w',2); + +CREATE TABLE t5 ( + col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, + col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, + col_varchar_10_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, + pk int(11) NOT NULL AUTO_INCREMENT, + col_int_key int(11) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t5 VALUES ('k','a','z',1,2),('x','a','w',2,7); + +CREATE TABLE t6 ( + col_int int(11) DEFAULT NULL, + col_int_key int(11) DEFAULT NULL +); +INSERT INTO t6 VALUES (6,1),(8,3); + +SELECT + table3.col_int AS field1, + table1.col_int AS field2, + table1.col_int_key AS field3, + table1.pk AS field4, + table1.col_int AS field5, + table2.col_int AS field6 +FROM + t1 AS table1 + LEFT OUTER JOIN + t4 AS table2 + LEFT JOIN t6 AS table3 + RIGHT JOIN t3 AS table4 + LEFT JOIN t5 AS table5 ON table4.pk = table5.pk + LEFT JOIN t0 AS table6 ON table5.col_int_key = table6.pk + ON table3.col_int_key = table5.pk + ON table2.col_varchar_1024_latin1_key = table5.col_varchar_10_utf8_key + LEFT JOIN t6 AS table7 ON table2.pk = table7.col_int + ON table1.col_varchar_10_latin1 = table5.col_varchar_1024_latin1_key + LEFT JOIN t2 AS table8 ON table3.col_int = table8.col_int +WHERE + table1.col_int_key < table2.pk +HAVING + field4 != 6; + +drop table t0,t1,t2,t3,t4,t5,t6; === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2010-01-15 15:27:55 +0000 +++ b/sql/sql_select.cc 2010-03-06 12:09:02 +0000 @@ -2562,6 +2562,7 @@ JOIN_TAB *stat,*stat_end,*s,**stat_ref; KEYUSE *keyuse,*start_keyuse; table_map outer_join=0; + table_map no_rows_const_tables= 0; SARGABLE_PARAM *sargables= 0; JOIN_TAB *stat_vector[MAX_TABLES+1]; DBUG_ENTER("make_join_statistics"); @@ -2622,6 +2623,7 @@ #endif { // Empty table s->dependent= 0; // Ignore LEFT JOIN depend. + no_rows_const_tables |= table->map; set_position(join,const_count++,s,(KEYUSE*) 0); continue; } @@ -2658,6 +2660,7 @@ !table->fulltext_searched && !join->no_const_tables) { set_position(join,const_count++,s,(KEYUSE*) 0); + no_rows_const_tables |= table->map; } } stat_vector[i]=0; @@ -2703,9 +2706,10 @@ ~outer_join, join->select_lex, &sargables)) goto error; - join->const_table_map= 0; + join->const_table_map= no_rows_const_tables; join->const_tables= const_count; eliminate_tables(join); + join->const_table_map &= ~no_rows_const_tables; const_count= join->const_tables; found_const_table_map= join->const_table_map;
participants (1)
-
Sergey Petrunya