@minnowdb/core 0.6.8 → 0.7.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 +3 -2
- package/dist/date-value.d.ts +5 -0
- package/dist/date-value.js +41 -0
- package/dist/engine/database.js +1085 -81
- package/dist/engine/optimizer.js +446 -18
- package/dist/engine/point-read.d.ts +4 -2
- package/dist/engine/point-read.js +16 -6
- package/dist/engine/query.d.ts +53 -1
- package/dist/engine/query.js +1160 -239
- package/dist/engine/sql-domains.d.ts +7 -1
- package/dist/engine/sql-domains.js +38 -1
- package/dist/engine/sql-functions.d.ts +11 -0
- package/dist/engine/sql-functions.js +1186 -0
- package/dist/engine/sql-semantics.d.ts +25 -4
- package/dist/engine/sql-semantics.js +134 -1
- package/dist/engine/vector.d.ts +7 -1
- package/dist/engine/vector.js +718 -124
- package/dist/plan/model.d.ts +21 -1
- package/dist/storage/types.js +44 -18
- package/package.json +1 -1
- package/postgres-feature-profile.json +15 -5
- package/sql-feature-matrix.json +277 -6
package/dist/engine/query.d.ts
CHANGED
|
@@ -40,6 +40,14 @@ export declare function isScalarFunctionName(name: AggregateName | ScalarFunctio
|
|
|
40
40
|
* SUBSTR count characters, not UTF-16 units, matching SQLite and PostgreSQL.
|
|
41
41
|
*/
|
|
42
42
|
export declare function scalarFunctionValue(name: Exclude<ScalarFunctionName, "COALESCE">, values: readonly unknown[]): unknown;
|
|
43
|
+
export type ScalarFunctionEvaluator = (values: readonly unknown[]) => unknown;
|
|
44
|
+
/**
|
|
45
|
+
* The evaluator for one function name, resolved once. A call site that keeps the evaluator
|
|
46
|
+
* skips the name dispatch on every row; the registry functions and the hottest built-ins get
|
|
47
|
+
* a closure of their own, everything else a closure over the general dispatch.
|
|
48
|
+
*/
|
|
49
|
+
export declare function scalarFunctionEvaluator(name: Exclude<ScalarFunctionName, "COALESCE">): ScalarFunctionEvaluator;
|
|
50
|
+
export declare function dateTruncValue(unit: unknown, value: unknown): Date | null;
|
|
43
51
|
/** The output column type of one window: rankings and most aggregates count, MIN/MAX carry. */
|
|
44
52
|
export declare function windowOutputType(window: WindowSpec, innerSchema: readonly SqlColumnSchema[]): SqlColumnType;
|
|
45
53
|
/** Logical domain carried or produced by a window result, when its physical type is not enough. */
|
|
@@ -56,6 +64,14 @@ interface CompileQueryOptions {
|
|
|
56
64
|
/** Set false to skip deterministic plan rewrites, for example to snapshot the raw plan. */
|
|
57
65
|
readonly optimize?: boolean;
|
|
58
66
|
}
|
|
67
|
+
/** One RETURNING item beyond a plain column: its statement text, output name, and the column it names when it is one. */
|
|
68
|
+
export interface ReturningItem {
|
|
69
|
+
sql: string;
|
|
70
|
+
alias: string;
|
|
71
|
+
expression: Expression;
|
|
72
|
+
/** The target column the item names, when it is a bare column reference. */
|
|
73
|
+
column?: string;
|
|
74
|
+
}
|
|
59
75
|
export declare function compileQuery(sql: string, options?: CompileQueryOptions): CompiledQuery;
|
|
60
76
|
/**
|
|
61
77
|
* One WHEN clause of a MERGE (F312). Branches are tried in order for each source row, and the
|
|
@@ -105,10 +121,14 @@ export interface UniqueConstraintDefinition {
|
|
|
105
121
|
interface DefaultInsertValue {
|
|
106
122
|
readonly default: true;
|
|
107
123
|
}
|
|
108
|
-
|
|
124
|
+
interface DeferredInsertExpression {
|
|
125
|
+
readonly expression: Expression;
|
|
126
|
+
}
|
|
127
|
+
export type InsertValue = QueryValue | DefaultInsertValue | DeferredInsertExpression | {
|
|
109
128
|
parameter: number;
|
|
110
129
|
};
|
|
111
130
|
export declare function isDefaultInsertValue(value: InsertValue): value is DefaultInsertValue;
|
|
131
|
+
export declare function isDeferredInsertExpression(value: InsertValue): value is DeferredInsertExpression;
|
|
112
132
|
export type CompiledStatement = {
|
|
113
133
|
kind: "select";
|
|
114
134
|
sql: string;
|
|
@@ -131,6 +151,11 @@ export type CompiledStatement = {
|
|
|
131
151
|
column: string;
|
|
132
152
|
/** The full PostgreSQL conflict target; `column` remains the scalar fast-path name. */
|
|
133
153
|
columns?: string[];
|
|
154
|
+
/**
|
|
155
|
+
* `ON CONFLICT DO NOTHING` with no target: the statement names no columns, and the
|
|
156
|
+
* table's unique key is resolved at execution, where the catalog is known.
|
|
157
|
+
*/
|
|
158
|
+
anyTarget?: true;
|
|
134
159
|
action: "nothing" | "replace" | "update";
|
|
135
160
|
/** Expressions evaluated against the stored target row and the proposed EXCLUDED row. */
|
|
136
161
|
assignments?: Array<{
|
|
@@ -141,10 +166,14 @@ export type CompiledStatement = {
|
|
|
141
166
|
where?: Expression;
|
|
142
167
|
};
|
|
143
168
|
returning?: string[] | "*";
|
|
169
|
+
/** RETURNING items that are not plain columns, evaluated over the affected rows. */
|
|
170
|
+
returningItems?: ReturningItem[];
|
|
144
171
|
parameterCount?: number;
|
|
145
172
|
} | {
|
|
146
173
|
kind: "update";
|
|
147
174
|
table: string;
|
|
175
|
+
/** `UPDATE t AS u`: the name the assignments, predicates, and RETURNING may qualify by. */
|
|
176
|
+
alias?: string;
|
|
148
177
|
assignments: Array<{
|
|
149
178
|
column: string;
|
|
150
179
|
expression: Expression;
|
|
@@ -155,16 +184,21 @@ export type CompiledStatement = {
|
|
|
155
184
|
right: Expression;
|
|
156
185
|
}>;
|
|
157
186
|
returning?: string[] | "*";
|
|
187
|
+
/** RETURNING items that are not plain columns, evaluated over the affected rows. */
|
|
188
|
+
returningItems?: ReturningItem[];
|
|
158
189
|
parameterCount?: number;
|
|
159
190
|
} | {
|
|
160
191
|
kind: "delete";
|
|
161
192
|
table: string;
|
|
193
|
+
alias?: string;
|
|
162
194
|
predicates: Array<{
|
|
163
195
|
left: Expression;
|
|
164
196
|
operator: PredicateOperator;
|
|
165
197
|
right: Expression;
|
|
166
198
|
}>;
|
|
167
199
|
returning?: string[] | "*";
|
|
200
|
+
/** RETURNING items that are not plain columns, evaluated over the affected rows. */
|
|
201
|
+
returningItems?: ReturningItem[];
|
|
168
202
|
parameterCount?: number;
|
|
169
203
|
} | {
|
|
170
204
|
kind: "create-table";
|
|
@@ -531,6 +565,8 @@ export declare function orderOutputName(expression: Expression, select: readonly
|
|
|
531
565
|
interface ListMembership {
|
|
532
566
|
set: ReadonlySet<unknown>;
|
|
533
567
|
hasNull: boolean;
|
|
568
|
+
/** Whether any member is text, which a typed left value may read in its own type. */
|
|
569
|
+
hasText: boolean;
|
|
534
570
|
}
|
|
535
571
|
/**
|
|
536
572
|
* IN lists produced by subquery materialization can hold many thousands of literals, and
|
|
@@ -626,6 +662,15 @@ export declare function planReadsViews(plan: CompiledQuery, isView: (name: strin
|
|
|
626
662
|
*/
|
|
627
663
|
export declare function expandViewSources(plan: CompiledQuery, viewFor: (tableName: string) => CompiledQuery | undefined, maxDepth?: number): CompiledQuery;
|
|
628
664
|
export declare function planHasSourceColumnAliases(plan: CompiledQuery): boolean;
|
|
665
|
+
/** Whether any block still needs source schemas before its SELECT shape can be lowered. */
|
|
666
|
+
export declare function planHasPendingSelectShapes(plan: CompiledQuery): boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Expands schema-dependent SELECT wildcards, then sends the now-concrete block through the same
|
|
669
|
+
* lowering used by ordinary named select lists. This is the single boundary at which wildcard
|
|
670
|
+
* width becomes plan shape: DISTINCT, windows, ORDER BY expressions/ordinals, set operations,
|
|
671
|
+
* CTE/derived column lists, grouping sets, and FULL JOIN therefore cannot disagree about it.
|
|
672
|
+
*/
|
|
673
|
+
export declare function bindPendingSelectShapes(plan: CompiledQuery, columnsOf: (tableName: string) => readonly string[] | undefined): CompiledQuery;
|
|
629
674
|
/** Whether any block of the plan still carries an unresolved NATURAL join marker. */
|
|
630
675
|
export declare function planHasNaturalJoins(plan: CompiledQuery): boolean;
|
|
631
676
|
/**
|
|
@@ -655,6 +700,13 @@ export declare function projectResultColumns(result: QueryResult, aliases: reado
|
|
|
655
700
|
export declare function derivedTableSource(derived: CompiledQuery, alias: string, nextSequence: () => number): TableSource;
|
|
656
701
|
/** The parser's LIMIT range contract, shared with the typed builder. */
|
|
657
702
|
export declare function validateLimit(limit: number): number;
|
|
703
|
+
/**
|
|
704
|
+
* Reads datetime text the way the TIMESTAMP literal does — a zoneless `2026-01-02 03:04:05` is
|
|
705
|
+
* UTC, never the host's zone — and falls back to the JavaScript parser for other spellings.
|
|
706
|
+
* `new Date("2026-01-02 03:04:05")` alone would read the same text in local time, so a CAST
|
|
707
|
+
* would answer differently on two machines.
|
|
708
|
+
*/
|
|
709
|
+
export declare function datetimeText(text: string): Date;
|
|
658
710
|
/** The parser's OFFSET range contract, shared with the typed builder. */
|
|
659
711
|
export declare function validateOffset(offset: number): number;
|
|
660
712
|
/**
|