@quereus/quereus 4.5.0 → 4.7.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 +5 -4
- package/dist/src/common/errors.d.ts +17 -0
- package/dist/src/common/errors.d.ts.map +1 -1
- package/dist/src/common/errors.js +21 -0
- package/dist/src/common/errors.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts +4 -3
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +44 -14
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +161 -1
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +307 -5
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-internal.d.ts +5 -2
- package/dist/src/core/database-internal.d.ts.map +1 -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 +33 -4
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database-materialized-views-plans.d.ts +12 -2
- package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.d.ts +46 -0
- package/dist/src/core/database-materialized-views.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.js +75 -4
- package/dist/src/core/database-materialized-views.js.map +1 -1
- package/dist/src/core/database-transaction.d.ts +9 -0
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +9 -0
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database.d.ts +16 -2
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +56 -15
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/derived-row-validator.d.ts.map +1 -1
- package/dist/src/core/derived-row-validator.js +7 -1
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +15 -5
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/emit/ast-stringify.d.ts +18 -2
- package/dist/src/emit/ast-stringify.d.ts.map +1 -1
- package/dist/src/emit/ast-stringify.js +22 -4
- package/dist/src/emit/ast-stringify.js.map +1 -1
- package/dist/src/func/builtins/aggregate.js +11 -11
- 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 +15 -85
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/conversion.d.ts.map +1 -1
- package/dist/src/func/builtins/conversion.js +10 -9
- package/dist/src/func/builtins/conversion.js.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +28 -10
- package/dist/src/func/builtins/datetime.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +19 -5
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json.d.ts.map +1 -1
- package/dist/src/func/builtins/json.js +23 -17
- package/dist/src/func/builtins/json.js.map +1 -1
- package/dist/src/func/builtins/mutation.js +2 -2
- package/dist/src/func/builtins/mutation.js.map +1 -1
- package/dist/src/func/builtins/return-types.d.ts +327 -0
- package/dist/src/func/builtins/return-types.d.ts.map +1 -0
- package/dist/src/func/builtins/return-types.js +43 -0
- package/dist/src/func/builtins/return-types.js.map +1 -0
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +150 -79
- package/dist/src/func/builtins/scalar.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +43 -8
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/func/builtins/string.d.ts.map +1 -1
- package/dist/src/func/builtins/string.js +4 -2
- package/dist/src/func/builtins/string.js.map +1 -1
- package/dist/src/func/builtins/timespan.d.ts +3 -0
- package/dist/src/func/builtins/timespan.d.ts.map +1 -1
- package/dist/src/func/builtins/timespan.js +15 -11
- package/dist/src/func/builtins/timespan.js.map +1 -1
- package/dist/src/func/registration.d.ts +35 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +235 -41
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +14 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/ast.d.ts +58 -1
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/parser.d.ts +46 -0
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +161 -45
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/utils.d.ts +13 -1
- package/dist/src/parser/utils.d.ts.map +1 -1
- package/dist/src/parser/utils.js +14 -0
- package/dist/src/parser/utils.js.map +1 -1
- package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -1
- package/dist/src/planner/analysis/assertion-classifier.js +7 -2
- package/dist/src/planner/analysis/assertion-classifier.js.map +1 -1
- package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -1
- package/dist/src/planner/analysis/assertion-hoist-cache.js +5 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts +11 -3
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +5 -4
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
- package/dist/src/planner/analysis/check-extraction.js +37 -4
- package/dist/src/planner/analysis/check-extraction.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +20 -22
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +29 -26
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts +0 -7
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +59 -59
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +13 -5
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +6 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.js +8 -1
- package/dist/src/planner/analysis/equi-correlation.js.map +1 -1
- package/dist/src/planner/analysis/predicate-dependencies.d.ts +34 -0
- package/dist/src/planner/analysis/predicate-dependencies.d.ts.map +1 -0
- package/dist/src/planner/analysis/predicate-dependencies.js +60 -0
- package/dist/src/planner/analysis/predicate-dependencies.js.map +1 -0
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.js +0 -26
- package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +117 -43
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/coercion.d.ts +21 -45
- package/dist/src/planner/building/coercion.d.ts.map +1 -1
- package/dist/src/planner/building/coercion.js +42 -91
- package/dist/src/planner/building/coercion.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +9 -5
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/create-assertion.d.ts.map +1 -1
- package/dist/src/planner/building/create-assertion.js +72 -1
- package/dist/src/planner/building/create-assertion.js.map +1 -1
- package/dist/src/planner/building/create-view.d.ts +6 -1
- package/dist/src/planner/building/create-view.d.ts.map +1 -1
- package/dist/src/planner/building/create-view.js +12 -3
- package/dist/src/planner/building/create-view.js.map +1 -1
- package/dist/src/planner/building/ddl.d.ts.map +1 -1
- package/dist/src/planner/building/ddl.js +6 -2
- package/dist/src/planner/building/ddl.js.map +1 -1
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +23 -10
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/dml-target.d.ts.map +1 -1
- package/dist/src/planner/building/dml-target.js +4 -0
- package/dist/src/planner/building/dml-target.js.map +1 -1
- package/dist/src/planner/building/drop-assertion.d.ts.map +1 -1
- package/dist/src/planner/building/drop-assertion.js +3 -1
- package/dist/src/planner/building/drop-assertion.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts +17 -0
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +28 -17
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +7 -5
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/function-call.d.ts +35 -0
- package/dist/src/planner/building/function-call.d.ts.map +1 -1
- package/dist/src/planner/building/function-call.js +60 -42
- 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 +185 -48
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/materialized-view.d.ts.map +1 -1
- package/dist/src/planner/building/materialized-view.js +3 -1
- package/dist/src/planner/building/materialized-view.js.map +1 -1
- package/dist/src/planner/building/schema-authored-context.d.ts +69 -0
- package/dist/src/planner/building/schema-authored-context.d.ts.map +1 -0
- package/dist/src/planner/building/schema-authored-context.js +75 -0
- package/dist/src/planner/building/schema-authored-context.js.map +1 -0
- package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
- package/dist/src/planner/building/schema-resolution.js +7 -4
- package/dist/src/planner/building/schema-resolution.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +188 -3
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +449 -65
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-compound.js +2 -2
- package/dist/src/planner/building/select-compound.js.map +1 -1
- package/dist/src/planner/building/select-context.d.ts +98 -0
- package/dist/src/planner/building/select-context.d.ts.map +1 -1
- package/dist/src/planner/building/select-context.js +120 -37
- package/dist/src/planner/building/select-context.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +10 -3
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +29 -8
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-ordinal.d.ts +64 -19
- package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
- package/dist/src/planner/building/select-ordinal.js +79 -30
- package/dist/src/planner/building/select-ordinal.js.map +1 -1
- package/dist/src/planner/building/select-projections.d.ts +1 -1
- package/dist/src/planner/building/select-projections.d.ts.map +1 -1
- package/dist/src/planner/building/select-projections.js +18 -11
- package/dist/src/planner/building/select-projections.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts +13 -3
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +142 -37
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts +37 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +240 -109
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +27 -13
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +102 -8
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +34 -4
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts +15 -0
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
- package/dist/src/planner/cache/correlation-detector.js +26 -0
- package/dist/src/planner/cache/correlation-detector.js.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.d.ts +7 -0
- package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.js +12 -3
- package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
- package/dist/src/planner/cost/conjunct-cost.d.ts +40 -0
- package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -1
- package/dist/src/planner/cost/conjunct-cost.js +45 -0
- package/dist/src/planner/cost/conjunct-cost.js.map +1 -1
- package/dist/src/planner/cost/index.d.ts +10 -0
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +15 -0
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +9 -0
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/characteristics.js.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +2 -0
- package/dist/src/planner/framework/pass.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.js +15 -0
- package/dist/src/planner/framework/pass.js.map +1 -1
- package/dist/src/planner/mutation/backward-body.d.ts.map +1 -1
- package/dist/src/planner/mutation/backward-body.js +4 -1
- package/dist/src/planner/mutation/backward-body.js.map +1 -1
- package/dist/src/planner/mutation/body-context.d.ts +23 -0
- package/dist/src/planner/mutation/body-context.d.ts.map +1 -0
- package/dist/src/planner/mutation/body-context.js +26 -0
- package/dist/src/planner/mutation/body-context.js.map +1 -0
- package/dist/src/planner/mutation/cte-flatten.js +15 -2
- package/dist/src/planner/mutation/cte-flatten.js.map +1 -1
- package/dist/src/planner/mutation/decomposition.d.ts +8 -0
- package/dist/src/planner/mutation/decomposition.d.ts.map +1 -1
- package/dist/src/planner/mutation/decomposition.js +8 -3
- package/dist/src/planner/mutation/decomposition.js.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +1 -1
- package/dist/src/planner/mutation/multi-source.d.ts +7 -0
- package/dist/src/planner/mutation/multi-source.d.ts.map +1 -1
- package/dist/src/planner/mutation/multi-source.js +5 -0
- package/dist/src/planner/mutation/multi-source.js.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -1
- package/dist/src/planner/mutation/scope-transform.d.ts +32 -0
- package/dist/src/planner/mutation/scope-transform.d.ts.map +1 -1
- package/dist/src/planner/mutation/scope-transform.js +181 -33
- package/dist/src/planner/mutation/scope-transform.js.map +1 -1
- package/dist/src/planner/mutation/set-op.d.ts.map +1 -1
- package/dist/src/planner/mutation/set-op.js +66 -16
- package/dist/src/planner/mutation/set-op.js.map +1 -1
- package/dist/src/planner/mutation/single-source.d.ts.map +1 -1
- package/dist/src/planner/mutation/single-source.js +100 -24
- package/dist/src/planner/mutation/single-source.js.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts +15 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.js +10 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts +15 -0
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +32 -17
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alias-node.js +2 -1
- package/dist/src/planner/nodes/alias-node.js.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.d.ts +51 -10
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.js +49 -2
- package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.js +4 -1
- package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.js +2 -1
- package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.js +8 -3
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cache-node.js +2 -1
- package/dist/src/planner/nodes/cache-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js +17 -19
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/create-assertion-node.d.ts +2 -1
- package/dist/src/planner/nodes/create-assertion-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/create-assertion-node.js +5 -2
- package/dist/src/planner/nodes/create-assertion-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +19 -9
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +25 -9
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/delete-node.d.ts +20 -2
- package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/delete-node.js +11 -2
- package/dist/src/planner/nodes/delete-node.js.map +1 -1
- package/dist/src/planner/nodes/distinct-node.d.ts +6 -0
- package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/distinct-node.js +10 -2
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +58 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +107 -15
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/planner/nodes/drop-assertion-node.d.ts +2 -1
- package/dist/src/planner/nodes/drop-assertion-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-assertion-node.js +5 -2
- package/dist/src/planner/nodes/drop-assertion-node.js.map +1 -1
- package/dist/src/planner/nodes/eager-prefetch-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/eager-prefetch-node.js +2 -1
- package/dist/src/planner/nodes/eager-prefetch-node.js.map +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts +5 -0
- package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.js +13 -6
- package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +18 -5
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +1 -0
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +21 -16
- package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/insert-node.d.ts +19 -2
- package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/insert-node.js +10 -2
- package/dist/src/planner/nodes/insert-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts +20 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +30 -9
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/join-utils.d.ts +21 -0
- package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-utils.js +26 -0
- package/dist/src/planner/nodes/join-utils.js.map +1 -1
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +42 -10
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/key-set-semi-join-node.js +90 -17
- package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts +5 -0
- package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js +2 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts +6 -0
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +10 -2
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.js +8 -3
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts +5 -0
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.js +9 -2
- package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +29 -0
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +12 -0
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +18 -36
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +3 -2
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.d.ts +16 -2
- package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.js +10 -2
- package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +13 -32
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +5 -18
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +3 -1
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -0
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +22 -20
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +89 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +69 -2
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/update-node.d.ts +19 -2
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +10 -2
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-function.js +8 -0
- package/dist/src/planner/nodes/window-function.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +1 -1
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +3 -1
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts +27 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +130 -10
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +24 -0
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/planning-context.js.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +78 -20
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.js +296 -135
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js +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 +30 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +70 -5
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts +7 -4
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +39 -5
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js +15 -2
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +10 -3
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +6 -4
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +5 -31
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.js +4 -44
- package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.d.ts +49 -0
- package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -0
- package/dist/src/planner/rules/join/index-nested-loop.js +291 -0
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -0
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +8 -8
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts +4 -0
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +50 -15
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts +6 -0
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.js +25 -9
- package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts +7 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js +23 -11
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +10 -4
- 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 +115 -29
- 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 +2 -0
- 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 +18 -4
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts +2 -2
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +19 -22
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts +21 -8
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +70 -14
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +56 -17
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +103 -154
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts +76 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js +208 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +14 -11
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +21 -85
- 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 +7 -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 +18 -22
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.d.ts +52 -0
- package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -0
- package/dist/src/planner/rules/shared/access-leaf.js +95 -0
- package/dist/src/planner/rules/shared/access-leaf.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +17 -7
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +3 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +26 -9
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +69 -11
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts +17 -7
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.js +124 -87
- package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
- package/dist/src/planner/scopes/aliased.d.ts.map +1 -1
- package/dist/src/planner/scopes/aliased.js +6 -0
- package/dist/src/planner/scopes/aliased.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.d.ts +44 -13
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +137 -61
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/stats/conjunct-selectivity.d.ts +48 -0
- package/dist/src/planner/stats/conjunct-selectivity.d.ts.map +1 -0
- package/dist/src/planner/stats/conjunct-selectivity.js +168 -0
- package/dist/src/planner/stats/conjunct-selectivity.js.map +1 -0
- package/dist/src/planner/stats/index.d.ts +22 -3
- 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/table-cardinality.d.ts +28 -0
- package/dist/src/planner/stats/table-cardinality.d.ts.map +1 -0
- package/dist/src/planner/stats/table-cardinality.js +29 -0
- package/dist/src/planner/stats/table-cardinality.js.map +1 -0
- package/dist/src/planner/stored-body-context.d.ts +57 -0
- package/dist/src/planner/stored-body-context.d.ts.map +1 -0
- package/dist/src/planner/stored-body-context.js +64 -0
- package/dist/src/planner/stored-body-context.js.map +1 -0
- package/dist/src/planner/util/column-origins.d.ts +29 -8
- package/dist/src/planner/util/column-origins.d.ts.map +1 -1
- package/dist/src/planner/util/column-origins.js +74 -14
- package/dist/src/planner/util/column-origins.js.map +1 -1
- package/dist/src/planner/util/fd-utils.d.ts +32 -8
- package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
- package/dist/src/planner/util/fd-utils.js +46 -9
- package/dist/src/planner/util/fd-utils.js.map +1 -1
- package/dist/src/planner/util/ind-utils.d.ts +66 -19
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +91 -21
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +36 -3
- package/dist/src/planner/util/key-utils.d.ts.map +1 -1
- package/dist/src/planner/util/key-utils.js +57 -7
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/planner/util/output-names.d.ts +12 -0
- package/dist/src/planner/util/output-names.d.ts.map +1 -0
- package/dist/src/planner/util/output-names.js +20 -0
- package/dist/src/planner/util/output-names.js.map +1 -0
- package/dist/src/planner/util/row-estimates.d.ts +39 -0
- package/dist/src/planner/util/row-estimates.d.ts.map +1 -0
- package/dist/src/planner/util/row-estimates.js +68 -0
- package/dist/src/planner/util/row-estimates.js.map +1 -0
- package/dist/src/planner/util/row-population.d.ts +42 -0
- package/dist/src/planner/util/row-population.d.ts.map +1 -0
- package/dist/src/planner/util/row-population.js +71 -0
- package/dist/src/planner/util/row-population.js.map +1 -0
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.js +3 -2
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +60 -6
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +4 -4
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +97 -0
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -0
- package/dist/src/runtime/emit/alter-schema-event.js +87 -0
- package/dist/src/runtime/emit/alter-schema-event.js.map +1 -0
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +582 -236
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
- package/dist/src/runtime/emit/analyze.js +50 -7
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/assertion-drop-guard.d.ts +37 -0
- package/dist/src/runtime/emit/assertion-drop-guard.d.ts.map +1 -0
- package/dist/src/runtime/emit/assertion-drop-guard.js +59 -0
- package/dist/src/runtime/emit/assertion-drop-guard.js.map +1 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts +33 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.js +124 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -0
- package/dist/src/runtime/emit/cast.d.ts.map +1 -1
- package/dist/src/runtime/emit/cast.js +4 -19
- 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 +10 -227
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-assertion.js +31 -14
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte.js +11 -6
- package/dist/src/runtime/emit/cte.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +233 -28
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +8 -8
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-column-guards.d.ts +151 -0
- package/dist/src/runtime/emit/drop-column-guards.d.ts.map +1 -0
- package/dist/src/runtime/emit/drop-column-guards.js +230 -0
- package/dist/src/runtime/emit/drop-column-guards.js.map +1 -0
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +4 -3
- package/dist/src/runtime/emit/drop-index.js.map +1 -1
- package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-table.js +6 -0
- package/dist/src/runtime/emit/drop-table.js.map +1 -1
- package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-view.js +4 -0
- package/dist/src/runtime/emit/drop-view.js.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.js +2 -2
- package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +8 -67
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.js +11 -3
- package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts +4 -4
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +34 -22
- 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 +7 -2
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/operand-comparator.d.ts +30 -0
- package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -1
- package/dist/src/runtime/emit/operand-comparator.js +34 -0
- package/dist/src/runtime/emit/operand-comparator.js.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.js +4 -5
- package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +30 -0
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
- package/dist/src/runtime/emit/subquery.js +153 -52
- package/dist/src/runtime/emit/subquery.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +18 -6
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/window.js +36 -23
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/row-constraints.d.ts +85 -0
- package/dist/src/runtime/row-constraints.d.ts.map +1 -0
- package/dist/src/runtime/row-constraints.js +239 -0
- package/dist/src/runtime/row-constraints.js.map +1 -0
- package/dist/src/runtime/types.d.ts +8 -11
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +14 -1
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js +14 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/catalog-persistability.d.ts +19 -16
- package/dist/src/schema/catalog-persistability.d.ts.map +1 -1
- package/dist/src/schema/catalog-persistability.js +92 -20
- package/dist/src/schema/catalog-persistability.js.map +1 -1
- package/dist/src/schema/catalog.d.ts +73 -2
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +220 -39
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/column-source-resolver.d.ts +18 -0
- package/dist/src/schema/column-source-resolver.d.ts.map +1 -0
- package/dist/src/schema/column-source-resolver.js +22 -0
- package/dist/src/schema/column-source-resolver.js.map +1 -0
- package/dist/src/schema/column.d.ts +26 -3
- package/dist/src/schema/column.d.ts.map +1 -1
- package/dist/src/schema/column.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +7 -1
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/ddl-generator.d.ts.map +1 -1
- package/dist/src/schema/ddl-generator.js +27 -6
- package/dist/src/schema/ddl-generator.js.map +1 -1
- package/dist/src/schema/function.d.ts +32 -1
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js +10 -2
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/lens-compiler.d.ts.map +1 -1
- package/dist/src/schema/lens-compiler.js +203 -51
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts +2 -3
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +19 -11
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/manager.d.ts +115 -20
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +202 -70
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +142 -0
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +254 -9
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/reserved-tags.d.ts +1 -1
- package/dist/src/schema/reserved-tags.d.ts.map +1 -1
- package/dist/src/schema/reserved-tags.js +4 -3
- package/dist/src/schema/reserved-tags.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +16 -0
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +225 -38
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/table.d.ts +149 -1
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +248 -1
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +5 -3
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +5 -3
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/schema/view.d.ts +11 -0
- package/dist/src/schema/view.d.ts.map +1 -1
- package/dist/src/schema/view.js +12 -0
- package/dist/src/schema/view.js.map +1 -1
- package/dist/src/types/builtin-types.d.ts +54 -0
- package/dist/src/types/builtin-types.d.ts.map +1 -1
- package/dist/src/types/builtin-types.js +123 -34
- package/dist/src/types/builtin-types.js.map +1 -1
- package/dist/src/types/cast-semantics.d.ts +42 -0
- package/dist/src/types/cast-semantics.d.ts.map +1 -1
- package/dist/src/types/cast-semantics.js +64 -0
- package/dist/src/types/cast-semantics.js.map +1 -1
- package/dist/src/types/comparison-coercion.d.ts +101 -0
- package/dist/src/types/comparison-coercion.d.ts.map +1 -0
- package/dist/src/types/comparison-coercion.js +162 -0
- package/dist/src/types/comparison-coercion.js.map +1 -0
- package/dist/src/types/index.d.ts +2 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +2 -2
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +7 -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/validation.d.ts +56 -0
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +68 -0
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/util/{working-table-iterable.d.ts → array-row-iterable.d.ts} +6 -6
- package/dist/src/util/array-row-iterable.d.ts.map +1 -0
- package/dist/src/util/{working-table-iterable.js → array-row-iterable.js} +6 -6
- package/dist/src/util/array-row-iterable.js.map +1 -0
- package/dist/src/util/coercion.d.ts +8 -0
- package/dist/src/util/coercion.d.ts.map +1 -1
- package/dist/src/util/coercion.js +8 -0
- package/dist/src/util/coercion.js.map +1 -1
- package/dist/src/util/comparison.d.ts +16 -3
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +21 -5
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/util/key-serializer.d.ts +46 -0
- package/dist/src/util/key-serializer.d.ts.map +1 -1
- package/dist/src/util/key-serializer.js +47 -0
- package/dist/src/util/key-serializer.js.map +1 -1
- package/dist/src/util/value-set.d.ts +21 -0
- package/dist/src/util/value-set.d.ts.map +1 -0
- package/dist/src/util/value-set.js +22 -0
- package/dist/src/util/value-set.js.map +1 -0
- package/dist/src/vtab/capabilities.d.ts +1 -1
- package/dist/src/vtab/events.d.ts +8 -1
- package/dist/src/vtab/events.d.ts.map +1 -1
- package/dist/src/vtab/events.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts +15 -0
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/alter-column.d.ts +147 -0
- package/dist/src/vtab/memory/layer/alter-column.d.ts.map +1 -0
- package/dist/src/vtab/memory/layer/alter-column.js +214 -0
- package/dist/src/vtab/memory/layer/alter-column.js.map +1 -0
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +4 -3
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/interface.d.ts +2 -2
- package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +176 -25
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +569 -558
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.js +32 -5
- package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +101 -15
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +133 -45
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +16 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +64 -3
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +11 -6
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/module.d.ts +77 -23
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +9 -2
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js +1 -1
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/util/working-table-iterable.d.ts.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CastNode } from '../nodes/scalar.js';
|
|
2
|
-
import {
|
|
3
|
-
import { NULL_TYPE } from '../../types/builtin-types.js';
|
|
2
|
+
import { comparisonGroupCoercions, comparisonGroupIndices, crossTypeCoercion } from '../../types/comparison-coercion.js';
|
|
4
3
|
/**
|
|
5
4
|
* Plan-build cross-type coercion for comparison sites. Every construct that
|
|
6
5
|
* compares operands — `=` and friends, BETWEEN, IN value lists, simple CASE,
|
|
@@ -8,103 +7,48 @@ import { NULL_TYPE } from '../../types/builtin-types.js';
|
|
|
8
7
|
* ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}) —
|
|
9
8
|
* reconciles its operands through this one module so none of them can drift
|
|
10
9
|
* from the others.
|
|
10
|
+
*
|
|
11
|
+
* This file owns only the *rewrite*: which operand gets wrapped in a synthetic
|
|
12
|
+
* `CastNode`. The decision of which operand converts and to what lives in
|
|
13
|
+
* `types/comparison-coercion.ts`, shared with the emit-time consumer
|
|
14
|
+
* (`runtime/emit/operand-comparator.ts` `makeComparisonGroup`) that serves the
|
|
15
|
+
* builtins which return one of their arguments and so cannot be rewritten here.
|
|
11
16
|
*/
|
|
12
17
|
/**
|
|
13
18
|
* Reconcile operands of a comparison whose plan-time types cannot be compared
|
|
14
19
|
* meaningfully as-is, by wrapping one side in a synthetic CastNode.
|
|
15
20
|
* Returns `[left, right]` — possibly with one side replaced by a CastNode.
|
|
16
21
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* 1. **Object-physical vs anything else.** JSON is the engine's only logical type
|
|
20
|
-
* whose `physicalType` is `PhysicalType.OBJECT`: its runtime values are native
|
|
21
|
-
* JS objects/arrays, which `compareSqlValuesFast` short-circuits against any
|
|
22
|
-
* other storage class — so `json_col = '{"a":1}'` was unconditionally false,
|
|
23
|
-
* even for byte-identical text. The non-object side is cast to the object
|
|
24
|
-
* side's type, never the reverse: casting the JSON side to text would make
|
|
25
|
-
* equality depend on spelling and put `=` out of step with the index, which
|
|
26
|
-
* compares structurally.
|
|
27
|
-
*
|
|
28
|
-
* The gate is deliberately `physicalType === OBJECT`, **not**
|
|
29
|
-
* `semanticOrdering`. DATE/TIME/DATETIME/TIMESPAN also carry semantic ordering
|
|
30
|
-
* but are physically text, and the runtime's `tryTemporalComparison` already
|
|
31
|
-
* reconciles them; routing them through a cast would change behavior for no
|
|
32
|
-
* gain.
|
|
33
|
-
*
|
|
34
|
-
* A cast to JSON is lenient (see `runtime/emit/cast.ts`): text that does not
|
|
35
|
-
* parse comes back unchanged, so `json_col = 'not json'` is false rather than
|
|
36
|
-
* an error. Note the consequence for JSON *string scalars*, which are stored
|
|
37
|
-
* as plain JS strings: a column holding `"hello"` matches BOTH the SQL literal
|
|
38
|
-
* `'"hello"'` (parses to the JSON string `hello`) and the bare `'hello'` (does
|
|
39
|
-
* not parse, falls back to the raw string `hello`, which `JSON_TYPE.compare`
|
|
40
|
-
* then compares as text). Only the first form generalizes — `'[1,2]'` matches
|
|
41
|
-
* the JSON array while a bare `[1,2]` is not SQL text at all.
|
|
42
|
-
*
|
|
43
|
-
* 2. **Numeric vs textual.** The textual operand is cast to the numeric side's
|
|
44
|
-
* type name (e.g. 'INTEGER' or 'REAL') so the runtime can take the fast path.
|
|
22
|
+
* See {@link crossTypeCoercion} for the rule (object-physical vs anything else,
|
|
23
|
+
* then numeric vs textual) and why each side is chosen.
|
|
45
24
|
*/
|
|
46
25
|
export function insertCrossTypeCoercion(scope, left, right) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const leftObject = leftLogical.physicalType === PhysicalType.OBJECT;
|
|
50
|
-
const rightObject = rightLogical.physicalType === PhysicalType.OBJECT;
|
|
51
|
-
// NOTE: two object-physical operands of DIFFERENT logical types fall through both
|
|
52
|
-
// arms onto the generic runtime path. Unreachable while JSON is the only
|
|
53
|
-
// PhysicalType.OBJECT type; adding a second one means deciding which side converts.
|
|
54
|
-
// Exactly one side is object-physical. A NULL-typed operand is left alone: the
|
|
55
|
-
// comparison is UNKNOWN regardless, so the cast would only add a runtime hop.
|
|
56
|
-
if (leftObject !== rightObject) {
|
|
57
|
-
if (leftObject && rightLogical !== NULL_TYPE) {
|
|
58
|
-
return [left, wrapInCast(scope, right, leftLogical.name)];
|
|
59
|
-
}
|
|
60
|
-
if (rightObject && leftLogical !== NULL_TYPE) {
|
|
61
|
-
return [wrapInCast(scope, left, rightLogical.name), right];
|
|
62
|
-
}
|
|
26
|
+
const coercion = crossTypeCoercion(left.getType().logicalType, right.getType().logicalType);
|
|
27
|
+
if (!coercion)
|
|
63
28
|
return [left, right];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const leftTextual = !!leftLogical.isTextual;
|
|
68
|
-
const rightTextual = !!rightLogical.isTextual;
|
|
69
|
-
if (leftNumeric && rightTextual) {
|
|
70
|
-
// Wrap right (textual) in a cast to the left's numeric type
|
|
71
|
-
return [left, wrapInCast(scope, right, leftLogical.name)];
|
|
72
|
-
}
|
|
73
|
-
if (rightNumeric && leftTextual) {
|
|
74
|
-
// Wrap left (textual) in a cast to the right's numeric type
|
|
75
|
-
return [wrapInCast(scope, left, rightLogical.name), right];
|
|
76
|
-
}
|
|
77
|
-
return [left, right];
|
|
29
|
+
return coercion.side === 'left'
|
|
30
|
+
? [wrapInCast(scope, left, coercion.target.name), right]
|
|
31
|
+
: [left, wrapInCast(scope, right, coercion.target.name)];
|
|
78
32
|
}
|
|
79
33
|
/**
|
|
80
|
-
* Apply
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* never been applied to either site (`int_col in ('1')` is false today for the same
|
|
87
|
-
* underlying reason), and turning it on here would change unrelated behavior; that
|
|
88
|
-
* case is tracked by `bug-numeric-text-coercion-skips-in-and-case`. Note `=` and
|
|
89
|
-
* BETWEEN DO apply it, so those two forms currently disagree with IN / simple CASE
|
|
90
|
-
* on a numeric column compared against a numeric-looking string.
|
|
91
|
-
*
|
|
92
|
-
* The probe is shared by every value, so it is wrapped at most once — if any value
|
|
93
|
-
* is object-physical while the probe is not, the probe is cast first and the values
|
|
94
|
-
* are then reconciled against it.
|
|
34
|
+
* Apply {@link comparisonGroupCoercions} across the one-probe-against-many-values
|
|
35
|
+
* shape shared by an IN value list, a simple CASE and a scalar builtin's
|
|
36
|
+
* comparison group, so `json_col in ('{"a":1}')`, `int_col in ('1')` and
|
|
37
|
+
* `case int_col when '1' …` all agree with the `=` spelling of the same
|
|
38
|
+
* comparison. See that function for the probe-vs-value asymmetry and the one
|
|
39
|
+
* documented gap it leaves.
|
|
95
40
|
*/
|
|
96
|
-
export function
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return [coercedProbe, values.map(val => insertCrossTypeCoercion(scope, coercedProbe, val)[1])];
|
|
41
|
+
export function coerceComparisonSet(scope, probe, values) {
|
|
42
|
+
const nodes = [probe, ...values];
|
|
43
|
+
const targets = comparisonGroupCoercions(nodes.map(node => node.getType().logicalType));
|
|
44
|
+
const coerced = nodes.map((node, i) => {
|
|
45
|
+
const target = targets[i];
|
|
46
|
+
return target ? wrapInCast(scope, node, target.name) : node;
|
|
47
|
+
});
|
|
48
|
+
return [coerced[0], coerced.slice(1)];
|
|
105
49
|
}
|
|
106
50
|
/**
|
|
107
|
-
* Apply {@link
|
|
51
|
+
* Apply {@link coerceComparisonSet} across the argument positions a scalar
|
|
108
52
|
* function declares as one comparison group
|
|
109
53
|
* ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}),
|
|
110
54
|
* so `nullif(json_col, '{"a":1}')` reconciles its operands exactly as
|
|
@@ -112,24 +56,31 @@ export function coerceObjectPhysicalSet(scope, probe, values) {
|
|
|
112
56
|
* the rest the value-list role; positions outside the argument list are ignored
|
|
113
57
|
* (defensive — a well-formed declaration never names one). Mutates `args` in
|
|
114
58
|
* place, replacing coerced members with their CastNode wrappers.
|
|
59
|
+
*
|
|
60
|
+
* NOT for a function that returns one of its arguments verbatim
|
|
61
|
+
* ({@link import('../../schema/function.js').BaseFunctionSchema.returnsArg}):
|
|
62
|
+
* replacing the argument replaces the *returned value* too. Those go through
|
|
63
|
+
* `makeComparisonGroup` at emit time instead.
|
|
115
64
|
*/
|
|
116
65
|
export function coerceComparisonGroup(scope, comparesArgs, args) {
|
|
117
|
-
const indices = comparesArgs
|
|
118
|
-
? args.map((_, i) => i)
|
|
119
|
-
: comparesArgs.filter(i => i >= 0 && i < args.length);
|
|
66
|
+
const indices = comparisonGroupIndices(comparesArgs, args.length);
|
|
120
67
|
if (indices.length < 2)
|
|
121
68
|
return;
|
|
122
69
|
const [probeIdx, ...valueIdx] = indices;
|
|
123
|
-
const [probe, values] =
|
|
70
|
+
const [probe, values] = coerceComparisonSet(scope, args[probeIdx], valueIdx.map(i => args[i]));
|
|
124
71
|
args[probeIdx] = probe;
|
|
125
72
|
valueIdx.forEach((argIdx, j) => { args[argIdx] = values[j]; });
|
|
126
73
|
}
|
|
127
74
|
/** Create a synthetic CastNode wrapping `operand` with the given target type name. */
|
|
128
75
|
export function wrapInCast(scope, operand, targetType) {
|
|
129
|
-
// Synthesise
|
|
76
|
+
// Synthesise an AST.CastExpr. `targetType` is the only field CastNode itself
|
|
77
|
+
// reads, but `formatExpression` renders a node from its AST rather than from
|
|
78
|
+
// its children — a `literal null` placeholder here made every coerced operand
|
|
79
|
+
// print as `cast(null as integer)` in EXPLAIN while the real operand child was
|
|
80
|
+
// intact. Carrying the operand's own AST keeps the rendering truthful.
|
|
130
81
|
const syntheticExpr = {
|
|
131
82
|
type: 'cast',
|
|
132
|
-
expr:
|
|
83
|
+
expr: operand.expression,
|
|
133
84
|
targetType,
|
|
134
85
|
};
|
|
135
86
|
return new CastNode(scope, syntheticExpr, operand);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coercion.js","sourceRoot":"","sources":["../../../../src/planner/building/coercion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"coercion.js","sourceRoot":"","sources":["../../../../src/planner/building/coercion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,E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":3,"file":"constraint-builder.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"constraint-builder.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,SAAS,EAAE,EAC1B,aAAa,EAAE,SAAS,EAAE,EAC1B,kBAAkB,EAAE,aAAa,EACjC,iBAAiB,GAAE,SAAS,EAAO;AACnC;;;;;GAKG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM,GAC7D,eAAe,EAAE,CA4KnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,SAAS,EAAE,EAC1B,iBAAiB,GAAE,SAAS,EAAO;AACnC;;;;;;;;GAQG;AACH,sBAAsB,CAAC,EAAE,KAAK,GAC7B,kBAAkB,EAAE,CAqDtB"}
|
|
@@ -7,6 +7,7 @@ import { TableReferenceNode } from '../nodes/reference.js';
|
|
|
7
7
|
import { validateDeterministicConstraint } from '../validation/determinism-validator.js';
|
|
8
8
|
import { columnSchemaToScalarType } from '../type-utils.js';
|
|
9
9
|
import { stripSelfQualifierInCheckExpression } from '../../schema/rename-rewriter.js';
|
|
10
|
+
import { buildColumnSourceResolver } from '../../schema/column-source-resolver.js';
|
|
10
11
|
import { cloneExpr } from '../mutation/scope-transform.js';
|
|
11
12
|
/**
|
|
12
13
|
* Determines if a constraint should be checked for the given operation
|
|
@@ -45,7 +46,7 @@ additionalConstraints = []) {
|
|
|
45
46
|
// Filter constraints by operation (the table's own plus any threaded extras)
|
|
46
47
|
const applicableConstraints = [...tableSchema.checkConstraints, ...additionalConstraints]
|
|
47
48
|
.filter(constraint => shouldCheckConstraint(constraint, operation));
|
|
48
|
-
const resolveColumnInSource = (
|
|
49
|
+
const resolveColumnInSource = buildColumnSourceResolver(ctx.schemaManager);
|
|
49
50
|
// Build expression nodes for each constraint
|
|
50
51
|
return applicableConstraints.map(constraint => {
|
|
51
52
|
// Create scope with OLD/NEW column access for constraint evaluation
|
|
@@ -115,10 +116,13 @@ additionalConstraints = []) {
|
|
|
115
116
|
ctx.schemaManager.setCurrentSchema(tableSchema.schemaName);
|
|
116
117
|
}
|
|
117
118
|
try {
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
// The search path is already narrowed to the table's own schema by
|
|
120
|
+
// `schemaAuthoredContext` (building/schema-authored-context.ts) — the ONE place that
|
|
121
|
+
// decides it for every schema-authored expression kind. Every caller reaches here
|
|
122
|
+
// through a context derived from it (`core/derived-row-validator.ts` included), so
|
|
123
|
+
// do not re-narrow: a second copy is how the CHECK and the column DEFAULT on one
|
|
124
|
+
// table drifted apart in the first place.
|
|
125
|
+
const constraintCtx = { ...ctx, scope: constraintScope };
|
|
122
126
|
// Fold table-qualified self-references (`check (t.qty > 0)`) to the bare
|
|
123
127
|
// column form the row-context scope registers. Done as an AST rewrite on a
|
|
124
128
|
// clone (never the stored constraint) rather than by seeding `<table>.<col>`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-builder.js","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,mCAAmC,
|
|
1
|
+
{"version":3,"file":"constraint-builder.js","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MA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,EAAE,CACtC,IAAI,mBAAmB,CAAC,CAAC,EAAE,GAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CACzE,CAAC;YACJ,CAAC;YACD,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAC/C,IAAI,mBAAmB,CAAC,CAAC,EAAE,GAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CACzE,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,EAAE,WAA6B,CAAmB,CAAC;QAClG,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,WAA6B,EAAE,WAAW,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,IAAoB;IAChD,MAAM,KAAK,GAAe,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QACvB,IAAI,CAAC,YAAY,kBAAkB,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-assertion.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/create-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-assertion.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/create-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAkFxE,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,CAAC,mBAAmB,GAAG,mBAAmB,CAOjH"}
|
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
import { CreateAssertionNode } from '../nodes/create-assertion-node.js';
|
|
2
|
+
import { buildAssertionViolationSql } from '../../schema/assertion.js';
|
|
3
|
+
import { buildSelectStmt } from './select.js';
|
|
4
|
+
import { Parser } from '../../parser/parser.js';
|
|
5
|
+
import { QuereusError } from '../../common/errors.js';
|
|
6
|
+
import { StatusCode } from '../../common/types.js';
|
|
7
|
+
import { storedBodyContext } from '../stored-body-context.js';
|
|
8
|
+
/**
|
|
9
|
+
* Plans the assertion's violation query so a body that cannot resolve fails the
|
|
10
|
+
* `CREATE ASSERTION` itself.
|
|
11
|
+
*
|
|
12
|
+
* Without this gate the create succeeds and the failure surfaces at COMMIT —
|
|
13
|
+
* `AssertionEvaluator` recompiles EVERY live assertion on any commit that
|
|
14
|
+
* touched any table, so one unresolvable body blocks writes to the whole
|
|
15
|
+
* database, at some unrelated later statement, with an error that never names
|
|
16
|
+
* the assertion.
|
|
17
|
+
*
|
|
18
|
+
* Strictness deliberately matches `CREATE VIEW`, which plans its body at build
|
|
19
|
+
* time via {@link planViewBody}: whatever the planner rejects for a view body
|
|
20
|
+
* (missing table, missing column, unknown function) is rejected here too, and
|
|
21
|
+
* nothing more (a type mismatch such as `x + 'abc'` is not a planner error and
|
|
22
|
+
* still creates).
|
|
23
|
+
*
|
|
24
|
+
* What is planned is the derived violation SQL round-tripped through
|
|
25
|
+
* {@link buildAssertionViolationSql} + the parser, NOT the CHECK expression
|
|
26
|
+
* directly. That text is exactly what the emitter stores and what the
|
|
27
|
+
* commit-time evaluator re-parses and re-plans, so validating it also covers a
|
|
28
|
+
* stringify/parse round trip that loses or mangles part of the expression —
|
|
29
|
+
* planning the AST in hand would miss that.
|
|
30
|
+
*
|
|
31
|
+
* Build time, not emit time: statements execute one at a time (`apply schema`
|
|
32
|
+
* runs each migration statement through its own `_execWithinTransaction`), so
|
|
33
|
+
* the catalog left by every preceding statement is visible here, and a
|
|
34
|
+
* rejection happens before any transaction start or catalog mutation — a clean
|
|
35
|
+
* no-op.
|
|
36
|
+
*
|
|
37
|
+
* NOTE: no assertion-hoist suppression is needed (unlike the emitter's
|
|
38
|
+
* dependency discovery, which calls `withSuppressedAssertionHoist`). Hoisting
|
|
39
|
+
* is an optimizer pass; this path builds only, and the optimizer never runs
|
|
40
|
+
* over the body here.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: `CREATE ASSERTION` now plans its body twice — once here (build only)
|
|
43
|
+
* and once in `emitCreateAssertion` for dependency discovery (build +
|
|
44
|
+
* optimize). Immaterial today: creates are rare and the body is one small
|
|
45
|
+
* query. If assertion creates ever show up hot (a large declarative schema
|
|
46
|
+
* applied repeatedly), hang the node planned here on `CreateAssertionNode` and
|
|
47
|
+
* have the emitter walk that instead of re-planning.
|
|
48
|
+
*/
|
|
49
|
+
function planAssertionBody(ctx, schemaName, assertionName, check) {
|
|
50
|
+
// Unqualified names in a stored body resolve against the assertion's own
|
|
51
|
+
// schema first — the same home-schema rule `planViewBody` applies.
|
|
52
|
+
const bodyCtx = storedBodyContext(ctx, schemaName);
|
|
53
|
+
try {
|
|
54
|
+
const violationSql = buildAssertionViolationSql(check);
|
|
55
|
+
const parsed = new Parser().parse(violationSql);
|
|
56
|
+
if (parsed.type !== 'select') {
|
|
57
|
+
throw new QuereusError(`violation query rendered as '${parsed.type}', expected a select`, StatusCode.INTERNAL);
|
|
58
|
+
}
|
|
59
|
+
buildSelectStmt(bodyCtx, parsed);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
const cause = e instanceof Error ? e : undefined;
|
|
63
|
+
// Keep the underlying text — it is what names the missing table / column /
|
|
64
|
+
// function — and prefix the assertion so the user knows which one failed.
|
|
65
|
+
throw new QuereusError(`Cannot create assertion '${assertionName}': ${cause?.message ?? String(e)}`, e instanceof QuereusError ? e.code : StatusCode.ERROR, cause, check.loc?.start.line, check.loc?.start.column);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
2
68
|
export function buildCreateAssertionStmt(ctx, stmt) {
|
|
3
|
-
|
|
69
|
+
const sm = ctx.schemaManager;
|
|
70
|
+
// Canonical schemaName (see SchemaManager.canonicalSchemaName) — it becomes
|
|
71
|
+
// the assertion's stored home schema.
|
|
72
|
+
const schemaName = stmt.name.schema ? sm.canonicalSchemaName(stmt.name.schema) : sm.getCurrentSchemaName();
|
|
73
|
+
planAssertionBody(ctx, schemaName, stmt.name.name, stmt.check);
|
|
74
|
+
return new CreateAssertionNode(ctx.scope, schemaName, stmt.name.name, stmt.check);
|
|
4
75
|
}
|
|
5
76
|
//# sourceMappingURL=create-assertion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-assertion.js","sourceRoot":"","sources":["../../../../src/planner/building/create-assertion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-assertion.js","sourceRoot":"","sources":["../../../../src/planner/building/create-assertion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MA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,CAAC,KAAK,EACrD,KAAK,EACL,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EACrB,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CACvB,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAoB,EAAE,IAA6B;IAC3F,MAAM,EAAE,GAAG,GAAG,CAAC,aAAa,CAAC;IAC7B,4EAA4E;IAC5E,sCAAsC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC;IAC3G,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -8,8 +8,13 @@ import { type RelationalPlanNode } from '../nodes/plan-node.js';
|
|
|
8
8
|
* permanently — a view body re-evaluates on every reference, so a DML body
|
|
9
9
|
* would re-drive writes on every read, which is incoherent with view
|
|
10
10
|
* semantics. Mutations must be expressed in the query that *uses* the view.
|
|
11
|
+
*
|
|
12
|
+
* `homeSchemaName` — the schema the view/maintained table lands in. When given,
|
|
13
|
+
* the body plans under that schema's home path ({@link Database._homeSchemaPath})
|
|
14
|
+
* so unqualified names in the body resolve next to the object that owns them,
|
|
15
|
+
* not against the creating statement's search path.
|
|
11
16
|
*/
|
|
12
|
-
export declare function planViewBody(ctx: PlanningContext, viewName: string, body: AST.QueryExpr): RelationalPlanNode;
|
|
17
|
+
export declare function planViewBody(ctx: PlanningContext, viewName: string, body: AST.QueryExpr, homeSchemaName?: string): RelationalPlanNode;
|
|
13
18
|
/**
|
|
14
19
|
* Builds a plan node for CREATE VIEW statements.
|
|
15
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-view.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/create-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-view.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/create-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAKlF;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,kBAAkB,CA4BrI;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,CAAC,cAAc,GAAG,cAAc,CAuClG"}
|
|
@@ -4,14 +4,23 @@ import { buildSelectStmt, buildValuesStmt } from './select.js';
|
|
|
4
4
|
import { isRelationalNode } from '../nodes/plan-node.js';
|
|
5
5
|
import { QuereusError } from '../../common/errors.js';
|
|
6
6
|
import { StatusCode } from '../../common/types.js';
|
|
7
|
+
import { storedBodyContext } from '../stored-body-context.js';
|
|
7
8
|
/**
|
|
8
9
|
* Plan the view body for arity validation. SELECT and VALUES bodies build
|
|
9
10
|
* directly. DML bodies (INSERT/UPDATE/DELETE with RETURNING) are rejected
|
|
10
11
|
* permanently — a view body re-evaluates on every reference, so a DML body
|
|
11
12
|
* would re-drive writes on every read, which is incoherent with view
|
|
12
13
|
* semantics. Mutations must be expressed in the query that *uses* the view.
|
|
14
|
+
*
|
|
15
|
+
* `homeSchemaName` — the schema the view/maintained table lands in. When given,
|
|
16
|
+
* the body plans under that schema's home path ({@link Database._homeSchemaPath})
|
|
17
|
+
* so unqualified names in the body resolve next to the object that owns them,
|
|
18
|
+
* not against the creating statement's search path.
|
|
13
19
|
*/
|
|
14
|
-
export function planViewBody(ctx, viewName, body) {
|
|
20
|
+
export function planViewBody(ctx, viewName, body, homeSchemaName) {
|
|
21
|
+
if (homeSchemaName) {
|
|
22
|
+
ctx = storedBodyContext(ctx, homeSchemaName);
|
|
23
|
+
}
|
|
15
24
|
switch (body.type) {
|
|
16
25
|
case 'select': {
|
|
17
26
|
const planned = buildSelectStmt(ctx, body);
|
|
@@ -41,7 +50,7 @@ export function buildCreateViewStmt(ctx, stmt) {
|
|
|
41
50
|
// If an explicit column list was provided, validate that its arity matches the body's projection.
|
|
42
51
|
// Plan the body (read-only) so star-expansion and CTEs are resolved.
|
|
43
52
|
if (stmt.columns && stmt.columns.length > 0) {
|
|
44
|
-
const planned = planViewBody(ctx, viewName, stmt.select);
|
|
53
|
+
const planned = planViewBody(ctx, viewName, stmt.select, schemaName);
|
|
45
54
|
const bodyArity = planned.getAttributes().length;
|
|
46
55
|
if (stmt.columns.length !== bodyArity) {
|
|
47
56
|
throw new QuereusError(`View '${viewName}' has ${stmt.columns.length} declared columns but body produces ${bodyArity}`, StatusCode.ERROR);
|
|
@@ -50,7 +59,7 @@ export function buildCreateViewStmt(ctx, stmt) {
|
|
|
50
59
|
else {
|
|
51
60
|
// No explicit column list — still run the gate so a DML body is
|
|
52
61
|
// rejected at plan time rather than waiting until first reference.
|
|
53
|
-
planViewBody(ctx, viewName, stmt.select);
|
|
62
|
+
planViewBody(ctx, viewName, stmt.select, schemaName);
|
|
54
63
|
}
|
|
55
64
|
// The original SQL text is needed for the view definition
|
|
56
65
|
// Reconstruct it from the AST using the proper stringifier
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-view.js","sourceRoot":"","sources":["../../../../src/planner/building/create-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAA2B,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-view.js","sourceRoot":"","sources":["../../../../src/planner/building/create-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAA2B,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,GAAoB,EAAE,QAAgB,EAAE,IAAmB,EAAE,cAAuB;IAChH,IAAI,cAAc,EAAE,CAAC;QACpB,GAAG,GAAG,iBA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AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOhE,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,GAAG,CAAC,eAAe,GACvB,eAAe,CAYjB;
|
|
1
|
+
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/ddl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOhE,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,GAAG,CAAC,eAAe,GACvB,eAAe,CAYjB;AAyGD,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,GAAG,CAAC,eAAe,GACvB,eAAe,CAOjB"}
|
|
@@ -28,7 +28,12 @@ export function buildCreateTableStmt(context, stmt) {
|
|
|
28
28
|
*/
|
|
29
29
|
function raiseCreateMaintainedDiagnostics(context, stmt) {
|
|
30
30
|
const tableName = stmt.table.name;
|
|
31
|
-
|
|
31
|
+
// The body plans under the table's home-schema path (same landing rule as the
|
|
32
|
+
// CREATE TABLE emitter: explicit qualifier, else the current schema) so its
|
|
33
|
+
// unqualified source names resolve next to the maintained table.
|
|
34
|
+
const sm = context.db.schemaManager;
|
|
35
|
+
const homeSchemaName = stmt.table.schema ? sm.canonicalSchemaName(stmt.table.schema) : sm.getCurrentSchemaName();
|
|
36
|
+
const planned = planViewBody(context, tableName, stmt.maintained.select, homeSchemaName);
|
|
32
37
|
const bodyArity = planned.getAttributes().length;
|
|
33
38
|
if (bodyArity !== stmt.columns.length) {
|
|
34
39
|
throw new QuereusError(`cannot create maintained table '${tableName}': body produces ${bodyArity} columns but the table declares ${stmt.columns.length}`, StatusCode.ERROR, undefined, stmt.table.loc?.start.line, stmt.table.loc?.start.column);
|
|
@@ -45,7 +50,6 @@ function raiseCreateMaintainedDiagnostics(context, stmt) {
|
|
|
45
50
|
}
|
|
46
51
|
// Resolve the hosting module exactly as CREATE TABLE will (the `using`
|
|
47
52
|
// clause, else the session default) and require the backing-host capability.
|
|
48
|
-
const sm = context.db.schemaManager;
|
|
49
53
|
const moduleName = stmt.moduleName ?? sm.getDefaultVTabModuleName();
|
|
50
54
|
const moduleInfo = sm.getModule(moduleName);
|
|
51
55
|
if (!moduleInfo?.module) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddl.js","sourceRoot":"","sources":["../../../../src/planner/building/ddl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,UAAU,oBAAoB,CACnC,OAAwB,EACxB,IAAyB;IAEzB,gFAAgF;IAChF,+EAA+E;IAC/E,8EAA8E;IAC9E,8BAA8B,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrB,gCAAgC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,eAAe,CACzB,OAAO,CAAC,KAAK,EACb,IAAI,CACJ,CAAC;AACH,CAAC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oB,CAAC;QAC7C,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;KAC7F,CAAC;IACF,uBAAuB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAoF,MAAM,uBAAuB,CAAC;AASnI,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAoF,MAAM,uBAAuB,CAAC;AASnI,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAmB5E,wBAAgB,eAAe,CAC7B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,GAAG,CAAC,UAAU;AACpB;;;;;;;GAOG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM;AAC9D;;;;;;GAMG;AACH,UAAU,UAAQ,GACjB,QAAQ,CAmUV"}
|
|
@@ -22,10 +22,12 @@ import { validateReturningQualifiers } from '../validation/returning-qualifier-v
|
|
|
22
22
|
import { isCommittedSchemaRef } from './schema-resolution.js';
|
|
23
23
|
import { buildViewMutation } from './view-mutation-builder.js';
|
|
24
24
|
import { isMaintainedTable, maintainedTableViewLike } from '../../schema/derivation.js';
|
|
25
|
+
import { isViewSchema } from '../../schema/view.js';
|
|
25
26
|
import { validateReservedTags } from '../../schema/reserved-tags.js';
|
|
26
27
|
import { raiseStmtTagDiagnostics } from './tag-diagnostics.js';
|
|
27
28
|
import { buildWithContext } from './select-context.js';
|
|
28
29
|
import { resolveCteTarget, contextForCteTarget, resolveSubqueryTarget } from './dml-target.js';
|
|
30
|
+
import { schemaAuthoredContext } from './schema-authored-context.js';
|
|
29
31
|
export function buildDeleteStmt(ctx, stmt,
|
|
30
32
|
/**
|
|
31
33
|
* Extra row constraints to enforce alongside the table's own — already resolved
|
|
@@ -85,20 +87,21 @@ lensRouted = false) {
|
|
|
85
87
|
// hook then syncs the backing. See docs/materialized-views.md § Write boundary.
|
|
86
88
|
// Dispatch order is load-bearing: a maintained table (derivation-bearing)
|
|
87
89
|
// must hit the view-mutation rewrite, never the direct table write.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
// An unqualified target resolves through the schema search path, exactly as an
|
|
91
|
+
// unqualified read does (see `SchemaManager.findSchemaItem`).
|
|
92
|
+
const deleteTarget = ctx.schemaManager.findSchemaItem(stmt.table.name, stmt.table.schema, contextWithSchemaPath.schemaPath);
|
|
93
|
+
const deleteView = isViewSchema(deleteTarget) ? deleteTarget
|
|
94
|
+
: (isMaintainedTable(deleteTarget) ? maintainedTableViewLike(deleteTarget) : undefined);
|
|
91
95
|
if (deleteView) {
|
|
92
96
|
// Route through the view-mutation substrate (single-source = one base op).
|
|
93
97
|
return buildViewMutation(contextWithCTEs, deleteView, { op: 'delete', stmt });
|
|
94
98
|
}
|
|
95
99
|
const tableRetrieve = buildTableReference({ type: 'table', table: stmt.table }, contextWithCTEs);
|
|
96
100
|
const tableReference = tableRetrieve.tableRef; // Extract the actual TableReferenceNode
|
|
97
|
-
// Backstop on the RESOLVED table: the dispatch above
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
// view-mutation rewrite.
|
|
101
|
+
// Backstop on the RESOLVED table: the dispatch above and buildTableReference
|
|
102
|
+
// walk the same path today, so this should be unreachable — but they are two
|
|
103
|
+
// resolvers, and a direct write to a maintained table would corrupt derived
|
|
104
|
+
// contents. Keep the belt: route any that slips through to the same rewrite.
|
|
102
105
|
const deleteResolved = tableReference.tableSchema;
|
|
103
106
|
if (isMaintainedTable(deleteResolved)) {
|
|
104
107
|
return buildViewMutation(contextWithCTEs, maintainedTableViewLike(deleteResolved), { op: 'delete', stmt });
|
|
@@ -151,6 +154,16 @@ lensRouted = false) {
|
|
|
151
154
|
// Built off the CTE-aware context so `stmt.cteNodes` thread into the WHERE subquery
|
|
152
155
|
// builds — a CTE read there now resolves (closes the prior read gap).
|
|
153
156
|
const deleteCtx = { ...contextWithCTEs, scope: tableScope };
|
|
157
|
+
// Contexts for the table's OWN schema-authored SQL (`check on delete` constraints,
|
|
158
|
+
// parent-side FK probes). Derived once here rather than per call site; both clear the
|
|
159
|
+
// CTE namespace so none of that SQL can bind this statement's common table
|
|
160
|
+
// expressions — its own leading `with` clause or ones it inherited from an enclosing
|
|
161
|
+
// statement — and both narrow the schema path to the target's own schema.
|
|
162
|
+
// `schemaAuthoredDeleteCtx` keeps the table scope so `old.` still resolves;
|
|
163
|
+
// `schemaAuthoredCtx` matches the bare `ctx` the FK builder already took.
|
|
164
|
+
const targetSchemaName = tableReference.tableSchema.schemaName;
|
|
165
|
+
const schemaAuthoredDeleteCtx = schemaAuthoredContext(deleteCtx, targetSchemaName);
|
|
166
|
+
const schemaAuthoredCtx = schemaAuthoredContext(ctx, targetSchemaName);
|
|
154
167
|
if (stmt.where) {
|
|
155
168
|
const filterExpression = buildExpression(deleteCtx, stmt.where);
|
|
156
169
|
sourceNode = new FilterNode(deleteCtx.scope, sourceNode, filterExpression);
|
|
@@ -178,7 +191,7 @@ lensRouted = false) {
|
|
|
178
191
|
});
|
|
179
192
|
}
|
|
180
193
|
// Build constraint checks at plan time
|
|
181
|
-
const constraintChecks = buildConstraintChecks(
|
|
194
|
+
const constraintChecks = buildConstraintChecks(schemaAuthoredDeleteCtx, tableReference.tableSchema, RowOpFlag.DELETE, oldAttributes, newAttributes, flatRowDescriptor, contextAttributes, additionalConstraints);
|
|
182
195
|
// Build parent-side FK constraint checks if foreign_keys pragma is enabled.
|
|
183
196
|
// Skipped entirely when the batchability gate admits the statement — the
|
|
184
197
|
// runtime DML executor then enforces every inbound RESTRICT FK with ONE
|
|
@@ -188,7 +201,7 @@ lensRouted = false) {
|
|
|
188
201
|
// ABORT default (matching the `undefined` onConflict on the DmlExecutorNode).
|
|
189
202
|
if (ctx.db.options.getBooleanOption('foreign_keys')
|
|
190
203
|
&& getBatchableRestrictFks(ctx.schemaManager, tableReference.tableSchema, 'delete', undefined, lensRouted) === undefined) {
|
|
191
|
-
const parentFKChecks = buildParentSideFKChecks(
|
|
204
|
+
const parentFKChecks = buildParentSideFKChecks(schemaAuthoredCtx, tableReference.tableSchema, RowOpFlag.DELETE, oldAttributes, newAttributes, contextAttributes);
|
|
192
205
|
constraintChecks.push(...parentFKChecks);
|
|
193
206
|
}
|
|
194
207
|
// Mirror INSERT/UPDATE wiring: the DML prep node (DeleteNode) expands the
|