SQL/PSM (MySQL 9.7)

This assessment applies the coupling account — coupling as access to a shared resource, and the coupling floor [1], [2] — and the knowledge-embodiment theorem [3]; the language is assessed against its official reference [4], [5].

Snapshot SQL/PSM (MySQL 9.7 LTS) — released 21 April 2026 · lifecycle current

Family SQL/PSM — shelf: Data and Science

The language’s primary object is a dataset or a numeric array, not a program loop. A shelf groups; it does not classify — the tags below carry every use, paradigm, and platform of this snapshot.

Trajectory SQL/PSM in the SQL standard (1996 — Persistent Stored Modules enters the standard as the procedural layer) · MySQL 5.0 stored programs (October 2005 — procedures, functions, triggers, and events reach MySQL) · MySQL 9.7 LTS (21 April 2026 — assessed release: the newest long-term-support line of the MySQL 9.x series)

Tags

Use — Data and statistics, Query

Paradigm — Imperative, Procedural, Declarative

Lifecycle — Current

Memory — Runtime-managed

Typing — Static, strong

Resources

The language’s official entry points, and the documents that name the release this page assesses. A link marked this release pins the document to SQL/PSM (MySQL 9.7 LTS); an unmarked link is the current reference for the language.

Landing page

Specification and reference

1 Assessment

This page assesses SQL/PSM stored programs (MySQL 9.7 LTS) in five parts: core coupling — what the language’s own constructs force; ecosystem coupling — what the surrounding platform, tooling, and community cost; engineering readiness — whether the artifact can be reproduced, verified, observed, worked in quickly, connected to other languages, and governed openly; the profile — the unscored facts a score cannot express; and the scoring detail — the mechanism marks and the arithmetic behind every score. A ✅ bullet marks a construct that helps. A ⚠️ or ❌ bullet marks a cost; the scoring model does not price every cost named here.

Core coupling 78.9/100 · Ecosystem coupling 86.3/100 · Engineering readiness 45.6/100

1.1 Core coupling

1.1.1 Type

  • ❌ NULL is a member of every domain: a routine parameter, local, or OUT value carries NULL without a declaration, three-valued logic decides every comparison, and no signature states whether NULL is legal (T10)
  • ⚠️ No sum types: an alternative is modeled by nullable OUT parameters, a status column, or separate routines, and the caller learns the encoding by reading the body
  • ⚠️ No generic parameter: routines are typed per definition, and a routine over “any table” must take dynamic SQL or return one fixed shape
  • ❌ Statements state no effect: a stored function that writes a table, calls a trigger, or reads the clock looks like any other in the catalog — only the DETERMINISTIC/NOT DETERMINISTIC declaration, which the docs state is trusted for replication rather than verified, says anything (T12)
  • ❌ C code rides the boundary: the server loads native plugins and UDFs through its plugin interface, and the declaration the two sides agree on is checked by neither compiler (T14)

1.1.2 Construction

  • ✅ The routine is one block: BEGIN … END gathers DECLARE, flow, and SQL into one deployable unit the catalog stores and parses
  • ⚠️ Tables mutate in place: the routine body is ordinary DML, and every UPDATE is an in-place mutation with no immutability construct anywhere in the language

1.1.3 Memory

  • ✅ Allocation is the server’s: buffers, sort areas, and cursors live in mysqld, and the routine text allocates nothing

1.1.4 Error

  • ❌ The handler decides, or the statement dies: DECLARE … HANDLER FOR SQLEXCEPTION routes a failure, and without a handler the routine aborts with an error to the caller — no value ever carries the failure (Er3)
  • ❌ No composable result type: failures travel by exception or error code, results by OUT parameters and SELECT result sets, and neither can thread through an expression (Er4)

1.1.5 Concurrency

  • ❌ One session, one shared state: user variables, temporary tables, and session settings are visible across every routine the session calls, so two callers of the same routine share what it reads (K2)

1.1.6 Platform

  • ❌ The routine runs only in MySQL-family servers: CALL speaks the server’s protocol, the body compiles in the server’s parser, and nothing in the language runs without mysqld (P1)
  • ❌ A poor fit outside set work: the language has no data abstraction beyond tables, no libraries, and no error values, so application logic pays for every abstraction it builds (P4)

