@quereus/quereus 0.4.6 → 0.4.9
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/config/loader.d.ts +41 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +102 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/core/database.d.ts +1 -1
- package/dist/src/core/database.js +2 -2
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/planner/building/create-view.d.ts.map +1 -1
- package/dist/src/planner/building/create-view.js +3 -25
- package/dist/src/planner/building/create-view.js.map +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +20 -1
- package/dist/src/planner/building/select.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/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/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/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +18 -3
- package/dist/src/schema/catalog.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/schema/schema-differ.js +3 -3
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/util/ast-stringify.d.ts +1 -0
- package/dist/src/util/ast-stringify.d.ts.map +1 -1
- package/dist/src/util/ast-stringify.js +1 -1
- 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/config/loader.ts +140 -0
- package/src/core/database.ts +2 -2
- package/src/index.ts +9 -0
- package/src/planner/building/create-view.ts +3 -30
- package/src/planner/building/select.ts +29 -1
- package/src/planner/nodes/dml-executor-node.ts +1 -1
- 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/update.ts +1 -1
- package/src/runtime/utils.ts +6 -6
- package/src/schema/catalog.ts +17 -3
- package/src/schema/manager.ts +20 -20
- package/src/schema/schema-differ.ts +3 -3
- package/src/util/ast-stringify.ts +1 -1
- 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","sourceRoot":"","sources":["../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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,KAAK,EAAE,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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,oBAAoB,CAAC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AAI,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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loader for Quoomb
|
|
3
|
+
* Handles loading, parsing, and interpolating quoomb.config.json files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Database } from '../core/database.js';
|
|
7
|
+
import type { SqlValue } from '../common/types.js';
|
|
8
|
+
import { loadPlugin } from '../util/plugin-loader.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Plugin configuration from config file
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginConfig {
|
|
14
|
+
source: string;
|
|
15
|
+
config?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Quoomb configuration file format
|
|
20
|
+
*/
|
|
21
|
+
export interface QuoombConfig {
|
|
22
|
+
$schema?: string;
|
|
23
|
+
plugins?: PluginConfig[];
|
|
24
|
+
autoload?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Interpolate environment variables in a value
|
|
29
|
+
* Supports ${VAR_NAME} and ${VAR_NAME:-default} syntax
|
|
30
|
+
*/
|
|
31
|
+
export function interpolateEnvVars(value: any, env: Record<string, string> = {}): any {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return value.replace(/\$\{([^}]+)\}/g, (match, varSpec) => {
|
|
34
|
+
const [varName, defaultValue] = varSpec.split(':-');
|
|
35
|
+
return env[varName.trim()] ?? defaultValue ?? match;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === 'object' && value !== null) {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return value.map(v => interpolateEnvVars(v, env));
|
|
41
|
+
}
|
|
42
|
+
const result: Record<string, any> = {};
|
|
43
|
+
for (const [key, val] of Object.entries(value)) {
|
|
44
|
+
result[key] = interpolateEnvVars(val, env);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Interpolate environment variables in a config object
|
|
53
|
+
*/
|
|
54
|
+
export function interpolateConfigEnvVars(config: QuoombConfig, env?: Record<string, string>): QuoombConfig {
|
|
55
|
+
let envVars: Record<string, string> = {};
|
|
56
|
+
|
|
57
|
+
if (env) {
|
|
58
|
+
envVars = env;
|
|
59
|
+
} else if (typeof process !== 'undefined' && process.env) {
|
|
60
|
+
// Filter out undefined values from process.env
|
|
61
|
+
envVars = Object.fromEntries(
|
|
62
|
+
Object.entries(process.env).filter(([, v]) => v !== undefined) as Array<[string, string]>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return interpolateEnvVars(config, envVars);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Load plugins from a config object
|
|
71
|
+
*/
|
|
72
|
+
export async function loadPluginsFromConfig(
|
|
73
|
+
db: Database,
|
|
74
|
+
config: QuoombConfig,
|
|
75
|
+
options?: { allowCdn?: boolean; env?: 'auto' | 'browser' | 'node' }
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
if (!config.plugins || config.plugins.length === 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const pluginConfig of config.plugins) {
|
|
82
|
+
try {
|
|
83
|
+
const configObj = pluginConfig.config ?? {};
|
|
84
|
+
|
|
85
|
+
// Convert config values to SqlValue type
|
|
86
|
+
const sqlConfig: Record<string, SqlValue> = {};
|
|
87
|
+
for (const [key, value] of Object.entries(configObj)) {
|
|
88
|
+
if (value === null || value === undefined) {
|
|
89
|
+
sqlConfig[key] = null;
|
|
90
|
+
} else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
91
|
+
sqlConfig[key] = value;
|
|
92
|
+
} else {
|
|
93
|
+
// For complex types, convert to JSON string
|
|
94
|
+
sqlConfig[key] = JSON.stringify(value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
await loadPlugin(pluginConfig.source, db, sqlConfig, options);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn(
|
|
101
|
+
`Warning: Failed to load plugin from ${pluginConfig.source}: ${
|
|
102
|
+
error instanceof Error ? error.message : 'Unknown error'
|
|
103
|
+
}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Validate a config object
|
|
111
|
+
*/
|
|
112
|
+
export function validateConfig(config: any): config is QuoombConfig {
|
|
113
|
+
if (typeof config !== 'object' || config === null) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (config.plugins !== undefined) {
|
|
118
|
+
if (!Array.isArray(config.plugins)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
for (const plugin of config.plugins) {
|
|
122
|
+
if (typeof plugin !== 'object' || plugin === null) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
if (typeof plugin.source !== 'string') {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (plugin.config !== undefined && typeof plugin.config !== 'object') {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (config.autoload !== undefined && typeof config.autoload !== 'boolean') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
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();
|
|
@@ -377,7 +377,7 @@ export class Database {
|
|
|
377
377
|
this.statements.clear();
|
|
378
378
|
|
|
379
379
|
// Clear schemas, ensuring VTabs are potentially disconnected
|
|
380
|
-
// This will also call
|
|
380
|
+
// This will also call destroy on VTabs via SchemaManager.clearAll -> schema.clearTables -> schemaManager.dropTable
|
|
381
381
|
this.schemaManager.clearAll();
|
|
382
382
|
|
|
383
383
|
// this.registeredVTabs.clear(); // Removed, SchemaManager handles module lifecycle
|
package/src/index.ts
CHANGED
|
@@ -93,6 +93,15 @@ export type {
|
|
|
93
93
|
PluginRegistrations
|
|
94
94
|
} from './vtab/manifest.js';
|
|
95
95
|
|
|
96
|
+
// Re-export config system
|
|
97
|
+
export {
|
|
98
|
+
interpolateEnvVars,
|
|
99
|
+
interpolateConfigEnvVars,
|
|
100
|
+
loadPluginsFromConfig,
|
|
101
|
+
validateConfig
|
|
102
|
+
} from './config/loader.js';
|
|
103
|
+
export type { QuoombConfig, PluginConfig } from './config/loader.js';
|
|
104
|
+
|
|
96
105
|
// Re-export virtual table framework
|
|
97
106
|
export type { VirtualTableModule } from './vtab/module.js';
|
|
98
107
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as AST from '../../parser/ast.js';
|
|
2
2
|
import type { PlanningContext } from '../planning-context.js';
|
|
3
3
|
import { CreateViewNode } from '../nodes/create-view-node.js';
|
|
4
|
+
import { createViewToString } from '../../util/ast-stringify.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Builds a plan node for CREATE VIEW statements.
|
|
@@ -11,9 +12,8 @@ export function buildCreateViewStmt(ctx: PlanningContext, stmt: AST.CreateViewSt
|
|
|
11
12
|
const viewName = stmt.view.name;
|
|
12
13
|
|
|
13
14
|
// The original SQL text is needed for the view definition
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
const sql = reconstructViewSQL(stmt);
|
|
15
|
+
// Reconstruct it from the AST using the proper stringifier
|
|
16
|
+
const sql = createViewToString(stmt);
|
|
17
17
|
|
|
18
18
|
return new CreateViewNode(
|
|
19
19
|
ctx.scope,
|
|
@@ -26,31 +26,4 @@ export function buildCreateViewStmt(ctx: PlanningContext, stmt: AST.CreateViewSt
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Reconstructs the original SQL text for a CREATE VIEW statement.
|
|
31
|
-
* This is a simplified version - in production, the original text should be preserved.
|
|
32
|
-
*/
|
|
33
|
-
function reconstructViewSQL(stmt: AST.CreateViewStmt): string {
|
|
34
|
-
let sql = 'CREATE VIEW ';
|
|
35
|
-
|
|
36
|
-
if (stmt.ifNotExists) {
|
|
37
|
-
sql += 'IF NOT EXISTS ';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (stmt.view.schema) {
|
|
41
|
-
sql += `${stmt.view.schema}.`;
|
|
42
|
-
}
|
|
43
|
-
sql += stmt.view.name;
|
|
44
29
|
|
|
45
|
-
if (stmt.columns && stmt.columns.length > 0) {
|
|
46
|
-
sql += ` (${stmt.columns.join(', ')})`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
sql += ' AS ';
|
|
50
|
-
|
|
51
|
-
// For now, just add a placeholder for the SELECT statement
|
|
52
|
-
// In a full implementation, this would reconstruct the full SELECT
|
|
53
|
-
sql += '(SELECT statement)';
|
|
54
|
-
|
|
55
|
-
return sql;
|
|
56
|
-
}
|
|
@@ -333,7 +333,35 @@ export function buildFrom(fromClause: AST.FromClause, parentContext: PlanningCon
|
|
|
333
333
|
|
|
334
334
|
if (viewSchema) {
|
|
335
335
|
// Build the view's SELECT statement
|
|
336
|
-
|
|
336
|
+
let viewSelectNode = buildSelectStmt(parentContext, viewSchema.selectAst, cteNodes) as RelationalPlanNode;
|
|
337
|
+
|
|
338
|
+
// If the view has explicit column names, wrap with a projection to rename columns
|
|
339
|
+
if (viewSchema.columns && viewSchema.columns.length > 0) {
|
|
340
|
+
const viewAttributes = viewSelectNode.getAttributes();
|
|
341
|
+
const projections = viewSchema.columns.map((columnName, i) => {
|
|
342
|
+
if (i >= viewAttributes.length) {
|
|
343
|
+
throw new QuereusError(
|
|
344
|
+
`View '${viewSchema.name}' has more explicit column names than SELECT columns`,
|
|
345
|
+
StatusCode.ERROR
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
const attr = viewAttributes[i];
|
|
349
|
+
const columnRef = new ColumnReferenceNode(
|
|
350
|
+
parentContext.scope,
|
|
351
|
+
{ type: 'column', name: attr.name } as AST.ColumnExpr,
|
|
352
|
+
attr.type,
|
|
353
|
+
attr.id,
|
|
354
|
+
i
|
|
355
|
+
);
|
|
356
|
+
return {
|
|
357
|
+
node: columnRef,
|
|
358
|
+
alias: columnName
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
fromTable = new ProjectNode(parentContext.scope, viewSelectNode, projections);
|
|
362
|
+
} else {
|
|
363
|
+
fromTable = viewSelectNode;
|
|
364
|
+
}
|
|
337
365
|
|
|
338
366
|
// Create scope for view columns
|
|
339
367
|
const viewScope = new RegisteredScope(parentContext.scope);
|
|
@@ -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 {
|