bool get_field(MEM_ROOT *mem, Field *field, String *res)
{
  char *to;
  StringBuffer<MAX_FIELD_WIDTH> str;
  bool rc;
  THD *thd= field->get_thd();
  sql_mode_t sql_mode_backup= thd->variables.sql_mode;
  thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;

  field->val_str(&str);
  if ((rc= !str.length() ||
           !(to= strmake_root(mem, str.ptr(), str.length()))))
  {
    res->length(0);
    goto ex;
  }
  res->set(to, str.length(), field->charset());

ex:
  thd->variables.sql_mode= sql_mode_backup;
  return rc;
}
bool get_field(MEM_ROOT *mem, Field *field, String *res)
{
  char *to;
  StringBuffer<MAX_FIELD_WIDTH> str;
  bool rc;
  THD *thd= field->get_thd();
  sql_mode_t sql_mode_backup= thd->variables.sql_mode;
  thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;

  field->val_str(&str);
  if ((rc= !str.length() ||
           !(to= strmake_root(mem, str.ptr(), str.length()))))
  {
    res->length(0);
    goto ex;
  }
  res->set(to, str.length(), field->charset());

ex:
  thd->variables.sql_mode= sql_mode_backup;
  return rc;
}