Bug #101239 mysqlcheck lacks documentation on output format or return codes
Submitted: 20 Oct 2020 10:28 Modified: 14 Dec 2020 17:28
Reporter: Jaime Crespo (OCA) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: check tables, documentation, mysqlcheck, Output, return

[20 Oct 2020 10:28] Jaime Crespo
Description:
As a mysql user, I want to check all tables of my MySQL server (as we had recently some index corruption) and understand which ones had errors (were not ok).

I used mysqlcheck rather than SQL "check table" directly so I don't have to handle the logic of going over all tables.

I checked the manual (and man page) for mysql check: https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html and it doesn't mention what it outputs, other than mentioning it uses standard CHECK TABLE commands, for the default option.

Does it return 0 if all tables are without errors? What does it return if not? Does it always return 0 and we are supposed to parse the output? If we are supposed to parse the output, how does it return the sql output (tab separated?).

How to repeat:
Go to https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html or execute "man mysqlcheck" ( https://github.com/mysql/mysql-server/blob/8.0/man/mysqlcheck.1 ) or "mysqlcheck --help" and try to respond the above questions.

Suggested fix:
Add an "output" section or paragraph both on MySQL official documentation and man page with the detailed output of each mysqlcheck option return to stdout/stderr and return code.

I don't mind if it always returns 0 (if it runs CHECK TABLE correctly, as it is difficult to provide meaningful return codes on commands that do multiple things) as long as it is documented. I will have to check the source code to know what it really does.
[20 Oct 2020 10:59] MySQL Verification Team
Hello Jaime,

Thank you for the report!

Thanks,
Umesh
[14 Dec 2020 17:28] Paul DuBois
Posted by developer:
 
mysqlcheck has the usual command-line exit status of 0 = success, nonzero = failure. Nonzero can be the exit status for reasons unrelated to query execution (for example, a misspelled option), so it's not a great way to tell some check has failed; no check may have even been run.

If you're interested in structured query output to parse, you're probably better off using mysql to execute a CHECK TABLE statement. It has output-format options to suit application requirements.