@quereus/quereus 0.4.5 → 0.4.8
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 +2 -2
- package/dist/src/core/database.d.ts +2 -3
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +4 -5
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/parser/ast.d.ts +0 -1
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/lexer.d.ts +0 -1
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +0 -2
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +2 -14
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/building/transaction.js +4 -4
- package/dist/src/planner/building/transaction.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +1 -1
- package/dist/src/planner/nodes/transaction-node.d.ts +1 -3
- package/dist/src/planner/nodes/transaction-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/transaction-node.js +2 -7
- package/dist/src/planner/nodes/transaction-node.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +3 -3
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/remote-query.d.ts +1 -1
- package/dist/src/runtime/emit/remote-query.js +5 -5
- package/dist/src/runtime/emit/remote-query.js.map +1 -1
- package/dist/src/runtime/emit/scan.js +10 -10
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/transaction.js +1 -1
- package/dist/src/runtime/emit/transaction.js.map +1 -1
- package/dist/src/runtime/emit/update.js +1 -1
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/utils.js +6 -6
- package/dist/src/runtime/utils.js.map +1 -1
- package/dist/src/schema/manager.d.ts +4 -4
- package/dist/src/schema/manager.js +20 -20
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/util/ast-stringify.d.ts.map +1 -1
- package/dist/src/util/ast-stringify.js +1 -6
- package/dist/src/util/ast-stringify.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +0 -6
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +0 -27
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +4 -10
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +4 -16
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +14 -14
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +21 -21
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/module.d.ts +6 -18
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +17 -17
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/database.ts +4 -5
- package/src/parser/ast.ts +0 -1
- package/src/parser/lexer.ts +0 -2
- package/src/parser/parser.ts +2 -13
- package/src/planner/building/transaction.ts +4 -4
- package/src/planner/nodes/dml-executor-node.ts +1 -1
- package/src/planner/nodes/transaction-node.ts +1 -7
- package/src/runtime/emit/dml-executor.ts +3 -3
- package/src/runtime/emit/remote-query.ts +5 -5
- package/src/runtime/emit/scan.ts +10 -10
- package/src/runtime/emit/transaction.ts +1 -1
- package/src/runtime/emit/update.ts +1 -1
- package/src/runtime/utils.ts +6 -6
- package/src/schema/manager.ts +20 -20
- package/src/util/ast-stringify.ts +1 -6
- package/src/vtab/best-access-plan.ts +0 -30
- package/src/vtab/memory/module.ts +4 -17
- package/src/vtab/memory/table.ts +21 -21
- package/src/vtab/module.ts +7 -17
- package/src/vtab/table.ts +17 -17
|
@@ -17,7 +17,7 @@ export class MemoryTable extends VirtualTable {
|
|
|
17
17
|
/** @internal Connection state specific to this table instance (lazily initialized) */
|
|
18
18
|
connection = null;
|
|
19
19
|
/**
|
|
20
|
-
* @internal - Use MemoryTableModule.
|
|
20
|
+
* @internal - Use MemoryTableModule.connect or create
|
|
21
21
|
* Creates a connection-specific instance linked to a manager.
|
|
22
22
|
*/
|
|
23
23
|
constructor(db, module, manager // Pass the shared manager instance
|
|
@@ -77,79 +77,79 @@ export class MemoryTable extends VirtualTable {
|
|
|
77
77
|
}
|
|
78
78
|
return new MemoryVirtualTableConnection(this.tableName, this.connection);
|
|
79
79
|
}
|
|
80
|
-
//
|
|
81
|
-
async *
|
|
80
|
+
// Direct async iteration for query execution
|
|
81
|
+
async *query(filterInfo) {
|
|
82
82
|
const conn = await this.ensureConnection();
|
|
83
|
-
logger.debugLog(`
|
|
83
|
+
logger.debugLog(`query using connection ${conn.connectionId} (pending: ${conn.pendingTransactionLayer?.getLayerId()}, read: ${conn.readLayer.getLayerId()})`);
|
|
84
84
|
const currentSchema = this.manager.tableSchema;
|
|
85
85
|
if (!currentSchema) {
|
|
86
|
-
logger.error('
|
|
86
|
+
logger.error('query', this.tableName, 'Table schema is undefined');
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
const plan = buildScanPlanFromFilterInfo(filterInfo, currentSchema);
|
|
90
|
-
logger.debugLog(`
|
|
90
|
+
logger.debugLog(`query invoked for ${this.tableName} with plan: ${safeJsonStringify(plan)}`);
|
|
91
91
|
const startLayer = conn.pendingTransactionLayer ?? conn.readLayer;
|
|
92
|
-
logger.debugLog(`
|
|
92
|
+
logger.debugLog(`query reading from layer ${startLayer.getLayerId()}`);
|
|
93
93
|
// Delegate scanning to the manager, which handles layer recursion
|
|
94
94
|
yield* this.manager.scanLayer(startLayer, plan);
|
|
95
95
|
}
|
|
96
|
-
// Note:
|
|
96
|
+
// Note: getBestAccessPlan is handled by the MemoryTableModule, not the table instance.
|
|
97
97
|
/** Performs mutation through the connection's transaction layer */
|
|
98
|
-
async
|
|
98
|
+
async update(operation, values, oldKeyValues, onConflict) {
|
|
99
99
|
const conn = await this.ensureConnection();
|
|
100
100
|
// Delegate mutation to the manager.
|
|
101
101
|
// This assumes manager.performMutation will be updated to this signature and logic.
|
|
102
102
|
return this.manager.performMutation(conn, operation, values, oldKeyValues, onConflict);
|
|
103
103
|
}
|
|
104
104
|
/** Begins a transaction for this connection */
|
|
105
|
-
async
|
|
105
|
+
async begin() {
|
|
106
106
|
(await this.ensureConnection()).begin();
|
|
107
107
|
}
|
|
108
108
|
/** Commits this connection's transaction */
|
|
109
|
-
async
|
|
109
|
+
async commit() {
|
|
110
110
|
// Only commit if a connection has actually been established
|
|
111
111
|
if (this.connection) {
|
|
112
112
|
await this.connection.commit();
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
/** Rolls back this connection's transaction */
|
|
116
|
-
async
|
|
116
|
+
async rollback() {
|
|
117
117
|
// Only rollback if a connection has actually been established
|
|
118
118
|
if (this.connection) {
|
|
119
119
|
this.connection.rollback();
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
/** Sync operation (currently no-op for memory table layers) */
|
|
123
|
-
async
|
|
123
|
+
async sync() {
|
|
124
124
|
// This might trigger background collapse in the manager in the future
|
|
125
125
|
// await this.manager.tryCollapseLayers(); // Optional: trigger collapse on sync?
|
|
126
126
|
return Promise.resolve();
|
|
127
127
|
}
|
|
128
128
|
/** Renames the underlying table via the manager */
|
|
129
|
-
async
|
|
129
|
+
async rename(newName) {
|
|
130
130
|
logger.operation('Rename', this.tableName, { newName });
|
|
131
131
|
await this.manager.renameTable(newName);
|
|
132
132
|
// Update this instance's schema reference after rename
|
|
133
133
|
this.tableSchema = this.manager.tableSchema;
|
|
134
134
|
}
|
|
135
135
|
// --- Savepoint operations ---
|
|
136
|
-
async
|
|
136
|
+
async savepoint(savepointIndex) {
|
|
137
137
|
const conn = await this.ensureConnection();
|
|
138
138
|
conn.createSavepoint(savepointIndex);
|
|
139
139
|
}
|
|
140
|
-
async
|
|
140
|
+
async release(savepointIndex) {
|
|
141
141
|
if (!this.connection)
|
|
142
142
|
return; // No connection, no savepoints to release
|
|
143
143
|
this.connection.releaseSavepoint(savepointIndex);
|
|
144
144
|
}
|
|
145
|
-
async
|
|
145
|
+
async rollbackTo(savepointIndex) {
|
|
146
146
|
if (!this.connection)
|
|
147
147
|
return; // No connection, no savepoints to rollback to
|
|
148
148
|
this.connection.rollbackToSavepoint(savepointIndex);
|
|
149
149
|
}
|
|
150
150
|
// --- End Savepoint operations ---
|
|
151
151
|
/** Handles schema changes via the manager */
|
|
152
|
-
async
|
|
152
|
+
async alterSchema(changeInfo) {
|
|
153
153
|
const originalManagerSchema = this.manager.tableSchema; // For potential error recovery
|
|
154
154
|
try {
|
|
155
155
|
switch (changeInfo.type) {
|
|
@@ -185,7 +185,7 @@ export class MemoryTable extends VirtualTable {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
/** Disconnects this connection instance from the manager */
|
|
188
|
-
async
|
|
188
|
+
async disconnect() {
|
|
189
189
|
if (this.connection) {
|
|
190
190
|
// Manager handles cleanup and potential layer collapse trigger
|
|
191
191
|
await this.manager.disconnect(this.connection.connectionId);
|
|
@@ -193,12 +193,12 @@ export class MemoryTable extends VirtualTable {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
// --- Index DDL methods delegate to the manager ---
|
|
196
|
-
async
|
|
196
|
+
async createIndex(indexSchema) {
|
|
197
197
|
logger.operation('Create Index', this.tableName, { indexName: indexSchema.name });
|
|
198
198
|
await this.manager.createIndex(indexSchema);
|
|
199
199
|
this.tableSchema = this.manager.tableSchema; // Refresh local schema ref
|
|
200
200
|
}
|
|
201
|
-
async
|
|
201
|
+
async dropIndex(indexName) {
|
|
202
202
|
logger.operation('Drop Index', this.tableName, { indexName });
|
|
203
203
|
await this.manager.dropIndex(indexName);
|
|
204
204
|
// Update schema reference
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","source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;QACzC,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,2BAA2B;IACzE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,SAAiB;QAChC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9D,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACxC,0BAA0B;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAC7C,CAAC;CAED;AAED,6DAA6D;AAC7D,+GAA+G"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Database } from '../core/database.js';
|
|
2
2
|
import type { VirtualTable } from './table.js';
|
|
3
|
-
import type { IndexInfo } from './index-info.js';
|
|
4
3
|
import type { ColumnDef } from '../parser/ast.js';
|
|
5
4
|
import type { TableSchema, IndexSchema } from '../schema/table.js';
|
|
6
5
|
import type { BestAccessPlanRequest, BestAccessPlanResult } from './best-access-plan.js';
|
|
7
6
|
import type { PlanNode } from '../planner/nodes/plan-node.js';
|
|
8
7
|
/**
|
|
9
|
-
* Base interface for module-specific configuration passed to
|
|
8
|
+
* Base interface for module-specific configuration passed to create/connect.
|
|
10
9
|
* Modules should define their own interface extending this if they need options.
|
|
11
10
|
*/
|
|
12
11
|
export interface BaseModuleConfig {
|
|
@@ -38,7 +37,7 @@ export interface VirtualTableModule<TTable extends VirtualTable, TConfig extends
|
|
|
38
37
|
* @returns The new VirtualTable instance
|
|
39
38
|
* @throws QuereusError on failure
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
create(db: Database, tableSchema: TableSchema): TTable;
|
|
42
41
|
/**
|
|
43
42
|
* Connects to an existing virtual table definition.
|
|
44
43
|
* Called when the schema is loaded or a connection needs to interact with the table.
|
|
@@ -52,7 +51,7 @@ export interface VirtualTableModule<TTable extends VirtualTable, TConfig extends
|
|
|
52
51
|
* @returns The connection-specific VirtualTable instance
|
|
53
52
|
* @throws QuereusError on failure
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
connect(db: Database, pAux: unknown, moduleName: string, schemaName: string, tableName: string, options: TConfig): TTable;
|
|
56
55
|
/**
|
|
57
56
|
* Determines if this module can execute a plan subtree starting at the given node.
|
|
58
57
|
* Used for query push-down to virtual table modules that support arbitrary queries.
|
|
@@ -71,17 +70,6 @@ export interface VirtualTableModule<TTable extends VirtualTable, TConfig extends
|
|
|
71
70
|
* @returns Access plan result describing the chosen strategy
|
|
72
71
|
*/
|
|
73
72
|
getBestAccessPlan?(db: Database, tableInfo: TableSchema, request: BestAccessPlanRequest): BestAccessPlanResult;
|
|
74
|
-
/**
|
|
75
|
-
* Determines the best query plan for a given set of constraints and orderings.
|
|
76
|
-
* This method MUST be synchronous for performance. It modifies the passed IndexInfo object.
|
|
77
|
-
*
|
|
78
|
-
* @deprecated Use getBestAccessPlan instead for better type safety and extensibility
|
|
79
|
-
* @param db The database connection
|
|
80
|
-
* @param tableInfo The schema information for the table being planned
|
|
81
|
-
* @param indexInfo Input constraints/orderings and output plan details
|
|
82
|
-
* @returns StatusCode.OK on success, or an error code
|
|
83
|
-
*/
|
|
84
|
-
xBestIndex(db: Database, tableInfo: TableSchema, indexInfo: IndexInfo): number;
|
|
85
73
|
/**
|
|
86
74
|
* Destroys the underlying persistent representation of the virtual table.
|
|
87
75
|
* Called by DROP TABLE.
|
|
@@ -93,7 +81,7 @@ export interface VirtualTableModule<TTable extends VirtualTable, TConfig extends
|
|
|
93
81
|
* @param tableName The name of the virtual table being destroyed
|
|
94
82
|
* @throws QuereusError on failure
|
|
95
83
|
*/
|
|
96
|
-
|
|
84
|
+
destroy(db: Database, pAux: unknown, moduleName: string, schemaName: string, tableName: string): Promise<void>;
|
|
97
85
|
/**
|
|
98
86
|
* Creates an index on a virtual table.
|
|
99
87
|
* Called by CREATE INDEX.
|
|
@@ -104,13 +92,13 @@ export interface VirtualTableModule<TTable extends VirtualTable, TConfig extends
|
|
|
104
92
|
* @param indexSchema The schema definition for the index being created
|
|
105
93
|
* @throws QuereusError on failure
|
|
106
94
|
*/
|
|
107
|
-
|
|
95
|
+
createIndex?(db: Database, schemaName: string, tableName: string, indexSchema: IndexSchema): Promise<void>;
|
|
108
96
|
/**
|
|
109
97
|
* Checks for shadow table name conflicts
|
|
110
98
|
* @param name The name to check
|
|
111
99
|
* @returns true if the name would conflict
|
|
112
100
|
*/
|
|
113
|
-
|
|
101
|
+
shadowName?(name: string): boolean;
|
|
114
102
|
}
|
|
115
103
|
/**
|
|
116
104
|
* Defines the structure for schema change information passed to xAlterSchema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/vtab/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/vtab/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO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jB;;;;OAIG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACzB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3F;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
|
package/dist/src/vtab/table.d.ts
CHANGED
|
@@ -30,15 +30,15 @@ export declare abstract class VirtualTable {
|
|
|
30
30
|
* Called when the database connection closes or the statement is finalized
|
|
31
31
|
* @throws QuereusError on failure
|
|
32
32
|
*/
|
|
33
|
-
abstract
|
|
33
|
+
abstract disconnect(): Promise<void>;
|
|
34
34
|
/**
|
|
35
35
|
* (Optional) Opens a direct data stream for this virtual table based on filter criteria.
|
|
36
|
-
* This is an alternative to the cursor-based
|
|
37
|
-
* @param filterInfo Information from
|
|
36
|
+
* This is an alternative to the cursor-based open/filter/next model.
|
|
37
|
+
* @param filterInfo Information from getBestAccessPlan and query parameters.
|
|
38
38
|
* @returns An AsyncIterable yielding Row tuples.
|
|
39
39
|
* @throws QuereusError on failure
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
query?(filterInfo: FilterInfo): AsyncIterable<Row>;
|
|
42
42
|
/**
|
|
43
43
|
* Executes a pushed-down plan subtree.
|
|
44
44
|
* Called when the module indicated support via supports() method.
|
|
@@ -48,7 +48,7 @@ export declare abstract class VirtualTable {
|
|
|
48
48
|
* @param ctx Optional context from supports() assessment
|
|
49
49
|
* @returns Async iterable of rows resulting from the plan execution
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
executePlan?(db: Database, plan: PlanNode, ctx?: unknown): AsyncIterable<Row>;
|
|
52
52
|
/**
|
|
53
53
|
* Performs an INSERT, UPDATE, or DELETE operation
|
|
54
54
|
* @param operation The operation to perform (insert, update, delete)
|
|
@@ -58,7 +58,7 @@ export declare abstract class VirtualTable {
|
|
|
58
58
|
* @returns new row for INSERT/UPDATE, undefined for DELETE
|
|
59
59
|
* @throws QuereusError or ConstraintError on failure
|
|
60
60
|
*/
|
|
61
|
-
abstract
|
|
61
|
+
abstract update(operation: RowOp, values: Row | undefined, oldKeyValues?: Row, onConflict?: ConflictResolution): Promise<Row | undefined>;
|
|
62
62
|
/**
|
|
63
63
|
* (Optional) Creates a new connection for transaction support.
|
|
64
64
|
* If implemented, this enables proper transaction isolation for this table.
|
|
@@ -74,54 +74,54 @@ export declare abstract class VirtualTable {
|
|
|
74
74
|
/**
|
|
75
75
|
* Begins a transaction on this virtual table
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
begin?(): Promise<void>;
|
|
78
78
|
/**
|
|
79
79
|
* Syncs changes within the virtual table transaction
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
sync?(): Promise<void>;
|
|
82
82
|
/**
|
|
83
83
|
* Commits the virtual table transaction
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
commit?(): Promise<void>;
|
|
86
86
|
/**
|
|
87
87
|
* Rolls back the virtual table transaction
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
rollback?(): Promise<void>;
|
|
90
90
|
/**
|
|
91
91
|
* Renames the virtual table
|
|
92
92
|
* @param newName The new name for the table
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
rename?(newName: string): Promise<void>;
|
|
95
95
|
/**
|
|
96
96
|
* Begins a savepoint
|
|
97
97
|
* @param savepointIndex The savepoint identifier
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
savepoint?(savepointIndex: number): Promise<void>;
|
|
100
100
|
/**
|
|
101
101
|
* Releases a savepoint
|
|
102
102
|
* @param savepointIndex The savepoint identifier
|
|
103
103
|
*/
|
|
104
|
-
|
|
104
|
+
release?(savepointIndex: number): Promise<void>;
|
|
105
105
|
/**
|
|
106
106
|
* Rolls back to a savepoint
|
|
107
107
|
* @param savepointIndex The savepoint identifier
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
rollbackTo?(savepointIndex: number): Promise<void>;
|
|
110
110
|
/**
|
|
111
111
|
* Modifies the schema of this virtual table
|
|
112
112
|
* @param changeInfo Object describing the schema modification
|
|
113
113
|
* @throws QuereusError or ConstraintError on failure
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
alterSchema?(changeInfo: SchemaChangeInfo): Promise<void>;
|
|
116
116
|
/**
|
|
117
117
|
* Creates a secondary index on the virtual table
|
|
118
118
|
* @param indexInfo The index definition
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
createIndex?(indexInfo: IndexSchema): Promise<void>;
|
|
121
121
|
/**
|
|
122
122
|
* Drops a secondary index from the virtual table
|
|
123
123
|
* @param indexName The name of the index to drop
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
dropIndex?(indexName: string): Promise<void>;
|
|
126
126
|
}
|
|
127
127
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/vtab/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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AAgB,CAAC,IAAI,YAAY,CAAC,sBAAsB,CAAC;IAEzD;;;;OAIG;IACH,aAAa,CAAC,IAAI,sBAAsB,GAAG,SAAS;IAEpD;;OAEG;IACH,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtB;;OAEG;IACH,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAE1B;;;OAGG;IACH,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvC;;;OAGG;IACH,SAAS,CAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjD;;;OAGG;IACH,OAAO,CAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE/C;;;OAGG;IACH,UAAU,CAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAElD;;;;OAIG;IACH,WAAW,CAAC,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEzD;;;OAGG;IACH,WAAW,CAAC,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnD;;;OAGG;IACH,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC5C"}
|
package/package.json
CHANGED
package/src/core/database.ts
CHANGED
|
@@ -304,7 +304,7 @@ export class Database {
|
|
|
304
304
|
* Registers a virtual table module.
|
|
305
305
|
* @param name The name of the module.
|
|
306
306
|
* @param module The module implementation.
|
|
307
|
-
* @param auxData Optional client data passed to
|
|
307
|
+
* @param auxData Optional client data passed to create/connect.
|
|
308
308
|
*/
|
|
309
309
|
registerVtabModule(name: string, module: AnyVirtualTableModule, auxData?: unknown): void {
|
|
310
310
|
this.checkOpen();
|
|
@@ -313,16 +313,15 @@ export class Database {
|
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
315
|
* Begins a transaction.
|
|
316
|
-
* @param mode Transaction mode ('deferred', 'immediate', or 'exclusive').
|
|
317
316
|
*/
|
|
318
|
-
async beginTransaction(
|
|
317
|
+
async beginTransaction(): Promise<void> {
|
|
319
318
|
this.checkOpen();
|
|
320
319
|
|
|
321
320
|
if (this.inTransaction) {
|
|
322
321
|
throw new QuereusError("Transaction already active", StatusCode.ERROR);
|
|
323
322
|
}
|
|
324
323
|
|
|
325
|
-
await this.exec(
|
|
324
|
+
await this.exec("BEGIN TRANSACTION");
|
|
326
325
|
this.inTransaction = true;
|
|
327
326
|
this.isAutocommit = false;
|
|
328
327
|
}
|
|
@@ -378,7 +377,7 @@ export class Database {
|
|
|
378
377
|
this.statements.clear();
|
|
379
378
|
|
|
380
379
|
// Clear schemas, ensuring VTabs are potentially disconnected
|
|
381
|
-
// This will also call
|
|
380
|
+
// This will also call destroy on VTabs via SchemaManager.clearAll -> schema.clearTables -> schemaManager.dropTable
|
|
382
381
|
this.schemaManager.clearAll();
|
|
383
382
|
|
|
384
383
|
// this.registeredVTabs.clear(); // Removed, SchemaManager handles module lifecycle
|
package/src/parser/ast.ts
CHANGED
package/src/parser/lexer.ts
CHANGED
|
@@ -82,7 +82,6 @@ export enum TokenType {
|
|
|
82
82
|
TRANSACTION = 'TRANSACTION',
|
|
83
83
|
DEFERRED = 'DEFERRED',
|
|
84
84
|
IMMEDIATE = 'IMMEDIATE',
|
|
85
|
-
EXCLUSIVE = 'EXCLUSIVE',
|
|
86
85
|
JOIN = 'JOIN',
|
|
87
86
|
INNER = 'INNER',
|
|
88
87
|
LEFT = 'LEFT',
|
|
@@ -242,7 +241,6 @@ export const KEYWORDS: Record<string, TokenType> = {
|
|
|
242
241
|
'transaction': TokenType.TRANSACTION,
|
|
243
242
|
'deferred': TokenType.DEFERRED,
|
|
244
243
|
'immediate': TokenType.IMMEDIATE,
|
|
245
|
-
'exclusive': TokenType.EXCLUSIVE,
|
|
246
244
|
'deferrable': TokenType.DEFERRABLE,
|
|
247
245
|
'initially': TokenType.INITIALLY,
|
|
248
246
|
'stored': TokenType.STORED,
|
package/src/parser/parser.ts
CHANGED
|
@@ -2298,21 +2298,10 @@ export class Parser {
|
|
|
2298
2298
|
* @returns AST for BEGIN statement
|
|
2299
2299
|
*/
|
|
2300
2300
|
private beginStatement(startToken: Token, _withClause?: AST.WithClause): AST.BeginStmt {
|
|
2301
|
-
|
|
2302
|
-
if (this.peekKeyword('DEFERRED')) {
|
|
2303
|
-
this.advance();
|
|
2304
|
-
mode = 'deferred';
|
|
2305
|
-
} else if (this.peekKeyword('IMMEDIATE')) {
|
|
2306
|
-
this.advance();
|
|
2307
|
-
mode = 'immediate';
|
|
2308
|
-
} else if (this.peekKeyword('EXCLUSIVE')) {
|
|
2309
|
-
this.advance();
|
|
2310
|
-
mode = 'exclusive';
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2301
|
+
// Skip optional TRANSACTION keyword
|
|
2313
2302
|
this.matchKeyword('TRANSACTION');
|
|
2314
2303
|
|
|
2315
|
-
return { type: 'begin',
|
|
2304
|
+
return { type: 'begin', loc: _createLoc(startToken, this.previous()) };
|
|
2316
2305
|
}
|
|
2317
2306
|
|
|
2318
2307
|
/**
|
|
@@ -3,7 +3,7 @@ import type { PlanningContext } from '../planning-context.js';
|
|
|
3
3
|
import { TransactionPlanNode } from '../nodes/transaction-node.js';
|
|
4
4
|
|
|
5
5
|
export function buildBeginStmt(ctx: PlanningContext, stmt: AST.BeginStmt): TransactionPlanNode {
|
|
6
|
-
return new TransactionPlanNode(ctx.scope, 'begin', stmt
|
|
6
|
+
return new TransactionPlanNode(ctx.scope, 'begin', stmt);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function buildCommitStmt(ctx: PlanningContext, stmt: AST.CommitStmt): TransactionPlanNode {
|
|
@@ -11,13 +11,13 @@ export function buildCommitStmt(ctx: PlanningContext, stmt: AST.CommitStmt): Tra
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function buildRollbackStmt(ctx: PlanningContext, stmt: AST.RollbackStmt): TransactionPlanNode {
|
|
14
|
-
return new TransactionPlanNode(ctx.scope, 'rollback', stmt,
|
|
14
|
+
return new TransactionPlanNode(ctx.scope, 'rollback', stmt, stmt.savepoint);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function buildSavepointStmt(ctx: PlanningContext, stmt: AST.SavepointStmt): TransactionPlanNode {
|
|
18
|
-
return new TransactionPlanNode(ctx.scope, 'savepoint', stmt,
|
|
18
|
+
return new TransactionPlanNode(ctx.scope, 'savepoint', stmt, stmt.name);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function buildReleaseStmt(ctx: PlanningContext, stmt: AST.ReleaseStmt): TransactionPlanNode {
|
|
22
|
-
return new TransactionPlanNode(ctx.scope, 'release', stmt,
|
|
22
|
+
return new TransactionPlanNode(ctx.scope, 'release', stmt, stmt.savepoint);
|
|
23
23
|
}
|
|
@@ -8,7 +8,7 @@ import { RowOp } from '../../common/types.js';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Executes actual database insert/update/delete operations after constraint validation.
|
|
11
|
-
* This node performs the actual vtab.
|
|
11
|
+
* This node performs the actual vtab.update operations and yields the affected rows.
|
|
12
12
|
* All data transformations (defaults, conversions, etc.) happen before this node.
|
|
13
13
|
*/
|
|
14
14
|
export class DmlExecutorNode extends PlanNode implements RelationalPlanNode {
|
|
@@ -7,7 +7,6 @@ import { astToString } from '../../util/ast-stringify.js';
|
|
|
7
7
|
export interface TransactionNode extends VoidNode {
|
|
8
8
|
nodeType: PlanNodeType.Transaction;
|
|
9
9
|
operation: 'begin' | 'commit' | 'rollback' | 'savepoint' | 'release';
|
|
10
|
-
mode?: 'deferred' | 'immediate' | 'exclusive'; // For BEGIN
|
|
11
10
|
savepoint?: string; // For ROLLBACK TO, SAVEPOINT, RELEASE
|
|
12
11
|
statementAst: AST.BeginStmt | AST.CommitStmt | AST.RollbackStmt | AST.SavepointStmt | AST.ReleaseStmt;
|
|
13
12
|
}
|
|
@@ -19,7 +18,6 @@ export class TransactionPlanNode extends VoidNode implements TransactionNode {
|
|
|
19
18
|
scope: Scope,
|
|
20
19
|
public readonly operation: 'begin' | 'commit' | 'rollback' | 'savepoint' | 'release',
|
|
21
20
|
public readonly statementAst: AST.BeginStmt | AST.CommitStmt | AST.RollbackStmt | AST.SavepointStmt | AST.ReleaseStmt,
|
|
22
|
-
public readonly mode?: 'deferred' | 'immediate' | 'exclusive',
|
|
23
21
|
public readonly savepoint?: string
|
|
24
22
|
) {
|
|
25
23
|
super(scope, 1); // Transaction operations have low cost
|
|
@@ -28,7 +26,7 @@ export class TransactionPlanNode extends VoidNode implements TransactionNode {
|
|
|
28
26
|
override toString(): string {
|
|
29
27
|
switch (this.operation) {
|
|
30
28
|
case 'begin':
|
|
31
|
-
return
|
|
29
|
+
return 'BEGIN';
|
|
32
30
|
case 'commit':
|
|
33
31
|
return 'COMMIT';
|
|
34
32
|
case 'rollback':
|
|
@@ -48,10 +46,6 @@ export class TransactionPlanNode extends VoidNode implements TransactionNode {
|
|
|
48
46
|
statement: astToString(this.statementAst)
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
if (this.mode) {
|
|
52
|
-
props.mode = this.mode;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
49
|
if (this.savepoint) {
|
|
56
50
|
props.savepoint = this.savepoint;
|
|
57
51
|
}
|
|
@@ -22,7 +22,7 @@ export function emitDmlExecutor(plan: DmlExecutorNode, ctx: EmissionContext): In
|
|
|
22
22
|
try {
|
|
23
23
|
for await (const flatRow of rows) {
|
|
24
24
|
const newRow = extractNewRowFromFlat(flatRow, tableSchema.columns.length);
|
|
25
|
-
await vtab.
|
|
25
|
+
await vtab.update!('insert', newRow, undefined, plan.onConflict ?? ConflictResolution.ABORT);
|
|
26
26
|
// Track change (INSERT): record NEW primary key
|
|
27
27
|
const pkValues = tableSchema.primaryKeyDefinition.map(def => newRow[def.index]);
|
|
28
28
|
ctx.db._recordInsert(`${tableSchema.schemaName}.${tableSchema.name}`, pkValues);
|
|
@@ -48,7 +48,7 @@ export function emitDmlExecutor(plan: DmlExecutorNode, ctx: EmissionContext): In
|
|
|
48
48
|
}
|
|
49
49
|
return oldRow[pkColIdx];
|
|
50
50
|
});
|
|
51
|
-
await vtab.
|
|
51
|
+
await vtab.update!('update', newRow, keyValues, ConflictResolution.ABORT);
|
|
52
52
|
// Track change (UPDATE): record OLD and NEW primary keys
|
|
53
53
|
const newKeyValues: SqlValue[] = tableSchema.primaryKeyDefinition.map(pkColDef => newRow[pkColDef.index]);
|
|
54
54
|
ctx.db._recordUpdate(`${tableSchema.schemaName}.${tableSchema.name}`, keyValues, newKeyValues);
|
|
@@ -72,7 +72,7 @@ export function emitDmlExecutor(plan: DmlExecutorNode, ctx: EmissionContext): In
|
|
|
72
72
|
}
|
|
73
73
|
return oldRow[pkColIdx];
|
|
74
74
|
});
|
|
75
|
-
await vtab.
|
|
75
|
+
await vtab.update!('delete', undefined, keyValues, ConflictResolution.ABORT);
|
|
76
76
|
// Track change (DELETE): record OLD primary key
|
|
77
77
|
ctx.db._recordDelete(`${tableSchema.schemaName}.${tableSchema.name}`, keyValues);
|
|
78
78
|
yield flatRow;
|
|
@@ -8,7 +8,7 @@ import type { AnyVirtualTableModule } from '../../vtab/module.js';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Emitter for RemoteQueryNode.
|
|
11
|
-
* Calls the virtual table's
|
|
11
|
+
* Calls the virtual table's executePlan() method to execute the pushed-down pipeline.
|
|
12
12
|
*/
|
|
13
13
|
export function emitRemoteQuery(plan: RemoteQueryNode, _ctx: EmissionContext): Instruction {
|
|
14
14
|
async function* run(rctx: RuntimeContext): AsyncIterable<Row> {
|
|
@@ -19,7 +19,7 @@ export function emitRemoteQuery(plan: RemoteQueryNode, _ctx: EmissionContext): I
|
|
|
19
19
|
const vtabModule = (moduleCtx as { vtabModule?: AnyVirtualTableModule } | undefined)?.vtabModule ?? tableRef.vtabModule;
|
|
20
20
|
|
|
21
21
|
// Connect to the table to get the instance
|
|
22
|
-
const table = vtabModule.
|
|
22
|
+
const table = vtabModule.connect(
|
|
23
23
|
rctx.db,
|
|
24
24
|
undefined, // pAux
|
|
25
25
|
tableSchema.vtabModuleName,
|
|
@@ -28,15 +28,15 @@ export function emitRemoteQuery(plan: RemoteQueryNode, _ctx: EmissionContext): I
|
|
|
28
28
|
{} // empty config for now
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
if (!table.
|
|
31
|
+
if (!table.executePlan) {
|
|
32
32
|
throw new QuereusError(
|
|
33
|
-
`Virtual table module for '${tableSchema.name}' does not implement
|
|
33
|
+
`Virtual table module for '${tableSchema.name}' does not implement executePlan() ` +
|
|
34
34
|
`despite indicating support via supports() method.`,
|
|
35
35
|
StatusCode.INTERNAL
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
yield* table.
|
|
39
|
+
yield* table.executePlan(rctx.db, plan.source, plan.moduleCtx);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return {
|