Skip to content

Commit f4d3ddc

Browse files
committed
Only send JSON if rows_read > 0
1 parent 765fc31 commit f4d3ddc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sql/protocol_classic.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,11 +1323,17 @@ bool Protocol_classic::send_eof(uint server_status, uint statement_warn_count) {
13231323
if (has_client_capability(CLIENT_DEPRECATE_EOF) &&
13241324
(m_thd->get_command() != COM_BINLOG_DUMP &&
13251325
m_thd->get_command() != COM_BINLOG_DUMP_GTID)) {
1326-
char message[64] = "";
1327-
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", m_thd->get_stmt_da()->rows_read());
1328-
1329-
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1330-
message, 1+strlen(message+1), true);
1326+
ulonglong rows_read = m_thd->get_stmt_da()->rows_read();
1327+
if (rows_read) {
1328+
char message[64] = "";
1329+
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", rows_read);
1330+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1331+
message, 1+strlen(message+1), true);
1332+
}
1333+
else {
1334+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1335+
NULL, 0, true);
1336+
}
13311337
}
13321338
else
13331339
retval = net_send_eof(m_thd, server_status, statement_warn_count);

0 commit comments

Comments
 (0)