summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-07-14 11:48:13 +0400
committerAlexander Barkov <bar@mariadb.com>2020-07-15 11:11:44 +0400
commiteb2eaba7fdbd13c9814ab4619cc23d9f140e5485 (patch)
treeaa5e62b66d04b6ca331ce5077b898abaf2b2197e /sql/protocol.cc
parentbe98036f25ac8cfb34fa5bb5066975d79f595aec (diff)
downloadmariadb-git-eb2eaba7fdbd13c9814ab4619cc23d9f140e5485.tar.gz
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;
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 07d09ecb4ee..a97e0d0997d 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -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);
}