@crvouga/sqlite-mem 1.8.0 → 1.9.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 +31 -18
- package/compat/divergences.json +5 -5
- package/compat/scenarios.ts +7 -6
- package/dist/api/database.d.ts +7 -15
- package/dist/api/snapshot.d.ts +21 -0
- package/dist/constraints/check.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6490 -5845
- package/dist/index.js.map +4 -4
- package/dist/indexes/index.d.ts +15 -0
- package/dist/indexes/keys.d.ts +20 -0
- package/dist/serialization/codec.d.ts +2 -2
- package/dist/storage/row.d.ts +6 -3
- package/dist/storage/table.d.ts +10 -0
- package/dist/types/value.d.ts +0 -1
- package/dist/unstable.js +630 -133
- package/dist/unstable.js.map +4 -4
- package/package.json +1 -1
package/dist/indexes/index.d.ts
CHANGED
|
@@ -22,8 +22,23 @@ export declare class IndexStore {
|
|
|
22
22
|
clear(): void;
|
|
23
23
|
clone(): IndexStore;
|
|
24
24
|
freeze(): void;
|
|
25
|
+
/** Sorted entries for SQLM v3 persistence. */
|
|
26
|
+
snapshotEntries(): Array<{
|
|
27
|
+
key: string;
|
|
28
|
+
rowids: Rowid[];
|
|
29
|
+
values: SqlValue[];
|
|
30
|
+
}>;
|
|
31
|
+
/** Sorted keys + rowids for SQLM v4 (values rebuilt from the table). */
|
|
32
|
+
snapshotKeys(): Array<{
|
|
33
|
+
key: string;
|
|
34
|
+
rowids: Rowid[];
|
|
35
|
+
}>;
|
|
36
|
+
rememberKeyValues(key: string, values: readonly SqlValue[]): void;
|
|
25
37
|
get size(): number;
|
|
26
38
|
private orderedKeys;
|
|
27
39
|
private assertMutable;
|
|
28
40
|
}
|
|
41
|
+
/** Hash-join / covering-hash key: NULL components never match. */
|
|
29
42
|
export declare function serializeIndexKey(values: readonly SqlValue[]): string | null;
|
|
43
|
+
/** Index-store key: NULL is a distinct component so composite prefix lookups still hit. */
|
|
44
|
+
export declare function serializeIndexEntry(values: readonly SqlValue[]): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IndexedColumn } from "../ast/nodes.js";
|
|
2
|
+
import type { EvalContext } from "../expressions/context.js";
|
|
3
|
+
import type { IndexInfo } from "../storage/database-state.js";
|
|
4
|
+
import { type Row } from "../storage/row.js";
|
|
5
|
+
import type { Table } from "../storage/table.js";
|
|
6
|
+
import type { Affinity, SqlValue } from "../types/value.js";
|
|
7
|
+
/** Heap cells for evaluating index expressions / partial `WHERE` via `ExecutionEnv`. */
|
|
8
|
+
export declare function heapRowCells(table: Table, row: Row): Array<{
|
|
9
|
+
table: string;
|
|
10
|
+
name: string;
|
|
11
|
+
value: SqlValue;
|
|
12
|
+
affinity: Affinity;
|
|
13
|
+
collate: string | null;
|
|
14
|
+
}>;
|
|
15
|
+
/** Indexed-column values for one heap row (expression indexes included when `ctx` is set). */
|
|
16
|
+
export declare function indexKeyValues(columns: readonly IndexedColumn[], row: Row, ctx?: EvalContext | null, table?: Table): SqlValue[];
|
|
17
|
+
/** Rebuild `index.store` from `table` using the same keys as DML maintenance. */
|
|
18
|
+
export declare function rebuildIndexFromTable(index: IndexInfo, table: Table, ctxForRow: (row: Row) => EvalContext): void;
|
|
19
|
+
/** Snapshot / no-`ExecutionEnv` evaluator for index expressions / partial predicates. */
|
|
20
|
+
export declare function tableRowEvalContext(table: Table, row: Row): EvalContext;
|
|
@@ -10,7 +10,7 @@ export interface SnapshotRuntime {
|
|
|
10
10
|
export interface DecodedSnapshot {
|
|
11
11
|
/** Restored catalog and table data. */
|
|
12
12
|
state: DatabaseState;
|
|
13
|
-
/** Present for v2 snapshots; `null` for v1 (schema/rows only). */
|
|
13
|
+
/** Present for v2+ snapshots; `null` for v1 (schema/rows only). */
|
|
14
14
|
runtime: SnapshotRuntime | null;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -18,7 +18,7 @@ export interface DecodedSnapshot {
|
|
|
18
18
|
*
|
|
19
19
|
* Prefer {@link Database.snapshot} unless you are serializing engine state directly.
|
|
20
20
|
*/
|
|
21
|
-
export declare function encodeDatabaseState(state: DatabaseState, runtime: SnapshotRuntime): Uint8Array;
|
|
21
|
+
export declare function encodeDatabaseState(state: DatabaseState, runtime: SnapshotRuntime, formatVersion?: number): Uint8Array;
|
|
22
22
|
/**
|
|
23
23
|
* Decode a blob from {@link encodeDatabaseState} / {@link Database.snapshot}.
|
|
24
24
|
*
|
package/dist/storage/row.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { SqlValue } from "../types/value.js";
|
|
2
2
|
export type Rowid = number | bigint;
|
|
3
|
+
/** Heap row: `values[i]` is `table.columns[i]`. */
|
|
3
4
|
export interface Row {
|
|
4
5
|
rowid: Rowid;
|
|
5
|
-
values:
|
|
6
|
+
values: SqlValue[];
|
|
6
7
|
}
|
|
7
|
-
export type
|
|
8
|
+
export type NamedRowValues = Map<string, SqlValue> | ReadonlyMap<string, SqlValue> | Record<string, SqlValue>;
|
|
9
|
+
export type RowValues = NamedRowValues | readonly SqlValue[];
|
|
8
10
|
export declare function normalizeColumnName(name: string): string;
|
|
9
|
-
export declare function rowValues(values:
|
|
11
|
+
export declare function rowValues(values: NamedRowValues): Map<string, SqlValue>;
|
|
10
12
|
export declare function cloneRow(row: Row): Row;
|
|
13
|
+
export declare function isValueArray(values: RowValues): values is readonly SqlValue[];
|
package/dist/storage/table.d.ts
CHANGED
|
@@ -55,7 +55,16 @@ export declare class Table {
|
|
|
55
55
|
/** Cached maximum rowid. `undefined` means recompute after deleting the maximum. */
|
|
56
56
|
private maximumRowid;
|
|
57
57
|
frozen: boolean;
|
|
58
|
+
/** nameLower → column index; rebuilt after ALTER. */
|
|
59
|
+
private colIndex;
|
|
58
60
|
constructor(name: string, columns: ColumnInfo[], options?: TableOptions);
|
|
61
|
+
rebuildColIndex(): void;
|
|
62
|
+
columnOffset(nameLower: string): number | undefined;
|
|
63
|
+
hasColumn(nameLower: string): boolean;
|
|
64
|
+
cell(row: Row, nameLower: string): SqlValue;
|
|
65
|
+
setCell(row: Row, nameLower: string, value: SqlValue): void;
|
|
66
|
+
namedValues(row: Row): Map<string, SqlValue>;
|
|
67
|
+
rowFromNamed(values: Map<string, SqlValue>, rowid?: Rowid): Row;
|
|
59
68
|
integerPkColumn(): ColumnInfo | undefined;
|
|
60
69
|
get(rowid: Rowid): Row | undefined;
|
|
61
70
|
getByKey(value: SqlValue): Row | undefined;
|
|
@@ -82,6 +91,7 @@ export declare class Table {
|
|
|
82
91
|
private assertMutable;
|
|
83
92
|
/** Rebuild clustered storage after snapshot decode or bulk load. */
|
|
84
93
|
rebuildClusteredRows(): void;
|
|
94
|
+
private cellsFromInput;
|
|
85
95
|
private prepareValues;
|
|
86
96
|
private column;
|
|
87
97
|
private validate;
|
package/dist/types/value.d.ts
CHANGED
|
@@ -72,7 +72,6 @@ export declare function sqlValueEquals(a: SqlValue, b: SqlValue): boolean;
|
|
|
72
72
|
* Returns -1, 0, 1, or null if either side is NULL (SQL NULL).
|
|
73
73
|
*/
|
|
74
74
|
export declare function compareSql(a: SqlValue, b: SqlValue): number | null;
|
|
75
|
-
/** UTF-8 encode `s` (SQLite TEXT → BLOB). */
|
|
76
75
|
export declare function utf8Encode(s: string): Uint8Array;
|
|
77
76
|
/** UTF-8 decode `b` (SQLite BLOB → TEXT). */
|
|
78
77
|
export declare function utf8Decode(b: Uint8Array): string;
|