[Maria-developers] MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH
![](https://secure.gravatar.com/avatar/39b623a1559cf9c69ac3d9d4fb44e7fe.jpg?s=120&d=mm&r=g)
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@mariadb.org
![](https://secure.gravatar.com/avatar/68ff00c1752bf8aede68a05f77ebd28b.jpg?s=120&d=mm&r=g)
Hi Sergei, On 06/20/2016 05:44 PM, Sergei Golubchik wrote:
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?
This is a version with removing MODE_PAD_CHAR_TO_FULL_LENGTH. Thanks!
Regards, Sergei Chief Architect MariaDB and security@mariadb.org
![](https://secure.gravatar.com/avatar/39b623a1559cf9c69ac3d9d4fb44e7fe.jpg?s=120&d=mm&r=g)
Hi, Alexander! On Jun 21, Alexander Barkov wrote:
Hi Sergei,
This is a version with removing MODE_PAD_CHAR_TO_FULL_LENGTH.
Thanks! ...
ok to push! Regards, Sergei Chief Architect MariaDB and security@mariadb.org
participants (2)
-
Alexander Barkov
-
Sergei Golubchik