@quereus/quereus 4.3.1 → 4.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 +25 -7
- package/dist/src/common/types.d.ts +9 -59
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/common/types.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts +2 -2
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +4 -3
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-external-changes.d.ts +3 -3
- package/dist/src/core/database-external-changes.d.ts.map +1 -1
- package/dist/src/core/database-external-changes.js +13 -10
- package/dist/src/core/database-external-changes.js.map +1 -1
- package/dist/src/core/database-internal.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.d.ts +199 -0
- package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -0
- package/dist/src/core/database-materialized-views-analysis.js +502 -0
- package/dist/src/core/database-materialized-views-analysis.js.map +1 -0
- package/dist/src/core/database-materialized-views-apply.d.ts +422 -0
- package/dist/src/core/database-materialized-views-apply.d.ts.map +1 -0
- package/dist/src/core/database-materialized-views-apply.js +929 -0
- package/dist/src/core/database-materialized-views-apply.js.map +1 -0
- package/dist/src/core/database-materialized-views-plan-builders.d.ts +267 -0
- package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -0
- package/dist/src/core/database-materialized-views-plan-builders.js +1423 -0
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -0
- package/dist/src/core/database-materialized-views-plans.d.ts +641 -0
- package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -0
- package/dist/src/core/database-materialized-views-plans.js +13 -0
- package/dist/src/core/database-materialized-views-plans.js.map +1 -0
- package/dist/src/core/database-materialized-views.d.ts +108 -860
- package/dist/src/core/database-materialized-views.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.js +212 -2165
- package/dist/src/core/database-materialized-views.js.map +1 -1
- package/dist/src/core/database-transaction.d.ts +10 -1
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +16 -4
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database-watchers.d.ts.map +1 -1
- package/dist/src/core/database-watchers.js +2 -1
- package/dist/src/core/database-watchers.js.map +1 -1
- package/dist/src/core/database.d.ts +99 -13
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +270 -50
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/derived-row-validator.d.ts +1 -1
- package/dist/src/core/derived-row-validator.d.ts.map +1 -1
- package/dist/src/core/derived-row-validator.js +5 -3
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/statement.d.ts +8 -0
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +98 -18
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/emit/ast-stringify.d.ts.map +1 -1
- package/dist/src/emit/ast-stringify.js +24 -13
- package/dist/src/emit/ast-stringify.js.map +1 -1
- package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
- package/dist/src/func/builtins/aggregate.js +127 -21
- package/dist/src/func/builtins/aggregate.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +2 -1
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json.d.ts.map +1 -1
- package/dist/src/func/builtins/json.js +2 -1
- package/dist/src/func/builtins/json.js.map +1 -1
- package/dist/src/func/builtins/mutation.d.ts.map +1 -1
- package/dist/src/func/builtins/mutation.js +3 -2
- package/dist/src/func/builtins/mutation.js.map +1 -1
- package/dist/src/func/registration.d.ts +6 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +16 -0
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +16 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +33 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/ast.d.ts +2 -2
- package/dist/src/parser/lexer.d.ts +11 -1
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +40 -34
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +16 -9
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/analysis/authored-inverse.js +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +52 -0
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +84 -7
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +64 -17
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +26 -0
- package/dist/src/planner/analysis/equi-correlation.d.ts.map +1 -0
- package/dist/src/planner/analysis/equi-correlation.js +62 -0
- package/dist/src/planner/analysis/equi-correlation.js.map +1 -0
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +54 -18
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.js +86 -42
- package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
- package/dist/src/planner/analysis/sat-checker.d.ts +8 -1
- package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -1
- package/dist/src/planner/analysis/sat-checker.js +117 -22
- package/dist/src/planner/analysis/sat-checker.js.map +1 -1
- package/dist/src/planner/analysis/scalar-invertibility.d.ts +13 -4
- package/dist/src/planner/analysis/scalar-invertibility.d.ts.map +1 -1
- package/dist/src/planner/analysis/scalar-invertibility.js +12 -3
- package/dist/src/planner/analysis/scalar-invertibility.js.map +1 -1
- package/dist/src/planner/analysis/scalar-subqueries.d.ts +28 -0
- package/dist/src/planner/analysis/scalar-subqueries.d.ts.map +1 -0
- package/dist/src/planner/analysis/scalar-subqueries.js +60 -0
- package/dist/src/planner/analysis/scalar-subqueries.js.map +1 -0
- package/dist/src/planner/analysis/update-lineage.d.ts +1 -1
- package/dist/src/planner/analysis/update-lineage.js +1 -1
- package/dist/src/planner/analysis/update-lineage.js.map +1 -1
- package/dist/src/planner/analysis/view-complement.d.ts +2 -2
- package/dist/src/planner/building/delete.js +2 -2
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/dml-target.d.ts +2 -2
- package/dist/src/planner/building/dml-target.js +2 -2
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +53 -2
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/schema-resolution.d.ts +3 -0
- package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
- package/dist/src/planner/building/schema-resolution.js +4 -5
- package/dist/src/planner/building/schema-resolution.js.map +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +18 -4
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/update.js +2 -2
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +7 -7
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +5 -8
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.d.ts +34 -2
- package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.js +185 -42
- package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
- package/dist/src/planner/cache/reference-graph.d.ts +14 -5
- package/dist/src/planner/cache/reference-graph.d.ts.map +1 -1
- package/dist/src/planner/cache/reference-graph.js +31 -39
- package/dist/src/planner/cache/reference-graph.js.map +1 -1
- package/dist/src/planner/cost/index.d.ts +30 -5
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +26 -0
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/debug.d.ts +3 -2
- package/dist/src/planner/debug.d.ts.map +1 -1
- package/dist/src/planner/debug.js +9 -3
- package/dist/src/planner/debug.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +46 -19
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/characteristics.js +50 -134
- package/dist/src/planner/framework/characteristics.js.map +1 -1
- package/dist/src/planner/framework/context.d.ts +8 -44
- package/dist/src/planner/framework/context.d.ts.map +1 -1
- package/dist/src/planner/framework/context.js +0 -91
- package/dist/src/planner/framework/context.js.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +7 -0
- package/dist/src/planner/framework/pass.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.js +84 -0
- package/dist/src/planner/framework/pass.js.map +1 -1
- package/dist/src/planner/framework/registry.d.ts +13 -42
- package/dist/src/planner/framework/registry.d.ts.map +1 -1
- package/dist/src/planner/framework/registry.js +14 -182
- package/dist/src/planner/framework/registry.js.map +1 -1
- package/dist/src/planner/mutation/backward-body.d.ts +2 -2
- package/dist/src/planner/mutation/cte-flatten.js +1 -1
- package/dist/src/planner/mutation/decomposition.d.ts +2 -2
- package/dist/src/planner/mutation/decomposition.js +1 -1
- package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +2 -1
- package/dist/src/planner/mutation/lens-enforcement.js.map +1 -1
- package/dist/src/planner/mutation/multi-source.d.ts +8 -8
- package/dist/src/planner/mutation/multi-source.js +11 -11
- package/dist/src/planner/mutation/multi-source.js.map +1 -1
- package/dist/src/planner/mutation/propagate.d.ts +1 -1
- package/dist/src/planner/mutation/propagate.js +1 -1
- package/dist/src/planner/mutation/scope-transform.d.ts +2 -2
- package/dist/src/planner/mutation/scope-transform.js +3 -3
- package/dist/src/planner/mutation/scope-transform.js.map +1 -1
- package/dist/src/planner/mutation/set-op.d.ts +1 -1
- package/dist/src/planner/mutation/set-op.d.ts.map +1 -1
- package/dist/src/planner/mutation/set-op.js +3 -2
- package/dist/src/planner/mutation/set-op.js.map +1 -1
- package/dist/src/planner/mutation/single-source.d.ts +3 -3
- package/dist/src/planner/mutation/single-source.js +9 -9
- package/dist/src/planner/mutation/single-source.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-function.d.ts +3 -1
- package/dist/src/planner/nodes/aggregate-function.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-function.js +1 -0
- package/dist/src/planner/nodes/aggregate-function.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts +1 -0
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +8 -1
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alias-node.js +3 -1
- package/dist/src/planner/nodes/alias-node.js.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.js +3 -2
- package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.d.ts +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.js +5 -2
- package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
- package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/async-gather-node.js +3 -1
- package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
- package/dist/src/planner/nodes/block.js +3 -3
- package/dist/src/planner/nodes/block.js.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.d.ts +2 -0
- package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.js +5 -1
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/cache-node.d.ts +19 -2
- package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cache-node.js +43 -3
- package/dist/src/planner/nodes/cache-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +16 -1
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +16 -3
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/distinct-node.js +3 -3
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +21 -0
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/planner/nodes/envelope-scan-node.d.ts +1 -1
- package/dist/src/planner/nodes/envelope-scan-node.js +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.js +4 -2
- package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts +10 -2
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +81 -14
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +12 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +28 -1
- package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts +3 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js +1 -0
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts +3 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +5 -5
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js +4 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts +1 -0
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +4 -3
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.d.ts +2 -0
- package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.js +6 -1
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.js +3 -1
- package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +68 -5
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +137 -24
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/project-node.d.ts +3 -2
- package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +1 -0
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.d.ts +30 -1
- package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.js +38 -5
- package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts +5 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +3 -0
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/remote-query-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/remote-query-node.js +3 -1
- package/dist/src/planner/nodes/remote-query-node.js.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.js +3 -1
- package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.js +3 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/sink-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/sink-node.js +3 -1
- package/dist/src/planner/nodes/sink-node.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts +2 -1
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +9 -5
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +12 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +32 -3
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +2 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +2 -0
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts +2 -2
- package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.js +5 -1
- package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
- package/dist/src/planner/nodes/window-function.d.ts +3 -1
- package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-function.js +1 -0
- package/dist/src/planner/nodes/window-function.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts +52 -8
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +1014 -895
- package/dist/src/planner/optimizer.js.map +1 -1
- 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 +235 -202
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js +8 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts +7 -0
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js +14 -1
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts +2 -2
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +55 -56
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js +6 -0
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts +25 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +176 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -0
- package/dist/src/planner/rules/cache/rule-scalar-cse.d.ts +1 -1
- package/dist/src/planner/rules/cache/rule-scalar-cse.js +1 -1
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts +29 -0
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts.map +1 -0
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js +66 -0
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js.map +1 -0
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts +1 -1
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +1 -54
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.d.ts +1 -1
- package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.js +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.js +1 -1
- package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js +5 -6
- package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +1 -1
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts +2 -2
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.js +4 -3
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +19 -0
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +48 -0
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js +12 -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.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +22 -20
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/shared/index-style-context.d.ts +39 -0
- package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -0
- package/dist/src/planner/rules/shared/index-style-context.js +26 -0
- package/dist/src/planner/rules/shared/index-style-context.js.map +1 -0
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts +1 -1
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js +1 -1
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts +1 -1
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +1 -1
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.d.ts +191 -0
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.d.ts.map +1 -0
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js +623 -0
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +10 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +242 -51
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
- package/dist/src/planner/stats/analyze.d.ts.map +1 -1
- package/dist/src/planner/stats/analyze.js +2 -20
- package/dist/src/planner/stats/analyze.js.map +1 -1
- package/dist/src/planner/stats/histogram.d.ts.map +1 -1
- package/dist/src/planner/stats/histogram.js +4 -0
- package/dist/src/planner/stats/histogram.js.map +1 -1
- package/dist/src/planner/util/fd-utils.d.ts +2 -3
- package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
- package/dist/src/planner/util/fd-utils.js +2 -3
- package/dist/src/planner/util/fd-utils.js.map +1 -1
- package/dist/src/planner/validation/plan-validator.d.ts +16 -0
- package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
- package/dist/src/planner/validation/plan-validator.js +36 -0
- package/dist/src/planner/validation/plan-validator.js.map +1 -1
- package/dist/src/runtime/async-util.d.ts +26 -0
- package/dist/src/runtime/async-util.d.ts.map +1 -1
- package/dist/src/runtime/async-util.js +139 -55
- package/dist/src/runtime/async-util.js.map +1 -1
- package/dist/src/runtime/cache/shared-cache.d.ts +7 -0
- package/dist/src/runtime/cache/shared-cache.d.ts.map +1 -1
- package/dist/src/runtime/cache/shared-cache.js +34 -1
- package/dist/src/runtime/cache/shared-cache.js.map +1 -1
- package/dist/src/runtime/context-helpers.d.ts +32 -4
- package/dist/src/runtime/context-helpers.d.ts.map +1 -1
- package/dist/src/runtime/context-helpers.js +26 -9
- package/dist/src/runtime/context-helpers.js.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.js +2 -1
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
- package/dist/src/runtime/emission-context.d.ts +27 -3
- package/dist/src/runtime/emission-context.d.ts.map +1 -1
- package/dist/src/runtime/emission-context.js +38 -7
- package/dist/src/runtime/emission-context.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +7 -1
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/aggregate.d.ts +2 -3
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +23 -28
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +98 -9
- 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 +2 -1
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/asof-scan.js +13 -10
- package/dist/src/runtime/emit/asof-scan.js.map +1 -1
- package/dist/src/runtime/emit/async-gather.d.ts.map +1 -1
- package/dist/src/runtime/emit/async-gather.js +4 -3
- package/dist/src/runtime/emit/async-gather.js.map +1 -1
- package/dist/src/runtime/emit/between.d.ts.map +1 -1
- package/dist/src/runtime/emit/between.js +2 -1
- package/dist/src/runtime/emit/between.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +122 -14
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/block.d.ts.map +1 -1
- package/dist/src/runtime/emit/block.js +2 -1
- package/dist/src/runtime/emit/block.js.map +1 -1
- package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/bloom-join.js +20 -8
- package/dist/src/runtime/emit/bloom-join.js.map +1 -1
- package/dist/src/runtime/emit/cache.d.ts +7 -3
- package/dist/src/runtime/emit/cache.d.ts.map +1 -1
- package/dist/src/runtime/emit/cache.js +25 -7
- package/dist/src/runtime/emit/cache.js.map +1 -1
- package/dist/src/runtime/emit/case.d.ts.map +1 -1
- package/dist/src/runtime/emit/case.js +66 -45
- package/dist/src/runtime/emit/case.js.map +1 -1
- package/dist/src/runtime/emit/cast.d.ts.map +1 -1
- package/dist/src/runtime/emit/cast.js +2 -1
- package/dist/src/runtime/emit/cast.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +13 -7
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-assertion.js +2 -1
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-index.js +12 -1
- package/dist/src/runtime/emit/create-index.js.map +1 -1
- package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-table.js +12 -1
- package/dist/src/runtime/emit/create-table.js.map +1 -1
- package/dist/src/runtime/emit/cte-reference.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte-reference.js +2 -1
- package/dist/src/runtime/emit/cte-reference.js.map +1 -1
- package/dist/src/runtime/emit/cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte.js +45 -21
- package/dist/src/runtime/emit/cte.js.map +1 -1
- package/dist/src/runtime/emit/ddl-transaction-policy.d.ts +50 -0
- package/dist/src/runtime/emit/ddl-transaction-policy.d.ts.map +1 -0
- package/dist/src/runtime/emit/ddl-transaction-policy.js +69 -0
- package/dist/src/runtime/emit/ddl-transaction-policy.js.map +1 -0
- package/dist/src/runtime/emit/delete.d.ts.map +1 -1
- package/dist/src/runtime/emit/delete.js +2 -1
- package/dist/src/runtime/emit/delete.js.map +1 -1
- package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
- package/dist/src/runtime/emit/distinct.js +2 -1
- package/dist/src/runtime/emit/distinct.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +138 -74
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +2 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +17 -1
- package/dist/src/runtime/emit/drop-index.js.map +1 -1
- package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-table.js +11 -1
- package/dist/src/runtime/emit/drop-table.js.map +1 -1
- package/dist/src/runtime/emit/eager-prefetch.d.ts.map +1 -1
- package/dist/src/runtime/emit/eager-prefetch.js +2 -1
- package/dist/src/runtime/emit/eager-prefetch.js.map +1 -1
- package/dist/src/runtime/emit/envelope-scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/envelope-scan.js +2 -1
- package/dist/src/runtime/emit/envelope-scan.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 +3 -2
- package/dist/src/runtime/emit/fanout-lookup-join.js.map +1 -1
- package/dist/src/runtime/emit/filter.d.ts.map +1 -1
- package/dist/src/runtime/emit/filter.js +8 -3
- package/dist/src/runtime/emit/filter.js.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.js +16 -11
- package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
- package/dist/src/runtime/emit/insert.d.ts.map +1 -1
- package/dist/src/runtime/emit/insert.js +2 -1
- package/dist/src/runtime/emit/insert.js.map +1 -1
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +20 -6
- package/dist/src/runtime/emit/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 +2 -1
- package/dist/src/runtime/emit/limit-offset.js.map +1 -1
- package/dist/src/runtime/emit/literal.d.ts.map +1 -1
- package/dist/src/runtime/emit/literal.js +2 -1
- package/dist/src/runtime/emit/literal.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts +22 -0
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +128 -16
- 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 -0
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/merge-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/merge-join.js +14 -4
- package/dist/src/runtime/emit/merge-join.js.map +1 -1
- package/dist/src/runtime/emit/ordinal-slice.d.ts.map +1 -1
- package/dist/src/runtime/emit/ordinal-slice.js +2 -1
- package/dist/src/runtime/emit/ordinal-slice.js.map +1 -1
- package/dist/src/runtime/emit/pragma.d.ts.map +1 -1
- package/dist/src/runtime/emit/pragma.js +2 -1
- package/dist/src/runtime/emit/pragma.js.map +1 -1
- package/dist/src/runtime/emit/project.d.ts.map +1 -1
- package/dist/src/runtime/emit/project.js +7 -2
- package/dist/src/runtime/emit/project.js.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.js +61 -2
- package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
- package/dist/src/runtime/emit/returning.d.ts.map +1 -1
- package/dist/src/runtime/emit/returning.js +7 -2
- package/dist/src/runtime/emit/returning.js.map +1 -1
- package/dist/src/runtime/emit/scalar-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/scalar-function.js +2 -1
- package/dist/src/runtime/emit/scalar-function.js.map +1 -1
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +55 -17
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +6 -5
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/sequencing.d.ts.map +1 -1
- package/dist/src/runtime/emit/sequencing.js +2 -1
- package/dist/src/runtime/emit/sequencing.js.map +1 -1
- package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-operation.js +6 -5
- package/dist/src/runtime/emit/set-operation.js.map +1 -1
- package/dist/src/runtime/emit/sink.d.ts.map +1 -1
- package/dist/src/runtime/emit/sink.js +2 -1
- package/dist/src/runtime/emit/sink.js.map +1 -1
- package/dist/src/runtime/emit/sort.d.ts.map +1 -1
- package/dist/src/runtime/emit/sort.js +2 -1
- package/dist/src/runtime/emit/sort.js.map +1 -1
- package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
- package/dist/src/runtime/emit/subquery.js +42 -23
- package/dist/src/runtime/emit/subquery.js.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.js +2 -1
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/temporal-arithmetic.d.ts.map +1 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js +2 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +1 -1
- package/dist/src/runtime/emit/transaction.d.ts.map +1 -1
- package/dist/src/runtime/emit/transaction.js +2 -1
- package/dist/src/runtime/emit/transaction.js.map +1 -1
- package/dist/src/runtime/emit/unary.d.ts.map +1 -1
- package/dist/src/runtime/emit/unary.js +2 -1
- package/dist/src/runtime/emit/unary.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +2 -1
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/values.d.ts.map +1 -1
- package/dist/src/runtime/emit/values.js +2 -1
- package/dist/src/runtime/emit/values.js.map +1 -1
- package/dist/src/runtime/emit/view-mutation.d.ts +1 -1
- package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
- package/dist/src/runtime/emit/view-mutation.js +6 -3
- package/dist/src/runtime/emit/view-mutation.js.map +1 -1
- package/dist/src/runtime/emit/window.d.ts.map +1 -1
- package/dist/src/runtime/emit/window.js +26 -9
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/emitters.d.ts +11 -3
- package/dist/src/runtime/emitters.d.ts.map +1 -1
- package/dist/src/runtime/emitters.js +13 -22
- package/dist/src/runtime/emitters.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +39 -13
- package/dist/src/runtime/foreign-key-actions.js.map +1 -1
- package/dist/src/runtime/parallel-driver.d.ts +32 -4
- package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
- package/dist/src/runtime/parallel-driver.js +88 -18
- package/dist/src/runtime/parallel-driver.js.map +1 -1
- package/dist/src/runtime/scheduler.d.ts +56 -7
- package/dist/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/src/runtime/scheduler.js +223 -200
- package/dist/src/runtime/scheduler.js.map +1 -1
- package/dist/src/runtime/strict-flags.d.ts +22 -0
- package/dist/src/runtime/strict-flags.d.ts.map +1 -0
- package/dist/src/runtime/strict-flags.js +26 -0
- package/dist/src/runtime/strict-flags.js.map +1 -0
- package/dist/src/runtime/strict-fork.d.ts +4 -4
- package/dist/src/runtime/strict-fork.d.ts.map +1 -1
- package/dist/src/runtime/strict-fork.js +175 -31
- package/dist/src/runtime/strict-fork.js.map +1 -1
- package/dist/src/runtime/types.d.ts +102 -4
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js +37 -0
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/runtime/utils.d.ts.map +1 -1
- package/dist/src/runtime/utils.js +8 -17
- package/dist/src/runtime/utils.js.map +1 -1
- package/dist/src/schema/column.d.ts +8 -0
- package/dist/src/schema/column.d.ts.map +1 -1
- package/dist/src/schema/column.js.map +1 -1
- package/dist/src/schema/ddl-generator.js +5 -0
- package/dist/src/schema/ddl-generator.js.map +1 -1
- package/dist/src/schema/function.d.ts +79 -0
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/lens-compiler.js +2 -2
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +2 -3
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/lens.d.ts +1 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +7 -2
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +61 -0
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +77 -0
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/table.d.ts +36 -8
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +61 -11
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +28 -5
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +37 -5
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/schema/view.d.ts +1 -1
- package/dist/src/schema/view.js +1 -1
- package/dist/src/types/json-type.d.ts.map +1 -1
- package/dist/src/types/json-type.js +18 -8
- package/dist/src/types/json-type.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +26 -0
- package/dist/src/types/logical-type.d.ts.map +1 -1
- package/dist/src/types/logical-type.js.map +1 -1
- package/dist/src/util/comparison.d.ts +83 -59
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +191 -131
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/util/json-canonical.d.ts +34 -0
- package/dist/src/util/json-canonical.d.ts.map +1 -0
- package/dist/src/util/json-canonical.js +32 -0
- package/dist/src/util/json-canonical.js.map +1 -0
- package/dist/src/util/key-serializer.d.ts +10 -3
- package/dist/src/util/key-serializer.d.ts.map +1 -1
- package/dist/src/util/key-serializer.js +43 -17
- package/dist/src/util/key-serializer.js.map +1 -1
- package/dist/src/util/key-tuple-codec.d.ts +37 -0
- package/dist/src/util/key-tuple-codec.d.ts.map +1 -0
- package/dist/src/util/key-tuple-codec.js +65 -0
- package/dist/src/util/key-tuple-codec.js.map +1 -0
- package/dist/src/util/latches.d.ts +29 -3
- package/dist/src/util/latches.d.ts.map +1 -1
- package/dist/src/util/latches.js +60 -6
- package/dist/src/util/latches.js.map +1 -1
- package/dist/src/util/patterns.d.ts +22 -8
- package/dist/src/util/patterns.d.ts.map +1 -1
- package/dist/src/util/patterns.js +87 -16
- package/dist/src/util/patterns.js.map +1 -1
- package/dist/src/util/qualified-name.d.ts +10 -0
- package/dist/src/util/qualified-name.d.ts.map +1 -0
- package/dist/src/util/qualified-name.js +15 -0
- package/dist/src/util/qualified-name.js.map +1 -0
- package/dist/src/vtab/backing-host.d.ts +8 -1
- package/dist/src/vtab/backing-host.d.ts.map +1 -1
- package/dist/src/vtab/backing-host.js +7 -0
- package/dist/src/vtab/backing-host.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +18 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +15 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/capabilities.d.ts +44 -0
- package/dist/src/vtab/capabilities.d.ts.map +1 -1
- package/dist/src/vtab/filter-info.d.ts +42 -0
- package/dist/src/vtab/filter-info.d.ts.map +1 -1
- package/dist/src/vtab/filter-info.js +137 -1
- package/dist/src/vtab/filter-info.js.map +1 -1
- package/dist/src/vtab/idx-str.d.ts +62 -0
- package/dist/src/vtab/idx-str.d.ts.map +1 -0
- package/dist/src/vtab/idx-str.js +130 -0
- package/dist/src/vtab/idx-str.js.map +1 -0
- package/dist/src/vtab/index-descriptor.d.ts +122 -0
- package/dist/src/vtab/index-descriptor.d.ts.map +1 -0
- package/dist/src/vtab/index-descriptor.js +104 -0
- package/dist/src/vtab/index-descriptor.js.map +1 -0
- package/dist/src/vtab/mapping-advertisement.d.ts +1 -1
- package/dist/src/vtab/memory/index.d.ts +12 -4
- package/dist/src/vtab/memory/index.d.ts.map +1 -1
- package/dist/src/vtab/memory/index.js +17 -9
- package/dist/src/vtab/memory/index.js.map +1 -1
- package/dist/src/vtab/memory/layer/base.d.ts +85 -31
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +127 -86
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/connection.d.ts +27 -0
- package/dist/src/vtab/memory/layer/connection.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/connection.js +36 -1
- package/dist/src/vtab/memory/layer/connection.js.map +1 -1
- package/dist/src/vtab/memory/layer/interface.d.ts +24 -4
- package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +212 -16
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +754 -170
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/plan-filter.d.ts +26 -1
- package/dist/src/vtab/memory/layer/plan-filter.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/plan-filter.js +29 -11
- package/dist/src/vtab/memory/layer/plan-filter.js.map +1 -1
- package/dist/src/vtab/memory/layer/safe-iterate.d.ts +2 -2
- package/dist/src/vtab/memory/layer/safe-iterate.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js +2 -2
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.d.ts +5 -1
- package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.js +59 -24
- package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-plan.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-plan.js +13 -21
- package/dist/src/vtab/memory/layer/scan-plan.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +169 -7
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +334 -9
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +11 -4
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +35 -16
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +30 -4
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +63 -15
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/memory/utils/predicate.d.ts +9 -1
- package/dist/src/vtab/memory/utils/predicate.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/predicate.js +35 -14
- package/dist/src/vtab/memory/utils/predicate.js.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key-encode.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key-encode.js +12 -6
- package/dist/src/vtab/memory/utils/primary-key-encode.js.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key.d.ts +6 -1
- package/dist/src/vtab/memory/utils/primary-key.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key.js +12 -8
- package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
- package/dist/src/vtab/module.d.ts +38 -14
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +41 -2
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js +19 -0
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +5 -4
- package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts +0 -18
- package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts.map +0 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js +0 -65
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Materialized-view maintenance — plan types and the manager's decoupling context.
|
|
3
|
+
*
|
|
4
|
+
* The tagged {@link MaintenancePlan} union (one arm per maintenance strategy) plus the
|
|
5
|
+
* shared plan shapes, the per-column {@link BackingProjector}, the coarsening-collision
|
|
6
|
+
* watch column, the per-statement {@link BackingConnectionCache}, and the
|
|
7
|
+
* {@link MaterializedViewManagerContext} the manager runs against. Split out of
|
|
8
|
+
* `database-materialized-views.ts` (its class + orchestration) so the type surface reads
|
|
9
|
+
* on its own; see that file and `docs/mv-maintenance.md` for how each arm is built and
|
|
10
|
+
* applied.
|
|
11
|
+
*/
|
|
12
|
+
import type { SchemaManager } from '../schema/manager.js';
|
|
13
|
+
import type { SqlValue, Row } from '../common/types.js';
|
|
14
|
+
import type { CollationFunction, CollationResolver } from '../types/logical-type.js';
|
|
15
|
+
import type { PrimaryKeyColumnDefinition } from '../schema/table.js';
|
|
16
|
+
import type { BTreeKeyForPrimary } from '../vtab/memory/types.js';
|
|
17
|
+
import { Scheduler } from '../runtime/scheduler.js';
|
|
18
|
+
import type { BindingMode } from '../planner/analysis/binding-extractor.js';
|
|
19
|
+
import type { MaintenanceSourceStats, MaintenanceStrategy } from '../planner/cost/index.js';
|
|
20
|
+
import type { AggregateAlgebra, AggregateFunctionSchema } from '../schema/function.js';
|
|
21
|
+
import type { AggValue } from '../func/registration.js';
|
|
22
|
+
import type { DerivedRowConstraintValidator } from './derived-row-validator.js';
|
|
23
|
+
import type { MaintainedTableSchema } from '../schema/derivation.js';
|
|
24
|
+
import type { VirtualTableConnection } from '../vtab/connection.js';
|
|
25
|
+
import type { CompiledPredicate } from '../vtab/memory/utils/predicate.js';
|
|
26
|
+
import type { Database } from './database.js';
|
|
27
|
+
import type { DatabaseEventEmitter } from './database-events.js';
|
|
28
|
+
import type * as AST from '../parser/ast.js';
|
|
29
|
+
/**
|
|
30
|
+
* Database internals the materialized-view manager needs. Mirrors
|
|
31
|
+
* `AssertionEvaluatorContext` / `WatcherManagerContext` — keeps the manager
|
|
32
|
+
* decoupled from the full `Database`.
|
|
33
|
+
*/
|
|
34
|
+
export interface MaterializedViewManagerContext {
|
|
35
|
+
readonly schemaManager: SchemaManager;
|
|
36
|
+
readonly optimizer: Database['optimizer'];
|
|
37
|
+
/** Database event emitter — the row-time collision telemetry channel
|
|
38
|
+
* ({@link MaterializedViewManager.detectAndReportCoarseningCollisions}) queues
|
|
39
|
+
* {@link MaintenanceCollisionEvent}s here. Already exposed for the transaction
|
|
40
|
+
* manager; reused narrowly. */
|
|
41
|
+
getEventEmitter(): DatabaseEventEmitter;
|
|
42
|
+
/** Name→function collation lookup against the owning database's registry (throws on an
|
|
43
|
+
* unregistered name). Every collation-aware comparison the manager makes — key identity,
|
|
44
|
+
* UNIQUE self-conflict, coarsening-collision divergence — resolves through this, so a
|
|
45
|
+
* collation registered with `db.registerCollation(...)` is honored instead of silently
|
|
46
|
+
* degrading to byte comparison. */
|
|
47
|
+
getCollationResolver(): CollationResolver;
|
|
48
|
+
_buildPlan(statements: AST.Statement[]): import('./database.js').BuildPlanResult;
|
|
49
|
+
_findTable(tableName: string, schemaName?: string): ReturnType<Database['_findTable']>;
|
|
50
|
+
/** Backing-connection resolution for row-time write-through (see {@link MaterializedViewManager.getBackingConnection}). */
|
|
51
|
+
getConnectionsForTable(tableName: string): VirtualTableConnection[];
|
|
52
|
+
registerConnection(connection: VirtualTableConnection): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A compiled per-MV maintenance plan — how {@link MaterializedViewManager.applyMaintenancePlan}
|
|
56
|
+
* keeps an MV's backing table consistent with a source row-write. A tagged union over
|
|
57
|
+
* the maintenance strategies the incremental substrate names (the spike's
|
|
58
|
+
* `incremental-maintenance-substrate-spike` design). The builder
|
|
59
|
+
* ({@link MaterializedViewManager.buildMaintenancePlan}) produces four bounded-delta arms:
|
|
60
|
+
* `'inverse-projection'` (the covering-index shape), `'residual-recompute'` (single-source
|
|
61
|
+
* aggregates), `'prefix-delete'` (single-source lateral-TVF fan-out), and `'join-residual'`
|
|
62
|
+
* (the provably-1:1 inner join). Only `'inverse-projection'` is applied **per source row,
|
|
63
|
+
* immediately** — its backing is read mid-statement by covering-UNIQUE enforcement, and its
|
|
64
|
+
* delta is a cheap pure projection. The three **residual** arms accumulate their affected
|
|
65
|
+
* binding keys into the per-statement {@link ResidualKeyBatch} (deduped across the
|
|
66
|
+
* statement's changes) and recompute once per distinct key at the end-of-statement flush.
|
|
67
|
+
* The `'full-rebuild'` floor (the always-correct convergence point for bodies no
|
|
68
|
+
* bounded-delta arm fits) is likewise deferred — marked dirty per row and rebuilt once per
|
|
69
|
+
* statement. Both deferred kinds drain at
|
|
70
|
+
* {@link MaterializedViewManager.flushDeferredMaintenance}.
|
|
71
|
+
*/
|
|
72
|
+
export type MaintenancePlan = InverseProjectionPlan | FullRebuildPlan | ResidualRecomputePlan | PrefixDeletePlan | JoinResidualPlan;
|
|
73
|
+
/**
|
|
74
|
+
* One backing primary-key column as a {@link MaintenancePlan} sees it: the btree's declared
|
|
75
|
+
* `(index, direction, collation-name)` triple plus the collation *function* the name resolves
|
|
76
|
+
* to, resolved once when the plan is built (`resolveBackingPkColumns`).
|
|
77
|
+
*
|
|
78
|
+
* The name stays for logging and plan equality; the function is what the per-row key
|
|
79
|
+
* comparisons in `database-materialized-views-apply.ts` call, so they never pay a registry
|
|
80
|
+
* lookup — nor silently fall back to byte comparison — per row.
|
|
81
|
+
*/
|
|
82
|
+
export interface BackingPkColumn extends PrimaryKeyColumnDefinition {
|
|
83
|
+
/** Resolved comparator for {@link collation}; BINARY when the column declares no COLLATE. */
|
|
84
|
+
readonly collationFn: CollationFunction;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The three **residual** (key-filtered recompute) arms — every {@link MaintenancePlan}
|
|
88
|
+
* kind except `'inverse-projection'` and `'full-rebuild'`. These are the arms the
|
|
89
|
+
* per-statement {@link ResidualKeyBatch} defers: their affected binding keys accumulate
|
|
90
|
+
* (deduped) during the statement's row loop and each distinct key's residual runs once
|
|
91
|
+
* at the end-of-statement flush ({@link MaterializedViewManager.flushDeferredMaintenance}).
|
|
92
|
+
*/
|
|
93
|
+
export type ResidualMaintenancePlan = ResidualRecomputePlan | PrefixDeletePlan | JoinResidualPlan;
|
|
94
|
+
/**
|
|
95
|
+
* Fields shared by the three residual arms. `fullRebuildScheduler` is the per-statement
|
|
96
|
+
* **degrade-to-rebuild escape**: when the statement's distinct affected-key count makes
|
|
97
|
+
* k residual runs cost more than one whole-body rebuild (`shouldDegradeToRebuild` against
|
|
98
|
+
* {@link MaintenancePlanCommon.sourceStats}), the flush runs this scheduler to completion
|
|
99
|
+
* and applies a single `'replace-all'` diff instead — the stored `chosenStrategy` is
|
|
100
|
+
* unchanged, so a later low-cardinality statement naturally reverts to per-key residuals.
|
|
101
|
+
* Compiled once at registration ({@link buildMaintenancePlan}) exactly like the floor's
|
|
102
|
+
* own `bodyScheduler`; optional defensively (an absent scheduler just skips the demotion).
|
|
103
|
+
*/
|
|
104
|
+
export interface ResidualArmCommon {
|
|
105
|
+
fullRebuildScheduler?: Scheduler;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Structural subset of the fields the forward (driving-source) residual-recompute
|
|
109
|
+
* apply path reads — shared by the aggregate {@link ResidualRecomputePlan} and the
|
|
110
|
+
* 1:1-join {@link JoinResidualPlan} so both drive {@link applyForwardResidual}
|
|
111
|
+
* unchanged. For an aggregate the forward key is the group key (`'gk'`); for a join
|
|
112
|
+
* it is the driving table `T`'s PK (`'pk'`).
|
|
113
|
+
*/
|
|
114
|
+
export interface ForwardResidualPlan {
|
|
115
|
+
mv: MaintainedTableSchema;
|
|
116
|
+
backingSchema: string;
|
|
117
|
+
backingTableName: string;
|
|
118
|
+
/** Cached scheduler for the key-filtered residual (the body with `injectKeyFilter`
|
|
119
|
+
* applied on the driving source). Re-run per affected key, bound through the live txn. */
|
|
120
|
+
residualScheduler: Scheduler;
|
|
121
|
+
bindParamPrefix: 'gk' | 'pk';
|
|
122
|
+
/** Source-column indices of the forward binding key (group columns / `T`'s PK columns). */
|
|
123
|
+
bindColumns: number[];
|
|
124
|
+
backingPkDefinition: ReadonlyArray<BackingPkColumn>;
|
|
125
|
+
backingPkSourceCols: number[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* How a single backing output column is derived from the changed source row — a pure
|
|
129
|
+
* per-row (per-statement) function. `'passthrough'` copies a source column (the column
|
|
130
|
+
* permutation that *every* PK / UNIQUE-covered column must use, so the backing key and
|
|
131
|
+
* the inverse-projection conflict map are recoverable); `'expr'` evaluates a
|
|
132
|
+
* deterministic scalar expression over the source row (a non-key derived column —
|
|
133
|
+
* `materialized-view-rowtime-expression-projections`). `eval` is the runtime-compiled
|
|
134
|
+
* evaluator (see {@link compileSourceRowEvaluator}), so a computed backing value is
|
|
135
|
+
* exactly what `select <body>` would produce.
|
|
136
|
+
*/
|
|
137
|
+
export type BackingProjector = {
|
|
138
|
+
readonly kind: 'passthrough';
|
|
139
|
+
readonly sourceCol: number;
|
|
140
|
+
} | {
|
|
141
|
+
readonly kind: 'expr';
|
|
142
|
+
readonly eval: (sourceRow: Row) => SqlValue;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* One **weakened** column of a coarsened backing key K′, precomputed once at
|
|
146
|
+
* registration for the row-time collision telemetry
|
|
147
|
+
* ({@link MaterializedViewManager.detectAndReportCoarseningCollisions}). Carries the
|
|
148
|
+
* backing column index to read from each {@link BackingRowChange} image, the
|
|
149
|
+
* **source** (pre-coarsening, stricter) collation the divergence test compares
|
|
150
|
+
* under, the **output** (coarsened) collation the backing key enforces, and the
|
|
151
|
+
* column name for the {@link MaintenanceCollisionEvent} payload. Derived from
|
|
152
|
+
* `mv.derivation.coarsenedKey.weakened` (column names) via `mv.columnIndexMap`.
|
|
153
|
+
*/
|
|
154
|
+
export interface CoarseningWatchColumn {
|
|
155
|
+
/** Backing column index (= body output column index) the weakened K′ column lands at. */
|
|
156
|
+
readonly index: number;
|
|
157
|
+
/** Source key enforcement collation (pre-coarsening); the divergence test compares under it. */
|
|
158
|
+
readonly sourceCollation: string;
|
|
159
|
+
/** {@link sourceCollation} resolved against the database registry, once at registration. */
|
|
160
|
+
readonly sourceCollationFn: CollationFunction;
|
|
161
|
+
/** Output (coarsened) collation the backing key enforces. */
|
|
162
|
+
readonly outputCollation: string;
|
|
163
|
+
/** Backing/output column name (for the event payload's `weakenedColumns`). */
|
|
164
|
+
readonly column: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Common identity + cost-gate fields shared by every {@link MaintenancePlan} arm.
|
|
168
|
+
* `chosenStrategy` / `sourceStats` are set once by the create-time cost gate
|
|
169
|
+
* ({@link buildMaintenancePlan}, via `selectMaintenanceStrategy`) and are not
|
|
170
|
+
* re-evaluated per write, except for the per-statement residual → rebuild demotion
|
|
171
|
+
* (`shouldDegradeToRebuild` against the statement's actual distinct-key count, at
|
|
172
|
+
* the end-of-statement flush).
|
|
173
|
+
*/
|
|
174
|
+
export interface MaintenancePlanCommon {
|
|
175
|
+
/** The MV this plan maintains. */
|
|
176
|
+
mv: MaintainedTableSchema;
|
|
177
|
+
/** Lowercased `schema.table` of the single source `T`. */
|
|
178
|
+
sourceBase: string;
|
|
179
|
+
backingSchema: string;
|
|
180
|
+
backingTableName: string;
|
|
181
|
+
/** Strategy the cost gate chose: argmin `maintenanceCost` over the body's sound strategies. */
|
|
182
|
+
chosenStrategy: MaintenanceStrategy;
|
|
183
|
+
/** Create-time cost inputs (StatsProvider + forward optimizer), retained so the DML
|
|
184
|
+
* boundary can re-cost residual vs. rebuild against the actual changeCardinality. */
|
|
185
|
+
sourceStats: MaintenanceSourceStats;
|
|
186
|
+
/** Compiled declared-CHECK/FK validator over derived row images — present ONLY
|
|
187
|
+
* when the maintained table declares ≥1 applicable CHECK or ≥1 FK (the
|
|
188
|
+
* zero-overhead gate: MV-sugar backings and constraint-less maintained tables
|
|
189
|
+
* carry `undefined` and pay nothing per write). Built once at registration
|
|
190
|
+
* ({@link MaterializedViewManager.registerMaterializedView}); applied to each
|
|
191
|
+
* insert/update {@link BackingRowChange} before the cascade. */
|
|
192
|
+
derivedRowValidator?: DerivedRowConstraintValidator;
|
|
193
|
+
/** Precomputed weakened-K′-column watch list for row-time collision telemetry —
|
|
194
|
+
* present ONLY when `mv.derivation.coarsenedKey` is stamped (the zero-overhead
|
|
195
|
+
* gate: a provable-key / refining-lineage-key MV carries `undefined` and pays
|
|
196
|
+
* nothing per write — detection short-circuits on this field). Built once at
|
|
197
|
+
* registration ({@link MaterializedViewManager.registerMaterializedView} →
|
|
198
|
+
* {@link MaterializedViewManager.buildCoarseningWatch}); read by
|
|
199
|
+
* {@link MaterializedViewManager.detectAndReportCoarseningCollisions} from both
|
|
200
|
+
* the bounded-delta and full-rebuild maintenance arms. */
|
|
201
|
+
coarseningWatch?: ReadonlyArray<CoarseningWatchColumn>;
|
|
202
|
+
/** Backing columns that are BOTH declared NOT NULL AND physical-PK members AND whose
|
|
203
|
+
* re-derived body output column is nullable — the exact reachable "NOT-NULL
|
|
204
|
+
* ordering-seeded PK over a loosened source" skew. Present ONLY when non-empty (the
|
|
205
|
+
* zero-overhead gate: nearly every MV carries `undefined` and pays a single boolean
|
|
206
|
+
* check per maintained write — the NOT-NULL/physical-PK set alone is non-empty for
|
|
207
|
+
* almost every MV, so the discriminator is the body-nullability term). Precomputed once
|
|
208
|
+
* at plan build ({@link MaterializedViewManager.buildMaintenancePlan}). Read by the
|
|
209
|
+
* row-time guard in {@link MaterializedViewManager.maintainRowTime} /
|
|
210
|
+
* {@link MaterializedViewManager.flushDeferredMaintenance}. The refresh path has its own
|
|
211
|
+
* materialized-row equivalent (`assertNoNullInNotNullSeededPk` in
|
|
212
|
+
* runtime/emit/materialized-view-helpers.ts). See
|
|
213
|
+
* fix/bug-mv-rowtime-null-into-notnull-seeded-pk. */
|
|
214
|
+
nullGuardColumns?: ReadonlyArray<{
|
|
215
|
+
readonly index: number;
|
|
216
|
+
readonly name: string;
|
|
217
|
+
}>;
|
|
218
|
+
}
|
|
219
|
+
export interface InverseProjectionPlan extends MaintenancePlanCommon {
|
|
220
|
+
readonly kind: 'inverse-projection';
|
|
221
|
+
/** Backing-table physical primary-key definition (the column order the btree keys on). */
|
|
222
|
+
backingPkDefinition: ReadonlyArray<BackingPkColumn>;
|
|
223
|
+
/** `projectors[j]` derives backing output column `j` from the changed source row —
|
|
224
|
+
* either a passthrough copy of a source column or a deterministic scalar expression
|
|
225
|
+
* over the source row. Every PK / backing-key column is `'passthrough'` (eligibility
|
|
226
|
+
* rejects a computed column that lands in the backing key); non-key columns may be
|
|
227
|
+
* `'expr'`. {@link MaterializedViewManager.lookupCoveringConflicts} reads only the
|
|
228
|
+
* passthrough projectors for its inverse (source↔backing) map. */
|
|
229
|
+
projectors: BackingProjector[];
|
|
230
|
+
/** Partial-WHERE predicate evaluated on a single source row; absent ⇒ every row
|
|
231
|
+
* is in scope. A source row contributes a backing row only when this is
|
|
232
|
+
* unambiguously TRUE (mirrors partial-UNIQUE / partial-index semantics). */
|
|
233
|
+
predicate?: CompiledPredicate;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The always-correct **floor**: a body for which no bounded-delta arm is sound is
|
|
237
|
+
* maintained by re-evaluating it in full per writing statement and replacing the backing
|
|
238
|
+
* transactionally (a single `'replace-all'` {@link MaintenanceOp} — a keyed diff against
|
|
239
|
+
* the backing's pending layer, so the delta still commits/rolls-back with the source
|
|
240
|
+
* write and still drives the MV-over-MV cascade). The whole optimized body is compiled
|
|
241
|
+
* once at registration into {@link bodyScheduler}; {@link MaterializedViewManager.applyFullRebuild}
|
|
242
|
+
* runs it to completion against live source state and diffs the result into the backing.
|
|
243
|
+
*
|
|
244
|
+
* Reachability: `buildMaintenancePlan` routes a body here whenever no bounded-delta arm
|
|
245
|
+
* fits ({@link MaterializedViewManager.tryBuildBoundedDeltaArm} returns `null`). It is the
|
|
246
|
+
* one **deferred** arm — marked dirty per source row and rebuilt exactly once at the
|
|
247
|
+
* end-of-statement flush ({@link MaterializedViewManager.flushDeferredMaintenance}), so a bulk
|
|
248
|
+
* write is O(body) not O(rows × body). See `docs/mv-maintenance.md` § Full-rebuild floor.
|
|
249
|
+
*/
|
|
250
|
+
export interface FullRebuildPlan extends MaintenancePlanCommon {
|
|
251
|
+
readonly kind: 'full-rebuild';
|
|
252
|
+
/** The optimized body compiled once at registration — the **whole** body (no
|
|
253
|
+
* `injectKeyFilter`), with the read-side MV rewrite suppressed so it reads its sources,
|
|
254
|
+
* not the backing it populates. Re-run to completion per writing statement, bound
|
|
255
|
+
* through the live transaction (reads-own-writes), to recompute every backing row. */
|
|
256
|
+
bodyScheduler: Scheduler;
|
|
257
|
+
/** Every source base (lowercased `schema.table`) the body reads — set-op legs, every
|
|
258
|
+
* join source, etc. The plan is indexed under each in `rowTimeBySource` (via
|
|
259
|
+
* {@link planSourceBases}), so a write to **any** of them triggers a rebuild; missing
|
|
260
|
+
* one would leave the MV stale on that source's writes. `sourceBase` (the
|
|
261
|
+
* {@link MaintenancePlanCommon} field) holds the first of these for parity. */
|
|
262
|
+
sourceBases: string[];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* The general-body residual-recompute arm: per source change, derive the affected
|
|
266
|
+
* binding key(s) from the changed row, run a key-filtered residual of the body against
|
|
267
|
+
* **live mid-transaction source state**, and apply the keyed diff — upsert the recomputed
|
|
268
|
+
* slice (replacing the old row at the same backing key; a value-identical recompute is
|
|
269
|
+
* suppressed by the host, see vtab/backing-host.ts) or, when the residual returns
|
|
270
|
+
* nothing, delete the emptied key. Wired for the **single-source aggregate** shape
|
|
271
|
+
* (`select g1,… , agg(…) from T [where P] group by g1,…` over bare group columns) by
|
|
272
|
+
* `materialized-view-rowtime-residual-recompute`; the 1:1 row-preserving join shape
|
|
273
|
+
* (`'row'` binding) reuses the same kernel in a follow-on ticket.
|
|
274
|
+
*
|
|
275
|
+
* The residual is the body with a key-equality filter injected on `T`'s
|
|
276
|
+
* `TableReferenceNode` via {@link injectKeyFilter} (parameterized `gk0…` for a group
|
|
277
|
+
* binding, `pk0…` for a row binding), compiled + cached once at registration and run
|
|
278
|
+
* synchronously through the live transaction so the source read is reads-own-writes —
|
|
279
|
+
* the synchronous analogue of `database-assertions.ts`'s residual path.
|
|
280
|
+
*
|
|
281
|
+
* It carries the {@link BindingMode} the spike names as the convergence point (built
|
|
282
|
+
* directly from the body's shape — for an aggregate, the bare GROUP BY columns; NOT
|
|
283
|
+
* via `extractBindings`, whose `'group'` classification additionally requires the group
|
|
284
|
+
* key to cover a source unique key and so reports `'global'` for the common
|
|
285
|
+
* `group by <non-key>` body). The per-statement rebuild demotion rides
|
|
286
|
+
* {@link ResidualArmCommon.fullRebuildScheduler}.
|
|
287
|
+
*/
|
|
288
|
+
export interface ResidualRecomputePlan extends MaintenancePlanCommon, ResidualArmCommon {
|
|
289
|
+
readonly kind: 'residual-recompute';
|
|
290
|
+
binding: BindingMode;
|
|
291
|
+
/** Delta-aggregate fast path descriptor — present iff EVERY stored aggregate column
|
|
292
|
+
* passed the create-time delta eligibility gate ({@link buildDeltaAggregateDescriptor}
|
|
293
|
+
* in database-materialized-views-plan-builders.ts). When present, the statement
|
|
294
|
+
* accumulation folds per-column accumulator deltas alongside the residual keys and
|
|
295
|
+
* the flush maintains each affected group by pure arithmetic on the stored backing
|
|
296
|
+
* row (`merge` on insert, `merge(negate(…))` on delete) with zero source reads —
|
|
297
|
+
* falling back to the residual per group only where the declared algebra cannot
|
|
298
|
+
* prove a retraction observational (see {@link DeltaAggregateColumn.retractionSafe}).
|
|
299
|
+
* Absent ⇒ the arm behaves exactly as before (key-filtered residual re-execution).
|
|
300
|
+
* The plan `kind` stays `'residual-recompute'` either way; `chosenStrategy` records
|
|
301
|
+
* `'delta-aggregate'` when the descriptor is active (cost-strategy decoupling, the
|
|
302
|
+
* same pattern as `'prefix-delete'`). */
|
|
303
|
+
delta?: DeltaAggregateDescriptor;
|
|
304
|
+
/** Cached scheduler for the key-filtered residual (the body with `injectKeyFilter`
|
|
305
|
+
* applied on `T`). Re-run per affected key tuple, bound through the live transaction. */
|
|
306
|
+
residualScheduler: Scheduler;
|
|
307
|
+
/** Bind-parameter prefix the residual was compiled with: `'gk'` (group) / `'pk'` (row). */
|
|
308
|
+
bindParamPrefix: 'gk' | 'pk';
|
|
309
|
+
/** Source-column indices of the binding key (group columns / row key columns). The
|
|
310
|
+
* affected key tuple is `bindColumns.map(c => changedRow[c])`, bound to `${prefix}{i}`. */
|
|
311
|
+
bindColumns: number[];
|
|
312
|
+
/** Backing-table physical primary-key definition (the column order the btree keys on). */
|
|
313
|
+
backingPkDefinition: ReadonlyArray<BackingPkColumn>;
|
|
314
|
+
/** Source column projected (passthrough) into each backing-PK column, in
|
|
315
|
+
* `backingPkDefinition` order. The old backing slice's delete key for a changed row
|
|
316
|
+
* `R` is `buildPrimaryKeyFromValues(backingPkSourceCols.map(sc => R[sc]), backingPkDefinition)`. */
|
|
317
|
+
backingPkSourceCols: number[];
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* The single-source lateral-TVF fan-out arm: a body of the shape
|
|
321
|
+
* `select T.pk…, …, f.* from T cross join lateral tvf(<args over T>) f`, where each base
|
|
322
|
+
* row of `T` fans out to **N** backing rows (one per row the TVF emits for it). The
|
|
323
|
+
* backing PK is the **composite product key** `(T.pk ∪ tvf-key)` that
|
|
324
|
+
* `optimizer-keyed-cross-product-join-keys` advertises through `keysOf` over the lateral
|
|
325
|
+
* join, with the base PK as its **leading prefix** (asserted at build).
|
|
326
|
+
*
|
|
327
|
+
* Per changed base row, maintenance is a **keyed diff of the recomputed fan-out against
|
|
328
|
+
* the existing effective slice for the base-PK prefix** (read via the host's
|
|
329
|
+
* `scanEffective`, since one base row owns many backing rows sharing the prefix): re-run
|
|
330
|
+
* the TVF fan-out **residual** for that base row, delete only the existing keys the
|
|
331
|
+
* recompute no longer produces, and **upsert** each recomputed row (value-identical
|
|
332
|
+
* upserts are suppressed by the host). An UPDATE diffs both the OLD and NEW base keys
|
|
333
|
+
* (the base PK may move); a DELETE diffs the old slice to all-deletes; an INSERT diffs
|
|
334
|
+
* against an empty slice. This reuses the residual kernel of {@link ResidualRecomputePlan}
|
|
335
|
+
* unchanged — the affected-key derivation, the `injectKeyFilter` residual (pinned to the
|
|
336
|
+
* base `TableReferenceNode` with the `'pk'` prefix), reads-own-writes execution, the cost
|
|
337
|
+
* gate — and differs only in the **prefix-slice** diff (vs point-key) and the **N-row**
|
|
338
|
+
* residual (vs ≤1). The body's WHERE, if any, is part of the residual (so an out-of-scope
|
|
339
|
+
* base row fans out to zero rows), exactly as in the aggregate arm.
|
|
340
|
+
*
|
|
341
|
+
* `chosenStrategy` is `'residual-recompute'` (the shared key-filtered re-execution cost
|
|
342
|
+
* shape — the fan-out factor is unknown at create); `kind` is `'prefix-delete'` (the
|
|
343
|
+
* apply-arm dispatcher).
|
|
344
|
+
*/
|
|
345
|
+
export interface PrefixDeletePlan extends MaintenancePlanCommon, ResidualArmCommon {
|
|
346
|
+
readonly kind: 'prefix-delete';
|
|
347
|
+
/** Substrate parity (the base-PK 'row' binding); unread by the apply path, which uses
|
|
348
|
+
* `bindColumns` / `backingPrefixSourceCols`. */
|
|
349
|
+
binding: BindingMode;
|
|
350
|
+
/** Cached scheduler for the base-PK-keyed residual (the body with `injectKeyFilter`
|
|
351
|
+
* applied on `T`, `'pk'` prefix). Re-run per affected base key; fans out to N rows. */
|
|
352
|
+
residualScheduler: Scheduler;
|
|
353
|
+
bindParamPrefix: 'pk';
|
|
354
|
+
/** Source-`T` PK column indices (the base key). The affected key tuple is
|
|
355
|
+
* `bindColumns.map(c => changedRow[c])`, bound to `pk{i}`. */
|
|
356
|
+
bindColumns: number[];
|
|
357
|
+
/** Full backing-table physical primary key (base-PK prefix ++ TVF-key tail). */
|
|
358
|
+
backingPkDefinition: ReadonlyArray<BackingPkColumn>;
|
|
359
|
+
/** Number of leading backing-PK columns that form the base-PK prefix (= `bindColumns.length`). */
|
|
360
|
+
basePrefixLength: number;
|
|
361
|
+
/** Source-`T` column projected into each leading (base-prefix) backing-PK column, in
|
|
362
|
+
* backing-PK order. The by-prefix delete key for a changed row `R` is
|
|
363
|
+
* `backingPrefixSourceCols.map(sc => R[sc])`. */
|
|
364
|
+
backingPrefixSourceCols: number[];
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The 1:1 row-preserving **inner/cross join** arm: a body
|
|
368
|
+
* `select … from T join P on T.fk = P.id` where `T` contributes **exactly one** MV row
|
|
369
|
+
* per governed `T` row (proven by {@link proveOneToOneJoin} — no row loss via NOT-NULL
|
|
370
|
+
* FK→PK referential integrity, no fan-out via `isUnique(T.pk)` at the join frame). The
|
|
371
|
+
* backing is keyed on `T`'s PK (the composite product key `keysOf` advertises across the
|
|
372
|
+
* 1:1 join collapses to `T`'s PK), so each changed `T` row maps to one backing row.
|
|
373
|
+
*
|
|
374
|
+
* Reuses the residual kernel of {@link ResidualRecomputePlan} on its **driving (`T`)**
|
|
375
|
+
* side via {@link ForwardResidualPlan}: a `T`-keyed (`'pk'`) residual recomputes the one
|
|
376
|
+
* joined row for a changed `T` row (run residual → upsert the recomputed row, or delete
|
|
377
|
+
* the key when it returns nothing), identical to a `'row'`-binding aggregate of size 1.
|
|
378
|
+
* `applyForwardResidual` drives it.
|
|
379
|
+
*
|
|
380
|
+
* The **lookup (`P`)** side is the join arm's distinct problem: the MV's `sourceTables`
|
|
381
|
+
* includes `P`, so a write to `P` also fires maintenance, but the forward residual is
|
|
382
|
+
* keyed on `T`'s PK and a `P` row joins *many* `T` rows. This plan therefore carries a
|
|
383
|
+
* **second residual keyed on `P`'s PK** (`lookupResidualScheduler`): for a `P` change it
|
|
384
|
+
* runs `… where P.pk = :pk0` (the body **including** its WHERE) against live state,
|
|
385
|
+
* returning every currently in-scope joined row (each carrying its `T.pk` backing key), and
|
|
386
|
+
* **upserts** each.
|
|
387
|
+
*
|
|
388
|
+
* **WHERE handling — bounded-delta over a partial-WHERE 1:1 join.** A body WHERE is
|
|
389
|
+
* classified at build by which base table(s) its columns reference
|
|
390
|
+
* ({@link MaterializedViewManager.buildJoinResidualPlan}):
|
|
391
|
+
* - **`T`-only predicate** — no extra machinery. The forward (`T`) residual already injects
|
|
392
|
+
* + applies the WHERE (an out-of-scope `T` row recomputes to zero residual rows ⇒ its
|
|
393
|
+
* delete-without-upsert removes the backing row), and a `T`-column predicate cannot move
|
|
394
|
+
* the membership set `{ T : T.fk = P.pk }`, so the lookup side stays **upsert-only**
|
|
395
|
+
* (`lookupMembershipResidualScheduler` absent) — sound for the same reason the no-WHERE
|
|
396
|
+
* arm is.
|
|
397
|
+
* - **`P`-referencing predicate** (or both sides) — a `P` write can flip a row's WHERE truth
|
|
398
|
+
* and so add/remove a backing row, which upsert-only could never delete. The lookup side
|
|
399
|
+
* becomes **delete-capable**: `lookupMembershipResidualScheduler` is the body with
|
|
400
|
+
* `injectKeyFilter` on `P` but the WHERE **stripped** (membership only). Per affected `P`
|
|
401
|
+
* key {@link MaterializedViewManager.applyLookupResidual} diffs it against the in-scope
|
|
402
|
+
* `lookupResidualScheduler` (WHERE retained): membership keys the in-scope recompute no
|
|
403
|
+
* longer produces are deleted, the in-scope rows are upserted — a keyed diff that converges
|
|
404
|
+
* the membership both ways without churning the unchanged rows.
|
|
405
|
+
*
|
|
406
|
+
* Still inner/cross only; outer joins and **fanning** (non-1:1) joins continue to fall to the
|
|
407
|
+
* full-rebuild floor. See `docs/incremental-maintenance.md` § join-residual and the soundness
|
|
408
|
+
* note in {@link MaterializedViewManager.applyLookupResidual}.
|
|
409
|
+
*/
|
|
410
|
+
export interface JoinResidualPlan extends MaintenancePlanCommon, ForwardResidualPlan, ResidualArmCommon {
|
|
411
|
+
readonly kind: 'join-residual';
|
|
412
|
+
/** Substrate parity: the driving `T`'s `'row'`/PK binding. */
|
|
413
|
+
binding: BindingMode;
|
|
414
|
+
bindParamPrefix: 'pk';
|
|
415
|
+
/** Lowercased `schema.table` of the lookup source `P` (distinct from `sourceBase` = `T`). */
|
|
416
|
+
lookupBase: string;
|
|
417
|
+
/** Cached scheduler for the in-scope lookup-keyed residual (the body — WHERE **retained** —
|
|
418
|
+
* with `injectKeyFilter` applied on `P`, `'pk'` prefix). Re-run per affected `P` key;
|
|
419
|
+
* returns the currently in-scope joined rows to upsert. */
|
|
420
|
+
lookupResidualScheduler: Scheduler;
|
|
421
|
+
/** Delete-capable lookup membership residual (the body with the WHERE **stripped** and
|
|
422
|
+
* `injectKeyFilter` on `P`). Present **iff** the body WHERE references `P`: the lookup side
|
|
423
|
+
* must then delete the backing key of every currently-referencing `T` row (regardless of
|
|
424
|
+
* scope) before re-upserting the in-scope survivors, so a `P` write that flips a row's WHERE
|
|
425
|
+
* membership adds/removes its backing row. Absent for a no-WHERE or `T`-only-WHERE body
|
|
426
|
+
* (the lookup side is sound upsert-only — membership cannot move on a `P` write). */
|
|
427
|
+
lookupMembershipResidualScheduler?: Scheduler;
|
|
428
|
+
/** Source-`P` PK column indices (the lookup key). The affected key tuple for a `P`
|
|
429
|
+
* change is `lookupBindColumns.map(c => changedRow[c])`, bound to `pk{i}`. */
|
|
430
|
+
lookupBindColumns: number[];
|
|
431
|
+
lookupBindParamPrefix: 'pk';
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Per-statement cache of resolved backing {@link VirtualTableConnection}s, keyed by the
|
|
435
|
+
* lowercased backing `schema.table`. Created **once per DML generator run** (one
|
|
436
|
+
* statement) and threaded through the maintenance path so the backing-connection
|
|
437
|
+
* resolution — a scan over *all* the Database's active connections in
|
|
438
|
+
* {@link MaterializedViewManager.getBackingConnection} — is paid once per
|
|
439
|
+
* (statement, backing) instead of once per source row. This amortizes the dominant
|
|
440
|
+
* per-row overhead of a bulk `insert`/`update`/`delete` over a covered table.
|
|
441
|
+
*
|
|
442
|
+
* It is purely a resolution cache: the `'inverse-projection'` arm's per-row ops are still
|
|
443
|
+
* applied **immediately** to the cached connection's pending transaction layer, so a later
|
|
444
|
+
* same-statement row's enforcement scan (`lookupCoveringConflicts`) still observes every
|
|
445
|
+
* earlier row's backing write. The **residual** arms and the **full-rebuild** floor are
|
|
446
|
+
* instead deferred to a single end-of-statement
|
|
447
|
+
* {@link MaterializedViewManager.flushDeferredMaintenance} (tracked in the per-statement
|
|
448
|
+
* {@link ResidualKeyBatch} / dirty set, not this cache) — sound because only an
|
|
449
|
+
* inverse-projection MV can serve as a covering structure, so no enforcement scan depends
|
|
450
|
+
* on a deferred arm's per-row visibility. See `docs/mv-maintenance.md` § Synchronous,
|
|
451
|
+
* transactional, per-statement. Because the cache is scoped to one generator run, the
|
|
452
|
+
* connection it holds cannot be torn down mid-statement; the cold enforcement/eviction
|
|
453
|
+
* paths that omit the cache re-resolve the *same* connection deterministically, so
|
|
454
|
+
* reads-own-writes is unaffected.
|
|
455
|
+
*/
|
|
456
|
+
export type BackingConnectionCache = Map<string, VirtualTableConnection>;
|
|
457
|
+
/**
|
|
458
|
+
* One deduped **forward** (driving-source) affected binding key, as
|
|
459
|
+
* `applyForwardResidual` derives it from a changed source row: `keyTuple` binds the
|
|
460
|
+
* key-filtered residual's parameters, `keyVals` are the backing-PK values (in
|
|
461
|
+
* `backingPkDefinition` order) the recomputed slice is matched on, and `deleteKey` is the
|
|
462
|
+
* prebuilt point-delete key for an emptied slice. Deduped on `canonKeyValues(keyVals)`.
|
|
463
|
+
*/
|
|
464
|
+
export interface ForwardResidualKey {
|
|
465
|
+
keyTuple: SqlValue[];
|
|
466
|
+
keyVals: SqlValue[];
|
|
467
|
+
deleteKey: BTreeKeyForPrimary;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* One deduped affected **base** key of a `'prefix-delete'` fan-out plan: `keyTuple` binds
|
|
471
|
+
* the base-PK-keyed residual, `prefix` is the slice's leading-backing-PK equality key.
|
|
472
|
+
* Deduped on `canonKeyValues(keyTuple)`.
|
|
473
|
+
*/
|
|
474
|
+
export interface PrefixDeleteKey {
|
|
475
|
+
keyTuple: SqlValue[];
|
|
476
|
+
prefix: SqlValue[];
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* One stored aggregate output column of a delta-maintained aggregate MV, resolved once
|
|
480
|
+
* at plan build from the aggregate call node's registry-resolved function schema. The
|
|
481
|
+
* engine consumes ONLY the declared {@link AggregateAlgebra} plus the schema's
|
|
482
|
+
* step/finalize/initialValue — never an aggregate-name list (docs/invariants.md).
|
|
483
|
+
*/
|
|
484
|
+
export interface DeltaAggregateColumn {
|
|
485
|
+
/** Backing column index (= body output column index) this aggregate lands at. */
|
|
486
|
+
readonly backingCol: number;
|
|
487
|
+
/** The registry-resolved aggregate schema — carries step/finalize/initialValue. */
|
|
488
|
+
readonly schema: AggregateFunctionSchema;
|
|
489
|
+
/** `schema.algebra`, narrowed: `merge` + `decode` always; `negate` for a `'group'`
|
|
490
|
+
* column (absent for a `'tighten'` column). */
|
|
491
|
+
readonly algebra: AggregateAlgebra;
|
|
492
|
+
/** Delta maintenance class this column belongs to:
|
|
493
|
+
* - `'group'`: an abelian-group aggregate (count/sum — `merge` + `negate` + `decode`).
|
|
494
|
+
* Inserts and deletes both fold arithmetically (`merge` / `merge(negate(…))`).
|
|
495
|
+
* - `'tighten'`: a join-semilattice aggregate (min/max, `bit_or`/`bool_or` — `merge`,
|
|
496
|
+
* `decode`, but **no** `negate`). An insert `merge`s the new value in cheaply
|
|
497
|
+
* (min/max tighten toward the new extreme); a retraction cannot be undone
|
|
498
|
+
* arithmetically, so a retracted group falls back to the residual (its
|
|
499
|
+
* {@link retractionSafe} is always false, and {@link DeltaAggregateDescriptor.hasTighten}
|
|
500
|
+
* routes the whole group to the residual whether or not a row is stored). */
|
|
501
|
+
readonly deltaClass: 'group' | 'tighten';
|
|
502
|
+
/** Source column feeding `step()`; `undefined` for a zero-arg (count(*)-shaped) call. */
|
|
503
|
+
readonly argSourceCol: number | undefined;
|
|
504
|
+
/** True iff this is the zero-arg multiplicity witness (count(*)): its finalized value
|
|
505
|
+
* counts the group's rows, so 0 ⇔ the group emptied (delete the backing row). */
|
|
506
|
+
readonly isMultiplicity: boolean;
|
|
507
|
+
/** True when a RETRACTION may be applied through `decode` of the stored value:
|
|
508
|
+
* either the algebra declares `decodeExact` (decode is a full inverse), or the
|
|
509
|
+
* argument column is declared NOT NULL — then every surviving row contributes, so
|
|
510
|
+
* the true contribution count equals the multiplicity and stays positive while the
|
|
511
|
+
* backing row exists (sum's absorbing decode witness never spuriously empties).
|
|
512
|
+
* A group that accumulated a retraction while ANY column is not retraction-safe is
|
|
513
|
+
* re-derived by the residual at flush instead of trusting the arithmetic. A
|
|
514
|
+
* `'tighten'` column is never retraction-safe. */
|
|
515
|
+
readonly retractionSafe: boolean;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* The **decomposition-maintained** class of stored aggregate column (the `avg` class):
|
|
519
|
+
* a column whose value is a scalar `combine` over sibling partial aggregates that are
|
|
520
|
+
* THEMSELVES stored, delta-maintained columns of the same MV body — `avg(x) ≡
|
|
521
|
+
* sum(x)/count(x)`, and any UDAF declaring {@link AggregateAlgebra.decompose}. It carries
|
|
522
|
+
* NO independent accumulator (it is derived): at flush its value is
|
|
523
|
+
* `combine([finalized(partial) …])` over its partials' freshly finalized values. Resolved
|
|
524
|
+
* once at plan build (`buildDeltaAggregateDescriptor` — the create-time gate that binds
|
|
525
|
+
* each partial to a stored sibling) and evaluated per affected group at flush
|
|
526
|
+
* ({@link computeDeltaAggregateOps}). `avg` is the first client, not a special case.
|
|
527
|
+
*/
|
|
528
|
+
export interface DeltaDecomposeColumn {
|
|
529
|
+
/** Backing column index (= body output column index) this decomposed aggregate lands at. */
|
|
530
|
+
readonly backingCol: number;
|
|
531
|
+
/** Index into {@link DeltaAggregateDescriptor.aggColumns} of each partial, in
|
|
532
|
+
* `decompose.partials` order — the finalized partial values `combine` consumes. Two
|
|
533
|
+
* decompose columns sharing a partial name the same index (the partial is maintained
|
|
534
|
+
* once, read by both). */
|
|
535
|
+
readonly partialIndices: readonly number[];
|
|
536
|
+
/** `algebra.decompose.combine`: builds this column's finalized value from its partials'
|
|
537
|
+
* finalized values, in `partialIndices` order. Reproduces the aggregate's own finalize
|
|
538
|
+
* incl. the empty-group / divide-by-zero case (avg → count 0/NULL ⇒ NULL). */
|
|
539
|
+
readonly combine: (partialValues: readonly SqlValue[]) => SqlValue;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Create-time descriptor for the delta-aggregate fast path inside a
|
|
543
|
+
* `'residual-recompute'` plan — see {@link ResidualRecomputePlan.delta}. Built by
|
|
544
|
+
* `buildDeltaAggregateDescriptor` only when every stored column qualifies; any gate
|
|
545
|
+
* failure leaves the plan on the plain residual (never an error).
|
|
546
|
+
*/
|
|
547
|
+
export interface DeltaAggregateDescriptor {
|
|
548
|
+
/** The stored, independently-accumulated aggregate output columns (one per delta-
|
|
549
|
+
* maintainable aggregate the body projects). A {@link DeltaDecomposeColumn}'s partials
|
|
550
|
+
* are entries here; the decompose column itself is not (it accumulates nothing). */
|
|
551
|
+
readonly aggColumns: readonly DeltaAggregateColumn[];
|
|
552
|
+
/** Decomposition-maintained columns (the `avg` class): each derived at flush from its
|
|
553
|
+
* sibling stored partials via `combine`, contributing no independent accumulation.
|
|
554
|
+
* Empty for a body with no decompose column. See {@link DeltaDecomposeColumn}. */
|
|
555
|
+
readonly decomposeColumns: readonly DeltaDecomposeColumn[];
|
|
556
|
+
/** Non-aggregate (group-key passthrough) backing columns: each copies the group's
|
|
557
|
+
* backing-PK value at position `pkPos` (in `backingPkDefinition` order) into
|
|
558
|
+
* backing column `backingCol` — covers a group column projected outside the PK
|
|
559
|
+
* (e.g. a duplicate projection of a group column). */
|
|
560
|
+
readonly groupColumns: ReadonlyArray<{
|
|
561
|
+
readonly backingCol: number;
|
|
562
|
+
readonly pkPos: number;
|
|
563
|
+
}>;
|
|
564
|
+
/** Index into {@link aggColumns} of the count(*) multiplicity witness. */
|
|
565
|
+
readonly multiplicityIndex: number;
|
|
566
|
+
/** Total backing column count (the upsert row width). */
|
|
567
|
+
readonly backingColumnCount: number;
|
|
568
|
+
/** True iff every {@link DeltaAggregateColumn.retractionSafe}; when false, a group
|
|
569
|
+
* whose statement delta contains any retraction falls back to the residual. */
|
|
570
|
+
readonly retractionSafe: boolean;
|
|
571
|
+
/** True iff any {@link DeltaAggregateColumn} is `'tighten'` (min/max — `merge`, no
|
|
572
|
+
* `negate`). Such a column cannot retract arithmetically, so a group that accumulated
|
|
573
|
+
* ANY retraction re-derives from the residual whether or not a row is stored (unlike a
|
|
574
|
+
* merely not-retraction-safe abelian column, whose no-stored net-fold stays exact). A
|
|
575
|
+
* purely group-column descriptor (`false`) never takes the tighten fallback branch. */
|
|
576
|
+
readonly hasTighten: boolean;
|
|
577
|
+
/** Compiled single-source-row body WHERE; a row whose predicate is not
|
|
578
|
+
* unambiguously TRUE contributes nothing (mirrors the inverse-projection arm).
|
|
579
|
+
* Absent ⇒ every row is in scope. */
|
|
580
|
+
readonly predicate?: CompiledPredicate;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Per-group accumulated statement delta for a delta-aggregate MV — the value side of
|
|
584
|
+
* {@link ResidualKeyBatchEntry.delta}, keyed (like `forward`) on
|
|
585
|
+
* `canonKeyValues(keyVals)` so the two maps pair up at flush.
|
|
586
|
+
*/
|
|
587
|
+
export interface DeltaGroupState {
|
|
588
|
+
/** Backing-PK (group key) values, in `backingPkDefinition` order. */
|
|
589
|
+
readonly keyVals: SqlValue[];
|
|
590
|
+
/** Prebuilt point-delete key for an emptied group. */
|
|
591
|
+
readonly deleteKey: BTreeKeyForPrimary;
|
|
592
|
+
/** Net accumulator delta per aggregate column (descriptor `aggColumns` order),
|
|
593
|
+
* folded across the statement: `merge`d `step` contributions for inserts,
|
|
594
|
+
* `merge`d `negate(step(…))` contributions for deletes. */
|
|
595
|
+
readonly accs: AggValue[];
|
|
596
|
+
/** True once any retraction (delete / update-old-image) contributed — the flush
|
|
597
|
+
* falls back to the residual for this group when the descriptor is not
|
|
598
|
+
* retraction-safe and a stored row exists. */
|
|
599
|
+
retracted: boolean;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* The per-statement key accumulation for one residual-arm MV — which distinct binding
|
|
603
|
+
* keys this statement's source changes affected, per residual variant. `forward` holds
|
|
604
|
+
* driving-source keys (`'residual-recompute'` group keys; `'join-residual'` `T`-PK keys),
|
|
605
|
+
* `lookup` holds a `'join-residual'` plan's lookup-side (`P`-PK) keys (which run the
|
|
606
|
+
* reverse residual variant at flush), and `prefix` holds a `'prefix-delete'` plan's base
|
|
607
|
+
* keys. Exactly one map is populated for the single-variant arms; a `'join-residual'` MV
|
|
608
|
+
* may accumulate `forward` and `lookup` in one statement (e.g. an FK cascade writing both
|
|
609
|
+
* sides). Each map is keyed on the canonical key bytes (`canonKeyValues`) — the same
|
|
610
|
+
* dedup the per-row appliers do within one change, extended across the whole statement.
|
|
611
|
+
*/
|
|
612
|
+
export interface ResidualKeyBatchEntry {
|
|
613
|
+
forward: Map<string, ForwardResidualKey>;
|
|
614
|
+
lookup: Map<string, SqlValue[]>;
|
|
615
|
+
prefix: Map<string, PrefixDeleteKey>;
|
|
616
|
+
/** Delta-aggregate accumulation, keyed like `forward` on the canonical group-key
|
|
617
|
+
* bytes. Populated ONLY alongside `forward` (the residual keys are always
|
|
618
|
+
* accumulated too), so dropping it — {@link deltaPoisoned} — degrades the flush to
|
|
619
|
+
* the plain residual with zero information loss. */
|
|
620
|
+
delta?: Map<string, DeltaGroupState>;
|
|
621
|
+
/** Set when a per-row savepoint revert (OR FAIL) invalidated the accumulated
|
|
622
|
+
* deltas: the savepoint undid the failing row's source/backing writes, but a JS
|
|
623
|
+
* accumulation cannot be unwound, so the net deltas may include a reverted row's
|
|
624
|
+
* contribution. The residual keys stay valid (a reverted key recomputes to a
|
|
625
|
+
* value-identical row, suppressed), so the flush routes through them instead.
|
|
626
|
+
* See `poisonResidualDeltaAccumulations`. */
|
|
627
|
+
deltaPoisoned?: boolean;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Per-statement deferred-residual key batch, keyed by MV key (lowercased
|
|
631
|
+
* `schema.name`). Created once per DML generator run alongside the
|
|
632
|
+
* {@link BackingConnectionCache} and the deferred full-rebuild set; the residual arms
|
|
633
|
+
* accumulate their affected keys here during the row loop
|
|
634
|
+
* ({@link MaterializedViewManager.maintainRowTime}) and each MV's distinct keys are
|
|
635
|
+
* recomputed exactly once at the end-of-statement
|
|
636
|
+
* {@link MaterializedViewManager.flushDeferredMaintenance}. Owned by the statement:
|
|
637
|
+
* discarded with the statement-savepoint unwind on failure, never carried across
|
|
638
|
+
* statements.
|
|
639
|
+
*/
|
|
640
|
+
export type ResidualKeyBatch = Map<string, ResidualKeyBatchEntry>;
|
|
641
|
+
//# sourceMappingURL=database-materialized-views-plans.d.ts.map
|