@quereus/quereus 4.19.4 → 4.20.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.
Files changed (120) hide show
  1. package/README.md +257 -257
  2. package/dist/src/common/errors.d.ts +10 -0
  3. package/dist/src/common/errors.d.ts.map +1 -1
  4. package/dist/src/common/errors.js +14 -0
  5. package/dist/src/common/errors.js.map +1 -1
  6. package/dist/src/common/types.d.ts +16 -4
  7. package/dist/src/common/types.d.ts.map +1 -1
  8. package/dist/src/common/types.js.map +1 -1
  9. package/dist/src/core/database-events.d.ts.map +1 -1
  10. package/dist/src/core/database-events.js +12 -9
  11. package/dist/src/core/database-events.js.map +1 -1
  12. package/dist/src/core/database-transaction.d.ts.map +1 -1
  13. package/dist/src/core/database-transaction.js +28 -19
  14. package/dist/src/core/database-transaction.js.map +1 -1
  15. package/dist/src/core/database.d.ts +58 -6
  16. package/dist/src/core/database.d.ts.map +1 -1
  17. package/dist/src/core/database.js +185 -54
  18. package/dist/src/core/database.js.map +1 -1
  19. package/dist/src/core/param.d.ts +46 -1
  20. package/dist/src/core/param.d.ts.map +1 -1
  21. package/dist/src/core/param.js +87 -7
  22. package/dist/src/core/param.js.map +1 -1
  23. package/dist/src/core/statement.d.ts +66 -1
  24. package/dist/src/core/statement.d.ts.map +1 -1
  25. package/dist/src/core/statement.js +156 -91
  26. package/dist/src/core/statement.js.map +1 -1
  27. package/dist/src/index.d.ts +4 -4
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +5 -4
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/parser/lexer.d.ts.map +1 -1
  32. package/dist/src/parser/lexer.js +9 -3
  33. package/dist/src/parser/lexer.js.map +1 -1
  34. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
  35. package/dist/src/planner/analysis/change-scope.js +7 -20
  36. package/dist/src/planner/analysis/change-scope.js.map +1 -1
  37. package/dist/src/planner/analysis/check-extraction.d.ts +62 -0
  38. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
  39. package/dist/src/planner/analysis/check-extraction.js +19 -5
  40. package/dist/src/planner/analysis/check-extraction.js.map +1 -1
  41. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  42. package/dist/src/planner/analysis/constraint-extractor.js +7 -0
  43. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  44. package/dist/src/planner/analysis/scalar-param-usage.d.ts +6 -3
  45. package/dist/src/planner/analysis/scalar-param-usage.d.ts.map +1 -1
  46. package/dist/src/planner/analysis/scalar-param-usage.js +32 -4
  47. package/dist/src/planner/analysis/scalar-param-usage.js.map +1 -1
  48. package/dist/src/planner/building/coercion.js +1 -1
  49. package/dist/src/planner/building/coercion.js.map +1 -1
  50. package/dist/src/planner/building/schema-authored-context.d.ts +7 -7
  51. package/dist/src/planner/building/schema-authored-context.js +7 -7
  52. package/dist/src/planner/nodes/scalar.d.ts +19 -1
  53. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  54. package/dist/src/planner/nodes/scalar.js +13 -2
  55. package/dist/src/planner/nodes/scalar.js.map +1 -1
  56. package/dist/src/planner/nodes/set-operation-node.js +4 -0
  57. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  58. package/dist/src/runtime/emit/add-constraint.js +44 -1
  59. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  60. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  61. package/dist/src/runtime/emit/alter-table.js +20 -32
  62. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  63. package/dist/src/runtime/emit/ddl-event-scope.d.ts +20 -13
  64. package/dist/src/runtime/emit/ddl-event-scope.d.ts.map +1 -1
  65. package/dist/src/runtime/emit/ddl-event-scope.js +20 -13
  66. package/dist/src/runtime/emit/ddl-event-scope.js.map +1 -1
  67. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  68. package/dist/src/runtime/emit/materialized-view-helpers.js +9 -4
  69. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  70. package/dist/src/runtime/emit/parameter.d.ts.map +1 -1
  71. package/dist/src/runtime/emit/parameter.js +13 -8
  72. package/dist/src/runtime/emit/parameter.js.map +1 -1
  73. package/dist/src/runtime/emit/schema-declarative.d.ts +17 -6
  74. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  75. package/dist/src/runtime/emit/schema-declarative.js +169 -31
  76. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  77. package/dist/src/schema/catalog-rendering.d.ts +26 -0
  78. package/dist/src/schema/catalog-rendering.d.ts.map +1 -1
  79. package/dist/src/schema/catalog-rendering.js +54 -5
  80. package/dist/src/schema/catalog-rendering.js.map +1 -1
  81. package/dist/src/schema/catalog.d.ts +58 -2
  82. package/dist/src/schema/catalog.d.ts.map +1 -1
  83. package/dist/src/schema/catalog.js +45 -34
  84. package/dist/src/schema/catalog.js.map +1 -1
  85. package/dist/src/schema/constraint-builder.d.ts +67 -11
  86. package/dist/src/schema/constraint-builder.d.ts.map +1 -1
  87. package/dist/src/schema/constraint-builder.js +115 -12
  88. package/dist/src/schema/constraint-builder.js.map +1 -1
  89. package/dist/src/schema/ddl-generator.d.ts +21 -0
  90. package/dist/src/schema/ddl-generator.d.ts.map +1 -1
  91. package/dist/src/schema/ddl-generator.js +7 -1
  92. package/dist/src/schema/ddl-generator.js.map +1 -1
  93. package/dist/src/schema/rename/self-qualifier-strip.d.ts +27 -0
  94. package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -1
  95. package/dist/src/schema/rename/self-qualifier-strip.js +73 -0
  96. package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -1
  97. package/dist/src/schema/rename-rewriter.d.ts +5 -5
  98. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  99. package/dist/src/schema/rename-rewriter.js +5 -5
  100. package/dist/src/schema/rename-rewriter.js.map +1 -1
  101. package/dist/src/schema/schema-differ.d.ts +42 -2
  102. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  103. package/dist/src/schema/schema-differ.js +722 -67
  104. package/dist/src/schema/schema-differ.js.map +1 -1
  105. package/dist/src/schema/unique-enforcement.d.ts +23 -1
  106. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  107. package/dist/src/schema/unique-enforcement.js +43 -1
  108. package/dist/src/schema/unique-enforcement.js.map +1 -1
  109. package/dist/src/types/temporal-ops.d.ts.map +1 -1
  110. package/dist/src/types/temporal-ops.js +16 -10
  111. package/dist/src/types/temporal-ops.js.map +1 -1
  112. package/dist/src/vtab/capabilities.d.ts +5 -2
  113. package/dist/src/vtab/capabilities.d.ts.map +1 -1
  114. package/dist/src/vtab/memory/layer/manager.d.ts +30 -23
  115. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  116. package/dist/src/vtab/memory/layer/manager.js +102 -111
  117. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  118. package/dist/src/vtab/module.d.ts +16 -0
  119. package/dist/src/vtab/module.d.ts.map +1 -1
  120. package/package.json +3 -3
