← Back to team overview

maria-developers team mailing list archive

Re: MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH

 

Hi, Alexander!

On Jun 20, Alexander Barkov wrote:
> Hello Sergei,
> 
> Please review a patch for mdev-9524.
> 
> Thanks.

> diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
> index 09256a3..45fca08 100644
> --- a/sql/event_data_objects.cc
> +++ b/sql/event_data_objects.cc
> @@ -263,8 +263,17 @@ Event_basic::load_string_fields(Field **fields, ...)
>        ret= TRUE;
>        break;
>      }
> +    /*
> +      TODO: add a get_field() version returning the result in
> +      a LEX_STRING parameter.
> +    */
>      field_value->length= strlen(field_value->str);
>  
> +    // Trim trailing spaces, e.g. for MODE_PAD_CHAR_TO_FULL_LENGTH
> +    CHARSET_INFO *cs= fields[field_name]->charset();
> +    field_value->length= cs->cset->lengthsp(cs, field_value->str,
> +                                                field_value->length);
> +    field_value->str[field_value->length]= '\0';
>      field_name= (enum enum_events_table_field) va_arg(args, int);

Why wouldn't you rather fix it inside get_field()?
By temporarily removing MODE_PAD_CHAR_TO_FULL_LENGTH?

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx


Follow ups

References