Skip to content

Commit d80143b

Browse files
committed
Bug#29836015: CLEAN UP SOME FUNCTION SIGNATURES IN PROTOCOL_CLASSIC
Follow-up patch to fix a warning: function Protocol_binary::store hides a non virtual function, aka Protocol_text::store Both Protocol_text and Protocol_binary have store() functions for strings that do the exact same thing. Strings are sent as text regardless of the protocol being text or binary. Remove the store() functions for strings in Protocol_text and Protocol_binary, and instead have a common implementation in Protocol_classic. Also rename the virtual functions store(const char *, ...), store(float, ...) and store(double, ...) to store_string(), store_float() and store_double() to avoid similar conflicts with other non-virtual member functions of Protocol called store(), and to have names that are consistent with the names of the store functions for other data types. Change-Id: Ie1b9bcb401aedf7f2300b62e0c5a2c472a948b3c
1 parent 8468fc5 commit d80143b

25 files changed

+236
-264
lines changed

sql/auth/sql_authorization.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ void make_database_privilege_statement(THD *thd, ACL_USER *role,
10371037
if (want_access & GRANT_ACL)
10381038
db.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
10391039
protocol->start_row();
1040-
protocol->store(db.ptr(), db.length(), db.charset());
1040+
protocol->store_string(db.ptr(), db.length(), db.charset());
10411041
protocol->end_row();
10421042
}
10431043
};
@@ -1084,7 +1084,7 @@ void make_database_privilege_statement(THD *thd, ACL_USER *role,
10841084
append_identifier(thd, &db, acl_user->host.get_host(),
10851085
acl_user->host.get_host_len());
10861086
protocol->start_row();
1087-
protocol->store(db.ptr(), db.length(), db.charset());
1087+
protocol->store_string(db.ptr(), db.length(), db.charset());
10881088
protocol->end_row();
10891089
}
10901090
}
@@ -1114,7 +1114,7 @@ void make_proxy_privilege_statement(THD *thd MY_ATTRIBUTE((unused)),
11141114
String global;
11151115
proxy->print_grant(&global);
11161116
protocol->start_row();
1117-
protocol->store(global.ptr(), global.length(), global.charset());
1117+
protocol->store_string(global.ptr(), global.length(), global.charset());
11181118
protocol->end_row();
11191119
}
11201120
}
@@ -1176,7 +1176,7 @@ void make_sp_privilege_statement(THD *thd, ACL_USER *role, Protocol *protocol,
11761176
if (want_access & GRANT_ACL)
11771177
db.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
11781178
protocol->start_row();
1179-
protocol->store(db.ptr(), db.length(), db.charset());
1179+
protocol->store_string(db.ptr(), db.length(), db.charset());
11801180
protocol->end_row();
11811181
}
11821182
}
@@ -1229,7 +1229,7 @@ void make_with_admin_privilege_statement(
12291229
global.append(" WITH ADMIN OPTION");
12301230

12311231
protocol->start_row();
1232-
protocol->store(global.ptr(), global.length(), global.charset());
1232+
protocol->store_string(global.ptr(), global.length(), global.charset());
12331233
protocol->end_row();
12341234
}
12351235
}
@@ -1266,7 +1266,7 @@ void make_dynamic_privilege_statement(THD *thd, ACL_USER *role,
12661266
role->host.get_host_len());
12671267
if (grant_option) global.append(" WITH GRANT OPTION");
12681268
protocol->start_row();
1269-
protocol->store(global.ptr(), global.length(), global.charset());
1269+
protocol->store_string(global.ptr(), global.length(), global.charset());
12701270
protocol->end_row();
12711271
}
12721272
found = false;
@@ -1331,7 +1331,7 @@ void make_roles_privilege_statement(THD *thd, ACL_USER *role,
13311331
append_identifier(thd, &global, role->host.get_host(),
13321332
role->host.get_host_len());
13331333
protocol->start_row();
1334-
protocol->store(global.ptr(), global.length(), global.charset());
1334+
protocol->store_string(global.ptr(), global.length(), global.charset());
13351335
protocol->end_row();
13361336
}
13371337
}
@@ -1406,7 +1406,7 @@ void make_table_privilege_statement(THD *thd, ACL_USER *role,
14061406
if (agg.table_access & GRANT_ACL)
14071407
global.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
14081408
protocol->start_row();
1409-
protocol->store(global.ptr(), global.length(), global.charset());
1409+
protocol->store_string(global.ptr(), global.length(), global.charset());
14101410
protocol->end_row();
14111411
}
14121412
}
@@ -4702,7 +4702,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user,
47024702
make_global_privilege_statement(thd, access, acl_user, &output);
47034703
Protocol *protocol = thd->get_protocol();
47044704
protocol->start_row();
4705-
protocol->store(output.ptr(), output.length(), output.charset());
4705+
protocol->store_string(output.ptr(), output.length(), output.charset());
47064706
protocol->end_row();
47074707

