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,
{
CHARSET_INFO *thd_charset= thd->variables.character_set_results;
char *pos;
CHARSET_INFO *cs= system_charset_info;
DBUG_ASSERT(field.is_sane());
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
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.table_name) ||
store_ident(field.org_table_name) ||
......@@ -870,8 +869,7 @@ bool Protocol_text::store_field_metadata(const THD * thd,
Don't apply character set conversion:
extended metadata is a binary encoded data.
*/
if (store_binary_string(&metadata, cs,
MY_REPERTOIRE_UNICODE30))
if (store_binary_string(metadata.ptr(), metadata.length()))
return true;
}
if (packet->realloc(packet->length() + 12))
......@@ -1185,12 +1183,10 @@ bool Protocol_text::store_null()
*/
bool Protocol::store_string_aux(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{
/* '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 */
return net_store_data_cs((uchar*) from, length, fromcs, tocs);
......@@ -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,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{
#ifndef DBUG_OFF
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,
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
field_pos++;
#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)
dbug_tmp_restore_column_map(table->read_set, old_map);
#endif
return store_string_aux(str.ptr(), str.length(), str.charset(),
field->dtcollation().repertoire, tocs);
return store_string_aux(str.ptr(), str.length(), str.charset(), tocs);
}
......@@ -1466,12 +1459,10 @@ void Protocol_binary::prepare_for_resend()
bool Protocol_binary::store_str(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{
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()
......@@ -1534,7 +1525,6 @@ 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);
}
......
......@@ -63,25 +63,19 @@ class Protocol
MEM_ROOT *alloc;
#endif
bool needs_conversion(CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) const
{
// 'tocs' is set 0 when client issues SET character_set_results=NULL
return tocs && !my_charset_same(fromcs, tocs) &&
fromcs != &my_charset_bin &&
tocs != &my_charset_bin &&
(from_repertoire != MY_REPERTOIRE_ASCII ||
(fromcs->state & MY_CS_NONASCII) ||
(tocs->state & MY_CS_NONASCII));
tocs != &my_charset_bin;
}
/*
The following two are low-level functions that are invoked from
higher-level store_xxx() funcs. The data is stored into this->packet.
*/
bool store_string_aux(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs);
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
virtual bool send_ok(uint server_status, uint statement_warn_count,
ulonglong affected_rows, ulonglong last_insert_id,
......@@ -138,9 +132,7 @@ class Protocol
virtual bool store_longlong(longlong from, bool unsigned_flag)=0;
virtual bool store_decimal(const my_decimal *)=0;
virtual bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)=0;
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
virtual bool store_float(float from, uint32 decimals)=0;
virtual bool store_double(double from, uint32 decimals)=0;
virtual bool store(MYSQL_TIME *time, int decimals)=0;
......@@ -150,30 +142,23 @@ class Protocol
// Various useful wrappers for the virtual store*() methods.
// Backward wrapper for store_str()
inline bool store(const char *from, size_t length, CHARSET_INFO *cs,
my_repertoire_t repertoire= MY_REPERTOIRE_UNICODE30)
bool store(const char *from, size_t length, CHARSET_INFO *cs)
{
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,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)
bool store_lex_cstring(const LEX_CSTRING &s,
CHARSET_INFO *fromcs,
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,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire)
bool store_binary_string(const char *str, size_t length)
{
return store_str(str->ptr(), (uint) str->length(), fromcs, from_repertoire,
&my_charset_bin);
return store_str(str, (uint) length, &my_charset_bin, &my_charset_bin);
}
bool store_ident(const LEX_CSTRING &s,
my_repertoire_t repertoire= MY_REPERTOIRE_UNICODE30)
bool store_ident(const LEX_CSTRING &s)
{
return store_lex_cstring(s, system_charset_info, repertoire,
character_set_results());
return store_lex_cstring(s, system_charset_info, character_set_results());
}
// End of wrappers
......@@ -225,9 +210,7 @@ class Protocol_text final :public Protocol
bool store_longlong(longlong from, bool unsigned_flag) override;
bool store_decimal(const my_decimal *) override;
bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) override;
CHARSET_INFO *fromcs, CHARSET_INFO *tocs) override;
bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override;
......@@ -271,9 +254,7 @@ class Protocol_binary final :public Protocol
bool store_longlong(longlong from, bool unsigned_flag) override;
bool store_decimal(const my_decimal *) override;
bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs) override;
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override;
......@@ -321,8 +302,7 @@ class Protocol_discard final : public Protocol
bool store_long(longlong) override { return false; }
bool store_longlong(longlong, bool) override { return false; }
bool store_decimal(const my_decimal *) override { return false; }
bool store_str(const char *, size_t, CHARSET_INFO *, my_repertoire_t,
CHARSET_INFO *) override
bool store_str(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *)
{
return false;
}
......
......@@ -263,9 +263,7 @@ class Protocol_local :public Protocol
virtual bool store_longlong(longlong from, bool unsigned_flag);
virtual bool store_decimal(const my_decimal *);
virtual bool store_str(const char *from, size_t length,
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs);
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
virtual bool store(MYSQL_TIME *time, int decimals);
virtual bool store_date(MYSQL_TIME *time);
virtual bool store_time(MYSQL_TIME *time, int decimals);
......@@ -288,9 +286,7 @@ class Protocol_local :public Protocol
virtual bool send_error(uint sql_errno, const char *err_msg, const char* sqlstate);
private:
bool store_string(const char *str, size_t length,
CHARSET_INFO *src_cs,
my_repertoire_t src_repertoire,
CHARSET_INFO *dst_cs);
CHARSET_INFO *src_cs, CHARSET_INFO *dst_cs);
bool store_column(const void *data, size_t length);
void opt_add_row_to_rset();
......@@ -5273,14 +5269,12 @@ bool Protocol_local::store_column(const void *data, size_t length)
bool
Protocol_local::store_string(const char *str, size_t length,
CHARSET_INFO *src_cs,
my_repertoire_t src_repertoire,
CHARSET_INFO *dst_cs)
CHARSET_INFO *src_cs, CHARSET_INFO *dst_cs)
{
/* Store with conversion */
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)))
return TRUE;
......@@ -5340,11 +5334,9 @@ bool Protocol_local::store_decimal(const my_decimal *value)
/** Store a string. */
bool Protocol_local::store_str(const char *str, size_t length,
CHARSET_INFO *src_cs,
my_repertoire_t from_repertoire,
CHARSET_INFO *dst_cs)
CHARSET_INFO *src_cs, 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