1238
MariaDBERRORCriticalSyntax / VariablesHIGH confidence
SESSION variable cannot be used with SET GLOBAL
Production Risk
Low — SET fails; current configuration unchanged.
What this means
ER_INCORRECT_GLOBAL_LOCAL_VAR (1238, SQLSTATE HY000) is raised when a variable that is session-scoped only is used with SET GLOBAL, or a global-only variable is used with SET SESSION.
Why it happens
- 1Using SET GLOBAL on a session-only variable like sql_log_bin
- 2Using SET SESSION on a global-only variable
How to reproduce
trigger — this will error
trigger — this will error
SET GLOBAL sql_log_bin = 0; -- sql_log_bin is session-only, not global
expected output
ERROR 1238 (HY000): Variable 'sql_log_bin' is a SESSION variable and can't be used with SET GLOBAL
Fix
Use the correct scope for the variable
Use the correct scope for the variable
SET SESSION sql_log_bin = 0; -- correct scope
Why this works
Use SESSION for session-scoped variables and GLOBAL for global variables.
Sources
Official documentation ↗
MySQL 8.0 — 1238 ER_INCORRECT_GLOBAL_LOCAL_VAR
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev