@quereus/quereus 0.7.3 → 0.7.4
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/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,357 +0,0 @@
|
|
|
1
|
-
import { StatusCode } from "../../common/types.js";
|
|
2
|
-
import { QuereusError } from "../../common/errors.js";
|
|
3
|
-
import type { SqlValue } from "../../common/types.js";
|
|
4
|
-
import type { Instruction, InstructionRun, RuntimeContext } from "../types.js";
|
|
5
|
-
import type { BinaryOpNode } from "../../planner/nodes/scalar.js";
|
|
6
|
-
import { emitPlanNode } from "../emitters.js";
|
|
7
|
-
import { compareSqlValuesFast, resolveCollation } from "../../util/comparison.js";
|
|
8
|
-
import { coerceForComparison, coerceToNumberForArithmetic } from "../../util/coercion.js";
|
|
9
|
-
import { simpleLike } from "../../util/patterns.js";
|
|
10
|
-
import type { EmissionContext } from "../emission-context.js";
|
|
11
|
-
import { tryTemporalArithmetic, tryTemporalComparison } from "./temporal-arithmetic.js";
|
|
12
|
-
|
|
13
|
-
export function emitBinaryOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
14
|
-
// Normalize operator to uppercase for case-insensitive matching of keywords
|
|
15
|
-
const operator = plan.expression.operator.toUpperCase();
|
|
16
|
-
|
|
17
|
-
switch (operator) {
|
|
18
|
-
case '+':
|
|
19
|
-
case '-':
|
|
20
|
-
case '*':
|
|
21
|
-
case '/':
|
|
22
|
-
case '%':
|
|
23
|
-
return emitNumericOp(plan, ctx);
|
|
24
|
-
case '=':
|
|
25
|
-
case '==':
|
|
26
|
-
case '!=':
|
|
27
|
-
case '<>':
|
|
28
|
-
case '<':
|
|
29
|
-
case '<=':
|
|
30
|
-
case '>':
|
|
31
|
-
case '>=':
|
|
32
|
-
return emitComparisonOp(plan, ctx);
|
|
33
|
-
case '||':
|
|
34
|
-
return emitConcatOp(plan, ctx);
|
|
35
|
-
case 'AND':
|
|
36
|
-
case 'OR':
|
|
37
|
-
case 'XOR':
|
|
38
|
-
return emitLogicalOp(plan, ctx);
|
|
39
|
-
case 'LIKE':
|
|
40
|
-
return emitLikeOp(plan, ctx);
|
|
41
|
-
// TODO: emitBitwise
|
|
42
|
-
default:
|
|
43
|
-
throw new QuereusError(`Unsupported binary operator: ${plan.expression.operator}`, StatusCode.UNSUPPORTED);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function emitNumericOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
48
|
-
let inner: (v1: number, v2: number) => number;
|
|
49
|
-
let innerBigInt: (v1: bigint, v2: bigint) => bigint;
|
|
50
|
-
|
|
51
|
-
switch (plan.expression.operator) {
|
|
52
|
-
case '+':
|
|
53
|
-
inner = (v1, v2) => v1 + v2;
|
|
54
|
-
innerBigInt = (v1, v2) => v1 + v2;
|
|
55
|
-
break;
|
|
56
|
-
case '-':
|
|
57
|
-
inner = (v1, v2) => v1 - v2;
|
|
58
|
-
innerBigInt = (v1, v2) => v1 - v2;
|
|
59
|
-
break;
|
|
60
|
-
case '*':
|
|
61
|
-
inner = (v1, v2) => v1 * v2;
|
|
62
|
-
innerBigInt = (v1, v2) => v1 * v2;
|
|
63
|
-
break;
|
|
64
|
-
case '/':
|
|
65
|
-
inner = (v1, v2) => v1 / v2;
|
|
66
|
-
innerBigInt = (v1, v2) => v1 / v2;
|
|
67
|
-
break;
|
|
68
|
-
case '%':
|
|
69
|
-
inner = (v1, v2) => v1 % v2;
|
|
70
|
-
innerBigInt = (v1, v2) => v1 % v2;
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
throw new QuereusError(`Unsupported numeric operator: ${plan.expression.operator}`, StatusCode.UNSUPPORTED);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function run(ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue {
|
|
77
|
-
// Try temporal arithmetic first
|
|
78
|
-
const temporalResult = tryTemporalArithmetic(plan.expression.operator, v1, v2);
|
|
79
|
-
if (temporalResult !== undefined) {
|
|
80
|
-
return temporalResult;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Fall back to numeric arithmetic
|
|
84
|
-
if (v1 !== null && v2 !== null) {
|
|
85
|
-
if (typeof v1 === 'bigint' || typeof v2 === 'bigint') {
|
|
86
|
-
try {
|
|
87
|
-
return innerBigInt(v1 as bigint, v2 as bigint);
|
|
88
|
-
} catch {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
// Use shared coercion function for arithmetic context
|
|
93
|
-
const n1 = coerceToNumberForArithmetic(v1);
|
|
94
|
-
const n2 = coerceToNumberForArithmetic(v2);
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const result = inner(n1, n2);
|
|
98
|
-
if (!Number.isFinite(result)) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
} catch {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const leftExpr = emitPlanNode(plan.left, ctx);
|
|
111
|
-
const rightExpr = emitPlanNode(plan.right, ctx);
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
params: [leftExpr, rightExpr],
|
|
115
|
-
run: run as InstructionRun,
|
|
116
|
-
note: `${plan.expression.operator}(numeric)`
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function emitComparisonOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
121
|
-
let run: (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue) => SqlValue;
|
|
122
|
-
|
|
123
|
-
// Determine collation to use for comparison
|
|
124
|
-
const leftType = plan.left.getType();
|
|
125
|
-
const rightType = plan.right.getType();
|
|
126
|
-
let collationName = 'BINARY';
|
|
127
|
-
|
|
128
|
-
// Use collation from either operand (right side takes precedence for COLLATE expressions)
|
|
129
|
-
if (rightType.collationName) {
|
|
130
|
-
collationName = rightType.collationName;
|
|
131
|
-
} else if (leftType.collationName) {
|
|
132
|
-
collationName = leftType.collationName;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Pre-resolve collation function for optimal performance
|
|
136
|
-
const collationFunc = resolveCollation(collationName);
|
|
137
|
-
|
|
138
|
-
const operator = plan.expression.operator;
|
|
139
|
-
|
|
140
|
-
switch (operator) {
|
|
141
|
-
case '=':
|
|
142
|
-
case '==':
|
|
143
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
144
|
-
// SQL comparison: NULL = anything -> NULL
|
|
145
|
-
if (v1 === null || v2 === null) return null;
|
|
146
|
-
|
|
147
|
-
// Try temporal comparison first
|
|
148
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
149
|
-
if (temporalResult !== undefined) {
|
|
150
|
-
return temporalResult;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Apply type coercion before comparison
|
|
154
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
155
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) === 0;
|
|
156
|
-
};
|
|
157
|
-
break;
|
|
158
|
-
case '!=':
|
|
159
|
-
case '<>':
|
|
160
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
161
|
-
// SQL comparison: NULL != anything -> NULL
|
|
162
|
-
if (v1 === null || v2 === null) return null;
|
|
163
|
-
|
|
164
|
-
// Try temporal comparison first
|
|
165
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
166
|
-
if (temporalResult !== undefined) {
|
|
167
|
-
return temporalResult;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Apply type coercion before comparison
|
|
171
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
172
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) !== 0;
|
|
173
|
-
};
|
|
174
|
-
break;
|
|
175
|
-
case '<':
|
|
176
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
177
|
-
// SQL comparison: NULL < anything -> NULL
|
|
178
|
-
if (v1 === null || v2 === null) return null;
|
|
179
|
-
|
|
180
|
-
// Try temporal comparison first
|
|
181
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
182
|
-
if (temporalResult !== undefined) {
|
|
183
|
-
return temporalResult;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Apply type coercion before comparison
|
|
187
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
188
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) < 0;
|
|
189
|
-
};
|
|
190
|
-
break;
|
|
191
|
-
case '<=':
|
|
192
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
193
|
-
// SQL comparison: NULL <= anything -> NULL
|
|
194
|
-
if (v1 === null || v2 === null) return null;
|
|
195
|
-
|
|
196
|
-
// Try temporal comparison first
|
|
197
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
198
|
-
if (temporalResult !== undefined) {
|
|
199
|
-
return temporalResult;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Apply type coercion before comparison
|
|
203
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
204
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) <= 0;
|
|
205
|
-
};
|
|
206
|
-
break;
|
|
207
|
-
case '>':
|
|
208
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
209
|
-
// SQL comparison: NULL > anything -> NULL
|
|
210
|
-
if (v1 === null || v2 === null) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Try temporal comparison first
|
|
215
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
216
|
-
if (temporalResult !== undefined) {
|
|
217
|
-
return temporalResult;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Apply type coercion before comparison
|
|
221
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
222
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) > 0;
|
|
223
|
-
};
|
|
224
|
-
break;
|
|
225
|
-
case '>=':
|
|
226
|
-
run = (ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue => {
|
|
227
|
-
// SQL comparison: NULL >= anything -> NULL
|
|
228
|
-
if (v1 === null || v2 === null) return null;
|
|
229
|
-
|
|
230
|
-
// Try temporal comparison first
|
|
231
|
-
const temporalResult = tryTemporalComparison(operator, v1, v2);
|
|
232
|
-
if (temporalResult !== undefined) {
|
|
233
|
-
return temporalResult;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Apply type coercion before comparison
|
|
237
|
-
const [coercedV1, coercedV2] = coerceForComparison(v1, v2);
|
|
238
|
-
return compareSqlValuesFast(coercedV1, coercedV2, collationFunc) >= 0;
|
|
239
|
-
};
|
|
240
|
-
break;
|
|
241
|
-
default:
|
|
242
|
-
throw new QuereusError(`Unsupported comparison operator: ${operator}`, StatusCode.UNSUPPORTED);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const leftExpr = emitPlanNode(plan.left, ctx);
|
|
246
|
-
const rightExpr = emitPlanNode(plan.right, ctx);
|
|
247
|
-
|
|
248
|
-
return {
|
|
249
|
-
params: [leftExpr, rightExpr],
|
|
250
|
-
run: run as InstructionRun,
|
|
251
|
-
note: `${plan.expression.operator}(compare${collationName !== 'BINARY' ? ` ${collationName}` : ''})`
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export function emitConcatOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
256
|
-
function run(ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue {
|
|
257
|
-
// SQL concatenation: NULL || anything -> NULL
|
|
258
|
-
if (v1 === null || v2 === null) return null;
|
|
259
|
-
|
|
260
|
-
// Convert both operands to strings
|
|
261
|
-
const s1 = String(v1);
|
|
262
|
-
const s2 = String(v2);
|
|
263
|
-
return s1 + s2;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const leftExpr = emitPlanNode(plan.left, ctx);
|
|
267
|
-
const rightExpr = emitPlanNode(plan.right, ctx);
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
params: [leftExpr, rightExpr],
|
|
271
|
-
run: run as InstructionRun,
|
|
272
|
-
note: '||(concat)'
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export function emitLogicalOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
277
|
-
// Normalize operator to uppercase for case-insensitive matching
|
|
278
|
-
const operator = plan.expression.operator.toUpperCase();
|
|
279
|
-
|
|
280
|
-
function run(ctx: RuntimeContext, v1: SqlValue, v2: SqlValue): SqlValue {
|
|
281
|
-
// SQL three-valued logic
|
|
282
|
-
switch (operator) {
|
|
283
|
-
case 'AND': {
|
|
284
|
-
// NULL AND x -> NULL if x is true or NULL, otherwise false
|
|
285
|
-
// false AND x -> false
|
|
286
|
-
// true AND x -> x
|
|
287
|
-
if (v1 === null) {
|
|
288
|
-
return (v2 === null || v2) ? null : false;
|
|
289
|
-
}
|
|
290
|
-
if (!v1) return false;
|
|
291
|
-
return v2 === null ? null : (v2 ? true : false);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
case 'OR': {
|
|
295
|
-
// NULL OR x -> NULL if x is false or NULL, otherwise true
|
|
296
|
-
// true OR x -> true
|
|
297
|
-
// false OR x -> x
|
|
298
|
-
if (v1 === null) {
|
|
299
|
-
return (v2 === null || !v2) ? null : true;
|
|
300
|
-
}
|
|
301
|
-
if (v1) return true;
|
|
302
|
-
return v2 === null ? null : (v2 ? true : false);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
case 'XOR': {
|
|
306
|
-
// NULL XOR x -> NULL
|
|
307
|
-
// x XOR NULL -> NULL
|
|
308
|
-
// false XOR false -> false
|
|
309
|
-
// false XOR true -> true
|
|
310
|
-
// true XOR false -> true
|
|
311
|
-
// true XOR true -> false
|
|
312
|
-
if (v1 === null || v2 === null) return null;
|
|
313
|
-
const b1 = !!v1;
|
|
314
|
-
const b2 = !!v2;
|
|
315
|
-
return b1 !== b2;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
default:
|
|
319
|
-
throw new QuereusError(`Unsupported logical operator: ${plan.expression.operator}`, StatusCode.UNSUPPORTED);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const leftExpr = emitPlanNode(plan.left, ctx);
|
|
324
|
-
const rightExpr = emitPlanNode(plan.right, ctx);
|
|
325
|
-
|
|
326
|
-
return {
|
|
327
|
-
params: [leftExpr, rightExpr],
|
|
328
|
-
run: run as InstructionRun,
|
|
329
|
-
note: `${plan.expression.operator}(logical)`
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export function emitLikeOp(plan: BinaryOpNode, ctx: EmissionContext): Instruction {
|
|
334
|
-
function run(ctx: RuntimeContext, text: SqlValue, pattern: SqlValue): SqlValue {
|
|
335
|
-
// SQL LIKE logic: text LIKE pattern
|
|
336
|
-
// NULL handling: if either operand is NULL, result is NULL
|
|
337
|
-
if (text === null || pattern === null) {
|
|
338
|
-
return null;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Convert both operands to strings and perform LIKE matching
|
|
342
|
-
const textStr = String(text);
|
|
343
|
-
const patternStr = String(pattern);
|
|
344
|
-
|
|
345
|
-
return simpleLike(patternStr, textStr);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const leftExpr = emitPlanNode(plan.left, ctx);
|
|
349
|
-
const rightExpr = emitPlanNode(plan.right, ctx);
|
|
350
|
-
|
|
351
|
-
return {
|
|
352
|
-
params: [leftExpr, rightExpr],
|
|
353
|
-
run: run as InstructionRun,
|
|
354
|
-
note: 'LIKE(like)'
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { BlockNode } from '../../planner/nodes/block.js';
|
|
2
|
-
import type { Instruction, RuntimeContext, InstructionRun } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import type { RuntimeValue, OutputValue } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
import { PlanNodeType } from '../../planner/nodes/plan-node-type.js';
|
|
7
|
-
|
|
8
|
-
export function emitBlock(plan: BlockNode, ctx: EmissionContext): Instruction {
|
|
9
|
-
// For blocks, our result is the last statement that is not a sink (void)
|
|
10
|
-
const valueIndex = plan.statements.findLastIndex(stmt => stmt.nodeType !== PlanNodeType.Sink);
|
|
11
|
-
|
|
12
|
-
async function run(ctx: RuntimeContext, ...args: RuntimeValue[]): Promise<OutputValue> {
|
|
13
|
-
return valueIndex === -1 ? null : args[valueIndex];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const statements = plan.statements.map(stmt => emitPlanNode(stmt, ctx));
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
params: statements,
|
|
20
|
-
run: run as InstructionRun,
|
|
21
|
-
note: `block(${plan.statements.length} stmts, result idx: ${valueIndex})`
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { CacheNode } from '../../planner/nodes/cache-node.js';
|
|
2
|
-
import type { Instruction, InstructionRun, RuntimeContext } from '../types.js';
|
|
3
|
-
import type { Row } from '../../common/types.js';
|
|
4
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
5
|
-
import { emitCallFromPlan } from '../emitters.js';
|
|
6
|
-
import { streamWithCache, createCacheState, type SharedCacheConfig } from '../cache/shared-cache.js';
|
|
7
|
-
import { buffered, traced } from '../async-util.js';
|
|
8
|
-
import { isDebugEnabled } from '../../util/environment.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Usage example for other emitters needing caching (NLJ inner caching, CTE materialization):
|
|
12
|
-
*
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { streamWithCache, createCacheState } from '../cache/shared-cache.js';
|
|
15
|
-
*
|
|
16
|
-
* // In your emitter:
|
|
17
|
-
* const cacheState = createCacheState();
|
|
18
|
-
* const config = { threshold: 10000, strategy: 'memory', name: 'NLJ-inner' };
|
|
19
|
-
*
|
|
20
|
-
* // In your run function:
|
|
21
|
-
* yield* streamWithCache(sourceIterable, config, cacheState);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Emits a smart cache instruction that materializes input on first iteration
|
|
27
|
-
* and serves subsequent iterations from cached results.
|
|
28
|
-
*
|
|
29
|
-
* Now uses the shared cache utility to avoid code duplication.
|
|
30
|
-
*/
|
|
31
|
-
export function emitCache(plan: CacheNode, ctx: EmissionContext): Instruction {
|
|
32
|
-
// Create cache state using shared utility
|
|
33
|
-
const cacheState = createCacheState();
|
|
34
|
-
const config: SharedCacheConfig = {
|
|
35
|
-
threshold: plan.threshold,
|
|
36
|
-
strategy: plan.strategy,
|
|
37
|
-
name: `CacheNode-${plan.id}`
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
async function* run(rctx: RuntimeContext, sourceCallback: (innerCtx: RuntimeContext) => AsyncIterable<Row>): AsyncIterable<Row> {
|
|
41
|
-
let sourceIterable = sourceCallback(rctx);
|
|
42
|
-
|
|
43
|
-
// Optional: Add buffering for large threshold caches to improve performance
|
|
44
|
-
if (plan.threshold > 50000) {
|
|
45
|
-
sourceIterable = buffered(sourceIterable, Math.min(plan.threshold / 10, 5000));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Optional: Add tracing in debug mode
|
|
49
|
-
if (isDebugEnabled('runtime:cache')) {
|
|
50
|
-
sourceIterable = traced(sourceIterable, `cache-${plan.id}`,
|
|
51
|
-
(row, index) => `row ${index}: [${row.length} columns]`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
yield* streamWithCache(sourceIterable, config, cacheState);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const sourceInstruction = emitCallFromPlan(plan.source, ctx);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
params: [sourceInstruction],
|
|
61
|
-
run: run as InstructionRun,
|
|
62
|
-
note: `cache(${plan.strategy}, threshold=${plan.threshold})`
|
|
63
|
-
};
|
|
64
|
-
}
|
package/src/runtime/emit/case.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { CaseExprNode } from '../../planner/nodes/scalar.js';
|
|
2
|
-
import type { Instruction, InstructionRun, RuntimeContext } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import { type SqlValue } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
import { compareSqlValues } from '../../util/comparison.js';
|
|
7
|
-
import { isTruthy } from '../../util/comparison.js';
|
|
8
|
-
|
|
9
|
-
export function emitCaseExpr(plan: CaseExprNode, ctx: EmissionContext): Instruction {
|
|
10
|
-
// Simple CASE: CASE base_expr WHEN value1 THEN result1 WHEN value2 THEN result2 ... END
|
|
11
|
-
async function runSimpleCase(
|
|
12
|
-
runtimeCtx: RuntimeContext,
|
|
13
|
-
...args: SqlValue[]
|
|
14
|
-
): Promise<SqlValue> {
|
|
15
|
-
let argIndex = 0;
|
|
16
|
-
const baseValue = args[argIndex++];
|
|
17
|
-
|
|
18
|
-
// Evaluate WHEN/THEN clauses
|
|
19
|
-
for (const _clause of plan.whenThenClauses) {
|
|
20
|
-
const whenValue = args[argIndex++];
|
|
21
|
-
const thenValue = args[argIndex++];
|
|
22
|
-
|
|
23
|
-
const conditionMet = baseValue !== null && whenValue !== null &&
|
|
24
|
-
compareSqlValues(baseValue as SqlValue, whenValue) === 0;
|
|
25
|
-
|
|
26
|
-
if (conditionMet) {
|
|
27
|
-
return thenValue;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// No WHEN clause matched, return ELSE value or NULL
|
|
32
|
-
if (plan.elseExpr) {
|
|
33
|
-
return args[argIndex]; // ELSE value
|
|
34
|
-
} else {
|
|
35
|
-
return null; // No ELSE clause, return NULL
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Searched CASE: CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... END
|
|
40
|
-
async function runSearchedCase(
|
|
41
|
-
runtimeCtx: RuntimeContext,
|
|
42
|
-
...args: SqlValue[]
|
|
43
|
-
): Promise<SqlValue> {
|
|
44
|
-
let argIndex = 0;
|
|
45
|
-
|
|
46
|
-
// Evaluate WHEN/THEN clauses
|
|
47
|
-
for (const _clause of plan.whenThenClauses) {
|
|
48
|
-
const whenValue = args[argIndex++];
|
|
49
|
-
const thenValue = args[argIndex++];
|
|
50
|
-
|
|
51
|
-
if (isTruthy(whenValue)) {
|
|
52
|
-
return thenValue;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// No WHEN clause matched, return ELSE value or NULL
|
|
57
|
-
if (plan.elseExpr) {
|
|
58
|
-
return args[argIndex]; // ELSE value
|
|
59
|
-
} else {
|
|
60
|
-
return null; // No ELSE clause, return NULL
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Emit instructions for all sub-expressions
|
|
65
|
-
const paramInstructions: Instruction[] = [];
|
|
66
|
-
|
|
67
|
-
if (plan.baseExpr) {
|
|
68
|
-
paramInstructions.push(emitPlanNode(plan.baseExpr, ctx));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// TODO: consider making all of these calls for short-circuiting
|
|
72
|
-
|
|
73
|
-
for (const clause of plan.whenThenClauses) {
|
|
74
|
-
paramInstructions.push(emitPlanNode(clause.when, ctx));
|
|
75
|
-
paramInstructions.push(emitPlanNode(clause.then, ctx));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (plan.elseExpr) {
|
|
79
|
-
paramInstructions.push(emitPlanNode(plan.elseExpr, ctx));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
params: paramInstructions,
|
|
84
|
-
run: (plan.baseExpr ? runSimpleCase : runSearchedCase) as InstructionRun,
|
|
85
|
-
note: `case(${plan.whenThenClauses.length} when clauses${plan.elseExpr ? ', else' : ''})`
|
|
86
|
-
};
|
|
87
|
-
}
|
package/src/runtime/emit/cast.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import type { CastNode } from '../../planner/nodes/scalar.js';
|
|
2
|
-
import type { Instruction, InstructionRun, RuntimeContext } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import { type SqlValue } from '../../common/types.js';
|
|
5
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
6
|
-
|
|
7
|
-
export function emitCast(plan: CastNode, ctx: EmissionContext): Instruction {
|
|
8
|
-
async function run(
|
|
9
|
-
runtimeCtx: RuntimeContext,
|
|
10
|
-
operandValue: SqlValue
|
|
11
|
-
): Promise<SqlValue> {
|
|
12
|
-
const targetType = plan.expression.targetType.toUpperCase();
|
|
13
|
-
|
|
14
|
-
// Handle NULL values - CAST(NULL AS anything) = NULL
|
|
15
|
-
if (operandValue === null) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Perform the cast based on target type
|
|
20
|
-
switch (targetType) {
|
|
21
|
-
case 'INTEGER':
|
|
22
|
-
case 'INT':
|
|
23
|
-
case 'TINYINT':
|
|
24
|
-
case 'SMALLINT':
|
|
25
|
-
case 'MEDIUMINT':
|
|
26
|
-
case 'BIGINT':
|
|
27
|
-
case 'UNSIGNED BIG INT':
|
|
28
|
-
case 'INT2':
|
|
29
|
-
case 'INT8':
|
|
30
|
-
return castToInteger(operandValue);
|
|
31
|
-
|
|
32
|
-
case 'REAL':
|
|
33
|
-
case 'DOUBLE':
|
|
34
|
-
case 'DOUBLE PRECISION':
|
|
35
|
-
case 'FLOAT':
|
|
36
|
-
return castToReal(operandValue);
|
|
37
|
-
|
|
38
|
-
case 'TEXT':
|
|
39
|
-
case 'CHARACTER':
|
|
40
|
-
case 'VARCHAR':
|
|
41
|
-
case 'VARYING CHARACTER':
|
|
42
|
-
case 'NCHAR':
|
|
43
|
-
case 'NATIVE CHARACTER':
|
|
44
|
-
case 'NVARCHAR':
|
|
45
|
-
case 'CLOB':
|
|
46
|
-
return castToText(operandValue);
|
|
47
|
-
|
|
48
|
-
case 'BLOB':
|
|
49
|
-
return castToBlob(operandValue);
|
|
50
|
-
|
|
51
|
-
case 'NUMERIC':
|
|
52
|
-
case 'DECIMAL':
|
|
53
|
-
case 'BOOLEAN':
|
|
54
|
-
case 'DATE':
|
|
55
|
-
case 'DATETIME':
|
|
56
|
-
return castToNumeric(operandValue);
|
|
57
|
-
|
|
58
|
-
default:
|
|
59
|
-
// For unknown types, return as-is (BLOB affinity)
|
|
60
|
-
return operandValue;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
params: [emitPlanNode(plan.operand, ctx)],
|
|
66
|
-
run: run as InstructionRun,
|
|
67
|
-
note: `cast(${plan.expression.targetType})`
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function castToInteger(value: SqlValue): SqlValue {
|
|
72
|
-
if (typeof value === 'number') {
|
|
73
|
-
return Math.trunc(value);
|
|
74
|
-
}
|
|
75
|
-
if (typeof value === 'bigint') {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
if (typeof value === 'string') {
|
|
79
|
-
const num = Number(value);
|
|
80
|
-
return isNaN(num) ? 0 : Math.trunc(num);
|
|
81
|
-
}
|
|
82
|
-
if (typeof value === 'boolean') {
|
|
83
|
-
return value ? 1 : 0;
|
|
84
|
-
}
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function castToReal(value: SqlValue): SqlValue {
|
|
89
|
-
if (typeof value === 'number') {
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
if (typeof value === 'bigint') {
|
|
93
|
-
return Number(value);
|
|
94
|
-
}
|
|
95
|
-
if (typeof value === 'string') {
|
|
96
|
-
const num = Number(value);
|
|
97
|
-
return isNaN(num) ? 0.0 : num;
|
|
98
|
-
}
|
|
99
|
-
if (typeof value === 'boolean') {
|
|
100
|
-
return value ? 1.0 : 0.0;
|
|
101
|
-
}
|
|
102
|
-
return 0.0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function castToText(value: SqlValue): SqlValue {
|
|
106
|
-
if (typeof value === 'string') {
|
|
107
|
-
return value;
|
|
108
|
-
}
|
|
109
|
-
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
110
|
-
return String(value);
|
|
111
|
-
}
|
|
112
|
-
if (typeof value === 'boolean') {
|
|
113
|
-
return value ? '1' : '0';
|
|
114
|
-
}
|
|
115
|
-
if (value instanceof Uint8Array) {
|
|
116
|
-
// Convert blob to hex string
|
|
117
|
-
return Array.from(value, byte => byte.toString(16).padStart(2, '0')).join('').toUpperCase();
|
|
118
|
-
}
|
|
119
|
-
return String(value);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function castToBlob(value: SqlValue): SqlValue {
|
|
123
|
-
if (value instanceof Uint8Array) {
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
if (typeof value === 'string') {
|
|
127
|
-
// Convert string to UTF-8 bytes
|
|
128
|
-
return new TextEncoder().encode(value);
|
|
129
|
-
}
|
|
130
|
-
// For other types, convert to string first then to bytes
|
|
131
|
-
return new TextEncoder().encode(String(value));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function castToNumeric(value: SqlValue): SqlValue {
|
|
135
|
-
// NUMERIC affinity: prefer integer if possible, otherwise real
|
|
136
|
-
if (typeof value === 'number') {
|
|
137
|
-
return Number.isInteger(value) ? Math.trunc(value) : value;
|
|
138
|
-
}
|
|
139
|
-
if (typeof value === 'bigint') {
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
if (typeof value === 'string') {
|
|
143
|
-
const num = Number(value);
|
|
144
|
-
if (isNaN(num)) return 0;
|
|
145
|
-
return Number.isInteger(num) ? Math.trunc(num) : num;
|
|
146
|
-
}
|
|
147
|
-
if (typeof value === 'boolean') {
|
|
148
|
-
return value ? 1 : 0;
|
|
149
|
-
}
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CollateNode } from '../../planner/nodes/scalar.js';
|
|
2
|
-
import type { Instruction } from '../types.js';
|
|
3
|
-
import { emitPlanNode } from '../emitters.js';
|
|
4
|
-
import type { EmissionContext } from '../emission-context.js';
|
|
5
|
-
|
|
6
|
-
export function emitCollate(plan: CollateNode, ctx: EmissionContext): Instruction {
|
|
7
|
-
// No runtime effect
|
|
8
|
-
return emitPlanNode(plan.operand, ctx);
|
|
9
|
-
}
|