47084708
make_dynamic_privilege_statement(thd, acl_user, protocol, dynamic_acl);

sql/auth/sql_user.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ bool mysql_show_create_user(THD *thd, LEX_USER *user_name,
338338

339339
/* send the result row to client */
340340
protocol->start_row();
341-
protocol->store(sql_text.ptr(), sql_text.length(), sql_text.charset());
341+
protocol->store_string(sql_text.ptr(), sql_text.length(), sql_text.charset());
342342
if (protocol->end_row()) {
343343
error = 1;
344344
goto err;

sql/events.cc

+16-15
Original file line numberDiff line numberDiff line change
@@ -798,21 +798,22 @@ static bool send_show_create_event(THD *thd, Event_timed *et,
798798

799799
protocol->start_row();
800800

801-
protocol->store(et->m_event_name.str, et->m_event_name.length,
802-
system_charset_info);
803-
protocol->store(sql_mode.str, sql_mode.length, system_charset_info);
804-
protocol->store(tz_name->ptr(), tz_name->length(), system_charset_info);
805-
protocol->store(show_str.c_ptr(), show_str.length(),
806-
et->m_creation_ctx->get_client_cs());
807-
protocol->store(et->m_creation_ctx->get_client_cs()->csname,
808-
strlen(et->m_creation_ctx->get_client_cs()->csname),
809-
system_charset_info);
810-
protocol->store(et->m_creation_ctx->get_connection_cl()->name,
811-
strlen(et->m_creation_ctx->get_connection_cl()->name),
812-
system_charset_info);
813-
protocol->store(et->m_creation_ctx->get_db_cl()->name,
814-
strlen(et->m_creation_ctx->get_db_cl()->name),
815-
system_charset_info);
801+
protocol->store_string(et->m_event_name.str, et->m_event_name.length,
802+
system_charset_info);
803+
protocol->store_string(sql_mode.str, sql_mode.length, system_charset_info);
804+
protocol->store_string(tz_name->ptr(), tz_name->length(),
805+
system_charset_info);
806+
protocol->store_string(show_str.c_ptr(), show_str.length(),
807+
et->m_creation_ctx->get_client_cs());
808+
protocol->store_string(et->m_creation_ctx->get_client_cs()->csname,
809+
strlen(et->m_creation_ctx->get_client_cs()->csname),
810+
system_charset_info);
811+
protocol->store_string(et->m_creation_ctx->get_connection_cl()->name,
812+
strlen(et->m_creation_ctx->get_connection_cl()->name),
813+
system_charset_info);
814+
protocol->store_string(et->m_creation_ctx->get_db_cl()->name,
815+
strlen(et->m_creation_ctx->get_db_cl()->name),
816+
system_charset_info);
816817

817818
if (protocol->end_row()) return true;
818819

sql/field.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -4278,8 +4278,8 @@ bool Field_float::send_to_protocol(Protocol *protocol) const {
42784278
ASSERT_COLUMN_MARKED_FOR_READ;
42794279
if (is_null()) return protocol->store_null();
42804280
StringBuffer<FLOATING_POINT_BUFFER> buffer;
4281-
return protocol->store(static_cast<float>(Field_float::val_real()), dec,
4282-
zerofill ? field_length : 0, &buffer);
4281+
return protocol->store_float(static_cast<float>(Field_float::val_real()), dec,
4282+
zerofill ? field_length : 0, &buffer);
42834283
}
42844284

42854285
/**
@@ -4501,8 +4501,8 @@ String *Field_double::val_str(String *val_buffer,
45014501
bool Field_double::send_to_protocol(Protocol *protocol) const {
45024502
if (is_null()) return protocol->store_null();
45034503
StringBuffer<FLOATING_POINT_BUFFER> buffer;
4504-
return protocol->store(Field_double::val_real(), dec,
4505-
zerofill ? field_length : 0, &buffer);
4504+
return protocol->store_double(Field_double::val_real(), dec,
4505+
zerofill ? field_length : 0, &buffer);
45064506
}
45074507

45084508
int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr) const {

sql/handler.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7439,9 +7439,9 @@ static bool stat_print(THD *thd, const char *type, size_t type_len,
74397439
size_t status_len) {
74407440
Protocol *protocol = thd->get_protocol();
74417441
protocol->start_row();
7442-
protocol->store(type, type_len, system_charset_info);
7443-
protocol->store(file, file_len, system_charset_info);
7444-
protocol->store(status, status_len, system_charset_info);
7442+
protocol->store_string(type, type_len, system_charset_info);
7443+
protocol->store_string(file, file_len, system_charset_info);
7444+
protocol->store_string(status, status_len, system_charset_info);
74457445
if (protocol->end_row()) return true;
74467446
return false;
74477447
}

sql/item.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -6575,7 +6575,8 @@ bool Item::send(Protocol *protocol, String *buffer) {
65756575
case MYSQL_TYPE_JSON: {
65766576
const String *res = val_str(buffer);
65776577
if (res != nullptr)
6578-
return protocol->store(res->ptr(), res->length(), res->charset());
6578+
return protocol->store_string(res->ptr(), res->length(),
6579+
res->charset());
65796580
break;
65806581
}
65816582
case MYSQL_TYPE_TINY: {
@@ -6602,12 +6603,12 @@ bool Item::send(Protocol *protocol, String *buffer) {
66026603
}
66036604
case MYSQL_TYPE_FLOAT: {
66046605
float nr = static_cast<float>(val_real());
6605-
if (!null_value) return protocol->store(nr, decimals, 0, buffer);
6606+
if (!null_value) return protocol->store_float(nr, decimals, 0, buffer);
66066607
break;
66076608
}
66086609
case MYSQL_TYPE_DOUBLE: {
66096610
double nr = val_real();
6610-
if (!null_value) return protocol->store(nr, decimals, 0, buffer);
6611+
if (!null_value) return protocol->store_double(nr, decimals, 0, buffer);
66116612
break;
66126613
}
66136614
case MYSQL_TYPE_DATE: {

sql/log_event.cc

+21-21
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ int Log_event::net_send(Protocol *protocol, const char *log_name,
10901090
protocol->store(log_name, &my_charset_bin);
10911091
protocol->store((ulonglong)pos);
10921092
event_type = get_type_str();
1093-
protocol->store(event_type, strlen(event_type), &my_charset_bin);
1093+
protocol->store_string(event_type, strlen(event_type), &my_charset_bin);
10941094
protocol->store((uint32)server_id);
10951095
protocol->store((ulonglong)common_header->log_pos);
10961096
if (pack_info(protocol)) return 1;
@@ -3286,7 +3286,7 @@ int Query_log_event::pack_info(Protocol *protocol) {
32863286
}
32873287
}
32883288
// persist the buffer in protocol
3289-
protocol->store(str_buf.ptr(), str_buf.length(), &my_charset_bin);
3289+
protocol->store_string(str_buf.ptr(), str_buf.length(), &my_charset_bin);
32903290
return 0;
32913291
}
32923292

@@ -5200,7 +5200,7 @@ int Format_description_log_event::pack_info(Protocol *protocol) {
52005200
pos = my_stpcpy(pos, server_version);
52015201
pos = my_stpcpy(pos, ", Binlog ver: ");
52025202
pos = int10_to_str(binlog_version, pos, 10);
5203-
protocol->store(buf, (uint)(pos - buf), &my_charset_bin);
5203+
protocol->store_string(buf, (uint)(pos - buf), &my_charset_bin);
52045204
return 0;
52055205
}
52065206

@@ -5379,7 +5379,7 @@ int Rotate_log_event::pack_info(Protocol *protocol) {
53795379
tmp.append(new_log_ident, ident_len);
53805380
tmp.append(STRING_WITH_LEN(";pos="));
53815381
tmp.append(llstr(pos, buf));
5382-
protocol->store(tmp.ptr(), tmp.length(), &my_charset_bin);
5382+
protocol->store_string(tmp.ptr(), tmp.length(), &my_charset_bin);
53835383
return 0;
53845384
}
53855385
#endif // MYSQL_SERVER
@@ -5640,7 +5640,7 @@ int Intvar_log_event::pack_info(Protocol *protocol) {
56405640
pos = strmake(buf, (get_var_type_string()).c_str(), sizeof(buf) - 23);
56415641
*pos++ = '=';
56425642
pos = longlong10_to_str(val, pos, -10);
5643-
protocol->store(buf, (uint)(pos - buf), &my_charset_bin);
5643+
protocol->store_string(buf, (uint)(pos - buf), &my_charset_bin);
56445644
return 0;
56455645
}
56465646
#endif // MYSQL_SERVER
@@ -5757,7 +5757,7 @@ int Rand_log_event::pack_info(Protocol *protocol) {
57575757
pos = int10_to_str((long)seed1, pos, 10);
57585758
pos = my_stpcpy(pos, ",rand_seed2=");
57595759
pos = int10_to_str((long)seed2, pos, 10);
5760-
protocol->store(buf1, (uint)(pos - buf1), &my_charset_bin);
5760+
protocol->store_string(buf1, (uint)(pos - buf1), &my_charset_bin);
57615761
return 0;
57625762
}
57635763
#endif // MYSQL_SERVER
@@ -5859,7 +5859,7 @@ int Xid_log_event::pack_info(Protocol *protocol) {
58595859
pos = my_stpcpy(buf, "COMMIT /* xid=");
58605860
pos = longlong10_to_str(xid, pos, 10);
58615861
pos = my_stpcpy(pos, " */");
5862-
protocol->store(buf, (uint)(pos - buf), &my_charset_bin);
5862+
protocol->store_string(buf, (uint)(pos - buf), &my_charset_bin);
58635863
return 0;
58645864
}
58655865
#endif // MYSQL_SERVER
@@ -6200,7 +6200,7 @@ int XA_prepare_log_event::pack_info(Protocol *protocol) {
62006200
my_xid.data);
62016201
sprintf(query, (one_phase ? "XA COMMIT %s ONE PHASE" : "XA PREPARE %s"), buf);
62026202

6203-
protocol->store(query, strlen(query), &my_charset_bin);
6203+
protocol->store_string(query, strlen(query), &my_charset_bin);
62046204
return 0;
62056205
}
62066206

@@ -6384,7 +6384,7 @@ int User_var_log_event::pack_info(Protocol *protocol) {
63846384
buf[0] = '@';
63856385
memcpy(buf + 1, quoted_id, id_len);
63866386
buf[1 + id_len] = '=';
6387-
protocol->store(buf, event_len, &my_charset_bin);
6387+
protocol->store_string(buf, event_len, &my_charset_bin);
63886388
my_free(buf);
63896389
return 0;
63906390
}
@@ -6841,7 +6841,7 @@ int Append_block_log_event::pack_info(Protocol *protocol) {
68416841
size_t length;
68426842
length = snprintf(buf, sizeof(buf), ";file_id=%u;block_len=%u", file_id,
68436843
block_len);
6844-
protocol->store(buf, length, &my_charset_bin);
6844+
protocol->store_string(buf, length, &my_charset_bin);
68456845
return 0;
68466846
}
68476847

@@ -6977,7 +6977,7 @@ int Delete_file_log_event::pack_info(Protocol *protocol) {
69776977
char buf[64];
69786978
size_t length;
69796979
length = snprintf(buf, sizeof(buf), ";file_id=%u", (uint)file_id);
6980-
protocol->store(buf, length, &my_charset_bin);
6980+
protocol->store_string(buf, length, &my_charset_bin);
69816981
return 0;
69826982
}
69836983

@@ -7170,7 +7170,7 @@ int Execute_load_query_log_event::pack_info(Protocol *protocol) {
71707170
}
71717171
pos = my_stpcpy(pos, " ;file_id=");
71727172
pos = int10_to_str((long)file_id, pos, 10);
7173-
protocol->store(buf, pos - buf, &my_charset_bin);
7173+
protocol->store_string(buf, pos - buf, &my_charset_bin);
71747174
my_free(buf);
71757175
return 0;
71767176
}
@@ -10013,7 +10013,7 @@ int Rows_log_event::pack_info(Protocol *protocol) {
1001310013
char const *const flagstr = get_flags(STMT_END_F) ? " flags: STMT_END_F" : "";
1001410014
size_t bytes =
1001510015
snprintf(buf, sizeof(buf), "table_id: %llu%s", m_table_id.id(), flagstr);
10016-
protocol->store(buf, bytes, &my_charset_bin);
10016+
protocol->store_string(buf, bytes, &my_charset_bin);
1001710017
return 0;
1001810018
}
1001910019
#endif // MYSQL_SERVER
@@ -10937,7 +10937,7 @@ int Table_map_log_event::pack_info(Protocol *protocol) {
1093710937
size_t bytes = snprintf(buf, sizeof(buf), "table_id: %llu (%s.%s)",
1093810938
m_table_id.id(), m_dbnam.c_str(), m_tblnam.c_str());
1093910939
DBUG_ASSERT(bytes < 256);
10940-
protocol->store(buf, bytes, &my_charset_bin);
10940+
protocol->store_string(buf, bytes, &my_charset_bin);
1094110941
return 0;
1094210942
}
1094310943
#endif // MYSQL_SERVER
@@ -12092,7 +12092,7 @@ int Incident_log_event::pack_info(Protocol *protocol) {
1209212092
else
1209312093
bytes = snprintf(buf, sizeof(buf), "#%d (%s): %s", incident, description(),
1209412094
message);
12095-
protocol->store(buf, bytes, &my_charset_bin);
12095+
protocol->store_string(buf, bytes, &my_charset_bin);
1209612096
return 0;
1209712097
}
1209812098
#endif
@@ -12204,7 +12204,7 @@ int Ignorable_log_event::pack_info(Protocol *protocol) {
1220412204
char buf[256];
1220512205
size_t bytes;
1220612206
bytes = snprintf(buf, sizeof(buf), "# Unrecognized ignorable event");
12207-
protocol->store(buf, bytes, &my_charset_bin);
12207+
protocol->store_string(buf, bytes, &my_charset_bin);
1220812208
return 0;
1220912209
}
1221012210
#endif
@@ -12238,7 +12238,7 @@ int Rows_query_log_event::pack_info(Protocol *protocol) {
1223812238
if (!(buf = (char *)my_malloc(key_memory_log_event, len, MYF(MY_WME))))
1223912239
return 1;
1224012240
bytes = snprintf(buf, len, "# %s", m_rows_query);
12241-
protocol->store(buf, bytes, &my_charset_bin);
12241+
protocol->store_string(buf, bytes, &my_charset_bin);
1224212242
my_free(buf);
1224312243
return 0;
1224412244
}
@@ -12419,7 +12419,7 @@ Gtid_log_event::Gtid_log_event(
1241912419
int Gtid_log_event::pack_info(Protocol *protocol) {
1242012420
char buffer[MAX_SET_STRING_LENGTH + 1];
1242112421
size_t len = to_string(buffer);
12422-
protocol->store(buffer, len, &my_charset_bin);
12422+
protocol->store_string(buffer, len, &my_charset_bin);
1242312423
return 0;
1242412424
}
1242512425
#endif // MYSQL_SERVER
@@ -12853,7 +12853,7 @@ int Previous_gtids_log_event::pack_info(Protocol *protocol) {
1285312853
size_t length = 0;
1285412854
char *str = get_str(&length, &Gtid_set::default_string_format);
1285512855
if (str == nullptr) return 1;
12856-
protocol->store(str, length, &my_charset_bin);
12856+
protocol->store_string(str, length, &my_charset_bin);
1285712857
my_free(str);
1285812858
return 0;
1285912859
}
@@ -13011,7 +13011,7 @@ int Transaction_context_log_event::pack_info(Protocol *protocol) {
1301113011
DBUG_TRACE;
1301213012
char buf[256];
1301313013
size_t bytes = to_string(buf, 256);
13014-
protocol->store(buf, bytes, &my_charset_bin);
13014+
protocol->store_string(buf, bytes, &my_charset_bin);
1301513015
return 0;
1301613016
}
1301713017
#endif
@@ -13225,7 +13225,7 @@ int View_change_log_event::pack_info(Protocol *protocol) {
1322513225
DBUG_TRACE;
1322613226
char buf[256];
1322713227
size_t bytes = to_string(buf, 256);
13228-
protocol->store(buf, bytes, &my_charset_bin);
13228+
protocol->store_string(buf, bytes, &my_charset_bin);
1322913229
return 0;
1323013230
}
1323113231
#endif

sql/partitioning/partition_handler.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1394,10 +1394,10 @@ bool Partition_helper::print_admin_msg(THD *thd, uint len, const char *msg_type,
13941394
DBUG_PRINT("info", ("print_admin_msg: %s, %s, %s, %s", name, op_name,
13951395
msg_type, msgbuf));
13961396
protocol->start_row();
1397-
protocol->store(name, length, system_charset_info);
1397+
protocol->store_string(name, length, system_charset_info);
13981398
protocol->store(op_name, system_charset_info);
13991399
protocol->store(msg_type, system_charset_info);
1400-
protocol->store(msgbuf, msg_length, system_charset_info);
1400+
protocol->store_string(msgbuf, msg_length, system_charset_info);
14011401
if (protocol->end_row()) {
14021402
LogErr(ERROR_LEVEL, ER_MY_NET_WRITE_FAILED_FALLING_BACK_ON_STDERR, msgbuf);
14031403
goto err;

0 commit comments

Comments
 (0)