mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-23162 Improve Protocol performance for numeric data
Avoid character set conversion for numeric data in this scenario: SET NAMES utf8; CREATE OR REPLACE TABLE t1 (a INT); INSERT INTO t1 VALUES (1); SELECT a FROM t1;
This commit is contained in:
@@ -853,7 +853,7 @@ bool Protocol_text::store_field_metadata(const THD * thd,
|
||||
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
|
||||
{
|
||||
const LEX_CSTRING def= {STRING_WITH_LEN("def")};
|
||||
if (store_ident(def) ||
|
||||
if (store_ident(def, MY_REPERTOIRE_ASCII) ||
|
||||
store_ident(field.db_name) ||
|
||||
store_ident(field.table_name) ||
|
||||
store_ident(field.org_table_name) ||
|
||||
@@ -868,7 +868,8 @@ bool Protocol_text::store_field_metadata(const THD * thd,
|
||||
Don't apply character set conversion:
|
||||
extended metadata is a binary encoded data.
|
||||
*/
|
||||
if (store_lex_cstring(metadata.lex_cstring(), cs, &my_charset_bin))
|
||||
if (store_lex_cstring(metadata.lex_cstring(), cs,
|
||||
MY_REPERTOIRE_UNICODE30, &my_charset_bin))
|
||||
return true;
|
||||
}
|
||||
if (packet->realloc(packet->length() + 12))
|
||||
@@ -1182,10 +1183,12 @@ bool Protocol_text::store_null()
|
||||
*/
|
||||
|
||||
bool Protocol::store_string_aux(const char *from, size_t length,
|
||||
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
||||
CHARSET_INFO *fromcs,
|
||||
my_repertoire_t from_repertoire,
|
||||
CHARSET_INFO *tocs)
|
||||
{
|
||||
/* 'tocs' is set 0 when client issues SET character_set_results=NULL */
|
||||
if (needs_conversion(fromcs, tocs))
|
||||
if (needs_conversion(fromcs, from_repertoire, tocs))
|
||||
{
|
||||
/* Store with conversion */
|
||||
return net_store_data_cs((uchar*) from, length, fromcs, tocs);
|
||||
@@ -1208,7 +1211,9 @@ bool Protocol::store_warning(const char *from, size_t length)
|
||||
|
||||
|
||||
bool Protocol_text::store_str(const char *from, size_t length,
|
||||
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
||||
CHARSET_INFO *fromcs,
|
||||
my_repertoire_t from_repertoire,
|
||||
CHARSET_INFO *tocs)
|
||||
{
|
||||
#ifndef DBUG_OFF
|
||||
DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %.*b", field_pos,
|
||||
@@ -1217,7 +1222,7 @@ bool Protocol_text::store_str(const char *from, size_t length,
|
||||
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
|
||||
field_pos++;
|
||||
#endif
|
||||
return store_string_aux(from, length, fromcs, tocs);
|
||||
return store_string_aux(from, length, fromcs, from_repertoire, tocs);
|
||||
}
|
||||
|
||||
|
||||
@@ -1330,7 +1335,8 @@ bool Protocol_text::store(Field *field)
|
||||
dbug_tmp_restore_column_map(table->read_set, old_map);
|
||||
#endif
|
||||
|
||||
return store_string_aux(str.ptr(), str.length(), str.charset(), tocs);
|
||||
return store_string_aux(str.ptr(), str.length(), str.charset(),
|
||||
field->dtcollation().repertoire, tocs);
|
||||
}
|
||||
|
||||
|
||||
@@ -1449,10 +1455,12 @@ void Protocol_binary::prepare_for_resend()
|
||||
|
||||
|
||||
bool Protocol_binary::store_str(const char *from, size_t length,
|
||||
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
||||
CHARSET_INFO *fromcs,
|
||||
my_repertoire_t from_repertoire,
|
||||
CHARSET_INFO *tocs)
|
||||
{
|
||||
field_pos++;
|
||||
return store_string_aux(from, length, fromcs, tocs);
|
||||
return store_string_aux(from, length, fromcs, from_repertoire, tocs);
|
||||
}
|
||||
|
||||
bool Protocol_binary::store_null()
|
||||
@@ -1515,6 +1523,7 @@ bool Protocol_binary::store_decimal(const my_decimal *d)
|
||||
StringBuffer<DECIMAL_MAX_STR_LENGTH> str;
|
||||
(void) d->to_string(&str);
|
||||
return store_str(str.ptr(), str.length(), str.charset(),
|
||||
MY_REPERTOIRE_ASCII,
|
||||
thd->variables.character_set_results);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user