mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Support for character set conversion in binary protocol: another go
after Monty's review. - Item_param was rewritten. - it turns out that we can't convert string data to character set of connection on the fly, because they first should be written to the binary log. To support efficient conversion we need to rewrite prepared statements binlogging code first.
This commit is contained in:
@ -106,13 +106,13 @@ bool foreign_key_prefix(Key *a, Key *b)
|
||||
if (a->generated)
|
||||
{
|
||||
if (b->generated && a->columns.elements > b->columns.elements)
|
||||
swap(Key*, a, b); // Put shorter key in 'a'
|
||||
swap_variables(Key*, a, b); // Put shorter key in 'a'
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!b->generated)
|
||||
return TRUE; // No foreign key
|
||||
swap(Key*, a, b); // Put generated key in 'a'
|
||||
swap_variables(Key*, a, b); // Put generated key in 'a'
|
||||
}
|
||||
|
||||
/* Test if 'a' is a prefix of 'b' */
|
||||
@ -503,6 +503,35 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Convert string from source character set to target character set inplace.
|
||||
|
||||
SYNOPSIS
|
||||
THD::convert_string
|
||||
|
||||
DESCRIPTION
|
||||
Convert string using convert_buffer - buffer for character set
|
||||
conversion shared between all protocols.
|
||||
|
||||
RETURN
|
||||
0 ok
|
||||
!0 out of memory
|
||||
*/
|
||||
|
||||
bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
|
||||
{
|
||||
if (convert_buffer.copy(s->ptr(), s->length(), from_cs, to_cs))
|
||||
return TRUE;
|
||||
/* If convert_buffer >> s copying is more efficient long term */
|
||||
if (convert_buffer.alloced_length() >= convert_buffer.length() * 2 ||
|
||||
!s->is_alloced())
|
||||
{
|
||||
return s->copy(convert_buffer);
|
||||
}
|
||||
s->swap(convert_buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
Update some cache variables when character set changes
|
||||
*/
|
||||
|
Reference in New Issue
Block a user