@quereus/quereus 0.6.1 → 0.6.3
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/dist/src/common/type-inference.d.ts +9 -1
- package/dist/src/common/type-inference.d.ts.map +1 -1
- package/dist/src/common/type-inference.js +11 -3
- package/dist/src/common/type-inference.js.map +1 -1
- package/dist/src/core/database.d.ts +27 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +39 -6
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/param.d.ts +17 -1
- package/dist/src/core/param.d.ts.map +1 -1
- package/dist/src/core/param.js +23 -1
- package/dist/src/core/param.js.map +1 -1
- package/dist/src/core/statement.d.ts +10 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +71 -5
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/planner/scopes/param.d.ts +2 -2
- package/dist/src/planner/scopes/param.d.ts.map +1 -1
- package/dist/src/planner/scopes/param.js +9 -9
- package/dist/src/planner/scopes/param.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +1 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/schema/schema-hasher.d.ts +3 -3
- package/dist/src/schema/schema-hasher.d.ts.map +1 -1
- package/dist/src/schema/schema-hasher.js +9 -27
- package/dist/src/schema/schema-hasher.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +5 -0
- package/dist/src/types/logical-type.d.ts.map +1 -1
- package/dist/src/types/logical-type.js +15 -0
- package/dist/src/types/logical-type.js.map +1 -1
- package/dist/src/util/hash.d.ts +19 -0
- package/dist/src/util/hash.d.ts.map +1 -0
- package/dist/src/util/hash.js +76 -0
- package/dist/src/util/hash.js.map +1 -0
- package/package.json +1 -1
- package/src/common/type-inference.ts +11 -3
- package/src/core/database.ts +41 -6
- package/src/core/param.ts +23 -1
- package/src/core/statement.ts +89 -5
- package/src/planner/building/delete.ts +214 -214
- package/src/planner/building/insert.ts +428 -428
- package/src/planner/building/update.ts +319 -319
- package/src/planner/scopes/param.ts +9 -9
- package/src/runtime/emit/schema-declarative.ts +1 -1
- package/src/schema/schema-hasher.ts +9 -27
- package/src/types/index.ts +1 -1
- package/src/types/logical-type.ts +16 -0
- package/src/util/ast-stringify.ts +864 -864
- package/src/util/hash.ts +90 -0
- package/src/vtab/memory/table.ts +256 -256
- package/src/vtab/table.ts +162 -162
package/src/vtab/table.ts
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
import type { AnyVirtualTableModule, SchemaChangeInfo } from './module.js';
|
|
2
|
-
import type { Database } from '../core/database.js';
|
|
3
|
-
import type { TableSchema } from '../schema/table.js';
|
|
4
|
-
import type { MaybePromise, Row } from '../common/types.js';
|
|
5
|
-
import type { IndexSchema } from '../schema/table.js';
|
|
6
|
-
import type { FilterInfo } from './filter-info.js';
|
|
7
|
-
import type { RowOp } from '../common/types.js';
|
|
8
|
-
import type { ConflictResolution } from '../common/constants.js';
|
|
9
|
-
import type { VirtualTableConnection } from './connection.js';
|
|
10
|
-
import type { PlanNode } from '../planner/nodes/plan-node.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Base class representing a virtual table instance.
|
|
14
|
-
* Module implementations should subclass this to provide specific table behavior.
|
|
15
|
-
*/
|
|
16
|
-
export abstract class VirtualTable {
|
|
17
|
-
public readonly module: AnyVirtualTableModule;
|
|
18
|
-
public readonly db: Database;
|
|
19
|
-
public readonly tableName: string;
|
|
20
|
-
public readonly schemaName: string;
|
|
21
|
-
public errorMessage?: string;
|
|
22
|
-
public tableSchema?: TableSchema;
|
|
23
|
-
|
|
24
|
-
constructor(db: Database, module: AnyVirtualTableModule, schemaName: string, tableName: string) {
|
|
25
|
-
this.db = db;
|
|
26
|
-
this.module = module;
|
|
27
|
-
this.schemaName = schemaName;
|
|
28
|
-
this.tableName = tableName;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Sets an error message for the VTable
|
|
33
|
-
* @param message The error message string
|
|
34
|
-
*/
|
|
35
|
-
protected setErrorMessage(message: string | undefined): void {
|
|
36
|
-
this.errorMessage = message;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Disconnects from this virtual table connection instance
|
|
41
|
-
* Called when the database connection closes or the statement is finalized
|
|
42
|
-
* @throws QuereusError on failure
|
|
43
|
-
*/
|
|
44
|
-
abstract disconnect(): Promise<void>;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* (Optional) Opens a direct data stream for this virtual table based on filter criteria.
|
|
48
|
-
* This is an alternative to the cursor-based open/filter/next model.
|
|
49
|
-
* @param filterInfo Information from getBestAccessPlan and query parameters.
|
|
50
|
-
* @returns An AsyncIterable yielding Row tuples.
|
|
51
|
-
* @throws QuereusError on failure
|
|
52
|
-
*/
|
|
53
|
-
query?(filterInfo: FilterInfo): AsyncIterable<Row>;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Executes a pushed-down plan subtree.
|
|
57
|
-
* Called when the module indicated support via supports() method.
|
|
58
|
-
*
|
|
59
|
-
* @param db The database connection
|
|
60
|
-
* @param plan The plan node to execute
|
|
61
|
-
* @param ctx Optional context from supports() assessment
|
|
62
|
-
* @returns Async iterable of rows resulting from the plan execution
|
|
63
|
-
*/
|
|
64
|
-
executePlan?(
|
|
65
|
-
db: Database,
|
|
66
|
-
plan: PlanNode,
|
|
67
|
-
ctx?: unknown
|
|
68
|
-
): AsyncIterable<Row>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Performs an INSERT, UPDATE, or DELETE operation
|
|
72
|
-
* @param operation The operation to perform (insert, update, delete)
|
|
73
|
-
* @param values For INSERT/UPDATE, the values to insert/update. For DELETE, undefined
|
|
74
|
-
* @param oldKeyValues For UPDATE/DELETE, the old key values of the row to modify. Undefined for INSERT
|
|
75
|
-
* @param onConflict Conflict resolution mode (defaults to ABORT if unspecified)
|
|
76
|
-
* @returns new row for INSERT/UPDATE, undefined for DELETE
|
|
77
|
-
* @throws QuereusError or ConstraintError on failure
|
|
78
|
-
*/
|
|
79
|
-
abstract update(
|
|
80
|
-
operation: RowOp,
|
|
81
|
-
values: Row | undefined,
|
|
82
|
-
oldKeyValues?: Row,
|
|
83
|
-
onConflict?: ConflictResolution
|
|
84
|
-
): Promise<Row | undefined>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* (Optional) Creates a new connection for transaction support.
|
|
88
|
-
* If implemented, this enables proper transaction isolation for this table.
|
|
89
|
-
* @returns A new VirtualTableConnection instance
|
|
90
|
-
*/
|
|
91
|
-
createConnection?(): MaybePromise<VirtualTableConnection>;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* (Optional) Gets the current connection for this table instance.
|
|
95
|
-
* Used when the table maintains a single connection internally.
|
|
96
|
-
* @returns The current VirtualTableConnection instance, if any
|
|
97
|
-
*/
|
|
98
|
-
getConnection?(): VirtualTableConnection | undefined;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Begins a transaction on this virtual table
|
|
102
|
-
*/
|
|
103
|
-
begin?(): Promise<void>;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Syncs changes within the virtual table transaction
|
|
107
|
-
*/
|
|
108
|
-
sync?(): Promise<void>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Commits the virtual table transaction
|
|
112
|
-
*/
|
|
113
|
-
commit?(): Promise<void>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Rolls back the virtual table transaction
|
|
117
|
-
*/
|
|
118
|
-
rollback?(): Promise<void>;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Renames the virtual table
|
|
122
|
-
* @param newName The new name for the table
|
|
123
|
-
*/
|
|
124
|
-
rename?(newName: string): Promise<void>;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Begins a savepoint
|
|
128
|
-
* @param savepointIndex The savepoint identifier
|
|
129
|
-
*/
|
|
130
|
-
savepoint?(savepointIndex: number): Promise<void>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Releases a savepoint
|
|
134
|
-
* @param savepointIndex The savepoint identifier
|
|
135
|
-
*/
|
|
136
|
-
release?(savepointIndex: number): Promise<void>;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Rolls back to a savepoint
|
|
140
|
-
* @param savepointIndex The savepoint identifier
|
|
141
|
-
*/
|
|
142
|
-
rollbackTo?(savepointIndex: number): Promise<void>;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Modifies the schema of this virtual table
|
|
146
|
-
* @param changeInfo Object describing the schema modification
|
|
147
|
-
* @throws QuereusError or ConstraintError on failure
|
|
148
|
-
*/
|
|
149
|
-
alterSchema?(changeInfo: SchemaChangeInfo): Promise<void>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Creates a secondary index on the virtual table
|
|
153
|
-
* @param indexInfo The index definition
|
|
154
|
-
*/
|
|
155
|
-
createIndex?(indexInfo: IndexSchema): Promise<void>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Drops a secondary index from the virtual table
|
|
159
|
-
* @param indexName The name of the index to drop
|
|
160
|
-
*/
|
|
161
|
-
dropIndex?(indexName: string): Promise<void>;
|
|
162
|
-
}
|
|
1
|
+
import type { AnyVirtualTableModule, SchemaChangeInfo } from './module.js';
|
|
2
|
+
import type { Database } from '../core/database.js';
|
|
3
|
+
import type { TableSchema } from '../schema/table.js';
|
|
4
|
+
import type { MaybePromise, Row } from '../common/types.js';
|
|
5
|
+
import type { IndexSchema } from '../schema/table.js';
|
|
6
|
+
import type { FilterInfo } from './filter-info.js';
|
|
7
|
+
import type { RowOp } from '../common/types.js';
|
|
8
|
+
import type { ConflictResolution } from '../common/constants.js';
|
|
9
|
+
import type { VirtualTableConnection } from './connection.js';
|
|
10
|
+
import type { PlanNode } from '../planner/nodes/plan-node.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Base class representing a virtual table instance.
|
|
14
|
+
* Module implementations should subclass this to provide specific table behavior.
|
|
15
|
+
*/
|
|
16
|
+
export abstract class VirtualTable {
|
|
17
|
+
public readonly module: AnyVirtualTableModule;
|
|
18
|
+
public readonly db: Database;
|
|
19
|
+
public readonly tableName: string;
|
|
20
|
+
public readonly schemaName: string;
|
|
21
|
+
public errorMessage?: string;
|
|
22
|
+
public tableSchema?: TableSchema;
|
|
23
|
+
|
|
24
|
+
constructor(db: Database, module: AnyVirtualTableModule, schemaName: string, tableName: string) {
|
|
25
|
+
this.db = db;
|
|
26
|
+
this.module = module;
|
|
27
|
+
this.schemaName = schemaName;
|
|
28
|
+
this.tableName = tableName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets an error message for the VTable
|
|
33
|
+
* @param message The error message string
|
|
34
|
+
*/
|
|
35
|
+
protected setErrorMessage(message: string | undefined): void {
|
|
36
|
+
this.errorMessage = message;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Disconnects from this virtual table connection instance
|
|
41
|
+
* Called when the database connection closes or the statement is finalized
|
|
42
|
+
* @throws QuereusError on failure
|
|
43
|
+
*/
|
|
44
|
+
abstract disconnect(): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* (Optional) Opens a direct data stream for this virtual table based on filter criteria.
|
|
48
|
+
* This is an alternative to the cursor-based open/filter/next model.
|
|
49
|
+
* @param filterInfo Information from getBestAccessPlan and query parameters.
|
|
50
|
+
* @returns An AsyncIterable yielding Row tuples.
|
|
51
|
+
* @throws QuereusError on failure
|
|
52
|
+
*/
|
|
53
|
+
query?(filterInfo: FilterInfo): AsyncIterable<Row>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Executes a pushed-down plan subtree.
|
|
57
|
+
* Called when the module indicated support via supports() method.
|
|
58
|
+
*
|
|
59
|
+
* @param db The database connection
|
|
60
|
+
* @param plan The plan node to execute
|
|
61
|
+
* @param ctx Optional context from supports() assessment
|
|
62
|
+
* @returns Async iterable of rows resulting from the plan execution
|
|
63
|
+
*/
|
|
64
|
+
executePlan?(
|
|
65
|
+
db: Database,
|
|
66
|
+
plan: PlanNode,
|
|
67
|
+
ctx?: unknown
|
|
68
|
+
): AsyncIterable<Row>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Performs an INSERT, UPDATE, or DELETE operation
|
|
72
|
+
* @param operation The operation to perform (insert, update, delete)
|
|
73
|
+
* @param values For INSERT/UPDATE, the values to insert/update. For DELETE, undefined
|
|
74
|
+
* @param oldKeyValues For UPDATE/DELETE, the old key values of the row to modify. Undefined for INSERT
|
|
75
|
+
* @param onConflict Conflict resolution mode (defaults to ABORT if unspecified)
|
|
76
|
+
* @returns new row for INSERT/UPDATE, undefined for DELETE
|
|
77
|
+
* @throws QuereusError or ConstraintError on failure
|
|
78
|
+
*/
|
|
79
|
+
abstract update(
|
|
80
|
+
operation: RowOp,
|
|
81
|
+
values: Row | undefined,
|
|
82
|
+
oldKeyValues?: Row,
|
|
83
|
+
onConflict?: ConflictResolution
|
|
84
|
+
): Promise<Row | undefined>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* (Optional) Creates a new connection for transaction support.
|
|
88
|
+
* If implemented, this enables proper transaction isolation for this table.
|
|
89
|
+
* @returns A new VirtualTableConnection instance
|
|
90
|
+
*/
|
|
91
|
+
createConnection?(): MaybePromise<VirtualTableConnection>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* (Optional) Gets the current connection for this table instance.
|
|
95
|
+
* Used when the table maintains a single connection internally.
|
|
96
|
+
* @returns The current VirtualTableConnection instance, if any
|
|
97
|
+
*/
|
|
98
|
+
getConnection?(): VirtualTableConnection | undefined;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Begins a transaction on this virtual table
|
|
102
|
+
*/
|
|
103
|
+
begin?(): Promise<void>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Syncs changes within the virtual table transaction
|
|
107
|
+
*/
|
|
108
|
+
sync?(): Promise<void>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Commits the virtual table transaction
|
|
112
|
+
*/
|
|
113
|
+
commit?(): Promise<void>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Rolls back the virtual table transaction
|
|
117
|
+
*/
|
|
118
|
+
rollback?(): Promise<void>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Renames the virtual table
|
|
122
|
+
* @param newName The new name for the table
|
|
123
|
+
*/
|
|
124
|
+
rename?(newName: string): Promise<void>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Begins a savepoint
|
|
128
|
+
* @param savepointIndex The savepoint identifier
|
|
129
|
+
*/
|
|
130
|
+
savepoint?(savepointIndex: number): Promise<void>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Releases a savepoint
|
|
134
|
+
* @param savepointIndex The savepoint identifier
|
|
135
|
+
*/
|
|
136
|
+
release?(savepointIndex: number): Promise<void>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Rolls back to a savepoint
|
|
140
|
+
* @param savepointIndex The savepoint identifier
|
|
141
|
+
*/
|
|
142
|
+
rollbackTo?(savepointIndex: number): Promise<void>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Modifies the schema of this virtual table
|
|
146
|
+
* @param changeInfo Object describing the schema modification
|
|
147
|
+
* @throws QuereusError or ConstraintError on failure
|
|
148
|
+
*/
|
|
149
|
+
alterSchema?(changeInfo: SchemaChangeInfo): Promise<void>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Creates a secondary index on the virtual table
|
|
153
|
+
* @param indexInfo The index definition
|
|
154
|
+
*/
|
|
155
|
+
createIndex?(indexInfo: IndexSchema): Promise<void>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Drops a secondary index from the virtual table
|
|
159
|
+
* @param indexName The name of the index to drop
|
|
160
|
+
*/
|
|
161
|
+
dropIndex?(indexName: string): Promise<void>;
|
|
162
|
+
}
|