@quereus/quereus 4.15.2 → 4.17.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/dist/src/core/database-auto-analyze.d.ts +258 -0
- package/dist/src/core/database-auto-analyze.d.ts.map +1 -0
- package/dist/src/core/database-auto-analyze.js +616 -0
- package/dist/src/core/database-auto-analyze.js.map +1 -0
- package/dist/src/core/database-materialized-views.d.ts +42 -1
- package/dist/src/core/database-materialized-views.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.js +76 -3
- package/dist/src/core/database-materialized-views.js.map +1 -1
- package/dist/src/core/database-transaction.d.ts +17 -0
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +37 -0
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database.d.ts +8 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +135 -5
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +8 -8
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +27 -14
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.js +23 -2
- package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
- package/dist/src/planner/analysis/mv-body-functions.d.ts +46 -0
- package/dist/src/planner/analysis/mv-body-functions.d.ts.map +1 -0
- package/dist/src/planner/analysis/mv-body-functions.js +65 -0
- package/dist/src/planner/analysis/mv-body-functions.js.map +1 -0
- package/dist/src/planner/analysis/predicate-shape.d.ts +32 -4
- package/dist/src/planner/analysis/predicate-shape.d.ts.map +1 -1
- package/dist/src/planner/analysis/predicate-shape.js +37 -5
- package/dist/src/planner/analysis/predicate-shape.js.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +2 -2
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.js +46 -6
- package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
- package/dist/src/planner/analysis/sat-checker.js +2 -5
- package/dist/src/planner/analysis/sat-checker.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +17 -5
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +122 -79
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +73 -55
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/cost/index.d.ts +14 -0
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +19 -0
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +3 -2
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +31 -7
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/optimizer-tuning.d.ts +10 -6
- package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
- package/dist/src/planner/optimizer-tuning.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +24 -0
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js +8 -4
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts +14 -0
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +5 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts +3 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +8 -3
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.d.ts +47 -0
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.d.ts.map +1 -0
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.js +200 -0
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.js.map +1 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts +29 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +55 -16
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.d.ts +96 -22
- package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.js +401 -82
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts +20 -0
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +23 -4
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js +7 -0
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +19 -2
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.js +262 -40
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js +2 -1
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts +21 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +24 -6
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.d.ts +12 -12
- package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.js +3 -14
- package/dist/src/planner/rules/shared/access-leaf.js.map +1 -1
- package/dist/src/planner/stats/analyze.d.ts.map +1 -1
- package/dist/src/planner/stats/analyze.js +9 -3
- package/dist/src/planner/stats/analyze.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +6 -10
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/type-utils.d.ts.map +1 -1
- package/dist/src/planner/type-utils.js +3 -5
- package/dist/src/planner/type-utils.js.map +1 -1
- package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
- package/dist/src/planner/util/fd-utils.js +4 -7
- package/dist/src/planner/util/fd-utils.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +58 -4
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
- package/dist/src/runtime/emit/analyze.js +1 -2
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +5 -3
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/fanout-lookup-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/fanout-lookup-join.js +9 -1
- package/dist/src/runtime/emit/fanout-lookup-join.js.map +1 -1
- package/dist/src/runtime/emit/limit-offset.d.ts.map +1 -1
- package/dist/src/runtime/emit/limit-offset.js +50 -24
- package/dist/src/runtime/emit/limit-offset.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts +33 -2
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +61 -5
- package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view.js +6 -1
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/ordinal-slice.d.ts.map +1 -1
- package/dist/src/runtime/emit/ordinal-slice.js +8 -0
- package/dist/src/runtime/emit/ordinal-slice.js.map +1 -1
- package/dist/src/schema/derivation.d.ts +15 -1
- package/dist/src/schema/derivation.d.ts.map +1 -1
- package/dist/src/schema/derivation.js.map +1 -1
- package/dist/src/schema/function.d.ts +9 -4
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js +11 -9
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/schema.d.ts +14 -3
- package/dist/src/schema/schema.d.ts.map +1 -1
- package/dist/src/schema/schema.js +20 -2
- package/dist/src/schema/schema.js.map +1 -1
- package/dist/src/schema/table.d.ts +27 -0
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +55 -0
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +6 -13
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +8 -17
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/util/comparison.d.ts +19 -0
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +22 -0
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +34 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +64 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/index-descriptor.d.ts +9 -0
- package/dist/src/vtab/index-descriptor.d.ts.map +1 -1
- package/dist/src/vtab/index-descriptor.js +15 -0
- package/dist/src/vtab/index-descriptor.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +11 -9
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +12 -43
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +18 -0
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +176 -24
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +27 -3
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +28 -59
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,31 +1,45 @@
|
|
|
1
1
|
import { asRun } from '../types.js';
|
|
2
2
|
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
3
|
+
import { PlanNodeCharacteristics } from '../../planner/framework/characteristics.js';
|
|
4
|
+
/**
|
|
5
|
+
* Evaluate the LIMIT / OFFSET expressions and clamp them to a usable window.
|
|
6
|
+
*
|
|
7
|
+
* A missing LIMIT, a negative one, and a non-finite one (`null`, `NaN`) all clamp to zero
|
|
8
|
+
* rows, which is what `test/logic/94.1-limit-offset-edge-cases.sqllogic` and
|
|
9
|
+
* `104-emit-mutation-kills.sqllogic` pin today. Whether `limit null` should instead mean
|
|
10
|
+
* "no limit" is open — `backlog/bug-null-limit-returns-no-rows`.
|
|
11
|
+
*/
|
|
12
|
+
async function resolveWindow(ctx, limitFn, offsetFn) {
|
|
13
|
+
const limitValue = limitFn ? await limitFn(ctx) : null;
|
|
14
|
+
const offsetValue = offsetFn ? await offsetFn(ctx) : null;
|
|
15
|
+
const limit = limitValue !== null ? Number(limitValue) : Infinity;
|
|
16
|
+
const offset = offsetValue !== null ? Number(offsetValue) : 0;
|
|
17
|
+
return {
|
|
18
|
+
limit: limit < 0 || !Number.isFinite(limit) ? 0 : limit,
|
|
19
|
+
offset: offset < 0 || !Number.isFinite(offset) ? 0 : offset,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
3
22
|
export function emitLimitOffset(plan, ctx) {
|
|
23
|
+
// A LIMIT never truncates a writing source: a DML subtree under this node runs to
|
|
24
|
+
// completion even once the limit is reached, matching the full-drain rule the scalar
|
|
25
|
+
// / IN / EXISTS paths already apply (`emitExists`, `emitScalarSubquery`) and matching
|
|
26
|
+
// PostgreSQL's data-modifying CTEs. Pure sources take the early-stop path instead.
|
|
27
|
+
// One subtree test at emit time, not per row, so a LIMIT over a plain scan pays nothing.
|
|
28
|
+
const drainAfterLimit = PlanNodeCharacteristics.subtreeHasSideEffects(plan.source);
|
|
4
29
|
async function* run(ctx, sourceRows, ...args) {
|
|
5
|
-
//
|
|
6
|
-
let limitFn;
|
|
7
|
-
let offsetFn;
|
|
30
|
+
// Args arrive in declaration order, and either may be absent.
|
|
8
31
|
let argIndex = 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let limit = limitValue !== null ? Number(limitValue) : Infinity;
|
|
20
|
-
let offset = offsetValue !== null ? Number(offsetValue) : 0;
|
|
21
|
-
// Validate values
|
|
22
|
-
if (limit < 0 || !Number.isFinite(limit)) {
|
|
23
|
-
limit = 0; // No rows if limit is negative or invalid
|
|
32
|
+
const limitFn = plan.limit ? args[argIndex++] : undefined;
|
|
33
|
+
const offsetFn = plan.offset ? args[argIndex++] : undefined;
|
|
34
|
+
const { limit, offset } = await resolveWindow(ctx, limitFn, offsetFn);
|
|
35
|
+
// A zero (or clamped-to-zero) limit over a pure source must not touch the source at
|
|
36
|
+
// all, and this return is the ONLY thing that stops it: the loop below breaks only
|
|
37
|
+
// after a yield, so a zero limit that entered it would fall through to the drain
|
|
38
|
+
// branch and read the whole source. Pinned by the `LIMIT 0` case in
|
|
39
|
+
// `test/runtime/early-stop-consumption.spec.ts`.
|
|
40
|
+
if (limit <= 0 && !drainAfterLimit) {
|
|
41
|
+
return;
|
|
24
42
|
}
|
|
25
|
-
if (offset < 0 || !Number.isFinite(offset)) {
|
|
26
|
-
offset = 0; // No offset if negative or invalid
|
|
27
|
-
}
|
|
28
|
-
// Skip offset rows
|
|
29
43
|
let skipped = 0;
|
|
30
44
|
let emitted = 0;
|
|
31
45
|
for await (const row of sourceRows) {
|
|
@@ -34,10 +48,22 @@ export function emitLimitOffset(plan, ctx) {
|
|
|
34
48
|
continue;
|
|
35
49
|
}
|
|
36
50
|
if (emitted >= limit) {
|
|
37
|
-
|
|
51
|
+
// Only reachable while draining a side-effecting source: swallow the row so
|
|
52
|
+
// the write behind it still happens, but do not emit it.
|
|
53
|
+
// NOTE: the swallowed rows still travel the whole pipeline between the write
|
|
54
|
+
// and this node (projections, filters), so a `LIMIT 1` over a writing source
|
|
55
|
+
// pays for every row, not one. Correct and unavoidable while the write must
|
|
56
|
+
// complete; if an expensive projection over a large DML ever shows up as
|
|
57
|
+
// slow, push the drain down to the mutation node instead of draining here.
|
|
58
|
+
continue;
|
|
38
59
|
}
|
|
60
|
+
// Test the limit AFTER yielding, so the source is never asked for the row past
|
|
61
|
+
// the last one emitted. Testing at the top of the loop costs one extra pull on
|
|
62
|
+
// every limited query (see `ordinal-slice.ts` for the same shape).
|
|
39
63
|
yield row;
|
|
40
|
-
emitted
|
|
64
|
+
if (++emitted >= limit && !drainAfterLimit) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
41
67
|
}
|
|
42
68
|
}
|
|
43
69
|
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limit-offset.js","sourceRoot":"","sources":["../../../../src/runtime/emit/limit-offset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"limit-offset.js","sourceRoot":"","sources":["../../../../src/runtime/emit/limit-offset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAUrF;;;;;;;GAOG;AACH,KAAK,UAAU,aAAa,CAC3B,GAAmB,EACnB,OAAsE,EACtE,QAAuE;IAEvE,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE1D,MAAM,KAAK,GAAG,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ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AE,KAAK,CAAC,GAAG,CAAC;QACf,IAAI,EAAE,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG;KACvH,CAAC;AACH,CAAC"}
|
|
@@ -321,6 +321,27 @@ discardBackingOnFailure?: boolean): Promise<MaintainedTableSchema>;
|
|
|
321
321
|
* maintenance exactly like any source write.
|
|
322
322
|
*/
|
|
323
323
|
export declare function detachMaintainedDerivation(db: Database, mv: MaintainedTableSchema): TableSchema;
|
|
324
|
+
/**
|
|
325
|
+
* Reject a declared mutation-context variable on a maintained table. A maintained
|
|
326
|
+
* table's rows are derived by the engine — nobody ever writes to it directly — so no
|
|
327
|
+
* statement can ever carry a `with context` clause for one, and a declared variable
|
|
328
|
+
* could never receive a value. Left unrejected, the combination fails later and
|
|
329
|
+
* confusingly: the derived-row validator that compiles the table's declared CHECK /
|
|
330
|
+
* child-side-FK constraints registers no context symbols, so a bare-name read of the
|
|
331
|
+
* variable falls through to ordinary column resolution and raises "Column not found"
|
|
332
|
+
* from `planner/resolve.ts`.
|
|
333
|
+
*
|
|
334
|
+
* Rejects **any** declaration, not only one some constraint reads — the "declared but
|
|
335
|
+
* unread" case is harmless today, but that distinction is invisible to the author and
|
|
336
|
+
* would silently drift the moment a constraint is added; one rule is simpler to state
|
|
337
|
+
* and to document. Called from both authoring routes: {@link createMaintainedTable}
|
|
338
|
+
* (declared schema, before the table registers) and `runSetMaintained` in
|
|
339
|
+
* `alter-table.ts` (the live table, before {@link attachMaintainedDerivation}).
|
|
340
|
+
*/
|
|
341
|
+
export declare function assertNoMutationContextOnMaintainedTable(table: TableSchema, verb: 'create' | 'alter', loc?: {
|
|
342
|
+
line: number;
|
|
343
|
+
column: number;
|
|
344
|
+
}): void;
|
|
324
345
|
/**
|
|
325
346
|
* `create table … maintained as <body>` — the declared-shape authoring form,
|
|
326
347
|
* executed all-or-nothing:
|
|
@@ -523,8 +544,18 @@ export declare function referencedSourceColumns(db: Database, schemaName: string
|
|
|
523
544
|
* gating (`buildMaintenancePlan`) against the new catalog and throws on the
|
|
524
545
|
* create-time gates (non-determinism, bag/no-key floor, full-rebuild
|
|
525
546
|
* pathology against fresh ANALYZE stats — defensible: the alternative is
|
|
526
|
-
* unbounded per-write rebuild cost).
|
|
527
|
-
*
|
|
547
|
+
* unbounded per-write rebuild cost).
|
|
548
|
+
* 6. Body-function drift gate, inside that same registration: a body function
|
|
549
|
+
* now resolving to a different registration than the one that produced the
|
|
550
|
+
* backing's rows makes the recompiled plan disagree with the stored rows, so
|
|
551
|
+
* registration marks the MV stale itself (releasing the plan it just built)
|
|
552
|
+
* and reports it ⇒ decline. Distinct from every gate above in that the
|
|
553
|
+
* staleness has ALREADY been applied when this returns.
|
|
554
|
+
*
|
|
555
|
+
* Returns true iff the MV is LIVE afterwards — the caller relies on that to skip
|
|
556
|
+
* its own stale path. Every decline is idempotent with that path, so re-running it
|
|
557
|
+
* over an already-stale MV is a no-op re-assertion (gate 6's only cost is a second,
|
|
558
|
+
* identical backing-invalidation emit on a rare human-driven event).
|
|
528
559
|
*
|
|
529
560
|
* `oldObject`/`newObject` are the genuine event's distinct schemas. The synthetic
|
|
530
561
|
* backing-invalidation event (same object as old/new) is excluded by the caller's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialized-view-helpers.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/materialized-view-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAc,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE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umns
|
|
|
1038
1038
|
* untouched. An expressible plan splices around the verify-by-diff reconcile —
|
|
1039
1039
|
* see the sequencing notes inside.
|
|
1040
1040
|
*/
|
|
1041
|
+
// NOTE: this core does NOT re-assert {@link assertNoMutationContextOnMaintainedTable};
|
|
1042
|
+
// both of today's callers (createMaintainedTable, runSetMaintained) check before
|
|
1043
|
+
// calling. A third caller must run that guard too, or add it here.
|
|
1041
1044
|
export async function attachMaintainedDerivation(db, table, select, recordedColumns, positionalRename = false, allowReshape = false,
|
|
1042
1045
|
/**
|
|
1043
1046
|
* When true, a FAILED FRESH attach discards (via {@link VirtualTableModule.discardBackingForAttach})
|
|
@@ -1380,6 +1383,38 @@ export function detachMaintainedDerivation(db, mv) {
|
|
|
1380
1383
|
});
|
|
1381
1384
|
return plain;
|
|
1382
1385
|
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Reject a declared mutation-context variable on a maintained table. A maintained
|
|
1388
|
+
* table's rows are derived by the engine — nobody ever writes to it directly — so no
|
|
1389
|
+
* statement can ever carry a `with context` clause for one, and a declared variable
|
|
1390
|
+
* could never receive a value. Left unrejected, the combination fails later and
|
|
1391
|
+
* confusingly: the derived-row validator that compiles the table's declared CHECK /
|
|
1392
|
+
* child-side-FK constraints registers no context symbols, so a bare-name read of the
|
|
1393
|
+
* variable falls through to ordinary column resolution and raises "Column not found"
|
|
1394
|
+
* from `planner/resolve.ts`.
|
|
1395
|
+
*
|
|
1396
|
+
* Rejects **any** declaration, not only one some constraint reads — the "declared but
|
|
1397
|
+
* unread" case is harmless today, but that distinction is invisible to the author and
|
|
1398
|
+
* would silently drift the moment a constraint is added; one rule is simpler to state
|
|
1399
|
+
* and to document. Called from both authoring routes: {@link createMaintainedTable}
|
|
1400
|
+
* (declared schema, before the table registers) and `runSetMaintained` in
|
|
1401
|
+
* `alter-table.ts` (the live table, before {@link attachMaintainedDerivation}).
|
|
1402
|
+
*/
|
|
1403
|
+
export function assertNoMutationContextOnMaintainedTable(table, verb, loc) {
|
|
1404
|
+
const declared = table.mutationContext;
|
|
1405
|
+
if (!declared || declared.length === 0)
|
|
1406
|
+
return;
|
|
1407
|
+
const label = `${table.schemaName}.${table.name}`;
|
|
1408
|
+
const names = declared.map(v => v.name).join(', ');
|
|
1409
|
+
const message = verb === 'create'
|
|
1410
|
+
? `cannot create maintained table '${label}': a maintained table's rows are derived `
|
|
1411
|
+
+ `by the engine, so no statement can supply its mutation context variables (${names}); `
|
|
1412
|
+
+ `remove the 'with context' clause`
|
|
1413
|
+
: `cannot make table '${label}' maintained: it declares mutation context variables `
|
|
1414
|
+
+ `(${names}) that no statement can supply, because a maintained table's rows are `
|
|
1415
|
+
+ `derived by the engine`;
|
|
1416
|
+
throw new QuereusError(message, StatusCode.ERROR, undefined, loc?.line, loc?.column);
|
|
1417
|
+
}
|
|
1383
1418
|
/**
|
|
1384
1419
|
* `create table … maintained as <body>` — the declared-shape authoring form,
|
|
1385
1420
|
* executed all-or-nothing:
|
|
@@ -1426,6 +1461,7 @@ export async function createMaintainedTable(db, stmt) {
|
|
|
1426
1461
|
if (mismatch) {
|
|
1427
1462
|
throw new QuereusError(`cannot create maintained table '${schemaName}.${name}': ${mismatch}`, StatusCode.ERROR, undefined, stmt.table.loc?.start.line, stmt.table.loc?.start.column);
|
|
1428
1463
|
}
|
|
1464
|
+
assertNoMutationContextOnMaintainedTable(declared, 'create', stmt.table.loc?.start);
|
|
1429
1465
|
// `preferBacking = true`: route the create through the module's durable backing
|
|
1430
1466
|
// seam (`createBacking?() ?? create()`) so a durable-backing module (lamina)
|
|
1431
1467
|
// builds the basis `RowStore` that `resolveBackingHost` → `getBackingHost`
|
|
@@ -1978,8 +2014,18 @@ function expandGeneratedDependencyClosure(cols, deps) {
|
|
|
1978
2014
|
* gating (`buildMaintenancePlan`) against the new catalog and throws on the
|
|
1979
2015
|
* create-time gates (non-determinism, bag/no-key floor, full-rebuild
|
|
1980
2016
|
* pathology against fresh ANALYZE stats — defensible: the alternative is
|
|
1981
|
-
* unbounded per-write rebuild cost).
|
|
1982
|
-
*
|
|
2017
|
+
* unbounded per-write rebuild cost).
|
|
2018
|
+
* 6. Body-function drift gate, inside that same registration: a body function
|
|
2019
|
+
* now resolving to a different registration than the one that produced the
|
|
2020
|
+
* backing's rows makes the recompiled plan disagree with the stored rows, so
|
|
2021
|
+
* registration marks the MV stale itself (releasing the plan it just built)
|
|
2022
|
+
* and reports it ⇒ decline. Distinct from every gate above in that the
|
|
2023
|
+
* staleness has ALREADY been applied when this returns.
|
|
2024
|
+
*
|
|
2025
|
+
* Returns true iff the MV is LIVE afterwards — the caller relies on that to skip
|
|
2026
|
+
* its own stale path. Every decline is idempotent with that path, so re-running it
|
|
2027
|
+
* over an already-stale MV is a no-op re-assertion (gate 6's only cost is a second,
|
|
2028
|
+
* identical backing-invalidation emit on a rare human-driven event).
|
|
1983
2029
|
*
|
|
1984
2030
|
* `oldObject`/`newObject` are the genuine event's distinct schemas. The synthetic
|
|
1985
2031
|
* backing-invalidation event (same object as old/new) is excluded by the caller's
|
|
@@ -2046,7 +2092,11 @@ export function tryRecompileMaterializedViewLive(db, mv, oldObject, newObject) {
|
|
|
2046
2092
|
}
|
|
2047
2093
|
log('Recompiling materialized view %s.%s after a value-semantics ALTER (type/collation) on column(s) the body does not read (%s)', mv.schemaName, mv.name, [...valueChanged].join(', '));
|
|
2048
2094
|
}
|
|
2049
|
-
|
|
2095
|
+
// Body-function drift gate: registration already marked the MV stale and released
|
|
2096
|
+
// the plan it had just built, so there is nothing left to keep live. Decline, so
|
|
2097
|
+
// the caller's stale path re-asserts the same state and no log claims a live view.
|
|
2098
|
+
if (db.registerMaterializedView(backing))
|
|
2099
|
+
return false;
|
|
2050
2100
|
log('Recompiled materialized view %s.%s in place after a genuine source change', mv.schemaName, mv.name);
|
|
2051
2101
|
return true;
|
|
2052
2102
|
}
|
|
@@ -2797,8 +2847,14 @@ async function restoreMaterializedViewLive(db, schema, mv, backingNames) {
|
|
|
2797
2847
|
// Register the LIVE registered table (the backing-name pass may have swapped
|
|
2798
2848
|
// the catalog object); the shared derivation rides either way.
|
|
2799
2849
|
const live = schema.getTable(mv.name);
|
|
2800
|
-
|
|
2801
|
-
|
|
2850
|
+
// Body-function drift outranks this restore: registration found a body function now
|
|
2851
|
+
// resolving to a different registration than the one that produced the backing's rows,
|
|
2852
|
+
// and marked the MV stale. This pass restores views the RENAME did not affect — it says
|
|
2853
|
+
// nothing about whether the stored rows are still a faithful derivation, and only
|
|
2854
|
+
// REFRESH re-derives them. Leave the flag alone in that case.
|
|
2855
|
+
const drifted = db.registerMaterializedView(isMaintainedTable(live) ? live : mv);
|
|
2856
|
+
if (!drifted)
|
|
2857
|
+
mv.derivation.stale = false;
|
|
2802
2858
|
}
|
|
2803
2859
|
/**
|
|
2804
2860
|
* Restores every dependent MV that THIS rename statement marked stale but the
|