@quereus/quereus 0.7.2 → 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,772 +0,0 @@
|
|
|
1
|
-
import type { ScalarType } from "../../common/datatype.js";
|
|
2
|
-
import { OutputValue, SqlDataType } from "../../common/types.js";
|
|
3
|
-
import { PlanNode, type ScalarPlanNode, type UnaryScalarNode, type NaryScalarNode, type ZeroAryScalarNode, type BinaryScalarNode, PhysicalProperties, type ConstantNode, type TernaryScalarNode } from "./plan-node.js";
|
|
4
|
-
import type * as AST from "../../parser/ast.js";
|
|
5
|
-
import type { Scope } from "../scopes/scope.js";
|
|
6
|
-
import { PlanNodeType } from "./plan-node-type.js";
|
|
7
|
-
import { Cached } from "../../util/cached.js";
|
|
8
|
-
import { formatExpression, formatScalarType } from "../../util/plan-formatter.js";
|
|
9
|
-
import { quereusError } from '../../common/errors.js';
|
|
10
|
-
import { StatusCode } from '../../common/types.js';
|
|
11
|
-
import { NULL_TYPE, INTEGER_TYPE, REAL_TYPE, TEXT_TYPE, BLOB_TYPE, BOOLEAN_TYPE } from "../../types/builtin-types.js";
|
|
12
|
-
import { typeRegistry } from "../../types/registry.js";
|
|
13
|
-
|
|
14
|
-
export class UnaryOpNode extends PlanNode implements UnaryScalarNode {
|
|
15
|
-
readonly nodeType = PlanNodeType.UnaryOp;
|
|
16
|
-
private cachedType: Cached<ScalarType>;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
public readonly scope: Scope,
|
|
20
|
-
public readonly expression: AST.UnaryExpr,
|
|
21
|
-
public readonly operand: ScalarPlanNode,
|
|
22
|
-
) {
|
|
23
|
-
super(scope);
|
|
24
|
-
this.cachedType = new Cached(this.generateType);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
generateType = (): ScalarType => {
|
|
28
|
-
const operandType = this.operand.getType();
|
|
29
|
-
|
|
30
|
-
let logicalType = operandType.logicalType;
|
|
31
|
-
let nullable = operandType.nullable;
|
|
32
|
-
|
|
33
|
-
switch (this.expression.operator) {
|
|
34
|
-
case 'NOT':
|
|
35
|
-
case 'IS NULL':
|
|
36
|
-
case 'IS NOT NULL':
|
|
37
|
-
logicalType = BOOLEAN_TYPE;
|
|
38
|
-
nullable = false; // Boolean results are never null
|
|
39
|
-
break;
|
|
40
|
-
case '-':
|
|
41
|
-
case '+':
|
|
42
|
-
// Numeric unary operators preserve type
|
|
43
|
-
break;
|
|
44
|
-
case '~':
|
|
45
|
-
// Bitwise NOT - results in integer
|
|
46
|
-
logicalType = INTEGER_TYPE;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
typeClass: 'scalar',
|
|
52
|
-
logicalType,
|
|
53
|
-
nullable,
|
|
54
|
-
isReadOnly: operandType.isReadOnly,
|
|
55
|
-
collationName: operandType.collationName,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getType(): ScalarType {
|
|
60
|
-
return this.cachedType.value;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getChildren(): readonly [ScalarPlanNode] {
|
|
64
|
-
return [this.operand];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
getRelations(): readonly [] {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
72
|
-
if (newChildren.length !== 1) {
|
|
73
|
-
quereusError(`UnaryOpNode expects 1 child, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const [newOperand] = newChildren;
|
|
77
|
-
|
|
78
|
-
// Type check
|
|
79
|
-
if (!('expression' in newOperand)) {
|
|
80
|
-
quereusError('UnaryOpNode: child must be a ScalarPlanNode', StatusCode.INTERNAL);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Return same instance if nothing changed
|
|
84
|
-
if (newOperand === this.operand) {
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Create new instance
|
|
89
|
-
return new UnaryOpNode(
|
|
90
|
-
this.scope,
|
|
91
|
-
this.expression,
|
|
92
|
-
newOperand as ScalarPlanNode
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
override toString(): string {
|
|
97
|
-
return `${this.expression.operator} ${formatExpression(this.operand)}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
101
|
-
return {
|
|
102
|
-
operator: this.expression.operator,
|
|
103
|
-
operand: formatExpression(this.operand),
|
|
104
|
-
resultType: formatScalarType(this.getType())
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export class BinaryOpNode extends PlanNode implements BinaryScalarNode {
|
|
112
|
-
readonly nodeType = PlanNodeType.BinaryOp;
|
|
113
|
-
private cachedType: Cached<ScalarType>;
|
|
114
|
-
|
|
115
|
-
constructor(
|
|
116
|
-
public readonly scope: Scope,
|
|
117
|
-
public readonly expression: AST.BinaryExpr,
|
|
118
|
-
public readonly left: ScalarPlanNode,
|
|
119
|
-
public readonly right: ScalarPlanNode,
|
|
120
|
-
) {
|
|
121
|
-
super(scope);
|
|
122
|
-
|
|
123
|
-
this.cachedType = new Cached(this.generateType);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
generateType = (): ScalarType => {
|
|
127
|
-
const leftType = this.left.getType();
|
|
128
|
-
const rightType = this.right.getType();
|
|
129
|
-
|
|
130
|
-
let logicalType = leftType.logicalType;
|
|
131
|
-
|
|
132
|
-
switch (this.expression.operator) {
|
|
133
|
-
case 'OR':
|
|
134
|
-
case 'AND':
|
|
135
|
-
case '=':
|
|
136
|
-
case '!=':
|
|
137
|
-
case '<':
|
|
138
|
-
case '<=':
|
|
139
|
-
case '>':
|
|
140
|
-
case '>=':
|
|
141
|
-
case 'IS':
|
|
142
|
-
case 'IS NOT':
|
|
143
|
-
case 'IN':
|
|
144
|
-
// Comparison and logical operators return boolean
|
|
145
|
-
logicalType = BOOLEAN_TYPE;
|
|
146
|
-
break;
|
|
147
|
-
case '+':
|
|
148
|
-
case '-':
|
|
149
|
-
case '*':
|
|
150
|
-
case '/':
|
|
151
|
-
case '%':
|
|
152
|
-
// Arithmetic operators - implement numeric type promotion
|
|
153
|
-
// Rules: INTEGER + INTEGER -> INTEGER, INTEGER + REAL -> REAL, REAL + REAL -> REAL
|
|
154
|
-
if (leftType.logicalType.isNumeric && rightType.logicalType.isNumeric) {
|
|
155
|
-
// Both operands are numeric
|
|
156
|
-
if (leftType.logicalType.name === 'REAL' || rightType.logicalType.name === 'REAL') {
|
|
157
|
-
// If either is REAL, result is REAL
|
|
158
|
-
logicalType = REAL_TYPE;
|
|
159
|
-
} else {
|
|
160
|
-
// Both are INTEGER, result is INTEGER
|
|
161
|
-
logicalType = INTEGER_TYPE;
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
// Non-numeric operands - use left operand type (fallback)
|
|
165
|
-
logicalType = leftType.logicalType;
|
|
166
|
-
}
|
|
167
|
-
break;
|
|
168
|
-
case '||':
|
|
169
|
-
// String concatenation
|
|
170
|
-
logicalType = TEXT_TYPE;
|
|
171
|
-
break;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// TODO: Handle collation conflict
|
|
175
|
-
const collationName = leftType.collationName || rightType.collationName;
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
typeClass: 'scalar',
|
|
179
|
-
logicalType,
|
|
180
|
-
nullable: leftType.nullable || rightType.nullable,
|
|
181
|
-
isReadOnly: leftType.isReadOnly || rightType.isReadOnly,
|
|
182
|
-
collationName,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
getType(): ScalarType {
|
|
187
|
-
return this.cachedType.value;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
getChildren(): readonly [ScalarPlanNode, ScalarPlanNode] {
|
|
191
|
-
return [this.left, this.right];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
getRelations(): readonly [] {
|
|
195
|
-
return [];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
199
|
-
if (newChildren.length !== 2) {
|
|
200
|
-
quereusError(`BinaryOpNode expects 2 children, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const [newLeft, newRight] = newChildren;
|
|
204
|
-
|
|
205
|
-
// Type check
|
|
206
|
-
if (!('expression' in newLeft) || !('expression' in newRight)) {
|
|
207
|
-
quereusError('BinaryOpNode: children must be ScalarPlanNodes', StatusCode.INTERNAL);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Return same instance if nothing changed
|
|
211
|
-
if (newLeft === this.left && newRight === this.right) {
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Create new instance
|
|
216
|
-
return new BinaryOpNode(
|
|
217
|
-
this.scope,
|
|
218
|
-
this.expression,
|
|
219
|
-
newLeft as ScalarPlanNode,
|
|
220
|
-
newRight as ScalarPlanNode
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
override toString(): string {
|
|
225
|
-
return `${formatExpression(this.left)} ${this.expression.operator} ${formatExpression(this.right)}`;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
229
|
-
return {
|
|
230
|
-
operator: this.expression.operator,
|
|
231
|
-
left: formatExpression(this.left),
|
|
232
|
-
right: formatExpression(this.right),
|
|
233
|
-
resultType: formatScalarType(this.getType())
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export class LiteralNode extends PlanNode implements ZeroAryScalarNode, ConstantNode {
|
|
241
|
-
readonly nodeType = PlanNodeType.Literal;
|
|
242
|
-
/**
|
|
243
|
-
* When constant folding replaces an expression with a literal, we still need to
|
|
244
|
-
* preserve the *type metadata* (affinity, collation, nullability, etc.).
|
|
245
|
-
*
|
|
246
|
-
* The optional `explicitType` allows the caller to override the
|
|
247
|
-
* automatically-derived type so that information (e.g. COLLATE NOCASE)
|
|
248
|
-
* survives the folding pass.
|
|
249
|
-
*/
|
|
250
|
-
constructor(
|
|
251
|
-
public readonly scope: Scope,
|
|
252
|
-
public readonly expression: AST.LiteralExpr,
|
|
253
|
-
private readonly explicitType?: ScalarType,
|
|
254
|
-
) {
|
|
255
|
-
super(scope, 0.001); // Minimal cost
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
getType(): ScalarType {
|
|
259
|
-
// If a caller supplied an explicit type (to preserve metadata such as
|
|
260
|
-
// collation) honour it verbatim.
|
|
261
|
-
if (this.explicitType) {
|
|
262
|
-
return this.explicitType;
|
|
263
|
-
}
|
|
264
|
-
const value = this.expression.value;
|
|
265
|
-
if (value === null) {
|
|
266
|
-
return {
|
|
267
|
-
typeClass: 'scalar',
|
|
268
|
-
logicalType: NULL_TYPE,
|
|
269
|
-
nullable: true,
|
|
270
|
-
isReadOnly: true,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
if (typeof value === 'number') {
|
|
274
|
-
return {
|
|
275
|
-
typeClass: 'scalar',
|
|
276
|
-
logicalType: REAL_TYPE,
|
|
277
|
-
nullable: false,
|
|
278
|
-
isReadOnly: true,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
if (typeof value === 'bigint') {
|
|
282
|
-
return {
|
|
283
|
-
typeClass: 'scalar',
|
|
284
|
-
logicalType: INTEGER_TYPE,
|
|
285
|
-
nullable: false,
|
|
286
|
-
isReadOnly: true,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
if (typeof value === 'string') {
|
|
290
|
-
return {
|
|
291
|
-
typeClass: 'scalar',
|
|
292
|
-
logicalType: TEXT_TYPE,
|
|
293
|
-
nullable: false,
|
|
294
|
-
isReadOnly: true,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
if (typeof value === 'boolean') {
|
|
298
|
-
return {
|
|
299
|
-
typeClass: 'scalar',
|
|
300
|
-
logicalType: BOOLEAN_TYPE,
|
|
301
|
-
nullable: false,
|
|
302
|
-
isReadOnly: true,
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
if (value instanceof Uint8Array) {
|
|
306
|
-
return {
|
|
307
|
-
typeClass: 'scalar',
|
|
308
|
-
logicalType: BLOB_TYPE,
|
|
309
|
-
nullable: false,
|
|
310
|
-
isReadOnly: true,
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
quereusError(`Unknown literal type ${typeof value}`, StatusCode.INTERNAL);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
getValue(): OutputValue {
|
|
317
|
-
return this.expression.value;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
getChildren(): readonly [] {
|
|
321
|
-
return [];
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
getRelations(): readonly [] {
|
|
325
|
-
return [];
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
329
|
-
if (newChildren.length !== 0) {
|
|
330
|
-
quereusError(`LiteralNode expects 0 children, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
331
|
-
}
|
|
332
|
-
return this; // No children, so no change
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
override toString(): string {
|
|
336
|
-
const value = this.expression.value;
|
|
337
|
-
if (value === null) return 'NULL';
|
|
338
|
-
if (typeof value === 'string') return `'${value}'`;
|
|
339
|
-
if (value instanceof Uint8Array) return `X'${Array.from(value, b => b.toString(16).padStart(2, '0')).join('')}'`;
|
|
340
|
-
return String(value);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
344
|
-
return {
|
|
345
|
-
value: this.expression.value,
|
|
346
|
-
resultType: formatScalarType(this.getType())
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
override computePhysical(): Partial<PhysicalProperties> {
|
|
351
|
-
return {
|
|
352
|
-
constant: true,
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export class CaseExprNode extends PlanNode implements NaryScalarNode {
|
|
358
|
-
readonly nodeType = PlanNodeType.CaseExpr;
|
|
359
|
-
private cachedType: Cached<ScalarType>;
|
|
360
|
-
|
|
361
|
-
constructor(
|
|
362
|
-
public readonly scope: Scope,
|
|
363
|
-
public readonly expression: AST.CaseExpr,
|
|
364
|
-
public readonly baseExpr: ScalarPlanNode | undefined,
|
|
365
|
-
public readonly whenThenClauses: { when: ScalarPlanNode; then: ScalarPlanNode }[],
|
|
366
|
-
public readonly elseExpr: ScalarPlanNode | undefined,
|
|
367
|
-
) {
|
|
368
|
-
super(scope, 0.02 * whenThenClauses.length);
|
|
369
|
-
this.cachedType = new Cached(this.generateType);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
getType(): ScalarType {
|
|
373
|
-
return this.cachedType.value;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
generateType = (): ScalarType => {
|
|
377
|
-
// Determine the result type based on all THEN expressions and the ELSE expression
|
|
378
|
-
const resultExpressions = [
|
|
379
|
-
...this.whenThenClauses.map(clause => clause.then),
|
|
380
|
-
...(this.elseExpr ? [this.elseExpr] : [])
|
|
381
|
-
];
|
|
382
|
-
|
|
383
|
-
if (resultExpressions.length === 0) {
|
|
384
|
-
// No THEN clauses and no ELSE - should not happen in valid SQL
|
|
385
|
-
return {
|
|
386
|
-
typeClass: 'scalar',
|
|
387
|
-
logicalType: NULL_TYPE,
|
|
388
|
-
nullable: true,
|
|
389
|
-
isReadOnly: true,
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Use the first result expression as the base type
|
|
394
|
-
const firstType = resultExpressions[0].getType();
|
|
395
|
-
let logicalType = firstType.logicalType;
|
|
396
|
-
let nullable = firstType.nullable;
|
|
397
|
-
let isReadOnly = firstType.isReadOnly;
|
|
398
|
-
let collationName = firstType.collationName;
|
|
399
|
-
|
|
400
|
-
// Check all other result expressions for type compatibility
|
|
401
|
-
for (let i = 1; i < resultExpressions.length; i++) {
|
|
402
|
-
const exprType = resultExpressions[i].getType();
|
|
403
|
-
|
|
404
|
-
// If any result can be null, the whole CASE can be null
|
|
405
|
-
if (exprType.nullable) {
|
|
406
|
-
nullable = true;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// If any result is read-only, consider the whole CASE read-only
|
|
410
|
-
if (exprType.isReadOnly) {
|
|
411
|
-
isReadOnly = true;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Handle collation conflicts - for now, use the first non-null collation
|
|
415
|
-
if (!collationName && exprType.collationName) {
|
|
416
|
-
collationName = exprType.collationName;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// TODO: Implement proper type coercion rules for SQL
|
|
420
|
-
// For now, if types differ, default to TEXT
|
|
421
|
-
if (exprType.logicalType !== logicalType) {
|
|
422
|
-
logicalType = TEXT_TYPE;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// If there's no ELSE clause, the result can be NULL
|
|
427
|
-
if (!this.elseExpr) {
|
|
428
|
-
nullable = true;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return {
|
|
432
|
-
typeClass: 'scalar',
|
|
433
|
-
logicalType,
|
|
434
|
-
nullable,
|
|
435
|
-
isReadOnly,
|
|
436
|
-
collationName,
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
get operands(): readonly ScalarPlanNode[] {
|
|
441
|
-
const allOperands: ScalarPlanNode[] = [];
|
|
442
|
-
|
|
443
|
-
if (this.baseExpr) {
|
|
444
|
-
allOperands.push(this.baseExpr);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
for (const clause of this.whenThenClauses) {
|
|
448
|
-
allOperands.push(clause.when, clause.then);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (this.elseExpr) {
|
|
452
|
-
allOperands.push(this.elseExpr);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return allOperands;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
getChildren(): readonly ScalarPlanNode[] {
|
|
459
|
-
return this.operands;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
getRelations(): readonly [] {
|
|
463
|
-
return [];
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
467
|
-
const expectedLength = this.operands.length;
|
|
468
|
-
if (newChildren.length !== expectedLength) {
|
|
469
|
-
quereusError(`CaseExprNode expects ${expectedLength} children, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Type check
|
|
473
|
-
for (const child of newChildren) {
|
|
474
|
-
if (!('expression' in child)) {
|
|
475
|
-
quereusError('CaseExprNode: all children must be ScalarPlanNodes', StatusCode.INTERNAL);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Check if anything changed
|
|
480
|
-
const childrenChanged = newChildren.some((child, i) => child !== this.operands[i]);
|
|
481
|
-
if (!childrenChanged) {
|
|
482
|
-
return this;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Rebuild the complex structure
|
|
486
|
-
let childIndex = 0;
|
|
487
|
-
let newBaseExpr: ScalarPlanNode | undefined = undefined;
|
|
488
|
-
|
|
489
|
-
if (this.baseExpr) {
|
|
490
|
-
newBaseExpr = newChildren[childIndex] as ScalarPlanNode;
|
|
491
|
-
childIndex++;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
const newWhenThenClauses: { when: ScalarPlanNode; then: ScalarPlanNode }[] = [];
|
|
495
|
-
for (let i = 0; i < this.whenThenClauses.length; i++) {
|
|
496
|
-
const when = newChildren[childIndex] as ScalarPlanNode;
|
|
497
|
-
const then = newChildren[childIndex + 1] as ScalarPlanNode;
|
|
498
|
-
newWhenThenClauses.push({ when, then });
|
|
499
|
-
childIndex += 2;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
let newElseExpr: ScalarPlanNode | undefined = undefined;
|
|
503
|
-
if (this.elseExpr) {
|
|
504
|
-
newElseExpr = newChildren[childIndex] as ScalarPlanNode;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Create new instance
|
|
508
|
-
return new CaseExprNode(
|
|
509
|
-
this.scope,
|
|
510
|
-
this.expression,
|
|
511
|
-
newBaseExpr,
|
|
512
|
-
newWhenThenClauses,
|
|
513
|
-
newElseExpr
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
override toString(): string {
|
|
518
|
-
const baseStr = this.baseExpr ? ` ${formatExpression(this.baseExpr)}` : '';
|
|
519
|
-
const whenThenStr = this.whenThenClauses
|
|
520
|
-
.map(clause => ` WHEN ${formatExpression(clause.when)} THEN ${formatExpression(clause.then)}`)
|
|
521
|
-
.join('');
|
|
522
|
-
const elseStr = this.elseExpr ? ` ELSE ${formatExpression(this.elseExpr)}` : '';
|
|
523
|
-
return `CASE${baseStr}${whenThenStr}${elseStr} END`;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
527
|
-
const props: Record<string, unknown> = {
|
|
528
|
-
resultType: formatScalarType(this.getType()),
|
|
529
|
-
whenThenClauses: this.whenThenClauses.map(clause => ({
|
|
530
|
-
when: formatExpression(clause.when),
|
|
531
|
-
then: formatExpression(clause.then)
|
|
532
|
-
}))
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
if (this.baseExpr) {
|
|
536
|
-
props.baseExpression = formatExpression(this.baseExpr);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (this.elseExpr) {
|
|
540
|
-
props.elseExpression = formatExpression(this.elseExpr);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return props;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
export class CastNode extends PlanNode implements UnaryScalarNode {
|
|
548
|
-
readonly nodeType = PlanNodeType.Cast;
|
|
549
|
-
private cachedType: Cached<ScalarType>;
|
|
550
|
-
|
|
551
|
-
constructor(
|
|
552
|
-
public readonly scope: Scope,
|
|
553
|
-
public readonly expression: AST.CastExpr,
|
|
554
|
-
public readonly operand: ScalarPlanNode,
|
|
555
|
-
) {
|
|
556
|
-
super(scope, 0.02); // Slightly higher cost for type conversion
|
|
557
|
-
this.cachedType = new Cached(this.generateType);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
getType(): ScalarType {
|
|
561
|
-
return this.cachedType.value;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
generateType = (): ScalarType => {
|
|
565
|
-
const operandType = this.operand.getType();
|
|
566
|
-
const targetType = this.expression.targetType;
|
|
567
|
-
|
|
568
|
-
// Look up the logical type from the type registry
|
|
569
|
-
const logicalType = typeRegistry.getTypeOrDefault(targetType);
|
|
570
|
-
|
|
571
|
-
return {
|
|
572
|
-
typeClass: 'scalar',
|
|
573
|
-
logicalType,
|
|
574
|
-
nullable: operandType.nullable, // CAST preserves nullability
|
|
575
|
-
isReadOnly: operandType.isReadOnly,
|
|
576
|
-
collationName: logicalType.isTextual ? operandType.collationName : undefined,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
getChildren(): readonly [ScalarPlanNode] {
|
|
581
|
-
return [this.operand];
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
getRelations(): readonly [] {
|
|
585
|
-
return [];
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
589
|
-
if (newChildren.length !== 1) {
|
|
590
|
-
quereusError(`CastNode expects 1 child, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
const [newOperand] = newChildren;
|
|
594
|
-
|
|
595
|
-
// Type check
|
|
596
|
-
if (!('expression' in newOperand)) {
|
|
597
|
-
quereusError('CastNode: child must be a ScalarPlanNode', StatusCode.INTERNAL);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// Return same instance if nothing changed
|
|
601
|
-
if (newOperand === this.operand) {
|
|
602
|
-
return this;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// Create new instance
|
|
606
|
-
return new CastNode(
|
|
607
|
-
this.scope,
|
|
608
|
-
this.expression,
|
|
609
|
-
newOperand as ScalarPlanNode
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
override toString(): string {
|
|
614
|
-
return `CAST(${formatExpression(this.operand)} AS ${this.expression.targetType})`;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
618
|
-
return {
|
|
619
|
-
operand: formatExpression(this.operand),
|
|
620
|
-
targetType: this.expression.targetType,
|
|
621
|
-
resultType: formatScalarType(this.getType())
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
export class CollateNode extends PlanNode implements UnaryScalarNode {
|
|
627
|
-
readonly nodeType = PlanNodeType.Collate;
|
|
628
|
-
private cachedType: Cached<ScalarType>;
|
|
629
|
-
|
|
630
|
-
constructor(
|
|
631
|
-
public readonly scope: Scope,
|
|
632
|
-
public readonly expression: AST.CollateExpr,
|
|
633
|
-
public readonly operand: ScalarPlanNode,
|
|
634
|
-
) {
|
|
635
|
-
super(scope, 0.001); // Minimal cost for COLLATE
|
|
636
|
-
this.cachedType = new Cached(this.generateType);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
getType(): ScalarType {
|
|
640
|
-
return this.cachedType.value;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
generateType = (): ScalarType => {
|
|
644
|
-
const operandType = this.operand.getType();
|
|
645
|
-
|
|
646
|
-
return {
|
|
647
|
-
...operandType,
|
|
648
|
-
collationName: this.expression.collation.toUpperCase()
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
getChildren(): readonly [ScalarPlanNode] {
|
|
653
|
-
return [this.operand];
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
getRelations(): readonly [] {
|
|
657
|
-
return [];
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
661
|
-
if (newChildren.length !== 1) {
|
|
662
|
-
quereusError(`CollateNode expects 1 child, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const [newOperand] = newChildren;
|
|
666
|
-
|
|
667
|
-
// Type check
|
|
668
|
-
if (!('expression' in newOperand)) {
|
|
669
|
-
quereusError('CollateNode: child must be a ScalarPlanNode', StatusCode.INTERNAL);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// Return same instance if nothing changed
|
|
673
|
-
if (newOperand === this.operand) {
|
|
674
|
-
return this;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// Create new instance
|
|
678
|
-
return new CollateNode(
|
|
679
|
-
this.scope,
|
|
680
|
-
this.expression,
|
|
681
|
-
newOperand as ScalarPlanNode
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
override toString(): string {
|
|
686
|
-
return `${formatExpression(this.operand)} COLLATE ${this.expression.collation}`;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
690
|
-
return {
|
|
691
|
-
operand: formatExpression(this.operand),
|
|
692
|
-
collation: this.expression.collation,
|
|
693
|
-
resultType: formatScalarType(this.getType())
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
export class BetweenNode extends PlanNode implements TernaryScalarNode {
|
|
699
|
-
readonly nodeType = PlanNodeType.Between;
|
|
700
|
-
|
|
701
|
-
constructor(
|
|
702
|
-
public readonly scope: Scope,
|
|
703
|
-
public readonly expression: AST.BetweenExpr,
|
|
704
|
-
public readonly expr: ScalarPlanNode,
|
|
705
|
-
public readonly lower: ScalarPlanNode,
|
|
706
|
-
public readonly upper: ScalarPlanNode,
|
|
707
|
-
) {
|
|
708
|
-
super(scope, 0.03); // Cost for three comparisons
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
getType(): ScalarType {
|
|
712
|
-
// BETWEEN always returns BOOLEAN
|
|
713
|
-
return {
|
|
714
|
-
typeClass: 'scalar',
|
|
715
|
-
logicalType: BOOLEAN_TYPE,
|
|
716
|
-
nullable: false,
|
|
717
|
-
isReadOnly: true,
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
getChildren(): readonly [ScalarPlanNode, ScalarPlanNode, ScalarPlanNode] {
|
|
722
|
-
return [this.expr, this.lower, this.upper];
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
getRelations(): readonly [] {
|
|
726
|
-
return [];
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
730
|
-
if (newChildren.length !== 3) {
|
|
731
|
-
quereusError(`BetweenNode expects 3 children, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
const [newExpr, newLower, newUpper] = newChildren;
|
|
735
|
-
|
|
736
|
-
// Type check
|
|
737
|
-
for (const child of newChildren) {
|
|
738
|
-
if (!('expression' in child)) {
|
|
739
|
-
quereusError('BetweenNode: all children must be ScalarPlanNodes', StatusCode.INTERNAL);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// Return same instance if nothing changed
|
|
744
|
-
if (newExpr === this.expr && newLower === this.lower && newUpper === this.upper) {
|
|
745
|
-
return this;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
// Create new instance
|
|
749
|
-
return new BetweenNode(
|
|
750
|
-
this.scope,
|
|
751
|
-
this.expression,
|
|
752
|
-
newExpr as ScalarPlanNode,
|
|
753
|
-
newLower as ScalarPlanNode,
|
|
754
|
-
newUpper as ScalarPlanNode
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
override toString(): string {
|
|
759
|
-
const notPrefix = this.expression.not ? 'NOT ' : '';
|
|
760
|
-
return `${formatExpression(this.expr)} ${notPrefix}BETWEEN ${formatExpression(this.lower)} AND ${formatExpression(this.upper)}`;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
764
|
-
return {
|
|
765
|
-
expr: formatExpression(this.expr),
|
|
766
|
-
lower: formatExpression(this.lower),
|
|
767
|
-
upper: formatExpression(this.upper),
|
|
768
|
-
not: this.expression.not ?? false,
|
|
769
|
-
resultType: formatScalarType(this.getType())
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
}
|