Commit f1a9700f authored by Alexander Barkov's avatar Alexander Barkov

Revert "MDEV-23162 Improve Protocol performance for numeric data"

This reverts commit eb2eaba7.

A different implementation of MDEV-23162 is coming.
parent e96f66b9
...@@ -848,13 +848,12 @@ bool Protocol_text::store_field_metadata(const THD * thd, ...@@ -848,13 +848,12 @@ bool Protocol_text::store_field_metadata(const THD * thd,
{ {
CHARSET_INFO *thd_charset= thd->variables.character_set_results; CHARSET_INFO *thd_charset= thd->variables.character_set_results;
char *pos; char *pos;
CHARSET_INFO *cs= system_charset_info;
DBUG_ASSERT(field.is_sane()); DBUG_ASSERT(field.is_sane());
if (thd->client_capabilities & CLIENT_PROTOCOL_41) if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{ {
const LEX_CSTRING def= {STRING_WITH_LEN("def")}; const LEX_CSTRING def= {STRING_WITH_LEN("def")};
if (store_ident(def, MY_REPERTOIRE_ASCII) || if (store_ident(def) ||
store_ident(field.db_name) || store_ident(field.db_name) ||
store_ident(field.table_name) || store_ident(field.table_name) ||
store_ident(field.org_table_name) || store_ident(field.org_table_name) ||
...@@ -870,8 +869,7 @@ bool Protocol_text::store_field_metadata(const THD * thd, ...@@ -870,8 +869,7 @@ bool Protocol_text::store_field_metadata(const THD * thd,
Don't apply character set conversion: Don't apply character set conversion:
extended metadata is a binary encoded data. extended metadata is a binary encoded data.
*/ */
if (store_binary_string(&metadata, cs, if (store_binary_string(metadata.ptr(), metadata.length()))
MY_REPERTOIRE_UNICODE30))
return true; return true;
} }
if (packet->realloc(packet->length() + 12)) if (packet->realloc(packet->length() + 12))
...@@ -1185,12 +1183,10 @@ bool Protocol_text::store_null() ...@@ -1185,12 +1183,10 @@ bool Protocol_text::store_null()
*/ */
bool Protocol::store_string_aux(const char *from, size_t length, bool Protocol::store_string_aux(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
{ {
/* 'tocs' is set 0 when client issues SET character_set_results=NULL */ /* 'tocs' is set 0 when client issues SET character_set_results=NULL */
if (needs_conversion(fromcs, from_repertoire, tocs)) if (needs_conversion(fromcs, tocs))
{ {
/* Store with conversion */ /* Store with conversion */
return net_store_data_cs((uchar*) from, length, fromcs, tocs); return net_store_data_cs((uchar*) from, length, fromcs, tocs);
...@@ -1223,9 +1219,7 @@ bool Protocol::store_warning(const char *from, size_t length) ...@@ -1223,9 +1219,7 @@ bool Protocol::store_warning(const char *from, size_t length)
bool Protocol_text::store_str(const char *from, size_t length, bool Protocol_text::store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
DBUG_PRINT("info", ("Protocol_text::store field %u : %.*b", field_pos, DBUG_PRINT("info", ("Protocol_text::store field %u : %.*b", field_pos,
...@@ -1234,7 +1228,7 @@ bool Protocol_text::store_str(const char *from, size_t length, ...@@ -1234,7 +1228,7 @@ bool Protocol_text::store_str(const char *from, size_t length,
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING)); DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
field_pos++; field_pos++;
#endif #endif
return store_string_aux(from, length, fromcs, from_repertoire, tocs); return store_string_aux(from, length, fromcs, tocs);
} }
...@@ -1346,8 +1340,7 @@ bool Protocol_text::store(Field *field) ...@@ -1346,8 +1340,7 @@ bool Protocol_text::store(Field *field)
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
#endif #endif
return store_string_aux(str.ptr(), str.length(), str.charset(), return store_string_aux(str.ptr(), str.length(), str.charset(), tocs);
field->dtcollation().repertoire, tocs);
} }
...@@ -1466,12 +1459,10 @@ void Protocol_binary::prepare_for_resend() ...@@ -1466,12 +1459,10 @@ void Protocol_binary::prepare_for_resend()
bool Protocol_binary::store_str(const char *from, size_t length, bool Protocol_binary::store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
{ {
field_pos++; field_pos++;
return store_string_aux(from, length, fromcs, from_repertoire, tocs); return store_string_aux(from, length, fromcs, tocs);
} }
bool Protocol_binary::store_null() bool Protocol_binary::store_null()
...@@ -1534,7 +1525,6 @@ bool Protocol_binary::store_decimal(const my_decimal *d) ...@@ -1534,7 +1525,6 @@ bool Protocol_binary::store_decimal(const my_decimal *d)
StringBuffer<DECIMAL_MAX_STR_LENGTH> str; StringBuffer<DECIMAL_MAX_STR_LENGTH> str;
(void) d->to_string(&str); (void) d->to_string(&str);
return store_str(str.ptr(), str.length(), str.charset(), return store_str(str.ptr(), str.length(), str.charset(),
MY_REPERTOIRE_ASCII,
thd->variables.character_set_results); thd->variables.character_set_results);
} }
......
...@@ -63,25 +63,19 @@ class Protocol ...@@ -63,25 +63,19 @@ class Protocol
MEM_ROOT *alloc; MEM_ROOT *alloc;
#endif #endif
bool needs_conversion(CHARSET_INFO *fromcs, bool needs_conversion(CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) const CHARSET_INFO *tocs) const
{ {
// 'tocs' is set 0 when client issues SET character_set_results=NULL // 'tocs' is set 0 when client issues SET character_set_results=NULL
return tocs && !my_charset_same(fromcs, tocs) && return tocs && !my_charset_same(fromcs, tocs) &&
fromcs != &my_charset_bin && fromcs != &my_charset_bin &&
tocs != &my_charset_bin && tocs != &my_charset_bin;
(from_repertoire != MY_REPERTOIRE_ASCII ||
(fromcs->state & MY_CS_NONASCII) ||
(tocs->state & MY_CS_NONASCII));
} }
/* /*
The following two are low-level functions that are invoked from The following two are low-level functions that are invoked from
higher-level store_xxx() funcs. The data is stored into this->packet. higher-level store_xxx() funcs. The data is stored into this->packet.
*/ */
bool store_string_aux(const char *from, size_t length, bool store_string_aux(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs);
virtual bool send_ok(uint server_status, uint statement_warn_count, virtual bool send_ok(uint server_status, uint statement_warn_count,
ulonglong affected_rows, ulonglong last_insert_id, ulonglong affected_rows, ulonglong last_insert_id,
...@@ -138,9 +132,7 @@ class Protocol ...@@ -138,9 +132,7 @@ class Protocol
virtual bool store_longlong(longlong from, bool unsigned_flag)=0; virtual bool store_longlong(longlong from, bool unsigned_flag)=0;
virtual bool store_decimal(const my_decimal *)=0; virtual bool store_decimal(const my_decimal *)=0;
virtual bool store_str(const char *from, size_t length, virtual bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)=0;
virtual bool store_float(float from, uint32 decimals)=0; virtual bool store_float(float from, uint32 decimals)=0;
virtual bool store_double(double from, uint32 decimals)=0; virtual bool store_double(double from, uint32 decimals)=0;
virtual bool store(MYSQL_TIME *time, int decimals)=0; virtual bool store(MYSQL_TIME *time, int decimals)=0;
...@@ -150,30 +142,23 @@ class Protocol ...@@ -150,30 +142,23 @@ class Protocol
// Various useful wrappers for the virtual store*() methods. // Various useful wrappers for the virtual store*() methods.
// Backward wrapper for store_str() // Backward wrapper for store_str()
inline bool store(const char *from, size_t length, CHARSET_INFO *cs, bool store(const char *from, size_t length, CHARSET_INFO *cs)
my_repertoire_t repertoire= MY_REPERTOIRE_UNICODE30)
{ {
return store_str(from, length, cs, repertoire, character_set_results()); return store_str(from, length, cs, character_set_results());
} }
inline bool store_lex_cstring(const LEX_CSTRING &s, bool store_lex_cstring(const LEX_CSTRING &s,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire, CHARSET_INFO *tocs)
CHARSET_INFO *tocs)
{ {
return store_str(s.str, (uint) s.length, fromcs, from_repertoire, tocs); return store_str(s.str, (uint) s.length, fromcs, tocs);
} }
inline bool store_binary_string(Binary_string *str, bool store_binary_string(const char *str, size_t length)
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire)
{ {
return store_str(str->ptr(), (uint) str->length(), fromcs, from_repertoire, return store_str(str, (uint) length, &my_charset_bin, &my_charset_bin);
&my_charset_bin);
} }
bool store_ident(const LEX_CSTRING &s, bool store_ident(const LEX_CSTRING &s)
my_repertoire_t repertoire= MY_REPERTOIRE_UNICODE30)
{ {
return store_lex_cstring(s, system_charset_info, repertoire, return store_lex_cstring(s, system_charset_info, character_set_results());
character_set_results());
} }
// End of wrappers // End of wrappers
...@@ -225,9 +210,7 @@ class Protocol_text final :public Protocol ...@@ -225,9 +210,7 @@ class Protocol_text final :public Protocol
bool store_longlong(longlong from, bool unsigned_flag) override; bool store_longlong(longlong from, bool unsigned_flag) override;
bool store_decimal(const my_decimal *) override; bool store_decimal(const my_decimal *) override;
bool store_str(const char *from, size_t length, bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) override;
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) override;
bool store(MYSQL_TIME *time, int decimals) override; bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override; bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override; bool store_time(MYSQL_TIME *time, int decimals) override;
...@@ -271,9 +254,7 @@ class Protocol_binary final :public Protocol ...@@ -271,9 +254,7 @@ class Protocol_binary final :public Protocol
bool store_longlong(longlong from, bool unsigned_flag) override; bool store_longlong(longlong from, bool unsigned_flag) override;
bool store_decimal(const my_decimal *) override; bool store_decimal(const my_decimal *) override;
bool store_str(const char *from, size_t length, bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) override;
bool store(MYSQL_TIME *time, int decimals) override; bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override; bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override; bool store_time(MYSQL_TIME *time, int decimals) override;
...@@ -321,8 +302,7 @@ class Protocol_discard final : public Protocol ...@@ -321,8 +302,7 @@ class Protocol_discard final : public Protocol
bool store_long(longlong) override { return false; } bool store_long(longlong) override { return false; }
bool store_longlong(longlong, bool) override { return false; } bool store_longlong(longlong, bool) override { return false; }
bool store_decimal(const my_decimal *) override { return false; } bool store_decimal(const my_decimal *) override { return false; }
bool store_str(const char *, size_t, CHARSET_INFO *, my_repertoire_t, bool store_str(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *)
CHARSET_INFO *) override
{ {
return false; return false;
} }
......
...@@ -263,9 +263,7 @@ class Protocol_local :public Protocol ...@@ -263,9 +263,7 @@ class Protocol_local :public Protocol
virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store_longlong(longlong from, bool unsigned_flag);
virtual bool store_decimal(const my_decimal *); virtual bool store_decimal(const my_decimal *);
virtual bool store_str(const char *from, size_t length, virtual bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs);
virtual bool store(MYSQL_TIME *time, int decimals); virtual bool store(MYSQL_TIME *time, int decimals);
virtual bool store_date(MYSQL_TIME *time); virtual bool store_date(MYSQL_TIME *time);
virtual bool store_time(MYSQL_TIME *time, int decimals); virtual bool store_time(MYSQL_TIME *time, int decimals);
...@@ -288,9 +286,7 @@ class Protocol_local :public Protocol ...@@ -288,9 +286,7 @@ class Protocol_local :public Protocol
virtual bool send_error(uint sql_errno, const char *err_msg, const char* sqlstate); virtual bool send_error(uint sql_errno, const char *err_msg, const char* sqlstate);
private: private:
bool store_string(const char *str, size_t length, bool store_string(const char *str, size_t length,
CHARSET_INFO *src_cs, CHARSET_INFO *src_cs, CHARSET_INFO *dst_cs);
my_repertoire_t src_repertoire,
CHARSET_INFO *dst_cs);
bool store_column(const void *data, size_t length); bool store_column(const void *data, size_t length);
void opt_add_row_to_rset(); void opt_add_row_to_rset();
...@@ -5273,14 +5269,12 @@ bool Protocol_local::store_column(const void *data, size_t length) ...@@ -5273,14 +5269,12 @@ bool Protocol_local::store_column(const void *data, size_t length)
bool bool
Protocol_local::store_string(const char *str, size_t length, Protocol_local::store_string(const char *str, size_t length,
CHARSET_INFO *src_cs, CHARSET_INFO *src_cs, CHARSET_INFO *dst_cs)
my_repertoire_t src_repertoire,
CHARSET_INFO *dst_cs)
{ {
/* Store with conversion */ /* Store with conversion */
uint error_unused; uint error_unused;
if (needs_conversion(src_cs, src_repertoire, dst_cs)) if (needs_conversion(src_cs, dst_cs))
{ {
if (unlikely(convert->copy(str, length, src_cs, dst_cs, &error_unused))) if (unlikely(convert->copy(str, length, src_cs, dst_cs, &error_unused)))
return TRUE; return TRUE;
...@@ -5340,11 +5334,9 @@ bool Protocol_local::store_decimal(const my_decimal *value) ...@@ -5340,11 +5334,9 @@ bool Protocol_local::store_decimal(const my_decimal *value)
/** Store a string. */ /** Store a string. */
bool Protocol_local::store_str(const char *str, size_t length, bool Protocol_local::store_str(const char *str, size_t length,
CHARSET_INFO *src_cs, CHARSET_INFO *src_cs, CHARSET_INFO *dst_cs)
my_repertoire_t from_repertoire,
CHARSET_INFO *dst_cs)
{ {
return store_string(str, length, src_cs, from_repertoire, dst_cs); return store_string(str, length, src_cs, dst_cs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment