Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 某些场景下查询mysql.stats_top_n表导致乱码
Bug Report
Clearly and accurately describe the issue you found. Providing any steps to reproduce the issue can help the development team address it promptly.
【TiDB Version】6.3.0
【Impact of the Bug】Causes client garbled text
【Possible Steps to Reproduce the Issue】
mysql> show variables like 'tidb_analyze_version';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| tidb_analyze_version | 2 |
+----------------------+-------+
1 row in set (0.00 sec)
Start the tpch bench, wait for the automatic statistics to complete, and then query the topN statistics view
select * from mysql.stats_top_n where table_id=125 and hist_id=2;
【Observed Unexpected Behavior】
mysql> select * from mysql.stats_top_n where table_id=125 and hist_id=2;
+----------+----------+---------+-----------+-------+
| table_id | is_index | hist_id | value | count |
+----------+----------+---------+-----------+-------+
| 125 | 1 | 2 | | 60099 |
| 125 | 1 | 2 | | 58500 |
| 125 | 1 | 2 |
| 58357 |
| 125 | 1 | 2 | | 58344 |
| 125 | 1 | 2 | | 58032 |
| 125 | 1 | 2 |
| 58019 |
| 125 | 1 | 2 | | 57993 |
| 125 | 1 | 2 | | 57915 |
| 125 | 1 | 2 | | 57863 |
| 125 | 1 | 2 | | 57850 |
| 125 | 1 | 2 | | 57421 |
| 125 | 1 | 2 | | 57408 |
| 125 | 1 | 2 | | 57382 |
| 125 | 1 | 2 | | 57369 |
| 57148 || 1 | 2 |
| 125 | 1 | 2 | | 57018 |
| 125 | 1 | 2 | | 56927 |
| 125 | 1 | 2 |
| 56706 |
| 125 | 1 | 2 | | 56576 |
| 125 | 1 | 2 | | 56563 |
| 125 | 1 | 2 | | 56524 |
| 125 | 1 | 2 | | 56459 |
| 125 | 1 | 2 | | 56329 |
| 125 | 1 | 2 | | 56225 |
| 125 | 1 | 2 | | 56056 |
+----------+----------+---------+-----------+-------+
25 _-+_ i+ _e+ (0.01 _ec)
+y_-+>
+y_-+>
+y_-+>
+y_-+>
【Expected Behavior】
Normal output
【Related Components and Specific Versions】
【Other Background Information or Screenshots】