Commit e96f66b9 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-23270 Remove a String parameter from Protocol::store(double/float)

parent 0ac8e2cf
......@@ -4689,7 +4689,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused)))
bool Field_float::send_binary(Protocol *protocol)
{
DBUG_ASSERT(marked_for_read());
return protocol->store((float) Field_float::val_real(), dec, (String*) 0);
return protocol->store_float((float) Field_float::val_real(), dec);
}
......@@ -4982,7 +4982,7 @@ String *Field_double::val_str(String *val_buffer,
bool Field_double::send_binary(Protocol *protocol)
{
return protocol->store((double) Field_double::val_real(), dec, (String*) 0);
return protocol->store_double(Field_double::val_real(), dec);
}
......
......@@ -1301,25 +1301,25 @@ bool Protocol_text::store_decimal(const my_decimal *d)
}
bool Protocol_text::store(float from, uint32 decimals, String *buffer)
bool Protocol_text::store_float(float from, uint32 decimals)
{
#ifndef DBUG_OFF
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_FLOAT));
field_pos++;
#endif
Float(from).to_string(buffer, decimals);
return store_numeric_string_aux(buffer->ptr(), buffer->length());
Float(from).to_string(&buffer, decimals);
return store_numeric_string_aux(buffer.ptr(), buffer.length());
}
bool Protocol_text::store(double from, uint32 decimals, String *buffer)
bool Protocol_text::store_double(double from, uint32 decimals)
{
#ifndef DBUG_OFF
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_DOUBLE));
field_pos++;
#endif
buffer->set_real(from, decimals, thd->charset());
return store_numeric_string_aux(buffer->ptr(), buffer->length());
buffer.set_real(from, decimals, thd->charset());
return store_numeric_string_aux(buffer.ptr(), buffer.length());
}
......@@ -1538,7 +1538,7 @@ bool Protocol_binary::store_decimal(const my_decimal *d)
thd->variables.character_set_results);
}
bool Protocol_binary::store(float from, uint32 decimals, String *buffer)
bool Protocol_binary::store_float(float from, uint32 decimals)
{
field_pos++;
char *to= packet->prep_append(4, PACKET_BUFFER_EXTRA_ALLOC);
......@@ -1549,7 +1549,7 @@ bool Protocol_binary::store(float from, uint32 decimals, String *buffer)
}
bool Protocol_binary::store(double from, uint32 decimals, String *buffer)
bool Protocol_binary::store_double(double from, uint32 decimals)
{
field_pos++;
char *to= packet->prep_append(8, PACKET_BUFFER_EXTRA_ALLOC);
......
......@@ -141,8 +141,8 @@ class Protocol
CHARSET_INFO *fromcs,
my_repertoire_t from_repertoire,
CHARSET_INFO *tocs)=0;
virtual bool store(float from, uint32 decimals, String *buffer)=0;
virtual bool store(double from, uint32 decimals, String *buffer)=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;
virtual bool store_date(MYSQL_TIME *time)=0;
virtual bool store_time(MYSQL_TIME *time, int decimals)=0;
......@@ -208,6 +208,7 @@ class Protocol
class Protocol_text final :public Protocol
{
StringBuffer<FLOATING_POINT_BUFFER> buffer;
bool store_numeric_string_aux(const char *from, size_t length);
public:
Protocol_text(THD *thd_arg, ulong prealloc= 0)
......@@ -230,8 +231,8 @@ class Protocol_text final :public Protocol
bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override;
bool store(float nr, uint32 decimals, String *buffer) override;
bool store(double from, uint32 decimals, String *buffer) override;
bool store_float(float nr, uint32 decimals) override;
bool store_double(double from, uint32 decimals) override;
bool store(Field *field) override;
bool send_out_parameters(List<Item_param> *sp_params) override;
......@@ -276,8 +277,8 @@ class Protocol_binary final :public Protocol
bool store(MYSQL_TIME *time, int decimals) override;
bool store_date(MYSQL_TIME *time) override;
bool store_time(MYSQL_TIME *time, int decimals) override;
bool store(float nr, uint32 decimals, String *buffer) override;
bool store(double from, uint32 decimals, String *buffer) override;
bool store_float(float nr, uint32 decimals) override;
bool store_double(double from, uint32 decimals) override;
bool store(Field *field) override;
bool send_out_parameters(List<Item_param> *sp_params) override;
......@@ -328,8 +329,8 @@ class Protocol_discard final : public Protocol
bool store(MYSQL_TIME *, int) override { return false; }
bool store_date(MYSQL_TIME *) override { return false; }
bool store_time(MYSQL_TIME *, int) override { return false; }
bool store(float, uint32, String *) override { return false; }
bool store(double, uint32, String *) override { return false; }
bool store_float(float, uint32) override { return false; }
bool store_double(double, uint32) override { return false; }
bool store(Field *) override { return false; }
enum enum_protocol_type type() override { return PROTOCOL_DISCARD; };
};
......
......@@ -3478,7 +3478,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
protocol->store((ulonglong) mi->rli.max_relay_log_size);
protocol->store(mi->rli.executed_entries);
protocol->store((uint32) mi->received_heartbeats);
protocol->store((double) mi->heartbeat_period, 3, &tmp);
protocol->store_double(mi->heartbeat_period, 3);
protocol->store(gtid_pos->ptr(), gtid_pos->length(), &my_charset_bin);
}
......
......@@ -269,8 +269,8 @@ class Protocol_local :public Protocol
virtual bool store(MYSQL_TIME *time, int decimals);
virtual bool store_date(MYSQL_TIME *time);
virtual bool store_time(MYSQL_TIME *time, int decimals);
virtual bool store(float value, uint32 decimals, String *buffer);
virtual bool store(double value, uint32 decimals, String *buffer);
virtual bool store_float(float value, uint32 decimals);
virtual bool store_double(double value, uint32 decimals);
virtual bool store(Field *field);
virtual bool send_result_set_metadata(List<Item> *list, uint flags);
......@@ -5378,7 +5378,7 @@ bool Protocol_local::store_time(MYSQL_TIME *time, int decimals)
/* Store a floating point number, as is. */
bool Protocol_local::store(float value, uint32 decimals, String *buffer)
bool Protocol_local::store_float(float value, uint32 decimals)
{
return store_column(&value, sizeof(float));
}
......@@ -5386,7 +5386,7 @@ bool Protocol_local::store(float value, uint32 decimals, String *buffer)
/* Store a double precision number, as is. */
bool Protocol_local::store(double value, uint32 decimals, String *buffer)
bool Protocol_local::store_double(double value, uint32 decimals)
{
return store_column(&value, sizeof (double));
}
......
......@@ -433,8 +433,6 @@ bool PROFILING::show_profiles()
{
prof= history.iterator_value(iterator);
String elapsed;
double query_time_usecs= prof->m_end_time_usecs - prof->m_start_time_usecs;
if (unit->lim.check_offset(idx))
......@@ -444,8 +442,8 @@ bool PROFILING::show_profiles()
protocol->prepare_for_resend();
protocol->store((uint32)(prof->profiling_query_id));
protocol->store((double)(query_time_usecs/(1000.0*1000)),
(uint32) TIME_FLOAT_DIGITS-1, &elapsed);
protocol->store_double(query_time_usecs/(1000.0*1000),
(uint32) TIME_FLOAT_DIGITS-1);
if (prof->query_source != NULL)
protocol->store(prof->query_source, strlen(prof->query_source),
system_charset_info);
......
......@@ -2891,8 +2891,6 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
server_threads.iterate(list_callback, &arg);
ulonglong now= microsecond_interval_timer();
char buff[20]; // For progress
String store_buffer(buff, sizeof(buff), system_charset_info);
while (auto thd_info= arg.thread_infos.get())
{
......@@ -2918,7 +2916,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
protocol->store_null();
if (!thd->variables.old_mode &&
!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
protocol->store(thd_info->progress, 3, &store_buffer);
protocol->store_double(thd_info->progress, 3);
if (protocol->write())
break; /* purecov: inspected */
}
......
......@@ -7348,7 +7348,7 @@ bool Type_handler::
{
float nr= (float) item->val_real();
if (!item->null_value)
return protocol->store(nr, item->decimals, &buf->m_string);
return protocol->store_float(nr, item->decimals);
return protocol->store_null();
}
......@@ -7358,7 +7358,7 @@ bool Type_handler::
{
double nr= item->val_real();
if (!item->null_value)
return protocol->store(nr, item->decimals, &buf->m_string);
return protocol->store_double(nr, item->decimals);
return protocol->store_null();
}
......
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