← Back to team overview

maria-developers team mailing list archive

Re: 06942363ebc: MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable

 

Hi, Alexander!

On Jun 07, Alexander Barkov wrote:
> revision-id: 06942363ebc (mariadb-10.5.2-311-g06942363ebc)
> parent(s): 0d6d63e1505
> author: Alexander Barkov <bar@xxxxxxxxxxx>
> committer: Alexander Barkov <bar@xxxxxxxxxxx>
> timestamp: 2020-06-03 12:11:07 +0400
> message:
> 
> MDEV-14347 CREATE PROCEDURE returns no error when using an unknown variable
> 
> diff --git a/sql/item.cc b/sql/item.cc
> index 8ea6366e6c4..5800b9bc95e 100644
> --- a/sql/item.cc
> +++ b/sql/item.cc
> @@ -764,6 +764,29 @@ bool Item_field::collect_item_field_processor(void *arg)
>  }
>  
>  
> +void Item_ident::undeclared_spvar_error() const

Currently it's used only in Item_field::unknown_splocal_processor().
Do you plan to use this somewhere else?
Why is it a separate method and in Item_ident?

> +{
> +  /*
> +    We assume this is an unknown SP variable, possibly a ROW variable.
> +    Print the leftmost name in the error:
> +      SET var=a;      -> a
> +      SET var=a.b;    -> a
> +      SET var=a.b.c;  -> a
> +  */
> +  my_error(ER_SP_UNDECLARED_VAR, MYF(0),  db_name.str    ? db_name.str :
> +                                          table_name.str ? table_name.str :
> +                                          field_name.str);
> +}
> +
> +bool Item_field::unknown_splocal_processor(void *arg)
> +{
> +  DBUG_ENTER("Item_field::unknown_splocal_processor");
> +  DBUG_ASSERT(type() == FIELD_ITEM);
> +  undeclared_spvar_error();
> +  DBUG_RETURN(true);
> +}
> +
> +
>  bool Item_field::add_field_to_set_processor(void *arg)
>  {
>    DBUG_ENTER("Item_field::add_field_to_set_processor");
> @@ -8012,6 +8035,27 @@ void Item_ref::cleanup()
>  }
>  
>  
> +bool Item_ref::unknown_splocal_processor(void *arg)
> +{
> +  DBUG_ENTER("Item_ref::unknown_splocal_processor");
> +  DBUG_ASSERT(type() == REF_ITEM);
> +  DBUG_ASSERT(ref_type() == REF);
> +  undeclared_spvar_error();
> +  DBUG_RETURN(true);
> +}
> +
> +
> +bool Item_ref::walk(Item_processor processor, bool walk_subquery, void *arg)
> +{
> +  if (processor == &Item::unknown_splocal_processor)
> +    return unknown_splocal_processor(arg);

Why is that?
This is very unusual, normally walk() should not change its behavior
based on the processor.

> +  if (ref && *ref)
> +    return (*ref)->walk(processor, walk_subquery, arg) ||
> +           (this->*processor)(arg);
> +  return false;
> +}
> +
> +
>  /**
>    Transform an Item_ref object with a transformer callback function.
>  
Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx


Follow ups