File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -723,4 +723,18 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
723
723
c1 c2
724
724
x x
725
725
DROP TABLE t1,t2;
726
+ #
727
+ # MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ
728
+ # in WHERE and HAVING, ORDER BY, materialization+semijoin
729
+ #
730
+ CREATE TABLE t1 (a INT) ENGINE=MyISAM;
731
+ INSERT INTO t1 VALUES (3),(8);
732
+ CREATE TABLE t2 (b INT) ENGINE=MyISAM;
733
+ INSERT INTO t2 VALUES (2),(1);
734
+ SELECT a FROM t1
735
+ WHERE 9 IN ( SELECT MIN( a ) FROM t1 )
736
+ HAVING a <> ( SELECT COUNT(*) FROM t2 )
737
+ ORDER BY a;
738
+ a
739
+ DROP TABLE t1,t2;
726
740
End of 10.0 tests
Original file line number Diff line number Diff line change @@ -759,4 +759,22 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
759
759
760
760
DROP TABLE t1,t2;
761
761
762
+ --echo #
763
+ --echo # MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ
764
+ --echo # in WHERE and HAVING, ORDER BY, materialization+semijoin
765
+ --echo #
766
+
767
+ CREATE TABLE t1 (a INT) ENGINE=MyISAM;
768
+ INSERT INTO t1 VALUES (3),(8);
769
+
770
+ CREATE TABLE t2 (b INT) ENGINE=MyISAM;
771
+ INSERT INTO t2 VALUES (2),(1);
772
+
773
+ SELECT a FROM t1
774
+ WHERE 9 IN ( SELECT MIN( a ) FROM t1 )
775
+ HAVING a <> ( SELECT COUNT(*) FROM t2 )
776
+ ORDER BY a;
777
+
778
+ DROP TABLE t1,t2;
779
+
762
780
--echo End of 10.0 tests
Original file line number Diff line number Diff line change @@ -11476,13 +11476,15 @@ void JOIN_TAB::cleanup()
11476
11476
}
11477
11477
else
11478
11478
{
11479
+ TABLE_LIST *tmp= table->pos_in_table_list;
11479
11480
end_read_record(&read_record);
11480
- table->pos_in_table_list ->jtbm_subselect->cleanup();
11481
+ tmp ->jtbm_subselect->cleanup();
11481
11482
/*
11482
11483
The above call freed the materializedd temptable. Set it to NULL so
11483
11484
that we don't attempt to touch it if JOIN_TAB::cleanup() is invoked
11484
11485
multiple times (it may be)
11485
11486
*/
11487
+ tmp->table= NULL;
11486
11488
table=NULL;
11487
11489
}
11488
11490
DBUG_VOID_RETURN;
You can’t perform that action at this time.
0 commit comments