@quereus/quereus 2.9.0 → 3.0.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/README.md +224 -222
- package/dist/src/core/database-assertions.d.ts +36 -16
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +222 -118
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-transaction.d.ts +96 -13
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +294 -35
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database-watchers.d.ts +58 -0
- package/dist/src/core/database-watchers.d.ts.map +1 -0
- package/dist/src/core/database-watchers.js +206 -0
- package/dist/src/core/database-watchers.js.map +1 -0
- package/dist/src/core/database.d.ts +78 -5
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +120 -20
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts +9 -0
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +29 -0
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/core/table-handle.d.ts +45 -0
- package/dist/src/core/table-handle.d.ts.map +1 -0
- package/dist/src/core/table-handle.js +54 -0
- package/dist/src/core/table-handle.js.map +1 -0
- package/dist/src/func/builtins/conversion.d.ts.map +1 -1
- package/dist/src/func/builtins/conversion.js +12 -1
- package/dist/src/func/builtins/conversion.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +22 -8
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/generation.d.ts.map +1 -1
- package/dist/src/func/builtins/generation.js +26 -1
- package/dist/src/func/builtins/generation.js.map +1 -1
- package/dist/src/func/builtins/index.d.ts.map +1 -1
- package/dist/src/func/builtins/index.js +5 -1
- package/dist/src/func/builtins/index.js.map +1 -1
- package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
- package/dist/src/func/builtins/json-tvf.js +16 -2
- package/dist/src/func/builtins/json-tvf.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts +4 -0
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +270 -11
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/func/registration.d.ts +19 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +8 -3
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +7 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +12 -4
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/analysis/assertion-classifier.d.ts +71 -0
- package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -0
- package/dist/src/planner/analysis/assertion-classifier.js +286 -0
- package/dist/src/planner/analysis/assertion-classifier.js.map +1 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.d.ts +34 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.js +119 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -0
- package/dist/src/planner/analysis/binding-extractor.d.ts +58 -0
- package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -0
- package/dist/src/planner/analysis/binding-extractor.js +110 -0
- package/dist/src/planner/analysis/binding-extractor.js.map +1 -0
- package/dist/src/planner/analysis/change-scope.d.ts +184 -0
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -0
- package/dist/src/planner/analysis/change-scope.js +825 -0
- package/dist/src/planner/analysis/change-scope.js.map +1 -0
- package/dist/src/planner/analysis/check-extraction.d.ts +29 -0
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -0
- package/dist/src/planner/analysis/check-extraction.js +420 -0
- package/dist/src/planner/analysis/check-extraction.js.map +1 -0
- package/dist/src/planner/analysis/constraint-extractor.d.ts +47 -7
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +186 -93
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/partial-unique-extraction.d.ts +68 -0
- package/dist/src/planner/analysis/partial-unique-extraction.d.ts.map +1 -0
- package/dist/src/planner/analysis/partial-unique-extraction.js +347 -0
- package/dist/src/planner/analysis/partial-unique-extraction.js.map +1 -0
- package/dist/src/planner/analysis/predicate-conjuncts.d.ts +14 -0
- package/dist/src/planner/analysis/predicate-conjuncts.d.ts.map +1 -0
- package/dist/src/planner/analysis/predicate-conjuncts.js +31 -0
- package/dist/src/planner/analysis/predicate-conjuncts.js.map +1 -0
- package/dist/src/planner/analysis/predicate-shape.d.ts +52 -0
- package/dist/src/planner/analysis/predicate-shape.d.ts.map +1 -0
- package/dist/src/planner/analysis/predicate-shape.js +119 -0
- package/dist/src/planner/analysis/predicate-shape.js.map +1 -0
- package/dist/src/planner/analysis/sat-checker.d.ts +43 -0
- package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -0
- package/dist/src/planner/analysis/sat-checker.js +393 -0
- package/dist/src/planner/analysis/sat-checker.js.map +1 -0
- package/dist/src/planner/building/table.d.ts.map +1 -1
- package/dist/src/planner/building/table.js +1 -1
- package/dist/src/planner/building/table.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +10 -1
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/characteristics.js +24 -5
- package/dist/src/planner/framework/characteristics.js.map +1 -1
- package/dist/src/planner/framework/context.d.ts +1 -8
- package/dist/src/planner/framework/context.d.ts.map +1 -1
- package/dist/src/planner/framework/context.js +4 -21
- package/dist/src/planner/framework/context.js.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +18 -2
- package/dist/src/planner/framework/pass.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.js +145 -46
- package/dist/src/planner/framework/pass.js.map +1 -1
- package/dist/src/planner/framework/physical-utils.d.ts +0 -9
- package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
- package/dist/src/planner/framework/physical-utils.js +0 -31
- package/dist/src/planner/framework/physical-utils.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts +25 -0
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +75 -8
- 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 +6 -1
- package/dist/src/planner/nodes/alias-node.js.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.js +17 -3
- package/dist/src/planner/nodes/asof-scan-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 +19 -9
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/distinct-node.js +10 -6
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/empty-relation-node.d.ts +27 -0
- package/dist/src/planner/nodes/empty-relation-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/empty-relation-node.js +61 -0
- package/dist/src/planner/nodes/empty-relation-node.js.map +1 -0
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +65 -5
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +8 -6
- package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +12 -9
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/join-utils.d.ts +24 -1
- package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-utils.js +86 -0
- package/dist/src/planner/nodes/join-utils.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +6 -1
- 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 +19 -9
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.js +5 -2
- package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -0
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +186 -4
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- 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 +75 -30
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts +24 -2
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +101 -1
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.d.ts +9 -1
- package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.js +21 -0
- 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 +64 -28
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts +1 -0
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +12 -0
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.js +15 -0
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/single-row.d.ts.map +1 -1
- package/dist/src/planner/nodes/single-row.js +3 -1
- package/dist/src/planner/nodes/single-row.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +10 -3
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +8 -8
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +3 -3
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +26 -8
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/table-function-call.d.ts +4 -1
- package/dist/src/planner/nodes/table-function-call.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-function-call.js +224 -14
- package/dist/src/planner/nodes/table-function-call.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +9 -2
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/optimizer-tuning.d.ts +29 -1
- package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
- package/dist/src/planner/optimizer-tuning.js +3 -0
- package/dist/src/planner/optimizer-tuning.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +187 -0
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +22 -7
- 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 +30 -0
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -0
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +116 -0
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -0
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts +7 -7
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts.map +1 -1
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.js +18 -16
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts +56 -0
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -0
- package/dist/src/planner/rules/join/rule-join-elimination.js +326 -0
- package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -0
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js +10 -2
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts +20 -0
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +181 -0
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +46 -0
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +156 -0
- package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts +30 -0
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.js +60 -0
- package/dist/src/planner/rules/predicate/rule-filter-contradiction.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +45 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +210 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.d.ts +29 -0
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js +161 -0
- package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js.map +1 -0
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts +39 -0
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts.map +1 -0
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js +91 -0
- package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts +35 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +74 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +27 -0
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -0
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +103 -0
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +1 -25
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
- package/dist/src/planner/scopes/global.js +2 -2
- package/dist/src/planner/scopes/global.js.map +1 -1
- package/dist/src/planner/type-utils.d.ts.map +1 -1
- package/dist/src/planner/type-utils.js +11 -0
- package/dist/src/planner/type-utils.js.map +1 -1
- package/dist/src/planner/util/fd-utils.d.ts +245 -0
- package/dist/src/planner/util/fd-utils.d.ts.map +1 -0
- package/dist/src/planner/util/fd-utils.js +1416 -0
- package/dist/src/planner/util/fd-utils.js.map +1 -0
- package/dist/src/planner/util/ind-utils.d.ts +79 -0
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -0
- package/dist/src/planner/util/ind-utils.js +146 -0
- package/dist/src/planner/util/ind-utils.js.map +1 -0
- package/dist/src/planner/util/key-utils.d.ts +75 -14
- package/dist/src/planner/util/key-utils.d.ts.map +1 -1
- package/dist/src/planner/util/key-utils.js +234 -57
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/runtime/delta-executor.d.ts +134 -0
- package/dist/src/runtime/delta-executor.d.ts.map +1 -0
- package/dist/src/runtime/delta-executor.js +382 -0
- package/dist/src/runtime/delta-executor.js.map +1 -0
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +70 -24
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-assertion.js +3 -2
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +121 -41
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +1 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/empty-relation.d.ts +5 -0
- package/dist/src/runtime/emit/empty-relation.d.ts.map +1 -0
- package/dist/src/runtime/emit/empty-relation.js +11 -0
- package/dist/src/runtime/emit/empty-relation.js.map +1 -0
- package/dist/src/runtime/foreign-key-actions.d.ts +39 -0
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +219 -1
- 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 +2 -0
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +8 -0
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/change-events.d.ts +5 -1
- package/dist/src/schema/change-events.d.ts.map +1 -1
- package/dist/src/schema/change-events.js.map +1 -1
- package/dist/src/schema/function.d.ts +65 -1
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js +31 -0
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/manager.d.ts +33 -0
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +95 -4
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +32 -0
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +392 -105
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/table.d.ts +21 -2
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +17 -8
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/types/temporal-types.d.ts.map +1 -1
- package/dist/src/types/temporal-types.js +32 -0
- package/dist/src/types/temporal-types.js.map +1 -1
- package/dist/src/vtab/events.d.ts +9 -0
- package/dist/src/vtab/events.d.ts.map +1 -1
- package/dist/src/vtab/events.js +19 -0
- package/dist/src/vtab/events.js.map +1 -1
- package/dist/src/vtab/memory/layer/connection.d.ts +20 -8
- package/dist/src/vtab/memory/layer/connection.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/connection.js +95 -73
- package/dist/src/vtab/memory/layer/connection.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +91 -10
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +0 -8
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +0 -15
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +13 -2
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/memory/utils/predicate.d.ts +2 -1
- package/dist/src/vtab/memory/utils/predicate.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/predicate.js +32 -1
- package/dist/src/vtab/memory/utils/predicate.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TransactionLayer } from './transaction.js';
|
|
2
1
|
import { createLogger } from '../../../common/logger.js';
|
|
3
2
|
import { StatusCode } from '../../../common/types.js';
|
|
4
3
|
import { quereusError } from '../../../common/errors.js';
|
|
@@ -16,7 +15,25 @@ export class MemoryTableConnection {
|
|
|
16
15
|
readLayer;
|
|
17
16
|
pendingTransactionLayer = null;
|
|
18
17
|
explicitTransaction = false; // Track if transaction was explicitly started
|
|
19
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Stack of savepoint entries, indexed by depth from TransactionManager.
|
|
20
|
+
*
|
|
21
|
+
* Each slot stores:
|
|
22
|
+
* - `snapshot`: the immutable savepoint snapshot when a pending layer
|
|
23
|
+
* existed at savepoint time (eager path), or `null` if pending was
|
|
24
|
+
* null (lazy marker — no eager copy needed).
|
|
25
|
+
* - `readLayer`: the connection's readLayer at savepoint creation time,
|
|
26
|
+
* used to restore the read view when rolling back to a lazy marker
|
|
27
|
+
* that follows an outer eager-swap (otherwise the rollback would
|
|
28
|
+
* leave readLayer pointing at the inner snapshot's data).
|
|
29
|
+
*
|
|
30
|
+
* Eager path (snapshot != null): `createSavepoint` swaps `readLayer` to
|
|
31
|
+
* the snapshot and clears `pendingTransactionLayer`, so the next mutation
|
|
32
|
+
* allocates a fresh pending layer parented on the snapshot. This
|
|
33
|
+
* preserves the "SELECT iterates an immutable layer while INSERT writes
|
|
34
|
+
* a fresh child BTree" invariant, fixing mid-transaction halloween in
|
|
35
|
+
* self-referential INSERT...SELECT.
|
|
36
|
+
*/
|
|
20
37
|
savepointStack = [];
|
|
21
38
|
constructor(manager, initialReadLayer) {
|
|
22
39
|
this.connectionId = connectionCounter++;
|
|
@@ -38,25 +55,33 @@ export class MemoryTableConnection {
|
|
|
38
55
|
}
|
|
39
56
|
/** Commits the current transaction */
|
|
40
57
|
async commit() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
// If readLayer is a swapped savepoint snapshot (eager path), its data
|
|
59
|
+
// must be promoted into the committed chain on commit even when no
|
|
60
|
+
// further mutations created a new pending layer afterwards.
|
|
61
|
+
// commitTransaction handles the lazy pending-layer creation in that
|
|
62
|
+
// case.
|
|
63
|
+
if (this.pendingTransactionLayer
|
|
64
|
+
|| this.readLayer !== this.tableManager.currentCommittedLayer) {
|
|
65
|
+
await this.tableManager.commitTransaction(this);
|
|
66
|
+
// commitTransaction handles updating connection state (readLayer, pendingTransactionLayer)
|
|
44
67
|
}
|
|
45
|
-
|
|
46
|
-
//
|
|
68
|
+
// Always clear transaction state: DB-level commit broadcasts hit every
|
|
69
|
+
// connection regardless of whether it had work to do, and the connection
|
|
70
|
+
// must come out of explicit-transaction mode so subsequent autocommit
|
|
71
|
+
// statements work correctly.
|
|
47
72
|
this.clearTransactionState();
|
|
48
73
|
}
|
|
49
74
|
/** Rolls back the current transaction */
|
|
50
75
|
rollback() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
// Reset readLayer to the current committed layer
|
|
56
|
-
// Important: We need to ensure we're reading from a clean state
|
|
76
|
+
// Reset readLayer to the current committed layer; readLayer may have
|
|
77
|
+
// been swapped to a savepoint snapshot by createSavepoint's eager path.
|
|
57
78
|
this.readLayer = this.tableManager.currentCommittedLayer;
|
|
58
|
-
//
|
|
79
|
+
// Discard any pending layer
|
|
59
80
|
this.pendingTransactionLayer = null;
|
|
81
|
+
// Always clear transaction state: DB-level rollback broadcasts hit every
|
|
82
|
+
// connection regardless of whether it had work to do, and the connection
|
|
83
|
+
// must come out of explicit-transaction mode so subsequent autocommit
|
|
84
|
+
// statements work correctly.
|
|
60
85
|
this.clearTransactionState();
|
|
61
86
|
debugLog(`Connection %d: Rolled back transaction, readLayer reset to ${this.readLayer.getLayerId()}`, this.connectionId);
|
|
62
87
|
}
|
|
@@ -70,65 +95,56 @@ export class MemoryTableConnection {
|
|
|
70
95
|
if (depth < 0) {
|
|
71
96
|
quereusError(`Invalid savepoint depth: ${depth}. Must be non-negative.`, StatusCode.INTERNAL);
|
|
72
97
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
// Capture readLayer BEFORE any swap so rollback to a later lazy marker
|
|
99
|
+
// can restore the pre-swap view (see the comment on `savepointStack`).
|
|
100
|
+
const savedReadLayer = this.readLayer;
|
|
101
|
+
// Lazy-snapshot: if no pending layer exists yet, store a null snapshot
|
|
102
|
+
// marker instead of eagerly promoting. The pending layer will be created
|
|
103
|
+
// on first mutation; rolling back to a lazy marker restores the
|
|
104
|
+
// no-pending state with the saved readLayer.
|
|
105
|
+
//
|
|
106
|
+
// Eager-snapshot: promote the existing pending layer to immutable
|
|
107
|
+
// (markCommitted) and reuse it as the snapshot. Data-copying via a
|
|
108
|
+
// fresh layer doesn't survive "delete of inherited row" — the copy
|
|
109
|
+
// iterates the post-delete view (which already excludes the row),
|
|
110
|
+
// so a fresh layer would re-inherit the original entry from the
|
|
111
|
+
// parent BTree. Promoting the layer keeps the BTree's
|
|
112
|
+
// copy-on-write structure (with the cloned-and-spliced leaf)
|
|
113
|
+
// intact.
|
|
114
|
+
let snapshot = null;
|
|
115
|
+
if (this.pendingTransactionLayer) {
|
|
116
|
+
snapshot = this.pendingTransactionLayer;
|
|
117
|
+
snapshot.markCommitted();
|
|
118
|
+
}
|
|
119
|
+
this.savepointStack.push({ snapshot, readLayer: savedReadLayer });
|
|
120
|
+
// Eager-snapshot path: swap the immutable snapshot in as readLayer and
|
|
121
|
+
// drop the now-stale pending layer reference, so the next mutation
|
|
122
|
+
// allocates a fresh pending layer parented on the snapshot. This keeps
|
|
123
|
+
// SELECT iterators reading the snapshot's BTree while INSERTs mutate a
|
|
124
|
+
// different BTree (the new pending's copy-on-write child), matching
|
|
125
|
+
// the autocommit invariant for self-referential INSERT...SELECT.
|
|
126
|
+
if (snapshot) {
|
|
127
|
+
this.readLayer = snapshot;
|
|
128
|
+
this.pendingTransactionLayer = null;
|
|
76
129
|
}
|
|
77
|
-
// Create a snapshot of the current transaction state and push onto the stack
|
|
78
|
-
const savepointLayer = this.createTransactionSnapshot(this.pendingTransactionLayer);
|
|
79
|
-
this.savepointStack.push(savepointLayer);
|
|
80
130
|
// A SAVEPOINT implicitly puts the connection into explicit-transaction mode
|
|
81
131
|
// so that subsequent statements do NOT auto-commit and invalidate the savepoint.
|
|
82
132
|
this.explicitTransaction = true;
|
|
83
133
|
debugLog(`Connection %d: Created savepoint at depth %d (stack size: %d)`, this.connectionId, depth, this.savepointStack.length);
|
|
84
134
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Creates a snapshot of a transaction layer by copying its effective data to a new independent layer.
|
|
87
|
-
* This is necessary because BTree inheritance can cause shared mutable state issues.
|
|
88
|
-
* The snapshot becomes immutable and independent of the source layer.
|
|
89
|
-
*/
|
|
90
|
-
createTransactionSnapshot(sourceLayer) {
|
|
91
|
-
// Create a new transaction layer based on the source layer's parent
|
|
92
|
-
// This ensures the snapshot is independent of the source layer
|
|
93
|
-
const snapshotLayer = new TransactionLayer(sourceLayer.getParent());
|
|
94
|
-
// Copy change tracking state
|
|
95
|
-
if (sourceLayer.isTrackingChanges()) {
|
|
96
|
-
snapshotLayer.copyChangeTrackingFrom(sourceLayer);
|
|
97
|
-
}
|
|
98
|
-
// Copy all data from the source layer to the snapshot
|
|
99
|
-
const primaryTree = sourceLayer.getModificationTree('primary');
|
|
100
|
-
if (!primaryTree) {
|
|
101
|
-
// Empty transaction layer - just return the empty snapshot
|
|
102
|
-
snapshotLayer.markCommitted();
|
|
103
|
-
return snapshotLayer;
|
|
104
|
-
}
|
|
105
|
-
const firstPath = primaryTree.first();
|
|
106
|
-
if (!firstPath.on) {
|
|
107
|
-
// No data in the tree - return the empty snapshot
|
|
108
|
-
snapshotLayer.markCommitted();
|
|
109
|
-
return snapshotLayer;
|
|
110
|
-
}
|
|
111
|
-
// Copy all rows from the source layer
|
|
112
|
-
const { primaryKeyExtractorFromRow } = sourceLayer.getPkExtractorsAndComparators(sourceLayer.getSchema());
|
|
113
|
-
for (const path of primaryTree.ascending(firstPath)) {
|
|
114
|
-
const row = primaryTree.at(path);
|
|
115
|
-
try {
|
|
116
|
-
// Extract primary key and record the row in the snapshot
|
|
117
|
-
const primaryKey = primaryKeyExtractorFromRow(row);
|
|
118
|
-
snapshotLayer.recordUpsert(primaryKey, row, null);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
warnLog(`Connection %d: Failed to copy row to savepoint snapshot: %o`, this.connectionId, error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Mark the snapshot as committed to make it immutable
|
|
125
|
-
snapshotLayer.markCommitted();
|
|
126
|
-
return snapshotLayer;
|
|
127
|
-
}
|
|
128
135
|
/** Releases savepoints from the top of the stack down to the target depth (exclusive) */
|
|
129
136
|
releaseSavepoint(targetDepth) {
|
|
130
|
-
|
|
137
|
+
// Don't short-circuit on missing pendingTransactionLayer: a statement
|
|
138
|
+
// savepoint may have pushed a null marker, and the matching release
|
|
139
|
+
// must still pop it.
|
|
140
|
+
if (targetDepth > this.savepointStack.length) {
|
|
141
|
+
// Setting `Array.length` to a value larger than the current length
|
|
142
|
+
// pads with undefined slots, corrupting subsequent rollback-to /
|
|
143
|
+
// release lookups. Skip with a warning — the most likely cause is a
|
|
144
|
+
// failed savepoint replay during `Database.registerConnection`.
|
|
145
|
+
warnLog(`Connection %d: Release savepoint depth %d out of range (stack size: %d)`, this.connectionId, targetDepth, this.savepointStack.length);
|
|
131
146
|
return;
|
|
147
|
+
}
|
|
132
148
|
this.savepointStack.length = targetDepth;
|
|
133
149
|
debugLog(`Connection %d: Released savepoints to depth %d`, this.connectionId, targetDepth);
|
|
134
150
|
}
|
|
@@ -137,19 +153,25 @@ export class MemoryTableConnection {
|
|
|
137
153
|
* The savepoint is preserved (per SQL standard) so it can be rolled back to again.
|
|
138
154
|
*/
|
|
139
155
|
rollbackToSavepoint(targetDepth) {
|
|
140
|
-
if (!this.pendingTransactionLayer)
|
|
141
|
-
return;
|
|
142
156
|
if (targetDepth >= this.savepointStack.length) {
|
|
143
157
|
warnLog(`Connection %d: Savepoint depth %d out of range (stack size: %d)`, this.connectionId, targetDepth, this.savepointStack.length);
|
|
144
158
|
return;
|
|
145
159
|
}
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.pendingTransactionLayer
|
|
160
|
+
const entry = this.savepointStack[targetDepth];
|
|
161
|
+
if (entry.snapshot === null) {
|
|
162
|
+
// Lazy-snapshot marker: at savepoint creation there was no pending
|
|
163
|
+
// layer. Restore both readLayer (in case an outer eager-swap
|
|
164
|
+
// happened since) and clear pending.
|
|
165
|
+
this.readLayer = entry.readLayer;
|
|
166
|
+
this.pendingTransactionLayer = null;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// Eager-snapshot path: createSavepoint swapped readLayer to the
|
|
170
|
+
// snapshot and dropped pendingTransactionLayer. Restore that exact
|
|
171
|
+
// state on rollback — the next mutation will lazily create a new
|
|
172
|
+
// pending layer parented on the snapshot.
|
|
173
|
+
this.readLayer = entry.snapshot;
|
|
174
|
+
this.pendingTransactionLayer = null;
|
|
153
175
|
}
|
|
154
176
|
// Remove savepoints above the target, but preserve the target itself
|
|
155
177
|
this.savepointStack.length = targetDepth + 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../../src/vtab/memory/layer/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../../src/vtab/memory/layer/connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAC1B,MAAM,GAAG,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACjB,YAAY,CAAS;IACrB,YAAY,CAAqB;IAC1C,SAAS,CAAQ;IACjB,uBAAuB,GAA4B,IAAI,CAAC;IACxD,mBAAmB,GAAY,KAAK,CAAC,CAAC,8CAA8C;IAE3F;;;;;;;;;;;;;;;;;;OAkBG;IACK,cAAc,GAAmE,EAAE,CAAC;IAE5F,YAAY,OAA2B,EAAE,gBAAuB;QAC/D,IAAI,CAAC,YAAY,GAAG,iBAAiB,EAAE,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QA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gBvB,wBAAwB;IA4BtC,+EAA+E;YACjE,sBAAsB;IAkCpC,iEAAiE;YACnD,yBAAyB;IAoCvC,yEAAyE;IAC3D,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC;CAGzE"}
|
|
@@ -188,11 +188,66 @@ export class MemoryTableManager {
|
|
|
188
188
|
connection.clearSavepoints();
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
+
// If pending is null but readLayer is a swapped savepoint snapshot
|
|
192
|
+
// AHEAD of the committed chain, wrap an empty pending around it so
|
|
193
|
+
// the snapshot's data lands in the committed chain. "Ahead" means
|
|
194
|
+
// readLayer's parent chain leads back to `_currentCommittedLayer`
|
|
195
|
+
// (i.e., the snapshot was forked off the current committed head).
|
|
196
|
+
// If readLayer is instead a stale ancestor (e.g., the connection was
|
|
197
|
+
// last seeing a TransactionLayer that has since been consolidated into
|
|
198
|
+
// `baseLayer` by ALTER TABLE) or carries an out-of-date schema, leave
|
|
199
|
+
// it alone — committing such a layer would supplant the schema-aware
|
|
200
|
+
// committed head with stale data.
|
|
201
|
+
if (!connection.pendingTransactionLayer
|
|
202
|
+
&& connection.readLayer !== this._currentCommittedLayer
|
|
203
|
+
&& connection.readLayer instanceof TransactionLayer
|
|
204
|
+
&& connection.readLayer.getSchema() === this.tableSchema) {
|
|
205
|
+
let walker = connection.readLayer.getParent();
|
|
206
|
+
let isAhead = false;
|
|
207
|
+
while (walker) {
|
|
208
|
+
if (walker === this._currentCommittedLayer) {
|
|
209
|
+
isAhead = true;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
walker = walker.getParent();
|
|
213
|
+
}
|
|
214
|
+
if (isAhead) {
|
|
215
|
+
connection.pendingTransactionLayer = new TransactionLayer(connection.readLayer);
|
|
216
|
+
if (this.eventEmitter?.hasDataListeners?.()) {
|
|
217
|
+
connection.pendingTransactionLayer.enableChangeTracking();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
191
221
|
const pendingLayer = connection.pendingTransactionLayer;
|
|
192
|
-
if (!pendingLayer)
|
|
222
|
+
if (!pendingLayer) {
|
|
223
|
+
// No pending — refresh readLayer to the current committed head so a
|
|
224
|
+
// stale ancestor (post-schema-change) doesn't leak into the next
|
|
225
|
+
// statement's view.
|
|
226
|
+
connection.readLayer = this._currentCommittedLayer;
|
|
193
227
|
return;
|
|
194
|
-
|
|
195
|
-
|
|
228
|
+
}
|
|
229
|
+
// Capture changes from pendingLayer and any ancestor TransactionLayers
|
|
230
|
+
// up to (but not including) the currentCommittedLayer. Ancestor layers
|
|
231
|
+
// in the chain are typically savepoint-promoted in-transaction layers
|
|
232
|
+
// whose pendingChanges were never emitted (they were never directly
|
|
233
|
+
// committed). Walking the chain ensures events from earlier writes
|
|
234
|
+
// in the same transaction aren't dropped just because a SAVEPOINT
|
|
235
|
+
// promotion swapped the pending layer mid-transaction.
|
|
236
|
+
const eventChunks = [];
|
|
237
|
+
{
|
|
238
|
+
let layer = pendingLayer;
|
|
239
|
+
while (layer && layer !== this._currentCommittedLayer) {
|
|
240
|
+
if (layer instanceof TransactionLayer) {
|
|
241
|
+
const events = layer.getPendingChanges();
|
|
242
|
+
if (events.length > 0)
|
|
243
|
+
eventChunks.push(events);
|
|
244
|
+
}
|
|
245
|
+
layer = layer.getParent();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Chunks are newest-layer-first; reverse to chronological order while
|
|
249
|
+
// preserving intra-layer event order.
|
|
250
|
+
const changes = eventChunks.reverse().flat();
|
|
196
251
|
const lockKey = `MemoryTable.Commit:${this.schemaName}.${this._tableName}`;
|
|
197
252
|
const release = await Latches.acquire(lockKey);
|
|
198
253
|
logger.debugLog(`[Commit ${connection.connectionId}] Acquired lock for ${this._tableName}`);
|
|
@@ -440,8 +495,15 @@ export class MemoryTableManager {
|
|
|
440
495
|
}
|
|
441
496
|
ensureTransactionLayer(connection) {
|
|
442
497
|
if (!connection.pendingTransactionLayer) {
|
|
443
|
-
// Lazily create a new TransactionLayer
|
|
444
|
-
|
|
498
|
+
// Lazily create a new TransactionLayer parented on the connection's
|
|
499
|
+
// current readLayer (not the manager's _currentCommittedLayer).
|
|
500
|
+
// In the clean autocommit case the two are identical. After an
|
|
501
|
+
// eager-snapshot savepoint, readLayer is the immutable snapshot
|
|
502
|
+
// containing all in-transaction writes up to that point, so the
|
|
503
|
+
// new pending inherits those rows and reads-your-own-writes still
|
|
504
|
+
// works, while SELECTs iterating the snapshot don't see the new
|
|
505
|
+
// pending's mutations.
|
|
506
|
+
connection.pendingTransactionLayer = new TransactionLayer(connection.readLayer);
|
|
445
507
|
// Enable change tracking if there are data listeners
|
|
446
508
|
if (this.eventEmitter?.hasDataListeners?.()) {
|
|
447
509
|
connection.pendingTransactionLayer.enableChangeTracking();
|
|
@@ -467,7 +529,7 @@ export class MemoryTableManager {
|
|
|
467
529
|
const primaryKey = this.primaryKeyFromRow(newRowData);
|
|
468
530
|
const existingRow = this.lookupEffectiveRow(primaryKey, targetLayer);
|
|
469
531
|
if (existingRow !== null) {
|
|
470
|
-
// Resolve PK-conflict action: statement OR >
|
|
532
|
+
// Resolve PK-conflict action: statement OR > per-constraint default > ABORT.
|
|
471
533
|
const pkAction = onConflict ?? resolvePkDefaultConflict(schema) ?? ConflictResolution.ABORT;
|
|
472
534
|
if (pkAction === ConflictResolution.IGNORE) {
|
|
473
535
|
return { status: 'ok', row: undefined };
|
|
@@ -538,6 +600,13 @@ export class MemoryTableManager {
|
|
|
538
600
|
if (pkAction === ConflictResolution.IGNORE) {
|
|
539
601
|
return { status: 'ok', row: undefined };
|
|
540
602
|
}
|
|
603
|
+
if (pkAction === ConflictResolution.REPLACE) {
|
|
604
|
+
// Evict the row currently at the new PK, then move the updated row.
|
|
605
|
+
targetLayer.recordDelete(newPrimaryKey, existingRowAtNewKey);
|
|
606
|
+
targetLayer.recordDelete(oldPrimaryKey, oldRowData);
|
|
607
|
+
targetLayer.recordUpsert(newPrimaryKey, newRowData, null);
|
|
608
|
+
return { status: 'ok', row: newRowData, replacedRow: existingRowAtNewKey };
|
|
609
|
+
}
|
|
541
610
|
// Return constraint violation with existing row
|
|
542
611
|
return {
|
|
543
612
|
status: 'constraint',
|
|
@@ -1079,6 +1148,7 @@ export class MemoryTableManager {
|
|
|
1079
1148
|
name: newIndexSchemaEntry.name,
|
|
1080
1149
|
columns: Object.freeze(newIndexSchemaEntry.columns.map(c => c.index)),
|
|
1081
1150
|
predicate: newIndexSchemaEntry.predicate,
|
|
1151
|
+
derivedFromIndex: newIndexSchemaEntry.name,
|
|
1082
1152
|
};
|
|
1083
1153
|
updatedUniqueConstraints = Object.freeze([
|
|
1084
1154
|
...(this.tableSchema.uniqueConstraints ?? []),
|
|
@@ -1129,9 +1199,16 @@ export class MemoryTableManager {
|
|
|
1129
1199
|
}
|
|
1130
1200
|
throw new QuereusError(`Index '${indexName}' not on table '${this._tableName}'.`, StatusCode.ERROR);
|
|
1131
1201
|
}
|
|
1202
|
+
// Strip any UNIQUE constraint synthesized from this index alongside
|
|
1203
|
+
// the index itself (mirrors SchemaManager.dropIndex). Without this,
|
|
1204
|
+
// checkUniqueConstraints would keep enforcing it after DROP INDEX.
|
|
1205
|
+
const remainingUniqueConstraints = (this.tableSchema.uniqueConstraints ?? []).filter(uc => uc.derivedFromIndex?.toLowerCase() !== indexNameLower);
|
|
1132
1206
|
const finalNewTableSchema = Object.freeze({
|
|
1133
1207
|
...this.tableSchema,
|
|
1134
|
-
indexes: Object.freeze((this.tableSchema.indexes || []).filter(idx => idx.name.toLowerCase() !== indexNameLower))
|
|
1208
|
+
indexes: Object.freeze((this.tableSchema.indexes || []).filter(idx => idx.name.toLowerCase() !== indexNameLower)),
|
|
1209
|
+
uniqueConstraints: remainingUniqueConstraints.length > 0
|
|
1210
|
+
? Object.freeze(remainingUniqueConstraints)
|
|
1211
|
+
: undefined,
|
|
1135
1212
|
});
|
|
1136
1213
|
this.baseLayer.updateSchema(finalNewTableSchema);
|
|
1137
1214
|
await this.baseLayer.dropIndexFromBase(indexName);
|
|
@@ -1258,11 +1335,15 @@ export class MemoryTableManager {
|
|
|
1258
1335
|
}
|
|
1259
1336
|
}
|
|
1260
1337
|
/**
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1338
|
+
* Resolves the per-constraint default conflict action for PK conflicts.
|
|
1339
|
+
* Prefers the table-level `PRIMARY KEY (...) ON CONFLICT <action>` clause
|
|
1340
|
+
* (the constraint's own declaration) over any column-level `defaultConflict`
|
|
1341
|
+
* declared on a PK column (which primarily targets that column's own
|
|
1342
|
+
* constraints and only acts as a fallback for PK conflicts).
|
|
1264
1343
|
*/
|
|
1265
1344
|
function resolvePkDefaultConflict(schema) {
|
|
1345
|
+
if (schema.primaryKeyDefaultConflict !== undefined)
|
|
1346
|
+
return schema.primaryKeyDefaultConflict;
|
|
1266
1347
|
for (const def of schema.primaryKeyDefinition) {
|
|
1267
1348
|
const col = schema.columns[def.index];
|
|
1268
1349
|
if (col && col.defaultConflict !== undefined)
|