Skip to main content

Module sql_sem

Module sql_sem 

Source
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:

  1. A heuristic recogniser (out of scope for this module) walks the raw SQL and emits the structural pieces.
  2. The IR canonicaliser is responsible for fully-qualifying every TableUse.table and ColumnUse.column reference 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.md PL/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.md Data Dictionary View Families — ALL_TAB_COLUMNS is the server-side authority later passes use to cross-check ColumnUse.column against the table’s declared columns.

Structs§

AliasBinding
AliasScope
Map of alias → fully-qualified table. The lineage resolver consults this to rewrite bare col into <schema>.<table>.<col>.
ColumnUse
One referenced column. qualifier is the alias / table that scopes the reference; empty when the source SQL referenced the column bare (an alias-scope resolver will rewrite later).
ProjectionItem
One item in a SELECT’s projection list. alias is the SQL alias (after AS) if present; expression_text carries the raw expression so downstream readers can re-parse it via plsql_ir::lower_expression.
SqlSemanticModel
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.
SqlStatementModel
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.
TableUse
One referenced table / view / synonym. alias is set when the FROM clause supplied one; otherwise it’s the empty string.

Enums§

ColumnResolution
SqlSemanticVerb
SQL verb classification — distinct from plsql_ir::SqlVerb because the semantic model needs to express MERGE’s dual-update + insert nature.
TableUsageKind