@quereus/quereus 4.11.0 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/common/type-inference.d.ts +12 -6
- package/dist/src/common/type-inference.d.ts.map +1 -1
- package/dist/src/common/type-inference.js +12 -24
- package/dist/src/common/type-inference.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +7 -5
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +4 -3
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +4 -3
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.d.ts +1 -3
- package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.js +1 -11
- package/dist/src/core/database-materialized-views-analysis.js.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 +12 -10
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +13 -2
- 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 +14 -2
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/param.d.ts +9 -0
- package/dist/src/core/param.d.ts.map +1 -1
- package/dist/src/core/param.js +21 -1
- package/dist/src/core/param.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +38 -15
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
- package/dist/src/func/builtins/aggregate.js +7 -2
- 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 +27 -11
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +8 -3
- 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 +9 -29
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
- package/dist/src/func/builtins/json-tvf.js +14 -7
- package/dist/src/func/builtins/json-tvf.js.map +1 -1
- package/dist/src/func/builtins/return-types.d.ts +29 -0
- package/dist/src/func/builtins/return-types.d.ts.map +1 -1
- package/dist/src/func/builtins/return-types.js +4 -1
- package/dist/src/func/builtins/return-types.js.map +1 -1
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +22 -67
- 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 +26 -16
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +8 -5
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/visitor.d.ts +16 -0
- package/dist/src/parser/visitor.d.ts.map +1 -1
- package/dist/src/parser/visitor.js +16 -0
- package/dist/src/parser/visitor.js.map +1 -1
- package/dist/src/planner/analysis/assertion-plan.d.ts +33 -0
- package/dist/src/planner/analysis/assertion-plan.d.ts.map +1 -0
- package/dist/src/planner/analysis/assertion-plan.js +39 -0
- package/dist/src/planner/analysis/assertion-plan.js.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts +55 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.js +57 -0
- package/dist/src/planner/analysis/binary-operator-class.js.map +1 -0
- package/dist/src/planner/analysis/binding-extractor.d.ts +9 -3
- package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/binding-extractor.js +11 -16
- package/dist/src/planner/analysis/binding-extractor.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +19 -6
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/check-extraction.d.ts +1 -7
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
- package/dist/src/planner/analysis/check-extraction.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +17 -0
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +17 -5
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +18 -18
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts +11 -7
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +11 -7
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +1 -1
- package/dist/src/planner/analysis/equi-correlation.js +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.js +0 -2
- package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
- package/dist/src/planner/analysis/key-filter.d.ts.map +1 -1
- package/dist/src/planner/analysis/key-filter.js +2 -3
- package/dist/src/planner/analysis/key-filter.js.map +1 -1
- package/dist/src/planner/analysis/relation-key.d.ts +104 -0
- package/dist/src/planner/analysis/relation-key.d.ts.map +1 -0
- package/dist/src/planner/analysis/relation-key.js +121 -0
- package/dist/src/planner/analysis/relation-key.js.map +1 -0
- package/dist/src/planner/analysis/scalar-param-usage.d.ts.map +1 -1
- package/dist/src/planner/analysis/scalar-param-usage.js +12 -4
- package/dist/src/planner/analysis/scalar-param-usage.js.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.d.ts +9 -3
- package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.js +22 -8
- package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +31 -23
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/analyze.d.ts.map +1 -1
- package/dist/src/planner/building/analyze.js +21 -0
- package/dist/src/planner/building/analyze.js.map +1 -1
- package/dist/src/planner/building/block.d.ts.map +1 -1
- package/dist/src/planner/building/block.js +222 -82
- package/dist/src/planner/building/block.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +5 -3
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/delete.js +1 -1
- 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 +11 -3
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts +16 -6
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +43 -20
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/generated-column-scope.d.ts +58 -0
- package/dist/src/planner/building/generated-column-scope.d.ts.map +1 -0
- package/dist/src/planner/building/generated-column-scope.js +117 -0
- package/dist/src/planner/building/generated-column-scope.js.map +1 -0
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +20 -28
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +73 -132
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +405 -81
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +37 -8
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +8 -9
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-ordinal.d.ts +6 -0
- package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
- package/dist/src/planner/building/select-ordinal.js +1 -1
- package/dist/src/planner/building/select-ordinal.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts +2 -2
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +82 -101
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +78 -33
- 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 +14 -8
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +329 -14
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts +6 -0
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +52 -3
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
- package/dist/src/planner/cache/correlation-detector.js +44 -17
- package/dist/src/planner/cache/correlation-detector.js.map +1 -1
- package/dist/src/planner/framework/physical-utils.d.ts +6 -0
- package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
- package/dist/src/planner/framework/physical-utils.js +6 -0
- package/dist/src/planner/framework/physical-utils.js.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.d.ts +123 -0
- package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +362 -5
- package/dist/src/planner/mutation/lens-enforcement.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/nodes/alter-table-node.d.ts +15 -11
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.js +5 -0
- package/dist/src/planner/nodes/alter-table-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 +7 -0
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +16 -0
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
- package/dist/src/planner/nodes/pragma.js +5 -2
- package/dist/src/planner/nodes/pragma.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +9 -1
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +117 -91
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sequence-node.d.ts +50 -0
- package/dist/src/planner/nodes/sequence-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/sequence-node.js +96 -0
- package/dist/src/planner/nodes/sequence-node.js.map +1 -0
- package/dist/src/planner/nodes/values-node.d.ts +8 -0
- package/dist/src/planner/nodes/values-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/values-node.js +29 -6
- package/dist/src/planner/nodes/values-node.js.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts +43 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.js +27 -6
- package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +33 -4
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +80 -36
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +38 -1
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- 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 +8 -3
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +18 -12
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +4 -3
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.js +6 -0
- package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
- package/dist/src/planner/scopes/param.d.ts.map +1 -1
- package/dist/src/planner/scopes/param.js +10 -5
- package/dist/src/planner/scopes/param.js.map +1 -1
- package/dist/src/planner/util/ind-utils.d.ts +25 -8
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +53 -10
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +7 -7
- package/dist/src/planner/util/key-utils.js +9 -9
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/runtime/delta-executor.d.ts.map +1 -1
- package/dist/src/runtime/delta-executor.js +7 -2
- package/dist/src/runtime/delta-executor.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +50 -15
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +2 -43
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.js +2 -53
- package/dist/src/runtime/emit/alter-schema-event.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +59 -24
- 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 +7 -0
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.js +2 -3
- package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts +5 -0
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +22 -22
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/block.d.ts.map +1 -1
- package/dist/src/runtime/emit/block.js +9 -3
- package/dist/src/runtime/emit/block.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +5 -6
- 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 +71 -70
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-index.js +8 -3
- package/dist/src/runtime/emit/create-index.js.map +1 -1
- package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-table.js +20 -10
- package/dist/src/runtime/emit/create-table.js.map +1 -1
- package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-view.js +51 -44
- package/dist/src/runtime/emit/create-view.js.map +1 -1
- package/dist/src/runtime/emit/ddl-event-scope.d.ts +71 -0
- package/dist/src/runtime/emit/ddl-event-scope.d.ts.map +1 -0
- package/dist/src/runtime/emit/ddl-event-scope.js +80 -0
- package/dist/src/runtime/emit/ddl-event-scope.js.map +1 -0
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +23 -23
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +23 -17
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +7 -2
- 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 +16 -10
- 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 +50 -43
- package/dist/src/runtime/emit/drop-view.js.map +1 -1
- package/dist/src/runtime/emit/insert.d.ts.map +1 -1
- package/dist/src/runtime/emit/insert.js +2 -1
- package/dist/src/runtime/emit/insert.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view.js +87 -67
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts +8 -0
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +128 -25
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/sequence.d.ts +17 -0
- package/dist/src/runtime/emit/sequence.d.ts.map +1 -0
- package/dist/src/runtime/emit/sequence.js +40 -0
- package/dist/src/runtime/emit/sequence.js.map +1 -0
- package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-object-tags.js +40 -32
- package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.js +3 -2
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/update.js +3 -3
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
- package/dist/src/runtime/emit/view-mutation.js +45 -3
- package/dist/src/runtime/emit/view-mutation.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +9 -10
- package/dist/src/runtime/foreign-key-actions.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +3 -2
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/row-constraints.d.ts +14 -8
- package/dist/src/runtime/row-constraints.d.ts.map +1 -1
- package/dist/src/runtime/row-constraints.js +41 -15
- package/dist/src/runtime/row-constraints.js.map +1 -1
- package/dist/src/runtime/strict-representation.d.ts +11 -6
- package/dist/src/runtime/strict-representation.d.ts.map +1 -1
- package/dist/src/runtime/strict-representation.js +1 -44
- package/dist/src/runtime/strict-representation.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +25 -2
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/catalog-rendering.d.ts +38 -0
- package/dist/src/schema/catalog-rendering.d.ts.map +1 -0
- package/dist/src/schema/catalog-rendering.js +171 -0
- package/dist/src/schema/catalog-rendering.js.map +1 -0
- package/dist/src/schema/catalog.d.ts +69 -3
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +124 -19
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/column-source-resolver.d.ts +9 -5
- package/dist/src/schema/column-source-resolver.d.ts.map +1 -1
- package/dist/src/schema/column-source-resolver.js +9 -5
- package/dist/src/schema/column-source-resolver.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts +13 -10
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +45 -17
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/declared-schema-manager.d.ts +50 -0
- package/dist/src/schema/declared-schema-manager.d.ts.map +1 -1
- package/dist/src/schema/declared-schema-manager.js +52 -0
- package/dist/src/schema/declared-schema-manager.js.map +1 -1
- package/dist/src/schema/expr-scope/frame.d.ts +65 -0
- package/dist/src/schema/expr-scope/frame.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/frame.js +104 -0
- package/dist/src/schema/expr-scope/frame.js.map +1 -0
- package/dist/src/schema/expr-scope/walk.d.ts +40 -0
- package/dist/src/schema/expr-scope/walk.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/walk.js +260 -0
- package/dist/src/schema/expr-scope/walk.js.map +1 -0
- package/dist/src/schema/generated-column-refs.d.ts +41 -0
- package/dist/src/schema/generated-column-refs.d.ts.map +1 -0
- package/dist/src/schema/generated-column-refs.js +124 -0
- package/dist/src/schema/generated-column-refs.js.map +1 -0
- package/dist/src/schema/lens-ack.d.ts.map +1 -1
- package/dist/src/schema/lens-ack.js +5 -2
- package/dist/src/schema/lens-ack.js.map +1 -1
- package/dist/src/schema/lens-compiler.d.ts.map +1 -1
- package/dist/src/schema/lens-compiler.js +9 -1
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts +7 -2
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +105 -11
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/lens.d.ts +12 -0
- package/dist/src/schema/lens.d.ts.map +1 -1
- package/dist/src/schema/lens.js +10 -0
- package/dist/src/schema/lens.js.map +1 -1
- package/dist/src/schema/manager.d.ts +35 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +125 -26
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.d.ts +16 -10
- package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.js +30 -213
- package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +4 -3
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +4 -3
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +54 -6
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +108 -42
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/schema-hasher.d.ts +12 -0
- package/dist/src/schema/schema-hasher.d.ts.map +1 -1
- package/dist/src/schema/schema-hasher.js +28 -10
- package/dist/src/schema/schema-hasher.js.map +1 -1
- package/dist/src/schema/table.d.ts +74 -19
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +133 -71
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/types/comparison-coercion.d.ts +5 -1
- package/dist/src/types/comparison-coercion.d.ts.map +1 -1
- package/dist/src/types/comparison-coercion.js +21 -5
- package/dist/src/types/comparison-coercion.js.map +1 -1
- package/dist/src/types/representation.d.ts +65 -0
- package/dist/src/types/representation.d.ts.map +1 -0
- package/dist/src/types/representation.js +63 -0
- package/dist/src/types/representation.js.map +1 -0
- package/dist/src/types/validation.d.ts +76 -22
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +110 -31
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +10 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +16 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/capabilities.d.ts +72 -4
- package/dist/src/vtab/capabilities.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +17 -13
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/module.d.ts +13 -7
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/src/planner/nodes/array-index-node.d.ts +0 -22
- package/dist/src/planner/nodes/array-index-node.d.ts.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js +0 -41
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/runtime/emit/array-index.d.ts +0 -5
- package/dist/src/runtime/emit/array-index.d.ts.map +0 -1
- package/dist/src/runtime/emit/array-index.js +0 -22
- package/dist/src/runtime/emit/array-index.js.map +0 -1
|
@@ -6,7 +6,7 @@ import { buildInsertStmt } from './insert.js';
|
|
|
6
6
|
import { buildUpdateStmt } from './update.js';
|
|
7
7
|
import { buildDeleteStmt } from './delete.js';
|
|
8
8
|
import { buildExpression } from './expression.js';
|
|
9
|
-
import { QuereusError } from '../../common/errors.js';
|
|
9
|
+
import { QuereusError, quereusError } from '../../common/errors.js';
|
|
10
10
|
import { StatusCode } from '../../common/types.js';
|
|
11
11
|
import { RegisteredScope } from '../scopes/registered.js';
|
|
12
12
|
import { ColumnReferenceNode } from '../nodes/reference.js';
|
|
@@ -16,6 +16,11 @@ import { ColumnReferenceNode } from '../nodes/reference.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export function buildWithClause(ctx, withClause) {
|
|
18
18
|
const cteNodes = new Map();
|
|
19
|
+
// Is this a statement's OWN leading clause? `buildBlock` marks those (by clause
|
|
20
|
+
// object identity) on the context it builds every top-level statement under; a
|
|
21
|
+
// context that never passed through `buildBlock` marks nothing, which is the
|
|
22
|
+
// conservative answer. Absent the mark, a data-modifying member is rejected below.
|
|
23
|
+
const isTopLevelClause = ctx.topLevelWithClauses?.has(withClause) ?? false;
|
|
19
24
|
// Check for duplicate CTE names
|
|
20
25
|
const cteNames = new Set();
|
|
21
26
|
for (const cte of withClause.ctes) {
|
|
@@ -24,6 +29,9 @@ export function buildWithClause(ctx, withClause) {
|
|
|
24
29
|
throw new QuereusError(`Duplicate CTE name '${cte.name}' in WITH clause`, StatusCode.ERROR);
|
|
25
30
|
}
|
|
26
31
|
cteNames.add(cteName);
|
|
32
|
+
if (!isTopLevelClause && isDataModifyingCte(cte)) {
|
|
33
|
+
rejectNestedDataModifyingCte(cte);
|
|
34
|
+
}
|
|
27
35
|
}
|
|
28
36
|
// Build each CTE in order
|
|
29
37
|
// Note: For recursive CTEs, we may need to handle forward references
|
|
@@ -33,6 +41,28 @@ export function buildWithClause(ctx, withClause) {
|
|
|
33
41
|
}
|
|
34
42
|
return cteNodes;
|
|
35
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A data-modifying `with` member is legal ONLY in a statement's own leading clause.
|
|
46
|
+
* Only there does anything own its write: `attachUnreferencedDmlCtes` (building/block.ts)
|
|
47
|
+
* guarantees exactly one write per statement execution whether or not the member is read,
|
|
48
|
+
* and it is only ever handed top-level statements. Everywhere else the member's write is
|
|
49
|
+
* driven by whoever happens to reference it — dropped entirely when nothing does, re-driven
|
|
50
|
+
* on every evaluation when the position re-evaluates (a stored view body), and once for the
|
|
51
|
+
* whole statement rather than once per outer row when the position is a correlated subquery.
|
|
52
|
+
*
|
|
53
|
+
* Rejecting rather than defining those cases matches PostgreSQL, and mirrors the sibling
|
|
54
|
+
* reject in `planViewBody` (building/create-view.ts), which refuses a DML *body* for a view
|
|
55
|
+
* for the same re-drive reason.
|
|
56
|
+
*
|
|
57
|
+
* Sited here — one check on the clause — rather than at each nesting position, so it covers
|
|
58
|
+
* every one at once (`from` sub-query, scalar / `exists` / `in` sub-query, a clause nested
|
|
59
|
+
* inside another CTE body, a compound arm, a stored view / materialized-view / maintained
|
|
60
|
+
* body, an assertion body) plus any position added later: they all funnel through
|
|
61
|
+
* `buildWithContext` or `buildStoredBodyCTEs` into this function.
|
|
62
|
+
*/
|
|
63
|
+
function rejectNestedDataModifyingCte(cte) {
|
|
64
|
+
quereusError(`WITH member '${cte.name}' is data-modifying (${cte.query.type.toUpperCase()}), which is only allowed in a statement's own leading WITH clause — not in a subquery or a stored view/materialized-view body, where the write would either be dropped or re-driven on every evaluation. Move the mutation to the statement that uses this query.`, StatusCode.ERROR, undefined, cte.query);
|
|
65
|
+
}
|
|
36
66
|
/**
|
|
37
67
|
* True when `cte` is the recursive (self-referential) member of a WITH clause —
|
|
38
68
|
* the `recursive` keyword AND a compound (UNION / UNION ALL) SELECT body, which is
|
|
@@ -51,7 +81,7 @@ export function isRecursiveCte(recursive, cte) {
|
|
|
51
81
|
* `RETURNING` clause (the parser requires one for a CTE body). Such a CTE is built
|
|
52
82
|
* with `materialize` already on; see the call site in {@link buildCommonTableExpr}.
|
|
53
83
|
*/
|
|
54
|
-
function isDataModifyingCte(cte) {
|
|
84
|
+
export function isDataModifyingCte(cte) {
|
|
55
85
|
const t = cte.query.type;
|
|
56
86
|
return t === 'insert' || t === 'update' || t === 'delete';
|
|
57
87
|
}
|
|
@@ -135,7 +165,26 @@ export function buildCommonTableExpr(ctx, cte, isRecursive, existingCTEs, option
|
|
|
135
165
|
// RETURNING sets are small; if a bulk write's RETURNING ever needs to stream,
|
|
136
166
|
// buffering would have to become conditional on the reference count — which means
|
|
137
167
|
// first fixing that undercount, not relaxing this flag.
|
|
138
|
-
|
|
168
|
+
//
|
|
169
|
+
// Resolve the CTE's runtime identity through the per-statement memo
|
|
170
|
+
// (PlanningContext.cteDescriptors): every build of THIS source member within one
|
|
171
|
+
// statement gets the same descriptor, so all its CTENodes share one per-execution
|
|
172
|
+
// buffer in emitCTE — a data-modifying body writes once per statement execution
|
|
173
|
+
// even when the builders plan the member more than once (view write-through,
|
|
174
|
+
// multi-source decomposition, the unreferenced-member sink rebuild in buildBlock).
|
|
175
|
+
//
|
|
176
|
+
// NOTE: sharing the identity can also drop a READ-ONLY member's evaluation count from
|
|
177
|
+
// N to 1 — two builds of one member now feed one buffer when the materialization
|
|
178
|
+
// advisory buffers it, where they used to evaluate independently. Row-identical for a
|
|
179
|
+
// deterministic body, and arguably better for a non-deterministic one (one consistent
|
|
180
|
+
// image). If a body ever needs per-build re-evaluation, the memo has to become
|
|
181
|
+
// conditional on `isDataModifyingCte` rather than universal.
|
|
182
|
+
let tableDescriptor = ctx.cteDescriptors.get(cte);
|
|
183
|
+
if (!tableDescriptor) {
|
|
184
|
+
tableDescriptor = {};
|
|
185
|
+
ctx.cteDescriptors.set(cte, tableDescriptor);
|
|
186
|
+
}
|
|
187
|
+
return new CTENode(ctx.scope, cte.name, cte.columns, query, cte.materializationHint, isRecursive, isDataModifyingCte(cte), tableDescriptor);
|
|
139
188
|
}
|
|
140
189
|
/**
|
|
141
190
|
* Builds a recursive CTE node from a CTE with UNION structure.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with.js","sourceRoot":"","sources":["../../../../src/planner/building/with.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAuC,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAA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AAC,aAAa,EAAE,EAChC,gBAAgB,CAAC,OAAO,EAAE,EAC1B,gBAAgB,CAAC,eAAe,CAChC,CAAC;IAEF,oEAAoE;IACpE,uGAAuG;IACvG,MAAM,eAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;IACxD,uEAAuE;IACvE,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC;QACzC,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,iEAAiE;IACjE,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,CAAC;IAE7D,iCAAiC;IACjC,MAAM,kBAAkB,GAAG,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,CAAuB,CAAC;IAEvH,yEAAyE;IACzE,gBAAgB,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAE3D,OAAO,gBAAgB,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlation-detector.d.ts","sourceRoot":"","sources":["../../../../src/planner/cache/correlation-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIjG;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"correlation-detector.d.ts","sourceRoot":"","sources":["../../../../src/planner/cache/correlation-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIjG;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAO9E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,CAOvF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAShG"}
|
|
@@ -10,9 +10,11 @@ import { PlanNodeType } from '../nodes/plan-node-type.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export function isCorrelatedSubquery(subqueryNode) {
|
|
12
12
|
// Short-circuit: stop at the first external reference rather than collecting all.
|
|
13
|
+
// Each walk gets its OWN `seen` set — the two answer different questions, so
|
|
14
|
+
// sharing one would make the second walk skip nodes it must still inspect.
|
|
13
15
|
const definedAttributes = new Set();
|
|
14
|
-
collectDefinedAttributes(subqueryNode, definedAttributes);
|
|
15
|
-
return hasExternalReferences(subqueryNode, definedAttributes);
|
|
16
|
+
collectDefinedAttributes(subqueryNode, definedAttributes, new Set());
|
|
17
|
+
return hasExternalReferences(subqueryNode, definedAttributes, new Set());
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Collect the attribute IDs the subquery references from *outer* scopes (i.e.
|
|
@@ -21,10 +23,11 @@ export function isCorrelatedSubquery(subqueryNode) {
|
|
|
21
23
|
* correlation depends on, not merely that it is correlated.
|
|
22
24
|
*/
|
|
23
25
|
export function collectExternalReferences(subqueryNode) {
|
|
26
|
+
// Each walk gets its own `seen` set — see {@link isCorrelatedSubquery}.
|
|
24
27
|
const definedAttributes = new Set();
|
|
25
|
-
collectDefinedAttributes(subqueryNode, definedAttributes);
|
|
28
|
+
collectDefinedAttributes(subqueryNode, definedAttributes, new Set());
|
|
26
29
|
const external = new Set();
|
|
27
|
-
collectExternalAttributeIds(subqueryNode, definedAttributes, external);
|
|
30
|
+
collectExternalAttributeIds(subqueryNode, definedAttributes, external, new Set());
|
|
28
31
|
return external;
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
@@ -46,7 +49,7 @@ export function readsColumnsOf(reader, producer) {
|
|
|
46
49
|
if (external.size === 0)
|
|
47
50
|
return false;
|
|
48
51
|
const produced = new Set();
|
|
49
|
-
collectDefinedAttributes(producer, produced);
|
|
52
|
+
collectDefinedAttributes(producer, produced, new Set());
|
|
50
53
|
for (const attrId of external) {
|
|
51
54
|
if (produced.has(attrId))
|
|
52
55
|
return true;
|
|
@@ -54,9 +57,21 @@ export function readsColumnsOf(reader, producer) {
|
|
|
54
57
|
return false;
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
|
-
* Recursively collect all attributes defined by relational nodes within a subtree
|
|
60
|
+
* Recursively collect all attributes defined by relational nodes within a subtree.
|
|
61
|
+
*
|
|
62
|
+
* `seen` dedupes node visits within one top-level call. A relational node reaches
|
|
63
|
+
* its inputs through BOTH `getChildren()` and `getRelations()` — for a join those
|
|
64
|
+
* two lists overlap completely — so an undeduped walk visits each input twice per
|
|
65
|
+
* level and costs 2^depth down a join spine. `getRelations()` is not always a
|
|
66
|
+
* subset of `getChildren()`, so both descents must stay; dedupe, do not prune.
|
|
67
|
+
* The set is per top-level call and must not be shared across calls or cached
|
|
68
|
+
* across plan builds — plan nodes are rebuilt during optimization and the answer
|
|
69
|
+
* depends on where the walk started.
|
|
58
70
|
*/
|
|
59
|
-
function collectDefinedAttributes(node, definedAttributes) {
|
|
71
|
+
function collectDefinedAttributes(node, definedAttributes, seen) {
|
|
72
|
+
if (seen.has(node))
|
|
73
|
+
return;
|
|
74
|
+
seen.add(node);
|
|
60
75
|
// If this is a relational node, add its attributes
|
|
61
76
|
const isRelational = isRelationalNode(node);
|
|
62
77
|
if (isRelational) {
|
|
@@ -68,20 +83,28 @@ function collectDefinedAttributes(node, definedAttributes) {
|
|
|
68
83
|
// Recursively process all children
|
|
69
84
|
const children = node.getChildren();
|
|
70
85
|
for (const child of children) {
|
|
71
|
-
collectDefinedAttributes(child, definedAttributes);
|
|
86
|
+
collectDefinedAttributes(child, definedAttributes, seen);
|
|
72
87
|
}
|
|
73
88
|
// Also process relational children if any
|
|
74
89
|
if (isRelational) {
|
|
75
90
|
const relations = node.getRelations();
|
|
76
91
|
for (const relation of relations) {
|
|
77
|
-
collectDefinedAttributes(relation, definedAttributes);
|
|
92
|
+
collectDefinedAttributes(relation, definedAttributes, seen);
|
|
78
93
|
}
|
|
79
94
|
}
|
|
80
95
|
}
|
|
81
96
|
/**
|
|
82
|
-
* Check if the subtree contains any column references to attributes not in the defined set
|
|
97
|
+
* Check if the subtree contains any column references to attributes not in the defined set.
|
|
98
|
+
*
|
|
99
|
+
* See {@link collectDefinedAttributes} for why `seen` exists. Returning `false` on
|
|
100
|
+
* a repeat visit is sound: a node already visited that did not short-circuit
|
|
101
|
+
* `true` has no external reference under it, so `false` is the answer it already
|
|
102
|
+
* gave.
|
|
83
103
|
*/
|
|
84
|
-
function hasExternalReferences(node, definedAttributes) {
|
|
104
|
+
function hasExternalReferences(node, definedAttributes, seen) {
|
|
105
|
+
if (seen.has(node))
|
|
106
|
+
return false;
|
|
107
|
+
seen.add(node);
|
|
85
108
|
// Check if this is a column reference
|
|
86
109
|
if (node.nodeType === PlanNodeType.ColumnReference) {
|
|
87
110
|
const colRef = node;
|
|
@@ -93,7 +116,7 @@ function hasExternalReferences(node, definedAttributes) {
|
|
|
93
116
|
// Check all children
|
|
94
117
|
const children = node.getChildren();
|
|
95
118
|
for (const child of children) {
|
|
96
|
-
if (hasExternalReferences(child, definedAttributes)) {
|
|
119
|
+
if (hasExternalReferences(child, definedAttributes, seen)) {
|
|
97
120
|
return true;
|
|
98
121
|
}
|
|
99
122
|
}
|
|
@@ -101,7 +124,7 @@ function hasExternalReferences(node, definedAttributes) {
|
|
|
101
124
|
if (isRelationalNode(node)) {
|
|
102
125
|
const relations = node.getRelations();
|
|
103
126
|
for (const relation of relations) {
|
|
104
|
-
if (hasExternalReferences(relation, definedAttributes)) {
|
|
127
|
+
if (hasExternalReferences(relation, definedAttributes, seen)) {
|
|
105
128
|
return true;
|
|
106
129
|
}
|
|
107
130
|
}
|
|
@@ -110,9 +133,13 @@ function hasExternalReferences(node, definedAttributes) {
|
|
|
110
133
|
}
|
|
111
134
|
/**
|
|
112
135
|
* Like {@link hasExternalReferences}, but accumulates every external attribute
|
|
113
|
-
* ID into `external` instead of short-circuiting at the first one.
|
|
136
|
+
* ID into `external` instead of short-circuiting at the first one. See
|
|
137
|
+
* {@link collectDefinedAttributes} for why `seen` exists.
|
|
114
138
|
*/
|
|
115
|
-
function collectExternalAttributeIds(node, definedAttributes, external) {
|
|
139
|
+
function collectExternalAttributeIds(node, definedAttributes, external, seen) {
|
|
140
|
+
if (seen.has(node))
|
|
141
|
+
return;
|
|
142
|
+
seen.add(node);
|
|
116
143
|
if (node.nodeType === PlanNodeType.ColumnReference) {
|
|
117
144
|
const colRef = node;
|
|
118
145
|
if (!definedAttributes.has(colRef.attributeId)) {
|
|
@@ -120,11 +147,11 @@ function collectExternalAttributeIds(node, definedAttributes, external) {
|
|
|
120
147
|
}
|
|
121
148
|
}
|
|
122
149
|
for (const child of node.getChildren()) {
|
|
123
|
-
collectExternalAttributeIds(child, definedAttributes, external);
|
|
150
|
+
collectExternalAttributeIds(child, definedAttributes, external, seen);
|
|
124
151
|
}
|
|
125
152
|
if (isRelationalNode(node)) {
|
|
126
153
|
for (const relation of node.getRelations()) {
|
|
127
|
-
collectExternalAttributeIds(relation, definedAttributes, external);
|
|
154
|
+
collectExternalAttributeIds(relation, definedAttributes, external, seen);
|
|
128
155
|
}
|
|
129
156
|
}
|
|
130
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlation-detector.js","sourceRoot":"","sources":["../../../../src/planner/cache/correlation-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAA0C,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAgC;IACpE,kFAAkF;IAClF,MAAM,iBAAiB,GAAG,IAAI,GAAG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AK,YAAY,CAAC,eAAe,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,IAA2B,CAAC;QAC3C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAChD,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClC,CAAC;IACF,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACxC,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YAC5C,2BAA2B,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -16,6 +16,12 @@ export interface Ordering {
|
|
|
16
16
|
/**
|
|
17
17
|
* Extract ordering from sort keys if they are trivial column references
|
|
18
18
|
* Returns undefined if any sort key is not a simple column reference
|
|
19
|
+
*
|
|
20
|
+
* NOTE: all-or-nothing. `order by a, b * 2` yields nothing, though the leading
|
|
21
|
+
* `a` prefix alone would be a sound (weaker) claim that merge join and the
|
|
22
|
+
* ordering-prefix rules could still use. Cheap to relax — return the prefix
|
|
23
|
+
* collected before the first non-column key — if a plan ever needs an ordering
|
|
24
|
+
* above a computed secondary sort key.
|
|
19
25
|
*/
|
|
20
26
|
export declare function extractOrderingFromSortKeys(sortKeys: readonly {
|
|
21
27
|
expression: ScalarPlanNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physical-utils.d.ts","sourceRoot":"","sources":["../../../../src/planner/framework/physical-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAA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';
|
|
|
6
6
|
/**
|
|
7
7
|
* Extract ordering from sort keys if they are trivial column references
|
|
8
8
|
* Returns undefined if any sort key is not a simple column reference
|
|
9
|
+
*
|
|
10
|
+
* NOTE: all-or-nothing. `order by a, b * 2` yields nothing, though the leading
|
|
11
|
+
* `a` prefix alone would be a sound (weaker) claim that merge join and the
|
|
12
|
+
* ordering-prefix rules could still use. Cheap to relax — return the prefix
|
|
13
|
+
* collected before the first non-column key — if a plan ever needs an ordering
|
|
14
|
+
* above a computed secondary sort key.
|
|
9
15
|
*/
|
|
10
16
|
export function extractOrderingFromSortKeys(sortKeys, sourceAttributes) {
|
|
11
17
|
const ordering = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physical-utils.js","sourceRoot":"","sources":["../../../../src/planner/framework/physical-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAc1D
|
|
1
|
+
{"version":3,"file":"physical-utils.js","sourceRoot":"","sources":["../../../../src/planner/framework/physical-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAc1D;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CAC1C,QAA8E,EAC9E,gBAA2C;IAE3C,MAAM,QAAQ,GAAe,EAAE,CAAC;IAEhC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,8CAA8C;QAC9C,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,KAAK,YAAY,CAAC,eAAe,EAAE,CAAC;YAClE,OAAO,SAAS,CAAC,CAAC,oDAAoD;QACvE,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,UAA4C,CAAC;QAEvE,+EAA+E;QAC/E,0EAA0E;QAC1E,qCAAqC;QACrC,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IA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CAAC,CAAC,SAAS;gBACtB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM;aAC5B,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC5C,WAAmD,EACnD,KAAgC;IAEhC,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/D,MAAM,MAAM,GAAwC,EAAE,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC7B,+EAA+E;QAC/E,wEAAwE;QACxE,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type * as AST from '../../parser/ast.js';
|
|
1
2
|
import type { LensSlot } from '../../schema/lens.js';
|
|
2
3
|
import type { RowConstraintSchema } from '../../schema/table.js';
|
|
3
4
|
import { RowOpFlag } from '../../schema/table.js';
|
|
4
5
|
import type { SchemaManager } from '../../schema/manager.js';
|
|
6
|
+
import type { BasisRelationRef } from '../../vtab/mapping-advertisement.js';
|
|
5
7
|
import type { PlanningContext } from '../planning-context.js';
|
|
6
8
|
/**
|
|
7
9
|
* Lens row-local constraint enforcement (the write side of the lens prover's
|
|
@@ -70,6 +72,127 @@ export declare const LENS_BOUNDARY_ATTACHED_TAG = "quereus.lens.boundary.attache
|
|
|
70
72
|
* row-local checks — the common case, so a non-lens / check-free write pays nothing.
|
|
71
73
|
*/
|
|
72
74
|
export declare function collectLensRowLocalConstraints(ctx: PlanningContext, slot: LensSlot): RowConstraintSchema[];
|
|
75
|
+
/** One row-local logical check in authored (logical-column) terms. */
|
|
76
|
+
export interface LensRowLocalLogicalCheck {
|
|
77
|
+
/** The routed-constraint name (`lens:<name>` / `lens:check` / `lens:notnull:<col>`) — error text stays stable. */
|
|
78
|
+
readonly name: string;
|
|
79
|
+
/** The check expression over logical columns (authored, or synthesized for NOT NULL; shared, never mutated). */
|
|
80
|
+
readonly expr: AST.Expression;
|
|
81
|
+
/**
|
|
82
|
+
* Verbatim violation text for a synthesized check (the NOT NULL obligation) —
|
|
83
|
+
* the user never wrote the expression, so the failure must read as its real
|
|
84
|
+
* class (`NOT NULL constraint failed: t.col`), not an anonymous CHECK.
|
|
85
|
+
* Undefined for an authored CHECK, which keeps the derived message.
|
|
86
|
+
*/
|
|
87
|
+
readonly violationMessage?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The slot's `enforced-row-local` CHECK obligations in their authored (logical)
|
|
91
|
+
* terms — the raw material for the logical-row seam, before any basis rewrite.
|
|
92
|
+
* Returns `[]` for an un-proved / check-free slot (the common case).
|
|
93
|
+
*/
|
|
94
|
+
export declare function collectLensRowLocalLogicalChecks(slot: LensSlot): LensRowLocalLogicalCheck[];
|
|
95
|
+
/**
|
|
96
|
+
* The logical column (declared spelling) that maps to `basisColumn` on `relation`,
|
|
97
|
+
* or `undefined` when no logical column exposes it. Used by the decomposition
|
|
98
|
+
* write paths to find the logical spelling of the shared key (the anchor's key
|
|
99
|
+
* column), so the deferred logical-view re-read can address the written row:
|
|
100
|
+
* `_lr.<logicalKey> = NEW.<memberKey>`. A surrogate (hidden) shared key maps to
|
|
101
|
+
* no logical column ⇒ `undefined` ⇒ the caller must refuse loudly rather than
|
|
102
|
+
* skip enforcement.
|
|
103
|
+
*/
|
|
104
|
+
export declare function findLogicalColumnForBasis(slot: LensSlot, schemaManager: SchemaManager | undefined, relation: BasisRelationRef, basisColumn: string): string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* How the deferred logical-row re-read addresses the written row in the logical
|
|
107
|
+
* view, given only the riding base op's own key column (`<CORR>.<memberKey>`):
|
|
108
|
+
*
|
|
109
|
+
* - `shared-key` — the decomposition's shared key IS a logical column (a
|
|
110
|
+
* logical-tuple key): correlate directly, `_lr.<logicalKeyColumn> = <CORR>.<memberKey>`.
|
|
111
|
+
* - `member-hop` — the shared key is hidden (a surrogate): hop through the
|
|
112
|
+
* MANDATORY member owning each logical PK column to reconstruct the PK,
|
|
113
|
+
* `_lr.<pk_i> = (select __lra.<pkBasis_i> from <member_i> as __lra where __lra.<memberKey_i> = <CORR>.<memberKey>)`
|
|
114
|
+
* per PK column. Every member's key column carries the same shared-key value
|
|
115
|
+
* (the decomposition equi-join), so each hop lands on the written row's
|
|
116
|
+
* member row whichever member op the constraint rides — including a
|
|
117
|
+
* per-column decomposition whose compound PK spreads across several member
|
|
118
|
+
* stores (none of them the anchor).
|
|
119
|
+
*/
|
|
120
|
+
export type LensLogicalRowAddress = {
|
|
121
|
+
readonly kind: 'shared-key';
|
|
122
|
+
readonly logicalKeyColumn: string;
|
|
123
|
+
} | {
|
|
124
|
+
readonly kind: 'member-hop';
|
|
125
|
+
readonly pkColumns: ReadonlyArray<{
|
|
126
|
+
readonly logicalColumn: string;
|
|
127
|
+
readonly basisColumn: string;
|
|
128
|
+
readonly relation: BasisRelationRef;
|
|
129
|
+
readonly relationKeyColumn: string;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Resolves how a decomposition write can address the written logical row —
|
|
134
|
+
* preferring the direct shared-key correlation, falling back to the member-hop
|
|
135
|
+
* when the shared key is hidden but every logical PK column maps to a plain
|
|
136
|
+
* basis column on a single-key MANDATORY member (the anchor, or — under a
|
|
137
|
+
* per-column decomposition — the member store backing that PK column). Returns
|
|
138
|
+
* `undefined` when neither addressing works (a keyless logical table over a
|
|
139
|
+
* hidden surrogate, a PK column on an optional / composite-key member) — the
|
|
140
|
+
* caller must then refuse the write loudly rather than skip enforcement.
|
|
141
|
+
*/
|
|
142
|
+
export declare function resolveLensLogicalRowAddress(slot: LensSlot, schemaManager: SchemaManager | undefined, anchorRelation: BasisRelationRef, anchorKeyColumn: string): LensLogicalRowAddress | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* The stable name of the grouped deferred logical-row constraint. Bookkeeping
|
|
145
|
+
* only — the deferred queue keys its rows by it and the "constraint rode no base
|
|
146
|
+
* op" trace log prints it. It never reaches a user-visible failure message: the
|
|
147
|
+
* constraint is message-valued, so its evaluated VALUE (the failing rule's own
|
|
148
|
+
* verbatim text) is what the runtime reports.
|
|
149
|
+
*/
|
|
150
|
+
export declare const LENS_ROW_LOCAL_DEFERRED_NAME = "lens:rowlocal";
|
|
151
|
+
/**
|
|
152
|
+
* Builds the ONE deferred logical-row constraint covering EVERY row-local rule
|
|
153
|
+
* of a decomposition write, for one `(relation, correlation)` of the fan-out:
|
|
154
|
+
*
|
|
155
|
+
* (select min(case when not (<rule 1 over _lr.*>) then '<rule 1 message>'
|
|
156
|
+
* …
|
|
157
|
+
* when not (<rule n over _lr.*>) then '<rule n message>'
|
|
158
|
+
* else null end)
|
|
159
|
+
* from <logicalSchema>.<logicalTable> as _lr
|
|
160
|
+
* where <row address over <CORR>.<relationKeyColumn>>)
|
|
161
|
+
*
|
|
162
|
+
* The subquery FROM is the registered **logical view**, so at commit (the
|
|
163
|
+
* contained subquery auto-defers the constraint) it re-reads the written row's
|
|
164
|
+
* POST-write logical image — independent of which member relations the row's
|
|
165
|
+
* write happened to touch — ONCE, and decides all the rules against the row it
|
|
166
|
+
* already has. The constraint is **message-valued**
|
|
167
|
+
* ({@link RowConstraintSchema.messageValued}): it evaluates to NULL when every
|
|
168
|
+
* rule holds (also when the address matches no row — `min` over an empty
|
|
169
|
+
* selection is NULL, preserving the old `not exists` pass on a row the
|
|
170
|
+
* statement did not touch) and to a violated rule's verbatim message
|
|
171
|
+
* otherwise, which the runtime reports as-is. One planned subquery per
|
|
172
|
+
* group however many rules the table declares — where the retired
|
|
173
|
+
* one-constraint-per-rule shape paid plan construction linearly in the rule
|
|
174
|
+
* count (the measured cost this collapse removes).
|
|
175
|
+
*
|
|
176
|
+
* Per-rule NULL semantics carry inside the CASE: a rule evaluating to NULL
|
|
177
|
+
* makes its `when not (<rule>)` branch NULL ⇒ the branch is not taken ⇒ that
|
|
178
|
+
* rule passes (SQL's NULL-passes-a-CHECK convention, exactly what the per-rule
|
|
179
|
+
* form gave), while a later definitely-false rule still selects its own branch
|
|
180
|
+
* and ABORTs.
|
|
181
|
+
*
|
|
182
|
+
* The row address ({@link LensLogicalRowAddress}) correlates from the base op
|
|
183
|
+
* the constraint rides: `NEW` for an insert/update-shaped op, `OLD` for a
|
|
184
|
+
* member DELETE (the all-null assignment lowering, where no NEW row exists).
|
|
185
|
+
* `operations` masks the constraint to the op shape it rides (INSERT|UPDATE
|
|
186
|
+
* with `NEW`, DELETE with `OLD`); `referencedWriteRowRelations` carries the
|
|
187
|
+
* single `(relation, key column)` pair so the per-op gate (`constraintsForOp`)
|
|
188
|
+
* threads it onto exactly the ops targeting that member.
|
|
189
|
+
*
|
|
190
|
+
* Because the re-read evaluates the WHOLE logical row image, a cross-member
|
|
191
|
+
* CHECK (one the per-member gate could never thread) is enforced here too — the
|
|
192
|
+
* decomposition write paths that use this seam therefore close the documented
|
|
193
|
+
* cross-member deferral as a side effect (docs/lens.md § Constraint Attachment).
|
|
194
|
+
*/
|
|
195
|
+
export declare function synthesizeLensRowLocalDeferredConstraint(ctx: PlanningContext, slot: LensSlot, checks: readonly LensRowLocalLogicalCheck[], address: LensLogicalRowAddress, relation: BasisRelationRef, relationKeyColumn: string, correlation: 'NEW' | 'OLD', operations: RowOpFlag): RowConstraintSchema;
|
|
73
196
|
/**
|
|
74
197
|
* Builds the basis-term child-side FK existence constraints a lens write must
|
|
75
198
|
* enforce (the write side of the prover's `enforced-fk` obligation). For each FK
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens-enforcement.d.ts","sourceRoot":"","sources":["../../../../src/planner/mutation/lens-enforcement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lens-enforcement.d.ts","sourceRoot":"","sources":["../../../../src/planner/mutation/lens-enforcement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAuE,MAAM,uBAAuB,CAAC;AACtI,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAW5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,0FAA0F;AAC1F,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAuR3E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,GAAG,mBAAmB,EAAE,CAiC1G;AAqBD,sEAAsE;AACtE,MAAM,WAAW,wBAAwB;IACxC,kHAAkH;IAClH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gHAAgH;IAChH,QAAQ,CAAC,IAAI,EAAE,GAAG,CAA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