@quereus/quereus 4.4.0 → 4.5.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 +6 -1
- package/dist/src/common/types.d.ts +9 -0
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/common/types.js.map +1 -1
- package/dist/src/core/database-events.d.ts +49 -0
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +148 -0
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.js +1 -0
- package/dist/src/core/database-materialized-views-analysis.js.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.d.ts +2 -1
- package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.js +26 -5
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database-materialized-views-plans.d.ts +6 -3
- package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.d.ts +3 -2
- package/dist/src/core/database-materialized-views.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.js +26 -5
- package/dist/src/core/database-materialized-views.js.map +1 -1
- package/dist/src/core/database.d.ts +5 -0
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +21 -1
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/internal-statement-cache.d.ts +18 -0
- package/dist/src/core/internal-statement-cache.d.ts.map +1 -0
- package/dist/src/core/internal-statement-cache.js +211 -0
- package/dist/src/core/internal-statement-cache.js.map +1 -0
- package/dist/src/func/builtins/aggregate.d.ts +13 -12
- package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
- package/dist/src/func/builtins/aggregate.js +45 -67
- package/dist/src/func/builtins/aggregate.js.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.js +63 -48
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +92 -3
- package/dist/src/func/builtins/scalar.js.map +1 -1
- package/dist/src/func/registration.d.ts +18 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +26 -0
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +10 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/parser.d.ts +6 -0
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +45 -34
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/analysis/coarsened-key.d.ts +4 -3
- package/dist/src/planner/analysis/coarsened-key.d.ts.map +1 -1
- package/dist/src/planner/analysis/coarsened-key.js +37 -3
- package/dist/src/planner/analysis/coarsened-key.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +35 -3
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +37 -3
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts +13 -2
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +10 -14
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.js +29 -0
- package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
- package/dist/src/planner/analysis/predicate-conjuncts.d.ts +10 -4
- package/dist/src/planner/analysis/predicate-conjuncts.d.ts.map +1 -1
- package/dist/src/planner/analysis/predicate-conjuncts.js +28 -7
- package/dist/src/planner/analysis/predicate-conjuncts.js.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +6 -0
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.js +19 -29
- package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
- package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -1
- package/dist/src/planner/analysis/sat-checker.js +43 -4
- package/dist/src/planner/analysis/sat-checker.js.map +1 -1
- package/dist/src/planner/analysis/scalar-subqueries.d.ts +22 -3
- package/dist/src/planner/analysis/scalar-subqueries.d.ts.map +1 -1
- package/dist/src/planner/analysis/scalar-subqueries.js +32 -3
- package/dist/src/planner/analysis/scalar-subqueries.js.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.d.ts +64 -0
- package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -0
- package/dist/src/planner/analysis/set-op-type-merge.js +97 -0
- package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -0
- package/dist/src/planner/building/coercion.d.ts +78 -0
- package/dist/src/planner/building/coercion.d.ts.map +1 -0
- package/dist/src/planner/building/coercion.js +137 -0
- package/dist/src/planner/building/coercion.js.map +1 -0
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +5 -18
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +10 -3
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +13 -35
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts +44 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +54 -0
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/function-call.d.ts.map +1 -1
- package/dist/src/planner/building/function-call.js +8 -0
- package/dist/src/planner/building/function-call.js.map +1 -1
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +9 -12
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/select-compound.d.ts.map +1 -1
- package/dist/src/planner/building/select-compound.js +10 -6
- package/dist/src/planner/building/select-compound.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +13 -4
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/cost/conjunct-cost.d.ts +42 -0
- package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -0
- package/dist/src/planner/cost/conjunct-cost.js +62 -0
- package/dist/src/planner/cost/conjunct-cost.js.map +1 -0
- package/dist/src/planner/framework/pass.js +3 -3
- package/dist/src/planner/mutation/propagate.d.ts.map +1 -1
- package/dist/src/planner/mutation/propagate.js +1 -0
- package/dist/src/planner/mutation/propagate.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 +19 -8
- package/dist/src/planner/nodes/async-gather-node.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 +10 -5
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +0 -9
- 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/join-node.d.ts +5 -0
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +8 -1
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/join-utils.d.ts +57 -0
- package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-utils.js +47 -0
- package/dist/src/planner/nodes/join-utils.js.map +1 -1
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +87 -0
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/key-set-semi-join-node.js +137 -0
- package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -0
- 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 +14 -6
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -0
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +26 -3
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts +68 -16
- package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.js +147 -26
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +19 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +13 -2
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +54 -12
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +68 -0
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -0
- package/dist/src/planner/rules/access/rule-key-set-seek.js +408 -0
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -0
- package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js +2 -2
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts +27 -0
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +74 -29
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- 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 +23 -4
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts +10 -8
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js +10 -8
- package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +67 -41
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.js +72 -36
- package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.js +14 -2
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +11 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.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-conjunct-ordering.d.ts +30 -0
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +63 -0
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +17 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +206 -12
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +8 -1
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +3 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +13 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.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 +18 -3
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/shared/index-style-context.d.ts +17 -0
- package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -1
- package/dist/src/planner/rules/shared/index-style-context.js +7 -0
- package/dist/src/planner/rules/shared/index-style-context.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js +4 -0
- package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +24 -6
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +175 -60
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.d.ts +52 -0
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +151 -5
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/stats/index.d.ts +15 -0
- package/dist/src/planner/stats/index.d.ts.map +1 -1
- package/dist/src/planner/stats/index.js.map +1 -1
- package/dist/src/planner/stats/selectivity-combine.d.ts +53 -0
- package/dist/src/planner/stats/selectivity-combine.d.ts.map +1 -0
- package/dist/src/planner/stats/selectivity-combine.js +75 -0
- package/dist/src/planner/stats/selectivity-combine.js.map +1 -0
- package/dist/src/planner/util/column-origins.d.ts +58 -0
- package/dist/src/planner/util/column-origins.d.ts.map +1 -0
- package/dist/src/planner/util/column-origins.js +90 -0
- package/dist/src/planner/util/column-origins.js.map +1 -0
- package/dist/src/runtime/deferred-constraint-queue.d.ts +40 -0
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.js +91 -0
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
- package/dist/src/runtime/emit/aggregate-setup.d.ts +49 -0
- package/dist/src/runtime/emit/aggregate-setup.d.ts.map +1 -0
- package/dist/src/runtime/emit/aggregate-setup.js +99 -0
- package/dist/src/runtime/emit/aggregate-setup.js.map +1 -0
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +4 -69
- 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 +354 -165
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/asof-scan.js +11 -0
- package/dist/src/runtime/emit/asof-scan.js.map +1 -1
- package/dist/src/runtime/emit/between.d.ts.map +1 -1
- package/dist/src/runtime/emit/between.js +7 -12
- 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 +24 -25
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/bloom-join.js +8 -16
- package/dist/src/runtime/emit/bloom-join.js.map +1 -1
- package/dist/src/runtime/emit/case.d.ts.map +1 -1
- package/dist/src/runtime/emit/case.js +40 -6
- 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 +10 -23
- 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 +72 -51
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-view.js +6 -0
- package/dist/src/runtime/emit/create-view.js.map +1 -1
- package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
- package/dist/src/runtime/emit/distinct.js +6 -3
- 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 +188 -84
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/filter.d.ts +18 -0
- package/dist/src/runtime/emit/filter.d.ts.map +1 -1
- package/dist/src/runtime/emit/filter.js +52 -10
- 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 -65
- 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 +18 -7
- package/dist/src/runtime/emit/insert.js.map +1 -1
- package/dist/src/runtime/emit/join-key-extractor.d.ts +46 -0
- package/dist/src/runtime/emit/join-key-extractor.d.ts.map +1 -0
- package/dist/src/runtime/emit/join-key-extractor.js +60 -0
- package/dist/src/runtime/emit/join-key-extractor.js.map +1 -0
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +37 -11
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.d.ts +29 -0
- package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -0
- package/dist/src/runtime/emit/key-set-semi-join.js +143 -0
- package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -0
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts +14 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +33 -3
- 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 +47 -6
- 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 +32 -15
- package/dist/src/runtime/emit/merge-join.js.map +1 -1
- package/dist/src/runtime/emit/operand-comparator.d.ts +40 -0
- package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -0
- package/dist/src/runtime/emit/operand-comparator.js +59 -0
- package/dist/src/runtime/emit/operand-comparator.js.map +1 -0
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +11 -2
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/set-object-tags.d.ts +8 -0
- package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-object-tags.js +8 -0
- package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
- package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-operation.js +7 -4
- package/dist/src/runtime/emit/set-operation.js.map +1 -1
- package/dist/src/runtime/emit/sort.d.ts.map +1 -1
- package/dist/src/runtime/emit/sort.js +5 -2
- 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 +113 -13
- package/dist/src/runtime/emit/subquery.js.map +1 -1
- package/dist/src/runtime/emit/temporal-arithmetic.d.ts +7 -0
- package/dist/src/runtime/emit/temporal-arithmetic.d.ts.map +1 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js +15 -7
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +44 -3
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/window.d.ts.map +1 -1
- package/dist/src/runtime/emit/window.js +72 -55
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts +36 -1
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +238 -116
- package/dist/src/runtime/foreign-key-actions.js.map +1 -1
- package/dist/src/runtime/parallel-driver.d.ts +10 -2
- package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
- package/dist/src/runtime/parallel-driver.js +12 -2
- package/dist/src/runtime/parallel-driver.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +2 -0
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/types.d.ts +25 -0
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/catalog-persistability.d.ts +58 -0
- package/dist/src/schema/catalog-persistability.d.ts.map +1 -0
- package/dist/src/schema/catalog-persistability.js +87 -0
- package/dist/src/schema/catalog-persistability.js.map +1 -0
- package/dist/src/schema/catalog.d.ts +17 -1
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +25 -3
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts +20 -22
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +43 -36
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/ddl-generator.d.ts +23 -0
- package/dist/src/schema/ddl-generator.d.ts.map +1 -1
- package/dist/src/schema/ddl-generator.js +27 -0
- package/dist/src/schema/ddl-generator.js.map +1 -1
- package/dist/src/schema/function.d.ts +39 -1
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/manager.d.ts +28 -0
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +82 -14
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +51 -12
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +31 -0
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +37 -1
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/schema/window-function.d.ts +30 -10
- package/dist/src/schema/window-function.d.ts.map +1 -1
- package/dist/src/schema/window-function.js +20 -16
- package/dist/src/schema/window-function.js.map +1 -1
- package/dist/src/types/builtin-types.d.ts.map +1 -1
- package/dist/src/types/builtin-types.js +30 -4
- package/dist/src/types/builtin-types.js.map +1 -1
- package/dist/src/types/cast-semantics.d.ts +43 -0
- package/dist/src/types/cast-semantics.d.ts.map +1 -0
- package/dist/src/types/cast-semantics.js +59 -0
- package/dist/src/types/cast-semantics.js.map +1 -0
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/json-type.d.ts.map +1 -1
- package/dist/src/types/json-type.js +31 -10
- package/dist/src/types/json-type.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +22 -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/types/temporal-types.d.ts.map +1 -1
- package/dist/src/types/temporal-types.js +33 -11
- package/dist/src/types/temporal-types.js.map +1 -1
- package/dist/src/types/validation.d.ts +39 -1
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +60 -0
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/util/ast-spine-clone.d.ts +23 -0
- package/dist/src/util/ast-spine-clone.d.ts.map +1 -0
- package/dist/src/util/ast-spine-clone.js +41 -0
- package/dist/src/util/ast-spine-clone.js.map +1 -0
- package/dist/src/util/coercion.d.ts +13 -0
- package/dist/src/util/coercion.d.ts.map +1 -1
- package/dist/src/util/coercion.js +10 -1
- package/dist/src/util/coercion.js.map +1 -1
- package/dist/src/util/comparison.d.ts +114 -0
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +187 -27
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +87 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +87 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts +7 -0
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/dist/src/vtab/memory/connection.d.ts +14 -1
- package/dist/src/vtab/memory/connection.d.ts.map +1 -1
- package/dist/src/vtab/memory/connection.js +20 -2
- package/dist/src/vtab/memory/connection.js.map +1 -1
- package/dist/src/vtab/memory/layer/base.d.ts +12 -5
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +20 -9
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/connection.d.ts +17 -0
- package/dist/src/vtab/memory/layer/connection.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/connection.js +26 -0
- package/dist/src/vtab/memory/layer/connection.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +156 -31
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +695 -158
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/plan-filter.d.ts +41 -20
- package/dist/src/vtab/memory/layer/plan-filter.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/plan-filter.js +57 -27
- package/dist/src/vtab/memory/layer/plan-filter.js.map +1 -1
- package/dist/src/vtab/memory/layer/row-convert.d.ts +21 -0
- package/dist/src/vtab/memory/layer/row-convert.d.ts.map +1 -0
- package/dist/src/vtab/memory/layer/row-convert.js +30 -0
- package/dist/src/vtab/memory/layer/row-convert.js.map +1 -0
- package/dist/src/vtab/memory/layer/scan-layer.d.ts +6 -3
- package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.js +48 -34
- package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +142 -19
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +237 -73
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +14 -2
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +60 -41
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +1 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +12 -4
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/memory/types.d.ts +27 -1
- package/dist/src/vtab/memory/types.d.ts.map +1 -1
- package/dist/src/vtab/memory/types.js +16 -1
- package/dist/src/vtab/memory/types.js.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key.d.ts +9 -0
- package/dist/src/vtab/memory/utils/primary-key.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key.js +11 -0
- package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
- package/dist/src/vtab/module.d.ts +63 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +33 -7
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts +0 -26
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts.map +0 -1
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js +0 -66
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared join-key extraction for hash-style join emitters (bloom join, key-set
|
|
3
|
+
* semi join). Builds the per-pair collation normalizers and semantic-ordering
|
|
4
|
+
* canonicalizers once, and returns a single `extractKey(row, indices)` closure
|
|
5
|
+
* both sides of a join call. The two sides MUST agree bit-for-bit on the
|
|
6
|
+
* serialized key — two copies of this logic would drift, and the drift would
|
|
7
|
+
* show up as missing rows.
|
|
8
|
+
*/
|
|
9
|
+
import { serializeKey, serializeRowKey } from '../../util/key-serializer.js';
|
|
10
|
+
import { semanticKeyTransform } from '../../util/comparison.js';
|
|
11
|
+
import { effectiveCollationOfTypes, hashKeyCollationName } from '../../planner/analysis/comparison-collation.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build a {@link JoinKeyExtractor} for a list of equi-pairs, given each pair's
|
|
14
|
+
* two side types (left-side type first; order does not affect the result — the
|
|
15
|
+
* collation resolution is symmetric).
|
|
16
|
+
*
|
|
17
|
+
* Per pair, the comparison collation is resolved through the shared provenance
|
|
18
|
+
* lattice so both sides' key normalization agrees and matches every other join
|
|
19
|
+
* algorithm and the nested-loop fallback. The symmetric resolution is what
|
|
20
|
+
* makes MISMATCHED-collation pairs (declared NOCASE vs defaulted BINARY —
|
|
21
|
+
* tagged `collationsMatch: false` by `equi-pair-extractor`) hash-joinable:
|
|
22
|
+
* both sides' keys normalize under the one resolved collation, exactly what
|
|
23
|
+
* `=` would compare under. Throws on an explicit/declared conflict — a loud
|
|
24
|
+
* backstop; the extractor declines conflicting pairs (they stay in the
|
|
25
|
+
* residual), so this is unreachable for admitted pairs.
|
|
26
|
+
*
|
|
27
|
+
* Semantic-ordering key types additionally canonicalize: the serialized key IS
|
|
28
|
+
* the join match (no re-verify), so values `=` treats as equal (TIMESPAN
|
|
29
|
+
* 'PT1H' ≡ 'PT60M') must serialize identically. Mirrors GROUP BY in
|
|
30
|
+
* hash-aggregate.ts; per pair, active only when both sides declare the same
|
|
31
|
+
* semantic-ordering logical type with a groupKey hook. LOCKSTEP: a MIXED pair
|
|
32
|
+
* (one side semantic-ordering, the other not) can no longer reach a hash join —
|
|
33
|
+
* `equi-pair-extractor`'s semantic-ordering gate demotes it to the residual, so
|
|
34
|
+
* the `=` operator evaluates it in the generic join. Canonicalizing such a pair
|
|
35
|
+
* instead of declining would be unsound anyway (TIMESPAN's groupKey yields a
|
|
36
|
+
* NUMBER, which would hash-match a timespan-vs-integer pair that `=` calls
|
|
37
|
+
* unequal); see the gate's docstring.
|
|
38
|
+
*/
|
|
39
|
+
export function buildJoinKeyExtractor(pairTypes, ctx) {
|
|
40
|
+
const keyNormalizers = pairTypes.map(([leftType, rightType]) => {
|
|
41
|
+
const collationName = effectiveCollationOfTypes(leftType, rightType);
|
|
42
|
+
return ctx.resolveKeyNormalizer(hashKeyCollationName(collationName, [leftType, rightType]));
|
|
43
|
+
});
|
|
44
|
+
const keyCanonicalizers = pairTypes.map(([leftType, rightType]) => {
|
|
45
|
+
const leftLogical = leftType.logicalType;
|
|
46
|
+
const rightLogical = rightType.logicalType;
|
|
47
|
+
return leftLogical === rightLogical ? semanticKeyTransform(leftLogical) : undefined;
|
|
48
|
+
});
|
|
49
|
+
const hasKeyCanonicalizer = keyCanonicalizers.some(c => c !== undefined);
|
|
50
|
+
return (row, indices) => {
|
|
51
|
+
if (!hasKeyCanonicalizer)
|
|
52
|
+
return serializeRowKey(row, indices, keyNormalizers);
|
|
53
|
+
const values = indices.map((idx, i) => {
|
|
54
|
+
const v = row[idx];
|
|
55
|
+
return keyCanonicalizers[i] ? keyCanonicalizers[i](v) : v;
|
|
56
|
+
});
|
|
57
|
+
return serializeKey(values, keyNormalizers);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=join-key-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join-key-extractor.js","sourceRoot":"","sources":["../../../../src/runtime/emit/join-key-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AASjH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,qBAAqB,CACpC,SAA2D,EAC3D,GAAoB;IAEpB,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE;QAC9D,MAAM,aAAa,GAAG,yBAAyB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACrE,OAAO,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE;QACjE,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACzC,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;QAC3C,OAAO,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,CAAC,CAAC,CAAC;IACH,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IAEzE,OAAO,CAAC,GAAQ,EAAE,OAA0B,EAAiB,EAAE;QAC9D,IAAI,CAAC,mBAAmB;YAAE,OAAO,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QAC/E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAiB9D;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAiN9E"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { asRun } from '../types.js';
|
|
2
2
|
import { emitCallFromPlan, emitPlanNode } from '../emitters.js';
|
|
3
3
|
import { createLogger } from '../../common/logger.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BINARY_COLLATION } from '../../util/comparison.js';
|
|
5
5
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
6
6
|
import { effectiveCollationOfTypes } from '../../planner/analysis/comparison-collation.js';
|
|
7
|
+
import { makeOperandComparator } from './operand-comparator.js';
|
|
8
|
+
import { ANY_TYPE } from '../../types/builtin-types.js';
|
|
7
9
|
import { createRowSlot } from '../context-helpers.js';
|
|
8
10
|
import { joinOutputRow } from './join-output.js';
|
|
9
11
|
import { resolveMaybe } from '../async-util.js';
|
|
@@ -26,10 +28,13 @@ export function emitLoopJoin(plan, ctx) {
|
|
|
26
28
|
const leftRowDescriptor = buildRowDescriptor(leftAttributes);
|
|
27
29
|
const rightAttributes = plan.right.getAttributes();
|
|
28
30
|
const rightRowDescriptor = buildRowDescriptor(rightAttributes);
|
|
29
|
-
// Pre-resolve USING column indices and
|
|
30
|
-
// USING compares the two sides' same-named columns, so each pair resolves
|
|
31
|
-
// through the shared provenance lattice — `using (k)` agrees with the
|
|
32
|
-
// spelled-out `l.k = r.k` regardless of side order
|
|
31
|
+
// Pre-resolve USING column indices and per-column comparators at emit time.
|
|
32
|
+
// USING compares the two sides' same-named columns, so each pair resolves its
|
|
33
|
+
// collation through the shared provenance lattice — `using (k)` agrees with the
|
|
34
|
+
// spelled-out `l.k = r.k` regardless of side order — and its comparator through
|
|
35
|
+
// `makeOperandComparator`, the one copy of the routing rule `emitComparisonOp`
|
|
36
|
+
// uses, so the two also agree on declared-type semantics (see
|
|
37
|
+
// {@link evaluateUsingCondition}).
|
|
33
38
|
const usingResolved = plan.usingColumns?.map(columnName => {
|
|
34
39
|
const lowerName = columnName.toLowerCase();
|
|
35
40
|
const leftIndex = leftAttributes.findIndex(attr => attr.name.toLowerCase() === lowerName);
|
|
@@ -39,7 +44,8 @@ export function emitLoopJoin(plan, ctx) {
|
|
|
39
44
|
const collationFunc = leftType && rightType
|
|
40
45
|
? ctx.resolveCollation(effectiveCollationOfTypes(leftType, rightType))
|
|
41
46
|
: BINARY_COLLATION;
|
|
42
|
-
|
|
47
|
+
const compare = makeOperandComparator(leftType?.logicalType ?? ANY_TYPE, rightType?.logicalType ?? ANY_TYPE, collationFunc);
|
|
48
|
+
return { leftIndex, rightIndex, compare };
|
|
43
49
|
});
|
|
44
50
|
// Existence (`exists … as`) flags appended after both sides. The flag is the
|
|
45
51
|
// ACTUAL match bit the outer-join null-extension already computes (NOT a
|
|
@@ -201,16 +207,36 @@ export function emitLoopJoin(plan, ctx) {
|
|
|
201
207
|
};
|
|
202
208
|
}
|
|
203
209
|
/**
|
|
204
|
-
* Evaluates USING condition
|
|
205
|
-
* All index lookups
|
|
206
|
-
*
|
|
210
|
+
* Evaluates a USING condition from pre-resolved column indices and comparators.
|
|
211
|
+
* All index lookups, collation resolution and comparator routing happen at emit time.
|
|
212
|
+
*
|
|
213
|
+
* `using (k)` means exactly `l.k = r.k`, so each column compares through
|
|
214
|
+
* {@link makeOperandComparator} — the one copy of the routing rule
|
|
215
|
+
* `emitComparisonOp` uses. A USING column pairing a semantic-ordering type with a
|
|
216
|
+
* plain one (TIMESPAN `d` against TEXT `d`) therefore takes the same runtime
|
|
217
|
+
* duration check `=` takes and reports 'PT1H' ≡ 'PT60M'; a same-type pair takes the
|
|
218
|
+
* type's own compare. A NULL on either side fails the column outright, mirroring
|
|
219
|
+
* `emitComparisonOp`'s `v1 === null || v2 === null ⇒ null` guard: `l.k = r.k` is
|
|
220
|
+
* UNKNOWN, not true, when both are NULL. The comparators themselves rank NULL/NULL as
|
|
221
|
+
* equal (they are ordering functions, where NULL is a value), so the guard belongs
|
|
222
|
+
* here — without it a nested-loop USING join emits rows the hash-keyed path and the
|
|
223
|
+
* spelled-out ON form both drop.
|
|
224
|
+
*
|
|
225
|
+
* NOTE: USING skips the plan-time cross-type coercion `=` gets, so a JSON column
|
|
226
|
+
* paired with a TEXT one still compares as OBJECT-vs-TEXT storage classes and never
|
|
227
|
+
* matches. Tracked as `bug-using-join-skips-cross-type-coercion`.
|
|
207
228
|
*/
|
|
208
229
|
function evaluateUsingCondition(leftRow, rightRow, resolved) {
|
|
209
|
-
for (const { leftIndex, rightIndex,
|
|
230
|
+
for (const { leftIndex, rightIndex, compare } of resolved) {
|
|
210
231
|
if (leftIndex === -1 || rightIndex === -1) {
|
|
211
232
|
return false;
|
|
212
233
|
}
|
|
213
|
-
|
|
234
|
+
const leftValue = leftRow[leftIndex];
|
|
235
|
+
const rightValue = rightRow[rightIndex];
|
|
236
|
+
if (leftValue === null || rightValue === null) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
if (compare(leftValue, rightValue) !== 0) {
|
|
214
240
|
return false;
|
|
215
241
|
}
|
|
216
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAA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C;IAExC,KAAK,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC3D,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QACxC,IAAI,SAAS,KAAK,IAAI,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { KeySetSemiJoinNode, KeySetPushdown } from '../../planner/nodes/key-set-semi-join-node.js';
|
|
2
|
+
import type { Instruction } from '../types.js';
|
|
3
|
+
import type { EmissionContext } from '../emission-context.js';
|
|
4
|
+
import type { SqlValue } from '../../common/types.js';
|
|
5
|
+
import type { FilterInfo } from '../../vtab/filter-info.js';
|
|
6
|
+
/**
|
|
7
|
+
* Rewrite a full-scan FilterInfo into the single-column `plan=5` multi-seek the
|
|
8
|
+
* literal-IN arm of `rule-select-access-path` produces for `where col in (…)` —
|
|
9
|
+
* one EQ constraint per key, `argvIndex` 1…K, `inCount=<K>` in the idxStr
|
|
10
|
+
* (`seekWidth` omitted ⇒ 1). Every downstream consumer
|
|
11
|
+
* (`StoreTable.scanMultiSeek`, the memory vtab's scan-plan builder,
|
|
12
|
+
* `IsolatedTable.buildConstraintMatcher`) consumes it unchanged because it
|
|
13
|
+
* cannot be told apart from a literal list.
|
|
14
|
+
*
|
|
15
|
+
* Exported for the plan-time/runtime shape-equivalence unit test.
|
|
16
|
+
*/
|
|
17
|
+
export declare function stampMultiSeek(base: FilterInfo, pushdown: KeySetPushdown, keys: readonly SqlValue[]): FilterInfo;
|
|
18
|
+
/**
|
|
19
|
+
* Emit a KeySetSemiJoin: drain the key source once into a set, decide
|
|
20
|
+
* seek-vs-scan, then stream the target probing every row against the set.
|
|
21
|
+
*
|
|
22
|
+
* The probe is unconditional — the pushdown only changes how many rows the
|
|
23
|
+
* target emits. The target leaf is emitted through `emitSeqScan`'s
|
|
24
|
+
* `FilterInfoOverride` hook (the OrdinalSlice pattern): the override reads the
|
|
25
|
+
* per-execution state this run() stamped and either leaves the full-scan
|
|
26
|
+
* FilterInfo untouched or replaces it with the multi-seek.
|
|
27
|
+
*/
|
|
28
|
+
export declare function emitKeySetSemiJoin(plan: KeySetSemiJoinNode, ctx: EmissionContext): Instruction;
|
|
29
|
+
//# sourceMappingURL=key-set-semi-join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-set-semi-join.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/key-set-semi-join.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACxG,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAO,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAc5D;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,SAAS,QAAQ,EAAE,GACvB,UAAU,CA0BZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAuG9F"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { asRun } from '../types.js';
|
|
2
|
+
import { emitPlanNode } from '../emitters.js';
|
|
3
|
+
import { emitSeqScan } from './scan.js';
|
|
4
|
+
import { StatusCode } from '../../common/types.js';
|
|
5
|
+
import { QuereusError, throwIfAborted } from '../../common/errors.js';
|
|
6
|
+
import { IndexConstraintOp } from '../../common/constants.js';
|
|
7
|
+
import { encodeIdxStr, makeIdxStrSpec } from '../../vtab/idx-str.js';
|
|
8
|
+
import { buildJoinKeyExtractor } from './join-key-extractor.js';
|
|
9
|
+
import { compareSqlValuesFast, normalizeCollationName } from '../../util/comparison.js';
|
|
10
|
+
import { createLogger } from '../../common/logger.js';
|
|
11
|
+
const log = createLogger('runtime:emit:key-set-semi-join');
|
|
12
|
+
/**
|
|
13
|
+
* Rewrite a full-scan FilterInfo into the single-column `plan=5` multi-seek the
|
|
14
|
+
* literal-IN arm of `rule-select-access-path` produces for `where col in (…)` —
|
|
15
|
+
* one EQ constraint per key, `argvIndex` 1…K, `inCount=<K>` in the idxStr
|
|
16
|
+
* (`seekWidth` omitted ⇒ 1). Every downstream consumer
|
|
17
|
+
* (`StoreTable.scanMultiSeek`, the memory vtab's scan-plan builder,
|
|
18
|
+
* `IsolatedTable.buildConstraintMatcher`) consumes it unchanged because it
|
|
19
|
+
* cannot be told apart from a literal list.
|
|
20
|
+
*
|
|
21
|
+
* Exported for the plan-time/runtime shape-equivalence unit test.
|
|
22
|
+
*/
|
|
23
|
+
export function stampMultiSeek(base, pushdown, keys) {
|
|
24
|
+
const constraints = keys.map((_v, i) => ({
|
|
25
|
+
constraint: { iColumn: pushdown.seekColumnIndex, op: IndexConstraintOp.EQ, usable: true },
|
|
26
|
+
argvIndex: i + 1,
|
|
27
|
+
}));
|
|
28
|
+
const idxStr = encodeIdxStr(makeIdxStrSpec(pushdown.indexName, 'multiSeek', new Map([['inCount', String(keys.length)]])));
|
|
29
|
+
return {
|
|
30
|
+
...base,
|
|
31
|
+
idxStr,
|
|
32
|
+
constraints,
|
|
33
|
+
args: keys,
|
|
34
|
+
accessPath: pushdown.accessPath,
|
|
35
|
+
indexInfoOutput: {
|
|
36
|
+
...base.indexInfoOutput,
|
|
37
|
+
idxStr,
|
|
38
|
+
nConstraint: constraints.length,
|
|
39
|
+
aConstraint: constraints.map(c => c.constraint),
|
|
40
|
+
aConstraintUsage: constraints.map(c => ({ argvIndex: c.argvIndex, omit: true })),
|
|
41
|
+
estimatedRows: BigInt(keys.length),
|
|
42
|
+
// An ordering-only leaf stamps orderByConsumed vacuously (nothing above
|
|
43
|
+
// the replaced hash join consumed its order); the multi-seek is not an
|
|
44
|
+
// ordering plan, so report false — matching the literal-IN arm's shape.
|
|
45
|
+
orderByConsumed: false,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emit a KeySetSemiJoin: drain the key source once into a set, decide
|
|
51
|
+
* seek-vs-scan, then stream the target probing every row against the set.
|
|
52
|
+
*
|
|
53
|
+
* The probe is unconditional — the pushdown only changes how many rows the
|
|
54
|
+
* target emits. The target leaf is emitted through `emitSeqScan`'s
|
|
55
|
+
* `FilterInfoOverride` hook (the OrdinalSlice pattern): the override reads the
|
|
56
|
+
* per-execution state this run() stamped and either leaves the full-scan
|
|
57
|
+
* FilterInfo untouched or replaces it with the multi-seek.
|
|
58
|
+
*/
|
|
59
|
+
export function emitKeySetSemiJoin(plan, ctx) {
|
|
60
|
+
const targetAttributes = plan.target.getAttributes();
|
|
61
|
+
const keyAttributes = plan.keySource.getAttributes();
|
|
62
|
+
const targetColIdx = plan.target.getAttributeIndex().get(plan.targetAttrId) ?? -1;
|
|
63
|
+
const keyColIdx = plan.keySource.getAttributeIndex().get(plan.keyAttrId) ?? -1;
|
|
64
|
+
if (targetColIdx === -1 || keyColIdx === -1) {
|
|
65
|
+
throw new QuereusError(`KeySetSemiJoin: could not resolve join attr IDs ${plan.targetAttrId}=${plan.keyAttrId}`, StatusCode.INTERNAL);
|
|
66
|
+
}
|
|
67
|
+
// Same serialized-key pipeline as the bloom join it replaces — both sides
|
|
68
|
+
// MUST agree bit-for-bit (see join-key-extractor.ts).
|
|
69
|
+
const extractKey = buildJoinKeyExtractor([[targetAttributes[targetColIdx].type, keyAttributes[keyColIdx].type]], ctx);
|
|
70
|
+
const targetIndices = [targetColIdx];
|
|
71
|
+
const keyIndices = [keyColIdx];
|
|
72
|
+
// Seek keys are sorted under the INDEX's leading-key-column collation so the
|
|
73
|
+
// stamped multi-seek arrives in index-key order — required by the isolation
|
|
74
|
+
// overlay's ascending-merge assumption and what makes emission deterministic.
|
|
75
|
+
const seekCollation = ctx.resolveCollation(normalizeCollationName(plan.pushdown.accessPath.index.keyColumns[0].collation ?? 'BINARY'));
|
|
76
|
+
const seekSign = plan.pushdown.seekDescending ? -1 : 1;
|
|
77
|
+
const stateByCtx = new WeakMap();
|
|
78
|
+
const targetInstruction = emitSeqScan(plan.target, ctx, (base, rctx) => {
|
|
79
|
+
const state = stateByCtx.get(rctx);
|
|
80
|
+
if (!state) {
|
|
81
|
+
// The scheduler always runs the target as a child of this node's
|
|
82
|
+
// run(), so a missing state entry is a scheduling bug. A silent
|
|
83
|
+
// full-scan fallback here would be correct but would hide that bug
|
|
84
|
+
// indefinitely — mirrors OrdinalSlice's guard.
|
|
85
|
+
throw new QuereusError('KeySetSemiJoin target executed without key-set initialization', StatusCode.INTERNAL);
|
|
86
|
+
}
|
|
87
|
+
if (!state.seekKeys)
|
|
88
|
+
return base; // scan fallback — unchanged FilterInfo
|
|
89
|
+
return stampMultiSeek(base, plan.pushdown, state.seekKeys);
|
|
90
|
+
});
|
|
91
|
+
const keySourceInstruction = emitPlanNode(plan.keySource, ctx);
|
|
92
|
+
async function* run(rctx, targetRows, keyRows) {
|
|
93
|
+
// === Drain the key source completely into the probe set. Per distinct
|
|
94
|
+
// probe string, keep the FIRST raw value seen as the seek value.
|
|
95
|
+
// NOTE: under a nested-loop rescan this re-drains the key source each
|
|
96
|
+
// pass. Correct but wasteful; the right side is uncorrelated by rule
|
|
97
|
+
// construction, so caching it is a pure optimization that only matters
|
|
98
|
+
// if this shape ever shows up under an NLJ inner.
|
|
99
|
+
const probe = new Set();
|
|
100
|
+
const seekByProbe = new Map();
|
|
101
|
+
for await (const keyRow of keyRows) {
|
|
102
|
+
throwIfAborted(rctx.signal);
|
|
103
|
+
const key = extractKey(keyRow, keyIndices);
|
|
104
|
+
if (key === null)
|
|
105
|
+
continue; // NULL keys can't match
|
|
106
|
+
if (!probe.has(key)) {
|
|
107
|
+
probe.add(key);
|
|
108
|
+
seekByProbe.set(key, keyRow[keyColIdx]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// An empty build side means the semi join emits nothing — the target
|
|
112
|
+
// must not be opened at all.
|
|
113
|
+
if (probe.size === 0) {
|
|
114
|
+
log('Key set empty — target not opened');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const push = probe.size <= Math.min(plan.pushdown.maxKeys, plan.pushdown.breakEvenKeys);
|
|
118
|
+
let seekKeys = null;
|
|
119
|
+
if (push) {
|
|
120
|
+
seekKeys = [...seekByProbe.values()]
|
|
121
|
+
.sort((a, b) => seekSign * compareSqlValuesFast(a, b, seekCollation));
|
|
122
|
+
}
|
|
123
|
+
log('Key set drained: %d distinct keys, %s (breakEven=%d, max=%d)', probe.size, push ? 'seeking' : 'scanning', plan.pushdown.breakEvenKeys, plan.pushdown.maxKeys);
|
|
124
|
+
stateByCtx.set(rctx, { probe, seekKeys });
|
|
125
|
+
try {
|
|
126
|
+
for await (const targetRow of targetRows) {
|
|
127
|
+
const key = extractKey(targetRow, targetIndices);
|
|
128
|
+
if (key !== null && probe.has(key)) {
|
|
129
|
+
yield targetRow;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
stateByCtx.delete(rctx);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
params: [targetInstruction, keySourceInstruction],
|
|
139
|
+
run: asRun(run),
|
|
140
|
+
note: `key-set semi join (${plan.pushdown.indexName})`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=key-set-semi-join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-set-semi-join.js","sourceRoot":"","sources":["../../../../src/runtime/emit/key-set-semi-join.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,GAAG,GAAG,YAAY,CAAC,gCAAgC,CAAC,CAAC;AAS3D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAgB,EAChB,QAAwB,EACxB,IAAyB;IAEzB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,UAAU,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,eAAe,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;Q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AE,sBAAsB,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG;KACtD,CAAC;AACH,CAAC"}
|
|
@@ -100,7 +100,9 @@ export declare function computeBackingPrimaryKey(shape: BackingShape): ReadonlyA
|
|
|
100
100
|
}>;
|
|
101
101
|
/**
|
|
102
102
|
* Constructs the backing-table {@link TableSchema} for a materialized view from a
|
|
103
|
-
* derived {@link BackingShape}, hosted in `moduleName`
|
|
103
|
+
* derived {@link BackingShape}, hosted in `moduleName` — resolved through the one
|
|
104
|
+
* {@link normalizeBackingModuleName} decision (absent ⇒ `'memory'`), the same one
|
|
105
|
+
* the strict DDL-transaction gate in `materialized-view.ts` consults.
|
|
104
106
|
* The capability check here is defense-in-depth — the create builder already
|
|
105
107
|
* gates, but the catalog-import path reaches this without it.
|
|
106
108
|
*/
|
|
@@ -657,6 +659,17 @@ export declare function propagateColumnRenameToMaterializedViews(db: Database, s
|
|
|
657
659
|
* output name fails shape derivation and stays stale (staleness-diagnostic parity
|
|
658
660
|
* with a broken plain-view chain). Best-effort like the rest of the propagation:
|
|
659
661
|
* a per-MV failure logs, leaves that MV stale, and continues.
|
|
662
|
+
*
|
|
663
|
+
* NOTE: firing no `materialized_view_modified` is deliberate, but
|
|
664
|
+
* {@link renameShiftedBackingColumns} (run from the shared restore tail) DOES change the
|
|
665
|
+
* backing column names — and those names ARE part of the persisted DDL
|
|
666
|
+
* (`generateMaintainedTableDDL` renders the declared column list). So a `select *`
|
|
667
|
+
* materialized view's persisted column list goes stale after any source column rename,
|
|
668
|
+
* clean or not; the rename pre-flight in `schema/catalog-persistability.ts` cannot see it
|
|
669
|
+
* either, because the body AST never changes. Harmless today: reopen re-derives an
|
|
670
|
+
* IMPLICIT MV's shape from its body and reshapes (verified — persisted `("id","x")` with
|
|
671
|
+
* body `select * from m` rehydrates as `("id","y")` with no error). If implicit MVs ever
|
|
672
|
+
* stop reshaping on import, this becomes real durable drift and this pass needs an event.
|
|
660
673
|
*/
|
|
661
674
|
export declare function restoreUnaffectedMaterializedViews(db: Database, preStale: ReadonlySet<string>): Promise<void>;
|
|
662
675
|
//# sourceMappingURL=materialized-view-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialized-view-helpers.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/materialized-view-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAc,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EAAY,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAMrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAsF,MAAM,uBAAuB,CAAC;AAQ7I,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"materialized-view-helpers.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/materialized-view-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAc,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EAAY,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAMrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAsF,MAAM,uBAAuB,CA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AAC,CAwCf"}
|
|
@@ -8,8 +8,9 @@ import { proveCoverage } from '../../planner/analysis/coverage-prover.js';
|
|
|
8
8
|
import { deriveCoarsenedBackingKey } from '../../planner/analysis/coarsened-key.js';
|
|
9
9
|
import { buildColumnIndexMap, requireVtabModule, RowOpFlag } from '../../schema/table.js';
|
|
10
10
|
import { validateChecksOverExistingRows, validateForeignKeyOverExistingRows, maintainedTableCheckViolationError, maintainedTableFkViolationError, formatKeyValue, } from '../../schema/constraint-builder.js';
|
|
11
|
-
import { computeBodyHash } from '../../schema/view.js';
|
|
11
|
+
import { computeBodyHash, normalizeBackingModuleName } from '../../schema/view.js';
|
|
12
12
|
import { isMaintainedTable } from '../../schema/derivation.js';
|
|
13
|
+
import { assertCatalogObjectPersistable } from '../../schema/catalog-persistability.js';
|
|
13
14
|
import { renameTableInAst, renameColumnInAst } from '../../schema/rename-rewriter.js';
|
|
14
15
|
import { createLogger } from '../../common/logger.js';
|
|
15
16
|
import { compareSqlValuesFast, resolveCollationFunctions } from '../../util/comparison.js';
|
|
@@ -227,14 +228,16 @@ export function computeBackingPrimaryKey(shape) {
|
|
|
227
228
|
}
|
|
228
229
|
/**
|
|
229
230
|
* Constructs the backing-table {@link TableSchema} for a materialized view from a
|
|
230
|
-
* derived {@link BackingShape}, hosted in `moduleName`
|
|
231
|
+
* derived {@link BackingShape}, hosted in `moduleName` — resolved through the one
|
|
232
|
+
* {@link normalizeBackingModuleName} decision (absent ⇒ `'memory'`), the same one
|
|
233
|
+
* the strict DDL-transaction gate in `materialized-view.ts` consults.
|
|
231
234
|
* The capability check here is defense-in-depth — the create builder already
|
|
232
235
|
* gates, but the catalog-import path reaches this without it.
|
|
233
236
|
*/
|
|
234
237
|
export function buildBackingTableSchema(db, schemaName, backingTableName, shape, moduleName, moduleArgs,
|
|
235
238
|
/** Table-level metadata tags (the MV's `with tags (…)` — top-level on the unified record). */
|
|
236
239
|
tags) {
|
|
237
|
-
const resolvedModuleName = moduleName
|
|
240
|
+
const resolvedModuleName = normalizeBackingModuleName(moduleName);
|
|
238
241
|
const moduleInfo = db.schemaManager.getModule(resolvedModuleName);
|
|
239
242
|
if (!moduleInfo || !moduleInfo.module) {
|
|
240
243
|
throw new QuereusError(`no virtual table module named '${resolvedModuleName}'`, StatusCode.ERROR);
|
|
@@ -429,6 +432,13 @@ export async function materializeView(db, def, preDerivedShape) {
|
|
|
429
432
|
// body that is not row-time maintainable — roll the whole MV back so an
|
|
430
433
|
// ineligible body errors cleanly.
|
|
431
434
|
try {
|
|
435
|
+
// Same pre-flight the CREATE VIEW path runs, but it can only run HERE: the
|
|
436
|
+
// persisted DDL text (`generateMaintainedTableDDL`) does not exist until the
|
|
437
|
+
// derivation is attached. Placed inside this try so the existing catch — which
|
|
438
|
+
// already unlinks and drops the half-built backing — rolls a rejection back with
|
|
439
|
+
// no extra teardown. Harmless on the catalog-import path (an entry read back from
|
|
440
|
+
// the catalog re-generates persistable DDL by construction).
|
|
441
|
+
assertCatalogObjectPersistable(db, 'materializedView', maintained);
|
|
432
442
|
db.registerMaterializedView(maintained);
|
|
433
443
|
}
|
|
434
444
|
catch (e) {
|
|
@@ -1916,6 +1926,15 @@ function classifyBackingReshape(current, shape) {
|
|
|
1916
1926
|
// rows may still violate them, but the re-derived body rows will not. A NOT NULL
|
|
1917
1927
|
// *loosening* never throws on data, so it stays pre-reconcile. `name` is the
|
|
1918
1928
|
// column's post-rename (new) name.
|
|
1929
|
+
// NOTE: `retype` is queued before `recollate`, so a `TEXT COLLATE NOCASE` → `DATE`
|
|
1930
|
+
// reshape transits an illegal `DATE COLLATE NOCASE` shape between the two ops. Harmless
|
|
1931
|
+
// today — these lift straight onto `module.alterTable`, bypassing the engine-side
|
|
1932
|
+
// SET-DATA-TYPE collation guard (runtime/emit/alter-table.ts), and the following
|
|
1933
|
+
// `recollate` lands the legal final shape. It matters if either changes: if that guard
|
|
1934
|
+
// ever moves module-side the retype op starts failing, and on a store backend a crash
|
|
1935
|
+
// between the two ops leaves catalog DDL that does not re-parse. Fix then is the
|
|
1936
|
+
// differ's rule (schema-differ.ts `comparisonDomainAlters`): queue the collation change
|
|
1937
|
+
// first when its target is BINARY, after the retype otherwise.
|
|
1919
1938
|
const recordAttrShift = (from, to, name) => {
|
|
1920
1939
|
if (!backingTypeMatches(from, to))
|
|
1921
1940
|
postReconcileOps.push({ kind: 'retype', name, newTypeName: to.logicalType.name });
|
|
@@ -2553,6 +2572,17 @@ async function restoreMaterializedViewLive(db, schema, mv, backingNames) {
|
|
|
2553
2572
|
* output name fails shape derivation and stays stale (staleness-diagnostic parity
|
|
2554
2573
|
* with a broken plain-view chain). Best-effort like the rest of the propagation:
|
|
2555
2574
|
* a per-MV failure logs, leaves that MV stale, and continues.
|
|
2575
|
+
*
|
|
2576
|
+
* NOTE: firing no `materialized_view_modified` is deliberate, but
|
|
2577
|
+
* {@link renameShiftedBackingColumns} (run from the shared restore tail) DOES change the
|
|
2578
|
+
* backing column names — and those names ARE part of the persisted DDL
|
|
2579
|
+
* (`generateMaintainedTableDDL` renders the declared column list). So a `select *`
|
|
2580
|
+
* materialized view's persisted column list goes stale after any source column rename,
|
|
2581
|
+
* clean or not; the rename pre-flight in `schema/catalog-persistability.ts` cannot see it
|
|
2582
|
+
* either, because the body AST never changes. Harmless today: reopen re-derives an
|
|
2583
|
+
* IMPLICIT MV's shape from its body and reshapes (verified — persisted `("id","x")` with
|
|
2584
|
+
* body `select * from m` rehydrates as `("id","y")` with no error). If implicit MVs ever
|
|
2585
|
+
* stop reshaping on import, this becomes real durable drift and this pass needs an event.
|
|
2556
2586
|
*/
|
|
2557
2587
|
export async function restoreUnaffectedMaterializedViews(db, preStale) {
|
|
2558
2588
|
for (const mv of db.schemaManager.getAllMaintainedTables()) {
|