Rechercher dans le manuel MySQL

5.6.6.4 Version Tokens Reference

The following discussion serves as a reference to these Version Tokens components:

Version Tokens Functions

The Version Tokens plugin library includes several user-defined functions. One set of UDFs permits the server's list of version tokens to be manipulated and inspected. Another set of UDFs permits version tokens to be locked and unlocked. The VERSION_TOKEN_ADMIN or SUPER privilege is required to invoke any Version Tokens UDF.

The following UDFs permit the server's list of version tokens to be created, changed, removed, and inspected. Interpretation of name_list and token_list arguments (including whitespace handling) occurs as described in Section 5.6.6.3, “Using Version Tokens”, which provides details about the syntax for specifying tokens, as well as additional examples.

  • version_tokens_delete(name_list)

    Deletes tokens from the server's list of version tokens using the name_list argument and returns a binary string that indicates the outcome of the operation. name_list is a semicolon-separated list of version token names to delete.

    1. mysql> SELECT version_tokens_delete('tok1;tok3');
    2. +------------------------------------+
    3. | version_tokens_delete('tok1;tok3') |
    4. +------------------------------------+
    5. | 2 version tokens deleted.          |
    6. +------------------------------------+

    An argument of NULL is treated as an empty string, which has no effect on the token list.

    version_tokens_delete() deletes the tokens named in its argument, if they exist. (It is not an error to delete nonexisting tokens.) To clear the token list entirely without knowing which tokens are in the list, pass NULL or a string containing no tokens to version_tokens_set():

    1. mysql> SELECT version_tokens_set(NULL);
    2. +------------------------------+
    3. | version_tokens_set(NULL)     |
    4. +------------------------------+
    5. | Version tokens list cleared. |
    6. +------------------------------+
    7. mysql> SELECT version_tokens_set('');
    8. +------------------------------+
    9. | version_tokens_set('')       |
    10. +------------------------------+
    11. | Version tokens list cleared. |
    12. +------------------------------+
  • version_tokens_edit(token_list)

    Modifies the server's list of version tokens using the token_list argument and returns a binary string that indicates the outcome of the operation. token_list is a semicolon-separated list of name=value pairs specifying the name of each token to be defined and its value. If a token exists, its value is updated with the given value. If a token does not exist, it is created with the given value. If the argument is NULL or a string containing no tokens, the token list remains unchanged.

    1. mysql> SELECT version_tokens_set('tok1=value1;tok2=value2');
    2. +-----------------------------------------------+
    3. | version_tokens_set('tok1=value1;tok2=value2') |
    4. +-----------------------------------------------+
    5. | 2 version tokens set.                         |
    6. +-----------------------------------------------+
    7. mysql> SELECT version_tokens_edit('tok2=new_value2;tok3=new_value3');
    8. +--------------------------------------------------------+
    9. | version_tokens_edit('tok2=new_value2;tok3=new_value3') |
    10. +--------------------------------------------------------+
    11. | 2 version tokens updated.                              |
    12. +--------------------------------------------------------+
  • version_tokens_set(token_list)

    Replaces the server's list of version tokens with the tokens defined in the token_list argument and returns a binary string that indicates the outcome of the operation. token_list is a semicolon-separated list of name=value pairs specifying the name of each token to be defined and its value. If the argument is NULL or a string containing no tokens, the token list is cleared.

    1. mysql> SELECT version_tokens_set('tok1=value1;tok2=value2');
    2. +-----------------------------------------------+
    3. | version_tokens_set('tok1=value1;tok2=value2') |
    4. +-----------------------------------------------+
    5. | 2 version tokens set.                         |
    6. +-----------------------------------------------+
  • version_tokens_show()

    Returns the server's list of version tokens as a binary string containing a semicolon-separated list of name=value pairs.

    1. mysql> SELECT version_tokens_show();
    2. +--------------------------+
    3. | version_tokens_show()    |
    4. +--------------------------+
    5. | tok2=value2;tok1=value1; |
    6. +--------------------------+