1.1.7 Trade-offs (not coupling)

  • Logic next to the data: routines remove the network round trip per statement and run inside the server’s transactions, and the price is application logic whose deploy, debug, and version story is the database’s
  • Handlers are optional by design: BEGIN … END with DECLARE … HANDLER gives structured recovery, and the price is that a routine without one fails at the first unhandled error, discovered by the caller
  • Session state is the shared resource: user variables and temporary tables make cross-routine state cheap, and the price is that every caller of a routine shares whatever the session already holds
  • The definer is a privilege decision: SQL SECURITY DEFINER lets one routine guard a table behind its owner’s rights, and the price is a trust edge the signature carries silently

1.2 Ecosystem coupling

1.2.1 Performance

  • ✅ The plan is inspectable: EXPLAIN answers for the statements inside a routine through the ordinary session tools, and the optimizer answers per statement

1.2.2 Ecosystem

  • ✅ The installed base is one of the largest: drivers, ORMs, admin tooling, and managed offerings surround the server, and the community forums and docs answer the common questions

1.2.3 Evolution

  • ⚠️ The LTS calendar governs the surface: 9.7 is the newest long-term-support line, the release model states that features change only in the first release of an LTS line, and maintenance arrives quarterly

1.2.4 Domain

  • ❌ The routine exists to serve the database: the catalog, the privilege model, and the trigger/event system define what a stored program is, and moving the logic moves the engine (D1)

1.2.5 Learning

  • ❌ SQL-92 roots with procedural grafts: the docs interleave ISO statements with MySQL-specific variables, handlers, and delimiters, and the traps (implicit commits, cursor scoping) get their own chapters

1.2.6 Syntax

  • ❌ The tool changes the text: DELIMITER is a client-side convention the server never sees, one of several places where the program’s meaning depends on which tool reads it
  • ⚠️ Case rules differ per layer: table and column case follows the file system on some platforms while routine names follow the server, and the docs devote a page to identifier case sensitivity

1.2.7 Testing

  • ❌ No standard test harness for user routines: mysqltest serves the server’s own suite, and the documented testing story for stored programs is application-side tests against a live server (G1)

1.2.8 Security

  • ❌ Dynamic SQL is string-built: PREPARE and EXECUTE run SQL text held in a variable, so concatenated user input reaches the parser, and the documented mitigation is SQL-level privileges plus bound parameters (Q3)
  • ⚠️ SQL SECURITY DEFINER runs as its owner: a definer routine executes with the owner’s privileges, so the catalog records a trust decision the body never states

1.2.9 Delivery targets

What ships from a producer to a consumer, and whether the interface across a release boundary is promised. Ec8 is present when one compiled target crosses with no promise.

Target Ships as Crosses a producer boundary Cross-release promise
stored program source (procedures, functions, triggers, events) script no the database stores the source text and parses it at creation and use; no compiled unit crosses a boundary

1.3 Engineering readiness

1.3.1 Reproducibility

  • ✅ A routine is stored source: the same body on the same server version and data reproduces the same result, and nothing is compiled ahead of the call
  • ❌ No toolchain pin exists: the repository names no server version — the executing release is a deployment fact a third-party manager must supply (Y14)

1.3.2 Supply chain

  • ❌ No signed provenance for published routines or plugins: routines move as SQL dumps the server executes, and plugins install from distribution channels without signature checks (Y3)
  • ❌ No advisory feed names stored-program issues: fixes land in quarterly LTS release notes, and no published advisory database tracks the language surface the way Apache and CNCF projects publish theirs (Y16)

1.3.3 Observability

  • ❌ No tracing standard is part of the language: the performance_schema and the general log are server features, and the routine text carries no trace hook (Y5)
  • ❌ No structured logging in the language: SIGNAL text and the server log are all a routine can emit, and no logging construct exists in the language (Y6)

1.3.4 Feedback

  • ❌ No routine debugger ships with the server: diagnosis goes through SELECT scaffolding, handler instrumentation, and the error message (Y13)

1.3.5 Interop

  • ❌ No portable target: the body compiles in one server family’s parser, and SQL/PSM conformance is a manual claim no suite checks (Y10)

1.3.6 Governance

  • ❌ Governance is Oracle: the release model, the LTS calendar, and the language’s direction are one company’s, and no independent body can change them (Y11)
  • ❌ No public specification exists: the reference manual documents the implemented behavior of one server line, and no independent implementation follows from a published standard document (Y12)
  • ❌ Correctness is what mysqld does: no conformance suite exists for the stored-program language, and a second implementation would be a compatibility gamble (Y17)

1.4 Profile

Unscored, and kept separate from every score on purpose. The profile records what a mechanism price cannot express: what a running program costs, how well a coding model and an agent work in the language, and whether a safety-critical path exists.

1.4.1 Energy and cost

What this axis asks: what does a running program cost in energy and time?

  • ⚠️ Energy is mysqld’s: buffer pool, sort areas, and the event scheduler pay, and the reader’s levers are index and statement design the routine text exposes but does not control.

1.4.2 AI and agent readiness

What this axis asks: how well does a coding model and an agent work in this language?

  • ⚠️ Generated stored programs are common in migrations and admin tooling, and the traps are exactly the procedural layer: handler scope, implicit commits, definer rights, and cursor state that no generated snippet names.

1.4.3 Safety certification

What this axis asks: is there a certified or standards-qualified path to a safety-critical system?

  • ⚠️ No certified path; InnoDB’s ACID guarantees and the privilege model are the server’s, stated in its own documentation.

1.5 Scoring detail

1.5.1 Core coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Type T1 dynamic no static check language — 0
T2 weak static language — 0
T3 dynamic/duck dispatch language — 0
T4 no sum types language — 0
T5 no generics language — 0
T6 no namespaces language — 0
T7 type erasure/reflection language — 0
T8 operator overloading language — 0
T9 inheritance required for polymorphism language — 0
T10 no null-safety language ✅ −8
T11 no module boundary language — 0
T12 no effect tracking language ✅ −8
T13 async/sync colouring language — 0
T14 unchecked foreign boundary language ✅ −4
T15 chars are encoding units language — 0
Type cost −5.7 (−20)
Construction C1 global mutable state by default language ✅ −15
C2 no immutability by default language — 0
C3 constructors coupled to allocation language — 0
C4 no constructor/validation language — 0
C5 unpinned collection order language — 0
C6 aliasing by default language — 0
C7 undeclared control transfer language — 0
C8 no source-visible init order language — 0
Construction cost −4.3 (−15)
Memory M1 manual deallocation runtime — 0
M2 GC non-deterministic pauses runtime — 0
M3 no RAII language — 0
M4 no ownership model language — 0
M5 uninitialized reads language — 0
M6 unchecked reinterpretation language — 0
Er6 uncatchable runtime fault language — 0
M7 reference cycles leak runtime — 0
Memory cost 0
Error Er1 no structured path language — 0
Er2 unchecked exceptions only language — 0
Er3 errors ignored/non-exhaustive language ✅ −4
Er4 no composable result type language ✅ −4
Er5 no isolation unit for a fault runtime — 0
Error cost −2.3 (−8)
Concurrency K1 GIL/no parallel runtime — 0
K2 shared mutable state default language ✅ −8
K3 manual sync no race detection runtime — 0
K4 no structured concurrency language — 0
K5 no primitives language — 0
K6 thread-per-task cost runtime — 0
Concurrency cost −2.3 (−8)
Platform P1 cannot function outside one vendor/domain context ✅ −15
P2 single-vendor but other uses context — 0
P3 legacy/discontinued platform context — 0
P4 poor domain fit context ✅ −8
Platform cost −6.6 (−23)

Core coupling score: 78.9/100 — 74 of the 350 inventory points are present, so the axis cost is 100 × 74 ÷ 350 = 21.1 and the score is 100 − 21.1. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.2 Ecosystem coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Performance R1 interpreted no AOT/JIT runtime — 0
R2 GC pauses runtime — 0
R3 JIT warmup runtime — 0
Performance cost 0
Ecosystem Ec1 no package manager context — 0
Ec2 fragmented tooling context — 0
Ec3 small/niche/discontinued context — 0
Ec4 proprietary context — 0
Ec5 platform-locked tooling context — 0
Ec6 monoculture context — 0
Ec7 legacy burden context — 0
Ec8 unpromised binary boundary context — 0
Ec9 unpromised data boundary context — 0
Ecosystem cost 0
Evolution V1 breaking changes language — 0
V2 frozen context — 0
V3 discontinued context — 0
V4 glacial standards context — 0
V5 silent default drift runtime — 0
V7 build-variant state space context — 0
Evolution cost 0
Domain D1 domain/vendor lock-in context ✅ −15
D3 framework forces architecture context — 0
Domain cost −5.9 (−15)
Learning L1 steep context — 0
L2 large surface/multi-paradigm context — 0
L3 sparse docs context — 0
Learning cost 0
Syntax S1 verbose language — 0
S2 inconsistent language — 0
S3 punctuation-heavy language — 0
Syntax cost 0
Testing G1 weak tooling context ✅ −8
G2 poor debugging context — 0
G3 runtime-only errors context — 0
G4 no published monotonic clock runtime ✅ −4
Testing cost −4.7 (−12)
Security Q1 memory-unsafe language — 0
Q2 dynamic/weak typing risk language — 0
Q3 known vulnerability/injection context ✅ −8
Q4 silent integer overflow language — 0
Security cost −3.1 (−8)

Ecosystem coupling score: 86.3/100 — 35 of the 256 inventory points are present, so the axis cost is 100 × 35 ÷ 256 = 13.7 and the score is 100 − 13.7. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.3 Engineering readiness Dimensions

Dimension Mechanism Description Imposed by Present Weight
Reproducibility Y1 build not reproducible context — 0
Y2 dependencies not pinned context — 0
Y14 no toolchain version pin context ✅ −8
Y18 no machine-read project contract context — 0
Reproducibility cost −4.7 (−8)
Supply chain Y3 no signed provenance context ✅ −15
Y4 registry without namespacing context — 0
Y16 no advisory feed context ✅ −8
Supply chain cost −13.5 (−23)
Observability Y5 no stable tracing standard context ✅ −8
Y6 no structured logging context ✅ −4
Y15 no post-mortem diagnostics runtime — 0
Observability cost −7.0 (−12)
Feedback Y7 slow build context — 0
Y8 no fast in-editor analysis context — 0
Y13 no bundled debugger context ✅ −8
Feedback cost −4.7 (−8)
Interop Y9 no foreign-function interface language — 0
Y10 no portable target context ✅ −4
Interop cost −2.3 (−4)
Governance Y11 single-vendor governance context ✅ −15
Y12 closed specification context ✅ −15
Y17 no conformance mechanism context ✅ −8
Y19 no published parser context — 0
Governance cost −22.2 (−38)

Engineering readiness score: 45.6/100 — 93 of the 171 inventory points are present, so the axis cost is 100 × 93 ÷ 171 = 54.4 and the score is 100 − 54.4. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

Verdict: MySQL’s stored-program language is SQL/PSM-shaped procedural SQL: BEGIN … END blocks over DECLARE, cursors, handlers, SIGNAL and dynamic PREPARE, deployed as procedures, functions, triggers, and events inside the server catalog. Its costs are the server family’s own: NULL in every domain with no null-safety, failures that travel only by exception or error code, session-wide user variables and temporary tables as the default shared state, and single-vendor governance with no specification and no conformance suite. Main strengths: one deployable block per program, structured handler-based recovery, EXPLAIN through the ordinary session tools, GPL-public source, and a release model (9.7 LTS, quarterly maintenance) the docs state plainly. Main weaknesses: no debugger or user-routine test harness, no structured logging or tracing in the language, string-built dynamic SQL as the standing injection surface, and logic whose reproducibility depends on a server version no repository file names.


The formal development. The definitions, theorems, and proofs behind this page are published in:

All published papers

References

[1]
Y. Loth, “On the nature of coupling: All coupling as shared resource access.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925121.
[2]
Y. Loth, “Coupling as a consequence of cohesion: Decomposition, the coupling floor, and domain-imposed coupling.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925201.
[3]
Y. Loth, “On the nature of cohesion: Cohesion as correctness relative to a partitioning rule.” Zenodo, Jul. 2026. doi: 10.5281/zenodo.20492912.
[4]
Oracle Corporation, “MySQL 9.7 reference manual: Stored programs and views.” https://dev.mysql.com/doc/refman/9.7/en/stored-programs-views.html, 2026.
[5]
Oracle Corporation, “Changes in MySQL 9.7.0 (2026-04-21).” https://dev.mysql.com/doc/relnotes/mysql/9.7/en/news-9-7-0.html, 2026.