← Back to team overview

maria-developers team mailing list archive

Re: [Commits] a99dcdf7e9e: MDEV-6731: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ in WHERE and

 

Hi Varun,

Please fix the MDEV# in the commit comment.
Ok to push after that.

On Wed, Mar 14, 2018 at 12:11:20PM +0530, Varun wrote:
> revision-id: a99dcdf7e9ede3b96466eb1294284141805747fc (mariadb-10.0.30-308-ga99dcdf7e9e)
> parent(s): 48c11d407b409a1291c84782518c69ee9138ce72
> author: Varun Gupta
> committer: Varun Gupta
> timestamp: 2018-03-14 12:09:49 +0530
> message:
> 
> MDEV-6731: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ in WHERE and
>            HAVING, ORDER BY, materialization+semijoin
> 
> During cleanup a pointer to the materialised table that was freed was not set to NULL
> 
> ---
>  mysql-test/r/having.result | 14 ++++++++++++++
>  mysql-test/t/having.test   | 18 ++++++++++++++++++
>  sql/sql_select.cc          |  4 +++-
>  3 files changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
> index 0b933427303..99059c25fbd 100644
> --- a/mysql-test/r/having.result
> +++ b/mysql-test/r/having.result
> @@ -723,4 +723,18 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
>  c1	c2
>  x	x
>  DROP TABLE t1,t2;
> +#
> +# MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ 
> +# in WHERE and HAVING, ORDER BY, materialization+semijoin
> +#
> +CREATE TABLE t1 (a INT) ENGINE=MyISAM;
> +INSERT INTO t1 VALUES (3),(8);
> +CREATE TABLE t2 (b INT) ENGINE=MyISAM;
> +INSERT INTO t2 VALUES (2),(1);
> +SELECT a FROM t1
> +WHERE 9 IN ( SELECT MIN( a ) FROM t1 )  
> +HAVING a <> ( SELECT COUNT(*) FROM t2 ) 
> +ORDER BY a;
> +a
> +DROP TABLE t1,t2;
>  End of 10.0 tests
> diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
> index 1682fe5b874..e624cd630dd 100644
> --- a/mysql-test/t/having.test
> +++ b/mysql-test/t/having.test
> @@ -759,4 +759,22 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
>  
>  DROP TABLE t1,t2;
>  
> +--echo #
> +--echo # MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ 
> +--echo # in WHERE and HAVING, ORDER BY, materialization+semijoin
> +--echo #
> +
> +CREATE TABLE t1 (a INT) ENGINE=MyISAM;
> +INSERT INTO t1 VALUES (3),(8);
> + 
> +CREATE TABLE t2 (b INT) ENGINE=MyISAM;
> +INSERT INTO t2 VALUES (2),(1);
> + 
> +SELECT a FROM t1
> +WHERE 9 IN ( SELECT MIN( a ) FROM t1 )  
> +HAVING a <> ( SELECT COUNT(*) FROM t2 ) 
> +ORDER BY a;
> +
> +DROP TABLE t1,t2;
> +
>  --echo End of 10.0 tests
> diff --git a/sql/sql_select.cc b/sql/sql_select.cc
> index fd8ff6eb016..37d68c730dd 100644
> --- a/sql/sql_select.cc
> +++ b/sql/sql_select.cc
> @@ -11476,13 +11476,15 @@ void JOIN_TAB::cleanup()
>        }
>        else
>        {
> +        TABLE_LIST *tmp= table->pos_in_table_list;
>          end_read_record(&read_record);
> -        table->pos_in_table_list->jtbm_subselect->cleanup();
> +        tmp->jtbm_subselect->cleanup();
>          /* 
>            The above call freed the materializedd temptable. Set it to NULL so
>            that we don't attempt to touch it if JOIN_TAB::cleanup() is invoked
>            multiple times (it may be)
>          */
> +        tmp->table= NULL;
>          table=NULL;
>        }
>        DBUG_VOID_RETURN;
> _______________________________________________
> commits mailing list
> commits@xxxxxxxxxxx
> https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits

-- 
BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog