Skip to content

variable: select global variable with out global flag return wrong result. #8967

Closed
@crazycs520

Description

@crazycs520

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    such as max_connections, tidb_auto_analyze_ratio are only global level variable.
    In TiDB:
mysql root@127.0.0.1:test> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 151               |
+-------------------+
1 row in set
Time: 0.004s
mysql root@127.0.0.1:test> select @@global.max_connections;
+--------------------------+
| @@global.max_connections |
+--------------------------+
| 151                      |
+--------------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test> set @@global.max_connections=100;
Query OK, 0 rows affected
Time: 0.001s
mysql root@127.0.0.1:test> select @@global.max_connections;
+--------------------------+
| @@global.max_connections |
+--------------------------+
| 100                      |
+--------------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 151               |
+-------------------+
1 row in set

In Mysql

mysql root@127.0.0.1:test> select @@global.max_connections
+--------------------------+
| @@global.max_connections |
+--------------------------+
| 151                      |
+--------------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test> select @@max_connections
+-------------------+
| @@max_connections |
+-------------------+
| 151               |
+-------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test> set @@global.max_connections=100;
Query OK, 0 rows affected
Time: 0.000s
mysql root@127.0.0.1:test> select @@global.max_connections
+--------------------------+
| @@global.max_connections |
+--------------------------+
| 100                      |
+--------------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test> select @@max_connections
+-------------------+
| @@max_connections |
+-------------------+
| 100               |
+-------------------+
1 row in set
Time: 0.003s
mysql root@127.0.0.1:test>
  1. What did you expect to see?
    same as mysql.

  2. What did you see instead?

  3. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

mysql root@127.0.0.1:test> select tidb_version()                                                                                                                                          │+--------------------------+
+--------------------------------------------------------------------------+                                                                                                              │1 row in set
| tidb_version()                                                           |                                                                                                              │Time: 0.003s
+--------------------------------------------------------------------------+                                                                                                              │mysql root@127.0.0.1:test> select @@max_connections
| Release Version: v2.1.0-rc.3-415-g7ee6811d9                              |                                                                                                              │+-------------------+
| Git Commit Hash: 7ee6811d9777bc2ae281292bf2f6313abb64b5c3                |                                                                                                              │| @@max_connections |
| Git Branch: master                                                       |                                                                                                              │+-------------------+
| UTC Build Time: 2019-01-07 11:19:35                                      |                                                                                                              │| 100               |
| GoVersion: go version go1.11.2 darwin/amd64                              |                                                                                                              │+-------------------+
| Race Enabled: false                                                      |                                                                                                              │1 row in set
| TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e |                                                                                                              │Time: 0.003s
| Check Table Before Drop: false                                           |                                                                                                              │mysql root@127.0.0.1:test>
+--------------------------------------------------------------------------+                                                                                                              │
1 row in set

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions