Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
MySQL Query Span Omni Scenarios
Goal: Prove the omni MySQL query-span extractor preserves legacy MySQL query-span behavior without runtime fallback. Verification: each scenario must have an automated assertion against legacy-compatible query-span output, query type, access-table set, or error semantics. Reference sources: legacy ANTLR MySQL query-span extractor, legacy MySQL query type listener, current YAML query-span fixtures, omni MySQL AST node definitions, MySQL query-span migration plan.
Status: [ ] pending, [x] passing, [~] partial.
Phase 1: Statement Type And Root Selection
1.1 Select-Family Roots
- Plain
SELECTreturnsSelectand extracts target-list results. -
TABLE treturnsSelectand expands to the referenced table columns. -
VALUES ROW(...)returnsSelectand derives result columns from the first row. -
VALUES ROW(DEFAULT)returns a constantDEFAULTresult with empty source columns. -
SELECT ... INTOpreserves the legacy unsupported/error behavior. -
EXPLAIN SELECT ...returnsExplainwithout result columns. -
EXPLAIN ANALYZE SELECT ...returnsSelectand preserves select access tables. -
EXPLAIN ANALYZE TABLE treturnsSelectand preserves table access. -
EXPLAIN ANALYZE VALUES ROW(...)returnsSelectwithout result lineage extraction. -
EXPLAIN ANALYZE INSERT ...returnsDMLand no result columns. -
DESCRIBE ...returnsSelectInfoSchemalike legacy metadata reads. -
DESCfollowed by non-space whitespace returnsSelectInfoSchema. - Multiple statements in one query return the legacy single-statement error.
1.2 Query Type Buckets
-
SHOW ...returnsSelectInfoSchema. - non-password
SET ...returnsSelect. - password-changing
SET PASSWORD ...preserves legacy query type behavior. -
CREATE TABLE ...returnsDDL. -
CREATE DATABASE ...returnsDDL. -
CREATE VIEW ...returnsDDL. - user/role administration statements such as
CREATE USER,ALTER USER,DROP USER,GRANT, andREVOKEreturn non-select query types. -
ALTER TABLE ...returnsDDL. -
DROP TABLE ...returnsDDL. -
RENAME TABLE ...returnsDDL. -
TRUNCATE TABLE ...returnsDDL. -
IMPORT TABLE ...returnsDDL. -
INSERT ...returnsDML. -
REPLACE ...returnsDML. -
UPDATE ...returnsDML. -
DELETE ...returnsDML. -
LOAD DATA ...returnsDML. -
CALL ...returnsDML. -
DO ...returnsDML. -
HANDLER ... OPENreturnsDML. -
HANDLER ... READreturnsDML. -
HANDLER ... CLOSEreturnsDML. - transaction and locking statements return
DML. - replication statements return
DML. - prepared statements return
DML. - unhandled omni statement roots fail closed instead of falling through to
Select.
Phase 2: Target List And Expression Lineage
2.1 Target List Basics
- Literal target
SELECT 1returns a literal result with empty source columns. - Bare column target returns that column as a plain field.
- qualified column target resolves table and database qualifiers.
- target alias overrides expression-derived result name.
- unaliased expression uses the legacy expression text as result name.
-
SELECT * FROM texpands all source columns in table order. -
SELECT t.* FROM texpands only the qualified table columns. -
SELECT *, a FROM tpreserves star expansion plus explicit target. - duplicate output names preserve legacy ordering and duplicate result entries.
- reserved-word quoted identifiers resolve like legacy identifiers.
2.2 Expression Node Coverage
- binary arithmetic expression merges both operand source columns.
- binary comparison expression merges both operand source columns.
- JSON extraction binary operators merge object and path expression sources.
- unary expression preserves operand source columns and is not a plain field.
- function call merges argument source columns.
- aggregate function merges argument source columns.
- window function merges argument, partition, and order source columns.
- function separator expression contributes lineage where applicable.
- function-level
ORDER BYexpressions contribute lineage where applicable. - scalar subquery result merges selected result source columns.
-
EXISTS (SELECT ...)returns subquery result lineage and is not a plain field. -
CASEexpression merges operand, condition, result, and default sources. -
BETWEENexpression merges expression, lower, and upper sources. -
INvalue-list expression merges left expression and list item sources. -
IN (SELECT ...)merges left expression and subquery result sources. -
LIKEexpression merges expression, pattern, and escape sources. -
IS NULLand relatedIStests preserve expression sources. -
CASTexpression preserves inner expression lineage. -
EXTRACTexpression preserves inner expression lineage. -
INTERVALexpression preserves value expression lineage. -
COLLATEexpression preserves inner expression lineage. -
MATCH ... AGAINST ...merges matched columns and search expression sources. -
CONVERT(expr USING charset)preserves inner expression lineage. -
DEFAULTexpression returns empty source columns. -
ROW(...)expression merges item sources. -
MEMBER OFexpression merges value and JSON-array sources. - user variable reference preserves legacy empty-lineage behavior.
- system variable reference preserves legacy empty-lineage behavior.
- unknown future expression nodes fail closed or get explicit coverage before release.
Phase 3: FROM And Table Sources
3.1 Tables, Aliases, And Stars
- single table source resolves physical table columns.
- table alias changes the visible table name for column resolution.
- database-qualified table source resolves against the qualified database.
- cluster-qualified StarRocks table source filters cluster name as before.
- parenthesized single table source resolves like the unparenthesized table.
- comma-separated table sources expose all tables to target resolution.
-
DUALproduces no table source and allows literal targets. -
DUALjoin operands remain non-nil empty table sources and do not panic. - missing table maps to
NotFoundErrorfail-open behavior. - missing column maps to
NotFoundErrorfail-open behavior.
3.2 Joins
- inner join exposes left and right table columns.
- cross join exposes left and right table columns.
- straight join exposes left and right table columns.
- left outer join exposes left and right table columns.
- right outer join exposes left and right table columns.
-
JOIN ... USING(col)merges duplicateUSINGcolumns. - natural join merges common columns.
- natural left join merges common columns.
- natural right join merges common columns.
-
JOIN ... ONexpression contributes access-table dependencies. - nested join tree preserves visible source ordering.
- parenthesized table reference list behaves like legacy cross-join expansion.
3.3 Derived Tables And Table Functions
- derived table body contributes access-table dependencies.
- derived table alias controls visible table qualifier.
- derived table column alias list renames output columns.
- derived table column alias count mismatch returns legacy error.
- nested derived tables preserve lineage through each layer.
- lateral derived table preserves correlation behavior.
-
JSON_TABLEexposes declared columns as pseudo-table columns. -
JSON_TABLEcolumn lineage comes from the JSON document expression. - nested
JSON_TABLEcolumns flatten in legacy order. -
JSON_TABLEdocument expressions contribute access-table dependencies. -
JSON_TABLEwith alias omitted is rejected because MySQL requires a table-function alias.
Phase 4: Subqueries, CTEs, And Set Operations
4.1 Subquery Scope
- scalar subquery in target list contributes selected source columns.
- correlated scalar subquery can resolve outer query columns.
- subquery in
WHEREcontributes access-table dependencies. - subquery in
HAVINGcontributes access-table dependencies. - subquery in
ORDER BYcontributes access-table dependencies. - nested subqueries preserve nearest-scope alias shadowing.
- unqualified inner subquery columns follow legacy resolution order.
- outer table alias shadowed by inner alias follows legacy resolution.
4.2 Common Table Expressions
- non-recursive CTE exposes selected columns.
- non-recursive CTE explicit column list renames output columns.
- non-recursive CTE column count mismatch returns legacy error.
- nested CTE references resolve in legacy visibility order.
- recursive CTE merges anchor and recursive branch source columns.
- recursive CTE explicit column list count mismatch returns legacy error.
- recursive CTE reaches a stable source-column closure.
- left-deep recursive CTE set operations register the recursive CTE before resolving recursive left branches.
- CTE name shadows physical table name according to legacy behavior.
- later CTE cannot be referenced by earlier CTE unless legacy allowed it.
4.3 Set Operations
-
UNIONmerges left and right source columns by position. -
UNION ALLmerges left and right source columns by position. -
INTERSECTpreserves legacy support or error behavior. -
EXCEPTpreserves legacy support or error behavior. - set operation result names come from the left side.
- set operation column count mismatch returns legacy error.
- set operation inside derived table preserves derived output lineage.
- set operation inside CTE preserves CTE output lineage.
- parenthesized set operation preserves legacy grouping behavior.
Phase 5: Access Tables, System Tables, And Errors
5.1 Access Tables
- top-level
FROMtable appears inSourceColumnsas table-level access. - joined tables appear in
SourceColumnsas table-level access. - derived-table body tables appear in access tables.
- CTE body tables appear in access tables.
- scalar subquery tables appear in access tables.
- correlated subquery inner tables appear in access tables.
- function arguments containing subqueries appear in access tables.
- function-level
ORDER BYsubqueries appear in access tables. -
VALUESexpressions containing subqueries appear in access tables. -
SETassignment expressions containing subqueries appear in access tables. -
SETassignment expressions containing subqueries participate in mixed user/system table detection. -
TABLE ... ORDER BYsubqueries participate in mixed user/system table detection. -
TABLE ... LIMITsubqueries participate in mixed user/system table detection when parsed. -
CALLarguments containing subqueries participate in mixed user/system table detection. -
LOCK TABLESreferences participate in mixed user/system table detection. - DML/DDL roots such as
INSERT ... SELECTandCREATE TABLE ... AS SELECTparticipate in mixed user/system table detection. - table-bearing DDL roots such as
DROP TABLEandRENAME TABLEparticipate in mixed user/system table detection. - plain
EXPLAINpayload tables participate in mixed user/system table detection. -
HANDLERtable appears in access tables where legacy did.
5.2 System Tables
- all-system select returns
SelectInfoSchema. - all-system select suppresses returned access tables.
- mixed user/system table query returns
MixUserSystemTablesError. - uppercase system schema follows case-sensitive legacy behavior.
- uppercase system schema follows case-insensitive legacy behavior.
-
information_schemaaccess behaves like legacy system resource detection. -
performance_schemaaccess behaves like legacy system resource detection. -
mysqlschema access behaves like legacy system resource detection.
5.3 Error Semantics
- missing database maps to fail-open
NotFoundError. - missing table maps to fail-open
NotFoundError. - missing column maps to fail-open
NotFoundError. - unsupported select-with-into returns the legacy hard error.
- unsupported table-with-into returns the legacy hard error.
-
EXPLAIN ANALYZEdoes not require output lineage schema lookups for stale metadata. - unsupported table source returns a hard error instead of silent empty lineage.
- unsupported expression node cannot silently return empty source columns.
- parser failure returns
parser/base.SyntaxErrorwith position and does not fabricate a query span. - nil or empty statement list returns the legacy empty select span.
Phase 6: Metadata, Views, Engines, And Case Sensitivity
6.1 Metadata And Views
- view column lineage is derived from the view definition.
- view output column names are applied to view-derived results.
- view recursion through nested views preserves source table lineage.
- missing view dependency maps to legacy
NotFoundErrorbehavior. - duplicate database names with case differences follow
ignoreCaseSensitive. - default database is used when table reference omits database.
- explicit database overrides default database.
6.2 Case Sensitivity
- case-sensitive column lookup preserves exact table/database matching rules.
- case-insensitive column lookup resolves case variants.
- table alias matching follows legacy case-sensitivity behavior.
- CTE name matching follows legacy case-sensitivity behavior.
- derived table alias matching follows legacy case-sensitivity behavior.
- quoted identifier case is preserved in result names where legacy preserves it.
6.3 Engine-Specific Behavior
- current StarRocks fixtures keep matching golden output.
- StarRocks cluster-qualified database names are normalized before metadata lookup.
- StarRocks system/user table mixing follows legacy behavior.
- MySQL and StarRocks use the same lineage rules unless a fixture proves otherwise.