@quereus/quereus 0.1.0 → 0.2.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 +47 -23
- package/dist/src/core/database.d.ts +22 -4
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +44 -6
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts +0 -7
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +1 -51
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +0 -11
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/index.d.ts +13 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -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/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +40 -44
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/analysis/const-pass.d.ts.map +1 -1
- package/dist/src/planner/analysis/const-pass.js +12 -6
- package/dist/src/planner/analysis/const-pass.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts +11 -0
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -0
- package/dist/src/planner/building/constraint-builder.js +79 -0
- package/dist/src/planner/building/constraint-builder.js.map +1 -0
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +6 -3
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts +3 -0
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +33 -7
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +4 -1
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +46 -9
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-context.js +20 -11
- package/dist/src/planner/building/select-context.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +5 -3
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +29 -20
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-projections.d.ts +3 -1
- package/dist/src/planner/building/select-projections.d.ts.map +1 -1
- package/dist/src/planner/building/select-projections.js +15 -20
- package/dist/src/planner/building/select-projections.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +6 -3
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts +25 -2
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +147 -24
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/table.d.ts +0 -10
- package/dist/src/planner/building/table.d.ts.map +1 -1
- package/dist/src/planner/building/table.js +1 -35
- 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 +7 -4
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +7 -8
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts +11 -0
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -0
- package/dist/src/planner/cache/correlation-detector.js +73 -0
- package/dist/src/planner/cache/correlation-detector.js.map +1 -0
- package/dist/src/planner/cache/materialization-advisory.d.ts +12 -18
- package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.js +65 -46
- package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
- package/dist/src/planner/cache/reference-graph.d.ts +14 -9
- package/dist/src/planner/cache/reference-graph.d.ts.map +1 -1
- package/dist/src/planner/cache/reference-graph.js +93 -84
- package/dist/src/planner/cache/reference-graph.js.map +1 -1
- package/dist/src/planner/debug.d.ts +25 -0
- package/dist/src/planner/debug.d.ts.map +1 -1
- package/dist/src/planner/debug.js +127 -0
- package/dist/src/planner/debug.js.map +1 -1
- package/dist/src/planner/framework/context.d.ts +11 -0
- package/dist/src/planner/framework/context.d.ts.map +1 -1
- package/dist/src/planner/framework/context.js +25 -2
- package/dist/src/planner/framework/context.js.map +1 -1
- package/dist/src/planner/framework/registry.d.ts +3 -7
- package/dist/src/planner/framework/registry.d.ts.map +1 -1
- package/dist/src/planner/framework/registry.js +20 -31
- package/dist/src/planner/framework/registry.js.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts +2 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.js +3 -0
- package/dist/src/planner/nodes/add-constraint-node.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +6 -4
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cache-node.js +2 -2
- package/dist/src/planner/nodes/cache-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +11 -4
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js +38 -12
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/create-index-node.d.ts +2 -1
- package/dist/src/planner/nodes/create-index-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/create-index-node.js +3 -0
- package/dist/src/planner/nodes/create-index-node.js.map +1 -1
- package/dist/src/planner/nodes/create-table-node.d.ts +2 -1
- package/dist/src/planner/nodes/create-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/create-table-node.js +3 -0
- package/dist/src/planner/nodes/create-table-node.js.map +1 -1
- package/dist/src/planner/nodes/create-view-node.d.ts +2 -1
- package/dist/src/planner/nodes/create-view-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/create-view-node.js +3 -0
- package/dist/src/planner/nodes/create-view-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +33 -12
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.d.ts +18 -4
- package/dist/src/planner/nodes/cte-reference-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.js +40 -10
- package/dist/src/planner/nodes/cte-reference-node.js.map +1 -1
- package/dist/src/planner/nodes/delete-node.d.ts +4 -3
- package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/delete-node.js +20 -6
- package/dist/src/planner/nodes/delete-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 +2 -2
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +2 -2
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/planner/nodes/drop-table-node.d.ts +2 -1
- package/dist/src/planner/nodes/drop-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-table-node.js +3 -0
- package/dist/src/planner/nodes/drop-table-node.js.map +1 -1
- package/dist/src/planner/nodes/drop-view-node.d.ts +2 -1
- package/dist/src/planner/nodes/drop-view-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-view-node.js +3 -0
- package/dist/src/planner/nodes/drop-view-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +3 -3
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/insert-node.d.ts +2 -1
- package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/insert-node.js +18 -5
- package/dist/src/planner/nodes/insert-node.js.map +1 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts +28 -0
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js +69 -0
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +1 -0
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +3 -3
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +2 -2
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +23 -0
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +25 -2
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/project-node.d.ts +5 -1
- package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +39 -20
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.d.ts +2 -2
- package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.js +20 -8
- package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +4 -2
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +21 -13
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts +26 -2
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +82 -10
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sequencing-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/sequencing-node.js +2 -2
- package/dist/src/planner/nodes/sequencing-node.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 +3 -3
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/single-row.d.ts +4 -2
- package/dist/src/planner/nodes/single-row.d.ts.map +1 -1
- package/dist/src/planner/nodes/single-row.js +3 -0
- package/dist/src/planner/nodes/single-row.js.map +1 -1
- package/dist/src/planner/nodes/sink-node.d.ts +1 -1
- package/dist/src/planner/nodes/sink-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/sink-node.js +4 -4
- package/dist/src/planner/nodes/sink-node.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +2 -2
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -0
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +64 -11
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/subquery.d.ts +4 -4
- package/dist/src/planner/nodes/subquery.d.ts.map +1 -1
- package/dist/src/planner/nodes/subquery.js +68 -23
- package/dist/src/planner/nodes/subquery.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +83 -0
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -0
- package/dist/src/planner/nodes/table-access-nodes.js +226 -0
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -0
- package/dist/src/planner/nodes/update-node.d.ts +4 -2
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +26 -13
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +25 -23
- 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 +46 -50
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +13 -0
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/planning-context.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts +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 +59 -53
- 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 +62 -2
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js +31 -24
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +1 -1
- package/dist/src/planner/scopes/base.d.ts +0 -10
- package/dist/src/planner/scopes/base.d.ts.map +1 -1
- package/dist/src/planner/scopes/base.js +0 -14
- package/dist/src/planner/scopes/base.js.map +1 -1
- package/dist/src/planner/scopes/empty.d.ts +0 -2
- package/dist/src/planner/scopes/empty.d.ts.map +1 -1
- package/dist/src/planner/scopes/empty.js +0 -8
- package/dist/src/planner/scopes/empty.js.map +1 -1
- package/dist/src/planner/scopes/multi.d.ts.map +1 -1
- package/dist/src/planner/scopes/multi.js +0 -1
- package/dist/src/planner/scopes/multi.js.map +1 -1
- package/dist/src/planner/scopes/param.d.ts.map +1 -1
- package/dist/src/planner/scopes/param.js +0 -1
- package/dist/src/planner/scopes/param.js.map +1 -1
- package/dist/src/planner/scopes/registered.d.ts +0 -10
- package/dist/src/planner/scopes/registered.d.ts.map +1 -1
- package/dist/src/planner/scopes/registered.js +1 -17
- package/dist/src/planner/scopes/registered.js.map +1 -1
- package/dist/src/planner/scopes/scope.d.ts +0 -8
- package/dist/src/planner/scopes/scope.d.ts.map +1 -1
- package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
- package/dist/src/planner/validation/plan-validator.js +1 -7
- package/dist/src/planner/validation/plan-validator.js.map +1 -1
- package/dist/src/runtime/context-helpers.d.ts +45 -0
- package/dist/src/runtime/context-helpers.d.ts.map +1 -0
- package/dist/src/runtime/context-helpers.js +139 -0
- package/dist/src/runtime/context-helpers.js.map +1 -0
- package/dist/src/runtime/emission-context.d.ts +1 -0
- package/dist/src/runtime/emission-context.d.ts.map +1 -1
- package/dist/src/runtime/emission-context.js +2 -1
- 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 +119 -86
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/between.d.ts +5 -0
- package/dist/src/runtime/emit/between.d.ts.map +1 -0
- package/dist/src/runtime/emit/between.js +38 -0
- package/dist/src/runtime/emit/between.js.map +1 -0
- package/dist/src/runtime/emit/binary.d.ts +0 -1
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +0 -36
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/column-reference.d.ts.map +1 -1
- package/dist/src/runtime/emit/column-reference.js +2 -26
- package/dist/src/runtime/emit/column-reference.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +14 -121
- 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 +16 -48
- 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 +2 -8
- package/dist/src/runtime/emit/distinct.js.map +1 -1
- package/dist/src/runtime/emit/filter.d.ts.map +1 -1
- package/dist/src/runtime/emit/filter.js +6 -13
- package/dist/src/runtime/emit/filter.js.map +1 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.d.ts +5 -0
- package/dist/src/runtime/emit/internal-recursive-cte-ref.d.ts.map +1 -0
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js +23 -0
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +1 -0
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +40 -40
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/project.d.ts.map +1 -1
- package/dist/src/runtime/emit/project.js +13 -13
- 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 +3 -14
- 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 +7 -14
- package/dist/src/runtime/emit/returning.js.map +1 -1
- package/dist/src/runtime/emit/scan.d.ts +5 -2
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +21 -17
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/sort.d.ts.map +1 -1
- package/dist/src/runtime/emit/sort.js +8 -11
- package/dist/src/runtime/emit/sort.js.map +1 -1
- package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
- package/dist/src/runtime/emit/subquery.js +95 -40
- 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 +7 -22
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +20 -27
- 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 +55 -83
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/emitters.d.ts.map +1 -1
- package/dist/src/runtime/emitters.js +49 -1
- package/dist/src/runtime/emitters.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +5 -4
- 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 +47 -42
- package/dist/src/runtime/scheduler.js.map +1 -1
- package/dist/src/runtime/types.d.ts +34 -0
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js +21 -0
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +29 -16
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/util/plugin-loader.d.ts +10 -1
- package/dist/src/util/plugin-loader.d.ts.map +1 -1
- package/dist/src/util/plugin-loader.js +56 -1
- package/dist/src/util/plugin-loader.js.map +1 -1
- package/dist/src/util/working-table-iterable.d.ts.map +1 -1
- package/dist/src/util/working-table-iterable.js +8 -8
- package/dist/src/util/working-table-iterable.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts +36 -0
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/core/database.ts +48 -6
- package/src/core/statement.ts +1 -49
- package/src/func/builtins/explain.ts +0 -11
- package/src/index.ts +39 -5
- package/src/parser/ast.ts +11 -2
- package/src/parser/parser.ts +40 -47
- package/src/planner/analysis/const-pass.ts +281 -270
- package/src/planner/building/constraint-builder.ts +114 -0
- package/src/planner/building/delete.ts +16 -3
- package/src/planner/building/expression.ts +35 -7
- package/src/planner/building/insert.ts +14 -1
- package/src/planner/building/select-aggregates.ts +57 -11
- package/src/planner/building/select-context.ts +22 -12
- package/src/planner/building/select-modifiers.ts +35 -21
- package/src/planner/building/select-projections.ts +25 -26
- package/src/planner/building/select-window.ts +14 -9
- package/src/planner/building/select.ts +163 -31
- package/src/planner/building/table.ts +1 -40
- package/src/planner/building/update.ts +19 -4
- package/src/planner/building/with.ts +12 -13
- package/src/planner/cache/correlation-detector.ts +83 -0
- package/src/planner/cache/materialization-advisory.ts +71 -50
- package/src/planner/cache/reference-graph.ts +115 -91
- package/src/planner/debug.ts +163 -0
- package/src/planner/framework/context.ts +36 -2
- package/src/planner/framework/registry.ts +261 -274
- package/src/planner/nodes/add-constraint-node.ts +5 -1
- package/src/planner/nodes/aggregate-node.ts +6 -4
- package/src/planner/nodes/cache-node.ts +2 -2
- package/src/planner/nodes/constraint-check-node.ts +47 -13
- package/src/planner/nodes/create-index-node.ts +5 -1
- package/src/planner/nodes/create-table-node.ts +5 -1
- package/src/planner/nodes/create-view-node.ts +5 -1
- package/src/planner/nodes/cte-node.ts +45 -14
- package/src/planner/nodes/cte-reference-node.ts +49 -13
- package/src/planner/nodes/delete-node.ts +31 -7
- package/src/planner/nodes/distinct-node.ts +2 -2
- package/src/planner/nodes/dml-executor-node.ts +2 -2
- package/src/planner/nodes/drop-table-node.ts +5 -1
- package/src/planner/nodes/drop-view-node.ts +5 -1
- package/src/planner/nodes/filter.ts +3 -3
- package/src/planner/nodes/function.ts +93 -93
- package/src/planner/nodes/insert-node.ts +28 -5
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +76 -0
- package/src/planner/nodes/join-node.ts +3 -3
- package/src/planner/nodes/limit-offset.ts +2 -2
- package/src/planner/nodes/plan-node-type.ts +1 -1
- package/src/planner/nodes/plan-node.ts +39 -2
- package/src/planner/nodes/project-node.ts +39 -19
- package/src/planner/nodes/recursive-cte-node.ts +37 -9
- package/src/planner/nodes/reference.ts +4 -2
- package/src/planner/nodes/returning-node.ts +25 -13
- package/src/planner/nodes/scalar.ts +95 -11
- package/src/planner/nodes/sequencing-node.ts +2 -2
- package/src/planner/nodes/set-operation-node.ts +3 -3
- package/src/planner/nodes/single-row.ts +7 -2
- package/src/planner/nodes/sink-node.ts +5 -5
- package/src/planner/nodes/sort.ts +2 -2
- package/src/planner/nodes/stream-aggregate.ts +76 -12
- package/src/planner/nodes/subquery.ts +90 -27
- package/src/planner/nodes/{physical-access-nodes.ts → table-access-nodes.ts} +6 -6
- package/src/planner/nodes/update-node.ts +31 -13
- package/src/planner/nodes/window-node.ts +28 -22
- package/src/planner/optimizer.ts +257 -263
- package/src/planner/planning-context.ts +15 -0
- package/src/planner/rules/access/rule-select-access-path.ts +68 -64
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +74 -2
- package/src/planner/rules/cache/rule-materialization-advisory.ts +31 -27
- package/src/planner/scopes/base.ts +0 -17
- package/src/planner/scopes/empty.ts +0 -10
- package/src/planner/scopes/multi.ts +0 -1
- package/src/planner/scopes/param.ts +0 -1
- package/src/planner/scopes/registered.ts +1 -20
- package/src/planner/scopes/scope.ts +0 -12
- package/src/planner/validation/plan-validator.ts +1 -8
- package/src/runtime/context-helpers.ts +191 -0
- package/src/runtime/emission-context.ts +5 -2
- package/src/runtime/emit/aggregate.ts +131 -85
- package/src/runtime/emit/between.ts +51 -0
- package/src/runtime/emit/binary.ts +0 -46
- package/src/runtime/emit/column-reference.ts +3 -36
- package/src/runtime/emit/constraint-check.ts +17 -142
- package/src/runtime/emit/cte-reference.ts +23 -60
- package/src/runtime/emit/distinct.ts +2 -7
- package/src/runtime/emit/filter.ts +6 -13
- package/src/runtime/emit/internal-recursive-cte-ref.ts +37 -0
- package/src/runtime/emit/join.ts +45 -43
- package/src/runtime/emit/project.ts +18 -12
- package/src/runtime/emit/recursive-cte.ts +3 -12
- package/src/runtime/emit/returning.ts +7 -14
- package/src/runtime/emit/scan.ts +25 -23
- package/src/runtime/emit/sort.ts +8 -11
- package/src/runtime/emit/subquery.ts +108 -48
- package/src/runtime/emit/table-valued-function.ts +7 -20
- package/src/runtime/emit/update.ts +22 -29
- package/src/runtime/emit/window.ts +74 -88
- package/src/runtime/emitters.ts +52 -1
- package/src/runtime/register.ts +5 -4
- package/src/runtime/scheduler.ts +54 -54
- package/src/runtime/types.ts +45 -0
- package/src/schema/manager.ts +34 -19
- package/src/util/plugin-loader.ts +78 -4
- package/src/util/working-table-iterable.ts +15 -7
- package/src/vtab/manifest.ts +42 -0
- package/src/planner/nodes/scan.ts +0 -103
- package/src/planner/rules/physical/rule-mark-physical.ts +0 -37
- package/src/runtime/emit/table-reference.ts +0 -92
|
@@ -2,6 +2,7 @@ import { emitCallFromPlan, emitPlanNode } from '../emitters.js';
|
|
|
2
2
|
import { createLogger } from '../../common/logger.js';
|
|
3
3
|
import { compareSqlValues } from '../../util/comparison.js';
|
|
4
4
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
5
|
+
import { createRowSlot } from '../context-helpers.js';
|
|
5
6
|
const log = createLogger('runtime:emit:join');
|
|
6
7
|
/**
|
|
7
8
|
* Emits a nested loop join instruction.
|
|
@@ -17,39 +18,37 @@ export function emitLoopJoin(plan, ctx) {
|
|
|
17
18
|
async function* run(rctx, leftSource, rightCallback, conditionCallback) {
|
|
18
19
|
const joinType = plan.joinType;
|
|
19
20
|
log('Starting %s join between %d left attrs and %d right attrs', joinType.toUpperCase(), leftAttributes.length, rightAttributes.length);
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
// Create row slots for efficient context management
|
|
22
|
+
const leftSlot = createRowSlot(rctx, leftRowDescriptor);
|
|
23
|
+
const rightSlot = createRowSlot(rctx, rightRowDescriptor);
|
|
24
|
+
try {
|
|
25
|
+
// Process left side and join with right (pure streaming)
|
|
26
|
+
for await (const leftRow of leftSource) {
|
|
27
|
+
// Set up left context
|
|
28
|
+
leftSlot.set(leftRow);
|
|
25
29
|
let leftMatched = false;
|
|
26
30
|
// Stream through right side for each left row
|
|
27
31
|
for await (const rightRow of rightCallback(rctx)) {
|
|
28
32
|
// Set up right context
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
conditionMet = !!conditionResult; // Convert to boolean
|
|
37
|
-
}
|
|
38
|
-
else if (plan.usingColumns) {
|
|
39
|
-
// Handle USING condition: check equality of specified columns
|
|
40
|
-
conditionMet = evaluateUsingCondition(leftRow, rightRow, plan.usingColumns, leftAttributes, rightAttributes);
|
|
41
|
-
}
|
|
42
|
-
else if (joinType === 'cross') {
|
|
43
|
-
// Cross join - always true
|
|
44
|
-
conditionMet = true;
|
|
45
|
-
}
|
|
46
|
-
if (conditionMet) {
|
|
47
|
-
leftMatched = true;
|
|
48
|
-
yield [...leftRow, ...rightRow];
|
|
49
|
-
}
|
|
33
|
+
rightSlot.set(rightRow);
|
|
34
|
+
// Evaluate join condition
|
|
35
|
+
let conditionMet = true;
|
|
36
|
+
if (conditionCallback) {
|
|
37
|
+
// Evaluate the join condition using the callback provided by scheduler
|
|
38
|
+
const conditionResult = await conditionCallback(rctx);
|
|
39
|
+
conditionMet = !!conditionResult; // Convert to boolean
|
|
50
40
|
}
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
else if (plan.usingColumns) {
|
|
42
|
+
// Handle USING condition: check equality of specified columns
|
|
43
|
+
conditionMet = evaluateUsingCondition(leftRow, rightRow, plan.usingColumns, leftAttributes, rightAttributes);
|
|
44
|
+
}
|
|
45
|
+
else if (joinType === 'cross') {
|
|
46
|
+
// Cross join - always true
|
|
47
|
+
conditionMet = true;
|
|
48
|
+
}
|
|
49
|
+
if (conditionMet) {
|
|
50
|
+
leftMatched = true;
|
|
51
|
+
yield [...leftRow, ...rightRow];
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
// Handle outer join semantics - null padding for unmatched left rows
|
|
@@ -60,20 +59,21 @@ export function emitLoopJoin(plan, ctx) {
|
|
|
60
59
|
yield outputRow;
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
// Handle right outer join semantics - we need to track which right rows were matched
|
|
63
|
+
// For now, we'll handle this in a simpler way by iterating again for right/full outer joins
|
|
64
|
+
if (joinType === 'right' || joinType === 'full') {
|
|
65
|
+
// For right outer joins, we need to find unmatched right rows
|
|
66
|
+
// This is more complex and less efficient - a real implementation would track matches
|
|
67
|
+
// For now, we'll implement a simplified version
|
|
68
|
+
log('Right/full outer join - checking for unmatched right rows');
|
|
69
|
+
// We'd need to track which right rows were matched during the main loop
|
|
70
|
+
// For now, we'll skip this implementation detail
|
|
71
|
+
// TODO: Implement proper right outer join semantics
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// For right outer joins, we need to find unmatched right rows
|
|
71
|
-
// This is more complex and less efficient - a real implementation would track matches
|
|
72
|
-
// For now, we'll implement a simplified version
|
|
73
|
-
log('Right/full outer join - checking for unmatched right rows');
|
|
74
|
-
// We'd need to track which right rows were matched during the main loop
|
|
75
|
-
// For now, we'll skip this implementation detail
|
|
76
|
-
// TODO: Implement proper right outer join semantics
|
|
74
|
+
finally {
|
|
75
|
+
leftSlot.close();
|
|
76
|
+
rightSlot.close();
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
const leftInstruction = emitPlanNode(plan.left, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../../../src/runtime/emit/join.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,GAAG,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,GAAoB;IAChE,mDAAmD;IACnD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IACjD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACnD,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAE/D,oFAAoF;IACpF,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,IAAoB,EAAE,UAA8B,EAAE,aAA0D,EAAE,iBAAgD;QACrL,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE/B,GAAG,CAAC,2DAA2D,EAC9D,QAAQ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WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAoChF"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
2
2
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
3
|
+
import { withAsyncRowContext, withRowContextGenerator } from '../context-helpers.js';
|
|
3
4
|
export function emitProject(plan, ctx) {
|
|
4
5
|
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
5
6
|
const projectionFuncs = plan.projections.map((projection) => {
|
|
6
7
|
return emitCallFromPlan(projection.node, ctx);
|
|
7
8
|
});
|
|
8
|
-
//
|
|
9
|
+
// Row descriptors
|
|
9
10
|
const sourceRowDescriptor = buildRowDescriptor(plan.source.getAttributes());
|
|
11
|
+
const outputRowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
10
12
|
async function* run(rctx, source, ...projectionFunctions) {
|
|
11
13
|
for await (const sourceRow of source) {
|
|
12
|
-
//
|
|
13
|
-
rctx
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
yield
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
rctx.context.delete(sourceRowDescriptor);
|
|
23
|
-
}
|
|
14
|
+
// Evaluate projections using the source row context
|
|
15
|
+
const outputs = await withAsyncRowContext(rctx, sourceRowDescriptor, () => sourceRow, async () => {
|
|
16
|
+
return Promise.all(projectionFunctions.map(fn => fn(rctx)));
|
|
17
|
+
});
|
|
18
|
+
// Push the output row descriptor for downstream consumers
|
|
19
|
+
yield* withRowContextGenerator(rctx, outputRowDescriptor, (async function* () {
|
|
20
|
+
yield outputs;
|
|
21
|
+
})(), async function* (row) {
|
|
22
|
+
yield row;
|
|
23
|
+
});
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../src/runtime/emit/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../src/runtime/emit/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErF,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,GAAoB;IAClE,MAAM,iBAAiB,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAC3D,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,kBAAkB;IAClB,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5E,MAAM,mBAAmB,GAAG,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"recursive-cte.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/recursive-cte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAe9D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CA0F1F"}
|
|
@@ -7,6 +7,7 @@ import { DEFAULT_TUNING } from '../../planner/optimizer-tuning.js';
|
|
|
7
7
|
import { quereusError } from '../../common/errors.js';
|
|
8
8
|
import { StatusCode } from '../../common/types.js';
|
|
9
9
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
10
|
+
import { withRowContext } from '../context-helpers.js';
|
|
10
11
|
const log = createLogger('runtime:emit:recursive-cte');
|
|
11
12
|
export function emitRecursiveCTE(plan, ctx) {
|
|
12
13
|
// Create row descriptor for CTE output attributes
|
|
@@ -28,13 +29,7 @@ export function emitRecursiveCTE(plan, ctx) {
|
|
|
28
29
|
const shouldYield = !allRowsTree || allRowsTree.insert(row).on;
|
|
29
30
|
if (shouldYield) {
|
|
30
31
|
// Yield immediately (streaming)
|
|
31
|
-
rctx
|
|
32
|
-
try {
|
|
33
|
-
yield row;
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
rctx.context.delete(rowDescriptor);
|
|
37
|
-
}
|
|
32
|
+
yield withRowContext(rctx, rowDescriptor, () => row, () => row);
|
|
38
33
|
// Add to delta for recursive processing (deep copy to avoid reference issues)
|
|
39
34
|
deltaRows.push([...row]);
|
|
40
35
|
}
|
|
@@ -56,13 +51,7 @@ export function emitRecursiveCTE(plan, ctx) {
|
|
|
56
51
|
const shouldYield = !allRowsTree || allRowsTree.insert(row).on;
|
|
57
52
|
if (shouldYield) {
|
|
58
53
|
// Stream the row immediately
|
|
59
|
-
rctx
|
|
60
|
-
try {
|
|
61
|
-
yield row;
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
rctx.context.delete(rowDescriptor);
|
|
65
|
-
}
|
|
54
|
+
yield withRowContext(rctx, rowDescriptor, () => row, () => row);
|
|
66
55
|
// Add to next iteration's delta (deep copy to avoid reference issues)
|
|
67
56
|
newDeltaRows.push([...row]);
|
|
68
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recursive-cte.js","sourceRoot":"","sources":["../../../../src/runtime/emit/recursive-cte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"recursive-cte.js","sourceRoot":"","sources":["../../../../src/runtime/emit/recursive-cte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO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GAAG,CAAC,CAAC;wBAEhE,sEAAsE;wBACtE,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAQ,CAAC,CAAC;oBACpC,CAAC;gBACF,CAAC;YACF,CAAC;oBAAS,CAAC;gBACV,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC5C,CAAC;YAED,0EAA0E;YAC1E,SAAS,GAAG,YAAY,CAAC;QAC1B,CAAC;QAED,sCAAsC;QACtC,IAAI,cAAc,IAAI,aAAa,EAAE,CAAC;YACrC,YAAY,CACX,kBAAkB,IAAI,CAAC,OAAO,uCAAuC,aAAa,GAAG,EACrF,UAAU,CAAC,KAAK,CAChB,CAAC;QACH,CAAC;QAED,GAAG,CAAC,uEAAuE,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC5G,CAAC;IAED,sDAAsD;IACtD,MAAM,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAClE,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IAEhF,OAAO;QACN,MAAM,EAAE,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;QACvD,GAAG;QACH,IAAI,EAAE,gBAAgB,IAAI,CAAC,OAAO,GAAG;KACrC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"returning.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/returning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"returning.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/returning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9D,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAgCpF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
2
2
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
3
|
+
import { withRowContextGenerator } from '../context-helpers.js';
|
|
3
4
|
export function emitReturning(plan, ctx) {
|
|
4
5
|
// Use the executor's attributes to build the row descriptor
|
|
5
6
|
// The executor should already output the correct flat OLD/NEW format for mutation operations
|
|
@@ -8,20 +9,12 @@ export function emitReturning(plan, ctx) {
|
|
|
8
9
|
const projectionEvaluators = plan.projections.map(proj => emitCallFromPlan(proj.node, ctx));
|
|
9
10
|
async function* run(rctx, executorRows, ...projectionCallbacks) {
|
|
10
11
|
// Project the results from the executor rows
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const resolved = await Promise.all(outputs);
|
|
18
|
-
yield resolved;
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
// Clean up source context
|
|
22
|
-
rctx.context.delete(sourceRowDescriptor);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
12
|
+
yield* withRowContextGenerator(rctx, sourceRowDescriptor, executorRows, async function* (_sourceRow) {
|
|
13
|
+
// Evaluate projection expressions in the context of this row
|
|
14
|
+
const outputs = projectionCallbacks.map(func => func(rctx));
|
|
15
|
+
const resolved = await Promise.all(outputs);
|
|
16
|
+
yield resolved;
|
|
17
|
+
});
|
|
25
18
|
}
|
|
26
19
|
// Emit the executor (now always produces rows)
|
|
27
20
|
const executorInstruction = emitPlanNode(plan.executor, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"returning.js","sourceRoot":"","sources":["../../../../src/runtime/emit/returning.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"returning.js","sourceRoot":"","sources":["../../../../src/runtime/emit/returning.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,UAAU,aAAa,CAAC,IAAmB,EAAE,GAAoB;IACtE,4DAA4D;IAC5D,6FAA6F;IAC7F,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAE9E,sCAAsC;IACtC,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CACxD,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAChC,CAAC;IAEF,KAAK,SAAS,CAAC,CAAC,GAAG,CAClB,IAAoB,EACpB,YAAgC,EAChC,GAAG,mBAAwD;QAE3D,6CAA6C;QAC7C,KAAK,CAAC,CAAC,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,UAAU;YAClG,6DAA6D;YAC7D,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC5C,MAAM,QAAe,CAAC;QACvB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,MAAM,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE7D,OAAO;QACN,MAAM,EAAE,CAAC,mBAAmB,EAAE,GAAG,oBAAoB,CAAC;QACtD,GAAG;QACH,IAAI,EAAE,aAAa,IAAI,CAAC,WAAW,CAAC,MAAM,QAAQ;KAClD,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SeqScanNode, IndexScanNode, IndexSeekNode } from "../../planner/nodes/table-access-nodes.js";
|
|
2
2
|
import type { Instruction } from "../types.js";
|
|
3
3
|
import type { EmissionContext } from "../emission-context.js";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Emits instructions for physical table access nodes (SeqScan, IndexScan, IndexSeek)
|
|
6
|
+
*/
|
|
7
|
+
export declare function emitSeqScan(plan: SeqScanNode | IndexScanNode | IndexSeekNode, ctx: EmissionContext): Instruction;
|
|
5
8
|
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/scan.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAItG,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,aAAa,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CA0EhH"}
|
|
@@ -3,61 +3,65 @@ import { QuereusError } from "../../common/errors.js";
|
|
|
3
3
|
import { createValidatedInstruction } from "../emitters.js";
|
|
4
4
|
import { disconnectVTable } from "../utils.js";
|
|
5
5
|
import { buildRowDescriptor } from "../../util/row-descriptor.js";
|
|
6
|
+
import { createRowSlot } from "../context-helpers.js";
|
|
7
|
+
/**
|
|
8
|
+
* Emits instructions for physical table access nodes (SeqScan, IndexScan, IndexSeek)
|
|
9
|
+
*/
|
|
6
10
|
export function emitSeqScan(plan, ctx) {
|
|
7
|
-
|
|
11
|
+
// Handle physical access nodes
|
|
12
|
+
const source = plan.source;
|
|
13
|
+
const schema = source.tableSchema;
|
|
8
14
|
// Create row descriptor mapping attribute IDs to column indices
|
|
9
15
|
const rowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
10
16
|
// Look up the virtual table module during emission and record the dependency
|
|
11
|
-
const moduleInfo = ctx.getVtabModule(
|
|
17
|
+
const moduleInfo = ctx.getVtabModule(schema.vtabModuleName);
|
|
12
18
|
if (!moduleInfo) {
|
|
13
|
-
throw new QuereusError(`Virtual table module '${
|
|
19
|
+
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' not found`, StatusCode.ERROR);
|
|
14
20
|
}
|
|
15
21
|
// Capture the module info key for runtime retrieval
|
|
16
|
-
const moduleKey = `vtab_module:${
|
|
22
|
+
const moduleKey = `vtab_module:${schema.vtabModuleName}`;
|
|
17
23
|
async function* run(runtimeCtx) {
|
|
18
24
|
// Use the captured module info instead of doing a fresh lookup
|
|
19
25
|
const capturedModuleInfo = ctx.getCapturedSchemaObject(moduleKey);
|
|
20
26
|
if (!capturedModuleInfo) {
|
|
21
|
-
throw new QuereusError(`Virtual table module '${
|
|
27
|
+
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' was not captured during emission`, StatusCode.INTERNAL);
|
|
22
28
|
}
|
|
23
29
|
const module = capturedModuleInfo.module;
|
|
24
30
|
if (typeof module.xConnect !== 'function') {
|
|
25
|
-
throw new QuereusError(`Virtual table module '${
|
|
31
|
+
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' does not implement xConnect`, StatusCode.MISUSE);
|
|
26
32
|
}
|
|
27
33
|
let vtabInstance;
|
|
28
34
|
try {
|
|
29
35
|
const options = {}; // TODO: Populate options from plan.source.tableSchema.vtabArgs or similar if needed
|
|
30
|
-
vtabInstance = module.xConnect(runtimeCtx.db, capturedModuleInfo.auxData,
|
|
36
|
+
vtabInstance = module.xConnect(runtimeCtx.db, capturedModuleInfo.auxData, schema.vtabModuleName, schema.schemaName, schema.name, options);
|
|
31
37
|
}
|
|
32
38
|
catch (e) {
|
|
33
39
|
const message = e instanceof Error ? e.message : String(e);
|
|
34
|
-
throw new QuereusError(`Module '${
|
|
40
|
+
throw new QuereusError(`Module '${schema.vtabModuleName}' xConnect failed for table '${schema.name}': ${message}`, e instanceof QuereusError ? e.code : StatusCode.ERROR, e instanceof Error ? e : undefined);
|
|
35
41
|
}
|
|
36
42
|
if (typeof vtabInstance.xQuery !== 'function') {
|
|
37
43
|
// Fallback or error if xQuery is not available. For now, throwing an error.
|
|
38
44
|
// Later, we could implement the xOpen/xFilter/xNext loop here as a fallback.
|
|
39
|
-
throw new QuereusError(`Virtual table '${
|
|
45
|
+
throw new QuereusError(`Virtual table '${schema.name}' does not support xQuery.`, StatusCode.UNSUPPORTED);
|
|
40
46
|
}
|
|
47
|
+
const rowSlot = createRowSlot(runtimeCtx, rowDescriptor);
|
|
41
48
|
try {
|
|
42
|
-
// Put cursor row into context using row descriptor
|
|
43
|
-
let row;
|
|
44
|
-
runtimeCtx.context.set(rowDescriptor, () => row);
|
|
45
49
|
const asyncRowIterable = vtabInstance.xQuery(plan.filterInfo);
|
|
46
|
-
for await (row of asyncRowIterable) {
|
|
50
|
+
for await (const row of asyncRowIterable) {
|
|
51
|
+
rowSlot.set(row);
|
|
47
52
|
yield row;
|
|
48
53
|
}
|
|
49
|
-
// Remove cursor row from context
|
|
50
|
-
runtimeCtx.context.delete(rowDescriptor);
|
|
51
54
|
}
|
|
52
55
|
catch (e) {
|
|
53
56
|
const message = e instanceof Error ? e.message : String(e);
|
|
54
|
-
throw new QuereusError(`Error during xQuery on table '${
|
|
57
|
+
throw new QuereusError(`Error during xQuery on table '${schema.name}': ${message}`, e instanceof QuereusError ? e.code : StatusCode.ERROR, e instanceof Error ? e : undefined);
|
|
55
58
|
}
|
|
56
59
|
finally {
|
|
60
|
+
rowSlot.close();
|
|
57
61
|
// Properly disconnect the VirtualTable instance
|
|
58
62
|
await disconnectVTable(runtimeCtx, vtabInstance);
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
|
-
return createValidatedInstruction([], run, ctx,
|
|
65
|
+
return createValidatedInstruction([], run, ctx, `${plan.nodeType}(${schema.name})`);
|
|
62
66
|
}
|
|
63
67
|
//# sourceMappingURL=scan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/runtime/emit/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/runtime/emit/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,O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AC;QAAC,OAAO,CAAM,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,IAAI,YAAY,CAAC,iCAAiC,MAAM,CAAC,IAAI,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAChL,CAAC;gBAAS,CAAC;YACV,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,gDAAgD;YAChD,MAAM,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IAED,OAAO,0BAA0B,CAChC,EAAE,EACF,GAAG,EACH,GAAG,EACH,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,GAAG,CAClC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAiE1E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
2
2
|
import { createOrderByComparatorFast, resolveCollation } from '../../util/comparison.js';
|
|
3
3
|
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
4
|
+
import { withAsyncRowContext } from '../context-helpers.js';
|
|
4
5
|
export function emitSort(plan, ctx) {
|
|
5
6
|
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
6
7
|
// Create row descriptor for source attributes
|
|
@@ -17,20 +18,16 @@ export function emitSort(plan, ctx) {
|
|
|
17
18
|
// Collect all rows with their sort key values
|
|
18
19
|
const rowsWithKeys = [];
|
|
19
20
|
for await (const sourceRow of source) {
|
|
20
|
-
|
|
21
|
-
ctx.context.set(sourceRowDescriptor, () => sourceRow);
|
|
22
|
-
try {
|
|
21
|
+
const keys = await withAsyncRowContext(ctx, sourceRowDescriptor, () => sourceRow, async () => {
|
|
23
22
|
// Evaluate sort key expressions
|
|
24
|
-
const
|
|
23
|
+
const keyValues = [];
|
|
25
24
|
for (const keyFunc of sortKeyFunctions) {
|
|
26
|
-
|
|
25
|
+
const result = keyFunc(ctx);
|
|
26
|
+
keyValues.push(await Promise.resolve(result));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Clean up context for this row
|
|
32
|
-
ctx.context.delete(sourceRowDescriptor);
|
|
33
|
-
}
|
|
28
|
+
return keyValues;
|
|
29
|
+
});
|
|
30
|
+
rowsWithKeys.push({ row: sourceRow, keys });
|
|
34
31
|
}
|
|
35
32
|
// Sort the collected rows using pre-created optimized comparators
|
|
36
33
|
rowsWithKeys.sort((a, b) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","s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AU,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE9C,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;oBACtB,OAAO,UAAU,CAAC;gBACnB,CAAC;YACF,CAAC;YACD,OAAO,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;QAEH,oBAAoB;QACpB,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,YAAY,EAAE,CAAC;YACpC,MAAM,GAAG,CAAC;QACX,CAAC;IACF,CAAC;IAED,OAAO;QACN,MAAM,EAAE,CAAC,iBAAiB,EAAE,GAAG,mBAAmB,CAAC;QACnD,GAAG,EAAE,GAAU;QACf,IAAI,EAAE,QAAQ,IAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ;KAC1C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subquery.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/subquery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"subquery.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/subquery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CA2B9F;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAiJtE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAe9E"}
|