Summary
ssh_db_query reports row_count one greater than the actual number of rows: 1 row → row_count: 2, 13 rows → 14, and a 0-row result → row_count: 2.
Affected code
src/index.js (v3.5.0), in the db-query handler:
const output = result.stdout.trim();
const lines = output.split('\n');
...
row_count: lines.length,
For MySQL, buildMySQLQueryCommand() wraps results with awk 'BEGIN{print "["} ... END{print "]"}', so output looks like:
[
{"row":1,"data":"..."},
{"row":2,"data":"..."}]
output.split('\n').length counts the leading [ line in addition to the per-row lines, so row_count = actual_rows + 1. It also conflates "lines" with "rows" — it would miscount if any cell value contained a newline.
Reproduction
Any MySQL query returning N rows reports row_count: N+1. A query returning 0 rows reports output: "[\n]" with row_count: 2.
Suggested fix
Derive the count from the actual result rows rather than the cosmetic line count — e.g. count the {"row": entries, JSON.parse the assembled array and use .length, or use MySQL's own row count. Subtracting the wrapper line would fix the off-by-one, but parsing the structured result is more robust.
Version: mcp-ssh-manager 3.5.0.
Related: #44 (query corruption in the same MySQL query path).
Summary
ssh_db_queryreportsrow_countone greater than the actual number of rows: 1 row →row_count: 2, 13 rows →14, and a 0-row result →row_count: 2.Affected code
src/index.js(v3.5.0), in the db-query handler:For MySQL,
buildMySQLQueryCommand()wraps results withawk 'BEGIN{print "["} ... END{print "]"}', sooutputlooks like:output.split('\n').lengthcounts the leading[line in addition to the per-row lines, sorow_count = actual_rows + 1. It also conflates "lines" with "rows" — it would miscount if any cell value contained a newline.Reproduction
Any MySQL query returning N rows reports
row_count: N+1. A query returning 0 rows reportsoutput: "[\n]"withrow_count: 2.Suggested fix
Derive the count from the actual result rows rather than the cosmetic line count — e.g. count the
{"row":entries,JSON.parsethe assembled array and use.length, or use MySQL's own row count. Subtracting the wrapper line would fix the off-by-one, but parsing the structured result is more robust.Version: mcp-ssh-manager 3.5.0.
Related: #44 (query corruption in the same MySQL query path).