Bug #118771 stats_persistent show value wrong in debug mode
Submitted: 2 Aug 4:47 Modified: 4 Aug 5:04
Reporter: zongyi chen (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S6 (Debug Builds)
Version:8.0.42, 8.0.43, 8.4.6, 9.4.0 OS:Any
Assigned to: CPU Architecture:Any

[2 Aug 4:47] zongyi chen
Description:
mysql> SET SESSION debug = '+d,skip_dd_table_access_check';
Query OK, 0 rows affected (0.00 sec)

mysql> create table t (a int) stats_persistent = 1;
Query OK, 0 rows affected (5.84 sec)

mysql> SELECT options FROM mysql.tables where name = 't';
+------------------------------------------------------------------------------------------------------------------------------------------------+
| options                                                                                                                                        |
+------------------------------------------------------------------------------------------------------------------------------------------------+
| avg_row_length=0;encrypt_type=N;key_block_size=0;keys_disabled=0;pack_record=0;stats_auto_recalc=0;stats_persistent=4096;stats_sample_pages=0; |
+------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

Noted that the value of stats_persistent is 4096, instead of the expected 1.

How to repeat:
be as above

Suggested fix:
diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc
index 32e0d28..cbf0d70 100644
--- a/sql/dd/dd_table.cc
+++ b/sql/dd/dd_table.cc
@@ -2077,7 +2077,7 @@ static bool fill_dd_table_from_create_info(
         (HA_OPTION_STATS_PERSISTENT | HA_OPTION_NO_STATS_PERSISTENT));
 
     table_options->set("stats_persistent", (create_info->table_options &
-                                            HA_OPTION_STATS_PERSISTENT));
+                                            HA_OPTION_STATS_PERSISTENT) ? 1 : 0);
   }
[4 Aug 5:04] MySQL Verification Team
Hello zongyi chen,

Thank you for the report and test case.
Verified as described.

regards,
Umesh
[4 Aug 5:17] MySQL Verification Team
Hello zongyi chen,

Please ensure to reupload the patch via "Contribution" tab of this bug page otherwise we may not be able to use it. Thank you.

regards,
Umesh