Class DatabaseContextTracker
Object
gudusoft.gsqlparser.resolver2.context.DatabaseContextTracker
Delta 4: Database context tracker for USE/SET statements.
Tracks USE DATABASE, USE SCHEMA, SET SCHEMA, and similar statements
to maintain the current database/schema context during resolution.
This enables proper resolution of unqualified table names when the
context is set by prior statements in the same SQL batch.
Example:
USE mydb; SELECT * FROM t; -- 't' should resolve to 'mydb.dbo.t' (or 'mydb.t')
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyDefaults(TSQLEnv env) Apply the tracked defaults to a TSQLEnv.Get the current database name.Get the current schema name.booleanCheck if any context has been tracked.voidProcess a single statement and update context if it's a USE/SET statement.voidprocessStatements(TStatementList statements) Process all statements in the list to extract database/schema context.voidreset()Reset the context tracker.toString()
-
Constructor Details
-
DatabaseContextTracker
public DatabaseContextTracker()
-
-
Method Details
-
processStatements
Process all statements in the list to extract database/schema context.- Parameters:
statements- The list of SQL statements to process
-
processStatement
Process a single statement and update context if it's a USE/SET statement.- Parameters:
stmt- The statement to process
-
applyDefaults
Apply the tracked defaults to a TSQLEnv.- Parameters:
env- The SQL environment to update
-
hasContext
Check if any context has been tracked.- Returns:
- true if either database or schema context has been set
-
getCurrentDatabase
Get the current database name.- Returns:
- The current database name, or null if not set
-
getCurrentSchema
Get the current schema name.- Returns:
- The current schema name, or null if not set
-
reset
Reset the context tracker. -
toString
-