import type { AsyncClient, Client, QueryArg, SyncClient } from './types.js'; /** * Returns true for statements that produce a result set. Heuristic by design; * union of sqlite and postgres row-returning keywords: * * - `select`, `with`, `explain`, `values` — both dialects. * - `pragma` — sqlite only (invalid syntax in pg; never matches a valid pg * statement so over-inclusion is harmless). * - `show`, `table`, `fetch` — pg only (invalid syntax in sqlite; same * harmless-overinclusion argument). * - …plus any write statement with a `returning` clause. * * Used by `execAdHocSql` to decide whether the UI should render rows or a * row-count summary. Strips leading comments/whitespace so a commented query * is classified by its actual first keyword. * * Try/catch on `.all()` is *not* a safe substitute: node:sqlite returns `[]` * for writes (no error to catch), and better-sqlite3 may execute partial side * effects before throwing — falling back to `.run()` would double-execute. * Keyword classification sidesteps both. */ export declare function sqlReturnsRows(sql: string): boolean; /** * Standard WHERE-clause fragment for user-table introspection queries. Excludes: * - SQLite's own internal tables (`sqlite_master`, `sqlite_sequence`, etc.). * - Cloudflare's reserved `_cf_*` prefix. Workerd's D1 binding emits a warning * for any identifier matching this prefix case-insensitively. Backslash-escape * `_` so it matches literally instead of as LIKE's single-char wildcard. * https://developers.cloudflare.com/d1/reference/database-size/#internal-metadata */ export declare const excludeReservedSqliteObjects = "name not like 'sqlite\\_%' escape '\\' and name not like '\\_cf\\_%' escape '\\'"; export declare function extractSchema(client: Client, schemaName?: string, input?: { excludedTables?: string[]; }): Promise; export type SqliteSchemaFingerprint = { tables: { name: string; columns: { name: string; type: string; notNull: boolean; defaultValue: string | null; primaryKeyPosition: number; hidden: number; }[]; indexes: { unique: boolean; origin: string; partial: boolean; columns: string[]; }[]; }[]; views: { name: string; sql: string; }[]; }; export declare function inspectSchemaFingerprint(client: Client, schemaName?: string, input?: { excludedTables?: string[]; }): Promise; export declare function rawSqlWithSqlSplittingSync(runOne: (query: { sql: string; args: QueryArg[]; }) => { rowsAffected?: number; lastInsertRowid?: string | number | bigint | null; }, sql: string): { rowsAffected?: number; lastInsertRowid?: string | number | bigint | null; }; export declare function rawSqlWithSqlSplittingAsync(runOne: (query: { sql: string; args: QueryArg[]; }) => Promise<{ rowsAffected?: number; lastInsertRowid?: string | number | bigint | null; }>, sql: string): Promise<{ rowsAffected?: number; lastInsertRowid?: string | number | bigint | null; }>; export declare function splitSqlStatements(sql: string): string[]; export declare function surroundWithBeginCommitRollbackSync(client: SyncClient, fn: (tx: SyncClient) => TResult): TResult; export declare function surroundWithBeginCommitRollbackSync(client: SyncClient, fn: (tx: SyncClient) => Promise): Promise; export declare function surroundWithBeginCommitRollbackAsync(client: AsyncClient, fn: (tx: AsyncClient) => Promise | TResult): Promise;