mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-12659 Add THD::make_string_literal()
This commit is contained in:
@ -2352,6 +2352,26 @@ bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item_string *THD::make_string_literal(const char *str, size_t length,
|
||||||
|
uint repertoire)
|
||||||
|
{
|
||||||
|
if (!charset_is_collation_connection &&
|
||||||
|
(repertoire != MY_REPERTOIRE_ASCII ||
|
||||||
|
!my_charset_is_ascii_based(variables.collation_connection)))
|
||||||
|
{
|
||||||
|
LEX_STRING to;
|
||||||
|
if (convert_string(&to, variables.collation_connection,
|
||||||
|
str, length, variables.character_set_client))
|
||||||
|
return NULL;
|
||||||
|
str= to.str;
|
||||||
|
length= to.length;
|
||||||
|
}
|
||||||
|
return new (mem_root) Item_string(this, str, length,
|
||||||
|
variables.collation_connection,
|
||||||
|
DERIVATION_COERCIBLE, repertoire);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update some cache variables when character set changes
|
Update some cache variables when character set changes
|
||||||
*/
|
*/
|
||||||
|
@ -3423,6 +3423,20 @@ public:
|
|||||||
|
|
||||||
bool convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs);
|
bool convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a string literal with optional client->connection conversion.
|
||||||
|
@param str - the string in the client character set
|
||||||
|
@param length - length of the string
|
||||||
|
@param repertoire - the repertoire of the string
|
||||||
|
*/
|
||||||
|
Item_string *make_string_literal(const char *str, size_t length,
|
||||||
|
uint repertoire);
|
||||||
|
Item_string *make_string_literal(const Lex_string_with_metadata_st &str)
|
||||||
|
{
|
||||||
|
uint repertoire= str.repertoire(variables.character_set_client);
|
||||||
|
return make_string_literal(str.str, str.length, repertoire);
|
||||||
|
}
|
||||||
|
|
||||||
void add_changed_table(TABLE *table);
|
void add_changed_table(TABLE *table);
|
||||||
void add_changed_table(const char *key, long key_length);
|
void add_changed_table(const char *key, long key_length);
|
||||||
CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
|
CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
|
||||||
|
@ -13712,27 +13712,7 @@ load_data_set_elem:
|
|||||||
text_literal:
|
text_literal:
|
||||||
TEXT_STRING
|
TEXT_STRING
|
||||||
{
|
{
|
||||||
LEX_CSTRING tmp;
|
if (!($$= thd->make_string_literal($1)))
|
||||||
CHARSET_INFO *cs_con= thd->variables.collation_connection;
|
|
||||||
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
|
|
||||||
uint repertoire= $1.repertoire(cs_cli);
|
|
||||||
if (thd->charset_is_collation_connection ||
|
|
||||||
(repertoire == MY_REPERTOIRE_ASCII &&
|
|
||||||
my_charset_is_ascii_based(cs_con)))
|
|
||||||
tmp= $1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LEX_STRING to;
|
|
||||||
if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
tmp.str= to.str;
|
|
||||||
tmp.length= to.length;
|
|
||||||
}
|
|
||||||
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
|
|
||||||
cs_con,
|
|
||||||
DERIVATION_COERCIBLE,
|
|
||||||
repertoire);
|
|
||||||
if ($$ == NULL)
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| NCHAR_STRING
|
| NCHAR_STRING
|
||||||
|
@ -13836,27 +13836,7 @@ load_data_set_elem:
|
|||||||
text_literal:
|
text_literal:
|
||||||
TEXT_STRING
|
TEXT_STRING
|
||||||
{
|
{
|
||||||
LEX_CSTRING tmp;
|
if (!($$= thd->make_string_literal($1)))
|
||||||
CHARSET_INFO *cs_con= thd->variables.collation_connection;
|
|
||||||
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
|
|
||||||
uint repertoire= $1.repertoire(cs_cli);
|
|
||||||
if (thd->charset_is_collation_connection ||
|
|
||||||
(repertoire == MY_REPERTOIRE_ASCII &&
|
|
||||||
my_charset_is_ascii_based(cs_con)))
|
|
||||||
tmp= $1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LEX_STRING to;
|
|
||||||
if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
tmp.str= to.str;
|
|
||||||
tmp.length= to.length;
|
|
||||||
}
|
|
||||||
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
|
|
||||||
cs_con,
|
|
||||||
DERIVATION_COERCIBLE,
|
|
||||||
repertoire);
|
|
||||||
if ($$ == NULL)
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| NCHAR_STRING
|
| NCHAR_STRING
|
||||||
|
Reference in New Issue
Block a user