001package gudusoft.gsqlparser.dlineage.dynamicsql;
002
003/**
004 * Resource bounds for {@code resolveDynamicSqlLineage}.
005 *
006 * <p>The evaluated dynamic-SQL string is effectively attacker-controlled (it is
007 * built from runtime parameter values), so every dimension that an adversarial
008 * or pathological procedure could blow up is capped. When a bound is exceeded
009 * the affected site fails <em>closed</em> to an unresolved diagnostic — never a
010 * hang, never an OOM, never a fabricated edge.
011 */
012public final class DynamicLineageOptions {
013
014    private int maxResolvedSqlLength = 1_000_000;   // chars in a single materialized statement string
015    private int maxSites = 256;                     // dynamic-SQL EXEC sites resolved per call
016    private int maxBindings = 1024;                 // parameter bindings accepted per call
017    private int maxExpansionDepth = 256;            // function/CASE nesting depth before failing closed
018    private long timeoutMillis = 10_000;            // wall-clock budget for the whole resolve call
019    private boolean showImplicitSchema = true;      // qualify unqualified names with currentDatabase/defaultSchema
020
021    public static DynamicLineageOptions createDefault() {
022        return new DynamicLineageOptions();
023    }
024
025    public int getMaxResolvedSqlLength() {
026        return maxResolvedSqlLength;
027    }
028
029    public DynamicLineageOptions setMaxResolvedSqlLength(int v) {
030        this.maxResolvedSqlLength = v;
031        return this;
032    }
033
034    public int getMaxSites() {
035        return maxSites;
036    }
037
038    public DynamicLineageOptions setMaxSites(int v) {
039        this.maxSites = v;
040        return this;
041    }
042
043    public int getMaxBindings() {
044        return maxBindings;
045    }
046
047    public DynamicLineageOptions setMaxBindings(int v) {
048        this.maxBindings = v;
049        return this;
050    }
051
052    public int getMaxExpansionDepth() {
053        return maxExpansionDepth;
054    }
055
056    public DynamicLineageOptions setMaxExpansionDepth(int v) {
057        this.maxExpansionDepth = v;
058        return this;
059    }
060
061    public long getTimeoutMillis() {
062        return timeoutMillis;
063    }
064
065    public DynamicLineageOptions setTimeoutMillis(long v) {
066        this.timeoutMillis = v;
067        return this;
068    }
069
070    public boolean isShowImplicitSchema() {
071        return showImplicitSchema;
072    }
073
074    public DynamicLineageOptions setShowImplicitSchema(boolean v) {
075        this.showImplicitSchema = v;
076        return this;
077    }
078}