Views, routines, triggers, events; server variables and status
In the Databases window
Section titled “In the Databases window”| Node | What it opens |
|---|---|
| Server variables (under a connection) | Tab Variables: <connection>. |
| Server status (under a connection) | Tab Status: <connection>. |
| Views (in the table list) | Double-click: rows. Context menu Edit definition: the object tab. |
| Procedures, functions | Double-click or Edit definition: the object tab. |
| Triggers, events (MySQL, MariaDB) | Listed after the routines, from information_schema.TRIGGERS and information_schema.EVENTS; double-click opens the object tab. |
| New → View… / Procedure… / Function… / Trigger… / Event… (database context menu) | The object tab with a template. |
PostgreSQL: views, materialized views, functions and procedures open read-only (pg_get_viewdef,
pg_get_functiondef); triggers are in the table’s Structure. Changes on PostgreSQL are not
available yet.
The object tab
Section titled “The object tab”The definition is read with SHOW CREATE VIEW | PROCEDURE | FUNCTION | TRIGGER | EVENT and the
DEFINER from information_schema. The editor holds the part after the object’s name:
| Kind | Edited text starts with |
|---|---|
| View | AS SELECT … (or a column list in parentheses) |
| Procedure, function | The parameter list: (IN p INT) … BEGIN … END; RETURNS, DETERMINISTIC, SQL SECURITY, COMMENT are written in the text |
| Trigger | BEFORE / AFTER … ON <table> FOR EACH ROW … |
| Event | ON SCHEDULE … … DO … |
Fields above the editor: DEFINER (CURRENT_USER or an account from mysql.user; the list is
empty without SELECT on mysql.user, the current definer is always offered), for views SQL
SECURITY and ALGORITHM. The line under them shows the SHOW CREATE sent, the stored
sql_mode, time_zone (events), character_set_client / collation_connection, the database
collation, and how the change is sent. The full head that KryoDesk writes is shown above the text.
Apply… (⌘S) needs a saved session with Allow write (as structure changes); the review
dialog shows every statement and the session statements around them. Drop… sends
DROP <KIND> db.name after the same review.
| Server | Change sent as |
|---|---|
| MariaDB | CREATE OR REPLACE … for every kind, one statement. |
| MySQL | Views: CREATE OR REPLACE VIEW. Procedures, functions, triggers, events: DROP … then CREATE …. Two statements, not atomic: if CREATE fails, the object is gone and its previous definition stays in the tab to copy. |
Rules:
- One statement. On MariaDB every change, and on MySQL views and
GRANT, go as prepared statements (the console showssql (change, prepared statement)>): the server parses one statement and refuses a second with a syntax error. MySQL does not prepareCREATE/DROPof procedures, functions, triggers and events (error 1295), so those go as text and KryoDesk checks them first, under thesql_modethe statement runs with: quotes and comments closed; executable comments/*! … */and/*M! … */, optimizer hints/*+ … */, control characters, words starting with$($$,$tag$), a body afterASandLANGUAGEother thanSQLrefused; outside quotes non-ASCII spaces and invisible characters (zero-width, bidi) refused.;only inside a block (BEGIN … END,IF … END IF,CASE … END CASE, loops); the body may be one such statement without an outerBEGIN; after its end only its label.BEGINopens a block only where a statement starts (body start, after;, a label,THEN,ELSE,DO,LOOP,REPEAT,DECLARE … HANDLER FOR …);BEGIN,END,CASE,IFand the other block words anywhere else (a column, an alias,t.end) must be in backticks. Outside quotes only ASCII is accepted (names with other letters go in backticks), no\, and numbers are plain (1e0ENDis refused).END REPEAT,END IFand the like right after aCASE … ENDexpression are refused: put the expression in parentheses. A prepared statement with:nameoutside quotes is refused: the driver would send?there. There is noDELIMITER: a trailing;is dropped. If the server still answers with a second result, the change stops with the server ran more than one statement and the connection is closed. sql_modestored with a routine, trigger or event, and thetime_zoneof an event, are set in the session for the statement (SET SESSION sql_mode = …) and set back afterwards.character_set_clientstaysutf8mb4; acollation_connectionother than utf8mb4 is recorded as utf8mb4 (warning in the review).- Grants on a procedure or function are read from
mysql.procs_privand listed in the review: dropping a routine removes them whenautomatic_sp_privilegesisON(MySQLDROP+CREATE, MariaDBCREATE OR REPLACE). Grant again (on by default) addsGRANT EXECUTE, ALTER ROUTINE ON PROCEDURE|FUNCTION … TO …after theCREATE. - A trigger created again goes after the other triggers of the same table, timing and event; add
FOLLOWS/PRECEDESin the text to keep its place. - The definition read when the tab opened must still be on the server when you prepare and when you send; otherwise the definition of … changed on the server.
- New objects use plain
CREATE(an existing name is refused by the server) with the session’ssql_mode. - Behind ProxySQL session variables are not set: a change that needs another
sql_mode,time_zoneor collation is refused; use a direct session.
Server variables
Section titled “Server variables”| Column | MySQL / MariaDB | PostgreSQL |
|---|---|---|
| Global / Reset value | SHOW GLOBAL VARIABLES |
pg_settings.reset_val |
| Session / Current | SHOW SESSION VARIABLES (orange when it differs from the global value) |
pg_settings.setting |
| Type | MariaDB information_schema.SYSTEM_VARIABLES (type, range, values); MySQL 8 numeric range from performance_schema.variables_info |
vartype, min_val, max_val, enumvals |
| Scope / Context | MariaDB VARIABLE_SCOPE |
context (postmaster = restart) |
| Dynamic | MariaDB: not READ_ONLY; MySQL: ? |
not postmaster / internal |
| Source | MariaDB GLOBAL_VALUE_ORIGIN; MySQL 8 VARIABLE_SOURCE, file, time and account of the last change (tooltip), persisted from performance_schema.persisted_variables |
source, file and line, pending_restart |
| Default | MariaDB DEFAULT_VALUE |
boot_val |
The filter matches names and descriptions; Differs from default keeps changed ones. Copy gives TSV.
The pencil (sessions with Allow write, not behind ProxySQL) opens the change:
| Statement | Server | Effect |
|---|---|---|
SET GLOBAL name = value |
all | Until restart; open sessions keep their session value. On MariaDB and MySQL 5.7 write the value to the configuration file to keep it. |
SET PERSIST name = value |
MySQL 8.0+ | Now and in mysqld-auto.cnf |
SET PERSIST_ONLY name = value |
MySQL 8.0+ | Only mysqld-auto.cnf (read-only variables) |
RESET PERSIST IF EXISTS name |
MySQL 8.0+ | Removed from mysqld-auto.cnf |
Variables holding secrets (names with password, pwd, secret, ending in _auth or key)
show *** in the table, the review, the console and the result; the server gets the typed value.
The value is checked against the type: ON/OFF, a whole number within the range, a number, one of
the listed values, or text sent as a string literal; DEFAULT sends = DEFAULT. A variable
marked read-only at run time takes only SET PERSIST_ONLY. The global value read when you
prepare must still be the same when you send. Production sessions need the confirmation checkbox.
Behind ProxySQL SET GLOBAL is refused: it would reach one backend chosen by the query rules (or
ProxySQL itself). Change backends over direct sessions; ProxySQL’s own variables are on its admin
port (6032).
PostgreSQL: read-only (ALTER SYSTEM and pg_reload_conf() are not available yet).
Server status
Section titled “Server status”Refresh reads SHOW GLOBAL STATUS (PostgreSQL: pg_stat_database of the connected database,
pg_stat_bgwriter, pg_stat_archiver, connections per state from pg_stat_activity,
pg_stat_wal from 14, pg_stat_checkpointer from 17, as view.column). Nothing is read in the
background. After the second read, Per second shows (new − old) / seconds between the answers for numeric values; Changed since the last read keeps only those.