Expand description
Semantic model for embedded SQL statements.
plsql_ir::Statement::Sql carries the raw SQL text. This
module adds the typed structure downstream lineage needs:
tables referenced, columns read / written, projection items,
and alias scope. Together these form SqlStatementModel —
one per embedded SQL statement — and SqlSemanticModel —
the per-package aggregate the lineage layer consumes.
Population happens in two passes:
- A heuristic recogniser (out of scope for this module) walks the raw SQL and emits the structural pieces.
- The IR canonicaliser is responsible for
fully-qualifying every
TableUse.tableandColumnUse.columnreference once the alias scope has been resolved.
This module ships only the types + the constructor helpers so the downstream consumers (lineage, doc, bindings) can program against a stable surface today.
§/oracle evidence
DATABASE-REFERENCE.mdPL/SQL Language Reference — the embedded-SQL grammar plus the column / table / alias semantics come from the SQL Language Reference chapter the PL/SQL Language Reference defers to.LOW-LEVEL-CATALOGS.mdData Dictionary View Families —ALL_TAB_COLUMNSis the server-side authority later passes use to cross-checkColumnUse.columnagainst the table’s declared columns.
Structs§
- Alias
Binding - Alias
Scope - Map of alias → fully-qualified table. The lineage resolver
consults this to rewrite bare
colinto<schema>.<table>.<col>. - Column
Use - One referenced column.
qualifieris the alias / table that scopes the reference; empty when the source SQL referenced the column bare (an alias-scope resolver will rewrite later). - Projection
Item - One item in a SELECT’s projection list.
aliasis the SQL alias (afterAS) if present;expression_textcarries the raw expression so downstream readers can re-parse it viaplsql_ir::lower_expression. - SqlSemantic
Model - Aggregate over every embedded SQL statement found in a routine body / package. The lineage layer consumes the aggregate; the doc + bindings layers consume the per-statement model.
- SqlStatement
Model - One embedded SQL statement seen from inside a PL/SQL routine
body. Carries the SQL verb (already in
Statement::Sql), the list of tables touched, the columns read / written, the projection (for SELECT) and the alias-to-table map. - Table
Use - One referenced table / view / synonym.
aliasis set when the FROM clause supplied one; otherwise it’s the empty string.
Enums§
- Column
Resolution - SqlSemantic
Verb - SQL verb classification — distinct from
plsql_ir::SqlVerbbecause the semantic model needs to express MERGE’s dual-update + insert nature. - Table
Usage Kind