package/README.md CHANGED
@@ -1,257 +1,257 @@
1
- # Quereus - A TypeScript SQL Query Processor
2
-
3
- <img src="../../docs/images/Quereus_colored_wide.svg" alt="Quereus Logo" height="150">
4
-
5
- > **Stability** — this package spans tiers: the core SQL engine, type system, and
6
- > virtual-table framework are **Stable**, while other feature areas are Beta or
7
- > Experimental. See [Stability](#stability) below and
8
- > [Stability Tiers](../../docs/stability.md#tiers) for the per-area assignment.
9
-
10
- Quereus is a feature-complete SQL query processor specifically designed for efficient in-memory data processing with a strong emphasis on the **virtual table** interface. It provides rich SQL query and constraint capabilities (joins, aggregates, subqueries, CTEs, window functions, constraints) over data sources exposed via the virtual table mechanism. Quereus features a modern type system with temporal types, JSON support, and plugin-extensible custom types. It has no persistent file storage, though one could be built as a virtual table module.
11
-
12
- ## Project Goals
13
-
14
- * **Virtual Table Centric** — provide a robust and flexible virtual table API as the primary means of interacting with data sources. All tables are virtual tables.
15
- * **In-Memory Default** — includes a comprehensive in-memory virtual table implementation (`MemoryTable`) with support for transactions and savepoints.
16
- * **Modern Type System** — extensible logical/physical type separation with built-in temporal types (DATE, TIME, DATETIME), native JSON type with deep equality comparison, and plugin support for custom types. See [Type System Documentation](../../docs/types.md).
17
- * **TypeScript & Modern JS** — leverage TypeScript's type system and modern JavaScript features and idioms.
18
- * **Async VTab Operations** — virtual table data operations (reads/writes) are asynchronous. Cursors are implemented as async iterables.
19
- * **Cross-Platform** — target diverse Javascript runtime environments, including Node.js, browser, and React Native. Plugin loading (via `@quereus/plugin-loader`) uses dynamic `import()` and is not compatible with React Native; use static imports for RN.
20
- * **Minimal Dependencies** — avoid heavy external dependencies where possible.
21
- * **SQL Compatibility** — comprehensive support for modern SQL features including joins, window functions, subqueries, CTEs, constraints, views, and advanced DML/DDL operations.
22
- * **Key-Based Addressing** — all tables are addressed by their defined Primary Key. The concept of a separate, implicit `rowid` for addressing rows is not used.
23
- * **Third Manifesto Friendly** — embraces some of the principles of the [Third Manifesto](https://www.dcs.warwick.ac.uk/~hugh/TTM/DTATRM.pdf), such as allowing for empty keys. Utilizes algebraic planning.
24
-
25
- ## Quick Start
26
-
27
- ```typescript
28
- import { Database } from '@quereus/quereus';
29
-
30
- const db = new Database();
31
-
32
- // Create a table and insert data
33
- await db.exec("create table users (id integer primary key, name text, email text)");
34
- await db.exec("insert into users values (1, 'Alice', 'alice@example.com')");
35
-
36
- // Query returns objects: { id: 1, name: 'Alice', email: 'alice@example.com' }
37
- const user = await db.get("select * from users where id = ?", [1]);
38
- console.log(user.name); // "Alice"
39
-
40
- // Iterate over multiple rows
41
- for await (const row of db.eval("select * from users")) {
42
- console.log(row.name);
43
- }
44
- ```
45
-
46
- ### Reactive Patterns with Event Hooks
47
-
48
- ```typescript
49
- import { Database } from '@quereus/quereus';
50
-
51
- const db = new Database();
52
-
53
- // Subscribe to data changes at the database level
54
- db.onDataChange((event) => {
55
- console.log(`${event.type} on ${event.tableName} (module: ${event.moduleName})`);
56
- if (event.remote) {
57
- console.log('Change came from remote sync');
58
- }
59
- if (event.type === 'update') {
60
- console.log('Changed columns:', event.changedColumns);
61
- }
62
- });
63
-
64
- // Subscribe to schema changes
65
- db.onSchemaChange((event) => {
66
- console.log(`${event.type} ${event.objectType}: ${event.objectName}`);
67
- });
68
-
69
- // Events fire after commit
70
- await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
71
- // Output: create table: users
72
-
73
- await db.exec("INSERT INTO users VALUES (1, 'Alice')");
74
- // Output: insert on users (module: memory)
75
- ```
76
-
77
- The database-level event system aggregates events from all modules automatically. Events are batched within transactions and delivered only after successful commit.
78
-
79
- SQL values use native JavaScript types (`string`, `number`, `bigint`, `Uint8Array`, `null`). Temporal types are ISO 8601 strings. Results stream as async iterators.
80
-
81
- See the [Usage Guide](../../docs/usage.md) for complete API reference and [Database-Level Event System](../../docs/module-events.md) for event system details.
82
-
83
- ## Platform Support & Storage
84
-
85
- Quereus runs on any JavaScript runtime. For persistent storage, platform-specific plugins provide the `store` virtual table module:
86
-
87
- ### Node.js
88
-
89
- Use [`@quereus/plugin-leveldb`](../quereus-plugin-leveldb/) for LevelDB-based persistent storage with full transaction isolation. Each table becomes a subdirectory under `basePath`:
90
-
91
- ```typescript
92
- import { Database, registerPlugin } from '@quereus/quereus';
93
- import leveldbPlugin from '@quereus/plugin-leveldb/plugin';
94
-
95
- const db = new Database();
96
- await registerPlugin(db, leveldbPlugin, { basePath: './data' }); // ./data/users/, ./data/orders/, etc.
97
-
98
- await db.exec(`create table users (id integer primary key, name text) using store`);
99
-
100
- // Full transaction isolation enabled by default
101
- await db.exec('BEGIN');
102
- await db.exec(`INSERT INTO users VALUES (1, 'Alice')`);
103
- const user = await db.get('SELECT * FROM users WHERE id = 1'); // Sees uncommitted insert
104
- await db.exec('COMMIT');
105
- ```
106
-
107
- ### Browser
108
-
109
- Use [`@quereus/plugin-indexeddb`](../quereus-plugin-indexeddb/) for IndexedDB-based persistent storage with cross-tab sync and full transaction isolation. All tables share one IndexedDB database:
110
-
111
- ```typescript
112
- import { Database, registerPlugin } from '@quereus/quereus';
113
- import indexeddbPlugin from '@quereus/plugin-indexeddb/plugin';
114
-
115
- const db = new Database();
116
- await registerPlugin(db, indexeddbPlugin, { databaseName: 'myapp' }); // IndexedDB database name
117
-
118
- await db.exec(`create table users (id integer primary key, name text) using store`);
119
- ```
120
-
121
- ### React Native
122
-
123
- Use [`@quereus/plugin-react-native-leveldb`](../quereus-plugin-react-native-leveldb/) for fast LevelDB storage with full transaction isolation. Each table becomes a separate LevelDB database with a name prefix:
124
-
125
- ```typescript
126
- import { LevelDB, LevelDBWriteBatch } from 'react-native-leveldb';
127
- import { Database, registerPlugin } from '@quereus/quereus';
128
- import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
129
-
130
- const db = new Database();
131
- await registerPlugin(db, leveldbPlugin, {
132
- openFn: LevelDB.open,
133
- WriteBatch: LevelDBWriteBatch,
134
- databaseName: 'myapp' // creates myapp_users, myapp_orders, etc.
135
- });
136
-
137
- await db.exec(`create table users (id integer primary key, name text) using store`);
138
- ```
139
-
140
- **Note:** React Native requires runtime polyfills and static plugin loading. See the [plugin README](../quereus-plugin-react-native-leveldb/) for setup details.
141
-
142
- **Required polyfills:**
143
- - `structuredClone` (Quereus uses it internally)
144
- - `TextEncoder` / `TextDecoder` (used by store plugins)
145
- - `Symbol.asyncIterator` (required for async-iterable support; Quereus has a Hermes workaround for AsyncGenerator iterables, but the symbol must exist)
146
-
147
- **Babel helpers:** Metro lowers async generators through Babel's `wrapAsyncGenerator` helper. Before `@babel/helpers` / `@babel/runtime` **7.29.2** that helper drops the rest of a `finally` block after its first `await` when iteration stops early (`break` / `return` inside `for await`), which would leave the database's execution lock held forever. Quereus probes for this before the first statement runs and throws an `UNSUPPORTED` error naming the fix; keep both packages at 7.29.2 or later (`yarn up '@babel/runtime@^7.29.2' '@babel/helpers@^7.29.2'` — a bare `yarn up` jumps to Babel 8; then restart Metro with `--reset-cache`).
148
-
149
- ### NativeScript
150
-
151
- Use [`@quereus/plugin-nativescript-sqlite`](../quereus-plugin-nativescript-sqlite/) for SQLite-based storage with full transaction isolation. All tables share one SQLite database file:
152
-
153
- ```typescript
154
- import { openOrCreate } from '@nativescript-community/sqlite';
155
- import { Database, registerPlugin } from '@quereus/quereus';
156
- import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
157
-
158
- const sqliteDb = openOrCreate('myapp.db'); // SQLite database file
159
- const db = new Database();
160
- await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
161
-
162
- await db.exec(`create table users (id integer primary key, name text) using store`);
163
- ```
164
-
165
- See [Store Documentation](../../docs/store.md) for the storage architecture and custom backend implementation.
166
-
167
- ## Documentation
168
-
169
- **Architecture deep dive:** [Architecture](../../docs/architecture.md) — the pipeline (parser → planner → runtime), source layout, extension patterns, design decisions, constraints model, and testing strategy. Start here if you're working on the engine itself.
170
-
171
- **User & operator docs:**
172
- * [Stability Tiers](../../docs/stability.md) — what each tier promises, and which feature areas are Stable, Beta, Experimental, or Internal
173
- * [Usage Guide](../../docs/usage.md) — complete API reference (type mappings, parameter binding, logging, tracing, transactions)
174
- * [SQL Reference Guide](../../docs/sql.md) — SQL syntax (includes Declarative Schema)
175
- * [Schema Management](../../docs/schema.md) — SchemaManager API, change events, key types, DDL generation. Deep dives: [rename detection and body-change detection](../../docs/schema-rename-detection.md), [view and materialized-view persistence](../../docs/view-persistence.md)
176
- * [View Updateability](../../docs/view-updateability.md) — write-through for views, CTEs, and subqueries-in-FROM; per-operator semantics and override tags
177
- * [Materialized Views](../../docs/materialized-views.md) — keyed derived relations, DDL, query resolution, write-through, declarative-schema round-trip. Deep dives: [maintenance](../../docs/mv-maintenance.md), [derived-row constraints and covering structures](../../docs/mv-constraints.md), [external row-change ingestion](../../docs/mv-ingestion.md), [schema-change staleness](../../docs/mv-schema-change.md), [the backing-host capability](../../docs/mv-backing-host.md)
178
- * [Lenses and Layered Schemas](../../docs/lens.md) — logical/basis separation and bidirectional per-table lenses
179
- * [Schema Migration in a Synced Database](../../docs/migration.md) — evolving schemas across replicated peers with lenses and maintained basis tables
180
- * [Type System](../../docs/types.md) — logical/physical types, temporal types, JSON, custom types
181
- * [Functions](../../docs/functions.md) — built-in scalar, aggregate, window, and JSON functions
182
- * [Memory Tables](../../docs/memory-table.md) — built-in MemoryTable module
183
- * [Module Authoring](../../docs/module-authoring.md) — virtual table module development. Deep dive: [capability negotiation](../../docs/module-capabilities.md) — every negotiation surface, DDL transactionality tiers, per-arm `alterTable` mandates
184
- * [Database-Level Event System](../../docs/module-events.md) — data and schema change events
185
- * [Date/Time Handling](../../docs/datetime.md) — temporal parsing, functions, and ISO 8601 formats
186
- * [Runtime](../../docs/runtime.md) — instruction-based execution and opcodes
187
- * [Error Handling](../../docs/errors.md) — error types and status codes
188
- * [Plugin System](../../docs/plugins.md) — virtual tables, functions, and collations
189
- * [Optimizer](../../docs/optimizer.md) — hub; topic docs for [Rules](../../docs/optimizer-rules.md), [Rule Families](../../docs/optimizer-rule-families.md), [Joins](../../docs/optimizer-joins.md), [Retrieve Push-down](../../docs/optimizer-retrieve.md), [Streaming](../../docs/optimizer-streaming.md), [Parallel](../../docs/optimizer-parallel.md), [Assertions](../../docs/optimizer-assertions.md), [Functional Dependencies](../../docs/optimizer-fd.md), [Visited Tracking](../../docs/optimizer-visited-tracking.md), [Conventions](../../docs/optimizer-conventions.md)
190
- * [Change-scope Introspection](../../docs/change-scope.md) — what a prepared statement reads from
191
- * [TODO List](../../docs/todo.md) — planned features
192
-
193
- ### Plugin Development
194
-
195
- Quereus exports all critical utilities needed for plugin and module development:
196
-
197
- * **Comparison Functions** — `compareSqlValues`, `compareRows`, `compareTypedValues`, `createTypedComparator` — match Quereus SQL semantics in custom implementations
198
- * **Coercion Utilities** — `tryCoerceToNumber`, `coerceForAggregate` — handle type coercion for aggregates and arithmetic
199
- * **Collation Support** — collations are registered per database with `db.registerCollation(name, func, options?)` and resolved through `db.getCollationResolver()`; the built-ins `BINARY`, `NOCASE`, and `RTRIM` are always present. Naming an unregistered collation raises `no such collation sequence`
200
- * **Type System** — full access to logical types, validation, and parsing utilities
201
- * **Event Hooks** — `VTableEventEmitter` interface for mutation and schema change events; enable reactive patterns, caching, and replication
202
- * **DDL Generation** — `generateTableDDL(tableSchema, db?)`, `generateIndexDDL(indexSchema, tableSchema, db?)` — canonical `CREATE TABLE` / `CREATE INDEX` output from runtime schema objects. With a `Database`, matches session defaults (schema qualification, `default_column_nullability`, `default_vtab_module`/`default_vtab_args`) for readable output; without one, emits fully-qualified, explicitly-annotated DDL safe for cross-session persistence. See [Schema Management — DDL Generation](../../docs/schema.md#ddl-generation).
203
-
204
- See the [Plugin System documentation](../../docs/plugins.md#comparison-and-coercion-utilities) for complete API reference and examples.
205
-
206
- ## Current Status
207
-
208
- Quereus is a feature-complete SQL query processor with a modern planner and instruction-based runtime architecture. The engine successfully handles complex SQL workloads including joins, window functions, subqueries, CTEs, constraints, and comprehensive DML/DDL operations.
209
-
210
- ### Stability
211
-
212
- Quereus spans a battle-tested SQL core and several research tracks. Every feature area
213
- carries one of four tiers, which say how much a future release may break you:
214
-
215
- | Tier | A breaking change may land in | In short |
216
- | --- | --- | --- |
217
- | **Stable** | a major release only | Build on it. |
218
- | **Beta** | a minor release | Complete and tested; the surface is still being shaped. |
219
- | **Experimental** | **any** release, including a patch | A research track. Prototype on it; expect churn. |
220
- | **Internal** | any release | Engine internals — no user-facing contract. |
221
-
222
- A tier is about compatibility, not correctness: a wrong answer is a bug at every tier,
223
- including Experimental. See [Stability Tiers](../../docs/stability.md) for the definitions
224
- and the per-area assignment.
225
-
226
- ### Capabilities
227
-
228
- * **Modern Type System** — temporal types (DATE, TIME, DATETIME), JSON with deep equality, plugin-extensible custom types
229
- * **Complete JOIN support** — INNER, LEFT, RIGHT, CROSS, SEMI, and ANTI joins with proper NULL padding
230
- * **Advanced window functions** — ranking, aggregates, and frame specifications
231
- * **Full constraint system** — NOT NULL, CHECK, FOREIGN KEY, and CREATE ASSERTION. Row-level constraints that reference other tables are automatically deferred to COMMIT. The `committed.tablename` pseudo-schema provides read-only access to pre-transaction state for transition constraints (e.g., "balance may not decrease"). See [Architecture — Constraints](../../docs/architecture.md#constraints).
232
- * **Comprehensive subqueries** — scalar, correlated, EXISTS, and IN subqueries
233
- * **Relational orthogonality** — INSERT/UPDATE/DELETE with RETURNING can be used as table sources
234
- * **Complete set operations** — UNION, INTERSECT, EXCEPT with proper deduplication
235
- * **DIFF (symmetric difference)** — `A diff B` equals `(A except B) union (B except A)`, handy for table equality checks via `not exists(A diff B)`
236
- * **Robust transaction support** — multi-level savepoints and rollback. See [Usage Guide](../../docs/usage.md#transactions) for details
237
- * **Rich built-in function library** — scalar, aggregate, window, JSON, and date/time functions
238
- * **Rule-based optimizer** — constant folding, caching, streaming aggregation, bloom-join selection, and correlated subquery decorrelation. See [Architecture — Optimizer](../../docs/architecture.md#optimizer).
239
- * **Change-scope introspection and reactive subscriptions** — `Statement.getChangeScope()` returns a JSON-serializable description of what base-table state and external inputs a prepared statement reads from. The companion `Database.watch(scope, handler)` consumes any `ChangeScope` value (analyzed, deserialized, or hand-built) and fires a post-commit callback whenever matching rows, groups, or tables change. See [Change-scope Documentation](../../docs/change-scope.md).
240
- * **Updatable views** *(Beta)* — `insert` / `update` / `delete` propagate through views, non-recursive CTEs, and subqueries in `from` to the underlying base tables (no `instead of` triggers; predicate-driven). Single-source projection-and-filter and multi-source key-preserving inner-join bodies are supported, with `returning`, the core-`select` `with defaults (col = expr, …)` and `with inverse (col = expr, …)` clauses (omitted-insert defaults and authored write-back expressions, both riding the body select), and per-row writable presence/membership columns for write routing. See [View Updateability](../../docs/view-updateability.md).
241
- * **Materialized views** *(Beta)* — `create materialized view` stores a query body as a keyed backing relation kept consistent with its sources **synchronously, inside the writing transaction** (row-time maintenance — no refresh-policy knob, reads-own-writes), with write-through DML and covering-structure constraint enforcement. See [Materialized Views](../../docs/materialized-views.md).
242
- * **Logical schemas and lenses** *(Experimental)* — separate an embodiment-free logical design from a module-backed basis, mapped by per-table bidirectional **lenses** built on view updateability. See [Lenses and Layered Schemas](../../docs/lens.md).
243
-
244
- [TODO List](../../docs/todo.md) has remaining priorities.
245
-
246
- ## Supported Built-in Functions
247
-
248
- * **Scalar** — `lower`, `upper`, `length`, `substr`/`substring`, `abs`, `round`, `coalesce`, `nullif`, `like`, `glob`, `typeof`
249
- * **Aggregate** — `count`, `sum`, `avg`, `min`, `max`, `group_concat`, `json_group_array`, `json_group_object`
250
- * **Window Functions** — complete implementation with `row_number`, `rank`, `dense_rank`, `ntile` (ranking); `count`, `sum`, `avg`, `min`, `max` with OVER clause (aggregates); full frame specification support (`ROWS BETWEEN`, `UNBOUNDED PRECEDING/FOLLOWING`); `NULLS FIRST/LAST` ordering
251
- * **Date/Time** — `date`, `time`, `datetime`, `julianday`, `strftime` (supports common formats and modifiers), `epoch_s`, `epoch_ms`, `epoch_s_frac` (Unix epoch conversions with strict parsing)
252
- * **JSON** — `json_valid`, `json_schema`, `json_type`, `json_extract`, `json_quote`, `json_array`, `json_object`, `json_insert`, `json_replace`, `json_set`, `json_remove`, `json_array_length`, `json_patch`
253
- * **Query Analysis** — `query_plan`, `scheduler_program`, `execution_trace` (debugging and performance analysis)
254
-
255
- ## Testing
256
-
257
- Tests live in `test/*.spec.ts`, driven by Mocha with ts-node/esm. Run with `yarn test`. Quereus uses SQL logic tests (primary), property-based tests, performance sentinels, unit tests, and a benchmark suite — see [Architecture — Testing Strategy](../../docs/architecture.md#testing-strategy) for details.
1
+ # Quereus - A TypeScript SQL Query Processor
2
+
3
+ <img src="../../docs/images/Quereus_colored_wide.svg" alt="Quereus Logo" height="150">
4
+
5
+ > **Stability** — this package spans tiers: the core SQL engine, type system, and
6
+ > virtual-table framework are **Stable**, while other feature areas are Beta or
7
+ > Experimental. See [Stability](#stability) below and
8
+ > [Stability Tiers](../../docs/stability.md#tiers) for the per-area assignment.
9
+
10
+ Quereus is a feature-complete SQL query processor specifically designed for efficient in-memory data processing with a strong emphasis on the **virtual table** interface. It provides rich SQL query and constraint capabilities (joins, aggregates, subqueries, CTEs, window functions, constraints) over data sources exposed via the virtual table mechanism. Quereus features a modern type system with temporal types, JSON support, and plugin-extensible custom types. It has no persistent file storage, though one could be built as a virtual table module.
11
+
12
+ ## Project Goals
13
+
14
+ * **Virtual Table Centric** — provide a robust and flexible virtual table API as the primary means of interacting with data sources. All tables are virtual tables.
15
+ * **In-Memory Default** — includes a comprehensive in-memory virtual table implementation (`MemoryTable`) with support for transactions and savepoints.
16
+ * **Modern Type System** — extensible logical/physical type separation with built-in temporal types (DATE, TIME, DATETIME), native JSON type with deep equality comparison, and plugin support for custom types. See [Type System Documentation](../../docs/types.md).
17
+ * **TypeScript & Modern JS** — leverage TypeScript's type system and modern JavaScript features and idioms.
18
+ * **Async VTab Operations** — virtual table data operations (reads/writes) are asynchronous. Cursors are implemented as async iterables.
19
+ * **Cross-Platform** — target diverse Javascript runtime environments, including Node.js, browser, and React Native. Plugin loading (via `@quereus/plugin-loader`) uses dynamic `import()` and is not compatible with React Native; use static imports for RN.
20
+ * **Minimal Dependencies** — avoid heavy external dependencies where possible.
21
+ * **SQL Compatibility** — comprehensive support for modern SQL features including joins, window functions, subqueries, CTEs, constraints, views, and advanced DML/DDL operations.
22
+ * **Key-Based Addressing** — all tables are addressed by their defined Primary Key. The concept of a separate, implicit `rowid` for addressing rows is not used.
23
+ * **Third Manifesto Friendly** — embraces some of the principles of the [Third Manifesto](https://www.dcs.warwick.ac.uk/~hugh/TTM/DTATRM.pdf), such as allowing for empty keys. Utilizes algebraic planning.
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { Database } from '@quereus/quereus';
29
+
30
+ const db = new Database();
31
+
32
+ // Create a table and insert data
33
+ await db.exec("create table users (id integer primary key, name text, email text)");
34
+ await db.exec("insert into users values (1, 'Alice', 'alice@example.com')");
35
+
36
+ // Query returns objects: { id: 1, name: 'Alice', email: 'alice@example.com' }
37
+ const user = await db.get("select * from users where id = ?", [1]);
38
+ console.log(user.name); // "Alice"
39
+
40
+ // Iterate over multiple rows
41
+ for await (const row of db.eval("select * from users")) {
42
+ console.log(row.name);
43
+ }
44
+ ```
45
+
46
+ ### Reactive Patterns with Event Hooks
47
+
48
+ ```typescript
49
+ import { Database } from '@quereus/quereus';
50
+
51
+ const db = new Database();
52
+
53
+ // Subscribe to data changes at the database level
54
+ db.onDataChange((event) => {
55
+ console.log(`${event.type} on ${event.tableName} (module: ${event.moduleName})`);
56
+ if (event.remote) {
57
+ console.log('Change came from remote sync');
58
+ }
59
+ if (event.type === 'update') {
60
+ console.log('Changed columns:', event.changedColumns);
61
+ }
62
+ });
63
+
64
+ // Subscribe to schema changes
65
+ db.onSchemaChange((event) => {
66
+ console.log(`${event.type} ${event.objectType}: ${event.objectName}`);
67
+ });
68
+
69
+ // Events fire after commit
70
+ await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
71
+ // Output: create table: users
72
+
73
+ await db.exec("INSERT INTO users VALUES (1, 'Alice')");
74
+ // Output: insert on users (module: memory)
75
+ ```
76
+
77
+ The database-level event system aggregates events from all modules automatically. Events are batched within transactions and delivered only after successful commit.
78
+
79
+ SQL values use native JavaScript types (`string`, `number`, `bigint`, `Uint8Array`, `null`). Temporal types are ISO 8601 strings. Results stream as async iterators.
80
+
81
+ See the [Usage Guide](../../docs/usage.md) for complete API reference and [Database-Level Event System](../../docs/module-events.md) for event system details.
82
+
83
+ ## Platform Support & Storage
84
+
85
+ Quereus runs on any JavaScript runtime. For persistent storage, platform-specific plugins provide the `store` virtual table module:
86
+
87
+ ### Node.js
88
+
89
+ Use [`@quereus/plugin-leveldb`](../quereus-plugin-leveldb/) for LevelDB-based persistent storage with full transaction isolation. Each table becomes a subdirectory under `basePath`:
90
+
91
+ ```typescript
92
+ import { Database, registerPlugin } from '@quereus/quereus';
93
+ import leveldbPlugin from '@quereus/plugin-leveldb/plugin';
94
+
95
+ const db = new Database();
96
+ await registerPlugin(db, leveldbPlugin, { basePath: './data' }); // ./data/users/, ./data/orders/, etc.
97
+
98
+ await db.exec(`create table users (id integer primary key, name text) using store`);
99
+
100
+ // Full transaction isolation enabled by default
101
+ await db.exec('BEGIN');
102
+ await db.exec(`INSERT INTO users VALUES (1, 'Alice')`);
103
+ const user = await db.get('SELECT * FROM users WHERE id = 1'); // Sees uncommitted insert
104
+ await db.exec('COMMIT');
105
+ ```
106
+
107
+ ### Browser
108
+
109
+ Use [`@quereus/plugin-indexeddb`](../quereus-plugin-indexeddb/) for IndexedDB-based persistent storage with cross-tab sync and full transaction isolation. All tables share one IndexedDB database:
110
+
111
+ ```typescript
112
+ import { Database, registerPlugin } from '@quereus/quereus';
113
+ import indexeddbPlugin from '@quereus/plugin-indexeddb/plugin';
114
+
115
+ const db = new Database();
116
+ await registerPlugin(db, indexeddbPlugin, { databaseName: 'myapp' }); // IndexedDB database name
117
+
118
+ await db.exec(`create table users (id integer primary key, name text) using store`);
119
+ ```
120
+
121
+ ### React Native
122
+
123
+ Use [`@quereus/plugin-react-native-leveldb`](../quereus-plugin-react-native-leveldb/) for fast LevelDB storage with full transaction isolation. Each table becomes a separate LevelDB database with a name prefix:
124
+
125
+ ```typescript
126
+ import { LevelDB, LevelDBWriteBatch } from 'react-native-leveldb';
127
+ import { Database, registerPlugin } from '@quereus/quereus';
128
+ import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
129
+
130
+ const db = new Database();
131
+ await registerPlugin(db, leveldbPlugin, {
132
+ openFn: LevelDB.open,
133
+ WriteBatch: LevelDBWriteBatch,
134
+ databaseName: 'myapp' // creates myapp_users, myapp_orders, etc.
135
+ });
136
+
137
+ await db.exec(`create table users (id integer primary key, name text) using store`);
138
+ ```
139
+
140
+ **Note:** React Native requires runtime polyfills and static plugin loading. See the [plugin README](../quereus-plugin-react-native-leveldb/) for setup details.
141
+
142
+ **Required polyfills:**
143
+ - `structuredClone` (Quereus uses it internally)
144
+ - `TextEncoder` / `TextDecoder` (used by store plugins)
145
+ - `Symbol.asyncIterator` (required for async-iterable support; Quereus has a Hermes workaround for AsyncGenerator iterables, but the symbol must exist)
146
+
147
+ **Babel helpers:** Metro lowers async generators through Babel's `wrapAsyncGenerator` helper. Before `@babel/helpers` / `@babel/runtime` **7.29.2** that helper drops the rest of a `finally` block after its first `await` when iteration stops early (`break` / `return` inside `for await`), which would leave the database's execution lock held forever. Quereus probes for this before the first statement runs and throws an `UNSUPPORTED` error naming the fix; keep both packages at 7.29.2 or later (`yarn up '@babel/runtime@^7.29.2' '@babel/helpers@^7.29.2'` — a bare `yarn up` jumps to Babel 8; then restart Metro with `--reset-cache`).
148
+
149
+ ### NativeScript
150
+
151
+ Use [`@quereus/plugin-nativescript-sqlite`](../quereus-plugin-nativescript-sqlite/) for SQLite-based storage with full transaction isolation. All tables share one SQLite database file:
152
+
153
+ ```typescript
154
+ import { openOrCreate } from '@nativescript-community/sqlite';
155
+ import { Database, registerPlugin } from '@quereus/quereus';
156
+ import sqlitePlugin from '@quereus/plugin-nativescript-sqlite/plugin';
157
+
158
+ const sqliteDb = openOrCreate('myapp.db'); // SQLite database file
159
+ const db = new Database();
160
+ await registerPlugin(db, sqlitePlugin, { db: sqliteDb });
161
+
162
+ await db.exec(`create table users (id integer primary key, name text) using store`);
163
+ ```
164
+
165
+ See [Store Documentation](../../docs/store.md) for the storage architecture and custom backend implementation.
166
+
167
+ ## Documentation
168
+
169
+ **Architecture deep dive:** [Architecture](../../docs/architecture.md) — the pipeline (parser → planner → runtime), source layout, extension patterns, design decisions, constraints model, and testing strategy. Start here if you're working on the engine itself.
170
+
171
+ **User & operator docs:**
172
+ * [Stability Tiers](../../docs/stability.md) — what each tier promises, and which feature areas are Stable, Beta, Experimental, or Internal
173
+ * [Usage Guide](../../docs/usage.md) — complete API reference (type mappings, parameter binding, logging, tracing, transactions)
174
+ * [SQL Reference Guide](../../docs/sql.md) — SQL syntax (includes Declarative Schema)
175
+ * [Schema Management](../../docs/schema.md) — SchemaManager API, change events, key types, DDL generation. Deep dives: [rename detection and body-change detection](../../docs/schema-rename-detection.md), [the migration plan's undo](../../docs/schema-undo-plan.md), [view and materialized-view persistence](../../docs/view-persistence.md)
176
+ * [View Updateability](../../docs/view-updateability.md) — write-through for views, CTEs, and subqueries-in-FROM; per-operator semantics and override tags
177
+ * [Materialized Views](../../docs/materialized-views.md) — keyed derived relations, DDL, query resolution, write-through, declarative-schema round-trip. Deep dives: [maintenance](../../docs/mv-maintenance.md), [derived-row constraints and covering structures](../../docs/mv-constraints.md), [external row-change ingestion](../../docs/mv-ingestion.md), [schema-change staleness](../../docs/mv-schema-change.md), [the backing-host capability](../../docs/mv-backing-host.md)
178
+ * [Lenses and Layered Schemas](../../docs/lens.md) — logical/basis separation and bidirectional per-table lenses
179
+ * [Schema Migration in a Synced Database](../../docs/migration.md) — evolving schemas across replicated peers with lenses and maintained basis tables
180
+ * [Type System](../../docs/types.md) — logical/physical types, temporal types, JSON, custom types
181
+ * [Functions](../../docs/functions.md) — built-in scalar, aggregate, window, and JSON functions
182
+ * [Memory Tables](../../docs/memory-table.md) — built-in MemoryTable module
183
+ * [Module Authoring](../../docs/module-authoring.md) — virtual table module development. Deep dive: [capability negotiation](../../docs/module-capabilities.md) — every negotiation surface, DDL transactionality tiers, per-arm `alterTable` mandates
184
+ * [Database-Level Event System](../../docs/module-events.md) — data and schema change events
185
+ * [Date/Time Handling](../../docs/datetime.md) — temporal parsing, functions, and ISO 8601 formats
186
+ * [Runtime](../../docs/runtime.md) — instruction-based execution and opcodes
187
+ * [Error Handling](../../docs/errors.md) — error types and status codes
188
+ * [Plugin System](../../docs/plugins.md) — virtual tables, functions, and collations
189
+ * [Optimizer](../../docs/optimizer.md) — hub; topic docs for [Rules](../../docs/optimizer-rules.md), [Rule Families](../../docs/optimizer-rule-families.md), [Joins](../../docs/optimizer-joins.md), [Retrieve Push-down](../../docs/optimizer-retrieve.md), [Streaming](../../docs/optimizer-streaming.md), [Parallel](../../docs/optimizer-parallel.md), [Assertions](../../docs/optimizer-assertions.md), [Functional Dependencies](../../docs/optimizer-fd.md), [Visited Tracking](../../docs/optimizer-visited-tracking.md), [Conventions](../../docs/optimizer-conventions.md)
190
+ * [Change-scope Introspection](../../docs/change-scope.md) — what a prepared statement reads from
191
+ * [TODO List](../../docs/todo.md) — planned features
192
+
193
+ ### Plugin Development
194
+
195
+ Quereus exports all critical utilities needed for plugin and module development:
196
+
197
+ * **Comparison Functions** — `compareSqlValues`, `compareRows`, `compareTypedValues`, `createTypedComparator` — match Quereus SQL semantics in custom implementations
198
+ * **Coercion Utilities** — `tryCoerceToNumber`, `coerceForAggregate` — handle type coercion for aggregates and arithmetic
199
+ * **Collation Support** — collations are registered per database with `db.registerCollation(name, func, options?)` and resolved through `db.getCollationResolver()`; the built-ins `BINARY`, `NOCASE`, and `RTRIM` are always present. Naming an unregistered collation raises `no such collation sequence`
200
+ * **Type System** — full access to logical types, validation, and parsing utilities
201
+ * **Event Hooks** — `VTableEventEmitter` interface for mutation and schema change events; enable reactive patterns, caching, and replication
202
+ * **DDL Generation** — `generateTableDDL(tableSchema, db?)`, `generateIndexDDL(indexSchema, tableSchema, db?)` — canonical `CREATE TABLE` / `CREATE INDEX` output from runtime schema objects. With a `Database`, matches session defaults (schema qualification, `default_column_nullability`, `default_vtab_module`/`default_vtab_args`) for readable output; without one, emits fully-qualified, explicitly-annotated DDL safe for cross-session persistence. See [Schema Management — DDL Generation](../../docs/schema.md#ddl-generation).
203
+
204
+ See the [Plugin System documentation](../../docs/plugins.md#comparison-and-coercion-utilities) for complete API reference and examples.
205
+
206
+ ## Current Status
207
+
208
+ Quereus is a feature-complete SQL query processor with a modern planner and instruction-based runtime architecture. The engine successfully handles complex SQL workloads including joins, window functions, subqueries, CTEs, constraints, and comprehensive DML/DDL operations.
209
+
210
+ ### Stability
211
+
212
+ Quereus spans a battle-tested SQL core and several research tracks. Every feature area
213
+ carries one of four tiers, which say how much a future release may break you:
214
+
215
+ | Tier | A breaking change may land in | In short |
216
+ | --- | --- | --- |
217
+ | **Stable** | a major release only | Build on it. |
218
+ | **Beta** | a minor release | Complete and tested; the surface is still being shaped. |
219
+ | **Experimental** | **any** release, including a patch | A research track. Prototype on it; expect churn. |
220
+ | **Internal** | any release | Engine internals — no user-facing contract. |
221
+
222
+ A tier is about compatibility, not correctness: a wrong answer is a bug at every tier,
223
+ including Experimental. See [Stability Tiers](../../docs/stability.md) for the definitions
224
+ and the per-area assignment.
225
+
226
+ ### Capabilities
227
+
228
+ * **Modern Type System** — temporal types (DATE, TIME, DATETIME), JSON with deep equality, plugin-extensible custom types
229
+ * **Complete JOIN support** — INNER, LEFT, RIGHT, CROSS, SEMI, and ANTI joins with proper NULL padding
230
+ * **Advanced window functions** — ranking, aggregates, and frame specifications
231
+ * **Full constraint system** — NOT NULL, CHECK, FOREIGN KEY, and CREATE ASSERTION. Row-level constraints that reference other tables are automatically deferred to COMMIT. The `committed.tablename` pseudo-schema provides read-only access to pre-transaction state for transition constraints (e.g., "balance may not decrease"). See [Architecture — Constraints](../../docs/architecture.md#constraints).
232
+ * **Comprehensive subqueries** — scalar, correlated, EXISTS, and IN subqueries
233
+ * **Relational orthogonality** — INSERT/UPDATE/DELETE with RETURNING can be used as table sources
234
+ * **Complete set operations** — UNION, INTERSECT, EXCEPT with proper deduplication
235
+ * **DIFF (symmetric difference)** — `A diff B` equals `(A except B) union (B except A)`, handy for table equality checks via `not exists(A diff B)`
236
+ * **Robust transaction support** — multi-level savepoints and rollback. See [Usage Guide](../../docs/usage.md#transactions) for details
237
+ * **Rich built-in function library** — scalar, aggregate, window, JSON, and date/time functions
238
+ * **Rule-based optimizer** — constant folding, caching, streaming aggregation, bloom-join selection, and correlated subquery decorrelation. See [Architecture — Optimizer](../../docs/architecture.md#optimizer).
239
+ * **Change-scope introspection and reactive subscriptions** — `Statement.getChangeScope()` returns a JSON-serializable description of what base-table state and external inputs a prepared statement reads from. The companion `Database.watch(scope, handler)` consumes any `ChangeScope` value (analyzed, deserialized, or hand-built) and fires a post-commit callback whenever matching rows, groups, or tables change. See [Change-scope Documentation](../../docs/change-scope.md).
240
+ * **Updatable views** *(Beta)* — `insert` / `update` / `delete` propagate through views, non-recursive CTEs, and subqueries in `from` to the underlying base tables (no `instead of` triggers; predicate-driven). Single-source projection-and-filter and multi-source key-preserving inner-join bodies are supported, with `returning`, the core-`select` `with defaults (col = expr, …)` and `with inverse (col = expr, …)` clauses (omitted-insert defaults and authored write-back expressions, both riding the body select), and per-row writable presence/membership columns for write routing. See [View Updateability](../../docs/view-updateability.md).
241
+ * **Materialized views** *(Beta)* — `create materialized view` stores a query body as a keyed backing relation kept consistent with its sources **synchronously, inside the writing transaction** (row-time maintenance — no refresh-policy knob, reads-own-writes), with write-through DML and covering-structure constraint enforcement. See [Materialized Views](../../docs/materialized-views.md).
242
+ * **Logical schemas and lenses** *(Experimental)* — separate an embodiment-free logical design from a module-backed basis, mapped by per-table bidirectional **lenses** built on view updateability. See [Lenses and Layered Schemas](../../docs/lens.md).
243
+
244
+ [TODO List](../../docs/todo.md) has remaining priorities.
245
+
246
+ ## Supported Built-in Functions
247
+
248
+ * **Scalar** — `lower`, `upper`, `length`, `substr`/`substring`, `abs`, `round`, `coalesce`, `nullif`, `like`, `glob`, `typeof`
249
+ * **Aggregate** — `count`, `sum`, `avg`, `min`, `max`, `group_concat`, `json_group_array`, `json_group_object`
250
+ * **Window Functions** — complete implementation with `row_number`, `rank`, `dense_rank`, `ntile` (ranking); `count`, `sum`, `avg`, `min`, `max` with OVER clause (aggregates); full frame specification support (`ROWS BETWEEN`, `UNBOUNDED PRECEDING/FOLLOWING`); `NULLS FIRST/LAST` ordering
251
+ * **Date/Time** — `date`, `time`, `datetime`, `julianday`, `strftime` (supports common formats and modifiers), `epoch_s`, `epoch_ms`, `epoch_s_frac` (Unix epoch conversions with strict parsing)
252
+ * **JSON** — `json_valid`, `json_schema`, `json_type`, `json_extract`, `json_quote`, `json_array`, `json_object`, `json_insert`, `json_replace`, `json_set`, `json_remove`, `json_array_length`, `json_patch`
253
+ * **Query Analysis** — `query_plan`, `scheduler_program`, `execution_trace` (debugging and performance analysis)
254
+
255
+ ## Testing
256
+
257
+ Tests live in `test/*.spec.ts`, driven by Mocha with ts-node/esm. Run with `yarn test`. Quereus uses SQL logic tests (primary), property-based tests, performance sentinels, unit tests, and a benchmark suite — see [Architecture — Testing Strategy](../../docs/architecture.md#testing-strategy) for details.
@@ -85,6 +85,16 @@ export declare function isAbortError(e: unknown): boolean;
85
85
  export declare class MisuseError extends QuereusError {
86
86
  constructor(message?: string, cause?: Error);
87
87
  }
88
+ /**
89
+ * A transaction is already open on this Database, so the requested operation —
90
+ * beginning a transaction, or running an `exec` batch with `transaction: true` —
91
+ * cannot proceed. Distinct from a plain QuereusError so a caller can positively
92
+ * recognise "someone else owns a transaction here" and back off, rather than
93
+ * matching message text. Carries StatusCode.BUSY.
94
+ */
95
+ export declare class TransactionActiveError extends QuereusError {
96
+ constructor(message?: string, cause?: Error);
97
+ }
88
98
  /**
89
99
  * Helper function to throw a QuereusError with optional location information from AST nodes
90
100
  * @param message Error message
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAyB,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAiB3G;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACpC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAA8B,EAAE,KAAK,CAAC,EAAE,KAAK;CA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O,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,CAyBrD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,YAAY,GAAE,OAAe,GAAG,MAAM,CAuB/F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAMvD"}
@@ -133,6 +133,20 @@ export class MisuseError extends QuereusError {
133
133
  Object.setPrototypeOf(this, MisuseError.prototype);
134
134
  }
135
135
  }
136
+ /**
137
+ * A transaction is already open on this Database, so the requested operation —
138
+ * beginning a transaction, or running an `exec` batch with `transaction: true` —
139
+ * cannot proceed. Distinct from a plain QuereusError so a caller can positively
140
+ * recognise "someone else owns a transaction here" and back off, rather than
141
+ * matching message text. Carries StatusCode.BUSY.
142
+ */
143
+ export class TransactionActiveError extends QuereusError {
144
+ constructor(message = 'Cannot begin transaction: a transaction is already active', cause) {
145
+ super(message, StatusCode.BUSY, cause);
146
+ this.name = 'TransactionActiveError';
147
+ Object.setPrototypeOf(this, TransactionActiveError.prototype);
148
+ }
149
+ }
136
150
  /**
137
151
  * Helper function to throw a QuereusError with optional location information from AST nodes
138
152
  * @param message Error message
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC/B,IAAI,CAAS;IACb,IAAI,CAAU;IACd,MAAM,CAAU;IAEvB,YAA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