public final class DynamicSqlLineageResolver extends Object
TDynamicSqlStringEvaluator), then for each materialized EXEC site run
ordinary dlineage on the concrete string and tag the resulting edges with
dynamic provenance.
This is purely additive — it constructs fresh, throwaway
DataFlowAnalyzer instances for the materialized strings and never
touches the default analysis path, so default dlineage output is unchanged.
| Modifier and Type | Class and Description |
|---|---|
static class |
DynamicSqlLineageResolver.MaterializedSite
Materialized dynamic-SQL text for one EXEC / sp_executesql site, produced by the
no-bindings default-path evaluation (
materializeSitesWithoutBindings(gudusoft.gsqlparser.TCustomSqlStatement, gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.dlineage.dynamicsql.DynamicLineageOptions)). |
| Modifier and Type | Method and Description |
|---|---|
static List<Map<String,SqlValue>> |
discoverCallSiteBindings(TCustomSqlStatement procAst,
int maxBindingSets)
Discover parameter bindings from literal call sites of
procAst in the same
parsed file: top-level EXEC <proc> 'literal', @p = 'literal', ... statements
whose (unqualified) module name matches the procedure name. |
static List<Map<String,SqlValue>> |
discoverCrossFileCallSiteBindings(TCustomSqlStatement procAst,
RoutineCatalog catalog,
int maxBindingSets)
Discover parameter bindings from literal call sites of
procAst located in
OTHER files of the same multi-file analysis (plan Phase 5: cross-file routine
references). |
static List<String> |
foldDbmsSqlTexts(TCustomSqlStatement enclosingRoutine,
TExpression sqlArg,
RoutineCatalog catalog,
int maxVariants)
DBMS_SQL entry point (plan Phase 5 slice 4): fold the SQL-text argument of a
DBMS_SQL.PARSE call into concrete statement texts. |
static Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite> |
materializeSites(TCustomSqlStatement procAst,
EDbVendor vendor,
Map<String,SqlValue> bindings,
DynamicLineageOptions options)
Same as
materializeSitesWithoutBindings(gudusoft.gsqlparser.TCustomSqlStatement, gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.dlineage.dynamicsql.DynamicLineageOptions), but with caller-supplied parameter
bindings (e.g. |
static Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite> |
materializeSitesWithoutBindings(TCustomSqlStatement procAst,
EDbVendor vendor,
DynamicLineageOptions options)
Default-path hook for
DataFlowAnalyzer: abstractly evaluate a procedure's
dynamic-SQL string building with NO call-site bindings — only literal parameter
defaults are seeded — and return the materialized string per EXEC/sp_executesql
statement node (identity-keyed against the SAME parse tree that was passed in). |
static List<Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite>> |
materializeSiteVariants(TCustomSqlStatement procAst,
EDbVendor vendor,
Map<String,SqlValue> bindings,
DynamicLineageOptions options)
Materialize all bounded, row-correlated constant-relation variants for a
procedure.
|
static List<TCustomSqlStatement> |
plsqlInterpretationStatements(TStatementList ownStatements,
String ownText,
RoutineCatalog catalog,
int maxForeignCallers)
Oracle analog of cross-file call-site discovery (plan Phase 5): collect
top-level statements from OTHER files (anonymous blocks, CALL statements)
that mention a routine defined in the current file, so the caller can feed
them to
TASTEvaluator together with the file's own statements and
fold parameter-dependent EXECUTE IMMEDIATE templates under the callers'
literal arguments. |
static DynamicLineageResult |
resolve(TCustomSqlStatement procAst,
EDbVendor vendor,
TSQLEnv sqlEnv,
String currentDatabase,
String defaultSchema,
Map<String,SqlValue> bindings,
DynamicLineageOptions options) |
public static Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite> materializeSitesWithoutBindings(TCustomSqlStatement procAst, EDbVendor vendor, DynamicLineageOptions options)
DataFlowAnalyzer: abstractly evaluate a procedure's
dynamic-SQL string building with NO call-site bindings — only literal parameter
defaults are seeded — and return the materialized string per EXEC/sp_executesql
statement node (identity-keyed against the SAME parse tree that was passed in).
Constant- and template-built strings (REPLACE/QUOTENAME/CONCAT chains over
literals and literal-seeded variables) reduce fully; strings depending on unbound
parameters reduce to placeholder-bearing PARTIAL text; anything else is reported
with a reason. Purely computational — nothing is executed and no model state of
any analyzer is touched.public static Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite> materializeSites(TCustomSqlStatement procAst, EDbVendor vendor, Map<String,SqlValue> bindings, DynamicLineageOptions options)
materializeSitesWithoutBindings(gudusoft.gsqlparser.TCustomSqlStatement, gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.dlineage.dynamicsql.DynamicLineageOptions), but with caller-supplied parameter
bindings (e.g. extracted from a literal call site) seeded before the walk. Parameters
absent from the bindings fall back to their literal defaults, then to placeholders.public static List<Map<TCustomSqlStatement,DynamicSqlLineageResolver.MaterializedSite>> materializeSiteVariants(TCustomSqlStatement procAst, EDbVendor vendor, Map<String,SqlValue> bindings, DynamicLineageOptions options)
public static DynamicLineageResult resolve(TCustomSqlStatement procAst, EDbVendor vendor, TSQLEnv sqlEnv, String currentDatabase, String defaultSchema, Map<String,SqlValue> bindings, DynamicLineageOptions options)
public static List<Map<String,SqlValue>> discoverCallSiteBindings(TCustomSqlStatement procAst, int maxBindingSets)
procAst in the same
parsed file: top-level EXEC <proc> 'literal', @p = 'literal', ... statements
whose (unqualified) module name matches the procedure name. Positional and named
arguments are supported; OUTPUT and non-literal arguments are left unbound (they
become placeholders during evaluation). Returns up to maxBindingSets distinct
binding sets in file order.public static List<Map<String,SqlValue>> discoverCrossFileCallSiteBindings(TCustomSqlStatement procAst, RoutineCatalog catalog, int maxBindingSets)
procAst located in
OTHER files of the same multi-file analysis (plan Phase 5: cross-file routine
references). otherFileSqlTexts holds the raw SQL text of every analysis
unit; the procedure's own file is skipped by text identity. A text is parsed at
most once per analysis via the caller-owned parseCache (key: the text),
and only when it mentions the procedure's simple name at all.
Never guesses across ambiguity: if any other file defines a procedure with the same simple name in a database-compatible context, there are two candidate owners for a matching call and this method returns no bindings at all. Binding sets are returned in canonical-key order, so the result is independent of the file order of the analysis. Binding sets already surfaced by the same-file discovery above are excluded here, so duplicates never consume the caller's shared cap.
public static List<TCustomSqlStatement> plsqlInterpretationStatements(TStatementList ownStatements, String ownText, RoutineCatalog catalog, int maxForeignCallers)
TASTEvaluator together with the file's own statements and
fold parameter-dependent EXECUTE IMMEDIATE templates under the callers'
literal arguments.
Mirrors the MSSQL rules: a text is parsed at most once per analysis via
parseCache and only when it mentions one of the candidate routine
names; a same-simple-name routine DEFINITION in another file makes that
name ambiguous and drops it from the harvest (never guess between two
candidate owners); foreign definitions themselves are never appended.
Returned statements are ordered by their source text, so evaluation order
is independent of the file order of the analysis.
public static List<String> foldDbmsSqlTexts(TCustomSqlStatement enclosingRoutine, TExpression sqlArg, RoutineCatalog catalog, int maxVariants)
DBMS_SQL.PARSE call into concrete statement texts. Returns the
no-binding fold first (literal or literal-composed locals), then one fold per
literal call-site binding set (same-file callers first, then cross-file via
the catalog), deduplicated, capped at maxVariants. Empty when nothing
folds — the site then keeps its honest unresolved diagnostic. The fold shares
the EXECUTE IMMEDIATE whitelist (literals, parameters bound at vetted call
sites, locals with exactly one literal-composed assignment, || and
parentheses), so a fold can never fabricate object names.