SET GLOBAL

Sets an engine variable globally. SET GLOBAL behaves differently when used with sync variables and non-sync variables.

When SET GLOBAL is used with a sync variable, the variable must be updated on the master aggregator. Depending on the variable, the update is propagated to either the other aggregators or to all of the nodes in a cluster. If the updated nodes are restarted, the update persists.

SET GLOBAL may also be used to set two types of non-sync variables listed below.

  • Global: When you set a global variable, its value is effective for your current connection to the node and any subsequent connections, initiated by any user.

  • Session that can also be set globally: When you set this type of variable globally, its value is NOT effective for your current connection to the node but is effective for any subsequent connections to the node, initiated by any user.

Syntax

SET GLOBAL variable_name = value

SET @@GLOBAL.variable_name = value

Remarks

  • variable_name is the name of a global engine variable.
  • The @@global.variable_name syntax for engine variables is supported for compatibility with some other database systems. This is similar to MySQL behavior.
  • To apply engine variable changes across all nodes in the cluster, the SET GLOBAL command must be executed on each node individually. If you add more nodes to your cluster after setting a variable, you must also apply the same variable settings to each additional node.
  • See the engine variables overview for information about other ways to set variables.

Example 1

The following example sets a global variable and retrieves its value.

Set the variable:

SET GLOBAL connect_timeout = 15;

Retrieve its value:

SELECT @@connect_timeout;

Example 2

The following example displays the expected error that results when you try to set a sync variable on a node other than the master aggregator:

SET GLOBAL default_distributed_ddl_timeout = 15;

Output:

ERROR 1752 (HY000): This instance is not the master aggregator. SETTING SYNC SETTINGS
is not permitted on child aggregators and leaves.

Related Topics

Was this article useful?