@minnowdb/core 0.2.1 → 0.4.0
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 +23 -32
- package/dist/block-format/block.d.ts +32 -13
- package/dist/block-format/block.js +179 -55
- package/dist/block-format/checksum.d.ts +2 -1
- package/dist/block-format/checksum.js +5 -2
- package/dist/block-format/codecs.d.ts +7 -2
- package/dist/block-format/codecs.js +53 -12
- package/dist/block-format/column.d.ts +3 -2
- package/dist/block-format/column.js +96 -30
- package/dist/block-format/index.d.ts +2 -2
- package/dist/block-format/index.js +2 -2
- package/dist/block-format/physical.d.ts +8 -2
- package/dist/block-format/physical.js +14 -6
- package/dist/block-format/types.d.ts +7 -3
- package/dist/block-format/types.js +0 -1
- package/dist/block-format/unicode.d.ts +11 -0
- package/dist/block-format/unicode.js +46 -0
- package/dist/date-value.d.ts +15 -0
- package/dist/date-value.js +64 -0
- package/dist/engine/artifact-cache.d.ts +2 -1
- package/dist/engine/artifact-cache.js +5 -1
- package/dist/engine/batch.d.ts +11 -3
- package/dist/engine/batch.js +17 -7
- package/dist/engine/buffered-writer.d.ts +2 -1
- package/dist/engine/buffered-writer.js +34 -9
- package/dist/engine/cache-limits.d.ts +25 -0
- package/dist/engine/cache-limits.js +25 -0
- package/dist/engine/catalog.d.ts +24 -5
- package/dist/engine/catalog.js +34 -7
- package/dist/engine/client.d.ts +29 -7
- package/dist/engine/client.js +216 -40
- package/dist/engine/database.d.ts +224 -39
- package/dist/engine/database.js +7475 -1539
- package/dist/engine/defaults.d.ts +4 -8
- package/dist/engine/defaults.js +46 -22
- package/dist/engine/errors.d.ts +19 -1
- package/dist/engine/errors.js +32 -2
- package/dist/engine/fts.d.ts +0 -6
- package/dist/engine/fts.js +41 -14
- package/dist/engine/group-index.d.ts +0 -1
- package/dist/engine/group-index.js +6 -11
- package/dist/engine/index.d.ts +16 -10
- package/dist/engine/index.js +12 -9
- package/dist/engine/join-index.d.ts +0 -1
- package/dist/engine/join-index.js +2 -2
- package/dist/engine/keyed-live.d.ts +57 -0
- package/dist/engine/keyed-live.js +226 -0
- package/dist/engine/live-api.d.ts +4 -0
- package/dist/engine/live-api.js +4 -0
- package/dist/engine/live.d.ts +43 -26
- package/dist/engine/live.js +504 -126
- package/dist/engine/memory.d.ts +2 -1
- package/dist/engine/memory.js +3 -2
- package/dist/engine/optimizer.d.ts +0 -1
- package/dist/engine/optimizer.js +262 -27
- package/dist/engine/query-api.d.ts +3 -0
- package/dist/engine/query-api.js +3 -0
- package/dist/engine/query-cache.d.ts +1 -2
- package/dist/engine/query-cache.js +7 -5
- package/dist/engine/query.d.ts +134 -29
- package/dist/engine/query.js +1668 -372
- package/dist/engine/result-wire.d.ts +0 -1
- package/dist/engine/result-wire.js +2 -2
- package/dist/engine/schema-wire.d.ts +6 -3
- package/dist/engine/schema-wire.js +40 -34
- package/dist/engine/schema.d.ts +156 -80
- package/dist/engine/schema.js +570 -108
- package/dist/engine/sort-keys.d.ts +4 -4
- package/dist/engine/sort-keys.js +44 -29
- package/dist/engine/sql-domains.d.ts +31 -0
- package/dist/engine/sql-domains.js +585 -0
- package/dist/engine/sql-driver.d.ts +19 -0
- package/dist/engine/sql-driver.js +1 -0
- package/dist/engine/sql-json.d.ts +7 -9
- package/dist/engine/sql-json.js +75 -15
- package/dist/engine/sql-semantics.d.ts +8 -3
- package/dist/engine/sql-semantics.js +458 -30
- package/dist/engine/typed-live.d.ts +67 -0
- package/dist/engine/typed-live.js +349 -0
- package/dist/engine/vector.d.ts +12 -2
- package/dist/engine/vector.js +635 -119
- package/dist/engine/worker-host.d.ts +9 -2
- package/dist/engine/worker-host.js +620 -152
- package/dist/engine/worker.d.ts +0 -1
- package/dist/engine/worker.js +3 -3
- package/dist/engine/write-block-planner.d.ts +18 -0
- package/dist/engine/write-block-planner.js +112 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/plan/index.d.ts +3 -4
- package/dist/plan/index.js +3 -4
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/indexeddb.d.ts +99 -51
- package/dist/storage/indexeddb.js +13448 -2660
- package/dist/storage/memory.d.ts +64 -57
- package/dist/storage/memory.js +1042 -128
- package/dist/storage/opfs/files.d.ts +18 -7
- package/dist/storage/opfs/files.js +115 -28
- package/dist/storage/opfs/index.d.ts +1 -1
- package/dist/storage/opfs/index.js +1 -1
- package/dist/storage/opfs/leader.d.ts +409 -75
- package/dist/storage/opfs/leader.js +4621 -650
- package/dist/storage/opfs/rpc.d.ts +15 -3
- package/dist/storage/opfs/rpc.js +224 -2
- package/dist/storage/opfs/snapshot-ledger.d.ts +40 -0
- package/dist/storage/opfs/snapshot-ledger.js +281 -0
- package/dist/storage/opfs/store.d.ts +33 -99
- package/dist/storage/opfs/store.js +453 -364
- package/dist/storage/persistence.d.ts +37 -0
- package/dist/storage/persistence.js +78 -0
- package/dist/storage/snapshot-stream.d.ts +24 -0
- package/dist/storage/snapshot-stream.js +897 -0
- package/dist/storage/snapshot.d.ts +9 -85
- package/dist/storage/snapshot.js +33 -265
- package/dist/storage/toolkit/extents.d.ts +41 -7
- package/dist/storage/toolkit/extents.js +402 -39
- package/dist/storage/toolkit/index.d.ts +4 -5
- package/dist/storage/toolkit/index.js +28 -4
- package/dist/storage/toolkit/record-core.d.ts +182 -55
- package/dist/storage/toolkit/record-core.js +6158 -1331
- package/dist/storage/toolkit/sync-file.d.ts +10 -1
- package/dist/storage/toolkit/sync-file.js +50 -2
- package/dist/storage/toolkit/wal.d.ts +23 -5
- package/dist/storage/toolkit/wal.js +89 -27
- package/dist/storage/toolkit/wire.d.ts +15 -2
- package/dist/storage/toolkit/wire.js +199 -10
- package/dist/storage/types.d.ts +1439 -204
- package/dist/storage/types.js +1745 -141
- package/dist/testing/block-store-conformance.d.ts +0 -1
- package/dist/testing/block-store-conformance.js +1009 -119
- package/dist/testing/index.d.ts +46 -26
- package/dist/testing/index.js +112 -57
- package/dist/testing/opfs-shim.d.ts +13 -3
- package/dist/testing/opfs-shim.js +40 -6
- package/dist/testing/simulator.d.ts +97 -0
- package/dist/testing/simulator.js +591 -0
- package/dist/testing/sqllogictest.d.ts +89 -0
- package/dist/testing/sqllogictest.js +434 -0
- package/dist/transactions/index.d.ts +92 -16
- package/dist/transactions/index.js +1074 -236
- package/dist/worker-protocol/index.d.ts +3 -2
- package/dist/worker-protocol/index.js +2 -5
- package/package.json +53 -3
- package/postgres-feature-profile.json +223 -0
- package/sql-feature-matrix.json +172 -252
- package/dist/block-format/block.d.ts.map +0 -1
- package/dist/block-format/block.js.map +0 -1
- package/dist/block-format/checksum.d.ts.map +0 -1
- package/dist/block-format/checksum.js.map +0 -1
- package/dist/block-format/codecs.d.ts.map +0 -1
- package/dist/block-format/codecs.js.map +0 -1
- package/dist/block-format/column.d.ts.map +0 -1
- package/dist/block-format/column.js.map +0 -1
- package/dist/block-format/index.d.ts.map +0 -1
- package/dist/block-format/index.js.map +0 -1
- package/dist/block-format/physical.d.ts.map +0 -1
- package/dist/block-format/physical.js.map +0 -1
- package/dist/block-format/types.d.ts.map +0 -1
- package/dist/block-format/types.js.map +0 -1
- package/dist/engine/artifact-cache.d.ts.map +0 -1
- package/dist/engine/artifact-cache.js.map +0 -1
- package/dist/engine/batch.d.ts.map +0 -1
- package/dist/engine/batch.js.map +0 -1
- package/dist/engine/buffered-writer.d.ts.map +0 -1
- package/dist/engine/buffered-writer.js.map +0 -1
- package/dist/engine/catalog.d.ts.map +0 -1
- package/dist/engine/catalog.js.map +0 -1
- package/dist/engine/client.d.ts.map +0 -1
- package/dist/engine/client.js.map +0 -1
- package/dist/engine/coordinator.d.ts +0 -17
- package/dist/engine/coordinator.d.ts.map +0 -1
- package/dist/engine/coordinator.js +0 -60
- package/dist/engine/coordinator.js.map +0 -1
- package/dist/engine/database.d.ts.map +0 -1
- package/dist/engine/database.js.map +0 -1
- package/dist/engine/defaults.d.ts.map +0 -1
- package/dist/engine/defaults.js.map +0 -1
- package/dist/engine/errors.d.ts.map +0 -1
- package/dist/engine/errors.js.map +0 -1
- package/dist/engine/fts.d.ts.map +0 -1
- package/dist/engine/fts.js.map +0 -1
- package/dist/engine/group-index.d.ts.map +0 -1
- package/dist/engine/group-index.js.map +0 -1
- package/dist/engine/index.d.ts.map +0 -1
- package/dist/engine/index.js.map +0 -1
- package/dist/engine/join-index.d.ts.map +0 -1
- package/dist/engine/join-index.js.map +0 -1
- package/dist/engine/live.d.ts.map +0 -1
- package/dist/engine/live.js.map +0 -1
- package/dist/engine/memory.d.ts.map +0 -1
- package/dist/engine/memory.js.map +0 -1
- package/dist/engine/optimizer.d.ts.map +0 -1
- package/dist/engine/optimizer.js.map +0 -1
- package/dist/engine/query-cache.d.ts.map +0 -1
- package/dist/engine/query-cache.js.map +0 -1
- package/dist/engine/query.d.ts.map +0 -1
- package/dist/engine/query.js.map +0 -1
- package/dist/engine/result-wire.d.ts.map +0 -1
- package/dist/engine/result-wire.js.map +0 -1
- package/dist/engine/schema-wire.d.ts.map +0 -1
- package/dist/engine/schema-wire.js.map +0 -1
- package/dist/engine/schema.d.ts.map +0 -1
- package/dist/engine/schema.js.map +0 -1
- package/dist/engine/sort-keys.d.ts.map +0 -1
- package/dist/engine/sort-keys.js.map +0 -1
- package/dist/engine/sql-json.d.ts.map +0 -1
- package/dist/engine/sql-json.js.map +0 -1
- package/dist/engine/sql-semantics.d.ts.map +0 -1
- package/dist/engine/sql-semantics.js.map +0 -1
- package/dist/engine/vector.d.ts.map +0 -1
- package/dist/engine/vector.js.map +0 -1
- package/dist/engine/worker-host.d.ts.map +0 -1
- package/dist/engine/worker-host.js.map +0 -1
- package/dist/engine/worker.d.ts.map +0 -1
- package/dist/engine/worker.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plan/index.d.ts.map +0 -1
- package/dist/plan/index.js.map +0 -1
- package/dist/storage/fixture-shape.d.ts +0 -42
- package/dist/storage/fixture-shape.d.ts.map +0 -1
- package/dist/storage/fixture-shape.js +0 -146
- package/dist/storage/fixture-shape.js.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/indexeddb.d.ts.map +0 -1
- package/dist/storage/indexeddb.js.map +0 -1
- package/dist/storage/memory.d.ts.map +0 -1
- package/dist/storage/memory.js.map +0 -1
- package/dist/storage/opfs/files.d.ts.map +0 -1
- package/dist/storage/opfs/files.js.map +0 -1
- package/dist/storage/opfs/index.d.ts.map +0 -1
- package/dist/storage/opfs/index.js.map +0 -1
- package/dist/storage/opfs/leader.d.ts.map +0 -1
- package/dist/storage/opfs/leader.js.map +0 -1
- package/dist/storage/opfs/rpc.d.ts.map +0 -1
- package/dist/storage/opfs/rpc.js.map +0 -1
- package/dist/storage/opfs/store.d.ts.map +0 -1
- package/dist/storage/opfs/store.js.map +0 -1
- package/dist/storage/snapshot.d.ts.map +0 -1
- package/dist/storage/snapshot.js.map +0 -1
- package/dist/storage/toolkit/extents.d.ts.map +0 -1
- package/dist/storage/toolkit/extents.js.map +0 -1
- package/dist/storage/toolkit/index.d.ts.map +0 -1
- package/dist/storage/toolkit/index.js.map +0 -1
- package/dist/storage/toolkit/record-core.d.ts.map +0 -1
- package/dist/storage/toolkit/record-core.js.map +0 -1
- package/dist/storage/toolkit/sync-file.d.ts.map +0 -1
- package/dist/storage/toolkit/sync-file.js.map +0 -1
- package/dist/storage/toolkit/wal.d.ts.map +0 -1
- package/dist/storage/toolkit/wal.js.map +0 -1
- package/dist/storage/toolkit/wire.d.ts.map +0 -1
- package/dist/storage/toolkit/wire.js.map +0 -1
- package/dist/storage/types.d.ts.map +0 -1
- package/dist/storage/types.js.map +0 -1
- package/dist/testing/block-store-conformance.d.ts.map +0 -1
- package/dist/testing/block-store-conformance.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/opfs-shim.d.ts.map +0 -1
- package/dist/testing/opfs-shim.js.map +0 -1
- package/dist/testing/seeds.d.ts +0 -11
- package/dist/testing/seeds.d.ts.map +0 -1
- package/dist/testing/seeds.js +0 -50
- package/dist/testing/seeds.js.map +0 -1
- package/dist/transactions/index.d.ts.map +0 -1
- package/dist/transactions/index.js.map +0 -1
- package/dist/worker-protocol/index.d.ts.map +0 -1
- package/dist/worker-protocol/index.js.map +0 -1
package/dist/engine/query.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DatabaseRow } from "./database.js";
|
|
2
|
-
import type { ColumnDefault } from "../storage/types.js";
|
|
2
|
+
import type { ColumnDefault, SqlDomain } from "../storage/types.js";
|
|
3
3
|
import { type FtsStats } from "./fts.js";
|
|
4
4
|
import { QueryMemoryContext, type QueryMemoryUsage } from "./memory.js";
|
|
5
|
-
import { type ColumnarTable, type AsyncQueryExecutionOptions } from "./vector.js";
|
|
5
|
+
import { type ColumnarTable, type AsyncQueryExecutionOptions, type QueryBatchExecutionOptions } from "./vector.js";
|
|
6
6
|
export type QueryValue = boolean | number | string | Date | null;
|
|
7
7
|
export type QueryRow = Record<string, QueryValue>;
|
|
8
8
|
export interface QueryResult {
|
|
@@ -19,6 +19,7 @@ export interface PreparedQuery {
|
|
|
19
19
|
readonly memoryUsage: QueryMemoryUsage;
|
|
20
20
|
execute(): QueryResult;
|
|
21
21
|
executeAsync(options?: AsyncQueryExecutionOptions): Promise<QueryResult>;
|
|
22
|
+
executeBatches(options: QueryBatchExecutionOptions, consume: (batch: QueryResult) => void | Promise<void>): Promise<readonly string[]>;
|
|
22
23
|
close(): void;
|
|
23
24
|
}
|
|
24
25
|
export interface QueryExecutionOptions {
|
|
@@ -32,9 +33,15 @@ export interface QueryExecutionOptions {
|
|
|
32
33
|
}
|
|
33
34
|
export type BinaryOperator = "+" | "-" | "*" | "/" | "%" | "||";
|
|
34
35
|
export type ComparisonOperator = "=" | "!=" | "<>" | ">" | ">=" | "<" | "<=";
|
|
35
|
-
export type AggregateName = "COUNT" | "SUM" | "AVG" | "MIN" | "MAX";
|
|
36
|
-
export type ScalarFunctionName = "ROUND" | "COALESCE" | "DATE_TRUNC" | "DATE_ADD" | "UPPER" | "LOWER" | "LENGTH" | "ABS" | "TRIM" | "LTRIM" | "RTRIM" | "SUBSTR" | "REPLACE" | "INSTR" | "NULLIF" | "GREATEST" | "LEAST" | "FLOOR" | "CEIL" | "MOD" | "POWER" | "SQRT" | "EXTRACT" | "CAST" | "OCTET_LENGTH" | "LPAD" | "RPAD" | "OVERLAY" | "CURRENT_DATE" | "CURRENT_TIMESTAMP" | "LOCALTIME" | "GROUPING" | "JSON_VALUE" | "JSON_QUERY" | "JSON_EXISTS" | "JSON_OBJECT" | "JSON_ARRAY" | "IS_JSON"
|
|
36
|
+
export type AggregateName = "COUNT" | "SUM" | "AVG" | "MIN" | "MAX" | "JSON_ARRAYAGG" | "STRING_AGG";
|
|
37
|
+
export type ScalarFunctionName = "ROUND" | "COALESCE" | "DATE_TRUNC" | "DATE_ADD" | "UPPER" | "LOWER" | "LENGTH" | "ABS" | "TRIM" | "LTRIM" | "RTRIM" | "SUBSTR" | "REPLACE" | "INSTR" | "NULLIF" | "GREATEST" | "LEAST" | "FLOOR" | "CEIL" | "MOD" | "POWER" | "SQRT" | "EXTRACT" | "CAST" | "OCTET_LENGTH" | "LPAD" | "RPAD" | "OVERLAY" | "CURRENT_DATE" | "CURRENT_TIMESTAMP" | "LOCALTIME" | "GROUPING" | "JSON_VALUE" | "JSON_QUERY" | "JSON_EXISTS" | "JSON_OBJECT" | "JSON_ARRAY" | "IS_JSON" | "ARRAY"
|
|
38
|
+
/** Optimizer-only, prefix-free equality key for hashable multi-column decorrelation. */
|
|
39
|
+
| "MINNOW_TUPLE_KEY"
|
|
40
|
+
/** Parser-produced wrapper carrying one explicit collation through ordering/comparison. */
|
|
41
|
+
| "MINNOW_COLLATE" | "NEXTVAL" | "CURRVAL" | "RANDOM" | "GEN_RANDOM_UUID";
|
|
37
42
|
export declare const scalarFunctionNames: ReadonlySet<string>;
|
|
43
|
+
/** Functions whose answer can change without any catalog or input-row change. */
|
|
44
|
+
export declare const volatileScalarFunctionNames: ReadonlySet<string>;
|
|
38
45
|
/**
|
|
39
46
|
* The niladic datetime functions (F051-06/07/08). Their value is the statement's own clock
|
|
40
47
|
* reading, so they are resolved once per execution rather than evaluated per row: every row of
|
|
@@ -70,6 +77,8 @@ export declare function dateTruncValue(unit: unknown, value: unknown): Date | nu
|
|
|
70
77
|
export type Expression = {
|
|
71
78
|
kind: "literal";
|
|
72
79
|
value: QueryValue;
|
|
80
|
+
internalSqlValue?: true;
|
|
81
|
+
sqlDomain?: SqlDomain;
|
|
73
82
|
}
|
|
74
83
|
/** A `?` or `$n` placeholder; `index` is 0-based. Replaced by a literal at bind time. */
|
|
75
84
|
| {
|
|
@@ -97,6 +106,11 @@ export type Expression = {
|
|
|
97
106
|
name: AggregateName | ScalarFunctionName;
|
|
98
107
|
arguments: Expression[];
|
|
99
108
|
distinct?: boolean;
|
|
109
|
+
aggregateOrderBy?: Array<{
|
|
110
|
+
expression: Expression;
|
|
111
|
+
direction: "asc" | "desc";
|
|
112
|
+
nulls?: "first" | "last";
|
|
113
|
+
}>;
|
|
100
114
|
} | {
|
|
101
115
|
kind: "list";
|
|
102
116
|
items: Expression[];
|
|
@@ -198,6 +212,8 @@ export interface WindowSpec {
|
|
|
198
212
|
}
|
|
199
213
|
/** The output column type of one window: rankings and most aggregates count, MIN/MAX carry. */
|
|
200
214
|
export declare function windowOutputType(window: WindowSpec, innerSchema: readonly SqlColumnSchema[]): SqlColumnType;
|
|
215
|
+
/** Logical domain carried or produced by a window result, when its physical type is not enough. */
|
|
216
|
+
export declare function windowOutputDomain(window: WindowSpec, innerSchema: readonly SqlColumnSchema[]): SqlDomain | undefined;
|
|
201
217
|
export interface SelectItem {
|
|
202
218
|
expression: Expression;
|
|
203
219
|
alias: string;
|
|
@@ -224,9 +240,11 @@ export interface TableSource {
|
|
|
224
240
|
* is an ordinary select list and nothing else has to know about it.
|
|
225
241
|
*/
|
|
226
242
|
columnAliases?: string[];
|
|
243
|
+
/** Parser marker for a derived source allowed to reference sources to its left. */
|
|
244
|
+
lateral?: true;
|
|
227
245
|
}
|
|
228
246
|
export interface JoinPlan extends TableSource {
|
|
229
|
-
kind: "inner" | "left";
|
|
247
|
+
kind: "inner" | "left" | "semi" | "anti";
|
|
230
248
|
left: Expression;
|
|
231
249
|
right: Expression;
|
|
232
250
|
/** General ON condition for non-equi or multi-key joins; left/right are inert placeholders. */
|
|
@@ -252,7 +270,7 @@ export interface RecursiveCte {
|
|
|
252
270
|
step: CompiledQuery;
|
|
253
271
|
all: boolean;
|
|
254
272
|
}
|
|
255
|
-
export type PredicateOperator = ComparisonOperator | `${ComparisonOperator} ANY` | `${ComparisonOperator} ALL` | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL" | "LIKE" | "NOT LIKE" | "ILIKE" | "NOT ILIKE" | "IS DISTINCT FROM" | "IS NOT DISTINCT FROM" | "IS TRUE";
|
|
273
|
+
export type PredicateOperator = ComparisonOperator | `${ComparisonOperator} ANY` | `${ComparisonOperator} ALL` | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL" | "LIKE" | "NOT LIKE" | "ILIKE" | "NOT ILIKE" | "SIMILAR TO" | "NOT SIMILAR TO" | "IS DISTINCT FROM" | "IS NOT DISTINCT FROM" | "IS TRUE";
|
|
256
274
|
export interface Predicate {
|
|
257
275
|
left: Expression;
|
|
258
276
|
operator: PredicateOperator;
|
|
@@ -272,8 +290,8 @@ export interface CompiledQuery {
|
|
|
272
290
|
expression: Expression;
|
|
273
291
|
direction: "asc" | "desc";
|
|
274
292
|
/**
|
|
275
|
-
* Explicit NULL placement, absolute regardless of direction. Absent keeps
|
|
276
|
-
*
|
|
293
|
+
* Explicit NULL placement, absolute regardless of direction. Absent keeps PostgreSQL's
|
|
294
|
+
* default: NULLS LAST for ASC and NULLS FIRST for DESC.
|
|
277
295
|
*/
|
|
278
296
|
nulls?: "first" | "last";
|
|
279
297
|
}>;
|
|
@@ -305,6 +323,10 @@ export interface CompiledQuery {
|
|
|
305
323
|
* because the answer depends on the clock rather than on the data.
|
|
306
324
|
*/
|
|
307
325
|
usesStatementDatetime?: boolean;
|
|
326
|
+
/** NEXTVAL/CURRVAL appear in this parsed statement and need connection-local resolution. */
|
|
327
|
+
usesSequenceCalls?: boolean;
|
|
328
|
+
/** RANDOM/GEN_RANDOM_UUID appear and make result memoization unsafe. */
|
|
329
|
+
usesVolatileFunctions?: boolean;
|
|
308
330
|
}
|
|
309
331
|
/** ORDER BY / LIMIT / OFFSET tail of a select or set operation. */
|
|
310
332
|
export interface SelectTail {
|
|
@@ -360,14 +382,24 @@ export type MergeBranch = {
|
|
|
360
382
|
export interface ForeignKeyDefinition {
|
|
361
383
|
name: string;
|
|
362
384
|
column: string;
|
|
385
|
+
columns?: string[];
|
|
363
386
|
parentTable: string;
|
|
364
387
|
parentColumn?: string;
|
|
388
|
+
parentColumns?: string[];
|
|
365
389
|
onDelete: "restrict" | "cascade" | "set null";
|
|
366
390
|
}
|
|
367
|
-
|
|
368
|
-
|
|
391
|
+
export interface UniqueConstraintDefinition {
|
|
392
|
+
name: string;
|
|
393
|
+
columns: string[];
|
|
394
|
+
}
|
|
395
|
+
/** An INSERT value: a constant, SQL DEFAULT, or an unbound placeholder. */
|
|
396
|
+
export interface DefaultInsertValue {
|
|
397
|
+
readonly default: true;
|
|
398
|
+
}
|
|
399
|
+
export type InsertValue = QueryValue | DefaultInsertValue | {
|
|
369
400
|
parameter: number;
|
|
370
401
|
};
|
|
402
|
+
export declare function isDefaultInsertValue(value: InsertValue): value is DefaultInsertValue;
|
|
371
403
|
export type CompiledStatement = {
|
|
372
404
|
kind: "select";
|
|
373
405
|
sql: string;
|
|
@@ -377,6 +409,8 @@ export type CompiledStatement = {
|
|
|
377
409
|
table: string;
|
|
378
410
|
columns: string[];
|
|
379
411
|
rows: InsertValue[][];
|
|
412
|
+
/** PostgreSQL's one-row `DEFAULT VALUES` form; execution expands it to omitted columns. */
|
|
413
|
+
defaultValues?: true;
|
|
380
414
|
/** INSERT ... SELECT source; `rows` is then empty and fills at execution. */
|
|
381
415
|
query?: CompiledQuery;
|
|
382
416
|
/**
|
|
@@ -386,9 +420,16 @@ export type CompiledStatement = {
|
|
|
386
420
|
*/
|
|
387
421
|
onConflict?: {
|
|
388
422
|
column: string;
|
|
389
|
-
|
|
390
|
-
/** The EXCLUDED columns a partial DO UPDATE merges; present only for "update". */
|
|
423
|
+
/** The full PostgreSQL conflict target; `column` remains the scalar fast-path name. */
|
|
391
424
|
columns?: string[];
|
|
425
|
+
action: "nothing" | "replace" | "update";
|
|
426
|
+
/** Expressions evaluated against the stored target row and the proposed EXCLUDED row. */
|
|
427
|
+
assignments?: Array<{
|
|
428
|
+
column: string;
|
|
429
|
+
expression: Expression;
|
|
430
|
+
}>;
|
|
431
|
+
/** PostgreSQL's post-conflict filter: false or unknown leaves the stored row untouched. */
|
|
432
|
+
where?: Expression;
|
|
392
433
|
};
|
|
393
434
|
returning?: string[] | "*";
|
|
394
435
|
parameterCount?: number;
|
|
@@ -422,8 +463,12 @@ export type CompiledStatement = {
|
|
|
422
463
|
columns: Array<{
|
|
423
464
|
name: string;
|
|
424
465
|
type: SqlColumnType;
|
|
466
|
+
integer?: true;
|
|
467
|
+
sqlDomain?: SqlDomain;
|
|
425
468
|
nullable?: boolean;
|
|
426
469
|
defaultValue?: ColumnDefault;
|
|
470
|
+
enumValues?: readonly string[];
|
|
471
|
+
backfill?: Exclude<QueryValue, null>;
|
|
427
472
|
}>;
|
|
428
473
|
checks?: Array<{
|
|
429
474
|
name: string;
|
|
@@ -431,8 +476,37 @@ export type CompiledStatement = {
|
|
|
431
476
|
}>;
|
|
432
477
|
foreignKeys?: ForeignKeyDefinition[];
|
|
433
478
|
uniqueKey?: string;
|
|
479
|
+
compositePrimaryKey?: string[];
|
|
480
|
+
uniqueConstraints?: UniqueConstraintDefinition[];
|
|
434
481
|
/** CREATE TABLE IF NOT EXISTS: an existing table of that name is left alone. */
|
|
435
482
|
ifNotExists?: boolean;
|
|
483
|
+
/** Schema-owned objects carry this bit atomically with creation. */
|
|
484
|
+
managed?: boolean;
|
|
485
|
+
parameterCount?: number;
|
|
486
|
+
} | {
|
|
487
|
+
kind: "create-enum";
|
|
488
|
+
name: string;
|
|
489
|
+
values: string[];
|
|
490
|
+
parameterCount?: number;
|
|
491
|
+
} | {
|
|
492
|
+
kind: "create-sequence";
|
|
493
|
+
name: string;
|
|
494
|
+
parameterCount?: number;
|
|
495
|
+
} | {
|
|
496
|
+
kind: "create-index";
|
|
497
|
+
index: string;
|
|
498
|
+
table: string;
|
|
499
|
+
columns: Array<{
|
|
500
|
+
name: string;
|
|
501
|
+
direction: "asc" | "desc";
|
|
502
|
+
}>;
|
|
503
|
+
unique?: true;
|
|
504
|
+
ifNotExists?: boolean;
|
|
505
|
+
parameterCount?: number;
|
|
506
|
+
} | {
|
|
507
|
+
kind: "drop-index";
|
|
508
|
+
index: string;
|
|
509
|
+
ifExists?: boolean;
|
|
436
510
|
parameterCount?: number;
|
|
437
511
|
} | {
|
|
438
512
|
kind: "create-trigger";
|
|
@@ -471,6 +545,8 @@ export type CompiledStatement = {
|
|
|
471
545
|
view: string;
|
|
472
546
|
sql: string;
|
|
473
547
|
orReplace?: boolean;
|
|
548
|
+
/** Schema-owned objects carry this bit atomically with creation. */
|
|
549
|
+
managed?: boolean;
|
|
474
550
|
parameterCount?: number;
|
|
475
551
|
} | {
|
|
476
552
|
kind: "drop-view";
|
|
@@ -479,7 +555,8 @@ export type CompiledStatement = {
|
|
|
479
555
|
parameterCount?: number;
|
|
480
556
|
} | {
|
|
481
557
|
kind: "transaction";
|
|
482
|
-
action: "begin" | "commit" | "rollback";
|
|
558
|
+
action: "begin" | "commit" | "rollback" | "savepoint" | "rollback-to" | "release";
|
|
559
|
+
name?: string;
|
|
483
560
|
parameterCount?: number;
|
|
484
561
|
} | {
|
|
485
562
|
kind: "merge";
|
|
@@ -510,9 +587,21 @@ export type CompiledStatement = {
|
|
|
510
587
|
column: {
|
|
511
588
|
name: string;
|
|
512
589
|
type: SqlColumnType;
|
|
590
|
+
integer?: true;
|
|
591
|
+
sqlDomain?: SqlDomain;
|
|
513
592
|
nullable?: boolean;
|
|
514
593
|
defaultValue?: ColumnDefault;
|
|
594
|
+
enumValues?: readonly string[];
|
|
595
|
+
backfill?: Exclude<QueryValue, null>;
|
|
515
596
|
};
|
|
597
|
+
/** Schema migrations may add a proven non-null column by supplying a backfill. */
|
|
598
|
+
allowNonNullableWithBackfill?: boolean;
|
|
599
|
+
parameterCount?: number;
|
|
600
|
+
} | {
|
|
601
|
+
kind: "drop-column";
|
|
602
|
+
table: string;
|
|
603
|
+
column: string;
|
|
604
|
+
ifExists?: true;
|
|
516
605
|
parameterCount?: number;
|
|
517
606
|
};
|
|
518
607
|
/**
|
|
@@ -521,6 +610,17 @@ export type CompiledStatement = {
|
|
|
521
610
|
* row condition over this table's columns, with no aggregate, window, subquery, or parameter.
|
|
522
611
|
*/
|
|
523
612
|
export declare function compileCheckExpression(sql: string, name: string): Expression;
|
|
613
|
+
export interface DefaultExpressionTarget {
|
|
614
|
+
readonly name: string;
|
|
615
|
+
readonly type: SqlColumnType;
|
|
616
|
+
readonly sqlDomain?: SqlDomain;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Parses and type-checks one catalog default. PostgreSQL defaults are variable-free scalar
|
|
620
|
+
* expressions: functions and operators are allowed, while row references, parameters,
|
|
621
|
+
* aggregates, windows, and subqueries are not.
|
|
622
|
+
*/
|
|
623
|
+
export declare function validateDefaultExpression(sql: string, target: DefaultExpressionTarget): void;
|
|
524
624
|
/**
|
|
525
625
|
* Routes one SQL statement: SELECT and WITH compile through the read-only query pipeline, while
|
|
526
626
|
* INSERT ... VALUES, UPDATE ... SET, and DELETE FROM parse into mutation statements. Any other
|
|
@@ -576,6 +676,10 @@ export type SqlColumnType = "boolean" | "number" | "string" | "datetime";
|
|
|
576
676
|
export interface SqlColumnSchema {
|
|
577
677
|
name: string;
|
|
578
678
|
type: SqlColumnType;
|
|
679
|
+
/** Exact SQL whole-number domain, physically stored as a safe JavaScript number. */
|
|
680
|
+
integer?: true;
|
|
681
|
+
/** Logical SQL domain when the stable physical representation alone is not semantic. */
|
|
682
|
+
sqlDomain?: SqlDomain;
|
|
579
683
|
}
|
|
580
684
|
/**
|
|
581
685
|
* Infers the typed output schema of one select block from typed source schemas. A column whose
|
|
@@ -583,11 +687,15 @@ export interface SqlColumnSchema {
|
|
|
583
687
|
* derived table always has concrete column types even when its result is empty.
|
|
584
688
|
*/
|
|
585
689
|
export declare function inferBlockSchema(plan: CompiledQuery, schemas: ReadonlyMap<string, readonly SqlColumnSchema[]>): SqlColumnSchema[];
|
|
690
|
+
/** Whether a final result can contain one of the engine's tagged string-domain values. */
|
|
691
|
+
export declare function queryResultNeedsExternalization(plan: CompiledQuery, schemas: ReadonlyMap<string, readonly SqlColumnSchema[]>): boolean;
|
|
586
692
|
export declare function referencedColumns(plan: CompiledQuery, schemas: ReadonlyMap<string, readonly string[]>): Map<string, string[]>;
|
|
587
693
|
export declare function createPreparedQuery(plan: CompiledQuery, tables: ReadonlyMap<string, DatabaseRow[]>, options?: QueryExecutionOptions): PreparedQuery;
|
|
588
694
|
/** Internal columnar entry point used after MinnowDatabase materializes a stable snapshot. */
|
|
589
695
|
export declare function createPreparedColumnarQuery(plan: CompiledQuery, tables: ReadonlyMap<string, ColumnarTable>, memory?: QueryMemoryContext, options?: {
|
|
590
696
|
ftsStats?: ReadonlyMap<string, FtsStats>;
|
|
697
|
+
/** False only when catalog-backed schema inference proves every output is already public. */
|
|
698
|
+
outputNeedsExternalization?: boolean;
|
|
591
699
|
}): PreparedQuery;
|
|
592
700
|
export declare function executeQuery(plan: CompiledQuery, tables: ReadonlyMap<string, DatabaseRow[]>, options?: QueryExecutionOptions): QueryResult;
|
|
593
701
|
/**
|
|
@@ -711,12 +819,9 @@ export interface ListMembership {
|
|
|
711
819
|
export declare function cachedListMembership(node: object, items: ReadonlyArray<{
|
|
712
820
|
kind: string;
|
|
713
821
|
}>): ListMembership | null;
|
|
714
|
-
/** Compiles a LIKE pattern (% = any run, _ = any character) to an anchored RegExp, cached. */
|
|
715
|
-
export declare function likeRegExp(pattern: string, caseInsensitive?: boolean, escape?: string): RegExp;
|
|
716
822
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
* dominate real workloads — and everything else falls back to the anchored RegExp.
|
|
823
|
+
* Shared bounded LIKE matcher. Compilation and the common literal prefix/suffix/containment
|
|
824
|
+
* fast paths are cached in sql-semantics; complex wildcard shapes have deterministic work caps.
|
|
720
825
|
*/
|
|
721
826
|
export declare function likeMatches(pattern: string, value: string, caseInsensitive?: boolean, escape?: string): boolean;
|
|
722
827
|
/** Splits a quantified operator like "> ANY" into its comparison and quantifier. */
|
|
@@ -744,12 +849,16 @@ export declare function expressionColumnNames(expression: Expression): string[];
|
|
|
744
849
|
export declare function expressionColumns(expression: Expression): string[];
|
|
745
850
|
export declare function expressionAliases(expression: Expression): Set<string>;
|
|
746
851
|
/**
|
|
747
|
-
* Resolves
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
852
|
+
* Resolves NULL placement for one order term. An omitted placement follows PostgreSQL: NULLS LAST
|
|
853
|
+
* for ASC and NULLS FIRST for DESC. Returns undefined when neither side is NULL; otherwise the
|
|
854
|
+
* signed placement is absolute, so direction negation must not apply to it. Two NULLs return 0
|
|
855
|
+
* so comparison falls through to the next term.
|
|
751
856
|
*/
|
|
752
|
-
export declare function
|
|
857
|
+
export declare function nullOrder(left: unknown, right: unknown, nulls: "first" | "last" | undefined, direction: "asc" | "desc"): number | undefined;
|
|
858
|
+
/** Carries the internal no-conversion proof across a defensive result copy. */
|
|
859
|
+
export declare function copyQueryResultExternalization(source: QueryResult, copy: QueryResult): QueryResult;
|
|
860
|
+
/** Removes internal domain tags only after every comparison, group, join, and sort is complete. */
|
|
861
|
+
export declare function externalizeQueryResult(result: QueryResult): QueryResult;
|
|
753
862
|
export interface SelectBlockParts {
|
|
754
863
|
sql: string;
|
|
755
864
|
base: TableSource;
|
|
@@ -782,6 +891,8 @@ export declare function expandDistinctWildcard(plan: CompiledQuery, columnsOf: (
|
|
|
782
891
|
* table's columns positionally (E051-09). The table's own column order is only known here, so
|
|
783
892
|
* the parser records the names and this pass — one per execution entry — applies them.
|
|
784
893
|
*/
|
|
894
|
+
/** Whether any block of the plan reads a table accepted by the supplied catalog predicate. */
|
|
895
|
+
export declare function planReadsTable(plan: CompiledQuery, matches: (name: string) => boolean): boolean;
|
|
785
896
|
/** Whether any block of the plan reads a table name the catalog answers with a view. */
|
|
786
897
|
export declare function planReadsViews(plan: CompiledQuery, isView: (name: string) => boolean): boolean;
|
|
787
898
|
/**
|
|
@@ -837,11 +948,6 @@ export declare function projectResultColumns(result: QueryResult, aliases: reado
|
|
|
837
948
|
export declare function derivedTableSource(derived: CompiledQuery, alias: string, nextSequence: () => number): TableSource;
|
|
838
949
|
/** The parser's LIMIT range contract, shared with the typed builder. */
|
|
839
950
|
export declare function validateLimit(limit: number): number;
|
|
840
|
-
/**
|
|
841
|
-
* `TIMESTAMP '2026-01-02 03:04:05'` — the standard's spelling, which writes a space where ISO
|
|
842
|
-
* writes a T and leaves the time off entirely for midnight. A literal without a zone is UTC, the
|
|
843
|
-
* same reading `DATE` already takes and the same one every datetime in a Minnow database has.
|
|
844
|
-
*/
|
|
845
951
|
export declare function timestampLiteral(text: string): Date;
|
|
846
952
|
/** The parser's OFFSET range contract, shared with the typed builder. */
|
|
847
953
|
export declare function validateOffset(offset: number): number;
|
|
@@ -853,4 +959,3 @@ export declare function validateOffset(offset: number): number;
|
|
|
853
959
|
*/
|
|
854
960
|
export declare function splitCondition(expression: Expression): Predicate[];
|
|
855
961
|
export {};
|
|
856
|
-
//# sourceMappingURL=query.d.ts.map
|