← Back to team overview

maria-developers team mailing list archive

Re: cb2cd9c3a43: MDEV-22058: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed in Diagnostics_area::set_ok_status

 

Hi, Rucha!

On Jul 02, Rucha Deodhar wrote:
> revision-id: cb2cd9c3a43 (mariadb-10.2.31-302-gcb2cd9c3a43)
> parent(s): dba7e1e8e14
> author: Rucha Deodhar <rucha.deodhar@xxxxxxxxxxx>
> committer: Rucha Deodhar <rucha.deodhar@xxxxxxxxxxx>
> timestamp: 2020-07-02 19:51:55 +0530
> message:
> 
> MDEV-22058: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed in Diagnostics_area::set_ok_status
> 
> Error state is not stored in check_and_do_in_subquery_rewrites() when there is
> illegal combination of optimizer switches. So all the functions eventually
> return false. Thus the assetion failure.
> 
> diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
> index 2fb5b88687f..e37b389836c 100644
> --- a/sql/opt_subselect.cc
> +++ b/sql/opt_subselect.cc
> @@ -559,6 +559,7 @@ bool is_materialization_applicable(THD *thd, Item_in_subselect *in_subs,
>  int check_and_do_in_subquery_rewrites(JOIN *join)
>  {
>    THD *thd=join->thd;
> +  int res= 0;
>    st_select_lex *select_lex= join->select_lex;
>    st_select_lex_unit* parent_unit= select_lex->master_unit();
>    DBUG_ENTER("check_and_do_in_subquery_rewrites");
> @@ -703,7 +704,11 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
>        /* Test if the user has set a legal combination of optimizer switches. */
>        if (!optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) &&
>            !optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION))
> +      {
>          my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));

I think this is very weird behavior. A user sets incorrect optimizer
switch, SET statement succeeds. But later at some point SELECT returns
an error.

You have correctly found the place where the error status is not
properly returned and fixed it.

But I'd rather suggest to move the check to where it should've been.
Here instead of the if() you put an assert:

  DBUG_ASSERT(optimizer_flag(thd,
      OPTIMIZER_SWITCH_IN_TO_EXISTS | OPTIMIZER_SWITCH_MATERIALIZATION));

and the if() with an error should be in sys_vars.cc. So that the user
would get an error from the SET statement. Look for ON_CHECK in the
sys_vars.cc

> +        res= -1;
> +      }
> +
>        /*
>          Transform each subquery predicate according to its overloaded
>          transformer.

Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx