@itwin/core-backend
Version:
iTwin.js backend components
79 lines • 3.74 kB
TypeScript
import { QueryPropertyMetaData } from "@itwin/core-common";
import type { IModelDb } from "./IModelDb";
import { ECSqlStatement } from "./ECSqlStatement";
import { IModelJsNative } from "@bentley/imodeljs-native";
import type { ECDb } from "./ECDb";
import type { StatementCache } from "./SqliteStatement";
/** Returns a statement to its cache, falling back to direct disposal without throwing.
* @internal
*/
export declare function releaseECSqlStatement(stmt: ECSqlStatement, cache: StatementCache<ECSqlStatement>, loggerCategory: string, canCache: boolean): void;
/**
* Executes ECSql queries one row at a time against an IModelDb, maintaining statement state between
* successive calls so the caller can page through results via offset-based requests.
* @internal
*/
export declare class ECSqlRowExecutor implements Disposable {
private readonly _db;
private readonly _stmt;
private readonly _loggerCategory;
private _removeListener;
private _isDisposed;
private _canCacheStatement;
/** Whether the statement completed preparation and can be returned to its cache.
* @internal
*/
get canCacheStatement(): boolean;
constructor(_db: IModelDb | ECDb, _stmt: ECSqlStatement, _loggerCategory: string);
/** Disposes the currently held statement without returning it to the cache.
* Invoked when the db signals it is closing (the statement cache is cleared on close, so the
* checked-out statement must be disposed directly to avoid a use-after-free or double dispose).
* @internal
*/
private cleanup;
/** Removes the database-close listener owned by this row executor.
* @internal
*/
[Symbol.dispose](): void;
/** Prepare the statement and bind parameters in one step.
* Call once during reader initialization — avoids the per-row `ensureStatementReady` check.
* @param query - The ECSql text to prepare.
* @param args - Optional bind parameters.
* @throws IModelError on preparation or binding failure.
* @internal
*/
prepareAndBind(query: string, args?: object): void;
/** Fast-path: step the cursor once and return row data directly.
*
* Returns the row data array if a row is available.
* Returns `undefined` if the result set is exhausted (DONE).
*
* This avoids all intermediate object allocations (StepResult, RowDataResult,
* DbRuntimeStats, DbQueryResponse) that the general `execute()` path creates per row.
*
* @param options - Native row-adaptor options (should be cached and reused across rows).
* @throws IModelError on step failure or row extraction failure.
* @internal
*/
stepNextRow(options: IModelJsNative.ECSqlRowAdaptorOptions): any;
/** Get column metadata directly from the prepared statement.
* Call once after `prepareAndBind` — the metadata does not change between rows.
* @param options - Native row-adaptor options that influence property naming.
* @returns Array of column metadata.
* @internal
*/
fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): QueryPropertyMetaData[];
/** Prepares the ECSql statement when the caller did not supply one from its cache.
* @param ecsql - The ECSql text to prepare.
* @returns An `OperationResult` indicating success or failure.
* @internal
*/
private prepareStmt;
/** Binds the supplied parameter values to the prepared statement.
* @param args - The parameter object to bind, or `undefined` when no parameters are needed.
* @returns An `OperationResult` indicating success or failure.
* @internal
*/
private bindValues;
}
//# sourceMappingURL=ECSqlRowExecutor.d.ts.map