@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,59 +0,0 @@
|
|
|
1
|
-
import type { ParameterReferenceNode } from '../../planner/nodes/reference.js';
|
|
2
|
-
import type { Instruction, RuntimeContext } from '../types.js';
|
|
3
|
-
import { QuereusError } from '../../common/errors.js';
|
|
4
|
-
import { StatusCode } from '../../common/types.js';
|
|
5
|
-
import type { SqlValue } from '../../common/types.js';
|
|
6
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
7
|
-
|
|
8
|
-
export function emitParameterReference(plan: ParameterReferenceNode, _ctx: EmissionContext): Instruction {
|
|
9
|
-
function run(ctx: RuntimeContext): SqlValue {
|
|
10
|
-
const identifier = plan.nameOrIndex; // This comes from the ParameterReferenceNode instance
|
|
11
|
-
|
|
12
|
-
if (ctx.params === undefined) {
|
|
13
|
-
throw new QuereusError('Query executed with parameters, but no parameter values were provided.', StatusCode.MISUSE);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof identifier === 'number') {
|
|
17
|
-
// For ? (anonymous) parameters, identifier is a 1-based index.
|
|
18
|
-
// SqlParameters can be an array or an object.
|
|
19
|
-
if (Array.isArray(ctx.params)) {
|
|
20
|
-
if (identifier < 1 || identifier > ctx.params.length) {
|
|
21
|
-
throw new QuereusError(`Parameter index ${identifier} is out of bounds.`, StatusCode.RANGE);
|
|
22
|
-
}
|
|
23
|
-
return ctx.params[identifier - 1];
|
|
24
|
-
} else if (typeof ctx.params === 'object' && ctx.params !== null) {
|
|
25
|
-
// Support numbered parameters like :1, :2 in an object (e.g., { "1": value })
|
|
26
|
-
const key = String(identifier);
|
|
27
|
-
if (!(key in ctx.params)) {
|
|
28
|
-
throw new QuereusError(`Parameter with index ${identifier} not found in provided object.`, StatusCode.NOTFOUND);
|
|
29
|
-
}
|
|
30
|
-
return ctx.params[key as keyof typeof ctx.params];
|
|
31
|
-
} else {
|
|
32
|
-
throw new QuereusError('Parameters provided in an unsupported format for indexed access.', StatusCode.MISUSE);
|
|
33
|
-
}
|
|
34
|
-
} else if (typeof identifier === 'string') {
|
|
35
|
-
// For named parameters like :name.
|
|
36
|
-
if (Array.isArray(ctx.params)) {
|
|
37
|
-
throw new QuereusError('Named parameter found in query, but parameters provided as an array.', StatusCode.MISUSE);
|
|
38
|
-
}
|
|
39
|
-
if (typeof ctx.params === 'object' && ctx.params !== null) {
|
|
40
|
-
const key = identifier.startsWith(':') ? identifier.substring(1) : identifier;
|
|
41
|
-
if (!(key in ctx.params)) {
|
|
42
|
-
throw new QuereusError(`Parameter with name '${key}' not found.`, StatusCode.NOTFOUND);
|
|
43
|
-
}
|
|
44
|
-
return ctx.params[key as keyof typeof ctx.params];
|
|
45
|
-
} else {
|
|
46
|
-
throw new QuereusError('Parameters provided in an unsupported format for named access.', StatusCode.MISUSE);
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
// Should not happen given ParameterReferenceNode structure
|
|
50
|
-
throw new QuereusError('Invalid parameter identifier type.', StatusCode.INTERNAL);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
params: [],
|
|
56
|
-
run,
|
|
57
|
-
note: `param(${typeof plan.nameOrIndex === 'string' ? plan.nameOrIndex : '#' + plan.nameOrIndex})`
|
|
58
|
-
};
|
|
59
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
2
|
-
import type { PragmaPlanNode } from '../../planner/nodes/pragma.js';
|
|
3
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
4
|
-
import type { Row, SqlValue } from '../../common/types.js';
|
|
5
|
-
import { createLogger } from '../../common/logger.js';
|
|
6
|
-
import { QuereusError } from '../../common/errors.js';
|
|
7
|
-
import { StatusCode } from '../../common/types.js';
|
|
8
|
-
|
|
9
|
-
const log = createLogger('runtime:emit:pragma');
|
|
10
|
-
|
|
11
|
-
export function emitPragma(plan: PragmaPlanNode, _ctx: EmissionContext): Instruction {
|
|
12
|
-
const run = async function* (rctx: RuntimeContext): AsyncIterable<Row> {
|
|
13
|
-
const pragmaName = plan.pragmaName;
|
|
14
|
-
const value = plan.value;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (value !== undefined) {
|
|
19
|
-
// Writing mode: set the pragma value
|
|
20
|
-
log(`PRAGMA ${pragmaName} = ${value}`);
|
|
21
|
-
|
|
22
|
-
// Try to set as a database option first
|
|
23
|
-
try {
|
|
24
|
-
rctx.db.setOption(pragmaName, value);
|
|
25
|
-
log(`Set option ${pragmaName} = ${value}`);
|
|
26
|
-
} catch {
|
|
27
|
-
// Treat unknown pragmas as no-ops for now, like SQLite often does
|
|
28
|
-
log(`Ignoring unrecognized PRAGMA: ${pragmaName}`);
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
// Reading mode: get the pragma value
|
|
32
|
-
log(`PRAGMA ${pragmaName} (reading)`);
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const currentValue = rctx.db.getOption(pragmaName) as SqlValue;
|
|
36
|
-
log(`Read option ${pragmaName} = ${currentValue}`);
|
|
37
|
-
// Return as a single-row result with the pragma name as column
|
|
38
|
-
yield [pragmaName, currentValue];
|
|
39
|
-
} catch (error) {
|
|
40
|
-
// If the pragma is unknown, return null or throw error depending on behavior needed
|
|
41
|
-
log(`Unknown PRAGMA: ${pragmaName}`);
|
|
42
|
-
throw new QuereusError(
|
|
43
|
-
`Unknown pragma: ${pragmaName}`,
|
|
44
|
-
StatusCode.ERROR,
|
|
45
|
-
error instanceof Error ? error : undefined
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
params: [],
|
|
53
|
-
run: run as InstructionRun,
|
|
54
|
-
note: `PRAGMA ${plan.pragmaName}${plan.value !== undefined ? ` = ${plan.value}` : ''}`
|
|
55
|
-
};
|
|
56
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { ProjectNode } from '../../planner/nodes/project-node.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
4
|
-
import { type Row } from '../../common/types.js';
|
|
5
|
-
import { type OutputValue } from '../../common/types.js';
|
|
6
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
7
|
-
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
8
|
-
import { withAsyncRowContext, withRowContextGenerator } from '../context-helpers.js';
|
|
9
|
-
|
|
10
|
-
export function emitProject(plan: ProjectNode, ctx: EmissionContext): Instruction {
|
|
11
|
-
const sourceInstruction = emitPlanNode(plan.source, ctx);
|
|
12
|
-
const projectionFuncs = plan.projections.map((projection) => {
|
|
13
|
-
return emitCallFromPlan(projection.node, ctx);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Row descriptors
|
|
17
|
-
const sourceRowDescriptor = buildRowDescriptor(plan.source.getAttributes());
|
|
18
|
-
const outputRowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
19
|
-
|
|
20
|
-
async function* run(rctx: RuntimeContext, source: AsyncIterable<Row>, ...projectionFunctions: Array<(ctx: RuntimeContext) => OutputValue>): AsyncIterable<Row> {
|
|
21
|
-
for await (const sourceRow of source) {
|
|
22
|
-
// Evaluate projections using the source row context
|
|
23
|
-
const outputs = await withAsyncRowContext(rctx, sourceRowDescriptor, () => sourceRow, async () => {
|
|
24
|
-
return Promise.all(projectionFunctions.map(fn => fn(rctx)));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Push the output row descriptor for downstream consumers
|
|
28
|
-
yield* withRowContextGenerator(
|
|
29
|
-
rctx,
|
|
30
|
-
outputRowDescriptor,
|
|
31
|
-
(async function* () {
|
|
32
|
-
yield outputs as Row;
|
|
33
|
-
})(),
|
|
34
|
-
async function* (row) {
|
|
35
|
-
yield row;
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
params: [sourceInstruction, ...projectionFuncs],
|
|
43
|
-
run: run as InstructionRun,
|
|
44
|
-
note: `project(${plan.projections.length} cols)`
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { RecursiveCTENode } from '../../planner/nodes/recursive-cte-node.js';
|
|
2
|
-
import type { Instruction, InstructionRun, RuntimeContext } from '../types.js';
|
|
3
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
4
|
-
import { emitCallFromPlan, emitPlanNode } from '../emitters.js';
|
|
5
|
-
import type { Row } from '../../common/types.js';
|
|
6
|
-
import { createLogger } from '../../common/logger.js';
|
|
7
|
-
import { BTree } from 'inheritree';
|
|
8
|
-
import { compareRows } from '../../util/comparison.js';
|
|
9
|
-
import { WorkingTableIterable } from '../../util/working-table-iterable.js';
|
|
10
|
-
import { DEFAULT_TUNING } from '../../planner/optimizer-tuning.js';
|
|
11
|
-
import { quereusError } from '../../common/errors.js';
|
|
12
|
-
import { StatusCode } from '../../common/types.js';
|
|
13
|
-
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
14
|
-
import { withRowContext } from '../context-helpers.js';
|
|
15
|
-
|
|
16
|
-
const log = createLogger('runtime:emit:recursive-cte');
|
|
17
|
-
|
|
18
|
-
export function emitRecursiveCTE(plan: RecursiveCTENode, ctx: EmissionContext): Instruction {
|
|
19
|
-
// Create row descriptor for CTE output attributes
|
|
20
|
-
const rowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
21
|
-
|
|
22
|
-
// Use the plan's table descriptor for table context coordination
|
|
23
|
-
const { tableDescriptor } = plan;
|
|
24
|
-
|
|
25
|
-
async function* run(rctx: RuntimeContext, baseCaseResult: AsyncIterable<Row>, recursiveCaseCallback: (ctx: RuntimeContext) => AsyncIterable<Row>): AsyncIterable<Row> {
|
|
26
|
-
log('Starting recursive CTE execution for %s (union=%s, algorithm=semi-naive)', plan.cteName, plan.isUnionAll ? 'ALL' : 'DISTINCT');
|
|
27
|
-
|
|
28
|
-
// Get configuration - use plan node limit if specified, otherwise use default tuning
|
|
29
|
-
const maxIterations = plan.maxRecursion ?? DEFAULT_TUNING.recursiveCte.maxIterations;
|
|
30
|
-
|
|
31
|
-
// Step 1: Initialize deduplication storage (for UNION DISTINCT) and delta tracking
|
|
32
|
-
const allRowsTree = plan.isUnionAll ? null : new BTree<Row, Row>(
|
|
33
|
-
(row: Row) => row, // Identity function - use row as its own key
|
|
34
|
-
compareRows
|
|
35
|
-
);
|
|
36
|
-
let deltaRows: Row[] = [];
|
|
37
|
-
|
|
38
|
-
// Step 2: Execute base case and populate initial delta
|
|
39
|
-
// Stream base case results immediately while building delta for next iteration
|
|
40
|
-
for await (const row of baseCaseResult) {
|
|
41
|
-
// Yield if we're union all or if the row is new
|
|
42
|
-
const shouldYield = !allRowsTree || allRowsTree.insert(row).on;
|
|
43
|
-
|
|
44
|
-
if (shouldYield) {
|
|
45
|
-
// Yield immediately (streaming)
|
|
46
|
-
yield withRowContext(rctx, rowDescriptor, () => row, () => row);
|
|
47
|
-
|
|
48
|
-
// Add to delta for recursive processing (deep copy to avoid reference issues)
|
|
49
|
-
deltaRows.push([...row] as Row);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Step 3: Semi-naïve iterative recursive execution
|
|
54
|
-
let iterationCount = 0;
|
|
55
|
-
|
|
56
|
-
while (deltaRows.length > 0 && (maxIterations === 0 || iterationCount < maxIterations)) {
|
|
57
|
-
++iterationCount;
|
|
58
|
-
log('Recursive CTE %s iteration %d, delta size: %d', plan.cteName, iterationCount, deltaRows.length);
|
|
59
|
-
|
|
60
|
-
// Create a working table iterable from ONLY the delta (not all accumulated rows)
|
|
61
|
-
const deltaIterable = new WorkingTableIterable([...deltaRows], rctx, rowDescriptor);
|
|
62
|
-
const newDeltaRows: Row[] = []; // Collect rows for next iteration
|
|
63
|
-
|
|
64
|
-
// Set up the delta table in context for CTE references to access
|
|
65
|
-
rctx.tableContexts.set(tableDescriptor, () => deltaIterable);
|
|
66
|
-
try {
|
|
67
|
-
// Execute recursive case using the callback - it only sees the delta
|
|
68
|
-
for await (const row of recursiveCaseCallback(rctx)) {
|
|
69
|
-
// For UNION DISTINCT: check if row is new; for UNION ALL: accept all rows
|
|
70
|
-
const shouldYield = !allRowsTree || allRowsTree.insert(row).on;
|
|
71
|
-
|
|
72
|
-
if (shouldYield) {
|
|
73
|
-
// Stream the row immediately
|
|
74
|
-
yield withRowContext(rctx, rowDescriptor, () => row, () => row);
|
|
75
|
-
|
|
76
|
-
// Add to next iteration's delta (deep copy to avoid reference issues)
|
|
77
|
-
newDeltaRows.push([...row] as Row);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
} finally {
|
|
81
|
-
rctx.tableContexts.delete(tableDescriptor);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Update delta for next iteration - only new rows, not accumulated result
|
|
85
|
-
deltaRows = newDeltaRows;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Safety check for infinite recursion
|
|
89
|
-
if (iterationCount >= maxIterations) {
|
|
90
|
-
quereusError(
|
|
91
|
-
`Recursive CTE '${plan.cteName}' exceeded maximum iteration limit (${maxIterations})`,
|
|
92
|
-
StatusCode.ERROR
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
log('Recursive CTE %s completed after %d iterations (semi-naive algorithm)', plan.cteName, iterationCount);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Emit both base case and recursive case instructions
|
|
100
|
-
const baseCaseInstruction = emitPlanNode(plan.baseCaseQuery, ctx);
|
|
101
|
-
const recursiveCaseInstruction = emitCallFromPlan(plan.recursiveCaseQuery, ctx);
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
params: [baseCaseInstruction, recursiveCaseInstruction],
|
|
105
|
-
run: run as InstructionRun,
|
|
106
|
-
note: `recursiveCTE(${plan.cteName})`
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Instruction, RuntimeContext } from '../types.js';
|
|
2
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
3
|
-
import type { Row } from '../../common/types.js';
|
|
4
|
-
import { QuereusError } from '../../common/errors.js';
|
|
5
|
-
import { StatusCode } from '../../common/types.js';
|
|
6
|
-
import type { RemoteQueryNode } from '../../planner/nodes/remote-query-node.js';
|
|
7
|
-
import type { AnyVirtualTableModule } from '../../vtab/module.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Emitter for RemoteQueryNode.
|
|
11
|
-
* Calls the virtual table's executePlan() method to execute the pushed-down pipeline.
|
|
12
|
-
*/
|
|
13
|
-
export function emitRemoteQuery(plan: RemoteQueryNode, _ctx: EmissionContext): Instruction {
|
|
14
|
-
async function* run(rctx: RuntimeContext): AsyncIterable<Row> {
|
|
15
|
-
// Retrieve virtual table connection via module context
|
|
16
|
-
const { tableRef, moduleCtx } = plan;
|
|
17
|
-
// Get the table instance - need to resolve this from the table reference
|
|
18
|
-
const tableSchema = tableRef.tableSchema;
|
|
19
|
-
const vtabModule = (moduleCtx as { vtabModule?: AnyVirtualTableModule } | undefined)?.vtabModule ?? tableRef.vtabModule;
|
|
20
|
-
|
|
21
|
-
// Connect to the table to get the instance
|
|
22
|
-
const table = vtabModule.connect(
|
|
23
|
-
rctx.db,
|
|
24
|
-
undefined, // pAux
|
|
25
|
-
tableSchema.vtabModuleName,
|
|
26
|
-
tableSchema.schemaName,
|
|
27
|
-
tableSchema.name,
|
|
28
|
-
{} // empty config for now
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
if (!table.executePlan) {
|
|
32
|
-
throw new QuereusError(
|
|
33
|
-
`Virtual table module for '${tableSchema.name}' does not implement executePlan() ` +
|
|
34
|
-
`despite indicating support via supports() method.`,
|
|
35
|
-
StatusCode.INTERNAL
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
yield* table.executePlan(rctx.db, plan.source, plan.moduleCtx);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
params: [],
|
|
44
|
-
run,
|
|
45
|
-
note: `remoteQuery(${plan.tableRef.tableSchema.name})`
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { RetrieveNode } from '../../planner/nodes/retrieve-node.js';
|
|
2
|
-
import type { Instruction } from '../types.js';
|
|
3
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
4
|
-
import { QuereusError } from '../../common/errors.js';
|
|
5
|
-
import { StatusCode } from '../../common/types.js';
|
|
6
|
-
|
|
7
|
-
export function emitRetrieve(plan: RetrieveNode, _ctx: EmissionContext): Instruction {
|
|
8
|
-
// RetrieveNode should always be rewritten by the optimizer's access path selection rule
|
|
9
|
-
// If we reach this point, it means the optimizer failed to convert it to a physical node
|
|
10
|
-
throw new QuereusError(
|
|
11
|
-
`RetrieveNode for table '${plan.tableRef.tableSchema.name}' was not rewritten to a physical access node. ` +
|
|
12
|
-
`This indicates the virtual table module has no supported access method (neither supports() nor getBestAccessPlan()).`,
|
|
13
|
-
StatusCode.INTERNAL
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ReturningNode } from '../../planner/nodes/returning-node.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import type { Row, OutputValue } from '../../common/types.js';
|
|
4
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
5
|
-
import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
|
|
6
|
-
import { buildRowDescriptor } from '../../util/row-descriptor.js';
|
|
7
|
-
import { withRowContextGenerator } from '../context-helpers.js';
|
|
8
|
-
|
|
9
|
-
export function emitReturning(plan: ReturningNode, ctx: EmissionContext): Instruction {
|
|
10
|
-
// Use the executor's attributes to build the row descriptor
|
|
11
|
-
// The executor should already output the correct flat OLD/NEW format for mutation operations
|
|
12
|
-
const sourceRowDescriptor = buildRowDescriptor(plan.executor.getAttributes());
|
|
13
|
-
|
|
14
|
-
// Pre-emit the projection expressions
|
|
15
|
-
const projectionEvaluators = plan.projections.map(proj =>
|
|
16
|
-
emitCallFromPlan(proj.node, ctx)
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
async function* run(
|
|
20
|
-
rctx: RuntimeContext,
|
|
21
|
-
executorRows: AsyncIterable<Row>,
|
|
22
|
-
...projectionCallbacks: Array<(ctx: RuntimeContext) => OutputValue>
|
|
23
|
-
): AsyncIterable<Row> {
|
|
24
|
-
// Project the results from the executor rows
|
|
25
|
-
yield* withRowContextGenerator(rctx, sourceRowDescriptor, executorRows, async function* (_sourceRow) {
|
|
26
|
-
// Evaluate projection expressions in the context of this row
|
|
27
|
-
const outputs = projectionCallbacks.map(func => func(rctx));
|
|
28
|
-
const resolved = await Promise.all(outputs);
|
|
29
|
-
yield resolved as Row;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Emit the executor (now always produces rows)
|
|
34
|
-
const executorInstruction = emitPlanNode(plan.executor, ctx);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
params: [executorInstruction, ...projectionEvaluators],
|
|
38
|
-
run: run as InstructionRun,
|
|
39
|
-
note: `returning(${plan.projections.length} cols)`
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { ScalarFunctionCallNode } from '../../planner/nodes/function.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { emitPlanNode, createValidatedInstruction } from '../emitters.js';
|
|
4
|
-
import { QuereusError } from '../../common/errors.js';
|
|
5
|
-
import { StatusCode, type SqlValue, type OutputValue } from '../../common/types.js';
|
|
6
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
7
|
-
import type { ScalarFunctionSchema } from '../../schema/function.js';
|
|
8
|
-
import { isScalarFunctionSchema } from '../../schema/function.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Default emission logic for scalar function calls.
|
|
12
|
-
* This is exported so custom emitters can call it if needed.
|
|
13
|
-
*/
|
|
14
|
-
export function emitScalarFunctionCallDefault(plan: ScalarFunctionCallNode, ctx: EmissionContext): Instruction {
|
|
15
|
-
const functionName = plan.expression.name.toLowerCase();
|
|
16
|
-
const functionSchema = plan.functionSchema;
|
|
17
|
-
|
|
18
|
-
// Validate that it's a scalar function
|
|
19
|
-
if (!isScalarFunctionSchema(functionSchema)) {
|
|
20
|
-
throw new QuereusError(`Function ${functionName} is not a scalar function`, StatusCode.ERROR);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function run(_rctx: RuntimeContext, ...args: Array<SqlValue>): OutputValue {
|
|
24
|
-
// Use the pre-resolved function schema from the plan node
|
|
25
|
-
const scalarFunction = functionSchema as ScalarFunctionSchema;
|
|
26
|
-
|
|
27
|
-
// Validate argument count
|
|
28
|
-
if (scalarFunction.numArgs >= 0 && args.length !== scalarFunction.numArgs) {
|
|
29
|
-
throw new QuereusError(`Function ${functionName} called with ${args.length} arguments, expected ${scalarFunction.numArgs}`, StatusCode.ERROR);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
return scalarFunction.implementation(...args);
|
|
34
|
-
} catch (error: any) {
|
|
35
|
-
throw new QuereusError(`Function ${functionName} failed: ${error.message}`, StatusCode.ERROR, error, plan.expression.loc?.start.line, plan.expression.loc?.start.column);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const operandExprs = plan.operands.map(operand => emitPlanNode(operand, ctx));
|
|
40
|
-
|
|
41
|
-
return createValidatedInstruction(
|
|
42
|
-
[...operandExprs],
|
|
43
|
-
run as InstructionRun,
|
|
44
|
-
ctx,
|
|
45
|
-
`${plan.expression.name}(${plan.operands.length})`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Main emitter for scalar function calls.
|
|
51
|
-
* Checks if the function has a custom emitter and uses it, otherwise uses default logic.
|
|
52
|
-
*/
|
|
53
|
-
export function emitScalarFunctionCall(plan: ScalarFunctionCallNode, ctx: EmissionContext): Instruction {
|
|
54
|
-
const functionSchema = plan.functionSchema;
|
|
55
|
-
|
|
56
|
-
// Validate that it's a scalar function
|
|
57
|
-
if (!isScalarFunctionSchema(functionSchema)) {
|
|
58
|
-
const functionName = plan.expression.name.toLowerCase();
|
|
59
|
-
throw new QuereusError(`Function ${functionName} is not a scalar function`, StatusCode.ERROR);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Check if function has a custom emitter
|
|
63
|
-
if (functionSchema.customEmitter) {
|
|
64
|
-
return functionSchema.customEmitter(plan, ctx, emitScalarFunctionCallDefault);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Use default emission logic
|
|
68
|
-
return emitScalarFunctionCallDefault(plan, ctx);
|
|
69
|
-
}
|
package/src/runtime/emit/scan.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { StatusCode, type Row } from "../../common/types.js";
|
|
2
|
-
import { SeqScanNode, IndexScanNode, IndexSeekNode } from "../../planner/nodes/table-access-nodes.js";
|
|
3
|
-
import { QuereusError } from "../../common/errors.js";
|
|
4
|
-
import type { VirtualTable } from "../../vtab/table.js";
|
|
5
|
-
import type { BaseModuleConfig, AnyVirtualTableModule } from "../../vtab/module.js";
|
|
6
|
-
import type { Instruction, RuntimeContext } from "../types.js";
|
|
7
|
-
import type { EmissionContext } from "../emission-context.js";
|
|
8
|
-
import { createValidatedInstruction, emitPlanNode } from "../emitters.js";
|
|
9
|
-
import { disconnectVTable } from "../utils.js";
|
|
10
|
-
import { buildRowDescriptor } from "../../util/row-descriptor.js";
|
|
11
|
-
import { createRowSlot } from "../context-helpers.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Emits instructions for physical table access nodes (SeqScan, IndexScan, IndexSeek)
|
|
15
|
-
*/
|
|
16
|
-
export function emitSeqScan(plan: SeqScanNode | IndexScanNode | IndexSeekNode, ctx: EmissionContext): Instruction {
|
|
17
|
-
// Handle physical access nodes
|
|
18
|
-
const source = plan.source;
|
|
19
|
-
const schema = source.tableSchema;
|
|
20
|
-
|
|
21
|
-
// Create row descriptor mapping attribute IDs to column indices
|
|
22
|
-
const rowDescriptor = buildRowDescriptor(plan.getAttributes());
|
|
23
|
-
|
|
24
|
-
// Look up the virtual table module during emission and record the dependency
|
|
25
|
-
const moduleInfo = ctx.getVtabModule(schema.vtabModuleName);
|
|
26
|
-
if (!moduleInfo) {
|
|
27
|
-
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' not found`, StatusCode.ERROR);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Capture the module info key for runtime retrieval
|
|
31
|
-
const moduleKey = `vtab_module:${schema.vtabModuleName}`;
|
|
32
|
-
|
|
33
|
-
async function* run(runtimeCtx: RuntimeContext, ...dynamicArgs: any[]): AsyncIterable<Row> {
|
|
34
|
-
// Use the captured module info instead of doing a fresh lookup
|
|
35
|
-
const capturedModuleInfo = ctx.getCapturedSchemaObject<{ module: AnyVirtualTableModule, auxData?: unknown }>(moduleKey);
|
|
36
|
-
if (!capturedModuleInfo) {
|
|
37
|
-
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' was not captured during emission`, StatusCode.INTERNAL);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const module = capturedModuleInfo.module;
|
|
41
|
-
if (typeof module.connect !== 'function') {
|
|
42
|
-
throw new QuereusError(`Virtual table module '${schema.vtabModuleName}' does not implement connect`, StatusCode.MISUSE);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let vtabInstance: VirtualTable;
|
|
46
|
-
try {
|
|
47
|
-
const options: BaseModuleConfig = (schema.vtabArgs ?? {}) as BaseModuleConfig;
|
|
48
|
-
vtabInstance = module.connect(
|
|
49
|
-
runtimeCtx.db,
|
|
50
|
-
capturedModuleInfo.auxData,
|
|
51
|
-
schema.vtabModuleName,
|
|
52
|
-
schema.schemaName,
|
|
53
|
-
schema.name,
|
|
54
|
-
options
|
|
55
|
-
);
|
|
56
|
-
} catch (e: any) {
|
|
57
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
58
|
-
throw new QuereusError(`Module '${schema.vtabModuleName}' connect failed for table '${schema.name}': ${message}`, e instanceof QuereusError ? e.code : StatusCode.ERROR, e instanceof Error ? e : undefined);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (typeof vtabInstance.query !== 'function') {
|
|
62
|
-
// Fallback or error if query is not available. For now, throwing an error.
|
|
63
|
-
// Later, we could implement the open/filter/next loop here as a fallback.
|
|
64
|
-
throw new QuereusError(`Virtual table '${schema.name}' does not support query.`, StatusCode.UNSUPPORTED);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const rowSlot = createRowSlot(runtimeCtx, rowDescriptor);
|
|
68
|
-
try {
|
|
69
|
-
// If this is an IndexSeek with dynamic seek keys, populate args from params
|
|
70
|
-
const effectiveFilterInfo = (() => {
|
|
71
|
-
if (plan instanceof IndexSeekNode && dynamicArgs && dynamicArgs.length > 0) {
|
|
72
|
-
return { ...plan.filterInfo, args: dynamicArgs };
|
|
73
|
-
}
|
|
74
|
-
return plan.filterInfo;
|
|
75
|
-
})();
|
|
76
|
-
|
|
77
|
-
const asyncRowIterable = vtabInstance.query(effectiveFilterInfo);
|
|
78
|
-
for await (const row of asyncRowIterable) {
|
|
79
|
-
rowSlot.set(row);
|
|
80
|
-
yield row;
|
|
81
|
-
}
|
|
82
|
-
} catch (e: any) {
|
|
83
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
84
|
-
throw new QuereusError(`Error during query on table '${schema.name}': ${message}`, e instanceof QuereusError ? e.code : StatusCode.ERROR, e instanceof Error ? e : undefined);
|
|
85
|
-
} finally {
|
|
86
|
-
rowSlot.close();
|
|
87
|
-
// Properly disconnect the VirtualTable instance
|
|
88
|
-
await disconnectVTable(runtimeCtx, vtabInstance);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Emit parameter instructions for dynamic seek keys (IndexSeek only)
|
|
93
|
-
const params: Instruction[] = [];
|
|
94
|
-
if (plan instanceof IndexSeekNode) {
|
|
95
|
-
for (const key of plan.getSeekKeys()) {
|
|
96
|
-
params.push(emitPlanNode(key, ctx));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return createValidatedInstruction(
|
|
101
|
-
params,
|
|
102
|
-
run,
|
|
103
|
-
ctx,
|
|
104
|
-
`${plan.nodeType}(${schema.name})`
|
|
105
|
-
);
|
|
106
|
-
}
|