Class TigerQueryEngine
- Namespace
- ItTiger.TigerQuery.Engine
- Assembly
- ItTiger.TigerQuery.dll
public sealed class TigerQueryEngine
- Inheritance
-
TigerQueryEngine
- Inherited Members
Remarks
The engine has no console output. Messages, result sets, and batch lifecycle information are delivered through TigerQueryEngineOptions callbacks. A single engine should not be used for concurrent runs because its options and callback destinations are shared.
Callbacks are synchronous. In prepared mode the order is plan-ready, then batch-start, any messages/result sets, and batch-end for each scheduled execution. Streaming mode omits plan-ready and preserves the same per-batch order.
Both modes share one batch coordinator, so error accounting, the effective
:ON ERROR policy, and the batch lifecycle behave identically. A batch
attempt fails when an exception is caught for it or when SQL Server reports an
error of severity 11 or higher during it — including the severity 11-16 user
errors the provider delivers as informational messages instead of throwing. A
failing attempt increments the failed count, ends with an unsuccessful batch-end
carrying a diagnostic, and, unless the effective policy is continue-on-error,
stops the run without starting any later batch. The effective policy decides
whether later batches run; it does not decide the outcome. Any failed attempt
makes the run's ResultCode something other than
Success, and a later successful batch never
clears an earlier failure.
Constructors
TigerQueryEngine(TigerQueryEngineOptions)
public TigerQueryEngine(TigerQueryEngineOptions options)
Parameters
optionsTigerQueryEngineOptions- The parsing, execution, and callback configuration.
Exceptions
- ArgumentNullException
optionsis null.
Methods
RunAsync(TextReader, CancellationToken)
input using the configured
ExecutionMode.public Task<ExecutionResult> RunAsync(TextReader input, CancellationToken cancellationToken = default)
Parameters
inputTextReader- The script reader. The engine does not dispose it.
cancellationTokenCancellationToken- A token observed during parsing and execution.
Returns
- Task<ExecutionResult>
- A result when execution reaches the coordinator's normal result path.
Remarks
Streaming mode opens the SQL connection before parsing batches incrementally, so earlier batches can execute before a later parser error. Prepared mode parses the complete TigerQuery/sqlcmd structure before opening the connection; parser failure therefore prevents SQL execution. Prepared mode retains every expanded logical batch for the duration of the run.
Preparation does not validate T-SQL. Connection, permission, T-SQL syntax, compilation, and runtime failures remain execution-time behavior. Parser and connection-opening exceptions escape this method.
Cancellation observed while an active provider batch operation is in the engine's batch catch path produces UserCancelled. Cancellation during parsing, preparation, connection opening, between executions, or in callbacks is propagated as OperationCanceledException.
Exceptions
- ArgumentNullException
inputis null.- ArgumentOutOfRangeException
- CommandTimeoutSeconds is negative.
- TigerQueryException
- TigerQuery/sqlcmd structure is malformed.
- OperationCanceledException
- Cancellation is observed outside an active batch provider operation.
- InvalidOperationException
- The configured ExecutionMode is unsupported.
RunFromFileAsync(string, Encoding?, CancellationToken)
public Task<ExecutionResult> RunFromFileAsync(string path, Encoding? encoding = null, CancellationToken cancellationToken = default)
Parameters
pathstring- The script file path.
encodingEncoding- The fallback encoding when no byte-order mark is detected; UTF-8 by default.
cancellationTokenCancellationToken- A token observed during parsing and execution.
Returns
- Task<ExecutionResult>
- A result when execution reaches the coordinator's normal result path.
Remarks
encoding. The file reader is
disposed after the run.Exceptions
- TigerQueryException
- TigerQuery/sqlcmd structure is malformed.
- OperationCanceledException
- Cancellation is observed outside an active batch provider operation.
RunFromStringAsync(string, CancellationToken)
public Task<ExecutionResult> RunFromStringAsync(string script, CancellationToken cancellationToken = default)
Parameters
scriptstring- The complete script text.
cancellationTokenCancellationToken- A token observed during parsing and execution.
Returns
- Task<ExecutionResult>
- A result when execution reaches the coordinator's normal result path.
Exceptions
- TigerQueryException
- TigerQuery/sqlcmd structure is malformed.
- OperationCanceledException
- Cancellation is observed outside an active batch provider operation.