@crvouga/sqlite-mem 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -216,7 +216,7 @@ Goal: drop-in SQL behavior vs SQLite **3.51.0**. Full matrix: [COMPATIBILITY.md]
216
216
  - FTS3/4/5 — largely implemented; shadow-table change counters intentionally diverge; some edges partial
217
217
  - `EXPLAIN` / `EXPLAIN QUERY PLAN` — stub shapes, not real bytecode
218
218
  - `INDEXED BY` / `NOT INDEXED` — parsed and discarded
219
- - Unknown `PRAGMA` succeeds with an empty result (SQLite-like); storage/journal/WAL pragmas N/A or no-op
219
+ - Unknown statement `PRAGMA` succeeds with an empty result (SQLite-like). All oracle-exposed `pragma_*` eponymous TVFs are supported (`SELECT * FROM pragma_table_info('t')`, bare `FROM pragma_database_list`, …), including **correlated** args such as `FROM table_list AS tl, pragma_table_info(tl.name) AS p` (Kysely SQLite introspector). Storage/journal getters return bun `:memory:`-compatible defaults.
220
220
 
221
221
  ## Common pitfalls
222
222
 
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared PRAGMA query engine used by statement-form `PRAGMA …` and `pragma_*` TVFs.
3
+ */
4
+ import type { Expr } from "../ast/nodes.js";
5
+ import { type SqlValue } from "../types/value.js";
6
+ import type { ExecutionEnv } from "./env.js";
7
+ export interface PragmaQueryResult {
8
+ columns: string[];
9
+ rows: SqlValue[][];
10
+ }
11
+ /** Oracle-exposed pragma_* TVF base names (without the `pragma_` prefix). */
12
+ export declare const PRAGMA_TVF_NAMES: readonly ["analysis_limit", "application_id", "auto_vacuum", "automatic_index", "busy_timeout", "cache_size", "cache_spill", "cell_size_check", "checkpoint_fullfsync", "collation_list", "compile_options", "count_changes", "data_version", "database_list", "default_cache_size", "defer_foreign_keys", "empty_result_callbacks", "encoding", "foreign_key_check", "foreign_key_list", "foreign_keys", "freelist_count", "full_column_names", "fullfsync", "function_list", "hard_heap_limit", "ignore_check_constraints", "index_info", "index_list", "index_xinfo", "integrity_check", "journal_mode", "journal_size_limit", "legacy_alter_table", "locking_mode", "max_page_count", "module_list", "optimize", "page_count", "page_size", "pragma_list", "query_only", "quick_check", "read_uncommitted", "recursive_triggers", "reverse_unordered_selects", "schema_version", "secure_delete", "short_column_names", "soft_heap_limit", "synchronous", "table_info", "table_list", "table_xinfo", "temp_store", "threads", "trusted_schema", "user_version", "writable_schema"];
13
+ /** Full pragma name list for `pragma_pragma_list` (includes names without TVFs). */
14
+ export declare const PRAGMA_LIST_NAMES: string[];
15
+ export declare function isPragmaTvfName(name: string): boolean;
16
+ /**
17
+ * Column names for a pragma_* TVF without evaluating arguments.
18
+ * Used by SELECT shape analysis so correlated args (e.g. `tl.name`) are not
19
+ * resolved before the outer row is bound.
20
+ */
21
+ export declare function pragmaTvfColumns(name: string): string[] | null;
22
+ /**
23
+ * Query a pragma by name with optional SQL values (TVF args or evaluated statement args).
24
+ * Read-only — writers stay in {@link executePragma}.
25
+ */
26
+ export declare function queryPragma(name: string, args: readonly SqlValue[], env: ExecutionEnv): PragmaQueryResult;
27
+ /** Evaluate a statement-form pragma argument expression to a SQL value list. */
28
+ export declare function evalPragmaArgs(expr: Expr | null, env: ExecutionEnv): SqlValue[];
29
+ export declare function evalPragmaSetValue(expr: Expr, env: ExecutionEnv): SqlValue;
30
+ export declare function coercePragmaInt(value: SqlValue): number;
31
+ export declare function coercePragmaTruthy(value: SqlValue): boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Register all oracle-exposed `pragma_*` eponymous table-valued functions.
3
+ * Imported for side effects from table-valued / select.
4
+ */
5
+ import { isPragmaTvfName } from "../executor/pragma-engine.js";
6
+ /** Idempotent registration of every oracle `pragma_*` TVF. */
7
+ export declare function ensurePragmaTvfsRegistered(): void;
8
+ export { isPragmaTvfName };
@@ -0,0 +1,11 @@
1
+ import type { ExecutionEnv, ScopeRow } from "../executor/env.js";
2
+ import type { SqlValue } from "../types/value.js";
3
+ export interface TableValuedResult {
4
+ columns: string[];
5
+ rows: ScopeRow[];
6
+ }
7
+ export type TableValuedFn = (args: SqlValue[], alias: string | null, env: ExecutionEnv) => TableValuedResult;
8
+ export declare function registerTableValuedFunction(name: string, fn: TableValuedFn): void;
9
+ export declare function getTableValuedFunction(name: string): TableValuedFn | undefined;
10
+ export declare function listRegisteredTableValuedFunctions(): string[];
11
+ export declare function hasRegisteredTableValuedFunction(name: string): boolean;
@@ -1,8 +1,13 @@
1
1
  import type { Expr } from "../ast/nodes.js";
2
2
  import type { ExecutionEnv, ScopeRow } from "../executor/env.js";
3
- export interface TableValuedResult {
4
- columns: string[];
5
- rows: ScopeRow[];
6
- }
3
+ import { registerTableValuedFunction, type TableValuedResult } from "./table-valued-registry.js";
4
+ export type { TableValuedResult };
5
+ export { registerTableValuedFunction };
6
+ /**
7
+ * Known output columns for a TVF without evaluating arguments.
8
+ * Prefer this for FROM-item shape analysis when args may be correlated.
9
+ */
10
+ export declare function tableValuedColumns(name: string): string[] | null;
7
11
  export declare function evaluateTableFunction(name: string, args: Expr[], alias: string | null, env: ExecutionEnv, scope?: ScopeRow | null, parent?: import("../expressions/context.js").EvalContext): TableValuedResult;
8
12
  export declare function listTableValuedFunctions(): string[];
13
+ export declare function hasTableValuedFunction(name: string): boolean;