# Session state and variable helpers

> Internal interfaces behind SET, SHOW, user variables and authentication cache management.

---

LLMS index: [llms.txt](/llms.txt)

---

Internal interfaces behind SET, SHOW, user variables and authentication cache management.

## C {#c}

| Signature | Purpose | Source definition |
|---|---|---|
| <a id="mysql-clear-user-variables-1c03d9c1" href="#mysql-clear-user-variables-1c03d9c1">`mysql.clear_user_variables() → void`</a> | Clear the session’s user variables. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/46-func-sess.sql#L95-L98) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/user_var.c#L220-L225) |

## F {#f}

| Signature | Purpose | Source definition |
|---|---|---|
| <a id="mysql-flush-auth-cache-fdbe3272" href="#mysql-flush-auth-cache-fdbe3272">`mysql.flush_auth_cache() → bigint`</a> | Clear the fast-authentication cache. EXECUTE is restricted. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/46-func-sess.sql#L136-L138) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mys_auth.c#L271-L295) |

## G {#g}

| Signature | Purpose | Source definition |
|---|---|---|
| <a id="mysql-get-system-global-variable-pg-catalog-text-a1f5ae1b" href="#mysql-get-system-global-variable-pg-catalog-text-a1f5ae1b">`mysql.get_system_global_variable(text) → text`</a> | Read a global @@ variable. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L80-L96) |
| <a id="mysql-get-system-session-variable-pg-catalog-text-d95088ea" href="#mysql-get-system-session-variable-pg-catalog-text-d95088ea">`mysql.get_system_session_variable(text) → text`</a> | Read a session @@ variable. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L62-L78) |
| <a id="mysql-get-system-variable-pg-catalog-text-boolean-9aa03aeb" href="#mysql-get-system-variable-pg-catalog-text-boolean-9aa03aeb">`mysql.get_system_variable(text, boolean) → text`</a> | Resolve a system variable for its requested scope. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L57-L60) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L136-L158) |
| <a id="mysql-get-user-var-character-varying-af3dceab" href="#mysql-get-user-var-character-varying-af3dceab">`mysql.get_user_var(variable_name character varying) → bytea`</a> | Read a MySQL @user variable. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/46-func-sess.sql#L90-L93) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/user_var.c#L288-L304) |
| <a id="mysql-getenv-pg-catalog-text-a4ebdb00" href="#mysql-getenv-pg-catalog-text-a4ebdb00">`mysql.getenv(text) → text`</a> | Read a server environment variable for installation. EXECUTE is restricted. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L99-L102) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L195-L222) |

## S {#s}

| Signature | Purpose | Source definition |
|---|---|---|
| <a id="mysql-set-system-charset-variable-pg-catalog-text-0b06833e" href="#mysql-set-system-charset-variable-pg-catalog-text-0b06833e">`mysql.set_system_charset_variable(text) → void`</a> | Apply SET CHARACTER SET to the current connection. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L123-L124) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L103-L110) |
| <a id="mysql-set-system-global-variable-pg-catalog-text-pg-catalog-anycompatible-5cb7a810" href="#mysql-set-system-global-variable-pg-catalog-text-pg-catalog-anycompatible-5cb7a810">`mysql.set_system_global_variable(text, anycompatible) → void`</a> | Set the global value of a system variable. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L34-L55) |
| <a id="mysql-set-system-names-variable-pg-catalog-text-e546b0fa" href="#mysql-set-system-names-variable-pg-catalog-text-e546b0fa">`mysql.set_system_names_variable(text) → void`</a> | Apply SET NAMES to the current connection. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L119-L120) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L93-L100) |
| <a id="mysql-set-system-names-variable-pg-catalog-text-pg-catalog-text-9337e5d1" href="#mysql-set-system-names-variable-pg-catalog-text-pg-catalog-text-9337e5d1">`mysql.set_system_names_variable(text, text) → void`</a> | Apply SET NAMES to the current connection. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L121-L122) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L93-L100) |
| <a id="mysql-set-system-session-variable-pg-catalog-text-pg-catalog-anycompatible-8d2c93c9" href="#mysql-set-system-session-variable-pg-catalog-text-pg-catalog-anycompatible-8d2c93c9">`mysql.set_system_session_variable(text, anycompatible) → void`</a> | Set the session value of a system variable. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L11-L32) |
| <a id="mysql-set-system-variable-pg-catalog-text-pg-catalog-text-boolean-2057642a" href="#mysql-set-system-variable-pg-catalog-text-pg-catalog-text-boolean-2057642a">`mysql.set_system_variable(text, text, boolean) → boolean`</a> | Assign a system variable in the selected scope. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L6-L9) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L113-L133) |
| <a id="mysql-set-user-var-character-varying-pg-catalog-anycompatible-2b918783" href="#mysql-set-user-var-character-varying-pg-catalog-anycompatible-2b918783">`mysql.set_user_var(variable_name character varying, variable_value anycompatible) → void`</a> | Store a MySQL @user variable for SET or expression evaluation. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/46-func-sess.sql#L78-L82) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/user_var.c#L186-L217) |
| <a id="mysql-set-user-var-in-expr-character-varying-pg-catalog-anycompatible-6f36b88a" href="#mysql-set-user-var-in-expr-character-varying-pg-catalog-anycompatible-6f36b88a">`mysql.set_user_var_in_expr(variable_name character varying, variable_value anycompatible) → bytea`</a> | Store a MySQL @user variable for SET or expression evaluation. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/46-func-sess.sql#L84-L88) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/user_var.c#L228-L285) |
| <a id="mysql-show-system-variable-pg-catalog-text-boolean-09bdf840" href="#mysql-show-system-variable-pg-catalog-text-boolean-09bdf840">`mysql.show_system_variable(text, boolean) → text`</a> | Resolve a system variable for its requested scope. | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/47-func-var.sql#L107-L109) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/systemVar.c#L165-L187) |

---

Backlinks:

- [Functions](/docs/mysql/reference/objects/functions/)
