Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Commit

Permalink
Better fix for ctype_ldml test failures
Browse files Browse the repository at this point in the history
Summary:
In D52023, I misunderstood what alloced meant. That fix is causing
problems with other tests. Replace that fix with this one which
works better.

Squash with D52023.

Test Plan:
```
./mtr --mem main.ctype_ldml innodb.innodb_ctype_ldml \
      main.func_str_no_ps main.func_str_debug \
      main.ctype_ucs main.ctype_ucs2_def
./mtr --mem --valgrind main.ctype_ldml innodb.innodb_ctype_ldml \
      main.func_str_no_ps main.func_str_debug \
      main.ctype_ucs main.ctype_ucs2_def
```

Reviewers: jeremycole, weixiang.zhai, inaam-rana, jtolmer, pivanof

Reviewed By: pivanof

Subscribers: santoshb, webscalesql-eng

Differential Revision: https://reviews.facebook.net/D52173
  • Loading branch information
jtolmer committed Dec 28, 2015
1 parent a7d37a7 commit 87e431a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
37 changes: 22 additions & 15 deletions sql/item_sum.cc
Expand Up @@ -3459,21 +3459,28 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
if (separator->needs_conversion(separator->length(), separator->charset(),
collation.collation, &offset))
{
uint32 buflen= collation.collation->mbmaxlen * separator->length();
uint errors, conv_length;
char *buf;
String *new_separator;

if (!(buf= (char*) thd->stmt_arena->alloc(buflen)) ||
!(new_separator= new(thd->stmt_arena->mem_root)
String(buf, buflen, collation.collation)))
return TRUE;

conv_length= copy_and_convert(buf, buflen, collation.collation,
separator->ptr(), separator->length(),
separator->charset(), &errors);
new_separator->length(conv_length);
separator= new_separator;
if (separator->length())
{
uint32 buflen= collation.collation->mbmaxlen * separator->length();
uint errors, conv_length;
char *buf;
String *new_separator;

if (!(buf= (char*) thd->stmt_arena->alloc(buflen)) ||
!(new_separator= new(thd->stmt_arena->mem_root)
String(buf, buflen, collation.collation)))
return TRUE;

conv_length= copy_and_convert(buf, buflen, collation.collation,
separator->ptr(), separator->length(),
separator->charset(), &errors);
new_separator->length(conv_length);
separator= new_separator;
}
else
{
separator->set_charset(collation.collation);
}
}

if (check_sum_func(thd, ref))
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_string.h
Expand Up @@ -527,8 +527,7 @@ class String

inline bool uses_buffer_owned_by(const String *s) const
{
return (alloced && s->alloced &&
Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
}
bool is_ascii() const
{
Expand Down

0 comments on commit 87e431a

Please sign in to comment.