Class QueryExecutionContext
- Namespace
- ItTiger.TigerQuery.Engine
- Assembly
- ItTiger.TigerQuery.dll
Holds mutable per-run parser state and executes batches on a caller-supplied
SQL connection.
public sealed class QueryExecutionContext
- Inheritance
-
QueryExecutionContext
- Inherited Members
Remarks
The context does not own or dispose the connection. It is mutable and not
safe for concurrent parsing or execution.
Constructors
QueryExecutionContext(TigerQueryEngineOptions, SqlConnection)
Initializes a per-run context.
public QueryExecutionContext(TigerQueryEngineOptions options, SqlConnection connection)
Parameters
optionsTigerQueryEngineOptions- The parser, execution, and callback options.
connectionSqlConnection- The SQL connection used by ExecuteBatchAsync(SqlBatch, int, int, CancellationToken). The context does not open or dispose it.
Exceptions
- ArgumentNullException
optionsorconnectionis null.
Properties
ContinueOnError
Gets or sets whether execution should continue after a nonfatal batch failure.
public bool ContinueOnError { get; set; }
Property Value
Remarks
Mode
Gets the configured parser mode.
public SqlCmdMode Mode { get; }
Property Value
Variables
Gets the case-insensitive variable table for this run.
public IReadOnlyDictionary<string, SqlCmdVariable> Variables { get; }
Property Value
Remarks
The dictionary cannot be modified through this view, although each
SqlCmdVariable reflects subsequent permitted assignments.
Methods
ExecuteBatchAsync(SqlBatch, int, int, CancellationToken)
Executes one batch iteration and materializes each result set for the
configured result-set callback.
public Task<int> ExecuteBatchAsync(SqlBatch batch, int batchNumber, int executionIndex, CancellationToken cancellationToken)
Parameters
batchSqlBatch- The batch whose SQL text is submitted.
batchNumberint- The one-based logical batch number.
executionIndexint- The one-based repeat iteration.
cancellationTokenCancellationToken- A token passed to provider operations.
Returns
Remarks
A null or whitespace-only batch is skipped. The supplied connection must
already be open. CommandTimeoutSeconds, when
set, bounds this one batch rather than the run. Result sets are fully read before they are delivered. When
the engine has redirected the result-set channel to a file, the result set is
written there and the callback is not invoked.
Exceptions
- OperationCanceledException
cancellationTokenis cancelled during provider work.- SqlException
- SQL Server rejects or fails the batch, including when the batch exceeds CommandTimeoutSeconds.
- OutputRoutingException
- A redirected result set could not be serialized or written.
ExpandVariables(string)
Expands sqlcmd variable references in text.
public string ExpandVariables(string input)
Parameters
inputstring- The source text to process.
Returns
GetVariableValue(string)
Looks up a variable value by case-insensitive name.
public string? GetVariableValue(string name)
Parameters
namestring- The name without reference delimiters.
Returns
SetVariableFromScript(string, string)
Applies a value parsed from a
:setvar command.public void SetVariableFromScript(string name, string value)
Parameters
namestring- The variable name without reference delimiters.
valuestring- The parsed replacement value.
Remarks
Empty or whitespace names are ignored. Assignments to protected
SqlCmdEx programmatic variables are also ignored.
Other assignments add or replace variables case-insensitively.