Skip to content

Commit faed54e

Browse files
committed
Only send JSON if rows_read > 0
1 parent c374f14 commit faed54e

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
@@ -1332,11 +1332,17 @@ bool Protocol_classic::send_eof(uint server_status, uint statement_warn_count) {
13321332
if (has_client_capability(CLIENT_DEPRECATE_EOF) &&
13331333
(m_thd->get_command() != COM_BINLOG_DUMP &&
13341334
m_thd->get_command() != COM_BINLOG_DUMP_GTID)) {
1335-
char message[64] = "";
1336-
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", m_thd->get_stmt_da()->rows_read());
1337-
1338-
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1339-
message, 1+strlen(message+1), true);
1335+
ulonglong rows_read = m_thd->get_stmt_da()->rows_read();
1336+
if (rows_read) {
1337+
char message[64] = "";
1338+
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", rows_read);
1339+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1340+
message, 1+strlen(message+1), true);
1341+
}
1342+
else {
1343+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1344+
NULL, 0, true);
1345+
}
13401346
}
13411347
else
13421348
retval = net_send_eof(m_thd, server_status, statement_warn_count);

0 commit comments

Comments
 (0)