MySQL :: MySQL 8.0 Reference Manual :: 7.6.6.4 Version Tokens Reference (original) (raw)

version_tokens_session

Command-Line Format --version-tokens-session=value
System Variable version_tokens_session
Scope Global, Session
Dynamic Yes
SET_VAR Hint Applies No
Type String
Default Value NULL

The session value of this variable specifies the client version token list and indicates the tokens that the client session requires the server version token list to have.

If theversion_tokens_session variable is NULL (the default) or has an empty value, any server version token list matches. (In effect, an empty value disables matching requirements.)

If theversion_tokens_session variable has a nonempty value, any mismatch between its value and the server version token list results in an error for any statement the session sends to the server. A mismatch occurs under these conditions:

It is not a mismatch for the server version token list to include a token not named in theversion_tokens_session value.

Suppose that a management application has set the server token list as follows:

mysql> SELECT version_tokens_set('tok1=a;tok2=b;tok3=c');
+--------------------------------------------+
| version_tokens_set('tok1=a;tok2=b;tok3=c') |
+--------------------------------------------+
| 3 version tokens set.                      |
+--------------------------------------------+

A client registers the tokens it requires the server to match by setting itsversion_tokens_session value. Then, for each subsequent statement sent by the client, the server checks its token list against the clientversion_tokens_session value and produces an error if there is a mismatch:

mysql> SET @@SESSION.version_tokens_session = 'tok1=a;tok2=b';
mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+

mysql> SET @@SESSION.version_tokens_session = 'tok1=b';
mysql> SELECT 1;
ERROR 3136 (42000): Version token mismatch for tok1. Correct value a

The first SELECT succeeds because the client tokens tok1 andtok2 are present in the server token list and each token has the same value in the server list. The second SELECT fails because, although tok1 is present in the server token list, it has a different value than specified by the client.

At this point, any statement sent by the client fails, unless the server token list changes such that it matches again. Suppose that the management application changes the server token list as follows:

mysql> SELECT version_tokens_edit('tok1=b');
+-------------------------------+
| version_tokens_edit('tok1=b') |
+-------------------------------+
| 1 version tokens updated.     |
+-------------------------------+
mysql> SELECT version_tokens_show();
+-----------------------+
| version_tokens_show() |
+-----------------------+
| tok3=c;tok1=b;tok2=b; |
+-----------------------+

Now the clientversion_tokens_session value matches the server token list and the client can once again successfully execute statements:

mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+