@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
package/src/planner/resolve.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Ambiguous, type Scope } from "./scopes/scope.js";
|
|
2
|
-
import * as AST from "../parser/ast.js";
|
|
3
|
-
import { ColumnReferenceNode, FunctionReferenceNode, ParameterReferenceNode, TableReferenceNode } from "./nodes/reference.js";
|
|
4
|
-
import { QuereusError } from "../common/errors.js";
|
|
5
|
-
import { StatusCode } from "../common/types.js";
|
|
6
|
-
import { isScalarNode, type ScalarPlanNode } from "./nodes/plan-node.js";
|
|
7
|
-
|
|
8
|
-
export function resolveTable(scope: Scope, exp: AST.IdentifierExpr, selectedSchema: string = 'main'): TableReferenceNode | typeof Ambiguous | undefined {
|
|
9
|
-
// table: [schema.]name
|
|
10
|
-
const idName = exp.name;
|
|
11
|
-
const idSchema = exp.schema;
|
|
12
|
-
const symbolKey = idSchema ? `${idSchema}.${idName}` : `${selectedSchema}.${idName}`;
|
|
13
|
-
|
|
14
|
-
const result = scope.resolveSymbol(symbolKey, exp);
|
|
15
|
-
if (result === Ambiguous || result instanceof TableReferenceNode) {
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
throw new QuereusError(`${symbolKey} isn't a table`, StatusCode.ERROR);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// TODO: pragma resolution
|
|
22
|
-
// export function resolveSchema(scope: Scope, exp: AST.IdentifierExpr): PragmaReferenceNode | typeof Ambiguous | undefined {
|
|
23
|
-
// // pragma: name
|
|
24
|
-
// const idName = exp.name.toLowerCase();
|
|
25
|
-
// const result = scope.resolveSymbol(idName);
|
|
26
|
-
// if (result === Ambiguous || result instanceof PragmaReferenceNode) {
|
|
27
|
-
// return result;
|
|
28
|
-
// }
|
|
29
|
-
// throw new QuereusError(`${idName} isn't a pragma`, StatusCode.ERROR);
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
export function resolveColumn(scope: Scope, exp: AST.ColumnExpr, selectedSchema: string = 'main'): ScalarPlanNode | typeof Ambiguous | undefined {
|
|
33
|
-
const schemaQualifier = exp.schema;
|
|
34
|
-
const tableQualifier = exp.table;
|
|
35
|
-
const columnName = exp.name;
|
|
36
|
-
|
|
37
|
-
if (tableQualifier) {
|
|
38
|
-
if (schemaQualifier) {
|
|
39
|
-
// Fully qualified: schema.table.column
|
|
40
|
-
const symbolKey = `${schemaQualifier}.${tableQualifier}.${columnName}`;
|
|
41
|
-
const result = scope.resolveSymbol(symbolKey, exp);
|
|
42
|
-
if (result === Ambiguous || (result && isScalarNode(result))) {
|
|
43
|
-
return result as ScalarPlanNode | typeof Ambiguous;
|
|
44
|
-
}
|
|
45
|
-
throw new QuereusError(`${symbolKey} isn't a column`, StatusCode.ERROR);
|
|
46
|
-
} else {
|
|
47
|
-
// Table qualified: table.column
|
|
48
|
-
// Try without schema first, then with schema if that fails
|
|
49
|
-
const unqualifiedKey = `${tableQualifier}.${columnName}`;
|
|
50
|
-
const result = scope.resolveSymbol(unqualifiedKey, exp);
|
|
51
|
-
if (result === Ambiguous || (result && isScalarNode(result))) {
|
|
52
|
-
return result as ScalarPlanNode | typeof Ambiguous;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// If unqualified fails, try with the selected schema
|
|
56
|
-
const qualifiedKey = `${selectedSchema}.${tableQualifier}.${columnName}`;
|
|
57
|
-
const qualifiedResult = scope.resolveSymbol(qualifiedKey, exp);
|
|
58
|
-
if (qualifiedResult === Ambiguous || (qualifiedResult && isScalarNode(qualifiedResult))) {
|
|
59
|
-
return qualifiedResult as ScalarPlanNode | typeof Ambiguous;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new QuereusError(`${unqualifiedKey} isn't a column`, StatusCode.ERROR);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
// Unqualified: column
|
|
66
|
-
const result = scope.resolveSymbol(columnName, exp);
|
|
67
|
-
if (result === Ambiguous || (result && isScalarNode(result))) {
|
|
68
|
-
return result as ScalarPlanNode | typeof Ambiguous;
|
|
69
|
-
}
|
|
70
|
-
throw new QuereusError(`Column not found: ${columnName}`, StatusCode.ERROR);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function resolveParameter(scope: Scope, exp: AST.ParameterExpr): ParameterReferenceNode | typeof Ambiguous | undefined {
|
|
75
|
-
// For anonymous parameters (?), use '?' as the symbolKey
|
|
76
|
-
// For named parameters (:name), use ':name' as the symbolKey
|
|
77
|
-
const symbolKey = exp.name ? `:${exp.name}` : '?';
|
|
78
|
-
const result = scope.resolveSymbol(symbolKey, exp);
|
|
79
|
-
if (result === Ambiguous || result instanceof ParameterReferenceNode) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
throw new QuereusError(`${symbolKey} isn't a parameter`, StatusCode.ERROR);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function resolveFunction(scope: Scope, exp: AST.FunctionExpr): FunctionReferenceNode | typeof Ambiguous | undefined {
|
|
86
|
-
// First try exact argument count
|
|
87
|
-
const symbolKey = exp.name.toLowerCase() + '/' + exp.args.length;
|
|
88
|
-
let result = scope.resolveSymbol(symbolKey, exp);
|
|
89
|
-
if (result === Ambiguous || result instanceof FunctionReferenceNode) {
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// If exact match not found, try variable argument function (numArgs = -1)
|
|
94
|
-
const varArgSymbolKey = exp.name.toLowerCase() + '/-1';
|
|
95
|
-
result = scope.resolveSymbol(varArgSymbolKey, exp);
|
|
96
|
-
if (result === Ambiguous || result instanceof FunctionReferenceNode) {
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
throw new QuereusError(`Function not found/ambiguous: ${exp.name}/${exp.args.length}`, StatusCode.ERROR);
|
|
101
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Optimizer Rules Directory
|
|
2
|
-
|
|
3
|
-
This directory contains optimization rules for the Quereus Titan optimizer, organized by functional area.
|
|
4
|
-
|
|
5
|
-
## Directory Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
rules/
|
|
9
|
-
├── rewrite/ # Logical-to-logical transformations
|
|
10
|
-
│ ├── predicate-pushdown/
|
|
11
|
-
│ ├── join-reordering/
|
|
12
|
-
│ └── subquery-rewrite/
|
|
13
|
-
├── access/ # Table access path optimization
|
|
14
|
-
│ ├── index-selection/
|
|
15
|
-
│ └── scan-strategy/
|
|
16
|
-
├── join/ # Join algorithm selection and optimization
|
|
17
|
-
│ ├── algorithm-selection/
|
|
18
|
-
│ └── join-ordering/
|
|
19
|
-
├── aggregate/ # Aggregation optimization
|
|
20
|
-
│ ├── streaming/
|
|
21
|
-
│ └── hash-aggregate/
|
|
22
|
-
├── cache/ # Caching and materialization
|
|
23
|
-
│ ├── materialization/
|
|
24
|
-
│ └── cache-injection/
|
|
25
|
-
└── physical/ # Physical property propagation
|
|
26
|
-
├── ordering/
|
|
27
|
-
└── uniqueness/
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Rule Categories
|
|
31
|
-
|
|
32
|
-
### Rewrite Rules (Logical → Logical)
|
|
33
|
-
Transform logical plan structure without changing to physical nodes:
|
|
34
|
-
- Retrieve growth (modules handle pushdown via Retrieve pipelines)
|
|
35
|
-
- Join reordering based on cardinality
|
|
36
|
-
- Subquery → join conversions
|
|
37
|
-
- Constant folding and elimination
|
|
38
|
-
|
|
39
|
-
### Access Rules (Logical → Physical)
|
|
40
|
-
Choose optimal table access strategies:
|
|
41
|
-
- Index vs. sequential scan selection
|
|
42
|
-
- Index seek vs. scan decisions
|
|
43
|
-
- Column pruning integration
|
|
44
|
-
|
|
45
|
-
### Join Rules (Logical → Physical)
|
|
46
|
-
Select join algorithms and optimize join trees:
|
|
47
|
-
- Nested loop vs. hash join selection
|
|
48
|
-
- Join order optimization
|
|
49
|
-
- Cache injection for inner sides
|
|
50
|
-
|
|
51
|
-
### Aggregate Rules (Logical → Physical)
|
|
52
|
-
Choose aggregation implementation strategies:
|
|
53
|
-
- Stream vs. hash aggregation
|
|
54
|
-
- Sort requirement analysis
|
|
55
|
-
- Grouping optimization
|
|
56
|
-
|
|
57
|
-
### Cache Rules
|
|
58
|
-
Inject caching where beneficial:
|
|
59
|
-
- CTE materialization decisions
|
|
60
|
-
- Nested loop inner caching
|
|
61
|
-
- Spill-to-disk strategies
|
|
62
|
-
|
|
63
|
-
### Physical Rules
|
|
64
|
-
Propagate and optimize physical properties:
|
|
65
|
-
- Ordering preservation and requirements
|
|
66
|
-
- Uniqueness key propagation
|
|
67
|
-
- Constant and deterministic flags
|
|
68
|
-
|
|
69
|
-
## Rule Naming Convention
|
|
70
|
-
|
|
71
|
-
Rules follow the pattern: `rule-<description>.ts`
|
|
72
|
-
|
|
73
|
-
Examples:
|
|
74
|
-
- `rule-grow-retrieve.ts`
|
|
75
|
-
- `rule-aggregate-streaming.ts`
|
|
76
|
-
- `rule-join-hash-conversion.ts`
|
|
77
|
-
- `rule-cache-cte-materialization.ts`
|
|
78
|
-
|
|
79
|
-
## Implementation Requirements
|
|
80
|
-
|
|
81
|
-
Each rule must:
|
|
82
|
-
1. Follow the function signature: `(node: PlanNode, optimizer: Optimizer) => PlanNode | null`
|
|
83
|
-
2. Include comprehensive unit tests in co-located `.spec.ts` file
|
|
84
|
-
3. Use consistent logging with `createLogger('optimizer:rule:<name>')`
|
|
85
|
-
4. Preserve attribute IDs when creating new nodes
|
|
86
|
-
5. Set appropriate physical properties using `PlanNode.setDefaultPhysical()`
|
|
87
|
-
|
|
88
|
-
## Getting Started
|
|
89
|
-
|
|
90
|
-
1. Choose the appropriate category directory
|
|
91
|
-
2. Copy the rule template from `docs/optimizer-conventions.md`
|
|
92
|
-
3. Implement the rule following the established patterns
|
|
93
|
-
4. Add comprehensive unit tests
|
|
94
|
-
5. Register the rule in the appropriate registry file
|
|
95
|
-
|
|
96
|
-
See `docs/optimizer-conventions.md` for detailed implementation guidelines.
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rule: Select Access Path
|
|
3
|
-
*
|
|
4
|
-
* Required Characteristics:
|
|
5
|
-
* - Node must be a RetrieveNode representing a virtual table access boundary
|
|
6
|
-
* - Module must support either supports() (query-based) or getBestAccessPlan() (index-based)
|
|
7
|
-
*
|
|
8
|
-
* Applied When:
|
|
9
|
-
* - RetrieveNode needs to be converted to appropriate physical access method
|
|
10
|
-
*
|
|
11
|
-
* Benefits: Enables cost-based access path selection and module-specific execution
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { createLogger } from '../../../common/logger.js';
|
|
15
|
-
import type { PlanNode, ScalarPlanNode } from '../../nodes/plan-node.js';
|
|
16
|
-
import { isRelationalNode, type RelationalPlanNode } from '../../nodes/plan-node.js';
|
|
17
|
-
import type { OptContext } from '../../framework/context.js';
|
|
18
|
-
import { RetrieveNode } from '../../nodes/retrieve-node.js';
|
|
19
|
-
import { RemoteQueryNode } from '../../nodes/remote-query-node.js';
|
|
20
|
-
import { SeqScanNode, IndexScanNode, IndexSeekNode } from '../../nodes/table-access-nodes.js';
|
|
21
|
-
import { seqScanCost } from '../../cost/index.js';
|
|
22
|
-
import type { ColumnMeta, BestAccessPlanRequest, BestAccessPlanResult } from '../../../vtab/best-access-plan.js';
|
|
23
|
-
import { FilterInfo } from '../../../vtab/filter-info.js';
|
|
24
|
-
import type { IndexConstraintUsage } from '../../../vtab/index-info.js';
|
|
25
|
-
import { TableReferenceNode } from '../../nodes/reference.js';
|
|
26
|
-
import { FilterNode } from '../../nodes/filter.js';
|
|
27
|
-
import { extractConstraintsForTable, type PredicateConstraint as PlannerPredicateConstraint, createTableInfoFromNode } from '../../analysis/constraint-extractor.js';
|
|
28
|
-
import { LiteralNode } from '../../nodes/scalar.js';
|
|
29
|
-
import type * as AST from '../../../parser/ast.js';
|
|
30
|
-
import { IndexConstraintOp } from '../../../common/constants.js';
|
|
31
|
-
|
|
32
|
-
const log = createLogger('optimizer:rule:select-access-path');
|
|
33
|
-
|
|
34
|
-
export function ruleSelectAccessPath(node: PlanNode, context: OptContext): PlanNode | null {
|
|
35
|
-
// Guard: node must be a RetrieveNode
|
|
36
|
-
if (!(node instanceof RetrieveNode)) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const retrieveNode = node as RetrieveNode;
|
|
41
|
-
const tableSchema = retrieveNode.tableRef.tableSchema;
|
|
42
|
-
const vtabModule = retrieveNode.vtabModule;
|
|
43
|
-
|
|
44
|
-
log('Selecting access path for retrieve over table %s', tableSchema.name);
|
|
45
|
-
|
|
46
|
-
// Always allow fallback to sequential scan to guarantee physicalization
|
|
47
|
-
// even when no specialized support is available.
|
|
48
|
-
|
|
49
|
-
// If grow-retrieve established an index-style context, reuse it directly
|
|
50
|
-
if (isIndexStyleContext(retrieveNode.moduleCtx)) {
|
|
51
|
-
log('Using index-style context provided by grow-retrieve');
|
|
52
|
-
const accessPlan = retrieveNode.moduleCtx.accessPlan;
|
|
53
|
-
const originalConstraints = retrieveNode.moduleCtx.originalConstraints as unknown as PlannerPredicateConstraint[];
|
|
54
|
-
const physicalLeaf: RelationalPlanNode = selectPhysicalNode(retrieveNode.tableRef, accessPlan, originalConstraints) as unknown as RelationalPlanNode;
|
|
55
|
-
if (retrieveNode.moduleCtx.residualPredicate) {
|
|
56
|
-
return new FilterNode(retrieveNode.scope, physicalLeaf, retrieveNode.moduleCtx.residualPredicate);
|
|
57
|
-
}
|
|
58
|
-
return physicalLeaf;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Check if module supports query-based execution via supports() method
|
|
62
|
-
if (vtabModule.supports && typeof vtabModule.supports === 'function') {
|
|
63
|
-
log('Module has supports() method - checking support for current pipeline');
|
|
64
|
-
|
|
65
|
-
// Check if module supports the current pipeline
|
|
66
|
-
const assessment = vtabModule.supports(retrieveNode.source);
|
|
67
|
-
|
|
68
|
-
if (assessment) {
|
|
69
|
-
log('Pipeline supported - creating RemoteQueryNode (cost: %d)', assessment.cost);
|
|
70
|
-
return new RemoteQueryNode(
|
|
71
|
-
retrieveNode.scope,
|
|
72
|
-
retrieveNode.source,
|
|
73
|
-
retrieveNode.tableRef,
|
|
74
|
-
assessment.ctx
|
|
75
|
-
);
|
|
76
|
-
} else {
|
|
77
|
-
log('Pipeline not supported by module - falling back to sequential scan');
|
|
78
|
-
return createSeqScan(retrieveNode.tableRef);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Check if module supports index-based execution via getBestAccessPlan() method
|
|
83
|
-
if (vtabModule.getBestAccessPlan && typeof vtabModule.getBestAccessPlan === 'function') {
|
|
84
|
-
log('Module has getBestAccessPlan() method - using index-based execution for %s', tableSchema.name);
|
|
85
|
-
|
|
86
|
-
return createIndexBasedAccess(retrieveNode, context);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Fall back to sequential scan if module has no access planning support
|
|
90
|
-
log('No access planning support, using sequential scan for %s', tableSchema.name);
|
|
91
|
-
return createSeqScan(retrieveNode.tableRef);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Create index-based access for modules that support getBestAccessPlan()
|
|
96
|
-
*/
|
|
97
|
-
function createIndexBasedAccess(retrieveNode: RetrieveNode, context: OptContext): PlanNode {
|
|
98
|
-
const tableSchema = retrieveNode.tableRef.tableSchema;
|
|
99
|
-
const vtabModule = retrieveNode.vtabModule;
|
|
100
|
-
|
|
101
|
-
// Check if we have pre-computed access plan from ruleGrowRetrieve
|
|
102
|
-
const indexCtx = retrieveNode.moduleCtx as any; // IndexStyleContext from grow rule
|
|
103
|
-
let accessPlan: BestAccessPlanResult;
|
|
104
|
-
let constraints: PlannerPredicateConstraint[];
|
|
105
|
-
let residualPredicate: PlanNode | undefined;
|
|
106
|
-
|
|
107
|
-
if (indexCtx?.accessPlan) {
|
|
108
|
-
// Use pre-computed access plan from grow rule
|
|
109
|
-
log('Using pre-computed access plan from grow rule');
|
|
110
|
-
accessPlan = indexCtx.accessPlan;
|
|
111
|
-
constraints = indexCtx.originalConstraints || [];
|
|
112
|
-
residualPredicate = indexCtx.residualPredicate;
|
|
113
|
-
} else {
|
|
114
|
-
// Extract constraints from grown pipeline in source using table instance key
|
|
115
|
-
const tInfo = createTableInfoFromNode(retrieveNode.tableRef, `${tableSchema.schemaName}.${tableSchema.name}`);
|
|
116
|
-
constraints = extractConstraintsForTable(retrieveNode.source, tInfo.relationKey);
|
|
117
|
-
|
|
118
|
-
// Build request for getBestAccessPlan
|
|
119
|
-
const request: BestAccessPlanRequest = {
|
|
120
|
-
columns: tableSchema.columns.map((col, index) => ({
|
|
121
|
-
index,
|
|
122
|
-
name: col.name,
|
|
123
|
-
type: col.logicalType,
|
|
124
|
-
isPrimaryKey: col.primaryKey || false,
|
|
125
|
-
isUnique: col.primaryKey || false // For now, assume only PK columns are unique
|
|
126
|
-
} as ColumnMeta)),
|
|
127
|
-
filters: constraints,
|
|
128
|
-
estimatedRows: retrieveNode.tableRef.estimatedRows
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Use the vtab module's getBestAccessPlan method to get an optimized access plan
|
|
132
|
-
accessPlan = vtabModule.getBestAccessPlan!(context.db, tableSchema, request) as BestAccessPlanResult;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Choose physical node based on access plan
|
|
136
|
-
const physicalLeaf: RelationalPlanNode = selectPhysicalNode(retrieveNode.tableRef, accessPlan, constraints) as unknown as RelationalPlanNode;
|
|
137
|
-
|
|
138
|
-
// If the Retrieve source contained a pipeline (e.g., Filter/Sort/Project), rebuild it above the physical leaf
|
|
139
|
-
let rebuiltPipeline: RelationalPlanNode = physicalLeaf;
|
|
140
|
-
if (retrieveNode.source !== retrieveNode.tableRef) {
|
|
141
|
-
log('Rebuilding Retrieve pipeline above physical access node');
|
|
142
|
-
rebuiltPipeline = rebuildPipelineWithNewLeaf(retrieveNode.source, retrieveNode.tableRef, physicalLeaf);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Wrap with residual predicate if present (on top of rebuilt pipeline)
|
|
146
|
-
let finalNode: PlanNode = rebuiltPipeline;
|
|
147
|
-
if (residualPredicate) {
|
|
148
|
-
log('Wrapping rebuilt pipeline with residual filter');
|
|
149
|
-
finalNode = new FilterNode(rebuiltPipeline.scope, rebuiltPipeline as any, residualPredicate as any);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
log('Selected access for table %s (cost: %f, rows: %s)', tableSchema.name, accessPlan.cost, accessPlan.rows);
|
|
153
|
-
return finalNode;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Rebuilds a relational pipeline by replacing the specified leaf with a new leaf.
|
|
158
|
-
* Preserves all operators (e.g., Filter, Sort, Project) above the leaf.
|
|
159
|
-
*/
|
|
160
|
-
function rebuildPipelineWithNewLeaf(
|
|
161
|
-
pipelineRoot: RelationalPlanNode,
|
|
162
|
-
oldLeaf: RelationalPlanNode,
|
|
163
|
-
newLeaf: RelationalPlanNode
|
|
164
|
-
): RelationalPlanNode {
|
|
165
|
-
if (pipelineRoot === oldLeaf) {
|
|
166
|
-
return newLeaf;
|
|
167
|
-
}
|
|
168
|
-
const children = pipelineRoot.getChildren();
|
|
169
|
-
const newChildren: PlanNode[] = children.map(child => {
|
|
170
|
-
if (isRelationalNode(child)) {
|
|
171
|
-
return rebuildPipelineWithNewLeaf(child, oldLeaf, newLeaf);
|
|
172
|
-
}
|
|
173
|
-
return child; // keep scalar children unchanged
|
|
174
|
-
});
|
|
175
|
-
return pipelineRoot.withChildren(newChildren) as RelationalPlanNode;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Select the appropriate physical node based on access plan
|
|
180
|
-
*/
|
|
181
|
-
function selectPhysicalNode(
|
|
182
|
-
tableRef: TableReferenceNode,
|
|
183
|
-
accessPlan: BestAccessPlanResult,
|
|
184
|
-
constraints: PlannerPredicateConstraint[]
|
|
185
|
-
): SeqScanNode | IndexScanNode | IndexSeekNode {
|
|
186
|
-
|
|
187
|
-
// Create a default FilterInfo for the physical nodes
|
|
188
|
-
const filterInfo: FilterInfo = {
|
|
189
|
-
idxNum: 0,
|
|
190
|
-
idxStr: 'fullscan',
|
|
191
|
-
constraints: [],
|
|
192
|
-
args: [],
|
|
193
|
-
indexInfoOutput: {
|
|
194
|
-
nConstraint: 0,
|
|
195
|
-
aConstraint: [],
|
|
196
|
-
nOrderBy: 0,
|
|
197
|
-
aOrderBy: [],
|
|
198
|
-
aConstraintUsage: [] as IndexConstraintUsage[],
|
|
199
|
-
idxNum: 0,
|
|
200
|
-
idxStr: 'fullscan',
|
|
201
|
-
orderByConsumed: false,
|
|
202
|
-
estimatedCost: accessPlan.cost,
|
|
203
|
-
estimatedRows: BigInt(accessPlan.rows || 1000),
|
|
204
|
-
idxFlags: 0,
|
|
205
|
-
colUsed: 0n,
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// Analyze the access plan to determine node type
|
|
210
|
-
// Determine handled constraints by column index, not array position (robust to ordering)
|
|
211
|
-
const handledByCol = new Set<number>();
|
|
212
|
-
constraints.forEach((c, i) => {
|
|
213
|
-
if (accessPlan.handledFilters[i] === true) handledByCol.add(c.columnIndex);
|
|
214
|
-
});
|
|
215
|
-
const eqHandled = constraints.filter(c => c.op === '=');
|
|
216
|
-
const hasEqualityConstraints = eqHandled.length > 0;
|
|
217
|
-
const hasRangeConstraints = constraints.some(c => ['>', '>=', '<', '<='].includes(c.op) && handledByCol.has(c.columnIndex));
|
|
218
|
-
|
|
219
|
-
// Convert OrderingSpec[] to the format expected by physical nodes
|
|
220
|
-
const providesOrdering = accessPlan.providesOrdering?.map(spec => ({
|
|
221
|
-
column: spec.columnIndex,
|
|
222
|
-
desc: spec.desc
|
|
223
|
-
}));
|
|
224
|
-
|
|
225
|
-
// Decision logic for access method
|
|
226
|
-
const maybeRows = accessPlan.rows || 0;
|
|
227
|
-
const pkCols = tableRef.tableSchema.primaryKeyDefinition ?? [];
|
|
228
|
-
const eqByCol = new Map<number, PlannerPredicateConstraint>();
|
|
229
|
-
for (const c of eqHandled) eqByCol.set(c.columnIndex, c);
|
|
230
|
-
const coversPk = pkCols.length > 0 && pkCols.every(pk => eqByCol.has(pk.index));
|
|
231
|
-
|
|
232
|
-
// If module didn't report handledFilters properly but we have full-PK equality,
|
|
233
|
-
// treat it as handled for the purpose of selecting IndexSeek.
|
|
234
|
-
const treatAsHandledPk = coversPk && pkCols.every(pk => handledByCol.has(pk.index) || eqByCol.has(pk.index));
|
|
235
|
-
|
|
236
|
-
if ((hasEqualityConstraints && coversPk || treatAsHandledPk) && maybeRows <= 10) {
|
|
237
|
-
// Build seek keys (as ScalarPlanNode) and constraint wiring for runtime args
|
|
238
|
-
const seekKeys = pkCols.map(pk => {
|
|
239
|
-
const c = eqByCol.get(pk.index)!;
|
|
240
|
-
if (c.valueExpr) return c.valueExpr as unknown as ScalarPlanNode;
|
|
241
|
-
const lit: AST.LiteralExpr = { type: 'literal', value: c.value } as unknown as AST.LiteralExpr;
|
|
242
|
-
return new LiteralNode(tableRef.scope, lit);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// Build FilterInfo with EQ constraints carrying argvIndex placeholders
|
|
246
|
-
const eqConstraints = pkCols.map((pk, i) => ({
|
|
247
|
-
constraint: { iColumn: pk.index, op: IndexConstraintOp.EQ, usable: true },
|
|
248
|
-
argvIndex: i + 1,
|
|
249
|
-
}));
|
|
250
|
-
const fi: FilterInfo = {
|
|
251
|
-
...filterInfo,
|
|
252
|
-
constraints: eqConstraints,
|
|
253
|
-
// idxStr plan=2 (equality); include primary idx tag for clarity
|
|
254
|
-
idxStr: 'idx=_primary_(0);plan=2',
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
log('Using index seek on primary key');
|
|
258
|
-
return new IndexSeekNode(
|
|
259
|
-
tableRef.scope,
|
|
260
|
-
tableRef,
|
|
261
|
-
fi,
|
|
262
|
-
'primary',
|
|
263
|
-
seekKeys,
|
|
264
|
-
false,
|
|
265
|
-
providesOrdering,
|
|
266
|
-
accessPlan.cost
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (hasRangeConstraints) {
|
|
271
|
-
// Build dynamic range seek using IndexSeek with lower/upper bound expressions
|
|
272
|
-
// Choose first handled range column (typically leading PK/index column)
|
|
273
|
-
const rangeCols = constraints
|
|
274
|
-
.filter(c => ['>', '>=', '<', '<='].includes(c.op) && handledByCol.has(c.columnIndex))
|
|
275
|
-
.sort((a, b) => a.columnIndex - b.columnIndex);
|
|
276
|
-
|
|
277
|
-
const primaryFirstCol = (tableRef.tableSchema.primaryKeyDefinition?.[0]?.index) ?? (rangeCols[0]?.columnIndex ?? 0);
|
|
278
|
-
const lower = rangeCols.find(c => c.columnIndex === primaryFirstCol && (c.op === '>' || c.op === '>=')) as unknown as PlannerPredicateConstraint | undefined;
|
|
279
|
-
const upper = rangeCols.find(c => c.columnIndex === primaryFirstCol && (c.op === '<' || c.op === '<=')) as unknown as PlannerPredicateConstraint | undefined;
|
|
280
|
-
|
|
281
|
-
const seekKeys: ScalarPlanNode[] = [];
|
|
282
|
-
const rangeConstraints: { constraint: { iColumn: number; op: number; usable: boolean }; argvIndex: number }[] = [] as any;
|
|
283
|
-
|
|
284
|
-
let argv = 1;
|
|
285
|
-
if (lower) {
|
|
286
|
-
// argvIndex starts at 1
|
|
287
|
-
rangeConstraints.push({ constraint: { iColumn: primaryFirstCol, op: opToIndexOp(lower.op as any), usable: true }, argvIndex: argv });
|
|
288
|
-
seekKeys.push(lower.valueExpr ? lower.valueExpr as any : new LiteralNode(tableRef.scope, { type: 'literal', value: lower.value } as any));
|
|
289
|
-
argv++;
|
|
290
|
-
}
|
|
291
|
-
if (upper) {
|
|
292
|
-
rangeConstraints.push({ constraint: { iColumn: primaryFirstCol, op: opToIndexOp(upper.op as any), usable: true }, argvIndex: argv });
|
|
293
|
-
seekKeys.push(upper.valueExpr ? upper.valueExpr as any : new LiteralNode(tableRef.scope, { type: 'literal', value: upper.value } as any));
|
|
294
|
-
argv++;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const fi: FilterInfo = {
|
|
298
|
-
...filterInfo,
|
|
299
|
-
constraints: rangeConstraints as any,
|
|
300
|
-
idxStr: 'idx=_primary_(0);plan=3',
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
log('Using index seek (range) on primary key');
|
|
304
|
-
return new IndexSeekNode(
|
|
305
|
-
tableRef.scope,
|
|
306
|
-
tableRef,
|
|
307
|
-
fi,
|
|
308
|
-
'primary',
|
|
309
|
-
seekKeys,
|
|
310
|
-
true,
|
|
311
|
-
providesOrdering,
|
|
312
|
-
accessPlan.cost
|
|
313
|
-
);
|
|
314
|
-
} else if (providesOrdering) {
|
|
315
|
-
// Ordering benefit without explicit range constraints: prefer index scan
|
|
316
|
-
// Use the index that provides the ordering, or fall back to primary
|
|
317
|
-
const indexName = accessPlan.orderingIndexName ?? 'primary';
|
|
318
|
-
log('Using index scan (ordering provided by %s)', indexName);
|
|
319
|
-
|
|
320
|
-
// Build FilterInfo with the correct index name for the runtime
|
|
321
|
-
const indexIdxStr = indexName === 'primary' ? '_primary_' : indexName;
|
|
322
|
-
const orderingFilterInfo: FilterInfo = {
|
|
323
|
-
...filterInfo,
|
|
324
|
-
idxStr: `idx=${indexIdxStr}(0);plan=0`,
|
|
325
|
-
indexInfoOutput: {
|
|
326
|
-
...filterInfo.indexInfoOutput,
|
|
327
|
-
idxStr: `idx=${indexIdxStr}(0);plan=0`,
|
|
328
|
-
orderByConsumed: true,
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
return new IndexScanNode(
|
|
333
|
-
tableRef.scope,
|
|
334
|
-
tableRef,
|
|
335
|
-
orderingFilterInfo,
|
|
336
|
-
indexName,
|
|
337
|
-
providesOrdering,
|
|
338
|
-
accessPlan.cost
|
|
339
|
-
);
|
|
340
|
-
} else {
|
|
341
|
-
// Fall back to sequential scan
|
|
342
|
-
log('Using sequential scan (no beneficial index access)');
|
|
343
|
-
return createSeqScan(tableRef, filterInfo, accessPlan.cost);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Narrow module context originating from grow-retrieve index-style fallback
|
|
348
|
-
function isIndexStyleContext(ctx: unknown): ctx is { kind: 'index-style'; accessPlan: BestAccessPlanResult; residualPredicate?: ScalarPlanNode; originalConstraints: unknown[] } {
|
|
349
|
-
return !!ctx && typeof ctx === 'object' && (ctx as any).kind === 'index-style';
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Create a sequential scan node
|
|
354
|
-
*/
|
|
355
|
-
function createSeqScan(tableRef: TableReferenceNode, filterInfo?: FilterInfo, cost?: number): SeqScanNode {
|
|
356
|
-
const tableRows = tableRef.estimatedRows || 1000;
|
|
357
|
-
const scanCost = cost ?? seqScanCost(tableRows);
|
|
358
|
-
|
|
359
|
-
// Create default FilterInfo if not provided
|
|
360
|
-
const effectiveFilterInfo = filterInfo || {
|
|
361
|
-
idxNum: 0,
|
|
362
|
-
idxStr: 'fullscan',
|
|
363
|
-
constraints: [],
|
|
364
|
-
args: [],
|
|
365
|
-
indexInfoOutput: {
|
|
366
|
-
nConstraint: 0,
|
|
367
|
-
aConstraint: [],
|
|
368
|
-
nOrderBy: 0,
|
|
369
|
-
aOrderBy: [],
|
|
370
|
-
aConstraintUsage: [] as IndexConstraintUsage[],
|
|
371
|
-
idxNum: 0,
|
|
372
|
-
idxStr: 'fullscan',
|
|
373
|
-
orderByConsumed: false,
|
|
374
|
-
estimatedCost: scanCost,
|
|
375
|
-
estimatedRows: BigInt(tableRows),
|
|
376
|
-
idxFlags: 0,
|
|
377
|
-
colUsed: 0n,
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
const seqScan = new SeqScanNode(
|
|
382
|
-
tableRef.scope,
|
|
383
|
-
tableRef,
|
|
384
|
-
effectiveFilterInfo,
|
|
385
|
-
scanCost
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
return seqScan;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function opToIndexOp(op: '>' | '>=' | '<' | '<='): number {
|
|
392
|
-
switch (op) {
|
|
393
|
-
case '>': return IndexConstraintOp.GT as unknown as number;
|
|
394
|
-
case '>=': return IndexConstraintOp.GE as unknown as number;
|
|
395
|
-
case '<': return IndexConstraintOp.LT as unknown as number;
|
|
396
|
-
case '<=': return IndexConstraintOp.LE as unknown as number;
|
|
397
|
-
default: return IndexConstraintOp.GE as unknown as number;
|
|
398
|
-
}
|
|
399
|
-
}
|