No cache version.

Caching disabled. Default setting for this page:enabled (code DEF204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher dans le manuel MySQL

27.4.5.19 The sys_get_config() Function

Given a configuration option name, returns the option value from the sys_config table, or the provided default value (which may be NULL) if the option does not exist in the table.

If sys_get_config() returns the default value and that value is NULL, it is expected that the caller is able to handle NULL for the given configuration option.

By convention, routines that call sys_get_config() first check whether the corresponding user-defined variable exists and is non-NULL. If so, the routine uses the variable value without reading the sys_config table. If the variable does not exist or is NULL, the routine reads the option value from the table and sets the user-defined variable to that value. For more information about the relationship between configuration options and their corresponding user-defined variables, see Section 27.4.2.1, “The sys_config Table”.

If you want to check whether the configuration option has already been set and, if not, use the return value of sys_get_config(), you can use IFNULL(...) (see example later). However, this should not be done inside a loop (for example, for each row in a result set) because for repeated calls where the assignment is needed only in the first iteration, using IFNULL(...) is expected to be significantly slower than using an IF (...) THEN ... END IF; block (see example later).

Parameters
  • in_variable_name VARCHAR(128): The name of the configuration option for which to return the value.

  • in_default_value VARCHAR(128): The default value to return if the configuration option is not found in the sys_config table.

Contents Haut

Return Value

A VARCHAR(128) value.

Contents Haut

Example

Get a configuration value from the sys_config table, falling back to 128 as the default if the option is not present in the table:

  1. mysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;
  2. +-------+
  3. | Value |
  4. +-------+
  5. | 64    |
  6. +-------+

One-liner example: Check whether the option is already set; if not, assign the IFNULL(...) result (using the value from the sys_config table):

  1. mysql> SET @sys.statement_truncate_len =
  2.        IFNULL(@sys.statement_truncate_len,
  3.               sys.sys_get_config('statement_truncate_len', 64));

IF (...) THEN ... END IF; block example: Check whether the option is already set; if not, assign the value from the sys_config table:

  1. IF (@sys.statement_truncate_len IS NULL) THEN
  2.   SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len', 64);

Find a PHP function

Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-sys-sys-get-config.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:en Manuel MySQL : https://dev.mysql.com/

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut