public final class RoutineCatalog extends Object
Lazily built and memoized per unit text: a unit is parsed (through the shared, caller-owned parse cache) and its statement list walked at most ONCE per analysis, no matter how many procedures consult the catalog. Callers keep their own cheap contains-prefilter, so units that never mention a routine of interest are still never parsed at all — cost semantics are identical to the previous per-procedure scans, minus the repeated walking.
The catalog only INDEXES; every matching, vetting, and ambiguity decision
stays in DynamicSqlLineageResolver so this refactor is behavior-
preserving by construction.
TSQLEnv / TSQLProceduregudusoft.gsqlparser.sqlenv.TSQLProcedure under TSQLSchema,
with typed parameters and even the definition source string). The two serve
different layers and are NOT redundant:
TSQLEnv stores
metadata — names, parameter TYPES, the definition as a STRING — and
serves NAME RESOLUTION (resolver2/dlineage resolving a.b.c
against catalog objects). This catalog stores live
AST nodes plus each
statement's unit provenance and effective USE database/schema, because
the dynamic-SQL binding machinery must hand the callee's AST to the
evaluator/interpreter and extract literal arguments from caller ASTs.
An env definition string would have to be re-parsed anyway — which is
exactly what this catalog's parse cache does, while also indexing what
the env has no concept of at all: call sites.TSQLEnv attached (and env construction is option-gated); this
catalog depends only on the analysis unit texts themselves.BoundProgram is later Phase 5/6
work.sourceCode,
grabit exports, DDL dumps) already flows in with no extra wiring: those
definitions become ordinary analysis units, so this catalog indexes them
like any other file while SQLEnvParser independently registers
them for name resolution.TSQLRoutine definition string for a routine that is NOT
among the analysis units, this catalog could parse that definition as a
virtual unit — covering the "caller file plus metadata-only definition"
scenario.| Constructor and Description |
|---|
RoutineCatalog(EDbVendor vendor,
List<String> unitTexts,
Map<String,TStatementList> parseCache) |
| Modifier and Type | Method and Description |
|---|---|
static String |
numberedGroupAfter(TObjectName name)
The
;N group of a deprecated numbered procedure, scanned from
the source tokens right after the name — the parser drops it from the
AST name entirely. |
public RoutineCatalog(EDbVendor vendor, List<String> unitTexts, Map<String,TStatementList> parseCache)
public static String numberedGroupAfter(TObjectName name)
;N group of a deprecated numbered procedure, scanned from
the source tokens right after the name — the parser drops it from the
AST name entirely. ;1 normalizes to null (p and
p;1 are one identity in T-SQL).