@quereus/quereus 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +372 -361
- package/dist/src/common/errors.d.ts +2 -18
- package/dist/src/common/errors.d.ts.map +1 -1
- package/dist/src/common/errors.js +6 -29
- package/dist/src/common/errors.js.map +1 -1
- package/dist/src/common/types.d.ts +8 -0
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/common/types.js +20 -0
- package/dist/src/common/types.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts +19 -2
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +113 -32
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +17 -0
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +36 -0
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database.d.ts +11 -0
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +178 -85
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts +6 -0
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +42 -56
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/emit/ast-stringify.d.ts +1 -0
- package/dist/src/emit/ast-stringify.d.ts.map +1 -1
- package/dist/src/emit/ast-stringify.js +12 -2
- package/dist/src/emit/ast-stringify.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 +75 -0
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/conversion.js +9 -12
- package/dist/src/func/builtins/conversion.js.map +1 -1
- package/dist/src/func/builtins/datetime.js +1 -1
- 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 +15 -3
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/index.d.ts.map +1 -1
- package/dist/src/func/builtins/index.js +1 -11
- package/dist/src/func/builtins/index.js.map +1 -1
- package/dist/src/func/builtins/json-helpers.js +1 -1
- package/dist/src/func/builtins/json-helpers.js.map +1 -1
- package/dist/src/func/builtins/json.d.ts.map +1 -1
- package/dist/src/func/builtins/json.js +2 -5
- package/dist/src/func/builtins/json.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +30 -32
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/func/builtins/string.d.ts.map +1 -1
- package/dist/src/func/builtins/string.js +40 -64
- package/dist/src/func/builtins/string.js.map +1 -1
- package/dist/src/func/builtins/timespan.d.ts.map +1 -1
- package/dist/src/func/builtins/timespan.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/ast.d.ts +9 -2
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/lexer.d.ts +1 -0
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +3 -0
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts +11 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +75 -135
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/analysis/const-evaluator.d.ts.map +1 -1
- package/dist/src/planner/analysis/const-evaluator.js +6 -3
- package/dist/src/planner/analysis/const-evaluator.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts +2 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +154 -22
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +18 -1
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/analyze.d.ts +5 -0
- package/dist/src/planner/building/analyze.d.ts.map +1 -0
- package/dist/src/planner/building/analyze.js +5 -0
- package/dist/src/planner/building/analyze.js.map +1 -0
- package/dist/src/planner/building/block.d.ts.map +1 -1
- package/dist/src/planner/building/block.js +3 -0
- 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 +25 -3
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +11 -0
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/drop-assertion.d.ts.map +1 -1
- package/dist/src/planner/building/drop-assertion.js +2 -1
- package/dist/src/planner/building/drop-assertion.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +55 -7
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts +16 -0
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -0
- package/dist/src/planner/building/foreign-key-builder.js +269 -0
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -0
- package/dist/src/planner/building/function-call.d.ts.map +1 -1
- package/dist/src/planner/building/function-call.js +3 -2
- package/dist/src/planner/building/function-call.js.map +1 -1
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +91 -10
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/schema-resolution.d.ts +4 -0
- package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
- package/dist/src/planner/building/schema-resolution.js +14 -3
- package/dist/src/planner/building/schema-resolution.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +1 -0
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +118 -3
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +3 -3
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-window.js +9 -8
- 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 +21 -10
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/table.d.ts.map +1 -1
- package/dist/src/planner/building/table.js +5 -3
- package/dist/src/planner/building/table.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +30 -1
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/with.js +1 -1
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/reference-graph.d.ts +1 -1
- package/dist/src/planner/cache/reference-graph.js +1 -1
- package/dist/src/planner/cost/index.d.ts +10 -3
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +17 -3
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/debug.js +1 -1
- package/dist/src/planner/debug.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +1 -1
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +3 -1
- package/dist/src/planner/framework/pass.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.js +62 -18
- package/dist/src/planner/framework/pass.js.map +1 -1
- package/dist/src/planner/framework/physical-utils.d.ts +5 -0
- package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
- package/dist/src/planner/framework/physical-utils.js +19 -0
- package/dist/src/planner/framework/physical-utils.js.map +1 -1
- package/dist/src/planner/framework/trace.d.ts.map +1 -1
- package/dist/src/planner/framework/trace.js +3 -2
- package/dist/src/planner/framework/trace.js.map +1 -1
- package/dist/src/planner/nodes/alias-node.d.ts +2 -1
- package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alias-node.js +8 -0
- package/dist/src/planner/nodes/alias-node.js.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.d.ts +42 -0
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/alter-table-node.js +55 -0
- package/dist/src/planner/nodes/alter-table-node.js.map +1 -0
- package/dist/src/planner/nodes/analyze-node.d.ts +25 -0
- package/dist/src/planner/nodes/analyze-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/analyze-node.js +83 -0
- package/dist/src/planner/nodes/analyze-node.js.map +1 -0
- package/dist/src/planner/nodes/bloom-join-node.d.ts +66 -0
- package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/bloom-join-node.js +200 -0
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -0
- package/dist/src/planner/nodes/constraint-check-node.d.ts +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.js +7 -7
- package/dist/src/planner/nodes/cte-reference-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts +9 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +69 -79
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.d.ts +60 -0
- package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/merge-join-node.js +207 -0
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -0
- 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/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +3 -2
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts +2 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +6 -2
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +3 -2
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/subquery.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/update-node.d.ts +2 -0
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +2 -1
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-function.js +7 -7
- package/dist/src/planner/nodes/window-function.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +2 -2
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +9 -14
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +40 -2
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/planning-context.js +1 -6
- package/dist/src/planner/planning-context.js.map +1 -1
- package/dist/src/planner/resolve.d.ts.map +1 -1
- package/dist/src/planner/resolve.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +157 -28
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js +27 -6
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts +19 -0
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts.map +1 -0
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js +53 -0
- package/dist/src/planner/rules/cache/rule-in-subquery-cache.js.map +1 -0
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js +5 -0
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +1 -1
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts +18 -0
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts.map +1 -0
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.js +37 -0
- package/dist/src/planner/rules/distinct/rule-distinct-elimination.js.map +1 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts +8 -3
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js +28 -17
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +16 -0
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -0
- package/dist/src/planner/rules/join/rule-join-physical-selection.js +216 -0
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +34 -4
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +23 -0
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -0
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +293 -0
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -0
- package/dist/src/planner/scopes/multi.d.ts +3 -2
- package/dist/src/planner/scopes/multi.d.ts.map +1 -1
- package/dist/src/planner/scopes/multi.js +32 -7
- package/dist/src/planner/scopes/multi.js.map +1 -1
- package/dist/src/planner/scopes/shadow.d.ts +20 -0
- package/dist/src/planner/scopes/shadow.d.ts.map +1 -0
- package/dist/src/planner/scopes/shadow.js +31 -0
- package/dist/src/planner/scopes/shadow.js.map +1 -0
- package/dist/src/planner/stats/analyze.d.ts +17 -0
- package/dist/src/planner/stats/analyze.d.ts.map +1 -0
- package/dist/src/planner/stats/analyze.js +114 -0
- package/dist/src/planner/stats/analyze.js.map +1 -0
- package/dist/src/planner/stats/catalog-stats.d.ts +80 -0
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -0
- package/dist/src/planner/stats/catalog-stats.js +248 -0
- package/dist/src/planner/stats/catalog-stats.js.map +1 -0
- package/dist/src/planner/stats/histogram.d.ts +24 -0
- package/dist/src/planner/stats/histogram.d.ts.map +1 -0
- package/dist/src/planner/stats/histogram.js +142 -0
- package/dist/src/planner/stats/histogram.js.map +1 -0
- package/dist/src/planner/type-utils.d.ts.map +1 -1
- package/dist/src/planner/type-utils.js +8 -2
- package/dist/src/planner/type-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +48 -2
- package/dist/src/planner/util/key-utils.d.ts.map +1 -1
- package/dist/src/planner/util/key-utils.js +123 -0
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/planner/validation/determinism-validator.d.ts +9 -0
- package/dist/src/planner/validation/determinism-validator.d.ts.map +1 -1
- package/dist/src/planner/validation/determinism-validator.js +11 -0
- package/dist/src/planner/validation/determinism-validator.js.map +1 -1
- package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
- package/dist/src/planner/validation/plan-validator.js +1 -0
- package/dist/src/planner/validation/plan-validator.js.map +1 -1
- package/dist/src/runtime/context-helpers.d.ts +34 -10
- package/dist/src/runtime/context-helpers.d.ts.map +1 -1
- package/dist/src/runtime/context-helpers.js +115 -39
- package/dist/src/runtime/context-helpers.js.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.d.ts +0 -1
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.js +10 -23
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
- package/dist/src/runtime/descriptor-helpers.d.ts +7 -0
- package/dist/src/runtime/descriptor-helpers.d.ts.map +1 -0
- package/dist/src/runtime/descriptor-helpers.js +24 -0
- package/dist/src/runtime/descriptor-helpers.js.map +1 -0
- package/dist/src/runtime/emission-context.d.ts +7 -1
- package/dist/src/runtime/emission-context.d.ts.map +1 -1
- package/dist/src/runtime/emission-context.js +16 -0
- package/dist/src/runtime/emission-context.js.map +1 -1
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +97 -93
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts +5 -0
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -0
- package/dist/src/runtime/emit/alter-table.js +209 -0
- package/dist/src/runtime/emit/alter-table.js.map +1 -0
- package/dist/src/runtime/emit/analyze.d.ts +9 -0
- package/dist/src/runtime/emit/analyze.d.ts.map +1 -0
- package/dist/src/runtime/emit/analyze.js +72 -0
- package/dist/src/runtime/emit/analyze.js.map +1 -0
- package/dist/src/runtime/emit/array-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/array-index.js +4 -2
- package/dist/src/runtime/emit/array-index.js.map +1 -1
- package/dist/src/runtime/emit/between.d.ts.map +1 -1
- package/dist/src/runtime/emit/between.js +8 -20
- package/dist/src/runtime/emit/between.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +155 -126
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/bloom-join.d.ts +12 -0
- package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -0
- package/dist/src/runtime/emit/bloom-join.js +114 -0
- package/dist/src/runtime/emit/bloom-join.js.map +1 -0
- package/dist/src/runtime/emit/cache.js +2 -2
- package/dist/src/runtime/emit/cache.js.map +1 -1
- package/dist/src/runtime/emit/cast.d.ts.map +1 -1
- package/dist/src/runtime/emit/cast.js +31 -117
- package/dist/src/runtime/emit/cast.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +2 -24
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/cte-reference.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte-reference.js +11 -5
- package/dist/src/runtime/emit/cte-reference.js.map +1 -1
- package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
- package/dist/src/runtime/emit/distinct.js +21 -12
- package/dist/src/runtime/emit/distinct.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +5 -1
- 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 +2 -0
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/filter.d.ts.map +1 -1
- package/dist/src/runtime/emit/filter.js +26 -7
- package/dist/src/runtime/emit/filter.js.map +1 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.d.ts.map +1 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js +11 -5
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +1 -1
- package/dist/src/runtime/emit/join.d.ts +1 -1
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +44 -33
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/merge-join.d.ts +14 -0
- package/dist/src/runtime/emit/merge-join.d.ts.map +1 -0
- package/dist/src/runtime/emit/merge-join.js +152 -0
- package/dist/src/runtime/emit/merge-join.js.map +1 -0
- package/dist/src/runtime/emit/parameter.d.ts.map +1 -1
- package/dist/src/runtime/emit/parameter.js +10 -32
- package/dist/src/runtime/emit/parameter.js.map +1 -1
- package/dist/src/runtime/emit/project.d.ts.map +1 -1
- package/dist/src/runtime/emit/project.js +22 -12
- package/dist/src/runtime/emit/project.js.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.js +5 -9
- package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
- package/dist/src/runtime/emit/returning.d.ts.map +1 -1
- package/dist/src/runtime/emit/returning.js +14 -8
- package/dist/src/runtime/emit/returning.js.map +1 -1
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +4 -1
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-operation.js +8 -5
- package/dist/src/runtime/emit/set-operation.js.map +1 -1
- package/dist/src/runtime/emit/sort.js +2 -2
- package/dist/src/runtime/emit/sort.js.map +1 -1
- package/dist/src/runtime/emit/subquery.js +2 -2
- package/dist/src/runtime/emit/subquery.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 +21 -7
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/unary.js +2 -2
- package/dist/src/runtime/emit/unary.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +43 -21
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/window.d.ts.map +1 -1
- package/dist/src/runtime/emit/window.js +368 -126
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts +15 -0
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -0
- package/dist/src/runtime/foreign-key-actions.js +109 -0
- package/dist/src/runtime/foreign-key-actions.js.map +1 -0
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +8 -0
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/src/runtime/scheduler.js +4 -1
- package/dist/src/runtime/scheduler.js.map +1 -1
- package/dist/src/runtime/types.d.ts +6 -5
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/change-events.d.ts +36 -8
- 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/column.d.ts +5 -1
- package/dist/src/schema/column.d.ts.map +1 -1
- package/dist/src/schema/column.js +1 -2
- package/dist/src/schema/column.js.map +1 -1
- package/dist/src/schema/manager.d.ts +54 -4
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +353 -313
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/schema-differ.js +3 -3
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/schema.d.ts +1 -1
- package/dist/src/schema/schema.js +2 -2
- package/dist/src/schema/schema.js.map +1 -1
- package/dist/src/schema/table.d.ts +49 -0
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +30 -11
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/types/builtin-types.d.ts.map +1 -1
- package/dist/src/types/builtin-types.js +26 -95
- package/dist/src/types/builtin-types.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/json-type.d.ts.map +1 -1
- package/dist/src/types/json-type.js +28 -40
- package/dist/src/types/json-type.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +6 -0
- package/dist/src/types/logical-type.d.ts.map +1 -1
- package/dist/src/types/logical-type.js +12 -0
- package/dist/src/types/logical-type.js.map +1 -1
- package/dist/src/types/temporal-types.d.ts.map +1 -1
- package/dist/src/types/temporal-types.js +8 -37
- package/dist/src/types/temporal-types.js.map +1 -1
- package/dist/src/util/coercion.d.ts +4 -5
- package/dist/src/util/coercion.d.ts.map +1 -1
- package/dist/src/util/coercion.js +10 -14
- package/dist/src/util/coercion.js.map +1 -1
- package/dist/src/util/comparison.d.ts +34 -21
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +77 -43
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/util/environment.d.ts +0 -8
- package/dist/src/util/environment.d.ts.map +1 -1
- package/dist/src/util/environment.js +0 -12
- package/dist/src/util/environment.js.map +1 -1
- package/dist/src/util/key-serializer.d.ts +33 -0
- package/dist/src/util/key-serializer.d.ts.map +1 -0
- package/dist/src/util/key-serializer.js +95 -0
- package/dist/src/util/key-serializer.js.map +1 -0
- package/dist/src/util/plugin-helper.d.ts.map +1 -1
- package/dist/src/util/plugin-helper.js +21 -45
- package/dist/src/util/plugin-helper.js.map +1 -1
- package/dist/src/util/serialization.d.ts +1 -0
- package/dist/src/util/serialization.d.ts.map +1 -1
- package/dist/src/util/serialization.js +8 -1
- package/dist/src/util/serialization.js.map +1 -1
- package/dist/src/util/working-table-iterable.d.ts +6 -5
- package/dist/src/util/working-table-iterable.d.ts.map +1 -1
- package/dist/src/util/working-table-iterable.js +8 -15
- package/dist/src/util/working-table-iterable.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +12 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +22 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts +3 -1
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/dist/src/vtab/memory/index.d.ts +2 -2
- package/dist/src/vtab/memory/index.d.ts.map +1 -1
- package/dist/src/vtab/memory/index.js +4 -7
- package/dist/src/vtab/memory/index.js.map +1 -1
- package/dist/src/vtab/memory/layer/base-cursor.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base-cursor.js +37 -9
- package/dist/src/vtab/memory/layer/base-cursor.js.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +1 -1
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +15 -3
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +85 -37
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-plan.d.ts +2 -0
- package/dist/src/vtab/memory/layer/scan-plan.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-plan.js +153 -78
- package/dist/src/vtab/memory/layer/scan-plan.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.js +39 -9
- package/dist/src/vtab/memory/layer/transaction-cursor.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +1 -5
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +14 -24
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +88 -283
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +9 -0
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +121 -18
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/memory/types.d.ts +1 -0
- package/dist/src/vtab/memory/types.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
- package/dist/src/vtab/module.d.ts +13 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +9 -0
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { emitCallFromPlan, emitPlanNode } from '../emitters.js';
|
|
2
|
+
import { createLogger } from '../../common/logger.js';
|
|
3
|
+
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
4
|
+
import { createRowSlot } from '../context-helpers.js';
|
|
5
|
+
import { resolveKeyNormalizer, serializeRowKey } from '../../util/key-serializer.js';
|
|
6
|
+
const log = createLogger('runtime:emit:bloom-join');
|
|
7
|
+
/**
|
|
8
|
+
* Emits a bloom (hash) join instruction.
|
|
9
|
+
*
|
|
10
|
+
* Build phase: materializes the right (build) side into a Map keyed by
|
|
11
|
+
* serialized equi-join column values.
|
|
12
|
+
* Probe phase: streams the left (probe) side, probing the map for matches.
|
|
13
|
+
*/
|
|
14
|
+
export function emitBloomJoin(plan, ctx) {
|
|
15
|
+
const leftAttributes = plan.left.getAttributes();
|
|
16
|
+
const rightAttributes = plan.right.getAttributes();
|
|
17
|
+
const leftRowDescriptor = buildRowDescriptor(leftAttributes);
|
|
18
|
+
const rightRowDescriptor = buildRowDescriptor(rightAttributes);
|
|
19
|
+
// Pre-resolve equi-pair column indices and collation normalizers from attribute IDs
|
|
20
|
+
const leftIndices = [];
|
|
21
|
+
const rightIndices = [];
|
|
22
|
+
const keyNormalizers = [];
|
|
23
|
+
for (const pair of plan.equiPairs) {
|
|
24
|
+
const li = leftAttributes.findIndex(a => a.id === pair.leftAttrId);
|
|
25
|
+
const ri = rightAttributes.findIndex(a => a.id === pair.rightAttrId);
|
|
26
|
+
if (li === -1 || ri === -1) {
|
|
27
|
+
throw new Error(`BloomJoin: could not resolve equi-pair attr IDs ${pair.leftAttrId}=${pair.rightAttrId}`);
|
|
28
|
+
}
|
|
29
|
+
leftIndices.push(li);
|
|
30
|
+
rightIndices.push(ri);
|
|
31
|
+
// Use the left attribute's collation (consistent with nested-loop join behavior)
|
|
32
|
+
const collationName = leftAttributes[li].type.collationName || rightAttributes[ri].type.collationName;
|
|
33
|
+
keyNormalizers.push(resolveKeyNormalizer(collationName));
|
|
34
|
+
}
|
|
35
|
+
const rightColCount = rightAttributes.length;
|
|
36
|
+
async function* run(rctx, leftSource, rightSource, residualCallback) {
|
|
37
|
+
log('Starting %s hash join: %d equi-pairs, %d left attrs, %d right attrs', plan.joinType.toUpperCase(), plan.equiPairs.length, leftAttributes.length, rightAttributes.length);
|
|
38
|
+
// === Build phase: materialize right side into hash map ===
|
|
39
|
+
const hashMap = new Map();
|
|
40
|
+
for await (const rightRow of rightSource) {
|
|
41
|
+
const key = serializeRowKey(rightRow, rightIndices, keyNormalizers);
|
|
42
|
+
if (key === null)
|
|
43
|
+
continue; // null keys can't match
|
|
44
|
+
const bucket = hashMap.get(key);
|
|
45
|
+
if (bucket) {
|
|
46
|
+
bucket.push(rightRow);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
hashMap.set(key, [rightRow]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
log('Build phase complete: %d buckets, right side materialized', hashMap.size);
|
|
53
|
+
// === Probe phase: stream left side, probe hash map ===
|
|
54
|
+
const isSemiOrAnti = plan.joinType === 'semi' || plan.joinType === 'anti';
|
|
55
|
+
const leftSlot = createRowSlot(rctx, leftRowDescriptor);
|
|
56
|
+
const rightSlot = createRowSlot(rctx, rightRowDescriptor);
|
|
57
|
+
try {
|
|
58
|
+
for await (const leftRow of leftSource) {
|
|
59
|
+
leftSlot.set(leftRow);
|
|
60
|
+
const key = serializeRowKey(leftRow, leftIndices, keyNormalizers);
|
|
61
|
+
let matched = false;
|
|
62
|
+
if (key !== null) {
|
|
63
|
+
const bucket = hashMap.get(key);
|
|
64
|
+
if (bucket) {
|
|
65
|
+
for (const rightRow of bucket) {
|
|
66
|
+
rightSlot.set(rightRow);
|
|
67
|
+
// Evaluate residual condition if present
|
|
68
|
+
if (residualCallback) {
|
|
69
|
+
const result = await residualCallback(rctx);
|
|
70
|
+
if (!result)
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
matched = true;
|
|
74
|
+
if (isSemiOrAnti) {
|
|
75
|
+
// Semi: first match is enough; Anti: record match and stop
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
yield [...leftRow, ...rightRow];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (isSemiOrAnti) {
|
|
83
|
+
// Semi: emit left row on match; Anti: emit left row on no match
|
|
84
|
+
if ((plan.joinType === 'semi' && matched) || (plan.joinType === 'anti' && !matched)) {
|
|
85
|
+
yield leftRow;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (!matched && plan.joinType === 'left') {
|
|
89
|
+
// LEFT JOIN: emit null-padded row for unmatched probe rows
|
|
90
|
+
const nullPadding = new Array(rightColCount).fill(null);
|
|
91
|
+
rightSlot.set(nullPadding);
|
|
92
|
+
yield [...leftRow, ...nullPadding];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
leftSlot.close();
|
|
98
|
+
rightSlot.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const leftInstruction = emitPlanNode(plan.left, ctx);
|
|
102
|
+
const rightInstruction = emitPlanNode(plan.right, ctx);
|
|
103
|
+
const params = [leftInstruction, rightInstruction];
|
|
104
|
+
if (plan.residualCondition) {
|
|
105
|
+
const residualInstruction = emitCallFromPlan(plan.residualCondition, ctx);
|
|
106
|
+
params.push(residualInstruction);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
params,
|
|
110
|
+
run: run,
|
|
111
|
+
note: `${plan.joinType} join (bloom/hash)`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=bloom-join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bloom-join.js","sourceRoot":"","sources":["../../../../src/runtime/emit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import { emitCallFromPlan } from '../emitters.js';
|
|
2
2
|
import { streamWithCache, createCacheState } from '../cache/shared-cache.js';
|
|
3
3
|
import { buffered, traced } from '../async-util.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isLoggingEnabled } from '../../common/logger.js';
|
|
5
5
|
/**
|
|
6
6
|
* Usage example for other emitters needing caching (NLJ inner caching, CTE materialization):
|
|
7
7
|
*
|
|
@@ -37,7 +37,7 @@ export function emitCache(plan, ctx) {
|
|
|
37
37
|
sourceIterable = buffered(sourceIterable, Math.min(plan.threshold / 10, 5000));
|
|
38
38
|
}
|
|
39
39
|
// Optional: Add tracing in debug mode
|
|
40
|
-
if (
|
|
40
|
+
if (isLoggingEnabled('runtime:cache')) {
|
|
41
41
|
sourceIterable = traced(sourceIterable, `cache-${plan.id}`, (row, index) => `row ${index}: [${row.length} columns]`);
|
|
42
42
|
}
|
|
43
43
|
yield* streamWithCache(sourceIterable, config, cacheState);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA0B,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA0B,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;;;G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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/cast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/cast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CA2B1E"}
|
|
@@ -1,49 +1,21 @@
|
|
|
1
1
|
import { emitPlanNode } from '../emitters.js';
|
|
2
|
+
import { inferType } from '../../types/registry.js';
|
|
2
3
|
export function emitCast(plan, ctx) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (operandValue === null) {
|
|
4
|
+
const logicalType = inferType(plan.expression.targetType);
|
|
5
|
+
function run(_runtimeCtx, operandValue) {
|
|
6
|
+
if (operandValue === null)
|
|
7
7
|
return null;
|
|
8
|
+
if (logicalType.parse) {
|
|
9
|
+
try {
|
|
10
|
+
return logicalType.parse(operandValue);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
// CAST failures in SQL return 0 for numeric targets, '' for text, etc.
|
|
14
|
+
// This matches SQLite's lenient CAST behavior.
|
|
15
|
+
return castFallback(operandValue, logicalType.name);
|
|
16
|
+
}
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
switch (targetType) {
|
|
11
|
-
case 'INTEGER':
|
|
12
|
-
case 'INT':
|
|
13
|
-
case 'TINYINT':
|
|
14
|
-
case 'SMALLINT':
|
|
15
|
-
case 'MEDIUMINT':
|
|
16
|
-
case 'BIGINT':
|
|
17
|
-
case 'UNSIGNED BIG INT':
|
|
18
|
-
case 'INT2':
|
|
19
|
-
case 'INT8':
|
|
20
|
-
return castToInteger(operandValue);
|
|
21
|
-
case 'REAL':
|
|
22
|
-
case 'DOUBLE':
|
|
23
|
-
case 'DOUBLE PRECISION':
|
|
24
|
-
case 'FLOAT':
|
|
25
|
-
return castToReal(operandValue);
|
|
26
|
-
case 'TEXT':
|
|
27
|
-
case 'CHARACTER':
|
|
28
|
-
case 'VARCHAR':
|
|
29
|
-
case 'VARYING CHARACTER':
|
|
30
|
-
case 'NCHAR':
|
|
31
|
-
case 'NATIVE CHARACTER':
|
|
32
|
-
case 'NVARCHAR':
|
|
33
|
-
case 'CLOB':
|
|
34
|
-
return castToText(operandValue);
|
|
35
|
-
case 'BLOB':
|
|
36
|
-
return castToBlob(operandValue);
|
|
37
|
-
case 'NUMERIC':
|
|
38
|
-
case 'DECIMAL':
|
|
39
|
-
case 'BOOLEAN':
|
|
40
|
-
case 'DATE':
|
|
41
|
-
case 'DATETIME':
|
|
42
|
-
return castToNumeric(operandValue);
|
|
43
|
-
default:
|
|
44
|
-
// For unknown types, return as-is (BLOB affinity)
|
|
45
|
-
return operandValue;
|
|
46
|
-
}
|
|
18
|
+
return operandValue;
|
|
47
19
|
}
|
|
48
20
|
return {
|
|
49
21
|
params: [emitPlanNode(plan.operand, ctx)],
|
|
@@ -51,82 +23,24 @@ export function emitCast(plan, ctx) {
|
|
|
51
23
|
note: `cast(${plan.expression.targetType})`
|
|
52
24
|
};
|
|
53
25
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (typeof value === 'string') {
|
|
62
|
-
const num = Number(value);
|
|
63
|
-
return isNaN(num) ? 0 : Math.trunc(num);
|
|
64
|
-
}
|
|
65
|
-
if (typeof value === 'boolean') {
|
|
66
|
-
return value ? 1 : 0;
|
|
67
|
-
}
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
function castToReal(value) {
|
|
71
|
-
if (typeof value === 'number') {
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
if (typeof value === 'bigint') {
|
|
75
|
-
return Number(value);
|
|
76
|
-
}
|
|
77
|
-
if (typeof value === 'string') {
|
|
78
|
-
const num = Number(value);
|
|
79
|
-
return isNaN(num) ? 0.0 : num;
|
|
80
|
-
}
|
|
81
|
-
if (typeof value === 'boolean') {
|
|
82
|
-
return value ? 1.0 : 0.0;
|
|
83
|
-
}
|
|
84
|
-
return 0.0;
|
|
85
|
-
}
|
|
86
|
-
function castToText(value) {
|
|
87
|
-
if (typeof value === 'string') {
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
91
|
-
return String(value);
|
|
92
|
-
}
|
|
93
|
-
if (typeof value === 'boolean') {
|
|
94
|
-
return value ? '1' : '0';
|
|
95
|
-
}
|
|
96
|
-
if (value instanceof Uint8Array) {
|
|
97
|
-
// Convert blob to hex string
|
|
98
|
-
return Array.from(value, byte => byte.toString(16).padStart(2, '0')).join('').toUpperCase();
|
|
99
|
-
}
|
|
100
|
-
return String(value);
|
|
101
|
-
}
|
|
102
|
-
function castToBlob(value) {
|
|
103
|
-
if (value instanceof Uint8Array) {
|
|
104
|
-
return value;
|
|
105
|
-
}
|
|
106
|
-
if (typeof value === 'string') {
|
|
107
|
-
// Convert string to UTF-8 bytes
|
|
108
|
-
return new TextEncoder().encode(value);
|
|
109
|
-
}
|
|
110
|
-
// For other types, convert to string first then to bytes
|
|
111
|
-
return new TextEncoder().encode(String(value));
|
|
112
|
-
}
|
|
113
|
-
function castToNumeric(value) {
|
|
114
|
-
// NUMERIC affinity: prefer integer if possible, otherwise real
|
|
115
|
-
if (typeof value === 'number') {
|
|
116
|
-
return Number.isInteger(value) ? Math.trunc(value) : value;
|
|
117
|
-
}
|
|
118
|
-
if (typeof value === 'bigint') {
|
|
119
|
-
return value;
|
|
120
|
-
}
|
|
121
|
-
if (typeof value === 'string') {
|
|
122
|
-
const num = Number(value);
|
|
123
|
-
if (isNaN(num))
|
|
26
|
+
/**
|
|
27
|
+
* Fallback for when LogicalType.parse throws on invalid input.
|
|
28
|
+
* CAST in SQL is lenient: non-numeric strings cast to integer yield 0, etc.
|
|
29
|
+
*/
|
|
30
|
+
function castFallback(value, typeName) {
|
|
31
|
+
switch (typeName) {
|
|
32
|
+
case 'INTEGER':
|
|
124
33
|
return 0;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
34
|
+
case 'REAL':
|
|
35
|
+
return 0.0;
|
|
36
|
+
case 'NUMERIC':
|
|
37
|
+
return 0;
|
|
38
|
+
case 'TEXT':
|
|
39
|
+
return String(value);
|
|
40
|
+
case 'BLOB':
|
|
41
|
+
return new TextEncoder().encode(String(value));
|
|
42
|
+
default:
|
|
43
|
+
return value;
|
|
129
44
|
}
|
|
130
|
-
return 0;
|
|
131
45
|
}
|
|
132
46
|
//# sourceMappingURL=cast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cast.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cast.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"cast.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cast.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,GAAoB;IAC5D,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAE1D,SAAS,GAAG,CACX,WAA2B,EAC3B,YAAsB;QAEtB,IAAI,YAAY,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvC,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC;gBACJ,OAAO,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACxC,CAAC;YAAC,MAAM,CAAC;gBACR,uEAAuE;gBACvE,+CAA+C;gBAC/C,OAAO,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,OAAO;QACN,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACzC,GAAG,EAAE,GAAqB;QAC1B,IAAI,EAAE,QAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG;KAC3C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAe,EAAE,QAAgB;IACtD,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,SAAS;YACb,OAAO,CAAC,CAAC;QACV,KAAK,MAAM;YACV,OAAO,GAAG,CAAC;QACZ,KAAK,SAAS;YACb,OAAO,CAAC,CAAC;QACV,KAAK,MAAM;YACV,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACtB,KAAK,MAAM;YACV,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-check.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/constraint-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"constraint-check.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/constraint-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAuB9D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAoHhG"}
|
|
@@ -4,6 +4,7 @@ import { StatusCode } from '../../common/types.js';
|
|
|
4
4
|
import { RowOpFlag } from '../../schema/table.js';
|
|
5
5
|
import { withAsyncRowContext, createRowSlot } from '../context-helpers.js';
|
|
6
6
|
import { expressionToString } from '../../emit/ast-stringify.js';
|
|
7
|
+
import { composeCombinedDescriptor } from '../descriptor-helpers.js';
|
|
7
8
|
export function emitConstraintCheck(plan, ctx) {
|
|
8
9
|
// Get the table schema to access constraints
|
|
9
10
|
const tableSchema = plan.table.tableSchema;
|
|
@@ -35,7 +36,7 @@ export function emitConstraintCheck(plan, ctx) {
|
|
|
35
36
|
evaluator: evaluatorInstruction.run,
|
|
36
37
|
constraintName,
|
|
37
38
|
constraintExpr,
|
|
38
|
-
shouldDefer: Boolean(check.deferrable || check.initiallyDeferred || check.
|
|
39
|
+
shouldDefer: Boolean(check.deferrable || check.initiallyDeferred || check.needsDeferred),
|
|
39
40
|
baseTable: `${tableSchema.schemaName}.${tableSchema.name}`,
|
|
40
41
|
contextRow: undefined,
|
|
41
42
|
contextDescriptor
|
|
@@ -101,29 +102,6 @@ export function emitConstraintCheck(plan, ctx) {
|
|
|
101
102
|
note: `constraintCheck(${plan.operation}, ${contextEvaluatorInstructions.length} ctx, ${plan.constraintChecks.length} checks)`
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Composes a combined row descriptor that includes both context and flat (OLD/NEW) descriptors.
|
|
106
|
-
* Context attributes come first, followed by OLD/NEW attributes with offset indices.
|
|
107
|
-
*/
|
|
108
|
-
function composeCombinedDescriptor(contextDescriptor, flatRowDescriptor) {
|
|
109
|
-
const combined = [];
|
|
110
|
-
const contextLength = Object.keys(contextDescriptor).filter(k => contextDescriptor[parseInt(k)] !== undefined).length;
|
|
111
|
-
// Copy context descriptor as-is (indices 0..contextLength-1)
|
|
112
|
-
for (const attrIdStr in contextDescriptor) {
|
|
113
|
-
const attrId = parseInt(attrIdStr);
|
|
114
|
-
if (contextDescriptor[attrId] !== undefined) {
|
|
115
|
-
combined[attrId] = contextDescriptor[attrId];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Copy flat descriptor with offset indices (indices contextLength..end)
|
|
119
|
-
for (const attrIdStr in flatRowDescriptor) {
|
|
120
|
-
const attrId = parseInt(attrIdStr);
|
|
121
|
-
if (flatRowDescriptor[attrId] !== undefined) {
|
|
122
|
-
combined[attrId] = flatRowDescriptor[attrId] + contextLength;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return combined;
|
|
126
|
-
}
|
|
127
105
|
async function checkConstraints(rctx, plan, tableSchema, row, constraintMetadata, evaluatorFunctions) {
|
|
128
106
|
// Check PRIMARY KEY constraints (UNIQUE constraints on PK columns)
|
|
129
107
|
await checkPrimaryKeyConstraints(rctx, plan, tableSchema, row);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-check.js","sourceRoot":"","sources":["../../../../src/runtime/emit/constraint-check.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EA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K,YAAY,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC;gBACxF,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,6BAA6B,CAAC,WAAwB,EAAE,UAA+B;IAC/F,+FAA+F;IAC/F,MAAM,aAAa,GAAG,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAsB,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;IAC3G,OAAO,UAAU,aAAa,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cte-reference.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/cte-reference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAO/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"cte-reference.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/cte-reference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAO/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CA+B1F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { emitPlanNode, createValidatedInstruction } from '../emitters.js';
|
|
2
2
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
3
|
-
import {
|
|
3
|
+
import { createRowSlot } from '../context-helpers.js';
|
|
4
4
|
import { createLogger } from '../../common/logger.js';
|
|
5
5
|
const logger = createLogger('runtime:cte');
|
|
6
6
|
export function emitCTEReference(plan, ctx) {
|
|
@@ -12,10 +12,16 @@ export function emitCTEReference(plan, ctx) {
|
|
|
12
12
|
// Standard CTE reference: Use normal instruction parameter approach
|
|
13
13
|
async function* run(rctx, cteResult) {
|
|
14
14
|
logger(`Executing CTE reference ${cteAlias}`);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const slot = createRowSlot(rctx, rowDescriptor);
|
|
16
|
+
try {
|
|
17
|
+
for await (const row of cteResult) {
|
|
18
|
+
slot.set(row);
|
|
19
|
+
yield row;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
slot.close();
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
// Emit the underlying CTE
|
|
21
27
|
const cteInstruction = emitPlanNode(plan.source, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cte-reference.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cte-reference.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cte-reference.js","sourceRoot":"","sources":["../../../../src/runtime/emit/cte-reference.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa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G,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CACzE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distinct.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/distinct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"distinct.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/distinct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAyClF"}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { emitPlanNode } from '../emitters.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createCollationRowComparator, BINARY_COLLATION } from '../../util/comparison.js';
|
|
3
3
|
import { BTree } from 'inheritree';
|
|
4
4
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createRowSlot } from '../context-helpers.js';
|
|
6
6
|
export function emitDistinct(plan, ctx) {
|
|
7
7
|
// Create row descriptor for output attributes (same as source since DISTINCT preserves attributes)
|
|
8
8
|
const outputRowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
// Pre-resolve collation-based row comparator (safe for mixed-type rows)
|
|
10
|
+
const attributes = plan.getAttributes();
|
|
11
|
+
const collationRowComparator = createCollationRowComparator(attributes.map(attr => attr.type.collationName ? ctx.resolveCollation(attr.type.collationName) : BINARY_COLLATION));
|
|
12
|
+
async function* run(rctx, source) {
|
|
13
|
+
// Create BTree to efficiently track distinct rows using pre-resolved typed comparator
|
|
14
|
+
const distinctTree = new BTree((row) => row, collationRowComparator);
|
|
15
|
+
const outputSlot = createRowSlot(rctx, outputRowDescriptor);
|
|
16
|
+
try {
|
|
17
|
+
for await (const sourceRow of source) {
|
|
18
|
+
// Check if we've seen this row before using BTree lookup
|
|
19
|
+
const newPath = distinctTree.insert(sourceRow);
|
|
20
|
+
if (newPath.on) {
|
|
21
|
+
// This is a new distinct row - set up context and yield it
|
|
22
|
+
outputSlot.set(sourceRow);
|
|
23
|
+
yield sourceRow;
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
}
|
|
27
|
+
finally {
|
|
28
|
+
outputSlot.close();
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
31
|
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
23
32
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../../../src/runtime/emit/distinct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../../../src/runtime/emit/distinct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,0B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,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACF,CAAC;IAED,MAAM,iBAAiB,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEzD,OAAO;QACN,MAAM,EAAE,CAAC,iBAAiB,CAAC;QAC3B,GAAG,EAAE,GAAqB;QAC1B,IAAI,EAAE,4BAA4B;KAClC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dml-executor.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/dml-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"dml-executor.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/dml-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAA+C,MAAM,aAAa,CAAC;AAM5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAuD9D,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAkexF"}
|
|
@@ -8,6 +8,7 @@ import { buildInsertStatement, buildUpdateStatement, buildDeleteStatement } from
|
|
|
8
8
|
import { hasNativeEventSupport } from '../../util/event-support.js';
|
|
9
9
|
import { sqlValuesEqual } from '../../util/comparison.js';
|
|
10
10
|
import { withAsyncRowContext } from '../context-helpers.js';
|
|
11
|
+
import { executeForeignKeyActions } from '../foreign-key-actions.js';
|
|
11
12
|
/**
|
|
12
13
|
* Emit an automatic data change event for modules without native event support.
|
|
13
14
|
*/
|
|
@@ -155,7 +156,6 @@ export function emitDmlExecutor(plan, ctx) {
|
|
|
155
156
|
// INSERT ----------------------------------------------------
|
|
156
157
|
// Number of context evaluators (used to split params in runInsert)
|
|
157
158
|
const numContextEvaluators = contextEvaluatorInstructions.length;
|
|
158
|
-
const numUpsertEvaluators = upsertEvaluatorInstructions.length;
|
|
159
159
|
async function* runInsert(ctx, rows, ...allEvaluators) {
|
|
160
160
|
// Split evaluators: first numContextEvaluators are context, rest are upsert
|
|
161
161
|
const contextEvaluators = allEvaluators.slice(0, numContextEvaluators);
|
|
@@ -292,6 +292,8 @@ export function emitDmlExecutor(plan, ctx) {
|
|
|
292
292
|
// Track change (UPDATE): record OLD and NEW primary keys
|
|
293
293
|
const newKeyValues = tableSchema.primaryKeyDefinition.map(pkColDef => newRow[pkColDef.index]);
|
|
294
294
|
ctx.db._recordUpdate(`${tableSchema.schemaName}.${tableSchema.name}`, keyValues, newKeyValues);
|
|
295
|
+
// Execute FK cascading actions (CASCADE, SET NULL, SET DEFAULT)
|
|
296
|
+
await executeForeignKeyActions(ctx.db, tableSchema, 'update', oldRow, newRow);
|
|
295
297
|
// Emit auto event for modules without native event support
|
|
296
298
|
if (needsAutoEvents) {
|
|
297
299
|
// Compute changed columns
|
|
@@ -359,6 +361,8 @@ export function emitDmlExecutor(plan, ctx) {
|
|
|
359
361
|
}
|
|
360
362
|
// Track change (DELETE): record OLD primary key
|
|
361
363
|
ctx.db._recordDelete(`${tableSchema.schemaName}.${tableSchema.name}`, keyValues);
|
|
364
|
+
// Execute FK cascading actions (CASCADE, SET NULL, SET DEFAULT)
|
|
365
|
+
await executeForeignKeyActions(ctx.db, tableSchema, 'delete', oldRow);
|
|
362
366
|
// Emit auto event for modules without native event support
|
|
363
367
|
if (needsAutoEvents) {
|
|
364
368
|
emitAutoDataEvent(ctx, tableSchema, 'delete', keyValues, [...oldRow]);
|