The following UDFs permit version tokens to be locked and unlocked:

  • version_tokens_lock_exclusive(token_name[, token_name] ..., timeout)

    Acquires exclusive locks on one or more version tokens, specified by name as strings, timing out with an error if the locks are not acquired within the given timeout value.

    1. mysql> SELECT version_tokens_lock_exclusive('lock1', 'lock2', 10);
    2. +-----------------------------------------------------+
    3. | version_tokens_lock_exclusive('lock1', 'lock2', 10) |
    4. +-----------------------------------------------------+
    5. |                                                   1 |
    6. +-----------------------------------------------------+
  • version_tokens_lock_shared(token_name[, token_name] ..., timeout)

    Acquires shared locks on one or more version tokens, specified by name as strings, timing out with an error if the locks are not acquired within the given timeout value.

    1. mysql> SELECT version_tokens_lock_shared('lock1', 'lock2', 10);
    2. +--------------------------------------------------+
    3. | version_tokens_lock_shared('lock1', 'lock2', 10) |
    4. +--------------------------------------------------+
    5. |                                                1 |
    6. +--------------------------------------------------+
  • version_tokens_unlock()

    Releases all locks that were acquired within the current session using version_tokens_lock_exclusive() and version_tokens_lock_shared().

    1. mysql> SELECT version_tokens_unlock();
    2. +-------------------------+
    3. | version_tokens_unlock() |
    4. +-------------------------+
    5. |                       1 |
    6. +-------------------------+

The locking functions share these characteristics:

  • The return value is nonzero for success. Otherwise, an error occurs.

  • Token names are strings.

  • In contrast to argument handling for the UDFs that manipulate the server token list, whitespace surrounding token name arguments is not ignored and = and ; characters are permitted.

  • It is possible to lock nonexisting token names. This does not create the tokens.

  • Timeout values are nonnegative integers representing the time in seconds to wait to acquire locks before timing out with an error. If the timeout is 0, there is no waiting and the function produces an error if locks cannot be acquired immediately.

  • Version Tokens locking functions are based on the locking service described at Section 29.3.1, “The Locking Service”.

Inhoudsopgave Haut

Version Tokens System Variables

Version Tokens supports the following system variables. These variables are unavailable unless the Version Tokens plugin is installed (see Section 5.6.6.2, “Installing or Uninstalling Version Tokens”).

System variables:

  • version_tokens_session

    Property Value
    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 the version_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 the version_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 the version_tokens_session value.

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

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

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

    1. mysql> SET @@SESSION.version_tokens_session = 'tok1=a;tok2=b';
    2. mysql> SELECT 1;
    3. +---+
    4. | 1 |
    5. +---+
    6. | 1 |
    7. +---+
    8.  
    9. mysql> SET @@SESSION.version_tokens_session = 'tok1=b';
    10. mysql> SELECT 1;
    11. ERROR 3136 (42000): Version token mismatch for tok1. Correct value a

    The first SELECT succeeds because the client tokens tok1 and tok2 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:

    1. mysql> SELECT version_tokens_edit('tok1=b');
    2. +-------------------------------+
    3. | version_tokens_edit('tok1=b') |
    4. +-------------------------------+
    5. | 1 version tokens updated.     |
    6. +-------------------------------+
    7. mysql> SELECT version_tokens_show();
    8. +-----------------------+
    9. | version_tokens_show() |
    10. +-----------------------+
    11. | tok3=c;tok1=b;tok2=b; |
    12. +-----------------------+

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

    1. mysql> SELECT 1;
    2. +---+
    3. | 1 |
    4. +---+
    5. | 1 |
    6. +---+
  • version_tokens_session_number

    Property Value
    Command-Line Format --version-tokens-session-number=#
    System Variable version_tokens_session_number
    Scope Global, Session
    Dynamic No
    SET_VAR Hint Applies No
    Type Integer
    Default Value 0

    This variable is for internal use.


Zoek in de MySQL-handleiding

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-version-tokens-reference.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut