Bug #104672 Missing server version check in mysqldump (COLUMN_STATISTICS)
Submitted: 20 Aug 2021 6:47 Modified: 20 Aug 2021 7:36
Reporter: Mathias Brodala Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:8 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysqldump

[20 Aug 2021 6:47] Mathias Brodala
Description:
As reported many times using "mysqldump" version 8 or with a MySQL server 5.7 or older leads to the dreaded 'Unknown table 'COLUMN_STATISTICS' in information_schema' error:

> Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = '<db>' AND TABLE_NAME = '<first-table>';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

How to repeat:
Run "mysqldump" 8+ on a MySQL 5.7 server.

Suggested fix:
There are many hints about working around this issue but from my POV the original issue should be addressed.

Namely "mysqldump" should actually check the MySQL server version (or capabilities/features) before its actual action. This way it can make sure to only use features actually supported by the MySQL server.

This way the mentioned COLUMN_STATISTICS would not occur; mysqldump could detect that it is connected to an older MySQL server and not query the COLUMN_STATISTICS table.

In the simplest case this detection would be an alternative trigger for already existing CLI flags like "--column-statistics=0" so no major code changes should be necessary.
[20 Aug 2021 7:04] MySQL Verification Team
Hello Mathias Brodala,

Thank you for the report and feedback.
Imho this is duplicate of existing bug report Bug #89825 which already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the original bug instead. Thank you!

regards,
Umesh
[20 Aug 2021 7:36] Mathias Brodala
Umesh, thanks a lot for the hint.

The mentioned issue sounds indeed like the one I reported. I did not find it on search since I did not see the "All" status in the bug search initially.

I now left a comment on that report with the most relevant info from here.