AsyncNativeOdbcConnection class

Constructors

AsyncNativeOdbcConnection({Duration? requestTimeout, void isolateEntry(SendPort)?, bool autoRecoverOnWorkerCrash = false, int workerCount = 1, int? maxPendingRequests, AsyncBackpressureMode backpressureMode = AsyncBackpressureMode.failFast, Duration? backpressureTimeout})

Properties

affinityEntryCountForTesting int
no setterinherited
autoRecoverOnWorkerCrash bool
finalinherited
backpressureMode AsyncBackpressureMode
finalinherited
backpressureTimeout Duration?
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Whether the worker isolate and ODBC environment are initialized.
no setterinherited
maxPendingRequests int?
finalinherited
onWorkerRecovered ↔ void Function()?
Optional callback invoked after _recoverWorkerInternal completes a successful auto-recovery.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
workerCount int
finalinherited
workerIsolateForTesting Isolate?
Worker isolate, exposed for testing (e.g., to simulate crash).
no setterinherited

Methods

asyncCancel(int asyncRequestId) Future<bool>
Best-effort cancellation for async request.
inherited
asyncFree(int asyncRequestId) Future<bool>
Frees async request resources.
inherited
asyncGetResult(int asyncRequestId, {int? maxBufferBytes}) Future<Uint8List?>
Retrieves binary result for a completed async request.
inherited
asyncPoll(int asyncRequestId) Future<int>
Polls async request status.
inherited
beginTransaction(int connectionId, int isolationLevel, {int savepointDialect = 0, int accessMode = 0, int lockTimeoutMs = 0}) Future<int>
Starts a transaction in the worker for connectionId with isolationLevel. Returns the transaction ID on success.
inherited
bulkInsertArray(int connectionId, String table, List<String> columns, Uint8List dataBuffer, int rowCount) Future<int>
Performs bulk insert on connectionId: table, columns, dataBuffer, rowCount. Returns rows inserted, or negative on error.
inherited
bulkInsertParallel(int poolId, String table, List<String> columns, Uint8List dataBuffer, int parallelism) Future<int>
Performs parallel bulk insert on poolId. Returns rows inserted, or negative value on error.
inherited
cancelStatement(int stmtId) Future<bool>
Requests cancellation of prepared statement stmtId in the worker.
inherited
catalogColumns(int connectionId, String table) Future<Uint8List?>
Returns catalog columns for table on connectionId. Binary result or null on error.
inherited
catalogForeignKeys(int connectionId, String table) Future<Uint8List?>
inherited
catalogIndexes(int connectionId, String table) Future<Uint8List?>
inherited
catalogPrimaryKeys(int connectionId, String table) Future<Uint8List?>
inherited
catalogTables(int connectionId, {String catalog = '', String schema = ''}) Future<Uint8List?>
Returns catalog tables for connectionId (optional catalog and schema). Returns binary result or null on error.
inherited
catalogTypeInfo(int connectionId) Future<Uint8List?>
Returns type info for connectionId. Binary result or null on error.
inherited
clearAllStatements() Future<int>
inherited
clearAuditEvents() Future<bool>
Clears in-memory audit events in the worker.
inherited
clearMetadataCache() Future<bool>
Clears metadata cache entries in the worker.
inherited
clearStatementCache() Future<bool>
Clears the prepared statement cache in the worker.
inherited
closeStatement(int stmtId) Future<bool>
Closes the prepared statement stmtId in the worker.
inherited
commitTransaction(int txnId) Future<bool>
Commits the transaction identified by txnId in the worker.
inherited
connect(String connectionString, {int timeoutMs = 0}) Future<int>
Opens a connection in the worker using connectionString.
inherited
createSavepoint(int txnId, String name) Future<bool>
Creates a savepoint name within the transaction txnId in the worker.
inherited
detectDriver(String connectionString) Future<String?>
Detects the database driver from a connection string.
inherited
disconnect(int connectionId) Future<bool>
Closes the connection identified by connectionId in the worker.
inherited
dispose() → void
Shuts down the worker isolate and releases resources.
inherited
executeAsync(int connectionId, String sql, {Duration pollInterval = const Duration(milliseconds: 10), Duration? timeout, int? maxBufferBytes}) Future<Uint8List?>
Executes sql in non-blocking mode using native async request lifecycle.
inherited
executeAsyncStart(int connectionId, String sql) Future<int>
Starts non-blocking query execution in native layer.
inherited
executeAsyncStartParams(int connectionId, String sql, Uint8List? serializedParams, {ResultEncoding resultEncoding = ResultEncoding.rowMajor}) Future<int>
Starts non-blocking parameterized execution in native layer.
inherited
executePrepared(int stmtId, List<ParamValue>? params, int timeoutOverrideMs, int fetchSize, {int? maxBufferBytes}) Future<Uint8List?>
Executes a prepared statement stmtId in the worker with optional params. Returns the binary result, or null on error.
inherited
executePreparedNamed(int stmtId, Map<String, Object?> namedParams, int timeoutOverrideMs, int fetchSize, {int? maxBufferBytes}) Future<Uint8List?>
Executes a prepared statement stmtId using named parameters.
inherited
executeQueryMulti(int connectionId, String sql, {int? maxBufferBytes}) Future<Uint8List?>
Executes sql on connectionId for multi-result sets in the worker. When maxBufferBytes is set, caps the result buffer size. Returns the binary result, or null on error.
inherited
executeQueryMultiParams(int connectionId, String sql, Uint8List? paramsBuffer, {int? maxBufferBytes}) Future<Uint8List?>
Executes a parameterised multi-result batch in the worker.
inherited
executeQueryNamed(int connectionId, String sql, Map<String, Object?> namedParams, {int? maxBufferBytes}) Future<Uint8List?>
Executes sql on connectionId using named parameters.
inherited
executeQueryParamBuffer(int connectionId, String sql, Uint8List? paramBuffer, {int? maxBufferBytes, Duration? timeout, ResultEncoding resultEncoding = ResultEncoding.rowMajor}) Future<Uint8List?>
Executes a parameterised query with a pre-serialised buffer (legacy v0 or DRT1 directed parameters).
inherited
executeQueryParams(int connectionId, String sql, List<ParamValue> params, {int? maxBufferBytes, Duration? timeout, ResultEncoding resultEncoding = ResultEncoding.rowMajor}) Future<Uint8List?>
Executes sql on connectionId with params in the worker.
inherited
failWorkerForTesting(int workerIndex) → void
inherited
getAuditEventsJson({int limit = 0}) Future<String?>
Returns audit events as JSON payload, or null on failure.
inherited
getAuditStatusJson() Future<String?>
Returns audit status as JSON payload, or null on failure.
inherited
getCacheMetrics() Future<PreparedStatementMetrics?>
Returns prepared statement cache metrics from the worker.
inherited
getConnectionDbmsInfoJson(int connectionId) Future<String?>
Returns live DBMS introspection payload as JSON, or null on failure.
inherited
getDriverCapabilitiesJson(String connectionString) Future<String?>
Returns driver capabilities payload as JSON, or null on failure.
inherited
getError() Future<String>
Returns the last error message from the worker (plain text).
inherited
getMetadataCacheStatsJson() Future<String?>
Returns metadata cache stats as JSON payload, or null on failure.
inherited
getMetrics() Future<OdbcMetrics?>
Returns ODBC metrics from the worker (query count, errors, latency, etc.).
inherited
getStructuredError() Future<StructuredError?>
Returns the last structured error (message, SQLSTATE, native code), or null if there is no error.
inherited
getStructuredErrorForConnection(int connectionId) Future<StructuredError?>
Returns the last structured error for connectionId, or null when there is no connection-scoped error information.
inherited
getVersion() Future<Map<String, String>?>
Returns engine version (api + abi) for compatibility checks.
inherited
getWorkerPoolStats() AsyncWorkerPoolStats
Returns a Dart-side snapshot of worker pool routing and health counters.
inherited
initialize() Future<bool>
Initializes the worker isolate and ODBC environment.
inherited
metadataCacheEnable({required int maxEntries, required int ttlSeconds}) Future<bool>
Enables metadata cache in the worker.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
poolClose(int poolId) Future<bool>
Closes pool poolId in the worker.
inherited
poolCreate(String connectionString, int maxSize, {PoolOptions? options}) Future<int>
Creates a connection pool in the worker. Returns pool ID on success.
inherited
poolGetConnection(int poolId) Future<int>
Obtains a connection from pool poolId. Returns connection ID on success.
inherited
poolGetState(int poolId) Future<({int idle, int size})?>
Returns the current state (size, idle) of pool poolId, or null on error.
inherited
poolGetStateJson(int poolId) Future<String?>
Returns detailed pool state payload as JSON, or null on failure.
inherited
poolHealthCheck(int poolId) Future<bool>
Runs a health check on pool poolId.
inherited
poolReleaseConnection(int connectionId) Future<bool>
Returns connectionId to its pool.
inherited
poolSetSize(int poolId, int newMaxSize) Future<bool>
Resizes pool poolId to newMaxSize in the worker.
inherited
prepare(int connectionId, String sql, {int timeoutMs = 0}) Future<int>
Prepares sql on connectionId in the worker.
inherited
prepareNamed(int connectionId, String sql, {int timeoutMs = 0}) Future<int>
Prepares sql with named parameters on connectionId in the worker.
inherited
recoverWorker() Future<void>
Disposes the current worker and re-initializes a fresh one.
inherited
releaseSavepoint(int txnId, String name) Future<bool>
Releases savepoint name in transaction txnId. Transaction stays active.
inherited
rollbackToSavepoint(int txnId, String name) Future<bool>
Rolls back to savepoint name in transaction txnId. Transaction stays active.
inherited
rollbackTransaction(int txnId) Future<bool>
Rolls back the transaction identified by txnId in the worker.
inherited
setAuditEnabled({required bool enabled}) Future<bool>
Enables/disables native audit event collection in the worker.
inherited
setLogLevel(int level) Future<void>
Sets native engine log verbosity in the worker.
inherited
streamAsync(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, Duration pollInterval = const Duration(milliseconds: 10), int? maxBufferBytes, int resultEncodingWire = 0, bool lazyStrings = false}) Stream<ParsedRowBuffer>
Runs sql using native async stream lifecycle: stream_start_async -> stream_poll_async -> stream_fetch -> stream_close.
inherited
streamCancel(int streamId) Future<bool>
Cancels an active low-level native stream in the worker.
inherited
streamClose(int streamId) Future<bool>
Closes an active stream in the worker. Public counterpart of _streamClose for the same reason as streamFetch. New in v3.3.0.
inherited
streamFetch(int streamId) Future<StreamFetchResponse>
Fetches the next chunk from an active stream in the worker. Public counterpart of _streamFetch, used by callers that drive the stream lifecycle themselves (e.g. streamQueryMulti). New in v3.3.0.
inherited
streamMultiStartAsync(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, int resultEncodingWire = 0}) Future<int>
Async variant of streamMultiStartBatched. Combine with streamPollAsync.
inherited
streamMultiStartBatched(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, int resultEncodingWire = 0}) Future<int>
Starts a streaming multi-result batch (M8 in v3.3.0). The chunks emitted by streamFetch follow the framed wire format documented in MultiResultStreamDecoder. Returns 0 when the loaded native library does not export the FFI.
inherited
streamPollAsync(int streamId) Future<int>
Polls low-level async stream status.
inherited
streamQuery(int connectionId, String sql, {int chunkSize = 1000, int? maxBufferBytes}) Stream<ParsedRowBuffer>
Runs sql in the worker using native batched streaming.
inherited
streamQueryBatched(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, int? maxBufferBytes, int resultEncodingWire = 0, bool lazyStrings = false}) Stream<ParsedRowBuffer>
Runs sql in the worker using native batched streaming.
inherited
streamQueryBuffer(int connectionId, String sql, {int chunkSize = 1000, int? maxBufferBytes, bool lazyStrings = false}) Stream<ParsedRowBuffer>
Legacy buffer-mode streaming via odbc_stream_start. Materialises the full result in the worker before yielding a single parsed chunk.
inherited
streamQueryColumnarBatched(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, int? maxBufferBytes, bool lazyStrings = false, ResultEncoding resultEncoding = ResultEncoding.columnar}) Stream<TypedColumnarResult>
Batched columnar streaming with direct TypedColumnarResult decode.
inherited
streamStartAsync(int connectionId, String sql, {int fetchSize = 1000, int chunkSize = 64 * 1024, int resultEncodingWire = 0}) Future<int>
Starts low-level async stream lifecycle and returns stream ID.
inherited
toString() String
A string representation of this object.
inherited
validateConnectionString(String connectionString) Future<String?>
Validates connection string format without opening a connection.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited