Bug #72293 THDVAR_INT return value is wrong
Submitted: 9 Apr 2014 17:05 Modified: 15 Apr 2014 20:14
Reporter: richard prohaska Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Storage Engines Severity:S3 (Non-critical)
Version:5.6.16, 5.7.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: linux

[9 Apr 2014 17:05] richard prohaska
Description:
If i have a THDVAR_INT with default 0, min -1, and max 1, the returned value is 4294967295 when i set it to -1.

mysql> set tokudb_demo=-1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> select @@tokudb_demo;
+---------------+
| @@tokudb_demo |
+---------------+
|    4294967295 |
+---------------+

How to repeat:
Add a demo session variable to the mysql server of type THDVAR_INT, set it to -1 and query its value.
[15 Apr 2014 20:14] Sveta Smirnova
Thank you for the report.

Verified as described.

To repeat modify source code as follows:

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- storage/innobase/handler/ha_innodb.cc	2014-04-03 14:11:16 +0000
+++ storage/innobase/handler/ha_innodb.cc	2014-04-15 20:10:28 +0000
@@ -529,6 +529,10 @@
   NULL, NULL,
   /* default */ TRUE);
 
+// bug#72293
+static MYSQL_THDVAR_INT(bug72293, PLUGIN_VAR_OPCMDARG, "Test for bug #72293", NULL, NULL, 0, -1, 1, 0);
+// end of bug #72293
+
 static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
   "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
   NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
@@ -16249,6 +16253,7 @@
   MYSQL_SYSVAR(ft_total_cache_size),
   MYSQL_SYSVAR(ft_result_cache_limit),
   MYSQL_SYSVAR(ft_enable_stopword),
+  MYSQL_SYSVAR(bug72293),
   MYSQL_SYSVAR(ft_max_token_size),
   MYSQL_SYSVAR(ft_min_token_size),
   MYSQL_SYSVAR(ft_num_word_optimize),

Then compile the server, run it and execute:

mysql> show variables like '%bug%';
+-----------------------------------------+------------------+
| Variable_name                           | Value            |
+-----------------------------------------+------------------+
...
| innodb_bug72293                         | 0                |
...
+-----------------------------------------+------------------+
9 rows in set (0.00 sec)

mysql> set innodb_bug72293=-1;
Query OK, 0 rows affected (0.00 sec)

mysql> select @@innodb_bug72293;
+-------------------+
| @@innodb_bug72293 |
+-------------------+
|        4294967295 |
+-------------------+
1 row in set (0.00 sec)