@quereus/quereus 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +19 -18
- package/package.json +3 -3
- package/dist/src/common/constants.js.map +0 -1
- package/dist/src/common/datatype.js.map +0 -1
- package/dist/src/common/errors.js.map +0 -1
- package/dist/src/common/json-types.js.map +0 -1
- package/dist/src/common/logger.js.map +0 -1
- package/dist/src/common/type-inference.js.map +0 -1
- package/dist/src/common/types.js.map +0 -1
- package/dist/src/core/database-options.js.map +0 -1
- package/dist/src/core/database.js.map +0 -1
- package/dist/src/core/param.js.map +0 -1
- package/dist/src/core/statement.js.map +0 -1
- package/dist/src/func/builtins/aggregate.js.map +0 -1
- package/dist/src/func/builtins/builtin-window-functions.js.map +0 -1
- package/dist/src/func/builtins/conversion.js.map +0 -1
- package/dist/src/func/builtins/datetime.js.map +0 -1
- package/dist/src/func/builtins/explain.js.map +0 -1
- package/dist/src/func/builtins/generation.js.map +0 -1
- package/dist/src/func/builtins/index.js.map +0 -1
- package/dist/src/func/builtins/json-helpers.js.map +0 -1
- package/dist/src/func/builtins/json-tvf.js.map +0 -1
- package/dist/src/func/builtins/json.js.map +0 -1
- package/dist/src/func/builtins/scalar.js.map +0 -1
- package/dist/src/func/builtins/schema.js.map +0 -1
- package/dist/src/func/builtins/string.js.map +0 -1
- package/dist/src/func/builtins/timespan.js.map +0 -1
- package/dist/src/func/context.js.map +0 -1
- package/dist/src/func/registration.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/index.js.map +0 -1
- package/dist/src/parser/lexer.js.map +0 -1
- package/dist/src/parser/parser.js.map +0 -1
- package/dist/src/parser/utils.js.map +0 -1
- package/dist/src/parser/visitor.js.map +0 -1
- package/dist/src/planner/analysis/binding-collector.js.map +0 -1
- package/dist/src/planner/analysis/const-evaluator.js.map +0 -1
- package/dist/src/planner/analysis/const-pass.js.map +0 -1
- package/dist/src/planner/analysis/constraint-extractor.js.map +0 -1
- package/dist/src/planner/analysis/predicate-normalizer.js.map +0 -1
- package/dist/src/planner/building/alter-table.js.map +0 -1
- package/dist/src/planner/building/block.js.map +0 -1
- package/dist/src/planner/building/constraint-builder.js.map +0 -1
- package/dist/src/planner/building/create-assertion.js.map +0 -1
- package/dist/src/planner/building/create-view.js.map +0 -1
- package/dist/src/planner/building/ddl.js.map +0 -1
- package/dist/src/planner/building/declare-schema.js.map +0 -1
- package/dist/src/planner/building/delete.js.map +0 -1
- package/dist/src/planner/building/drop-assertion.js.map +0 -1
- package/dist/src/planner/building/drop-table.js.map +0 -1
- package/dist/src/planner/building/drop-view.js.map +0 -1
- package/dist/src/planner/building/expression.js.map +0 -1
- package/dist/src/planner/building/function-call.js.map +0 -1
- package/dist/src/planner/building/insert.js.map +0 -1
- package/dist/src/planner/building/pragma.js.map +0 -1
- package/dist/src/planner/building/schema-resolution.js.map +0 -1
- package/dist/src/planner/building/select-aggregates.js.map +0 -1
- package/dist/src/planner/building/select-compound.js.map +0 -1
- package/dist/src/planner/building/select-context.js.map +0 -1
- package/dist/src/planner/building/select-modifiers.js.map +0 -1
- package/dist/src/planner/building/select-projections.js.map +0 -1
- package/dist/src/planner/building/select-window.js.map +0 -1
- package/dist/src/planner/building/select.js.map +0 -1
- package/dist/src/planner/building/table-function.js.map +0 -1
- package/dist/src/planner/building/table.js.map +0 -1
- package/dist/src/planner/building/transaction.js.map +0 -1
- package/dist/src/planner/building/update.js.map +0 -1
- package/dist/src/planner/building/with.js.map +0 -1
- package/dist/src/planner/cache/correlation-detector.js.map +0 -1
- package/dist/src/planner/cache/materialization-advisory.js.map +0 -1
- package/dist/src/planner/cache/reference-graph.js.map +0 -1
- package/dist/src/planner/cost/index.js.map +0 -1
- package/dist/src/planner/debug/logger-utils.js.map +0 -1
- package/dist/src/planner/debug.js.map +0 -1
- package/dist/src/planner/framework/characteristics.js.map +0 -1
- package/dist/src/planner/framework/context.js.map +0 -1
- package/dist/src/planner/framework/pass.js.map +0 -1
- package/dist/src/planner/framework/physical-utils.js.map +0 -1
- package/dist/src/planner/framework/registry.js.map +0 -1
- package/dist/src/planner/framework/trace.js.map +0 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-function.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-node.js.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/planner/nodes/block.js.map +0 -1
- package/dist/src/planner/nodes/cache-node.js.map +0 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +0 -1
- package/dist/src/planner/nodes/create-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/create-index-node.js.map +0 -1
- package/dist/src/planner/nodes/create-table-node.js.map +0 -1
- package/dist/src/planner/nodes/create-view-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/declarative-schema.js.map +0 -1
- package/dist/src/planner/nodes/delete-node.js.map +0 -1
- package/dist/src/planner/nodes/distinct-node.js.map +0 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-table-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-view-node.js.map +0 -1
- package/dist/src/planner/nodes/filter.js.map +0 -1
- package/dist/src/planner/nodes/function.js.map +0 -1
- package/dist/src/planner/nodes/insert-node.js.map +0 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +0 -1
- package/dist/src/planner/nodes/join-node.js.map +0 -1
- package/dist/src/planner/nodes/limit-offset.js.map +0 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +0 -1
- package/dist/src/planner/nodes/plan-node.js.map +0 -1
- package/dist/src/planner/nodes/pragma.js.map +0 -1
- package/dist/src/planner/nodes/project-node.js.map +0 -1
- package/dist/src/planner/nodes/recursive-cte-node.js.map +0 -1
- package/dist/src/planner/nodes/reference.js.map +0 -1
- package/dist/src/planner/nodes/remote-query-node.js.map +0 -1
- package/dist/src/planner/nodes/retrieve-node.js.map +0 -1
- package/dist/src/planner/nodes/returning-node.js.map +0 -1
- package/dist/src/planner/nodes/scalar.js.map +0 -1
- package/dist/src/planner/nodes/sequencing-node.js.map +0 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +0 -1
- package/dist/src/planner/nodes/single-row.js.map +0 -1
- package/dist/src/planner/nodes/sink-node.js.map +0 -1
- package/dist/src/planner/nodes/sort.js.map +0 -1
- package/dist/src/planner/nodes/stream-aggregate.js.map +0 -1
- package/dist/src/planner/nodes/subquery.js.map +0 -1
- package/dist/src/planner/nodes/table-access-nodes.js.map +0 -1
- package/dist/src/planner/nodes/table-function-call.js.map +0 -1
- package/dist/src/planner/nodes/transaction-node.js.map +0 -1
- package/dist/src/planner/nodes/update-node.js.map +0 -1
- package/dist/src/planner/nodes/values-node.js.map +0 -1
- package/dist/src/planner/nodes/view-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/window-function.js.map +0 -1
- package/dist/src/planner/nodes/window-node.js.map +0 -1
- package/dist/src/planner/optimizer-tuning.js.map +0 -1
- package/dist/src/planner/optimizer.js.map +0 -1
- package/dist/src/planner/planning-context.js.map +0 -1
- package/dist/src/planner/resolve.js.map +0 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +0 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +0 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +0 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +0 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +0 -1
- package/dist/src/planner/scopes/aliased.js.map +0 -1
- package/dist/src/planner/scopes/base.js.map +0 -1
- package/dist/src/planner/scopes/empty.js.map +0 -1
- package/dist/src/planner/scopes/global.js.map +0 -1
- package/dist/src/planner/scopes/multi.js.map +0 -1
- package/dist/src/planner/scopes/param.js.map +0 -1
- package/dist/src/planner/scopes/registered.js.map +0 -1
- package/dist/src/planner/scopes/scope.js.map +0 -1
- package/dist/src/planner/stats/basic-estimates.js.map +0 -1
- package/dist/src/planner/stats/index.js.map +0 -1
- package/dist/src/planner/type-utils.js.map +0 -1
- package/dist/src/planner/util/key-utils.js.map +0 -1
- package/dist/src/planner/validation/determinism-validator.js.map +0 -1
- package/dist/src/planner/validation/plan-validator.js.map +0 -1
- package/dist/src/runtime/async-util.js.map +0 -1
- package/dist/src/runtime/cache/shared-cache.js.map +0 -1
- package/dist/src/runtime/context-helpers.js.map +0 -1
- package/dist/src/runtime/deferred-constraint-queue.js.map +0 -1
- package/dist/src/runtime/emission-context.js.map +0 -1
- package/dist/src/runtime/emit/add-constraint.js.map +0 -1
- package/dist/src/runtime/emit/aggregate.js.map +0 -1
- package/dist/src/runtime/emit/array-index.js.map +0 -1
- package/dist/src/runtime/emit/between.js.map +0 -1
- package/dist/src/runtime/emit/binary.js.map +0 -1
- package/dist/src/runtime/emit/block.js.map +0 -1
- package/dist/src/runtime/emit/cache.js.map +0 -1
- package/dist/src/runtime/emit/case.js.map +0 -1
- package/dist/src/runtime/emit/cast.js.map +0 -1
- package/dist/src/runtime/emit/collate.js.map +0 -1
- package/dist/src/runtime/emit/column-reference.js.map +0 -1
- package/dist/src/runtime/emit/constraint-check.js.map +0 -1
- package/dist/src/runtime/emit/create-assertion.js.map +0 -1
- package/dist/src/runtime/emit/create-index.js.map +0 -1
- package/dist/src/runtime/emit/create-table.js.map +0 -1
- package/dist/src/runtime/emit/create-view.js.map +0 -1
- package/dist/src/runtime/emit/cte-reference.js.map +0 -1
- package/dist/src/runtime/emit/cte.js.map +0 -1
- package/dist/src/runtime/emit/delete.js.map +0 -1
- package/dist/src/runtime/emit/distinct.js.map +0 -1
- package/dist/src/runtime/emit/dml-executor.js.map +0 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +0 -1
- package/dist/src/runtime/emit/drop-table.js.map +0 -1
- package/dist/src/runtime/emit/drop-view.js.map +0 -1
- package/dist/src/runtime/emit/filter.js.map +0 -1
- package/dist/src/runtime/emit/insert.js.map +0 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +0 -1
- package/dist/src/runtime/emit/join.js.map +0 -1
- package/dist/src/runtime/emit/limit-offset.js.map +0 -1
- package/dist/src/runtime/emit/literal.js.map +0 -1
- package/dist/src/runtime/emit/parameter.js.map +0 -1
- package/dist/src/runtime/emit/pragma.js.map +0 -1
- package/dist/src/runtime/emit/project.js.map +0 -1
- package/dist/src/runtime/emit/recursive-cte.js.map +0 -1
- package/dist/src/runtime/emit/remote-query.js.map +0 -1
- package/dist/src/runtime/emit/retrieve.js.map +0 -1
- package/dist/src/runtime/emit/returning.js.map +0 -1
- package/dist/src/runtime/emit/scalar-function.js.map +0 -1
- package/dist/src/runtime/emit/scan.js.map +0 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +0 -1
- package/dist/src/runtime/emit/sequencing.js.map +0 -1
- package/dist/src/runtime/emit/set-operation.js.map +0 -1
- package/dist/src/runtime/emit/sink.js.map +0 -1
- package/dist/src/runtime/emit/sort.js.map +0 -1
- package/dist/src/runtime/emit/subquery.js.map +0 -1
- package/dist/src/runtime/emit/table-valued-function.js.map +0 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +0 -1
- package/dist/src/runtime/emit/transaction.js.map +0 -1
- package/dist/src/runtime/emit/unary.js.map +0 -1
- package/dist/src/runtime/emit/update.js.map +0 -1
- package/dist/src/runtime/emit/values.js.map +0 -1
- package/dist/src/runtime/emit/window-function.js.map +0 -1
- package/dist/src/runtime/emit/window.js.map +0 -1
- package/dist/src/runtime/emitters.js.map +0 -1
- package/dist/src/runtime/register.js.map +0 -1
- package/dist/src/runtime/scheduler.js.map +0 -1
- package/dist/src/runtime/types.js.map +0 -1
- package/dist/src/runtime/utils.js.map +0 -1
- package/dist/src/schema/assertion.js.map +0 -1
- package/dist/src/schema/catalog.js.map +0 -1
- package/dist/src/schema/change-events.js.map +0 -1
- package/dist/src/schema/column.js.map +0 -1
- package/dist/src/schema/declared-schema-manager.js.map +0 -1
- package/dist/src/schema/function.js.map +0 -1
- package/dist/src/schema/manager.js.map +0 -1
- package/dist/src/schema/schema-differ.js.map +0 -1
- package/dist/src/schema/schema-hasher.js.map +0 -1
- package/dist/src/schema/schema.js.map +0 -1
- package/dist/src/schema/table.js.map +0 -1
- package/dist/src/schema/view.js.map +0 -1
- package/dist/src/schema/window-function.js.map +0 -1
- package/dist/src/types/builtin-types.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/json-type.js.map +0 -1
- package/dist/src/types/logical-type.js.map +0 -1
- package/dist/src/types/plugin-interface.js.map +0 -1
- package/dist/src/types/registry.js.map +0 -1
- package/dist/src/types/temporal-types.js.map +0 -1
- package/dist/src/types/validation.js.map +0 -1
- package/dist/src/util/affinity.js.map +0 -1
- package/dist/src/util/ast-stringify.js.map +0 -1
- package/dist/src/util/cached.js.map +0 -1
- package/dist/src/util/coercion.js.map +0 -1
- package/dist/src/util/comparison.js.map +0 -1
- package/dist/src/util/environment.js.map +0 -1
- package/dist/src/util/hash.js.map +0 -1
- package/dist/src/util/latches.js.map +0 -1
- package/dist/src/util/mutation-statement.js.map +0 -1
- package/dist/src/util/patterns.js.map +0 -1
- package/dist/src/util/plan-formatter.js.map +0 -1
- package/dist/src/util/plugin-helper.js.map +0 -1
- package/dist/src/util/row-descriptor.js.map +0 -1
- package/dist/src/util/serialization.js.map +0 -1
- package/dist/src/util/sql-literal.js.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
- package/dist/src/vtab/best-access-plan.js.map +0 -1
- package/dist/src/vtab/connection.js.map +0 -1
- package/dist/src/vtab/filter-info.js.map +0 -1
- package/dist/src/vtab/index-info.js.map +0 -1
- package/dist/src/vtab/manifest.js.map +0 -1
- package/dist/src/vtab/memory/connection.js.map +0 -1
- package/dist/src/vtab/memory/index.js.map +0 -1
- package/dist/src/vtab/memory/layer/base-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/base.js.map +0 -1
- package/dist/src/vtab/memory/layer/connection.js.map +0 -1
- package/dist/src/vtab/memory/layer/interface.js.map +0 -1
- package/dist/src/vtab/memory/layer/manager.js.map +0 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +0 -1
- package/dist/src/vtab/memory/layer/scan-plan.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction.js.map +0 -1
- package/dist/src/vtab/memory/module.js.map +0 -1
- package/dist/src/vtab/memory/table.js.map +0 -1
- package/dist/src/vtab/memory/types.js.map +0 -1
- package/dist/src/vtab/memory/utils/logging.js.map +0 -1
- package/dist/src/vtab/memory/utils/primary-key.js.map +0 -1
- package/dist/src/vtab/module.js.map +0 -1
- package/dist/src/vtab/table.js.map +0 -1
- package/src/common/constants.ts +0 -60
- package/src/common/datatype.ts +0 -85
- package/src/common/errors.ts +0 -189
- package/src/common/json-types.ts +0 -16
- package/src/common/logger.ts +0 -97
- package/src/common/type-inference.ts +0 -39
- package/src/common/types.ts +0 -151
- package/src/core/database-options.ts +0 -258
- package/src/core/database.ts +0 -1461
- package/src/core/param.ts +0 -56
- package/src/core/statement.ts +0 -528
- package/src/func/builtins/aggregate.ts +0 -269
- package/src/func/builtins/builtin-window-functions.ts +0 -166
- package/src/func/builtins/conversion.ts +0 -226
- package/src/func/builtins/datetime.ts +0 -500
- package/src/func/builtins/explain.ts +0 -779
- package/src/func/builtins/generation.ts +0 -43
- package/src/func/builtins/index.ts +0 -167
- package/src/func/builtins/json-helpers.ts +0 -237
- package/src/func/builtins/json-tvf.ts +0 -224
- package/src/func/builtins/json.ts +0 -588
- package/src/func/builtins/scalar.ts +0 -423
- package/src/func/builtins/schema.ts +0 -213
- package/src/func/builtins/string.ts +0 -306
- package/src/func/builtins/timespan.ts +0 -179
- package/src/func/context.ts +0 -258
- package/src/func/registration.ts +0 -201
- package/src/index.ts +0 -172
- package/src/parser/ast.ts +0 -581
- package/src/parser/index.ts +0 -65
- package/src/parser/lexer.ts +0 -806
- package/src/parser/parser.ts +0 -3352
- package/src/parser/utils.ts +0 -10
- package/src/parser/visitor.ts +0 -188
- package/src/planner/analysis/README.md +0 -93
- package/src/planner/analysis/binding-collector.ts +0 -83
- package/src/planner/analysis/const-evaluator.ts +0 -63
- package/src/planner/analysis/const-pass.ts +0 -282
- package/src/planner/analysis/constraint-extractor.ts +0 -764
- package/src/planner/analysis/predicate-normalizer.ts +0 -237
- package/src/planner/building/alter-table.ts +0 -49
- package/src/planner/building/block.ts +0 -93
- package/src/planner/building/constraint-builder.ts +0 -178
- package/src/planner/building/create-assertion.ts +0 -7
- package/src/planner/building/create-view.ts +0 -29
- package/src/planner/building/ddl.ts +0 -24
- package/src/planner/building/declare-schema.ts +0 -22
- package/src/planner/building/delete.ts +0 -218
- package/src/planner/building/drop-assertion.ts +0 -11
- package/src/planner/building/drop-table.ts +0 -13
- package/src/planner/building/drop-view.ts +0 -19
- package/src/planner/building/expression.ts +0 -205
- package/src/planner/building/function-call.ts +0 -129
- package/src/planner/building/insert.ts +0 -435
- package/src/planner/building/pragma.ts +0 -34
- package/src/planner/building/schema-resolution.ts +0 -176
- package/src/planner/building/select-aggregates.ts +0 -318
- package/src/planner/building/select-compound.ts +0 -119
- package/src/planner/building/select-context.ts +0 -85
- package/src/planner/building/select-modifiers.ts +0 -236
- package/src/planner/building/select-projections.ts +0 -177
- package/src/planner/building/select-window.ts +0 -259
- package/src/planner/building/select.ts +0 -567
- package/src/planner/building/table-function.ts +0 -49
- package/src/planner/building/table.ts +0 -40
- package/src/planner/building/transaction.ts +0 -23
- package/src/planner/building/update.ts +0 -331
- package/src/planner/building/with.ts +0 -180
- package/src/planner/cache/correlation-detector.ts +0 -83
- package/src/planner/cache/materialization-advisory.ts +0 -265
- package/src/planner/cache/reference-graph.ts +0 -196
- package/src/planner/cost/index.ts +0 -169
- package/src/planner/debug/logger-utils.ts +0 -68
- package/src/planner/debug.ts +0 -480
- package/src/planner/framework/README.md +0 -132
- package/src/planner/framework/characteristics.ts +0 -503
- package/src/planner/framework/context.ts +0 -239
- package/src/planner/framework/pass.ts +0 -354
- package/src/planner/framework/physical-utils.ts +0 -210
- package/src/planner/framework/registry.ts +0 -261
- package/src/planner/framework/trace.ts +0 -259
- package/src/planner/nodes/add-constraint-node.ts +0 -62
- package/src/planner/nodes/aggregate-function.ts +0 -155
- package/src/planner/nodes/aggregate-node.ts +0 -267
- package/src/planner/nodes/array-index-node.ts +0 -50
- package/src/planner/nodes/block.ts +0 -80
- package/src/planner/nodes/cache-node.ts +0 -103
- package/src/planner/nodes/constraint-check-node.ts +0 -138
- package/src/planner/nodes/create-assertion-node.ts +0 -51
- package/src/planner/nodes/create-index-node.ts +0 -41
- package/src/planner/nodes/create-table-node.ts +0 -35
- package/src/planner/nodes/create-view-node.ts +0 -44
- package/src/planner/nodes/cte-node.ts +0 -168
- package/src/planner/nodes/cte-reference-node.ts +0 -125
- package/src/planner/nodes/declarative-schema.ts +0 -221
- package/src/planner/nodes/delete-node.ts +0 -102
- package/src/planner/nodes/distinct-node.ts +0 -107
- package/src/planner/nodes/dml-executor-node.ts +0 -104
- package/src/planner/nodes/drop-assertion-node.ts +0 -50
- package/src/planner/nodes/drop-table-node.ts +0 -36
- package/src/planner/nodes/drop-view-node.ts +0 -37
- package/src/planner/nodes/filter.ts +0 -144
- package/src/planner/nodes/function.ts +0 -98
- package/src/planner/nodes/insert-node.ts +0 -126
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +0 -61
- package/src/planner/nodes/join-node.ts +0 -336
- package/src/planner/nodes/limit-offset.ts +0 -144
- package/src/planner/nodes/plan-node-type.ts +0 -95
- package/src/planner/nodes/plan-node.ts +0 -503
- package/src/planner/nodes/pragma.ts +0 -98
- package/src/planner/nodes/project-node.ts +0 -337
- package/src/planner/nodes/recursive-cte-node.ts +0 -158
- package/src/planner/nodes/reference.ts +0 -334
- package/src/planner/nodes/remote-query-node.ts +0 -73
- package/src/planner/nodes/retrieve-node.ts +0 -86
- package/src/planner/nodes/returning-node.ts +0 -269
- package/src/planner/nodes/scalar.ts +0 -772
- package/src/planner/nodes/sequencing-node.ts +0 -113
- package/src/planner/nodes/set-operation-node.ts +0 -87
- package/src/planner/nodes/single-row.ts +0 -85
- package/src/planner/nodes/sink-node.ts +0 -61
- package/src/planner/nodes/sort.ts +0 -166
- package/src/planner/nodes/stream-aggregate.ts +0 -293
- package/src/planner/nodes/subquery.ts +0 -268
- package/src/planner/nodes/table-access-nodes.ts +0 -323
- package/src/planner/nodes/table-function-call.ts +0 -134
- package/src/planner/nodes/transaction-node.ts +0 -55
- package/src/planner/nodes/update-node.ts +0 -138
- package/src/planner/nodes/values-node.ts +0 -244
- package/src/planner/nodes/view-reference-node.ts +0 -97
- package/src/planner/nodes/window-function.ts +0 -73
- package/src/planner/nodes/window-node.ts +0 -199
- package/src/planner/optimizer-tuning.ts +0 -105
- package/src/planner/optimizer.ts +0 -332
- package/src/planner/planning-context.ts +0 -190
- package/src/planner/resolve.ts +0 -101
- package/src/planner/rules/README.md +0 -96
- package/src/planner/rules/access/rule-select-access-path.ts +0 -399
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +0 -162
- package/src/planner/rules/cache/rule-cte-optimization.ts +0 -79
- package/src/planner/rules/cache/rule-materialization-advisory.ts +0 -77
- package/src/planner/rules/cache/rule-mutating-subquery-cache.ts +0 -104
- package/src/planner/rules/join/rule-join-greedy-commute.ts +0 -48
- package/src/planner/rules/join/rule-join-key-inference.ts +0 -35
- package/src/planner/rules/join/rule-quickpick-enumeration.ts +0 -267
- package/src/planner/rules/predicate/rule-predicate-pushdown.ts +0 -144
- package/src/planner/rules/retrieve/rule-grow-retrieve.ts +0 -337
- package/src/planner/scopes/aliased.ts +0 -50
- package/src/planner/scopes/base.ts +0 -10
- package/src/planner/scopes/empty.ts +0 -12
- package/src/planner/scopes/global.ts +0 -73
- package/src/planner/scopes/multi.ts +0 -40
- package/src/planner/scopes/param.ts +0 -95
- package/src/planner/scopes/registered.ts +0 -67
- package/src/planner/scopes/scope.ts +0 -16
- package/src/planner/stats/basic-estimates.ts +0 -107
- package/src/planner/stats/index.ts +0 -158
- package/src/planner/type-utils.ts +0 -87
- package/src/planner/util/key-utils.ts +0 -46
- package/src/planner/validation/determinism-validator.ts +0 -104
- package/src/planner/validation/plan-validator.ts +0 -335
- package/src/runtime/async-util.ts +0 -283
- package/src/runtime/cache/shared-cache.ts +0 -169
- package/src/runtime/context-helpers.ts +0 -191
- package/src/runtime/deferred-constraint-queue.ts +0 -196
- package/src/runtime/emission-context.ts +0 -319
- package/src/runtime/emit/add-constraint.ts +0 -78
- package/src/runtime/emit/aggregate.ts +0 -581
- package/src/runtime/emit/array-index.ts +0 -25
- package/src/runtime/emit/between.ts +0 -51
- package/src/runtime/emit/binary.ts +0 -357
- package/src/runtime/emit/block.ts +0 -23
- package/src/runtime/emit/cache.ts +0 -64
- package/src/runtime/emit/case.ts +0 -87
- package/src/runtime/emit/cast.ts +0 -151
- package/src/runtime/emit/collate.ts +0 -9
- package/src/runtime/emit/column-reference.ts +0 -17
- package/src/runtime/emit/constraint-check.ts +0 -290
- package/src/runtime/emit/create-assertion.ts +0 -82
- package/src/runtime/emit/create-index.ts +0 -15
- package/src/runtime/emit/create-table.ts +0 -15
- package/src/runtime/emit/create-view.ts +0 -52
- package/src/runtime/emit/cte-reference.ts +0 -38
- package/src/runtime/emit/cte.ts +0 -39
- package/src/runtime/emit/delete.ts +0 -24
- package/src/runtime/emit/distinct.ts +0 -40
- package/src/runtime/emit/dml-executor.ts +0 -198
- package/src/runtime/emit/drop-assertion.ts +0 -45
- package/src/runtime/emit/drop-table.ts +0 -27
- package/src/runtime/emit/drop-view.ts +0 -49
- package/src/runtime/emit/filter.ts +0 -30
- package/src/runtime/emit/insert.ts +0 -42
- package/src/runtime/emit/internal-recursive-cte-ref.ts +0 -37
- package/src/runtime/emit/join.ts +0 -148
- package/src/runtime/emit/limit-offset.ts +0 -73
- package/src/runtime/emit/literal.ts +0 -17
- package/src/runtime/emit/parameter.ts +0 -59
- package/src/runtime/emit/pragma.ts +0 -56
- package/src/runtime/emit/project.ts +0 -46
- package/src/runtime/emit/recursive-cte.ts +0 -111
- package/src/runtime/emit/remote-query.ts +0 -47
- package/src/runtime/emit/retrieve.ts +0 -15
- package/src/runtime/emit/returning.ts +0 -41
- package/src/runtime/emit/scalar-function.ts +0 -69
- package/src/runtime/emit/scan.ts +0 -106
- package/src/runtime/emit/schema-declarative.ts +0 -215
- package/src/runtime/emit/sequencing.ts +0 -24
- package/src/runtime/emit/set-operation.ts +0 -141
- package/src/runtime/emit/sink.ts +0 -27
- package/src/runtime/emit/sort.ts +0 -75
- package/src/runtime/emit/subquery.ts +0 -203
- package/src/runtime/emit/table-valued-function.ts +0 -106
- package/src/runtime/emit/temporal-arithmetic.ts +0 -302
- package/src/runtime/emit/transaction.ts +0 -205
- package/src/runtime/emit/unary.ts +0 -101
- package/src/runtime/emit/update.ts +0 -66
- package/src/runtime/emit/values.ts +0 -66
- package/src/runtime/emit/window-function.ts +0 -42
- package/src/runtime/emit/window.ts +0 -458
- package/src/runtime/emitters.ts +0 -183
- package/src/runtime/register.ts +0 -150
- package/src/runtime/scheduler.ts +0 -488
- package/src/runtime/types.ts +0 -242
- package/src/runtime/utils.ts +0 -177
- package/src/schema/assertion.ts +0 -21
- package/src/schema/catalog.ts +0 -269
- package/src/schema/change-events.ts +0 -80
- package/src/schema/column.ts +0 -51
- package/src/schema/declared-schema-manager.ts +0 -82
- package/src/schema/function.ts +0 -188
- package/src/schema/manager.ts +0 -1034
- package/src/schema/schema-differ.ts +0 -214
- package/src/schema/schema-hasher.ts +0 -26
- package/src/schema/schema.ts +0 -222
- package/src/schema/table.ts +0 -409
- package/src/schema/view.ts +0 -19
- package/src/schema/window-function.ts +0 -56
- package/src/types/builtin-types.ts +0 -350
- package/src/types/index.ts +0 -17
- package/src/types/json-type.ts +0 -152
- package/src/types/logical-type.ts +0 -91
- package/src/types/plugin-interface.ts +0 -10
- package/src/types/registry.ts +0 -204
- package/src/types/temporal-types.ts +0 -290
- package/src/types/validation.ts +0 -120
- package/src/util/affinity.ts +0 -151
- package/src/util/ast-stringify.ts +0 -887
- package/src/util/cached.ts +0 -25
- package/src/util/coercion.ts +0 -113
- package/src/util/comparison.ts +0 -510
- package/src/util/environment.ts +0 -52
- package/src/util/hash.ts +0 -90
- package/src/util/latches.ts +0 -47
- package/src/util/mutation-statement.ts +0 -135
- package/src/util/patterns.ts +0 -56
- package/src/util/plan-formatter.ts +0 -48
- package/src/util/plugin-helper.ts +0 -110
- package/src/util/row-descriptor.ts +0 -105
- package/src/util/serialization.ts +0 -47
- package/src/util/sql-literal.ts +0 -22
- package/src/util/working-table-iterable.ts +0 -38
- package/src/vtab/best-access-plan.ts +0 -244
- package/src/vtab/connection.ts +0 -36
- package/src/vtab/filter-info.ts +0 -23
- package/src/vtab/index-info.ts +0 -84
- package/src/vtab/manifest.ts +0 -86
- package/src/vtab/memory/connection.ts +0 -73
- package/src/vtab/memory/index.ts +0 -191
- package/src/vtab/memory/layer/base-cursor.ts +0 -124
- package/src/vtab/memory/layer/base.ts +0 -275
- package/src/vtab/memory/layer/connection.ts +0 -203
- package/src/vtab/memory/layer/interface.ts +0 -47
- package/src/vtab/memory/layer/manager.ts +0 -909
- package/src/vtab/memory/layer/safe-iterate.ts +0 -49
- package/src/vtab/memory/layer/scan-plan.ts +0 -84
- package/src/vtab/memory/layer/transaction-cursor.ts +0 -162
- package/src/vtab/memory/layer/transaction.ts +0 -229
- package/src/vtab/memory/module.ts +0 -667
- package/src/vtab/memory/table.ts +0 -251
- package/src/vtab/memory/types.ts +0 -23
- package/src/vtab/memory/utils/logging.ts +0 -36
- package/src/vtab/memory/utils/primary-key.ts +0 -163
- package/src/vtab/module.ts +0 -162
- package/src/vtab/table.ts +0 -177
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { createLogger } from '../../common/logger.js';
|
|
4
|
-
import { StatusCode, type Row, type SqlValue } from '../../common/types.js';
|
|
5
|
-
import { QuereusError } from '../../common/errors.js';
|
|
6
|
-
import { collectSchemaCatalog } from '../../schema/catalog.js';
|
|
7
|
-
import { computeSchemaDiff, generateMigrationDDL } from '../../schema/schema-differ.js';
|
|
8
|
-
import { computeShortSchemaHash } from '../../schema/schema-hasher.js';
|
|
9
|
-
import type * as AST from '../../parser/ast.js';
|
|
10
|
-
import type { PlanNode } from '../../planner/nodes/plan-node.js';
|
|
11
|
-
|
|
12
|
-
const log = createLogger('runtime:emit:declare');
|
|
13
|
-
|
|
14
|
-
export function emitDeclareSchema(plan: PlanNode, _ctx: EmissionContext): Instruction {
|
|
15
|
-
const declareStmt = (plan as unknown as { statementAst: AST.DeclareSchemaStmt }).statementAst;
|
|
16
|
-
|
|
17
|
-
const run = (rctx: RuntimeContext): Row => {
|
|
18
|
-
const schemaName = declareStmt.schemaName || 'main';
|
|
19
|
-
log('DECLARE SCHEMA %s', schemaName);
|
|
20
|
-
|
|
21
|
-
// Clear previous declaration and seed data for this schema
|
|
22
|
-
rctx.db.declaredSchemaManager.clearSeedData(schemaName);
|
|
23
|
-
|
|
24
|
-
// Store the declared schema
|
|
25
|
-
rctx.db.declaredSchemaManager.setDeclaredSchema(schemaName, declareStmt);
|
|
26
|
-
|
|
27
|
-
// Process seed data if present
|
|
28
|
-
for (const item of declareStmt.items) {
|
|
29
|
-
if (item.type === 'declaredSeed' && item.seedData) {
|
|
30
|
-
const tableName = item.tableName;
|
|
31
|
-
const rows = Array.from(item.seedData) as Array<SqlValue[]>;
|
|
32
|
-
rctx.db.declaredSchemaManager.setSeedData(schemaName, tableName, rows);
|
|
33
|
-
log('Stored seed data for %s.%s (%d rows)', schemaName, tableName, rows.length);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Return empty row to satisfy type system (void result)
|
|
38
|
-
return [];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
params: [],
|
|
43
|
-
run: run as InstructionRun,
|
|
44
|
-
note: `declare schema ${declareStmt.schemaName || 'main'}`
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function emitDiffSchema(plan: PlanNode, _ctx: EmissionContext): Instruction {
|
|
49
|
-
const diffStmt = (plan as unknown as { statementAst: AST.DiffSchemaStmt }).statementAst;
|
|
50
|
-
|
|
51
|
-
const run = async function* (rctx: RuntimeContext): AsyncIterable<Row> {
|
|
52
|
-
const schemaName = diffStmt.schemaName || 'main';
|
|
53
|
-
log('DIFF SCHEMA %s', schemaName);
|
|
54
|
-
|
|
55
|
-
// Get declared schema
|
|
56
|
-
const declaredSchema = rctx.db.declaredSchemaManager.getDeclaredSchema(schemaName);
|
|
57
|
-
if (!declaredSchema) {
|
|
58
|
-
throw new QuereusError(`No declared schema found for '${schemaName}'`, StatusCode.ERROR);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Collect actual catalog
|
|
62
|
-
const actualCatalog = collectSchemaCatalog(rctx.db, schemaName);
|
|
63
|
-
|
|
64
|
-
// Compute diff
|
|
65
|
-
const diff = computeSchemaDiff(declaredSchema, actualCatalog);
|
|
66
|
-
|
|
67
|
-
// Generate migration DDL statements
|
|
68
|
-
const migrationStatements = generateMigrationDDL(diff, schemaName);
|
|
69
|
-
|
|
70
|
-
// Return each DDL statement as a row
|
|
71
|
-
// This allows users to fetch the DDL and execute it themselves with custom logic
|
|
72
|
-
for (const ddl of migrationStatements) {
|
|
73
|
-
yield [ddl];
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
params: [],
|
|
79
|
-
run: run as InstructionRun,
|
|
80
|
-
note: `diff schema ${diffStmt.schemaName || 'main'}`
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function emitApplySchema(plan: PlanNode, _ctx: EmissionContext): Instruction {
|
|
85
|
-
const applyStmt = (plan as unknown as { statementAst: AST.ApplySchemaStmt }).statementAst;
|
|
86
|
-
|
|
87
|
-
const run = async (rctx: RuntimeContext): Promise<Row> => {
|
|
88
|
-
const schemaName = applyStmt.schemaName || 'main';
|
|
89
|
-
log('APPLY SCHEMA %s', schemaName);
|
|
90
|
-
|
|
91
|
-
// Get declared schema
|
|
92
|
-
const declaredSchema = rctx.db.declaredSchemaManager.getDeclaredSchema(schemaName);
|
|
93
|
-
if (!declaredSchema) {
|
|
94
|
-
throw new QuereusError(`No declared schema found for '${schemaName}'`, StatusCode.ERROR);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Ensure the target schema exists (create if it doesn't, except for main/temp)
|
|
98
|
-
const lowerSchemaName = schemaName.toLowerCase();
|
|
99
|
-
if (lowerSchemaName !== 'main' && lowerSchemaName !== 'temp') {
|
|
100
|
-
if (!rctx.db.schemaManager.getSchema(schemaName)) {
|
|
101
|
-
rctx.db.schemaManager.addSchema(schemaName);
|
|
102
|
-
log('Created schema: %s', schemaName);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Collect actual catalog
|
|
107
|
-
const actualCatalog = collectSchemaCatalog(rctx.db, schemaName);
|
|
108
|
-
|
|
109
|
-
// Compute diff
|
|
110
|
-
const diff = computeSchemaDiff(declaredSchema, actualCatalog);
|
|
111
|
-
|
|
112
|
-
// Generate migration DDL
|
|
113
|
-
const migrationStatements = generateMigrationDDL(diff, schemaName);
|
|
114
|
-
|
|
115
|
-
// Execute each migration statement
|
|
116
|
-
for (const ddl of migrationStatements) {
|
|
117
|
-
log('Executing migration DDL: %s', ddl);
|
|
118
|
-
try {
|
|
119
|
-
await rctx.db.exec(ddl);
|
|
120
|
-
} catch (e) {
|
|
121
|
-
log('Migration failed for DDL: %s', ddl);
|
|
122
|
-
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
123
|
-
throw new QuereusError(
|
|
124
|
-
`Failed to execute DDL: ${ddl}\nError: ${errorMessage}`,
|
|
125
|
-
StatusCode.ERROR,
|
|
126
|
-
e instanceof Error ? e : undefined
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Apply seed data if requested
|
|
132
|
-
if (applyStmt.withSeed) {
|
|
133
|
-
const allSeedData = rctx.db.declaredSchemaManager.getAllSeedData(schemaName);
|
|
134
|
-
log('Seed data available for %d tables', allSeedData.size);
|
|
135
|
-
for (const [tableName, rows] of allSeedData) {
|
|
136
|
-
log('Applying seed data to %s.%s (%d rows)', schemaName, tableName, rows.length);
|
|
137
|
-
|
|
138
|
-
// Qualify table name with schema if not main
|
|
139
|
-
const qualifiedTableName = (schemaName && schemaName.toLowerCase() !== 'main')
|
|
140
|
-
? `${schemaName}.${tableName}`
|
|
141
|
-
: tableName;
|
|
142
|
-
|
|
143
|
-
// Delete existing rows, then insert seed rows in one batch
|
|
144
|
-
const deleteAndInsertSql = [
|
|
145
|
-
`DELETE FROM ${qualifiedTableName}`,
|
|
146
|
-
...rows.map(row => {
|
|
147
|
-
const values = row.map(v =>
|
|
148
|
-
v === null ? 'NULL' :
|
|
149
|
-
typeof v === 'string' ? `'${v.replace(/'/g, "''")}'` :
|
|
150
|
-
typeof v === 'number' || typeof v === 'bigint' ? String(v) :
|
|
151
|
-
'NULL'
|
|
152
|
-
).join(', ');
|
|
153
|
-
return `INSERT INTO ${qualifiedTableName} VALUES (${values})`;
|
|
154
|
-
})
|
|
155
|
-
].join('; ');
|
|
156
|
-
|
|
157
|
-
log('Executing seed SQL (length=%d): %s', deleteAndInsertSql.length, deleteAndInsertSql);
|
|
158
|
-
try {
|
|
159
|
-
await rctx.db.exec(deleteAndInsertSql);
|
|
160
|
-
log('Seed application succeeded for table %s', tableName);
|
|
161
|
-
} catch (e) {
|
|
162
|
-
log('Seed application failed for table %s: %O', tableName, e);
|
|
163
|
-
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
164
|
-
throw new QuereusError(
|
|
165
|
-
`Failed to apply seed data for table ${tableName}. SQL: ${deleteAndInsertSql}\nError: ${errorMessage}`,
|
|
166
|
-
StatusCode.ERROR,
|
|
167
|
-
e instanceof Error ? e : undefined
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Return empty row to satisfy type system (void result)
|
|
174
|
-
return [];
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
params: [],
|
|
179
|
-
run: run as InstructionRun,
|
|
180
|
-
note: `apply schema ${applyStmt.schemaName || 'main'}${applyStmt.withSeed ? ' with seed' : ''}`
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export function emitExplainSchema(plan: PlanNode, _ctx: EmissionContext): Instruction {
|
|
185
|
-
const explainStmt = (plan as unknown as { statementAst: AST.ExplainSchemaStmt }).statementAst;
|
|
186
|
-
|
|
187
|
-
const run = async function* (rctx: RuntimeContext): AsyncIterable<Row> {
|
|
188
|
-
const schemaName = explainStmt.schemaName || 'main';
|
|
189
|
-
log('EXPLAIN SCHEMA %s', schemaName);
|
|
190
|
-
|
|
191
|
-
// Get declared schema
|
|
192
|
-
const declaredSchema = rctx.db.declaredSchemaManager.getDeclaredSchema(schemaName);
|
|
193
|
-
if (!declaredSchema) {
|
|
194
|
-
throw new QuereusError(`No declared schema found for '${schemaName}'`, StatusCode.ERROR);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Compute hash
|
|
198
|
-
const hash = computeShortSchemaHash(declaredSchema);
|
|
199
|
-
|
|
200
|
-
// Return hash with version if specified
|
|
201
|
-
const result = explainStmt.version
|
|
202
|
-
? `version:${explainStmt.version},hash:${hash}`
|
|
203
|
-
: `hash:${hash}`;
|
|
204
|
-
|
|
205
|
-
yield [result];
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
params: [],
|
|
210
|
-
run: run as InstructionRun,
|
|
211
|
-
note: `explain schema ${explainStmt.schemaName || 'main'}`
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { SequencingNode } from '../../planner/nodes/sequencing-node.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import type { Row } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
|
|
7
|
-
export function emitSequencing(plan: SequencingNode, ctx: EmissionContext): Instruction {
|
|
8
|
-
async function* run(ctx: RuntimeContext, source: AsyncIterable<Row>): AsyncIterable<Row> {
|
|
9
|
-
let rowNumber = 1;
|
|
10
|
-
|
|
11
|
-
for await (const sourceRow of source) {
|
|
12
|
-
// Append row number to each row
|
|
13
|
-
yield [...sourceRow, rowNumber++] as Row;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
params: [sourceInstruction],
|
|
21
|
-
run: run as InstructionRun,
|
|
22
|
-
note: `sequencing(${plan.sequenceColumnName})`
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import type { SetOperationNode } from '../../planner/nodes/set-operation-node.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
4
|
-
import { emitPlanNode } from '../emitters.js';
|
|
5
|
-
import type { Row } from '../../common/types.js';
|
|
6
|
-
import { BTree } from 'inheritree';
|
|
7
|
-
import { compareRows } from '../../util/comparison.js';
|
|
8
|
-
|
|
9
|
-
export function emitSetOperation(plan: SetOperationNode, ctx: EmissionContext): Instruction {
|
|
10
|
-
const leftInst = emitPlanNode(plan.left, ctx);
|
|
11
|
-
const rightInst = emitPlanNode(plan.right, ctx);
|
|
12
|
-
|
|
13
|
-
// Helper function to create a properly structured output row
|
|
14
|
-
function createOutputRow(inputRow: Row): Row {
|
|
15
|
-
const outputRow: Row = [];
|
|
16
|
-
plan.getAttributes().forEach((attr, idx) => {
|
|
17
|
-
outputRow[idx] = inputRow[idx]; // Map by position since columns should align
|
|
18
|
-
});
|
|
19
|
-
return outputRow;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function* runUnionAll(rctx: RuntimeContext, leftRows: AsyncIterable<Row>, rightRows: AsyncIterable<Row>): AsyncIterable<Row> {
|
|
23
|
-
// Process left rows - let SortNode handle row context
|
|
24
|
-
for await (const row of leftRows) {
|
|
25
|
-
yield createOutputRow(row);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Process right rows - let SortNode handle row context
|
|
29
|
-
for await (const row of rightRows) {
|
|
30
|
-
yield createOutputRow(row);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function* runUnionDistinct(rctx: RuntimeContext, leftRows: AsyncIterable<Row>, rightRows: AsyncIterable<Row>): AsyncIterable<Row> {
|
|
35
|
-
// Use BTree for proper SQL value comparison instead of JSON.stringify
|
|
36
|
-
const distinctTree = new BTree<Row, Row>(
|
|
37
|
-
(row: Row) => row,
|
|
38
|
-
compareRows
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
for await (const row of leftRows) {
|
|
42
|
-
const outputRow = createOutputRow(row);
|
|
43
|
-
const newPath = distinctTree.insert(outputRow);
|
|
44
|
-
if (newPath.on) {
|
|
45
|
-
// This is a new distinct row
|
|
46
|
-
yield outputRow; // Let SortNode handle row context
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for await (const row of rightRows) {
|
|
50
|
-
const outputRow = createOutputRow(row);
|
|
51
|
-
const newPath = distinctTree.insert(outputRow);
|
|
52
|
-
if (newPath.on) {
|
|
53
|
-
// This is a new distinct row
|
|
54
|
-
yield outputRow; // Let SortNode handle row context
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function* runIntersect(rctx: RuntimeContext, leftRows: AsyncIterable<Row>, rightRows: AsyncIterable<Row>): AsyncIterable<Row> {
|
|
60
|
-
// Use BTree for proper SQL value comparison
|
|
61
|
-
const leftTree = new BTree<Row, Row>(
|
|
62
|
-
(row: Row) => row,
|
|
63
|
-
compareRows
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
// Build left set
|
|
67
|
-
for await (const row of leftRows) {
|
|
68
|
-
const outputRow = createOutputRow(row);
|
|
69
|
-
leftTree.insert(outputRow);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Check right rows against left set
|
|
73
|
-
const yielded = new BTree<Row, Row>(
|
|
74
|
-
(row: Row) => row,
|
|
75
|
-
compareRows
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
for await (const row of rightRows) {
|
|
79
|
-
const outputRow = createOutputRow(row);
|
|
80
|
-
const leftPath = leftTree.find(outputRow);
|
|
81
|
-
if (leftPath.on) {
|
|
82
|
-
// This row exists in left set - yield the LEFT row to preserve left-side types
|
|
83
|
-
const leftRow = leftTree.get(outputRow)!;
|
|
84
|
-
const yieldedPath = yielded.insert(leftRow);
|
|
85
|
-
if (yieldedPath.on) {
|
|
86
|
-
// Haven't yielded this row yet (handles duplicates in right)
|
|
87
|
-
yield leftRow; // Let SortNode handle row context
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function* runExcept(rctx: RuntimeContext, leftRows: AsyncIterable<Row>, rightRows: AsyncIterable<Row>): AsyncIterable<Row> {
|
|
94
|
-
// Use BTree for proper SQL value comparison
|
|
95
|
-
const rightTree = new BTree<Row, Row>(
|
|
96
|
-
(row: Row) => row,
|
|
97
|
-
compareRows
|
|
98
|
-
);
|
|
99
|
-
const leftRowsArray: Row[] = [];
|
|
100
|
-
|
|
101
|
-
// Collect left rows
|
|
102
|
-
for await (const row of leftRows) {
|
|
103
|
-
leftRowsArray.push(createOutputRow(row));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Build right set
|
|
107
|
-
for await (const row of rightRows) {
|
|
108
|
-
rightTree.insert(createOutputRow(row));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Yield left rows that are not in right set
|
|
112
|
-
for (const outputRow of leftRowsArray) {
|
|
113
|
-
const rightPath = rightTree.find(outputRow);
|
|
114
|
-
if (!rightPath.on) {
|
|
115
|
-
yield outputRow; // Let SortNode handle row context
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let run: InstructionRun;
|
|
121
|
-
switch (plan.op) {
|
|
122
|
-
case 'unionAll':
|
|
123
|
-
run = runUnionAll as InstructionRun;
|
|
124
|
-
break;
|
|
125
|
-
case 'union':
|
|
126
|
-
run = runUnionDistinct as InstructionRun;
|
|
127
|
-
break;
|
|
128
|
-
case 'intersect':
|
|
129
|
-
run = runIntersect as InstructionRun;
|
|
130
|
-
break;
|
|
131
|
-
case 'except':
|
|
132
|
-
run = runExcept as InstructionRun;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
params: [leftInst, rightInst],
|
|
138
|
-
run,
|
|
139
|
-
note: plan.op
|
|
140
|
-
};
|
|
141
|
-
}
|
package/src/runtime/emit/sink.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { SinkNode } from '../../planner/nodes/sink-node.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import type { Row } from '../../common/types.js';
|
|
4
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
5
|
-
import { emitPlanNode } from '../emitters.js';
|
|
6
|
-
|
|
7
|
-
export function emitSink(plan: SinkNode, ctx: EmissionContext): Instruction {
|
|
8
|
-
async function run(ctx: RuntimeContext, sourceRows: AsyncIterable<Row>): Promise<number> {
|
|
9
|
-
let rowCount = 0;
|
|
10
|
-
|
|
11
|
-
// Consume all rows from the source to trigger side effects
|
|
12
|
-
for await (const _row of sourceRows) {
|
|
13
|
-
++rowCount;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Return the count
|
|
17
|
-
return rowCount;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
params: [sourceInstruction],
|
|
24
|
-
run: run as InstructionRun,
|
|
25
|
-
note: `sink(${plan.operation})`
|
|
26
|
-
};
|
|
27
|
-
}
|
package/src/runtime/emit/sort.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { SortNode } from '../../planner/nodes/sort.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
4
|
-
import { type SqlValue, type Row, type MaybePromise } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
import { createOrderByComparatorFast, resolveCollation } from '../../util/comparison.js';
|
|
7
|
-
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
8
|
-
import { withAsyncRowContext } from '../context-helpers.js';
|
|
9
|
-
|
|
10
|
-
export function emitSort(plan: SortNode, ctx: EmissionContext): Instruction {
|
|
11
|
-
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
12
|
-
|
|
13
|
-
// Create row descriptor for source attributes
|
|
14
|
-
const sourceRowDescriptor = buildRowDescriptor(plan.source.getAttributes());
|
|
15
|
-
|
|
16
|
-
// Emit sort key instructions and pre-create optimized comparators with resolved collations
|
|
17
|
-
const sortKeyInstructions = plan.sortKeys.map(key => emitCallFromPlan(key.expression, ctx));
|
|
18
|
-
const sortKeyComparators = plan.sortKeys.map(key => {
|
|
19
|
-
const keyType = key.expression.getType();
|
|
20
|
-
const collationName = keyType.collationName || 'BINARY';
|
|
21
|
-
const collationFunc = resolveCollation(collationName);
|
|
22
|
-
return createOrderByComparatorFast(key.direction, key.nulls, collationFunc);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
async function* run(
|
|
26
|
-
ctx: RuntimeContext,
|
|
27
|
-
source: AsyncIterable<Row>,
|
|
28
|
-
...sortKeyFunctions: Array<(ctx: RuntimeContext) => MaybePromise<SqlValue>>
|
|
29
|
-
): AsyncIterable<Row> {
|
|
30
|
-
|
|
31
|
-
// Collect all rows with their sort key values
|
|
32
|
-
const rowsWithKeys: Array<{ row: Row; keys: SqlValue[] }> = [];
|
|
33
|
-
|
|
34
|
-
for await (const sourceRow of source) {
|
|
35
|
-
const keys = await withAsyncRowContext(ctx, sourceRowDescriptor, () => sourceRow, async () => {
|
|
36
|
-
// Evaluate sort key expressions
|
|
37
|
-
const keyValues: SqlValue[] = [];
|
|
38
|
-
for (const keyFunc of sortKeyFunctions) {
|
|
39
|
-
const result = keyFunc(ctx);
|
|
40
|
-
keyValues.push(await Promise.resolve(result));
|
|
41
|
-
}
|
|
42
|
-
return keyValues;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
rowsWithKeys.push({ row: sourceRow, keys });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Sort the collected rows using pre-created optimized comparators
|
|
49
|
-
rowsWithKeys.sort((a, b) => {
|
|
50
|
-
for (let i = 0; i < sortKeyComparators.length; i++) {
|
|
51
|
-
const comparator = sortKeyComparators[i];
|
|
52
|
-
const aValue = a.keys[i];
|
|
53
|
-
const bValue = b.keys[i];
|
|
54
|
-
|
|
55
|
-
const comparison = comparator(aValue, bValue);
|
|
56
|
-
|
|
57
|
-
if (comparison !== 0) {
|
|
58
|
-
return comparison;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return 0;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Yield sorted rows
|
|
65
|
-
for (const { row } of rowsWithKeys) {
|
|
66
|
-
yield row;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
params: [sourceInstruction, ...sortKeyInstructions],
|
|
72
|
-
run: run as InstructionRun,
|
|
73
|
-
note: `sort(${plan.sortKeys.length} keys)`
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import type { InNode, ExistsNode, ScalarSubqueryNode } from '../../planner/nodes/subquery.js';
|
|
2
|
-
import type { Instruction, InstructionRun, RuntimeContext } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import type { SqlValue, Row } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
import { QuereusError } from '../../common/errors.js';
|
|
7
|
-
import { StatusCode } from '../../common/types.js';
|
|
8
|
-
import { BTree } from 'inheritree';
|
|
9
|
-
import { compareSqlValuesFast, resolveCollation } from '../../util/comparison.js';
|
|
10
|
-
import { ConstantNode } from '../../planner/nodes/plan-node.js';
|
|
11
|
-
|
|
12
|
-
export function emitScalarSubquery(plan: ScalarSubqueryNode, ctx: EmissionContext): Instruction {
|
|
13
|
-
|
|
14
|
-
async function run(_rctx: RuntimeContext, input: AsyncIterable<Row>): Promise<SqlValue> {
|
|
15
|
-
let result: SqlValue = null;
|
|
16
|
-
let seen = false;
|
|
17
|
-
|
|
18
|
-
for await (const row of input) {
|
|
19
|
-
if (seen) {
|
|
20
|
-
throw new QuereusError('Scalar subquery returned more than one row', StatusCode.ERROR, undefined, plan.expression.loc?.start.line, plan.expression.loc?.start.column);
|
|
21
|
-
}
|
|
22
|
-
if (row.length > 1) {
|
|
23
|
-
throw new QuereusError('Subquery should return at most one column', StatusCode.ERROR);
|
|
24
|
-
}
|
|
25
|
-
result = row.length === 0 ? null : row[0];
|
|
26
|
-
seen = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const innerInstruction = emitPlanNode(plan.subquery, ctx);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
params: [innerInstruction],
|
|
36
|
-
run: run as InstructionRun,
|
|
37
|
-
note: 'SCALAR_SUBQUERY'
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function emitIn(plan: InNode, ctx: EmissionContext): Instruction {
|
|
42
|
-
// Extract collation from the condition expression
|
|
43
|
-
const conditionType = plan.condition.getType();
|
|
44
|
-
const collationName = conditionType.collationName || 'BINARY';
|
|
45
|
-
const collation = resolveCollation(collationName);
|
|
46
|
-
|
|
47
|
-
if (plan.source) {
|
|
48
|
-
// IN subquery: expr IN (SELECT ...)
|
|
49
|
-
// Use streaming approach - check each row as we read it, return early on match
|
|
50
|
-
async function runSubqueryStreaming(_rctx: RuntimeContext, input: AsyncIterable<Row>, condition: SqlValue): Promise<SqlValue> {
|
|
51
|
-
// If condition is NULL, result is NULL
|
|
52
|
-
if (condition === null) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let hasNull = false;
|
|
57
|
-
for await (const row of input) {
|
|
58
|
-
if (row.length > 0) {
|
|
59
|
-
const rowValue = row[0];
|
|
60
|
-
if (rowValue === null) {
|
|
61
|
-
hasNull = true;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
// Check for match immediately - no need to materialize
|
|
65
|
-
if (compareSqlValuesFast(condition, rowValue, collation) === 0) {
|
|
66
|
-
return true; // Found a match
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// No match found - if any value was NULL, result is NULL
|
|
72
|
-
return hasNull ? null : false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
76
|
-
const conditionExpr = emitPlanNode(plan.condition, ctx);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
params: [sourceInstruction, conditionExpr],
|
|
80
|
-
run: runSubqueryStreaming as InstructionRun,
|
|
81
|
-
note: `IN (subquery)`
|
|
82
|
-
};
|
|
83
|
-
} else if (plan.values) {
|
|
84
|
-
// IN value list: expr IN (value1, value2, ...)
|
|
85
|
-
|
|
86
|
-
// Check if all values are truly constant (can be evaluated at emit time)
|
|
87
|
-
const allConstant = plan.values.every(val => val.physical.constant);
|
|
88
|
-
|
|
89
|
-
if (allConstant) {
|
|
90
|
-
// Pre-build BTree at emit time for constant values
|
|
91
|
-
const tree = new BTree<SqlValue, SqlValue>(
|
|
92
|
-
(val: SqlValue) => val,
|
|
93
|
-
(a: SqlValue, b: SqlValue) => compareSqlValuesFast(a, b, collation)
|
|
94
|
-
);
|
|
95
|
-
let hasNull = false;
|
|
96
|
-
|
|
97
|
-
function innerConstantRun(_rctx: RuntimeContext, condition: SqlValue): SqlValue {
|
|
98
|
-
// If condition is NULL, result is NULL
|
|
99
|
-
if (condition === null) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Check if condition exists in pre-built tree
|
|
104
|
-
const path = tree.find(condition);
|
|
105
|
-
if (path.on) {
|
|
106
|
-
return true; // Found a match
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// No match found - if any value was NULL, result is NULL
|
|
110
|
-
return hasNull ? null : false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const values = plan.values.map(val => (val as unknown as ConstantNode).getValue());
|
|
114
|
-
|
|
115
|
-
let runFunc: InstructionRun;
|
|
116
|
-
|
|
117
|
-
if (values.some(val => val instanceof Promise)) {
|
|
118
|
-
// Must resolve promises at runtime
|
|
119
|
-
runFunc = (async (rctx: RuntimeContext, condition: SqlValue): Promise<SqlValue> => {
|
|
120
|
-
const resolved = await Promise.all(values);
|
|
121
|
-
|
|
122
|
-
for (const value of resolved) {
|
|
123
|
-
if (value === null) {
|
|
124
|
-
hasNull = true;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
tree.insert(value as SqlValue);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return innerConstantRun(rctx, condition);
|
|
131
|
-
}) as InstructionRun;
|
|
132
|
-
} else {
|
|
133
|
-
for (const value of values) {
|
|
134
|
-
if (value === null) {
|
|
135
|
-
hasNull = true;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
tree.insert(value as SqlValue);
|
|
139
|
-
}
|
|
140
|
-
runFunc = innerConstantRun as InstructionRun;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const conditionExpr = emitPlanNode(plan.condition, ctx);
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
params: [conditionExpr],
|
|
147
|
-
run: runFunc as InstructionRun,
|
|
148
|
-
note: `IN (${plan.values.length} constant values)`
|
|
149
|
-
};
|
|
150
|
-
} else {
|
|
151
|
-
// Some values are expressions - build tree at runtime
|
|
152
|
-
function runDynamicValues(_rctx: RuntimeContext, condition: SqlValue, ...values: SqlValue[]): SqlValue {
|
|
153
|
-
// If condition is NULL, result is NULL
|
|
154
|
-
if (condition === null) {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Linear scan is optimal since we're only doing one lookup per execution
|
|
159
|
-
let hasNull = false;
|
|
160
|
-
for (const value of values) {
|
|
161
|
-
if (value === null) {
|
|
162
|
-
hasNull = true;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (compareSqlValuesFast(condition, value, collation) === 0) {
|
|
166
|
-
return true; // Found a match
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// No match found - if any value was NULL, result is NULL
|
|
171
|
-
return hasNull ? null : false;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const conditionExpr = emitPlanNode(plan.condition, ctx);
|
|
175
|
-
const valueExprs = plan.values.map(val => emitPlanNode(val, ctx));
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
params: [conditionExpr, ...valueExprs],
|
|
179
|
-
run: runDynamicValues as InstructionRun,
|
|
180
|
-
note: `IN (${plan.values.length} dynamic values)`
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
throw new QuereusError('IN node must have either source or values', StatusCode.INTERNAL);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function emitExists(plan: ExistsNode, ctx: EmissionContext): Instruction {
|
|
189
|
-
async function run(_rctx: RuntimeContext, input: AsyncIterable<Row>): Promise<SqlValue> {
|
|
190
|
-
for await (const _row of input) {
|
|
191
|
-
return true; // First row => TRUE
|
|
192
|
-
}
|
|
193
|
-
return false; // Empty => FALSE
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const innerInstruction = emitPlanNode(plan.subquery, ctx);
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
params: [innerInstruction],
|
|
200
|
-
run: run as InstructionRun,
|
|
201
|
-
note: 'EXISTS'
|
|
202
|
-
};
|
|
203
|
-
}
|