@minnowdb/core 0.6.5 → 0.6.7
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/block-format/codecs.d.ts +0 -8
- package/dist/block-format/codecs.js +1 -1
- package/dist/engine/artifact-cache.d.ts +2 -1
- package/dist/engine/batch.d.ts +0 -1
- package/dist/engine/batch.js +1 -1
- package/dist/engine/buffered-writer.js +1 -12
- package/dist/engine/byte-estimates.d.ts +11 -0
- package/dist/engine/byte-estimates.js +25 -0
- package/dist/engine/database.js +58 -34
- package/dist/engine/fts.d.ts +0 -1
- package/dist/engine/fts.js +1 -1
- package/dist/engine/group-index.d.ts +2 -0
- package/dist/engine/group-index.js +4 -8
- package/dist/engine/join-index.d.ts +0 -1
- package/dist/engine/join-index.js +1 -15
- package/dist/engine/keyed-live.js +2 -36
- package/dist/engine/live-equal.d.ts +7 -0
- package/dist/engine/live-equal.js +42 -0
- package/dist/engine/optimizer.js +11 -16
- package/dist/engine/point-read.d.ts +1 -1
- package/dist/engine/point-read.js +3 -2
- package/dist/engine/query-cache.js +1 -12
- package/dist/engine/query.d.ts +20 -59
- package/dist/engine/query.js +286 -54
- package/dist/engine/result-wire.d.ts +2 -1
- package/dist/engine/schema.d.ts +15 -11
- package/dist/engine/schema.js +11 -19
- package/dist/engine/sort-keys.d.ts +2 -3
- package/dist/engine/sort-keys.js +1 -1
- package/dist/engine/sql-domains.d.ts +27 -2
- package/dist/engine/sql-domains.js +120 -6
- package/dist/engine/sql-json.d.ts +0 -2
- package/dist/engine/sql-json.js +1 -1
- package/dist/engine/sql-semantics.d.ts +2 -1
- package/dist/engine/typed-live.js +3 -41
- package/dist/engine/vector.d.ts +7 -7
- package/dist/engine/vector.js +11 -30
- package/dist/engine/write-block-planner.d.ts +2 -1
- package/dist/plan/model.d.ts +22 -0
- package/dist/plan/model.js +29 -1
- package/dist/storage/indexeddb.js +13 -23
- package/dist/storage/opfs/leader.d.ts +0 -4
- package/dist/storage/opfs/leader.js +5 -14
- package/dist/storage/opfs/snapshot-ledger.d.ts +3 -2
- package/dist/storage/toolkit/index.d.ts +1 -1
- package/dist/storage/toolkit/record-core.d.ts +0 -1
- package/dist/storage/toolkit/record-core.js +3 -19
- package/dist/storage/types.d.ts +4 -3
- package/dist/storage/types.js +13 -2
- package/dist/testing/block-store-conformance.js +28 -0
- package/dist/testing/opfs-shim.d.ts +2 -1
- package/dist/testing/simulator.js +3 -0
- package/dist/worker-protocol/index.d.ts +0 -32
- package/dist/worker-protocol/index.js +0 -40
- package/package.json +2 -1
- package/postgres-feature-profile.json +8 -3
- package/sql-feature-matrix.json +71 -11
package/dist/engine/query.d.ts
CHANGED
|
@@ -31,12 +31,6 @@ export interface QueryExecutionOptions {
|
|
|
31
31
|
export declare const scalarFunctionNames: ReadonlySet<string>;
|
|
32
32
|
/** Functions whose answer can change without any catalog or input-row change. */
|
|
33
33
|
export declare const volatileScalarFunctionNames: ReadonlySet<string>;
|
|
34
|
-
/**
|
|
35
|
-
* The niladic datetime functions (F051-06/07/08). Their value is the statement's own clock
|
|
36
|
-
* reading, so they are resolved once per execution rather than evaluated per row: every row of
|
|
37
|
-
* one statement sees one instant, both executors agree, and constant folding leaves them alone.
|
|
38
|
-
*/
|
|
39
|
-
export declare const statementDatetimeNames: ReadonlySet<string>;
|
|
40
34
|
export declare function isScalarFunctionName(name: AggregateName | ScalarFunctionName): name is ScalarFunctionName;
|
|
41
35
|
/**
|
|
42
36
|
* Evaluates one scalar function over already-evaluated argument values. Every executor calls
|
|
@@ -46,23 +40,6 @@ export declare function isScalarFunctionName(name: AggregateName | ScalarFunctio
|
|
|
46
40
|
* SUBSTR count characters, not UTF-16 units, matching SQLite and PostgreSQL.
|
|
47
41
|
*/
|
|
48
42
|
export declare function scalarFunctionValue(name: Exclude<ScalarFunctionName, "COALESCE">, values: readonly unknown[]): unknown;
|
|
49
|
-
export declare const dateTruncUnits: ReadonlySet<string>;
|
|
50
|
-
/**
|
|
51
|
-
* `INTERVAL '1 month'`, `INTERVAL '2 years 3 days'`. Months are kept apart from milliseconds
|
|
52
|
-
* rather than converted, because a month is not a fixed number of them: adding one to January 31
|
|
53
|
-
* has to land on the end of February, which only calendar arithmetic can do.
|
|
54
|
-
*/
|
|
55
|
-
export declare function intervalLiteral(text: string): {
|
|
56
|
-
months: number;
|
|
57
|
-
milliseconds: number;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* A datetime shifted by a calendar interval: whole months first, then milliseconds. A day that
|
|
61
|
-
* does not exist in the target month clamps to that month's last day, which is what both SQLite
|
|
62
|
-
* and PostgreSQL do with 31 January plus a month.
|
|
63
|
-
*/
|
|
64
|
-
export declare function dateAddValue(value: unknown, months: unknown, milliseconds: unknown): Date | string | null;
|
|
65
|
-
export declare function dateTruncValue(unit: unknown, value: unknown): Date | null;
|
|
66
43
|
/** The output column type of one window: rankings and most aggregates count, MIN/MAX carry. */
|
|
67
44
|
export declare function windowOutputType(window: WindowSpec, innerSchema: readonly SqlColumnSchema[]): SqlColumnType;
|
|
68
45
|
/** Logical domain carried or produced by a window result, when its physical type is not enough. */
|
|
@@ -75,7 +52,7 @@ export declare function windowOutputDomain(window: WindowSpec, innerSchema: read
|
|
|
75
52
|
export declare const DUAL_TABLE = "(dual)";
|
|
76
53
|
/** The dual source's single row, shared by every resolution path. */
|
|
77
54
|
export declare function dualTableRows(): DatabaseRow[];
|
|
78
|
-
|
|
55
|
+
interface CompileQueryOptions {
|
|
79
56
|
/** Set false to skip deterministic plan rewrites, for example to snapshot the raw plan. */
|
|
80
57
|
readonly optimize?: boolean;
|
|
81
58
|
}
|
|
@@ -84,7 +61,7 @@ export declare function compileQuery(sql: string, options?: CompileQueryOptions)
|
|
|
84
61
|
* One WHEN clause of a MERGE (F312). Branches are tried in order for each source row, and the
|
|
85
62
|
* first whose match state and optional condition hold decides what happens to that row.
|
|
86
63
|
*/
|
|
87
|
-
|
|
64
|
+
type MergeBranch = {
|
|
88
65
|
when: "matched";
|
|
89
66
|
condition?: Expression;
|
|
90
67
|
action: {
|
|
@@ -125,7 +102,7 @@ export interface UniqueConstraintDefinition {
|
|
|
125
102
|
columns: string[];
|
|
126
103
|
}
|
|
127
104
|
/** An INSERT value: a constant, SQL DEFAULT, or an unbound placeholder. */
|
|
128
|
-
|
|
105
|
+
interface DefaultInsertValue {
|
|
129
106
|
readonly default: true;
|
|
130
107
|
}
|
|
131
108
|
export type InsertValue = QueryValue | DefaultInsertValue | {
|
|
@@ -344,7 +321,7 @@ export type CompiledStatement = {
|
|
|
344
321
|
* row condition over this table's columns, with no aggregate, window, subquery, or parameter.
|
|
345
322
|
*/
|
|
346
323
|
export declare function compileCheckExpression(sql: string, name: string): Expression;
|
|
347
|
-
|
|
324
|
+
interface DefaultExpressionTarget {
|
|
348
325
|
readonly name: string;
|
|
349
326
|
readonly type: SqlColumnType;
|
|
350
327
|
readonly sqlDomain?: SqlDomain;
|
|
@@ -368,7 +345,7 @@ export declare function compileStatement(sql: string): CompiledStatement;
|
|
|
368
345
|
export declare function evaluateJoinedRowExpression(expression: Expression, rows: Readonly<Record<string, DatabaseRow | undefined>>): QueryValue;
|
|
369
346
|
/** Evaluates an expression against one row, for UPDATE SET assignment computation. */
|
|
370
347
|
export declare function evaluateRowExpression(expression: Expression, alias: string, row: DatabaseRow): QueryValue;
|
|
371
|
-
|
|
348
|
+
interface SubqueryResolutionStep {
|
|
372
349
|
/** The uncorrelated block to execute; earlier steps have already substituted inside it. */
|
|
373
350
|
readonly block: CompiledQuery;
|
|
374
351
|
/** Replaces the subquery node with the executed result as literals. */
|
|
@@ -386,9 +363,6 @@ export declare function subqueryResolutionSteps(plan: CompiledQuery): {
|
|
|
386
363
|
steps: SubqueryResolutionStep[];
|
|
387
364
|
};
|
|
388
365
|
export declare function blockHasSubqueries(plan: CompiledQuery): boolean;
|
|
389
|
-
/** True when any `?`/`$n` placeholder remains anywhere in the expression tree. */
|
|
390
|
-
export declare function containsParameter(expression: Expression): boolean;
|
|
391
|
-
export declare function blockHasParameters(block: CompiledQuery): boolean;
|
|
392
366
|
/**
|
|
393
367
|
* A deep copy of a compiled plan, statement, or expression tree. Plans are plain data — objects,
|
|
394
368
|
* arrays, primitives, and Date literals — so a direct recursive copy does what structuredClone
|
|
@@ -486,7 +460,7 @@ export declare function mapBlockExpressions(block: CompiledQuery, map: (expressi
|
|
|
486
460
|
*/
|
|
487
461
|
export declare function resolveStatementDatetimes(plan: CompiledQuery, now?: Date): CompiledQuery;
|
|
488
462
|
/** One top-level full-text MATCH conjunct of a plan, with its resolved column expressions. */
|
|
489
|
-
|
|
463
|
+
interface FtsMatchConjunct {
|
|
490
464
|
columns: Expression[];
|
|
491
465
|
query: string;
|
|
492
466
|
}
|
|
@@ -520,6 +494,17 @@ export declare function planContainsFts(plan: CompiledQuery, op?: "match" | "bm2
|
|
|
520
494
|
* later migrations.
|
|
521
495
|
*/
|
|
522
496
|
export declare function expandFtsColumns(plan: CompiledQuery, searchableColumnsFor: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
497
|
+
/**
|
|
498
|
+
* Annotates every `AVG(column)` in this block's expression positions with the argument column's
|
|
499
|
+
* declared NUMERIC scale, resolved against the given schemas. PostgreSQL floors an AVG's
|
|
500
|
+
* internal division scale at the summed values' display scale; the canonical NUMERIC encoding
|
|
501
|
+
* strips trailing fractional zeros, so without the annotation the divide cannot know the digits
|
|
502
|
+
* a declared scale above its own selection would render, and the display padding would fabricate
|
|
503
|
+
* zeros where PostgreSQL computes real digits. Runs where the catalog is known, per block —
|
|
504
|
+
* nested blocks execute through their own schema-aware entry. Copy-on-write: plans without an
|
|
505
|
+
* AVG pass through untouched, and the input is often the compile cache's own object.
|
|
506
|
+
*/
|
|
507
|
+
export declare function annotateAvgArgumentScales(plan: CompiledQuery, schemas: ReadonlyMap<string, readonly SqlColumnSchema[]>): CompiledQuery;
|
|
523
508
|
/**
|
|
524
509
|
* Appends window-function columns to an executed inner-block result. Rows sort stably by the
|
|
525
510
|
* hidden partition and ordering aliases with the same comparison semantics as ORDER BY;
|
|
@@ -532,7 +517,7 @@ export declare function applyWindowFunctions(result: QueryResult, windows: reado
|
|
|
532
517
|
/** Correctness reference retained while the vector executor matures. */
|
|
533
518
|
export declare function executeRowQuery(plan: CompiledQuery, tables: ReadonlyMap<string, DatabaseRow[]>): QueryResult;
|
|
534
519
|
/** One ORDER BY resolution source: an alias and the columns a wildcard select exposes from it. */
|
|
535
|
-
|
|
520
|
+
interface OrderSourceShape {
|
|
536
521
|
readonly alias: string;
|
|
537
522
|
readonly columns: readonly string[];
|
|
538
523
|
}
|
|
@@ -543,7 +528,7 @@ export interface OrderSourceShape {
|
|
|
543
528
|
* repeated rows.
|
|
544
529
|
*/
|
|
545
530
|
export declare function orderOutputName(expression: Expression, select: readonly SelectItem[], sources: readonly OrderSourceShape[]): string;
|
|
546
|
-
|
|
531
|
+
interface ListMembership {
|
|
547
532
|
set: ReadonlySet<unknown>;
|
|
548
533
|
hasNull: boolean;
|
|
549
534
|
}
|
|
@@ -604,7 +589,7 @@ export declare function nullOrder(left: unknown, right: unknown, nulls: "first"
|
|
|
604
589
|
export declare function copyQueryResultExternalization(source: QueryResult, copy: QueryResult): QueryResult;
|
|
605
590
|
/** Removes internal domain tags only after every comparison, group, join, and sort is complete. */
|
|
606
591
|
export declare function externalizeQueryResult(result: QueryResult): QueryResult;
|
|
607
|
-
|
|
592
|
+
interface SelectBlockParts {
|
|
608
593
|
sql: string;
|
|
609
594
|
base: TableSource;
|
|
610
595
|
joins: JoinPlan[];
|
|
@@ -624,13 +609,6 @@ export interface SelectBlockParts {
|
|
|
624
609
|
groupingSets?: Expression[][];
|
|
625
610
|
}
|
|
626
611
|
export declare function assembleSelectBlock(parts: SelectBlockParts, nextSequence: () => number): CompiledQuery;
|
|
627
|
-
/**
|
|
628
|
-
* Expands a pending SELECT DISTINCT * against known input columns: the select list becomes
|
|
629
|
-
* every wildcard output (alias-qualified when more than one source contributes), and GROUP BY
|
|
630
|
-
* over those same columns provides the deduplication through the grouped executor. Runs
|
|
631
|
-
* exactly once per execution entry, like MATCH(*) expansion.
|
|
632
|
-
*/
|
|
633
|
-
export declare function expandDistinctWildcard(plan: CompiledQuery, columnsOf: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
634
612
|
/**
|
|
635
613
|
* Turns every source carrying a column alias list into a derived projection that renames the
|
|
636
614
|
* table's columns positionally (E051-09). The table's own column order is only known here, so
|
|
@@ -648,15 +626,6 @@ export declare function planReadsViews(plan: CompiledQuery, isView: (name: strin
|
|
|
648
626
|
*/
|
|
649
627
|
export declare function expandViewSources(plan: CompiledQuery, viewFor: (tableName: string) => CompiledQuery | undefined, maxDepth?: number): CompiledQuery;
|
|
650
628
|
export declare function planHasSourceColumnAliases(plan: CompiledQuery): boolean;
|
|
651
|
-
/**
|
|
652
|
-
* FETCH FIRST n ROWS WITH TIES (F866). The plan runs without its limit — a limit pushed into a
|
|
653
|
-
* scan cannot know whether the next row ties — and the ordered result is trimmed here: rows up
|
|
654
|
-
* to the limit, plus every following row equal to the last one on all ORDER BY columns.
|
|
655
|
-
*/
|
|
656
|
-
export declare function withTiesPlan(plan: CompiledQuery): {
|
|
657
|
-
plan: CompiledQuery;
|
|
658
|
-
trim: (result: QueryResult) => QueryResult;
|
|
659
|
-
};
|
|
660
629
|
/** Whether any block of the plan still carries an unresolved NATURAL join marker. */
|
|
661
630
|
export declare function planHasNaturalJoins(plan: CompiledQuery): boolean;
|
|
662
631
|
/**
|
|
@@ -666,13 +635,6 @@ export declare function planHasNaturalJoins(plan: CompiledQuery): boolean;
|
|
|
666
635
|
*/
|
|
667
636
|
export declare function expandNaturalJoins(plan: CompiledQuery, columnsOf: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
668
637
|
export declare function expandSourceColumnAliases(plan: CompiledQuery, columnsOf: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
669
|
-
/**
|
|
670
|
-
* Expands `alias.*` select items into that source's columns (E051-07), at every nesting depth.
|
|
671
|
-
* Output names follow the same rule as a bare `*`: the column's own name when the block reads
|
|
672
|
-
* one source, and `alias.column` when it reads several, so two sources cannot collide.
|
|
673
|
-
* Runs once per execution entry, like MATCH(*) and DISTINCT * expansion.
|
|
674
|
-
*/
|
|
675
|
-
export declare function expandQualifiedWildcards(plan: CompiledQuery, columnsOf: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
676
638
|
/** Wraps compound members into the set-operation source the executor folds left to right. */
|
|
677
639
|
export declare function compoundSelectBlock(sql: string, blocks: CompiledQuery[], ops: SetOperator[], tail: SelectTail, nextSequence: () => number): CompiledQuery;
|
|
678
640
|
/**
|
|
@@ -693,7 +655,6 @@ export declare function projectResultColumns(result: QueryResult, aliases: reado
|
|
|
693
655
|
export declare function derivedTableSource(derived: CompiledQuery, alias: string, nextSequence: () => number): TableSource;
|
|
694
656
|
/** The parser's LIMIT range contract, shared with the typed builder. */
|
|
695
657
|
export declare function validateLimit(limit: number): number;
|
|
696
|
-
export declare function timestampLiteral(text: string): Date;
|
|
697
658
|
/** The parser's OFFSET range contract, shared with the typed builder. */
|
|
698
659
|
export declare function validateOffset(offset: number): number;
|
|
699
660
|
/**
|