opfsql 0.0.2
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/LICENSE +19 -0
- package/README.md +198 -0
- package/dist/binder/core/context.d.ts +15 -0
- package/dist/binder/core/errors.d.ts +4 -0
- package/dist/binder/core/helpers.d.ts +6 -0
- package/dist/binder/core/operators.d.ts +12 -0
- package/dist/binder/core/plan-utils.d.ts +4 -0
- package/dist/binder/core/scope.d.ts +34 -0
- package/dist/binder/core/type-check.d.ts +5 -0
- package/dist/binder/core/type-map.d.ts +8 -0
- package/dist/binder/core/utils/eval-constant.d.ts +4 -0
- package/dist/binder/core/utils/extract-columns.d.ts +4 -0
- package/dist/binder/core/utils/find-column.d.ts +4 -0
- package/dist/binder/core/utils/require-table.d.ts +3 -0
- package/dist/binder/expression/aggregate.d.ts +11 -0
- package/dist/binder/expression/between.d.ts +5 -0
- package/dist/binder/expression/case.d.ts +5 -0
- package/dist/binder/expression/cast.d.ts +5 -0
- package/dist/binder/expression/column-ref.d.ts +5 -0
- package/dist/binder/expression/comparison.d.ts +5 -0
- package/dist/binder/expression/conjunction.d.ts +5 -0
- package/dist/binder/expression/constant.d.ts +3 -0
- package/dist/binder/expression/function.d.ts +5 -0
- package/dist/binder/expression/index.d.ts +5 -0
- package/dist/binder/expression/operator.d.ts +5 -0
- package/dist/binder/expression/parameter.d.ts +4 -0
- package/dist/binder/expression/same-expression.d.ts +3 -0
- package/dist/binder/expression/star.d.ts +5 -0
- package/dist/binder/expression/subquery.d.ts +5 -0
- package/dist/binder/index.d.ts +30 -0
- package/dist/binder/statement/alter-table.d.ts +4 -0
- package/dist/binder/statement/create-index.d.ts +4 -0
- package/dist/binder/statement/create-table.d.ts +4 -0
- package/dist/binder/statement/cte.d.ts +16 -0
- package/dist/binder/statement/delete.d.ts +4 -0
- package/dist/binder/statement/drop.d.ts +3 -0
- package/dist/binder/statement/insert.d.ts +4 -0
- package/dist/binder/statement/query-node.d.ts +5 -0
- package/dist/binder/statement/select.d.ts +5 -0
- package/dist/binder/statement/set-operation.d.ts +5 -0
- package/dist/binder/statement/update.d.ts +4 -0
- package/dist/binder/table-ref/base-table.d.ts +5 -0
- package/dist/binder/table-ref/index.d.ts +5 -0
- package/dist/binder/table-ref/join.d.ts +6 -0
- package/dist/binder/table-ref/subquery.d.ts +5 -0
- package/dist/binder/tests/aggregates.test.d.ts +1 -0
- package/dist/binder/tests/binder.test.d.ts +1 -0
- package/dist/binder/tests/cte.test.d.ts +1 -0
- package/dist/binder/tests/ddl.test.d.ts +1 -0
- package/dist/binder/tests/dml.test.d.ts +1 -0
- package/dist/binder/tests/expressions.test.d.ts +1 -0
- package/dist/binder/tests/join.test.d.ts +1 -0
- package/dist/binder/tests/misc.test.d.ts +1 -0
- package/dist/binder/tests/select.test.d.ts +1 -0
- package/dist/binder/tests/subquery.test.d.ts +1 -0
- package/dist/binder/tests/test_helpers.d.ts +14 -0
- package/dist/binder/tests/union.test.d.ts +1 -0
- package/dist/binder/tests/utils.test.d.ts +1 -0
- package/dist/binder/types.d.ts +401 -0
- package/dist/engine/engine.d.ts +23 -0
- package/dist/engine/explain.d.ts +3 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/session.d.ts +43 -0
- package/dist/engine/tests/engine.test.d.ts +1 -0
- package/dist/engine/tests/explain-format.test.d.ts +1 -0
- package/dist/engine/tests/explain.test.d.ts +1 -0
- package/dist/engine/tests/session.test.d.ts +1 -0
- package/dist/engine/types.d.ts +19 -0
- package/dist/executor/ddl/alter-drop.d.ts +5 -0
- package/dist/executor/ddl/create.d.ts +5 -0
- package/dist/executor/ddl/index.d.ts +2 -0
- package/dist/executor/ddl.d.ts +8 -0
- package/dist/executor/dml/delete.d.ts +5 -0
- package/dist/executor/dml/index.d.ts +3 -0
- package/dist/executor/dml/insert.d.ts +5 -0
- package/dist/executor/dml/update.d.ts +5 -0
- package/dist/executor/dml/utils/coerce.d.ts +3 -0
- package/dist/executor/dml/utils/index-maintenance.d.ts +5 -0
- package/dist/executor/dml/utils/scan.d.ts +16 -0
- package/dist/executor/dml.d.ts +8 -0
- package/dist/executor/errors.d.ts +4 -0
- package/dist/executor/evaluate/aggregate.d.ts +4 -0
- package/dist/executor/evaluate/between.d.ts +5 -0
- package/dist/executor/evaluate/case.d.ts +5 -0
- package/dist/executor/evaluate/cast.d.ts +5 -0
- package/dist/executor/evaluate/column-ref.d.ts +5 -0
- package/dist/executor/evaluate/comparison.d.ts +5 -0
- package/dist/executor/evaluate/compile.d.ts +11 -0
- package/dist/executor/evaluate/conjunction.d.ts +5 -0
- package/dist/executor/evaluate/context.d.ts +9 -0
- package/dist/executor/evaluate/function.d.ts +5 -0
- package/dist/executor/evaluate/functions/md5.d.ts +1 -0
- package/dist/executor/evaluate/functions/normalize-json.d.ts +8 -0
- package/dist/executor/evaluate/helpers.d.ts +14 -0
- package/dist/executor/evaluate/index.d.ts +6 -0
- package/dist/executor/evaluate/json-access.d.ts +7 -0
- package/dist/executor/evaluate/operator.d.ts +5 -0
- package/dist/executor/evaluate/parameter.d.ts +4 -0
- package/dist/executor/evaluate/subquery.d.ts +5 -0
- package/dist/executor/evaluate/utils/cast.d.ts +7 -0
- package/dist/executor/evaluate/utils/compare.d.ts +8 -0
- package/dist/executor/evaluate/utils/like.d.ts +2 -0
- package/dist/executor/evaluate/utils/serialize.d.ts +3 -0
- package/dist/executor/execute/index.d.ts +4 -0
- package/dist/executor/execute/result.d.ts +5 -0
- package/dist/executor/execute/select.d.ts +8 -0
- package/dist/executor/executor.d.ts +5 -0
- package/dist/executor/index.d.ts +3 -0
- package/dist/executor/operators/aggregate.d.ts +22 -0
- package/dist/executor/operators/cte.d.ts +37 -0
- package/dist/executor/operators/filter.d.ts +13 -0
- package/dist/executor/operators/index-min-max.d.ts +18 -0
- package/dist/executor/operators/index-scan.d.ts +22 -0
- package/dist/executor/operators/index-union-scan.d.ts +22 -0
- package/dist/executor/operators/join.d.ts +36 -0
- package/dist/executor/operators/limit.d.ts +13 -0
- package/dist/executor/operators/projection.d.ts +14 -0
- package/dist/executor/operators/scan.d.ts +29 -0
- package/dist/executor/operators/set.d.ts +22 -0
- package/dist/executor/operators/sort.d.ts +18 -0
- package/dist/executor/operators/utils.d.ts +10 -0
- package/dist/executor/planner/index.d.ts +5 -0
- package/dist/executor/planner/plan-aggregate.d.ts +5 -0
- package/dist/executor/planner/plan-cte.d.ts +6 -0
- package/dist/executor/planner/plan-filter.d.ts +4 -0
- package/dist/executor/planner/plan-get.d.ts +6 -0
- package/dist/executor/planner/plan-join.d.ts +5 -0
- package/dist/executor/planner/plan-limit.d.ts +4 -0
- package/dist/executor/planner/plan-order-by.d.ts +4 -0
- package/dist/executor/planner/plan-projection.d.ts +4 -0
- package/dist/executor/planner/plan-set.d.ts +5 -0
- package/dist/executor/planner/types.d.ts +12 -0
- package/dist/executor/planner.d.ts +5 -0
- package/dist/executor/resolve.d.ts +3 -0
- package/dist/executor/tests/compile.test.d.ts +1 -0
- package/dist/executor/tests/ddl-dml.test.d.ts +1 -0
- package/dist/executor/tests/evaluate.test.d.ts +1 -0
- package/dist/executor/tests/executor.test.d.ts +1 -0
- package/dist/executor/tests/functions.test.d.ts +1 -0
- package/dist/executor/tests/helpers.d.ts +34 -0
- package/dist/executor/tests/index-min-max.test.d.ts +1 -0
- package/dist/executor/tests/index-scan.test.d.ts +1 -0
- package/dist/executor/tests/index-union-scan.test.d.ts +1 -0
- package/dist/executor/tests/operators.test.d.ts +1 -0
- package/dist/executor/tests/planner.test.d.ts +1 -0
- package/dist/executor/tests/scan.test.d.ts +1 -0
- package/dist/executor/types.d.ts +39 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/optimizer/build_probe_side.d.ts +2 -0
- package/dist/optimizer/decorrelate_exists.d.ts +2 -0
- package/dist/optimizer/expression_rewriter.d.ts +2 -0
- package/dist/optimizer/filter_combiner.d.ts +13 -0
- package/dist/optimizer/filter_pullup.d.ts +2 -0
- package/dist/optimizer/filter_pushdown.d.ts +2 -0
- package/dist/optimizer/in_clause_rewriter.d.ts +2 -0
- package/dist/optimizer/index.d.ts +15 -0
- package/dist/optimizer/index_selection.d.ts +3 -0
- package/dist/optimizer/join_order.d.ts +2 -0
- package/dist/optimizer/limit_pushdown.d.ts +2 -0
- package/dist/optimizer/remove_unused_columns.d.ts +2 -0
- package/dist/optimizer/reorder_filter.d.ts +4 -0
- package/dist/optimizer/tests/build_probe_side.test.d.ts +1 -0
- package/dist/optimizer/tests/decorrelate_exists.test.d.ts +1 -0
- package/dist/optimizer/tests/expression_rewriter.test.d.ts +1 -0
- package/dist/optimizer/tests/filter_combiner.test.d.ts +1 -0
- package/dist/optimizer/tests/filter_pullup.test.d.ts +1 -0
- package/dist/optimizer/tests/filter_pushdown.test.d.ts +1 -0
- package/dist/optimizer/tests/full_pipeline.test.d.ts +1 -0
- package/dist/optimizer/tests/in_clause_rewriter.test.d.ts +1 -0
- package/dist/optimizer/tests/index_selection.test.d.ts +1 -0
- package/dist/optimizer/tests/join_order.test.d.ts +1 -0
- package/dist/optimizer/tests/limit_pushdown.test.d.ts +1 -0
- package/dist/optimizer/tests/optimizer.test.d.ts +1 -0
- package/dist/optimizer/tests/remove_unused_columns.test.d.ts +1 -0
- package/dist/optimizer/tests/reorder_filter.test.d.ts +1 -0
- package/dist/optimizer/tests/test_helpers.d.ts +27 -0
- package/dist/optimizer/tests/utils.test.d.ts +1 -0
- package/dist/optimizer/utils/collect_column_refs.d.ts +2 -0
- package/dist/optimizer/utils/expression_key.d.ts +7 -0
- package/dist/optimizer/utils/expression_references_table.d.ts +2 -0
- package/dist/optimizer/utils/expressions_equal.d.ts +1 -0
- package/dist/optimizer/utils/flatten_conjunction.d.ts +2 -0
- package/dist/optimizer/utils/flip_comparison.d.ts +2 -0
- package/dist/optimizer/utils/get_expression_tables.d.ts +2 -0
- package/dist/optimizer/utils/get_operator_tables.d.ts +2 -0
- package/dist/optimizer/utils/index.d.ts +23 -0
- package/dist/optimizer/utils/is_column_ref.d.ts +2 -0
- package/dist/optimizer/utils/is_comparison.d.ts +2 -0
- package/dist/optimizer/utils/is_conjunction.d.ts +2 -0
- package/dist/optimizer/utils/is_constant.d.ts +2 -0
- package/dist/optimizer/utils/is_foldable.d.ts +2 -0
- package/dist/optimizer/utils/is_numeric_type.d.ts +2 -0
- package/dist/optimizer/utils/is_operator.d.ts +2 -0
- package/dist/optimizer/utils/is_parameter.d.ts +2 -0
- package/dist/optimizer/utils/make_bool_constant.d.ts +2 -0
- package/dist/optimizer/utils/make_conjunction.d.ts +2 -0
- package/dist/optimizer/utils/make_constant.d.ts +2 -0
- package/dist/optimizer/utils/make_null_constant.d.ts +2 -0
- package/dist/optimizer/utils/map_expression.d.ts +2 -0
- package/dist/optimizer/utils/map_operator_expressions.d.ts +2 -0
- package/dist/optimizer/utils/negate_comparison.d.ts +2 -0
- package/dist/parser/index.d.ts +3 -0
- package/dist/parser/lexer.d.ts +24 -0
- package/dist/parser/parser/base.d.ts +17 -0
- package/dist/parser/parser/ddl.d.ts +5 -0
- package/dist/parser/parser/dml.d.ts +5 -0
- package/dist/parser/parser/expressions.d.ts +5 -0
- package/dist/parser/parser/index.d.ts +7 -0
- package/dist/parser/parser/select.d.ts +3 -0
- package/dist/parser/parser/tcl.d.ts +3 -0
- package/dist/parser/parser/type-parser.d.ts +3 -0
- package/dist/parser/tests/lexer.test.d.ts +1 -0
- package/dist/parser/tests/parser.test.d.ts +1 -0
- package/dist/parser/types.d.ts +482 -0
- package/dist/store/backend/memory-storage.d.ts +16 -0
- package/dist/store/backend/node-storage.d.ts +33 -0
- package/dist/store/backend/opfs-storage.d.ts +39 -0
- package/dist/store/btree/btree.d.ts +48 -0
- package/dist/store/btree/compare.d.ts +13 -0
- package/dist/store/btree/search-bounds.d.ts +15 -0
- package/dist/store/btree/types.d.ts +33 -0
- package/dist/store/cache.d.ts +17 -0
- package/dist/store/catalog.d.ts +24 -0
- package/dist/store/errors.d.ts +5 -0
- package/dist/store/index-btree/compare.d.ts +3 -0
- package/dist/store/index-btree/index-btree.d.ts +53 -0
- package/dist/store/index-btree/search-bounds.d.ts +7 -0
- package/dist/store/index-btree/types.d.ts +27 -0
- package/dist/store/index-expression.d.ts +5 -0
- package/dist/store/index-manager.d.ts +23 -0
- package/dist/store/index.d.ts +10 -0
- package/dist/store/memory-storage.d.ts +13 -0
- package/dist/store/opfs/opfs-storage.d.ts +15 -0
- package/dist/store/opfs-storage.d.ts +44 -0
- package/dist/store/page-manager.d.ts +19 -0
- package/dist/store/row-manager.d.ts +15 -0
- package/dist/store/session-store.d.ts +20 -0
- package/dist/store/storage/memory-storage.d.ts +11 -0
- package/dist/store/storage/opfs-storage.d.ts +15 -0
- package/dist/store/storage.d.ts +28 -0
- package/dist/store/table-btree.d.ts +48 -0
- package/dist/store/table-manager.d.ts +17 -0
- package/dist/store/tests/btree.test.d.ts +1 -0
- package/dist/store/tests/catalog.test.d.ts +1 -0
- package/dist/store/tests/compare.test.d.ts +1 -0
- package/dist/store/tests/index-btree.test.d.ts +1 -0
- package/dist/store/tests/index-expression.test.d.ts +1 -0
- package/dist/store/tests/index-manager.test.d.ts +1 -0
- package/dist/store/tests/lru-cache.test.d.ts +1 -0
- package/dist/store/tests/memory-storage.d.ts +15 -0
- package/dist/store/tests/opfs-storage.test.d.ts +1 -0
- package/dist/store/tests/page-manager.test.d.ts +1 -0
- package/dist/store/tests/row-manager.test.d.ts +1 -0
- package/dist/store/tests/search-bounds.test.d.ts +1 -0
- package/dist/store/tests/storage.test.d.ts +1 -0
- package/dist/store/tests/table-btree.test.d.ts +1 -0
- package/dist/store/tests/vacuum.test.d.ts +1 -0
- package/dist/store/tests/wal-storage.test.d.ts +1 -0
- package/dist/store/types.d.ts +75 -0
- package/dist/store/vacuum.d.ts +12 -0
- package/dist/store/wal/crc32.d.ts +1 -0
- package/dist/store/wal/file-handle.d.ts +34 -0
- package/dist/store/wal/wal-storage.d.ts +50 -0
- package/dist/types.d.ts +87 -0
- package/dist/worker/client.d.ts +36 -0
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/protocol.d.ts +59 -0
- package/dist/worker/worker.d.ts +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# opfsql
|
|
2
|
+
|
|
3
|
+
Lightweight SQL engine written in TypeScript. ~40 KB gzipped, zero native dependencies. Runs in browser workers via OPFS.
|
|
4
|
+
|
|
5
|
+
[Live Client](https://talerok.github.io/opfsql/client/) | [Benchmark](https://talerok.github.io/opfsql/benchmark/)
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { WorkerEngine } from "opfsql";
|
|
11
|
+
|
|
12
|
+
const engine = new WorkerEngine(new URL("./worker.ts", import.meta.url));
|
|
13
|
+
await engine.open("my-db");
|
|
14
|
+
const conn = await engine.connect();
|
|
15
|
+
|
|
16
|
+
await conn.exec(`
|
|
17
|
+
CREATE TABLE users (
|
|
18
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
19
|
+
name TEXT NOT NULL,
|
|
20
|
+
email TEXT UNIQUE
|
|
21
|
+
)
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
await conn.exec("INSERT INTO users (name, email) VALUES ($1, $2)", [
|
|
25
|
+
"Alice",
|
|
26
|
+
"alice@example.com",
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const [result] = await conn.exec("SELECT * FROM users");
|
|
30
|
+
// result.type === "rows"
|
|
31
|
+
// result.rows === [{ id: 1, name: "Alice", email: "alice@example.com" }]
|
|
32
|
+
|
|
33
|
+
await conn.disconnect();
|
|
34
|
+
await engine.close();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `WorkerEngine`
|
|
40
|
+
|
|
41
|
+
| Method | Returns | Description |
|
|
42
|
+
| --------------------- | --------------------- | --------------------------------- |
|
|
43
|
+
| `engine.open(dbName)` | `Promise<void>` | Open database in worker |
|
|
44
|
+
| `engine.connect()` | `Promise<Connection>` | Create a new connection (session) |
|
|
45
|
+
| `engine.close()` | `Promise<void>` | Close the database |
|
|
46
|
+
|
|
47
|
+
### `Connection`
|
|
48
|
+
|
|
49
|
+
| Method | Returns | Description |
|
|
50
|
+
| ------------------------- | ---------------------------------- | ------------------------------------------------- |
|
|
51
|
+
| `conn.exec(sql, params?)` | `Promise<Result[]>` | Execute one or more SQL statements |
|
|
52
|
+
| `conn.prepare(sql)` | `Promise<RemotePreparedStatement>` | Prepare a single statement for repeated execution |
|
|
53
|
+
| `conn.getSchema()` | `Promise<CatalogData>` | Get current database schema |
|
|
54
|
+
| `conn.disconnect()` | `Promise<void>` | Close the connection |
|
|
55
|
+
|
|
56
|
+
### `RemotePreparedStatement`
|
|
57
|
+
|
|
58
|
+
| Method | Returns | Description |
|
|
59
|
+
| ------------------- | ----------------- | -------------------------------- |
|
|
60
|
+
| `stmt.run(params?)` | `Promise<Result>` | Execute with optional parameters |
|
|
61
|
+
| `stmt.free()` | `Promise<void>` | Release the prepared statement |
|
|
62
|
+
|
|
63
|
+
### `Result`
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
type Result =
|
|
67
|
+
| { type: "rows"; rows: Row[] }
|
|
68
|
+
| { type: "ok"; rowsAffected: number };
|
|
69
|
+
|
|
70
|
+
type Row = Record<string, Value>;
|
|
71
|
+
type Value = string | number | boolean | null | JsonValue | Uint8Array;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Parameters
|
|
75
|
+
|
|
76
|
+
Use `$1`, `$2`, etc. for parameterized queries:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
await conn.exec("SELECT * FROM users WHERE id = $1 AND name = $2", [1, "Alice"]);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Supported SQL
|
|
83
|
+
|
|
84
|
+
### Data Types
|
|
85
|
+
|
|
86
|
+
`INTEGER`, `BIGINT`, `SMALLINT`, `FLOAT`/`REAL`, `DOUBLE`, `TEXT`/`VARCHAR`/`CHAR`, `BLOB`, `BOOLEAN`, `JSON`
|
|
87
|
+
|
|
88
|
+
### Statements
|
|
89
|
+
|
|
90
|
+
| Statement | Notes |
|
|
91
|
+
| ------------------------------- | ------------------------------------------------------------------ |
|
|
92
|
+
| `SELECT` | `DISTINCT`, column aliases, table aliases, `SELECT` without `FROM` |
|
|
93
|
+
| `INSERT` | Multi-row, `INSERT...SELECT`, `ON CONFLICT DO NOTHING/UPDATE` |
|
|
94
|
+
| `UPDATE` | Expressions in `SET` |
|
|
95
|
+
| `DELETE` | With or without `WHERE` |
|
|
96
|
+
| `CREATE TABLE` | `IF NOT EXISTS`, column and table-level constraints |
|
|
97
|
+
| `ALTER TABLE` | `ADD COLUMN`, `DROP COLUMN` |
|
|
98
|
+
| `DROP TABLE` | `IF EXISTS` |
|
|
99
|
+
| `CREATE INDEX` | `UNIQUE`, multi-column, expression-based, `IF NOT EXISTS` |
|
|
100
|
+
| `DROP INDEX` | |
|
|
101
|
+
| `BEGIN` / `COMMIT` / `ROLLBACK` | Snapshot isolation, autocommit for standalone statements |
|
|
102
|
+
| `EXPLAIN` | Shows optimized logical plan for any statement |
|
|
103
|
+
|
|
104
|
+
### Clauses
|
|
105
|
+
|
|
106
|
+
| Clause | Notes |
|
|
107
|
+
| --------------------- | ------------------------------------------------------ |
|
|
108
|
+
| `WHERE` | All comparison, logical, and arithmetic operators |
|
|
109
|
+
| `ORDER BY` | Multi-column, `ASC`/`DESC`, `NULLS FIRST`/`NULLS LAST` |
|
|
110
|
+
| `GROUP BY` | Multiple columns |
|
|
111
|
+
| `HAVING` | |
|
|
112
|
+
| `LIMIT` / `OFFSET` | |
|
|
113
|
+
| `JOIN` | `INNER`, `LEFT`, `CROSS`; `ON` and `USING` |
|
|
114
|
+
| `UNION` / `UNION ALL` | Chainable |
|
|
115
|
+
| `WITH` (CTE) | Multiple CTEs, `WITH RECURSIVE` |
|
|
116
|
+
|
|
117
|
+
### Expressions
|
|
118
|
+
|
|
119
|
+
| Expression | Examples |
|
|
120
|
+
| ----------- | -------------------------------------------------------- |
|
|
121
|
+
| Arithmetic | `+`, `-`, `*`, `/`, `%` |
|
|
122
|
+
| Comparison | `=`, `!=`/`<>`, `<`, `<=`, `>`, `>=` |
|
|
123
|
+
| Logical | `AND`, `OR`, `NOT` |
|
|
124
|
+
| String | `\|\|` (concatenation) |
|
|
125
|
+
| Pattern | `LIKE`, `NOT LIKE` |
|
|
126
|
+
| Range | `BETWEEN`, `NOT BETWEEN` |
|
|
127
|
+
| Set | `IN (...)`, `NOT IN (...)` |
|
|
128
|
+
| Null check | `IS NULL`, `IS NOT NULL` |
|
|
129
|
+
| Conditional | `CASE WHEN ... THEN ... ELSE ... END` |
|
|
130
|
+
| Cast | `CAST(expr AS type)` |
|
|
131
|
+
| Subquery | Scalar, `EXISTS`, `NOT EXISTS`, `ANY`, `ALL`, correlated |
|
|
132
|
+
| JSON path | `data.name`, `items[0]`, `data.items[0].title` |
|
|
133
|
+
|
|
134
|
+
### Functions
|
|
135
|
+
|
|
136
|
+
**Aggregate:** `COUNT(*)`, `COUNT(col)`, `COUNT(DISTINCT col)`, `SUM`, `AVG`, `MIN`, `MAX`
|
|
137
|
+
|
|
138
|
+
**String:** `UPPER`, `LOWER`, `LENGTH`, `TRIM`, `LTRIM`, `RTRIM`, `SUBSTR`/`SUBSTRING`, `REPLACE`, `CONCAT`
|
|
139
|
+
|
|
140
|
+
**Math:** `ABS`, `ROUND`, `FLOOR`, `CEIL`/`CEILING`
|
|
141
|
+
|
|
142
|
+
**Hash:** `MD5`
|
|
143
|
+
|
|
144
|
+
**Utility:** `COALESCE`, `NULLIF`, `TYPEOF`
|
|
145
|
+
|
|
146
|
+
### Constraints
|
|
147
|
+
|
|
148
|
+
`PRIMARY KEY`, `UNIQUE`, `NOT NULL`, `DEFAULT`, `AUTOINCREMENT`, `FOREIGN KEY` (parsed, not enforced)
|
|
149
|
+
|
|
150
|
+
### Other
|
|
151
|
+
|
|
152
|
+
- Comments: `-- single line`, `/* block */`
|
|
153
|
+
- Quoted identifiers: `"my column"`
|
|
154
|
+
- Blob literals: `x'DEADBEEF'`
|
|
155
|
+
- Boolean literals: `TRUE`, `FALSE`
|
|
156
|
+
|
|
157
|
+
## Architecture
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
Lexer --> Parser --> Binder --> Optimizer --> Executor
|
|
161
|
+
| |
|
|
162
|
+
Catalog +------+------+
|
|
163
|
+
| |
|
|
164
|
+
RowManager IndexManager
|
|
165
|
+
| |
|
|
166
|
+
TableBTree IndexBTree
|
|
167
|
+
| |
|
|
168
|
+
+------+------+
|
|
169
|
+
|
|
|
170
|
+
PageStore
|
|
171
|
+
(WAL + page cache)
|
|
172
|
+
|
|
|
173
|
+
OPFS
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- **Lexer / Parser** — SQL text to AST
|
|
177
|
+
- **Binder** — resolves names, types, and constraints against the catalog
|
|
178
|
+
- **Optimizer** — rewrites logical plan (predicate pushdown, join reordering, index selection)
|
|
179
|
+
- **Executor** — pull-based iterator model (volcano), executes physical operators
|
|
180
|
+
- **RowManager / IndexManager** — logical layer over B-trees, handles row CRUD and index maintenance
|
|
181
|
+
- **TableBTree / IndexBTree** — B+ trees for row storage (keyed by rowId) and secondary indexes (composite keys → rowId buckets)
|
|
182
|
+
- **PageStore** — page-level I/O with LRU cache and WAL for crash safety
|
|
183
|
+
- **OPFS** — Origin Private File System (synchronous access handle in workers)
|
|
184
|
+
|
|
185
|
+
## Not Supported (vs SQLite)
|
|
186
|
+
|
|
187
|
+
| Feature | Status |
|
|
188
|
+
| ------------------------------------------------------------ | ---------------------------- |
|
|
189
|
+
| Window functions (`OVER`, `PARTITION BY`, `ROW_NUMBER`, ...) | Not supported |
|
|
190
|
+
| `RIGHT JOIN` / `FULL OUTER JOIN` | Not supported |
|
|
191
|
+
| Views (`CREATE VIEW`) | Not supported |
|
|
192
|
+
| Triggers | Not supported |
|
|
193
|
+
| Savepoints | Not supported |
|
|
194
|
+
| `CHECK` constraints | Not supported |
|
|
195
|
+
| `ATTACH` / `DETACH` | Not supported |
|
|
196
|
+
| `PRAGMA` | Not supported |
|
|
197
|
+
| Collation | Not configurable |
|
|
198
|
+
| Type affinity | Strict logical types instead |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ICatalog } from "../../store/types.js";
|
|
2
|
+
import type { BoundAggregateExpression, BoundExpression } from "../types.js";
|
|
3
|
+
import { BindScope } from "./scope.js";
|
|
4
|
+
export interface BindContext {
|
|
5
|
+
catalog: ICatalog;
|
|
6
|
+
nextTableIndex(): number;
|
|
7
|
+
resetTableIndex(): void;
|
|
8
|
+
createScope(): BindScope;
|
|
9
|
+
}
|
|
10
|
+
export interface AggregateContext {
|
|
11
|
+
aggregates: BoundAggregateExpression[];
|
|
12
|
+
groups: BoundExpression[];
|
|
13
|
+
groupIndex: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function createBindContext(catalog: ICatalog): BindContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ParsedExpression } from "../../parser/types.js";
|
|
2
|
+
import type { TableSchema } from "../../store/types.js";
|
|
3
|
+
import type { BindContext } from "./context.js";
|
|
4
|
+
export declare function requireTable(ctx: BindContext, name: string): TableSchema;
|
|
5
|
+
export declare function evalConstantInt(expr: ParsedExpression): number;
|
|
6
|
+
export declare function evalConstantValue(expr: ParsedExpression): string | number | boolean | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableSchema } from "../../store/types.js";
|
|
2
|
+
import type * as BT from "../types.js";
|
|
3
|
+
import type { BindContext } from "./context.js";
|
|
4
|
+
import type { BindingEntry } from "./scope.js";
|
|
5
|
+
export declare function makeEmptyGet(ctx: BindContext): BT.LogicalGet;
|
|
6
|
+
export declare function makeGet(entry: BindingEntry, schema: TableSchema): BT.LogicalGet;
|
|
7
|
+
export declare function makeFilter(child: BT.LogicalOperator, exprs: BT.BoundExpression[]): BT.LogicalFilter;
|
|
8
|
+
export declare function makeDistinct(child: BT.LogicalOperator): BT.LogicalDistinct;
|
|
9
|
+
export declare function makeOrderBy(child: BT.LogicalOperator, boundOrders: BT.BoundOrderByNode[]): BT.LogicalOrderBy;
|
|
10
|
+
export declare function makeLimit(child: BT.LogicalOperator, limitVal: number | null, offsetVal: number): BT.LogicalLimit;
|
|
11
|
+
export declare function makeAggregate(child: BT.LogicalOperator, groups: BT.BoundExpression[], aggregates: BT.BoundAggregateExpression[], groupIndex: number, aggregateIndex: number, havingExpression: BT.BoundExpression | null): BT.LogicalAggregate;
|
|
12
|
+
export declare function makeProjection(child: BT.LogicalOperator, tableIndex: number, expressions: BT.BoundExpression[], aliases: (string | null)[]): BT.LogicalProjection;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColumnDef, LogicalType } from "../../store/types.js";
|
|
2
|
+
import type { LogicalOperator, LogicalProjection } from "../types.js";
|
|
3
|
+
export declare function findProjection(plan: LogicalOperator): LogicalProjection | null;
|
|
4
|
+
export declare function extractColumnsFromPlan(plan: LogicalOperator, types: LogicalType[]): ColumnDef[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TableSchema } from "../../store/types.js";
|
|
2
|
+
import type { BoundColumnRefExpression, LogicalOperator } from "../types.js";
|
|
3
|
+
export interface BindingEntry {
|
|
4
|
+
tableIndex: number;
|
|
5
|
+
tableName: string;
|
|
6
|
+
alias: string;
|
|
7
|
+
schema: TableSchema;
|
|
8
|
+
}
|
|
9
|
+
interface CTEEntry {
|
|
10
|
+
plan: LogicalOperator;
|
|
11
|
+
index: number;
|
|
12
|
+
aliases: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class BindScope {
|
|
15
|
+
private parent?;
|
|
16
|
+
private bindings;
|
|
17
|
+
private ctes;
|
|
18
|
+
private tableIndexCounter;
|
|
19
|
+
constructor(tableIndexCounter: () => number, parent?: BindScope | undefined);
|
|
20
|
+
addTable(tableName: string, alias: string, schema: TableSchema): BindingEntry;
|
|
21
|
+
resolveColumn(columnName: string, tableAlias?: string): BoundColumnRefExpression;
|
|
22
|
+
resolveColumnIn(columnName: string, entries: BindingEntry[]): BoundColumnRefExpression;
|
|
23
|
+
findByAlias(alias: string): BindingEntry | undefined;
|
|
24
|
+
getAllBindings(): BindingEntry[];
|
|
25
|
+
addCTE(name: string, plan: LogicalOperator, index: number, aliases?: string[]): void;
|
|
26
|
+
getCTE(name: string): CTEEntry | undefined;
|
|
27
|
+
createChildScope(): BindScope;
|
|
28
|
+
createIsolatedScope(): BindScope;
|
|
29
|
+
private resolveQualified;
|
|
30
|
+
private resolveUnqualified;
|
|
31
|
+
private findMatchingColumns;
|
|
32
|
+
private collectCTEs;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LogicalType } from "../../store/types.js";
|
|
2
|
+
import type { BoundExpression } from "../types.js";
|
|
3
|
+
export declare function checkTypeCompatibility(left: LogicalType, right: LogicalType): LogicalType;
|
|
4
|
+
export declare function resolveArithmeticType(left: LogicalType, right: LogicalType): LogicalType;
|
|
5
|
+
export declare function resolveScalarFunctionReturnType(name: string, children: BoundExpression[]): LogicalType;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExpressionType } from "../../parser/types.js";
|
|
2
|
+
import type { LogicalType } from "../../store/types.js";
|
|
3
|
+
import type { ComparisonType, OperatorType } from "../types.js";
|
|
4
|
+
export declare function mapParserType(parserType: {
|
|
5
|
+
id: string;
|
|
6
|
+
}): LogicalType;
|
|
7
|
+
export declare function mapComparisonType(exprType: ExpressionType): ComparisonType;
|
|
8
|
+
export declare function mapOperatorType(exprType: ExpressionType): OperatorType;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColumnDef, LogicalType } from "../../../store/types.js";
|
|
2
|
+
import type { LogicalOperator, LogicalProjection } from "../../types.js";
|
|
3
|
+
export declare function findProjection(plan: LogicalOperator): LogicalProjection | null;
|
|
4
|
+
export declare function extractColumnsFromPlan(plan: LogicalOperator, types: LogicalType[]): ColumnDef[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TableSchema } from "../../../store/types.js";
|
|
2
|
+
export declare function findColumnIndex(schema: TableSchema, columnName: string): number;
|
|
3
|
+
export declare function findColumnIndexOrThrow(schema: TableSchema, columnName: string): number;
|
|
4
|
+
export declare function getPrimaryKeyColumns(schema: TableSchema): number[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FunctionExpression, ParsedExpression } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { BoundAggregateExpression } from "../types.js";
|
|
5
|
+
export declare const AGGREGATE_FUNCTIONS: Set<string>;
|
|
6
|
+
export declare function detectAggregates(exprs: ParsedExpression[]): boolean;
|
|
7
|
+
export declare function exprContainsAggregate(expr: ParsedExpression): boolean;
|
|
8
|
+
export declare function checkNoAggregates(expr: ParsedExpression, context?: string): void;
|
|
9
|
+
export declare function extractAggregates(ctx: BindContext, exprs: ParsedExpression[], scope: BindScope): BoundAggregateExpression[];
|
|
10
|
+
export declare function extractAggregatesFromExpr(ctx: BindContext, expr: ParsedExpression, scope: BindScope): BoundAggregateExpression[];
|
|
11
|
+
export declare function bindAggregate(ctx: BindContext, expr: FunctionExpression, scope: BindScope): BoundAggregateExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BetweenExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundBetweenExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindBetween(ctx: BindContext, expr: BetweenExpression, scope: BindScope, aggCtx?: AggregateContext): BoundBetweenExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CaseExpression } from "../../parser/types.js";
|
|
2
|
+
import type { AggregateContext, BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { BoundCaseExpression } from "../types.js";
|
|
5
|
+
export declare function bindCase(ctx: BindContext, expr: CaseExpression, scope: BindScope, aggCtx?: AggregateContext): BoundCaseExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CastExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundCastExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindCast(ctx: BindContext, expr: CastExpression, scope: BindScope, aggCtx?: AggregateContext): BoundCastExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ColumnRefExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundExpression } from '../types.js';
|
|
3
|
+
import type { AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindColumnRef(expr: ColumnRefExpression, scope: BindScope, aggCtx?: AggregateContext): BoundExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ComparisonExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindComparison(ctx: BindContext, expr: ComparisonExpression, scope: BindScope, aggCtx?: AggregateContext): BoundExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ConjunctionExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundConjunctionExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindConjunction(ctx: BindContext, expr: ConjunctionExpression, scope: BindScope, aggCtx?: AggregateContext): BoundConjunctionExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FunctionExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindFunction(ctx: BindContext, expr: FunctionExpression, scope: BindScope, aggCtx?: AggregateContext): BoundExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParsedExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundExpression } from '../types.js';
|
|
3
|
+
import type { BindContext, AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindExpression(ctx: BindContext, expr: ParsedExpression, scope: BindScope, aggCtx?: AggregateContext): BoundExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OperatorExpression } from "../../parser/types.js";
|
|
2
|
+
import type { AggregateContext, BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { BoundOperatorExpression } from "../types.js";
|
|
5
|
+
export declare function bindOperator(ctx: BindContext, expr: OperatorExpression, scope: BindScope, aggCtx?: AggregateContext): BoundOperatorExpression;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ParameterExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundParameterExpression } from '../types.js';
|
|
3
|
+
/** Parameters have unknown type at bind time — resolved to ANY at runtime. */
|
|
4
|
+
export declare function bindParameter(expr: ParameterExpression): BoundParameterExpression;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StarExpression } from '../../parser/types.js';
|
|
2
|
+
import type { BoundColumnRefExpression } from '../types.js';
|
|
3
|
+
import type { AggregateContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindStar(expr: StarExpression, scope: BindScope, aggCtx?: AggregateContext): BoundColumnRefExpression[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubqueryExpression } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { BoundSubqueryExpression } from "../types.js";
|
|
5
|
+
export declare function bindSubquery(ctx: BindContext, expr: SubqueryExpression, scope: BindScope): BoundSubqueryExpression;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Statement } from "../parser/types.js";
|
|
2
|
+
import type { ICatalog } from "../store/types.js";
|
|
3
|
+
import type { LogicalOperator } from "./types.js";
|
|
4
|
+
export declare class Binder {
|
|
5
|
+
private ctx;
|
|
6
|
+
constructor(catalog: ICatalog);
|
|
7
|
+
bindStatement(stmt: Statement): LogicalOperator;
|
|
8
|
+
}
|
|
9
|
+
export { BindError } from "./core/errors.js";
|
|
10
|
+
export { BindScope, type BindingEntry } from "./core/scope.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
import type { TableSchema } from "../store/types.js";
|
|
13
|
+
import type { BindingEntry } from "./core/scope.js";
|
|
14
|
+
import type { BoundColumnRefExpression } from "./types.js";
|
|
15
|
+
export interface IBinder {
|
|
16
|
+
bindStatement(stmt: Statement): LogicalOperator;
|
|
17
|
+
}
|
|
18
|
+
export interface IBindScope {
|
|
19
|
+
addTable(tableName: string, alias: string, schema: TableSchema): BindingEntry;
|
|
20
|
+
resolveColumn(columnName: string, tableAlias?: string): BoundColumnRefExpression;
|
|
21
|
+
resolveColumnIn(columnName: string, entries: BindingEntry[]): BoundColumnRefExpression;
|
|
22
|
+
findByAlias(alias: string): BindingEntry | undefined;
|
|
23
|
+
getAllBindings(): BindingEntry[];
|
|
24
|
+
addCTE(name: string, plan: LogicalOperator, index: number): void;
|
|
25
|
+
getCTE(name: string): {
|
|
26
|
+
plan: LogicalOperator;
|
|
27
|
+
index: number;
|
|
28
|
+
} | undefined;
|
|
29
|
+
createChildScope(): IBindScope;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CreateIndexStatement } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type * as BT from "../types.js";
|
|
4
|
+
export declare function bindCreateIndex(ctx: BindContext, stmt: CreateIndexStatement): BT.LogicalCreateIndex;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CreateTableStatement } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type * as BT from "../types.js";
|
|
4
|
+
export declare function bindCreateTable(_ctx: BindContext, stmt: CreateTableStatement): BT.LogicalCreateTable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SelectStatement } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { LogicalOperator } from "../types.js";
|
|
5
|
+
export interface CTECollected {
|
|
6
|
+
name: string;
|
|
7
|
+
plan: LogicalOperator;
|
|
8
|
+
index: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function collectCTEs(ctx: BindContext, cteMap: {
|
|
11
|
+
map: Record<string, {
|
|
12
|
+
query: SelectStatement;
|
|
13
|
+
aliases: string[];
|
|
14
|
+
}>;
|
|
15
|
+
recursive: boolean;
|
|
16
|
+
}, scope: BindScope): CTECollected[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SelectNode, SetOperationNode } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type { LogicalOperator } from "../types.js";
|
|
5
|
+
export declare function bindQueryNode(ctx: BindContext, node: SelectNode | SetOperationNode, scope: BindScope): LogicalOperator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SelectNode } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type * as BT from "../types.js";
|
|
5
|
+
export declare function bindSelect(ctx: BindContext, node: SelectNode, scope: BindScope): BT.LogicalOperator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SetOperationNode } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type * as BT from "../types.js";
|
|
5
|
+
export declare function bindSetOperation(ctx: BindContext, node: SetOperationNode, scope: BindScope): BT.LogicalOperator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BaseTableRef } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type * as BT from "../types.js";
|
|
5
|
+
export declare function bindBaseTableRef(ctx: BindContext, ref: BaseTableRef, scope: BindScope): BT.LogicalOperator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TableRef } from '../../parser/types.js';
|
|
2
|
+
import type { LogicalOperator } from '../types.js';
|
|
3
|
+
import type { BindContext } from '../core/context.js';
|
|
4
|
+
import type { BindScope } from '../core/scope.js';
|
|
5
|
+
export declare function bindTableRef(ctx: BindContext, ref: TableRef, scope: BindScope): LogicalOperator;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JoinRef, ParsedExpression } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type * as BT from "../types.js";
|
|
5
|
+
export declare function bindJoinRef(ctx: BindContext, ref: JoinRef, scope: BindScope): BT.LogicalOperator;
|
|
6
|
+
export declare function extractJoinConditions(ctx: BindContext, expr: ParsedExpression, scope: BindScope): BT.JoinCondition[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubqueryRef } from "../../parser/types.js";
|
|
2
|
+
import type { BindContext } from "../core/context.js";
|
|
3
|
+
import type { BindScope } from "../core/scope.js";
|
|
4
|
+
import type * as BT from "../types.js";
|
|
5
|
+
export declare function bindSubqueryRef(ctx: BindContext, ref: SubqueryRef, scope: BindScope): BT.LogicalOperator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|