@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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column origin attribution.
|
|
3
|
+
*
|
|
4
|
+
* Maps every output attribute id reachable under a relational subtree back to the
|
|
5
|
+
* base-table column that minted it. `rule-filter-selectivity` uses this to route
|
|
6
|
+
* each conjunct of a filter-over-join predicate to the statistics of the table its
|
|
7
|
+
* columns actually come from, instead of declining the whole filter because its
|
|
8
|
+
* source spans more than one table.
|
|
9
|
+
*
|
|
10
|
+
* ## Identity — not schema — distinguishes the two sides of a self-join
|
|
11
|
+
*
|
|
12
|
+
* `ColumnOrigin.ref` is the `TableReferenceNode` instance that produced the
|
|
13
|
+
* attribute. `from t a join t b` yields two distinct TableReferenceNodes sharing
|
|
14
|
+
* ONE `TableSchema` object, so a caller asking "how many relations does this
|
|
15
|
+
* expression touch?" must key on `ref` identity. Keying on `table` collapses the
|
|
16
|
+
* two sides and mis-classifies `a.age > b.age` as a single-table predicate
|
|
17
|
+
* comparing a column to a constant.
|
|
18
|
+
*
|
|
19
|
+
* ## Attributes minted above a base table are deliberately absent
|
|
20
|
+
*
|
|
21
|
+
* Computed projections, aggregate outputs, `values` rows and join existence flags
|
|
22
|
+
* never appear in the map. A predicate over one of them has no base-table column
|
|
23
|
+
* statistics to consult, so the caller must treat it as unknown rather than
|
|
24
|
+
* mis-attribute it by column name.
|
|
25
|
+
*
|
|
26
|
+
* ## Row-merging operators are opaque
|
|
27
|
+
*
|
|
28
|
+
* A set operation and a recursive CTE both *forward* their left / base-case branch's
|
|
29
|
+
* attribute ids (see `analysis/attribute-provenance.ts`), but the rows behind those
|
|
30
|
+
* ids come from every branch. `union all` of a 4-distinct-value column with a
|
|
31
|
+
* 1000-distinct-value one publishes the left branch's id while carrying both
|
|
32
|
+
* distributions, so attributing it to the left base table alone would hand the
|
|
33
|
+
* caller one branch's statistics as if they described the whole relation. The walk
|
|
34
|
+
* therefore stops at such a node and records nothing beneath it — a conjunct over a
|
|
35
|
+
* union reads as unknown, exactly like one over a computed projection.
|
|
36
|
+
*/
|
|
37
|
+
import { TableReferenceNode } from '../nodes/reference.js';
|
|
38
|
+
import type { RelationalPlanNode } from '../nodes/plan-node.js';
|
|
39
|
+
import type { TableSchema } from '../../schema/table.js';
|
|
40
|
+
/** Where a single attribute came from: a column of a specific base-table reference. */
|
|
41
|
+
export interface ColumnOrigin {
|
|
42
|
+
/** The TableReferenceNode that minted this attribute — identity is significant. */
|
|
43
|
+
readonly ref: TableReferenceNode;
|
|
44
|
+
readonly table: TableSchema;
|
|
45
|
+
readonly columnIndex: number;
|
|
46
|
+
readonly columnName: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Attribute id → originating base-table column, for every base column reachable
|
|
50
|
+
* under `node` via `getRelations()`.
|
|
51
|
+
*
|
|
52
|
+
* The walk descends relations only, so scalar subqueries hanging off a join
|
|
53
|
+
* condition or a filter predicate are NOT traversed — their columns stay out of
|
|
54
|
+
* the map and any conjunct referencing them reads as unknown. It also stops at a
|
|
55
|
+
* row-merging operator (see the file doc-comment).
|
|
56
|
+
*/
|
|
57
|
+
export declare function collectColumnOrigins(node: RelationalPlanNode): Map<number, ColumnOrigin>;
|
|
58
|
+
//# sourceMappingURL=column-origins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-origins.d.ts","sourceRoot":"","sources":["../../../../src/planner/util/column-origins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,KAAK,EAAY,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,uFAAuF;AACvF,MAAM,WAAW,YAAY;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAoBxF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column origin attribution.
|
|
3
|
+
*
|
|
4
|
+
* Maps every output attribute id reachable under a relational subtree back to the
|
|
5
|
+
* base-table column that minted it. `rule-filter-selectivity` uses this to route
|
|
6
|
+
* each conjunct of a filter-over-join predicate to the statistics of the table its
|
|
7
|
+
* columns actually come from, instead of declining the whole filter because its
|
|
8
|
+
* source spans more than one table.
|
|
9
|
+
*
|
|
10
|
+
* ## Identity — not schema — distinguishes the two sides of a self-join
|
|
11
|
+
*
|
|
12
|
+
* `ColumnOrigin.ref` is the `TableReferenceNode` instance that produced the
|
|
13
|
+
* attribute. `from t a join t b` yields two distinct TableReferenceNodes sharing
|
|
14
|
+
* ONE `TableSchema` object, so a caller asking "how many relations does this
|
|
15
|
+
* expression touch?" must key on `ref` identity. Keying on `table` collapses the
|
|
16
|
+
* two sides and mis-classifies `a.age > b.age` as a single-table predicate
|
|
17
|
+
* comparing a column to a constant.
|
|
18
|
+
*
|
|
19
|
+
* ## Attributes minted above a base table are deliberately absent
|
|
20
|
+
*
|
|
21
|
+
* Computed projections, aggregate outputs, `values` rows and join existence flags
|
|
22
|
+
* never appear in the map. A predicate over one of them has no base-table column
|
|
23
|
+
* statistics to consult, so the caller must treat it as unknown rather than
|
|
24
|
+
* mis-attribute it by column name.
|
|
25
|
+
*
|
|
26
|
+
* ## Row-merging operators are opaque
|
|
27
|
+
*
|
|
28
|
+
* A set operation and a recursive CTE both *forward* their left / base-case branch's
|
|
29
|
+
* attribute ids (see `analysis/attribute-provenance.ts`), but the rows behind those
|
|
30
|
+
* ids come from every branch. `union all` of a 4-distinct-value column with a
|
|
31
|
+
* 1000-distinct-value one publishes the left branch's id while carrying both
|
|
32
|
+
* distributions, so attributing it to the left base table alone would hand the
|
|
33
|
+
* caller one branch's statistics as if they described the whole relation. The walk
|
|
34
|
+
* therefore stops at such a node and records nothing beneath it — a conjunct over a
|
|
35
|
+
* union reads as unknown, exactly like one over a computed projection.
|
|
36
|
+
*/
|
|
37
|
+
import { TableReferenceNode } from '../nodes/reference.js';
|
|
38
|
+
import { SetOperationNode } from '../nodes/set-operation-node.js';
|
|
39
|
+
import { RecursiveCTENode } from '../nodes/recursive-cte-node.js';
|
|
40
|
+
/**
|
|
41
|
+
* Attribute id → originating base-table column, for every base column reachable
|
|
42
|
+
* under `node` via `getRelations()`.
|
|
43
|
+
*
|
|
44
|
+
* The walk descends relations only, so scalar subqueries hanging off a join
|
|
45
|
+
* condition or a filter predicate are NOT traversed — their columns stay out of
|
|
46
|
+
* the map and any conjunct referencing them reads as unknown. It also stops at a
|
|
47
|
+
* row-merging operator (see the file doc-comment).
|
|
48
|
+
*/
|
|
49
|
+
export function collectColumnOrigins(node) {
|
|
50
|
+
const origins = new Map();
|
|
51
|
+
// Plan trees are DAGs (a CTE instance can be shared), so dedupe by identity.
|
|
52
|
+
const visited = new Set();
|
|
53
|
+
const stack = [node];
|
|
54
|
+
while (stack.length > 0) {
|
|
55
|
+
const n = stack.pop();
|
|
56
|
+
if (visited.has(n))
|
|
57
|
+
continue;
|
|
58
|
+
visited.add(n);
|
|
59
|
+
if (n instanceof TableReferenceNode) {
|
|
60
|
+
addBaseColumns(n, origins);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (isRowMerging(n))
|
|
64
|
+
continue;
|
|
65
|
+
for (const rel of n.getRelations())
|
|
66
|
+
stack.push(rel);
|
|
67
|
+
}
|
|
68
|
+
return origins;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Does this node publish one branch's attribute ids over rows drawn from several
|
|
72
|
+
* branches? Such an id describes no single base-table column.
|
|
73
|
+
*/
|
|
74
|
+
function isRowMerging(node) {
|
|
75
|
+
return node instanceof SetOperationNode || node instanceof RecursiveCTENode;
|
|
76
|
+
}
|
|
77
|
+
/** Zip a table reference's attributes with its schema columns (1:1 by construction). */
|
|
78
|
+
function addBaseColumns(ref, out) {
|
|
79
|
+
// TableReferenceNode builds its attributes by mapping `tableSchema.columns`
|
|
80
|
+
// positionally (see reference.ts), so index i describes the same column in both
|
|
81
|
+
// lists — the same zip `computePhysical` uses to seed update lineage.
|
|
82
|
+
const attrs = ref.getAttributes();
|
|
83
|
+
ref.tableSchema.columns.forEach((col, i) => {
|
|
84
|
+
const attr = attrs[i];
|
|
85
|
+
if (!attr)
|
|
86
|
+
return;
|
|
87
|
+
out.set(attr.id, { ref, table: ref.tableSchema, columnIndex: i, columnName: col.name });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=column-origins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-origins.js","sourceRoot":"","sources":["../../../../src/planner/util/column-origins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,kB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AC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -10,6 +10,15 @@ export interface DeferredConstraintRow {
|
|
|
10
10
|
connectionId?: string;
|
|
11
11
|
contextRow?: Row;
|
|
12
12
|
contextDescriptor?: RowDescriptor;
|
|
13
|
+
/**
|
|
14
|
+
* Lowercase `<schema>.<name>` as this entry's frozen evaluator names a table →
|
|
15
|
+
* the name that table carries now. Populated by {@link DeferredConstraintQueue.notifyTableRename}
|
|
16
|
+
* for renames that happen AFTER this entry was queued, and handed to the scan
|
|
17
|
+
* leaf via `RuntimeContext.tableNameRemap` at evaluation time. Per-entry rather
|
|
18
|
+
* than queue-wide because a freed name may be reused by a fresh table in the
|
|
19
|
+
* same transaction — only entries queued before the rename may be redirected.
|
|
20
|
+
*/
|
|
21
|
+
tableRenames?: Map<string, string>;
|
|
13
22
|
}
|
|
14
23
|
export declare class DeferredConstraintQueue {
|
|
15
24
|
private readonly db;
|
|
@@ -17,6 +26,37 @@ export declare class DeferredConstraintQueue {
|
|
|
17
26
|
private layers;
|
|
18
27
|
constructor(db: Database);
|
|
19
28
|
enqueue(baseTable: string, constraintName: string, row: Row, descriptor: RowDescriptor, evaluator: (ctx: RuntimeContext) => OutputValue, connectionId?: string, contextRow?: Row, contextDescriptor?: RowDescriptor): void;
|
|
29
|
+
/**
|
|
30
|
+
* Records an `ALTER TABLE ... RENAME TO` against every entry already queued, so a
|
|
31
|
+
* check parked before the rename still finds its tables at commit.
|
|
32
|
+
*
|
|
33
|
+
* Two halves:
|
|
34
|
+
* - every pending entry learns `<schema>.<oldName>` → `newName`, composing across
|
|
35
|
+
* repeated renames (`pp → pp2 → pp3` leaves `main.pp` → `pp3`). Composition is
|
|
36
|
+
* confined to keys in the renamed table's own schema — map VALUES are bare names,
|
|
37
|
+
* so a same-named table in another schema must not follow this rename. An entry
|
|
38
|
+
* that already maps `<schema>.<oldName>` is left alone on that key: its emit-time
|
|
39
|
+
* table has moved on, and this rename is about whichever table holds the freed
|
|
40
|
+
* name now.
|
|
41
|
+
* - the bucket keyed by the write-time table name moves with the table, so
|
|
42
|
+
* {@link findConnection}'s name fallback keys off the CURRENT name.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: stamps every pending entry, including entries below the current savepoint
|
|
45
|
+
* layer, and `rollbackLayer` does not unstamp them. Correct today because a catalog
|
|
46
|
+
* rename is not rolled back either — the built-in modules declare the
|
|
47
|
+
* `'non-transactional'` DDL tier, so `rollback to <savepoint>` (and a whole
|
|
48
|
+
* `rollback`) leave the rename applied. If transactional DDL ever lands for the
|
|
49
|
+
* native backends, this remap has to become layer-scoped alongside the catalog.
|
|
50
|
+
*
|
|
51
|
+
* NOTE: walks every queued entry per rename, and each entry owns its own map — so a
|
|
52
|
+
* bulk load that parks a very large number of deferred rows and then renames pays
|
|
53
|
+
* O(entries) per rename plus one Map per entry. Fine at today's scale (renames inside
|
|
54
|
+
* a write transaction are rare); if that combination ever shows up hot, share one
|
|
55
|
+
* copy-on-write rename map across the entries queued between two renames.
|
|
56
|
+
*/
|
|
57
|
+
notifyTableRename(schemaName: string, oldName: string, newName: string): void;
|
|
58
|
+
/** Moves the `oldKey` bucket to `newKey`, merging per-constraint row lists into an existing destination. */
|
|
59
|
+
private rekeyBucket;
|
|
20
60
|
beginLayer(): void;
|
|
21
61
|
rollbackLayer(): void;
|
|
22
62
|
releaseLayer(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-constraint-queue.d.ts","sourceRoot":"","sources":["../../../src/runtime/deferred-constraint-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAY,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AASpD,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,aAAa,CAAC;IAC1B,SAAS,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,WAAW,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,iBAAiB,CAAC,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"deferred-constraint-queue.d.ts","sourceRoot":"","sources":["../../../src/runtime/deferred-constraint-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAY,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AASpD,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,aAAa,CAAC;IAC1B,SAAS,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,WAAW,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAClC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAID,qBAAa,uBAAuB;IAIvB,OAAO,CAAC,QAAQ,CAAC,EAAE;IAH/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;IAChE,OAAO,CAAC,MAAM,CAAmC;gBAEpB,EAAE,EAAE,QAAQ;IAEzC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,iBAAiB,CAAC,EAAE,aAAa,GAAG,IAAI;IAiB1N;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IA4B7E,4GAA4G;IAC5G,OAAO,CAAC,WAAW;IAgBnB,UAAU,IAAI,IAAI;IAIlB,aAAa,IAAI,IAAI;IAIrB,YAAY,IAAI,IAAI;IAOpB,KAAK,IAAI,IAAI;IAKP,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;YA4BxB,aAAa;IA0B3B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,QAAQ;IA4BhB,OAAO,CAAC,KAAK;IAYb,OAAO,CAAC,cAAc;CAkCtB"}
|
|
@@ -29,6 +29,80 @@ export class DeferredConstraintQueue {
|
|
|
29
29
|
contextDescriptor
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Records an `ALTER TABLE ... RENAME TO` against every entry already queued, so a
|
|
34
|
+
* check parked before the rename still finds its tables at commit.
|
|
35
|
+
*
|
|
36
|
+
* Two halves:
|
|
37
|
+
* - every pending entry learns `<schema>.<oldName>` → `newName`, composing across
|
|
38
|
+
* repeated renames (`pp → pp2 → pp3` leaves `main.pp` → `pp3`). Composition is
|
|
39
|
+
* confined to keys in the renamed table's own schema — map VALUES are bare names,
|
|
40
|
+
* so a same-named table in another schema must not follow this rename. An entry
|
|
41
|
+
* that already maps `<schema>.<oldName>` is left alone on that key: its emit-time
|
|
42
|
+
* table has moved on, and this rename is about whichever table holds the freed
|
|
43
|
+
* name now.
|
|
44
|
+
* - the bucket keyed by the write-time table name moves with the table, so
|
|
45
|
+
* {@link findConnection}'s name fallback keys off the CURRENT name.
|
|
46
|
+
*
|
|
47
|
+
* NOTE: stamps every pending entry, including entries below the current savepoint
|
|
48
|
+
* layer, and `rollbackLayer` does not unstamp them. Correct today because a catalog
|
|
49
|
+
* rename is not rolled back either — the built-in modules declare the
|
|
50
|
+
* `'non-transactional'` DDL tier, so `rollback to <savepoint>` (and a whole
|
|
51
|
+
* `rollback`) leave the rename applied. If transactional DDL ever lands for the
|
|
52
|
+
* native backends, this remap has to become layer-scoped alongside the catalog.
|
|
53
|
+
*
|
|
54
|
+
* NOTE: walks every queued entry per rename, and each entry owns its own map — so a
|
|
55
|
+
* bulk load that parks a very large number of deferred rows and then renames pays
|
|
56
|
+
* O(entries) per rename plus one Map per entry. Fine at today's scale (renames inside
|
|
57
|
+
* a write transaction are rare); if that combination ever shows up hot, share one
|
|
58
|
+
* copy-on-write rename map across the entries queued between two renames.
|
|
59
|
+
*/
|
|
60
|
+
notifyTableRename(schemaName, oldName, newName) {
|
|
61
|
+
const oldKey = `${schemaName}.${oldName}`.toLowerCase();
|
|
62
|
+
const newKey = `${schemaName}.${newName}`.toLowerCase();
|
|
63
|
+
const oldLower = oldName.toLowerCase();
|
|
64
|
+
const schemaPrefix = `${schemaName.toLowerCase()}.`;
|
|
65
|
+
const stampStore = (store) => {
|
|
66
|
+
for (const constraints of store.values()) {
|
|
67
|
+
for (const rows of constraints.values()) {
|
|
68
|
+
for (const entry of rows) {
|
|
69
|
+
const renames = entry.tableRenames ?? new Map();
|
|
70
|
+
for (const [key, current] of renames) {
|
|
71
|
+
if (key.startsWith(schemaPrefix) && current.toLowerCase() === oldLower) {
|
|
72
|
+
renames.set(key, newName);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!renames.has(oldKey))
|
|
76
|
+
renames.set(oldKey, newName);
|
|
77
|
+
entry.tableRenames = renames;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.rekeyBucket(store, oldKey, newKey);
|
|
82
|
+
};
|
|
83
|
+
stampStore(this.entries);
|
|
84
|
+
for (const layer of this.layers)
|
|
85
|
+
stampStore(layer);
|
|
86
|
+
}
|
|
87
|
+
/** Moves the `oldKey` bucket to `newKey`, merging per-constraint row lists into an existing destination. */
|
|
88
|
+
rekeyBucket(store, oldKey, newKey) {
|
|
89
|
+
if (oldKey === newKey)
|
|
90
|
+
return;
|
|
91
|
+
const bucket = store.get(oldKey);
|
|
92
|
+
if (!bucket)
|
|
93
|
+
return;
|
|
94
|
+
store.delete(oldKey);
|
|
95
|
+
const dest = store.get(newKey);
|
|
96
|
+
if (!dest) {
|
|
97
|
+
store.set(newKey, bucket);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const [constraintName, rows] of bucket) {
|
|
101
|
+
if (!dest.has(constraintName))
|
|
102
|
+
dest.set(constraintName, []);
|
|
103
|
+
dest.get(constraintName).push(...rows);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
32
106
|
beginLayer() {
|
|
33
107
|
this.layers.push(new Map());
|
|
34
108
|
}
|
|
@@ -65,6 +139,9 @@ export class DeferredConstraintQueue {
|
|
|
65
139
|
for (const entry of rows) {
|
|
66
140
|
const connection = this.findConnection(activeConnections, table, entry.connectionId);
|
|
67
141
|
runtimeCtx.activeConnection = connection;
|
|
142
|
+
// Per entry: the evaluator was frozen at row-write time, so any table it
|
|
143
|
+
// names by the pre-rename name resolves through this map in the scan leaf.
|
|
144
|
+
runtimeCtx.tableNameRemap = entry.tableRenames;
|
|
68
145
|
await this.evaluateEntry(runtimeCtx, entry);
|
|
69
146
|
}
|
|
70
147
|
}
|
|
@@ -81,6 +158,12 @@ export class DeferredConstraintQueue {
|
|
|
81
158
|
try {
|
|
82
159
|
slot.set(evaluationRow);
|
|
83
160
|
const value = await entry.evaluator(runtimeCtx);
|
|
161
|
+
// NOTE: unreachable from today's two enqueue sites (runtime/emit/constraint-check.ts
|
|
162
|
+
// and core/derived-row-validator.ts) — both wrap their evaluator so it throws its
|
|
163
|
+
// own message, attributed identically to the immediate path. This stays as the
|
|
164
|
+
// safety net for any future caller that queues a raw evaluator; if that never
|
|
165
|
+
// happens, it can go, and if it does, prefer teaching the caller to self-attribute
|
|
166
|
+
// over enriching this generic (name-only) message.
|
|
84
167
|
if (value !== null && !isTruthy(value)) {
|
|
85
168
|
throw new QuereusError(`CHECK constraint failed: ${entry.constraintName}`, StatusCode.CONSTRAINT);
|
|
86
169
|
}
|
|
@@ -116,6 +199,7 @@ export class DeferredConstraintQueue {
|
|
|
116
199
|
connectionId: entry.connectionId,
|
|
117
200
|
contextRow: entry.contextRow ? entry.contextRow.slice() : undefined,
|
|
118
201
|
contextDescriptor: entry.contextDescriptor,
|
|
202
|
+
tableRenames: entry.tableRenames,
|
|
119
203
|
})));
|
|
120
204
|
}
|
|
121
205
|
}
|
|
@@ -146,6 +230,13 @@ export class DeferredConstraintQueue {
|
|
|
146
230
|
}
|
|
147
231
|
throw new QuereusError(`Deferred constraint execution could not find connectionId=${preferredId} for table ${tableKey}`, StatusCode.INTERNAL);
|
|
148
232
|
}
|
|
233
|
+
// NOTE: this name fallback is only reached when the enqueue site had no
|
|
234
|
+
// `activeConnection` to stamp. `tableKey` is the table's CURRENT name, not the
|
|
235
|
+
// write-time one: `notifyTableRename` moves the bucket whenever an
|
|
236
|
+
// `ALTER TABLE ... RENAME TO` lands mid-transaction, matching the modules that
|
|
237
|
+
// re-key their connections on rename (see MemoryTableManager.rekeyRegisteredConnections).
|
|
238
|
+
// Were the two to drift apart, the entry would evaluate with no active connection and
|
|
239
|
+
// read committed state instead of the transaction's own writes.
|
|
149
240
|
const normalized = tableKey.toLowerCase();
|
|
150
241
|
const simple = normalized.includes('.') ? normalized.substring(normalized.lastIndexOf('.') + 1) : normalized;
|
|
151
242
|
const matches = connections.filter(conn => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-constraint-queue.js","sourceRoot":"","sources":["../../../src/runtime/deferred-constraint-queue.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"deferred-constraint-queue.js","sourceRoot":"","sources":["../../../src/runtime/deferred-constraint-queue.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAuBjD,MAAM,OAAO,uBAAuB;IAIN;IAHZ,OAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;IACxD,MAAM,GAAgC,EAAE,CAAC;IAEjD,YAA6B,EAAY;QAAZ,OAAE,G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AG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC7G,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,KAAK,MAAM,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,IAAI,YAAY,CACrB,gFAAgF,QAAQ,EAAE,EAC1F,UAAU,CAAC,QAAQ,CACnB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;CACD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ScalarPlanNode } from '../../planner/nodes/plan-node.js';
|
|
2
|
+
import type { AggregateArgBinding, FunctionSchema } from '../../schema/function.js';
|
|
3
|
+
import { type SqlValue } from '../../common/types.js';
|
|
4
|
+
import type { EmissionContext } from '../emission-context.js';
|
|
5
|
+
/**
|
|
6
|
+
* Emit-time setup shared by the stream and hash aggregate emitters: both walk the
|
|
7
|
+
* same `{ expression, alias }` aggregate list and need the same per-aggregate
|
|
8
|
+
* pre-resolutions. Everything here runs ONCE per emit — never per row.
|
|
9
|
+
*
|
|
10
|
+
* {@link argComparisonContext} is shared more widely still: the window emitter
|
|
11
|
+
* binds its own registry's comparison-sensitive functions from the same context,
|
|
12
|
+
* so `min(x) over (…)` and the `min(x)` aggregate read the call site identically.
|
|
13
|
+
*/
|
|
14
|
+
/** One entry of a stream/hash aggregate node's `aggregates` list. */
|
|
15
|
+
export type AggregateExpr = {
|
|
16
|
+
readonly expression: ScalarPlanNode;
|
|
17
|
+
readonly alias: string;
|
|
18
|
+
};
|
|
19
|
+
/** Compares one aggregate's argument values for DISTINCT tracking (scalar for a
|
|
20
|
+
* single argument, element-wise for several, constant for `count(*)`). */
|
|
21
|
+
export type DistinctComparator = (a: SqlValue | SqlValue[], b: SqlValue | SqlValue[]) => number;
|
|
22
|
+
/** The declared logical type and resolved collation of one aggregate or window
|
|
23
|
+
* argument at this call site — the comparison context `bindArgs` (aggregate and
|
|
24
|
+
* window alike) and DISTINCT tracking all rank under. A missing collation name
|
|
25
|
+
* stays undefined, which every consumer reads as BINARY. The logical type is
|
|
26
|
+
* always known here (narrower than {@link AggregateArgBinding}, which allows an
|
|
27
|
+
* untyped argument), so callers may compare with it directly. */
|
|
28
|
+
export declare function argComparisonContext(arg: ScalarPlanNode, ctx: EmissionContext): Required<Pick<AggregateArgBinding, 'logicalType'>> & AggregateArgBinding;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve each aggregate's schema and bind it to its call site's argument types and
|
|
31
|
+
* collations, so a comparison-sensitive aggregate (min/max via
|
|
32
|
+
* {@link import('../../schema/function.js').AggregateFunctionSchema.bindArgs}) steps
|
|
33
|
+
* and merges by the argument's semantic order. Nothing in the per-row path then has
|
|
34
|
+
* to resolve a type or a collation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function bindAggregateSchemas(aggregates: readonly AggregateExpr[], ctx: EmissionContext): {
|
|
37
|
+
schemas: FunctionSchema[];
|
|
38
|
+
distinctFlags: boolean[];
|
|
39
|
+
};
|
|
40
|
+
/** Pre-resolved typed comparators for DISTINCT aggregate argument tracking. */
|
|
41
|
+
export declare function buildDistinctComparators(aggregates: readonly AggregateExpr[], ctx: EmissionContext): DistinctComparator[];
|
|
42
|
+
/**
|
|
43
|
+
* Per-aggregate: may `coerceForAggregate` be skipped for this call site? Skipped when
|
|
44
|
+
* the aggregate never coerces anyway, when every argument is already numeric, or when
|
|
45
|
+
* every argument type carries semantic ordering (TIMESPAN/JSON) — the numeric-string
|
|
46
|
+
* conversion must never run ahead of a type-aware comparator.
|
|
47
|
+
*/
|
|
48
|
+
export declare function computeAggregateSkipCoercion(aggregates: readonly AggregateExpr[]): boolean[];
|
|
49
|
+
//# sourceMappingURL=aggregate-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate-setup.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/aggregate-setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAKpF,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;GAQG;AAEH,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5F;2EAC2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,MAAM,CAAC;AAEhG;;;;;kEAKkE;AAClE,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,GAClB,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC,GAAG,mBAAmB,CAM1E;AAmBD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,GAAG,EAAE,eAAe,GAClB;IAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAAC,aAAa,EAAE,OAAO,EAAE,CAAA;CAAE,CAgBzD;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,GAAG,EAAE,eAAe,GAClB,kBAAkB,EAAE,CAqBtB;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,EAAE,CAa5F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AggregateFunctionCallNode } from '../../planner/nodes/aggregate-function.js';
|
|
2
|
+
import { isAggregateFunctionSchema } from '../../schema/function.js';
|
|
3
|
+
import { bindAggregateSchema } from '../../func/registration.js';
|
|
4
|
+
import { createTypedComparator, hasSemanticOrdering } from '../../util/comparison.js';
|
|
5
|
+
import { StatusCode } from '../../common/types.js';
|
|
6
|
+
import { quereusError } from '../../common/errors.js';
|
|
7
|
+
/** The declared logical type and resolved collation of one aggregate or window
|
|
8
|
+
* argument at this call site — the comparison context `bindArgs` (aggregate and
|
|
9
|
+
* window alike) and DISTINCT tracking all rank under. A missing collation name
|
|
10
|
+
* stays undefined, which every consumer reads as BINARY. The logical type is
|
|
11
|
+
* always known here (narrower than {@link AggregateArgBinding}, which allows an
|
|
12
|
+
* untyped argument), so callers may compare with it directly. */
|
|
13
|
+
export function argComparisonContext(arg, ctx) {
|
|
14
|
+
const argType = arg.getType();
|
|
15
|
+
return {
|
|
16
|
+
logicalType: argType.logicalType,
|
|
17
|
+
collation: argType.collationName ? ctx.resolveCollation(argType.collationName) : undefined,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function argComparator(arg, ctx) {
|
|
21
|
+
const { logicalType, collation } = argComparisonContext(arg, ctx);
|
|
22
|
+
return createTypedComparator(logicalType, collation);
|
|
23
|
+
}
|
|
24
|
+
/** The aggregate call at `agg`, or an INTERNAL error when the plan holds something else. */
|
|
25
|
+
function requireAggregateCall(agg) {
|
|
26
|
+
const funcNode = agg.expression;
|
|
27
|
+
if (!(funcNode instanceof AggregateFunctionCallNode)) {
|
|
28
|
+
quereusError(`Expected AggregateFunctionCallNode but got ${funcNode.constructor.name}`, StatusCode.INTERNAL);
|
|
29
|
+
}
|
|
30
|
+
return funcNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve each aggregate's schema and bind it to its call site's argument types and
|
|
34
|
+
* collations, so a comparison-sensitive aggregate (min/max via
|
|
35
|
+
* {@link import('../../schema/function.js').AggregateFunctionSchema.bindArgs}) steps
|
|
36
|
+
* and merges by the argument's semantic order. Nothing in the per-row path then has
|
|
37
|
+
* to resolve a type or a collation.
|
|
38
|
+
*/
|
|
39
|
+
export function bindAggregateSchemas(aggregates, ctx) {
|
|
40
|
+
const schemas = [];
|
|
41
|
+
const distinctFlags = [];
|
|
42
|
+
for (const agg of aggregates) {
|
|
43
|
+
const funcNode = requireAggregateCall(agg);
|
|
44
|
+
const funcSchema = funcNode.functionSchema;
|
|
45
|
+
if (!isAggregateFunctionSchema(funcSchema)) {
|
|
46
|
+
quereusError(`Function ${funcNode.functionName || 'unknown'} is not an aggregate function`, StatusCode.INTERNAL);
|
|
47
|
+
}
|
|
48
|
+
schemas.push(bindAggregateSchema(funcSchema, (funcNode.args || []).map(arg => argComparisonContext(arg, ctx))));
|
|
49
|
+
distinctFlags.push(funcNode.isDistinct);
|
|
50
|
+
}
|
|
51
|
+
return { schemas, distinctFlags };
|
|
52
|
+
}
|
|
53
|
+
/** Pre-resolved typed comparators for DISTINCT aggregate argument tracking. */
|
|
54
|
+
export function buildDistinctComparators(aggregates, ctx) {
|
|
55
|
+
return aggregates.map(agg => {
|
|
56
|
+
const funcNode = agg.expression;
|
|
57
|
+
if (!(funcNode instanceof AggregateFunctionCallNode))
|
|
58
|
+
return () => 0;
|
|
59
|
+
const args = funcNode.args || [];
|
|
60
|
+
if (args.length === 1) {
|
|
61
|
+
const cmp = argComparator(args[0], ctx);
|
|
62
|
+
return (a, b) => cmp(a, b);
|
|
63
|
+
}
|
|
64
|
+
if (args.length === 0)
|
|
65
|
+
return () => 0; // count(*) — nothing to distinguish
|
|
66
|
+
const argComparators = args.map(arg => argComparator(arg, ctx));
|
|
67
|
+
return (a, b) => {
|
|
68
|
+
const arrA = a;
|
|
69
|
+
const arrB = b;
|
|
70
|
+
for (let i = 0; i < argComparators.length; i++) {
|
|
71
|
+
const cmp = argComparators[i](arrA[i], arrB[i]);
|
|
72
|
+
if (cmp !== 0)
|
|
73
|
+
return cmp;
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Per-aggregate: may `coerceForAggregate` be skipped for this call site? Skipped when
|
|
81
|
+
* the aggregate never coerces anyway, when every argument is already numeric, or when
|
|
82
|
+
* every argument type carries semantic ordering (TIMESPAN/JSON) — the numeric-string
|
|
83
|
+
* conversion must never run ahead of a type-aware comparator.
|
|
84
|
+
*/
|
|
85
|
+
export function computeAggregateSkipCoercion(aggregates) {
|
|
86
|
+
return aggregates.map(agg => {
|
|
87
|
+
const funcNode = agg.expression;
|
|
88
|
+
if (!(funcNode instanceof AggregateFunctionCallNode))
|
|
89
|
+
return false;
|
|
90
|
+
const funcName = (funcNode.functionName || '').toUpperCase();
|
|
91
|
+
// COUNT, GROUP_CONCAT and JSON_* never coerce their arguments.
|
|
92
|
+
if (funcName === 'COUNT' || funcName === 'GROUP_CONCAT' || funcName.startsWith('JSON_'))
|
|
93
|
+
return false;
|
|
94
|
+
const args = funcNode.args || [];
|
|
95
|
+
return args.length > 0 && (args.every(arg => arg.getType().logicalType.isNumeric)
|
|
96
|
+
|| args.every(arg => hasSemanticOrdering(arg.getType().logicalType)));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=aggregate-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate-setup.js","sourceRoot":"","sources":["../../../../src/runtime/emit/aggregate-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,UAAU,EAAiB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAoBtD;;;;;kEAKkE;AAClE,MAAM,UAAU,oBAAoB,CACnC,GAAmB,EACnB,GAAoB;IAEpB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC9B,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,WAA0B;QAC/C,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;KAC1F,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,GAAmB,EAAE,GAAoB;IAC/D,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClE,OAAO,qBAAqB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,4FAA4F;AAC5F,SAAS,oBAAoB,CAAC,GAAkB;IAC/C,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC;IAChC,IAAI,CAAC,CAAC,QAAQ,YAAY,yBAAyB,CA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YAAE,OAAO,KAAK,CAAC;QACnE,MAAM,QAAQ,GAAG,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7D,+DAA+D;QAC/D,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,cAAc,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QACtG,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;eACnD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,WAA0B,CAAC,CAAC,CACnF,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,kCAAkC,CAAC;AAYhF,OAAO,EAAY,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGzE,eAAO,MAAM,MAAM,0BAAkC,CAAC;AAMtD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAgB3D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAmdhG"}
|