@quereus/quereus 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +19 -18
- package/package.json +3 -3
- package/dist/src/common/constants.js.map +0 -1
- package/dist/src/common/datatype.js.map +0 -1
- package/dist/src/common/errors.js.map +0 -1
- package/dist/src/common/json-types.js.map +0 -1
- package/dist/src/common/logger.js.map +0 -1
- package/dist/src/common/type-inference.js.map +0 -1
- package/dist/src/common/types.js.map +0 -1
- package/dist/src/core/database-options.js.map +0 -1
- package/dist/src/core/database.js.map +0 -1
- package/dist/src/core/param.js.map +0 -1
- package/dist/src/core/statement.js.map +0 -1
- package/dist/src/func/builtins/aggregate.js.map +0 -1
- package/dist/src/func/builtins/builtin-window-functions.js.map +0 -1
- package/dist/src/func/builtins/conversion.js.map +0 -1
- package/dist/src/func/builtins/datetime.js.map +0 -1
- package/dist/src/func/builtins/explain.js.map +0 -1
- package/dist/src/func/builtins/generation.js.map +0 -1
- package/dist/src/func/builtins/index.js.map +0 -1
- package/dist/src/func/builtins/json-helpers.js.map +0 -1
- package/dist/src/func/builtins/json-tvf.js.map +0 -1
- package/dist/src/func/builtins/json.js.map +0 -1
- package/dist/src/func/builtins/scalar.js.map +0 -1
- package/dist/src/func/builtins/schema.js.map +0 -1
- package/dist/src/func/builtins/string.js.map +0 -1
- package/dist/src/func/builtins/timespan.js.map +0 -1
- package/dist/src/func/context.js.map +0 -1
- package/dist/src/func/registration.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/index.js.map +0 -1
- package/dist/src/parser/lexer.js.map +0 -1
- package/dist/src/parser/parser.js.map +0 -1
- package/dist/src/parser/utils.js.map +0 -1
- package/dist/src/parser/visitor.js.map +0 -1
- package/dist/src/planner/analysis/binding-collector.js.map +0 -1
- package/dist/src/planner/analysis/const-evaluator.js.map +0 -1
- package/dist/src/planner/analysis/const-pass.js.map +0 -1
- package/dist/src/planner/analysis/constraint-extractor.js.map +0 -1
- package/dist/src/planner/analysis/predicate-normalizer.js.map +0 -1
- package/dist/src/planner/building/alter-table.js.map +0 -1
- package/dist/src/planner/building/block.js.map +0 -1
- package/dist/src/planner/building/constraint-builder.js.map +0 -1
- package/dist/src/planner/building/create-assertion.js.map +0 -1
- package/dist/src/planner/building/create-view.js.map +0 -1
- package/dist/src/planner/building/ddl.js.map +0 -1
- package/dist/src/planner/building/declare-schema.js.map +0 -1
- package/dist/src/planner/building/delete.js.map +0 -1
- package/dist/src/planner/building/drop-assertion.js.map +0 -1
- package/dist/src/planner/building/drop-table.js.map +0 -1
- package/dist/src/planner/building/drop-view.js.map +0 -1
- package/dist/src/planner/building/expression.js.map +0 -1
- package/dist/src/planner/building/function-call.js.map +0 -1
- package/dist/src/planner/building/insert.js.map +0 -1
- package/dist/src/planner/building/pragma.js.map +0 -1
- package/dist/src/planner/building/schema-resolution.js.map +0 -1
- package/dist/src/planner/building/select-aggregates.js.map +0 -1
- package/dist/src/planner/building/select-compound.js.map +0 -1
- package/dist/src/planner/building/select-context.js.map +0 -1
- package/dist/src/planner/building/select-modifiers.js.map +0 -1
- package/dist/src/planner/building/select-projections.js.map +0 -1
- package/dist/src/planner/building/select-window.js.map +0 -1
- package/dist/src/planner/building/select.js.map +0 -1
- package/dist/src/planner/building/table-function.js.map +0 -1
- package/dist/src/planner/building/table.js.map +0 -1
- package/dist/src/planner/building/transaction.js.map +0 -1
- package/dist/src/planner/building/update.js.map +0 -1
- package/dist/src/planner/building/with.js.map +0 -1
- package/dist/src/planner/cache/correlation-detector.js.map +0 -1
- package/dist/src/planner/cache/materialization-advisory.js.map +0 -1
- package/dist/src/planner/cache/reference-graph.js.map +0 -1
- package/dist/src/planner/cost/index.js.map +0 -1
- package/dist/src/planner/debug/logger-utils.js.map +0 -1
- package/dist/src/planner/debug.js.map +0 -1
- package/dist/src/planner/framework/characteristics.js.map +0 -1
- package/dist/src/planner/framework/context.js.map +0 -1
- package/dist/src/planner/framework/pass.js.map +0 -1
- package/dist/src/planner/framework/physical-utils.js.map +0 -1
- package/dist/src/planner/framework/registry.js.map +0 -1
- package/dist/src/planner/framework/trace.js.map +0 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-function.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-node.js.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/planner/nodes/block.js.map +0 -1
- package/dist/src/planner/nodes/cache-node.js.map +0 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +0 -1
- package/dist/src/planner/nodes/create-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/create-index-node.js.map +0 -1
- package/dist/src/planner/nodes/create-table-node.js.map +0 -1
- package/dist/src/planner/nodes/create-view-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/declarative-schema.js.map +0 -1
- package/dist/src/planner/nodes/delete-node.js.map +0 -1
- package/dist/src/planner/nodes/distinct-node.js.map +0 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-table-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-view-node.js.map +0 -1
- package/dist/src/planner/nodes/filter.js.map +0 -1
- package/dist/src/planner/nodes/function.js.map +0 -1
- package/dist/src/planner/nodes/insert-node.js.map +0 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +0 -1
- package/dist/src/planner/nodes/join-node.js.map +0 -1
- package/dist/src/planner/nodes/limit-offset.js.map +0 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +0 -1
- package/dist/src/planner/nodes/plan-node.js.map +0 -1
- package/dist/src/planner/nodes/pragma.js.map +0 -1
- package/dist/src/planner/nodes/project-node.js.map +0 -1
- package/dist/src/planner/nodes/recursive-cte-node.js.map +0 -1
- package/dist/src/planner/nodes/reference.js.map +0 -1
- package/dist/src/planner/nodes/remote-query-node.js.map +0 -1
- package/dist/src/planner/nodes/retrieve-node.js.map +0 -1
- package/dist/src/planner/nodes/returning-node.js.map +0 -1
- package/dist/src/planner/nodes/scalar.js.map +0 -1
- package/dist/src/planner/nodes/sequencing-node.js.map +0 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +0 -1
- package/dist/src/planner/nodes/single-row.js.map +0 -1
- package/dist/src/planner/nodes/sink-node.js.map +0 -1
- package/dist/src/planner/nodes/sort.js.map +0 -1
- package/dist/src/planner/nodes/stream-aggregate.js.map +0 -1
- package/dist/src/planner/nodes/subquery.js.map +0 -1
- package/dist/src/planner/nodes/table-access-nodes.js.map +0 -1
- package/dist/src/planner/nodes/table-function-call.js.map +0 -1
- package/dist/src/planner/nodes/transaction-node.js.map +0 -1
- package/dist/src/planner/nodes/update-node.js.map +0 -1
- package/dist/src/planner/nodes/values-node.js.map +0 -1
- package/dist/src/planner/nodes/view-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/window-function.js.map +0 -1
- package/dist/src/planner/nodes/window-node.js.map +0 -1
- package/dist/src/planner/optimizer-tuning.js.map +0 -1
- package/dist/src/planner/optimizer.js.map +0 -1
- package/dist/src/planner/planning-context.js.map +0 -1
- package/dist/src/planner/resolve.js.map +0 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +0 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +0 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +0 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +0 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +0 -1
- package/dist/src/planner/scopes/aliased.js.map +0 -1
- package/dist/src/planner/scopes/base.js.map +0 -1
- package/dist/src/planner/scopes/empty.js.map +0 -1
- package/dist/src/planner/scopes/global.js.map +0 -1
- package/dist/src/planner/scopes/multi.js.map +0 -1
- package/dist/src/planner/scopes/param.js.map +0 -1
- package/dist/src/planner/scopes/registered.js.map +0 -1
- package/dist/src/planner/scopes/scope.js.map +0 -1
- package/dist/src/planner/stats/basic-estimates.js.map +0 -1
- package/dist/src/planner/stats/index.js.map +0 -1
- package/dist/src/planner/type-utils.js.map +0 -1
- package/dist/src/planner/util/key-utils.js.map +0 -1
- package/dist/src/planner/validation/determinism-validator.js.map +0 -1
- package/dist/src/planner/validation/plan-validator.js.map +0 -1
- package/dist/src/runtime/async-util.js.map +0 -1
- package/dist/src/runtime/cache/shared-cache.js.map +0 -1
- package/dist/src/runtime/context-helpers.js.map +0 -1
- package/dist/src/runtime/deferred-constraint-queue.js.map +0 -1
- package/dist/src/runtime/emission-context.js.map +0 -1
- package/dist/src/runtime/emit/add-constraint.js.map +0 -1
- package/dist/src/runtime/emit/aggregate.js.map +0 -1
- package/dist/src/runtime/emit/array-index.js.map +0 -1
- package/dist/src/runtime/emit/between.js.map +0 -1
- package/dist/src/runtime/emit/binary.js.map +0 -1
- package/dist/src/runtime/emit/block.js.map +0 -1
- package/dist/src/runtime/emit/cache.js.map +0 -1
- package/dist/src/runtime/emit/case.js.map +0 -1
- package/dist/src/runtime/emit/cast.js.map +0 -1
- package/dist/src/runtime/emit/collate.js.map +0 -1
- package/dist/src/runtime/emit/column-reference.js.map +0 -1
- package/dist/src/runtime/emit/constraint-check.js.map +0 -1
- package/dist/src/runtime/emit/create-assertion.js.map +0 -1
- package/dist/src/runtime/emit/create-index.js.map +0 -1
- package/dist/src/runtime/emit/create-table.js.map +0 -1
- package/dist/src/runtime/emit/create-view.js.map +0 -1
- package/dist/src/runtime/emit/cte-reference.js.map +0 -1
- package/dist/src/runtime/emit/cte.js.map +0 -1
- package/dist/src/runtime/emit/delete.js.map +0 -1
- package/dist/src/runtime/emit/distinct.js.map +0 -1
- package/dist/src/runtime/emit/dml-executor.js.map +0 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +0 -1
- package/dist/src/runtime/emit/drop-table.js.map +0 -1
- package/dist/src/runtime/emit/drop-view.js.map +0 -1
- package/dist/src/runtime/emit/filter.js.map +0 -1
- package/dist/src/runtime/emit/insert.js.map +0 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +0 -1
- package/dist/src/runtime/emit/join.js.map +0 -1
- package/dist/src/runtime/emit/limit-offset.js.map +0 -1
- package/dist/src/runtime/emit/literal.js.map +0 -1
- package/dist/src/runtime/emit/parameter.js.map +0 -1
- package/dist/src/runtime/emit/pragma.js.map +0 -1
- package/dist/src/runtime/emit/project.js.map +0 -1
- package/dist/src/runtime/emit/recursive-cte.js.map +0 -1
- package/dist/src/runtime/emit/remote-query.js.map +0 -1
- package/dist/src/runtime/emit/retrieve.js.map +0 -1
- package/dist/src/runtime/emit/returning.js.map +0 -1
- package/dist/src/runtime/emit/scalar-function.js.map +0 -1
- package/dist/src/runtime/emit/scan.js.map +0 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +0 -1
- package/dist/src/runtime/emit/sequencing.js.map +0 -1
- package/dist/src/runtime/emit/set-operation.js.map +0 -1
- package/dist/src/runtime/emit/sink.js.map +0 -1
- package/dist/src/runtime/emit/sort.js.map +0 -1
- package/dist/src/runtime/emit/subquery.js.map +0 -1
- package/dist/src/runtime/emit/table-valued-function.js.map +0 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +0 -1
- package/dist/src/runtime/emit/transaction.js.map +0 -1
- package/dist/src/runtime/emit/unary.js.map +0 -1
- package/dist/src/runtime/emit/update.js.map +0 -1
- package/dist/src/runtime/emit/values.js.map +0 -1
- package/dist/src/runtime/emit/window-function.js.map +0 -1
- package/dist/src/runtime/emit/window.js.map +0 -1
- package/dist/src/runtime/emitters.js.map +0 -1
- package/dist/src/runtime/register.js.map +0 -1
- package/dist/src/runtime/scheduler.js.map +0 -1
- package/dist/src/runtime/types.js.map +0 -1
- package/dist/src/runtime/utils.js.map +0 -1
- package/dist/src/schema/assertion.js.map +0 -1
- package/dist/src/schema/catalog.js.map +0 -1
- package/dist/src/schema/change-events.js.map +0 -1
- package/dist/src/schema/column.js.map +0 -1
- package/dist/src/schema/declared-schema-manager.js.map +0 -1
- package/dist/src/schema/function.js.map +0 -1
- package/dist/src/schema/manager.js.map +0 -1
- package/dist/src/schema/schema-differ.js.map +0 -1
- package/dist/src/schema/schema-hasher.js.map +0 -1
- package/dist/src/schema/schema.js.map +0 -1
- package/dist/src/schema/table.js.map +0 -1
- package/dist/src/schema/view.js.map +0 -1
- package/dist/src/schema/window-function.js.map +0 -1
- package/dist/src/types/builtin-types.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/json-type.js.map +0 -1
- package/dist/src/types/logical-type.js.map +0 -1
- package/dist/src/types/plugin-interface.js.map +0 -1
- package/dist/src/types/registry.js.map +0 -1
- package/dist/src/types/temporal-types.js.map +0 -1
- package/dist/src/types/validation.js.map +0 -1
- package/dist/src/util/affinity.js.map +0 -1
- package/dist/src/util/ast-stringify.js.map +0 -1
- package/dist/src/util/cached.js.map +0 -1
- package/dist/src/util/coercion.js.map +0 -1
- package/dist/src/util/comparison.js.map +0 -1
- package/dist/src/util/environment.js.map +0 -1
- package/dist/src/util/hash.js.map +0 -1
- package/dist/src/util/latches.js.map +0 -1
- package/dist/src/util/mutation-statement.js.map +0 -1
- package/dist/src/util/patterns.js.map +0 -1
- package/dist/src/util/plan-formatter.js.map +0 -1
- package/dist/src/util/plugin-helper.js.map +0 -1
- package/dist/src/util/row-descriptor.js.map +0 -1
- package/dist/src/util/serialization.js.map +0 -1
- package/dist/src/util/sql-literal.js.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
- package/dist/src/vtab/best-access-plan.js.map +0 -1
- package/dist/src/vtab/connection.js.map +0 -1
- package/dist/src/vtab/filter-info.js.map +0 -1
- package/dist/src/vtab/index-info.js.map +0 -1
- package/dist/src/vtab/manifest.js.map +0 -1
- package/dist/src/vtab/memory/connection.js.map +0 -1
- package/dist/src/vtab/memory/index.js.map +0 -1
- package/dist/src/vtab/memory/layer/base-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/base.js.map +0 -1
- package/dist/src/vtab/memory/layer/connection.js.map +0 -1
- package/dist/src/vtab/memory/layer/interface.js.map +0 -1
- package/dist/src/vtab/memory/layer/manager.js.map +0 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +0 -1
- package/dist/src/vtab/memory/layer/scan-plan.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction.js.map +0 -1
- package/dist/src/vtab/memory/module.js.map +0 -1
- package/dist/src/vtab/memory/table.js.map +0 -1
- package/dist/src/vtab/memory/types.js.map +0 -1
- package/dist/src/vtab/memory/utils/logging.js.map +0 -1
- package/dist/src/vtab/memory/utils/primary-key.js.map +0 -1
- package/dist/src/vtab/module.js.map +0 -1
- package/dist/src/vtab/table.js.map +0 -1
- package/src/common/constants.ts +0 -60
- package/src/common/datatype.ts +0 -85
- package/src/common/errors.ts +0 -189
- package/src/common/json-types.ts +0 -16
- package/src/common/logger.ts +0 -97
- package/src/common/type-inference.ts +0 -39
- package/src/common/types.ts +0 -151
- package/src/core/database-options.ts +0 -258
- package/src/core/database.ts +0 -1461
- package/src/core/param.ts +0 -56
- package/src/core/statement.ts +0 -528
- package/src/func/builtins/aggregate.ts +0 -269
- package/src/func/builtins/builtin-window-functions.ts +0 -166
- package/src/func/builtins/conversion.ts +0 -226
- package/src/func/builtins/datetime.ts +0 -500
- package/src/func/builtins/explain.ts +0 -779
- package/src/func/builtins/generation.ts +0 -43
- package/src/func/builtins/index.ts +0 -167
- package/src/func/builtins/json-helpers.ts +0 -237
- package/src/func/builtins/json-tvf.ts +0 -224
- package/src/func/builtins/json.ts +0 -588
- package/src/func/builtins/scalar.ts +0 -423
- package/src/func/builtins/schema.ts +0 -213
- package/src/func/builtins/string.ts +0 -306
- package/src/func/builtins/timespan.ts +0 -179
- package/src/func/context.ts +0 -258
- package/src/func/registration.ts +0 -201
- package/src/index.ts +0 -172
- package/src/parser/ast.ts +0 -581
- package/src/parser/index.ts +0 -65
- package/src/parser/lexer.ts +0 -806
- package/src/parser/parser.ts +0 -3352
- package/src/parser/utils.ts +0 -10
- package/src/parser/visitor.ts +0 -188
- package/src/planner/analysis/README.md +0 -93
- package/src/planner/analysis/binding-collector.ts +0 -83
- package/src/planner/analysis/const-evaluator.ts +0 -63
- package/src/planner/analysis/const-pass.ts +0 -282
- package/src/planner/analysis/constraint-extractor.ts +0 -764
- package/src/planner/analysis/predicate-normalizer.ts +0 -237
- package/src/planner/building/alter-table.ts +0 -49
- package/src/planner/building/block.ts +0 -93
- package/src/planner/building/constraint-builder.ts +0 -178
- package/src/planner/building/create-assertion.ts +0 -7
- package/src/planner/building/create-view.ts +0 -29
- package/src/planner/building/ddl.ts +0 -24
- package/src/planner/building/declare-schema.ts +0 -22
- package/src/planner/building/delete.ts +0 -218
- package/src/planner/building/drop-assertion.ts +0 -11
- package/src/planner/building/drop-table.ts +0 -13
- package/src/planner/building/drop-view.ts +0 -19
- package/src/planner/building/expression.ts +0 -205
- package/src/planner/building/function-call.ts +0 -129
- package/src/planner/building/insert.ts +0 -435
- package/src/planner/building/pragma.ts +0 -34
- package/src/planner/building/schema-resolution.ts +0 -176
- package/src/planner/building/select-aggregates.ts +0 -318
- package/src/planner/building/select-compound.ts +0 -119
- package/src/planner/building/select-context.ts +0 -85
- package/src/planner/building/select-modifiers.ts +0 -236
- package/src/planner/building/select-projections.ts +0 -177
- package/src/planner/building/select-window.ts +0 -259
- package/src/planner/building/select.ts +0 -567
- package/src/planner/building/table-function.ts +0 -49
- package/src/planner/building/table.ts +0 -40
- package/src/planner/building/transaction.ts +0 -23
- package/src/planner/building/update.ts +0 -331
- package/src/planner/building/with.ts +0 -180
- package/src/planner/cache/correlation-detector.ts +0 -83
- package/src/planner/cache/materialization-advisory.ts +0 -265
- package/src/planner/cache/reference-graph.ts +0 -196
- package/src/planner/cost/index.ts +0 -169
- package/src/planner/debug/logger-utils.ts +0 -68
- package/src/planner/debug.ts +0 -480
- package/src/planner/framework/README.md +0 -132
- package/src/planner/framework/characteristics.ts +0 -503
- package/src/planner/framework/context.ts +0 -239
- package/src/planner/framework/pass.ts +0 -354
- package/src/planner/framework/physical-utils.ts +0 -210
- package/src/planner/framework/registry.ts +0 -261
- package/src/planner/framework/trace.ts +0 -259
- package/src/planner/nodes/add-constraint-node.ts +0 -62
- package/src/planner/nodes/aggregate-function.ts +0 -155
- package/src/planner/nodes/aggregate-node.ts +0 -267
- package/src/planner/nodes/array-index-node.ts +0 -50
- package/src/planner/nodes/block.ts +0 -80
- package/src/planner/nodes/cache-node.ts +0 -103
- package/src/planner/nodes/constraint-check-node.ts +0 -138
- package/src/planner/nodes/create-assertion-node.ts +0 -51
- package/src/planner/nodes/create-index-node.ts +0 -41
- package/src/planner/nodes/create-table-node.ts +0 -35
- package/src/planner/nodes/create-view-node.ts +0 -44
- package/src/planner/nodes/cte-node.ts +0 -168
- package/src/planner/nodes/cte-reference-node.ts +0 -125
- package/src/planner/nodes/declarative-schema.ts +0 -221
- package/src/planner/nodes/delete-node.ts +0 -102
- package/src/planner/nodes/distinct-node.ts +0 -107
- package/src/planner/nodes/dml-executor-node.ts +0 -104
- package/src/planner/nodes/drop-assertion-node.ts +0 -50
- package/src/planner/nodes/drop-table-node.ts +0 -36
- package/src/planner/nodes/drop-view-node.ts +0 -37
- package/src/planner/nodes/filter.ts +0 -144
- package/src/planner/nodes/function.ts +0 -98
- package/src/planner/nodes/insert-node.ts +0 -126
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +0 -61
- package/src/planner/nodes/join-node.ts +0 -336
- package/src/planner/nodes/limit-offset.ts +0 -144
- package/src/planner/nodes/plan-node-type.ts +0 -95
- package/src/planner/nodes/plan-node.ts +0 -503
- package/src/planner/nodes/pragma.ts +0 -98
- package/src/planner/nodes/project-node.ts +0 -337
- package/src/planner/nodes/recursive-cte-node.ts +0 -158
- package/src/planner/nodes/reference.ts +0 -334
- package/src/planner/nodes/remote-query-node.ts +0 -73
- package/src/planner/nodes/retrieve-node.ts +0 -86
- package/src/planner/nodes/returning-node.ts +0 -269
- package/src/planner/nodes/scalar.ts +0 -772
- package/src/planner/nodes/sequencing-node.ts +0 -113
- package/src/planner/nodes/set-operation-node.ts +0 -87
- package/src/planner/nodes/single-row.ts +0 -85
- package/src/planner/nodes/sink-node.ts +0 -61
- package/src/planner/nodes/sort.ts +0 -166
- package/src/planner/nodes/stream-aggregate.ts +0 -293
- package/src/planner/nodes/subquery.ts +0 -268
- package/src/planner/nodes/table-access-nodes.ts +0 -323
- package/src/planner/nodes/table-function-call.ts +0 -134
- package/src/planner/nodes/transaction-node.ts +0 -55
- package/src/planner/nodes/update-node.ts +0 -138
- package/src/planner/nodes/values-node.ts +0 -244
- package/src/planner/nodes/view-reference-node.ts +0 -97
- package/src/planner/nodes/window-function.ts +0 -73
- package/src/planner/nodes/window-node.ts +0 -199
- package/src/planner/optimizer-tuning.ts +0 -105
- package/src/planner/optimizer.ts +0 -332
- package/src/planner/planning-context.ts +0 -190
- package/src/planner/resolve.ts +0 -101
- package/src/planner/rules/README.md +0 -96
- package/src/planner/rules/access/rule-select-access-path.ts +0 -399
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +0 -162
- package/src/planner/rules/cache/rule-cte-optimization.ts +0 -79
- package/src/planner/rules/cache/rule-materialization-advisory.ts +0 -77
- package/src/planner/rules/cache/rule-mutating-subquery-cache.ts +0 -104
- package/src/planner/rules/join/rule-join-greedy-commute.ts +0 -48
- package/src/planner/rules/join/rule-join-key-inference.ts +0 -35
- package/src/planner/rules/join/rule-quickpick-enumeration.ts +0 -267
- package/src/planner/rules/predicate/rule-predicate-pushdown.ts +0 -144
- package/src/planner/rules/retrieve/rule-grow-retrieve.ts +0 -337
- package/src/planner/scopes/aliased.ts +0 -50
- package/src/planner/scopes/base.ts +0 -10
- package/src/planner/scopes/empty.ts +0 -12
- package/src/planner/scopes/global.ts +0 -73
- package/src/planner/scopes/multi.ts +0 -40
- package/src/planner/scopes/param.ts +0 -95
- package/src/planner/scopes/registered.ts +0 -67
- package/src/planner/scopes/scope.ts +0 -16
- package/src/planner/stats/basic-estimates.ts +0 -107
- package/src/planner/stats/index.ts +0 -158
- package/src/planner/type-utils.ts +0 -87
- package/src/planner/util/key-utils.ts +0 -46
- package/src/planner/validation/determinism-validator.ts +0 -104
- package/src/planner/validation/plan-validator.ts +0 -335
- package/src/runtime/async-util.ts +0 -283
- package/src/runtime/cache/shared-cache.ts +0 -169
- package/src/runtime/context-helpers.ts +0 -191
- package/src/runtime/deferred-constraint-queue.ts +0 -196
- package/src/runtime/emission-context.ts +0 -319
- package/src/runtime/emit/add-constraint.ts +0 -78
- package/src/runtime/emit/aggregate.ts +0 -581
- package/src/runtime/emit/array-index.ts +0 -25
- package/src/runtime/emit/between.ts +0 -51
- package/src/runtime/emit/binary.ts +0 -357
- package/src/runtime/emit/block.ts +0 -23
- package/src/runtime/emit/cache.ts +0 -64
- package/src/runtime/emit/case.ts +0 -87
- package/src/runtime/emit/cast.ts +0 -151
- package/src/runtime/emit/collate.ts +0 -9
- package/src/runtime/emit/column-reference.ts +0 -17
- package/src/runtime/emit/constraint-check.ts +0 -290
- package/src/runtime/emit/create-assertion.ts +0 -82
- package/src/runtime/emit/create-index.ts +0 -15
- package/src/runtime/emit/create-table.ts +0 -15
- package/src/runtime/emit/create-view.ts +0 -52
- package/src/runtime/emit/cte-reference.ts +0 -38
- package/src/runtime/emit/cte.ts +0 -39
- package/src/runtime/emit/delete.ts +0 -24
- package/src/runtime/emit/distinct.ts +0 -40
- package/src/runtime/emit/dml-executor.ts +0 -198
- package/src/runtime/emit/drop-assertion.ts +0 -45
- package/src/runtime/emit/drop-table.ts +0 -27
- package/src/runtime/emit/drop-view.ts +0 -49
- package/src/runtime/emit/filter.ts +0 -30
- package/src/runtime/emit/insert.ts +0 -42
- package/src/runtime/emit/internal-recursive-cte-ref.ts +0 -37
- package/src/runtime/emit/join.ts +0 -148
- package/src/runtime/emit/limit-offset.ts +0 -73
- package/src/runtime/emit/literal.ts +0 -17
- package/src/runtime/emit/parameter.ts +0 -59
- package/src/runtime/emit/pragma.ts +0 -56
- package/src/runtime/emit/project.ts +0 -46
- package/src/runtime/emit/recursive-cte.ts +0 -111
- package/src/runtime/emit/remote-query.ts +0 -47
- package/src/runtime/emit/retrieve.ts +0 -15
- package/src/runtime/emit/returning.ts +0 -41
- package/src/runtime/emit/scalar-function.ts +0 -69
- package/src/runtime/emit/scan.ts +0 -106
- package/src/runtime/emit/schema-declarative.ts +0 -215
- package/src/runtime/emit/sequencing.ts +0 -24
- package/src/runtime/emit/set-operation.ts +0 -141
- package/src/runtime/emit/sink.ts +0 -27
- package/src/runtime/emit/sort.ts +0 -75
- package/src/runtime/emit/subquery.ts +0 -203
- package/src/runtime/emit/table-valued-function.ts +0 -106
- package/src/runtime/emit/temporal-arithmetic.ts +0 -302
- package/src/runtime/emit/transaction.ts +0 -205
- package/src/runtime/emit/unary.ts +0 -101
- package/src/runtime/emit/update.ts +0 -66
- package/src/runtime/emit/values.ts +0 -66
- package/src/runtime/emit/window-function.ts +0 -42
- package/src/runtime/emit/window.ts +0 -458
- package/src/runtime/emitters.ts +0 -183
- package/src/runtime/register.ts +0 -150
- package/src/runtime/scheduler.ts +0 -488
- package/src/runtime/types.ts +0 -242
- package/src/runtime/utils.ts +0 -177
- package/src/schema/assertion.ts +0 -21
- package/src/schema/catalog.ts +0 -269
- package/src/schema/change-events.ts +0 -80
- package/src/schema/column.ts +0 -51
- package/src/schema/declared-schema-manager.ts +0 -82
- package/src/schema/function.ts +0 -188
- package/src/schema/manager.ts +0 -1034
- package/src/schema/schema-differ.ts +0 -214
- package/src/schema/schema-hasher.ts +0 -26
- package/src/schema/schema.ts +0 -222
- package/src/schema/table.ts +0 -409
- package/src/schema/view.ts +0 -19
- package/src/schema/window-function.ts +0 -56
- package/src/types/builtin-types.ts +0 -350
- package/src/types/index.ts +0 -17
- package/src/types/json-type.ts +0 -152
- package/src/types/logical-type.ts +0 -91
- package/src/types/plugin-interface.ts +0 -10
- package/src/types/registry.ts +0 -204
- package/src/types/temporal-types.ts +0 -290
- package/src/types/validation.ts +0 -120
- package/src/util/affinity.ts +0 -151
- package/src/util/ast-stringify.ts +0 -887
- package/src/util/cached.ts +0 -25
- package/src/util/coercion.ts +0 -113
- package/src/util/comparison.ts +0 -510
- package/src/util/environment.ts +0 -52
- package/src/util/hash.ts +0 -90
- package/src/util/latches.ts +0 -47
- package/src/util/mutation-statement.ts +0 -135
- package/src/util/patterns.ts +0 -56
- package/src/util/plan-formatter.ts +0 -48
- package/src/util/plugin-helper.ts +0 -110
- package/src/util/row-descriptor.ts +0 -105
- package/src/util/serialization.ts +0 -47
- package/src/util/sql-literal.ts +0 -22
- package/src/util/working-table-iterable.ts +0 -38
- package/src/vtab/best-access-plan.ts +0 -244
- package/src/vtab/connection.ts +0 -36
- package/src/vtab/filter-info.ts +0 -23
- package/src/vtab/index-info.ts +0 -84
- package/src/vtab/manifest.ts +0 -86
- package/src/vtab/memory/connection.ts +0 -73
- package/src/vtab/memory/index.ts +0 -191
- package/src/vtab/memory/layer/base-cursor.ts +0 -124
- package/src/vtab/memory/layer/base.ts +0 -275
- package/src/vtab/memory/layer/connection.ts +0 -203
- package/src/vtab/memory/layer/interface.ts +0 -47
- package/src/vtab/memory/layer/manager.ts +0 -909
- package/src/vtab/memory/layer/safe-iterate.ts +0 -49
- package/src/vtab/memory/layer/scan-plan.ts +0 -84
- package/src/vtab/memory/layer/transaction-cursor.ts +0 -162
- package/src/vtab/memory/layer/transaction.ts +0 -229
- package/src/vtab/memory/module.ts +0 -667
- package/src/vtab/memory/table.ts +0 -251
- package/src/vtab/memory/types.ts +0 -23
- package/src/vtab/memory/utils/logging.ts +0 -36
- package/src/vtab/memory/utils/primary-key.ts +0 -163
- package/src/vtab/module.ts +0 -162
- package/src/vtab/table.ts +0 -177
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
import type * as AST from '../../parser/ast.js';
|
|
2
|
-
import type { PlanningContext } from '../planning-context.js';
|
|
3
|
-
import { InsertNode } from '../nodes/insert-node.js';
|
|
4
|
-
import { buildTableReference } from './table.js';
|
|
5
|
-
import { QuereusError } from '../../common/errors.js';
|
|
6
|
-
import { StatusCode } from '../../common/types.js';
|
|
7
|
-
import { buildSelectStmt } from './select.js';
|
|
8
|
-
import { buildWithClause } from './with.js';
|
|
9
|
-
import { ValuesNode } from '../nodes/values-node.js';
|
|
10
|
-
import { PlanNode, type RelationalPlanNode, type ScalarPlanNode, type Attribute, type RowDescriptor } from '../nodes/plan-node.js';
|
|
11
|
-
import { buildExpression } from './expression.js';
|
|
12
|
-
import { checkColumnsAssignable, columnSchemaToDef } from '../type-utils.js';
|
|
13
|
-
import type { ColumnDef } from '../../common/datatype.js';
|
|
14
|
-
import type { CTEScopeNode } from '../nodes/cte-node.js';
|
|
15
|
-
import { RegisteredScope } from '../scopes/registered.js';
|
|
16
|
-
import { ColumnReferenceNode, TableReferenceNode } from '../nodes/reference.js';
|
|
17
|
-
import { SinkNode } from '../nodes/sink-node.js';
|
|
18
|
-
import { ConstraintCheckNode } from '../nodes/constraint-check-node.js';
|
|
19
|
-
import { RowOpFlag } from '../../schema/table.js';
|
|
20
|
-
import { ReturningNode } from '../nodes/returning-node.js';
|
|
21
|
-
import { ProjectNode, type Projection } from '../nodes/project-node.js';
|
|
22
|
-
import { buildOldNewRowDescriptors } from '../../util/row-descriptor.js';
|
|
23
|
-
import { DmlExecutorNode } from '../nodes/dml-executor-node.js';
|
|
24
|
-
import { buildConstraintChecks } from './constraint-builder.js';
|
|
25
|
-
import { validateDeterministicDefault } from '../validation/determinism-validator.js';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Creates a uniform row expansion projection that maps any relational source
|
|
29
|
-
* to the target table's column structure, filling in defaults for omitted columns.
|
|
30
|
-
* This ensures INSERT works orthogonally with any relational source.
|
|
31
|
-
*/
|
|
32
|
-
function createRowExpansionProjection(
|
|
33
|
-
ctx: PlanningContext,
|
|
34
|
-
sourceNode: RelationalPlanNode,
|
|
35
|
-
targetColumns: ColumnDef[],
|
|
36
|
-
tableReference: TableReferenceNode,
|
|
37
|
-
contextScope?: RegisteredScope
|
|
38
|
-
): RelationalPlanNode {
|
|
39
|
-
const tableSchema = tableReference.tableSchema;
|
|
40
|
-
|
|
41
|
-
// If we're inserting into all columns in table order, no expansion needed
|
|
42
|
-
if (targetColumns.length === tableSchema.columns.length) {
|
|
43
|
-
const allColumnsMatch = targetColumns.every((tc, i) =>
|
|
44
|
-
tc.name.toLowerCase() === tableSchema.columns[i].name.toLowerCase()
|
|
45
|
-
);
|
|
46
|
-
if (allColumnsMatch) {
|
|
47
|
-
return sourceNode; // Source already matches table structure
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Create projection expressions for each table column
|
|
52
|
-
const projections: Projection[] = [];
|
|
53
|
-
const sourceAttributes = sourceNode.getAttributes();
|
|
54
|
-
|
|
55
|
-
// If we have a context scope, we need to also register source columns in it
|
|
56
|
-
// so that defaults can reference them (e.g., DEFAULT base_price + markup)
|
|
57
|
-
if (contextScope) {
|
|
58
|
-
targetColumns.forEach((targetCol, index) => {
|
|
59
|
-
if (index < sourceAttributes.length) {
|
|
60
|
-
const sourceAttr = sourceAttributes[index];
|
|
61
|
-
const colNameLower = targetCol.name.toLowerCase();
|
|
62
|
-
contextScope.registerSymbol(colNameLower, (exp, s) =>
|
|
63
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, sourceAttr.type, sourceAttr.id, index)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
tableSchema.columns.forEach((tableColumn) => {
|
|
70
|
-
// Find if this table column is in the target columns
|
|
71
|
-
const targetColIndex = targetColumns.findIndex(tc =>
|
|
72
|
-
tc.name.toLowerCase() === tableColumn.name.toLowerCase()
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
if (targetColIndex >= 0) {
|
|
76
|
-
// This column is provided by the source - reference the source column
|
|
77
|
-
if (targetColIndex < sourceAttributes.length) {
|
|
78
|
-
const sourceAttr = sourceAttributes[targetColIndex];
|
|
79
|
-
// Create a column reference to the source attribute
|
|
80
|
-
const columnRef = new ColumnReferenceNode(
|
|
81
|
-
ctx.scope,
|
|
82
|
-
{ type: 'column', name: sourceAttr.name } satisfies AST.ColumnExpr,
|
|
83
|
-
sourceAttr.type,
|
|
84
|
-
sourceAttr.id,
|
|
85
|
-
targetColIndex
|
|
86
|
-
);
|
|
87
|
-
projections.push({
|
|
88
|
-
node: columnRef,
|
|
89
|
-
alias: tableColumn.name
|
|
90
|
-
});
|
|
91
|
-
} else {
|
|
92
|
-
throw new QuereusError(
|
|
93
|
-
`Source has fewer columns than expected for INSERT target columns`,
|
|
94
|
-
StatusCode.ERROR
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
// This column is omitted - use default value or NULL
|
|
99
|
-
let defaultNode: ScalarPlanNode;
|
|
100
|
-
// Use context scope for default evaluation if available
|
|
101
|
-
const defaultCtx = contextScope ? { ...ctx, scope: contextScope } : ctx;
|
|
102
|
-
if (tableColumn.defaultValue !== undefined) {
|
|
103
|
-
// Use default value
|
|
104
|
-
if (typeof tableColumn.defaultValue === 'object' && tableColumn.defaultValue !== null && 'type' in tableColumn.defaultValue) {
|
|
105
|
-
// It's an AST.Expression - build it into a plan node with context scope
|
|
106
|
-
defaultNode = buildExpression(defaultCtx, tableColumn.defaultValue as AST.Expression) as ScalarPlanNode;
|
|
107
|
-
|
|
108
|
-
// Validate that the default expression is deterministic
|
|
109
|
-
validateDeterministicDefault(defaultNode, tableColumn.name, tableSchema.name);
|
|
110
|
-
} else {
|
|
111
|
-
// Literal default value
|
|
112
|
-
defaultNode = buildExpression(defaultCtx, { type: 'literal', value: tableColumn.defaultValue }) as ScalarPlanNode;
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
// No default value - use NULL
|
|
116
|
-
defaultNode = buildExpression(defaultCtx, { type: 'literal', value: null }) as ScalarPlanNode;
|
|
117
|
-
}
|
|
118
|
-
projections.push({
|
|
119
|
-
node: defaultNode,
|
|
120
|
-
alias: tableColumn.name
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Create projection node that expands source to table structure
|
|
126
|
-
return new ProjectNode(ctx.scope, sourceNode, projections);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Validates that RETURNING expressions use appropriate NEW/OLD qualifiers for the operation type
|
|
131
|
-
*/
|
|
132
|
-
function validateReturningExpression(expr: AST.Expression, operationType: 'INSERT' | 'UPDATE' | 'DELETE'): void {
|
|
133
|
-
function checkExpression(e: AST.Expression): void {
|
|
134
|
-
if (e.type === 'column') {
|
|
135
|
-
if (e.table?.toLowerCase() === 'old' && operationType === 'INSERT') {
|
|
136
|
-
throw new QuereusError(
|
|
137
|
-
'OLD qualifier cannot be used in INSERT RETURNING clause',
|
|
138
|
-
StatusCode.ERROR
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
if (e.table?.toLowerCase() === 'new' && operationType === 'DELETE') {
|
|
142
|
-
throw new QuereusError(
|
|
143
|
-
'NEW qualifier cannot be used in DELETE RETURNING clause',
|
|
144
|
-
StatusCode.ERROR
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
} else if (e.type === 'binary') {
|
|
148
|
-
checkExpression(e.left);
|
|
149
|
-
checkExpression(e.right);
|
|
150
|
-
} else if (e.type === 'unary') {
|
|
151
|
-
checkExpression(e.expr);
|
|
152
|
-
} else if (e.type === 'function') {
|
|
153
|
-
e.args.forEach(checkExpression);
|
|
154
|
-
} else if (e.type === 'case') {
|
|
155
|
-
if (e.baseExpr) checkExpression(e.baseExpr);
|
|
156
|
-
e.whenThenClauses.forEach(clause => {
|
|
157
|
-
checkExpression(clause.when);
|
|
158
|
-
checkExpression(clause.then);
|
|
159
|
-
});
|
|
160
|
-
if (e.elseExpr) checkExpression(e.elseExpr);
|
|
161
|
-
} else if (e.type === 'cast') {
|
|
162
|
-
checkExpression(e.expr);
|
|
163
|
-
} else if (e.type === 'collate') {
|
|
164
|
-
checkExpression(e.expr);
|
|
165
|
-
} else if (e.type === 'subquery') {
|
|
166
|
-
// Subqueries in RETURNING are complex - for now, we'll skip validation
|
|
167
|
-
// A full implementation would need to traverse the subquery's AST
|
|
168
|
-
} else if (e.type === 'in') {
|
|
169
|
-
checkExpression(e.expr);
|
|
170
|
-
if (e.values) {
|
|
171
|
-
e.values.forEach(checkExpression);
|
|
172
|
-
}
|
|
173
|
-
} else if (e.type === 'exists') {
|
|
174
|
-
// EXISTS subqueries are complex - skip validation for now
|
|
175
|
-
} else if (e.type === 'windowFunction') {
|
|
176
|
-
checkExpression(e.function);
|
|
177
|
-
}
|
|
178
|
-
// Other expression types (literal, parameter) don't need validation
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
checkExpression(expr);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export function buildInsertStmt(
|
|
185
|
-
ctx: PlanningContext,
|
|
186
|
-
stmt: AST.InsertStmt,
|
|
187
|
-
): PlanNode {
|
|
188
|
-
const tableRetrieve = buildTableReference({ type: 'table', table: stmt.table }, ctx);
|
|
189
|
-
const tableReference = tableRetrieve.tableRef; // Extract the actual TableReferenceNode
|
|
190
|
-
|
|
191
|
-
// Process mutation context assignments if present
|
|
192
|
-
const mutationContextValues = new Map<string, ScalarPlanNode>();
|
|
193
|
-
const contextAttributes: Attribute[] = [];
|
|
194
|
-
let contextScope: RegisteredScope | undefined;
|
|
195
|
-
|
|
196
|
-
if (stmt.contextValues && tableReference.tableSchema.mutationContext) {
|
|
197
|
-
// Create context attributes
|
|
198
|
-
tableReference.tableSchema.mutationContext.forEach((contextVar) => {
|
|
199
|
-
contextAttributes.push({
|
|
200
|
-
id: PlanNode.nextAttrId(),
|
|
201
|
-
name: contextVar.name,
|
|
202
|
-
type: {
|
|
203
|
-
typeClass: 'scalar' as const,
|
|
204
|
-
logicalType: contextVar.logicalType,
|
|
205
|
-
nullable: !contextVar.notNull,
|
|
206
|
-
isReadOnly: true
|
|
207
|
-
},
|
|
208
|
-
sourceRelation: `context.${tableReference.tableSchema.name}`
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// Create a new scope for mutation context
|
|
213
|
-
contextScope = new RegisteredScope(ctx.scope);
|
|
214
|
-
|
|
215
|
-
// Register mutation context variables in the scope (before evaluating expressions)
|
|
216
|
-
contextAttributes.forEach((attr, index) => {
|
|
217
|
-
const contextVar = tableReference.tableSchema.mutationContext![index];
|
|
218
|
-
const varNameLower = contextVar.name.toLowerCase();
|
|
219
|
-
|
|
220
|
-
// Register both unqualified and qualified names
|
|
221
|
-
contextScope!.subscribeFactory(varNameLower, (exp, s) =>
|
|
222
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, index)
|
|
223
|
-
);
|
|
224
|
-
contextScope!.subscribeFactory(`context.${varNameLower}`, (exp, s) =>
|
|
225
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, index)
|
|
226
|
-
);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
// Build context value expressions using the context scope
|
|
230
|
-
const contextWithScope = { ...ctx, scope: contextScope };
|
|
231
|
-
stmt.contextValues.forEach((assignment) => {
|
|
232
|
-
const valueExpr = buildExpression(contextWithScope, assignment.value) as ScalarPlanNode;
|
|
233
|
-
mutationContextValues.set(assignment.name, valueExpr);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
let targetColumns: ColumnDef[] = [];
|
|
238
|
-
if (stmt.columns && stmt.columns.length > 0) {
|
|
239
|
-
// Explicit columns specified
|
|
240
|
-
targetColumns = stmt.columns.map((colName, index) => columnSchemaToDef(colName, tableReference.tableSchema.columns[index]));
|
|
241
|
-
} else {
|
|
242
|
-
// No explicit columns - default to all table columns in order
|
|
243
|
-
targetColumns = tableReference.tableSchema.columns.map(col => columnSchemaToDef(col.name, col));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
let sourceNode: RelationalPlanNode;
|
|
247
|
-
|
|
248
|
-
if (stmt.values) {
|
|
249
|
-
// VALUES clause - build the VALUES node
|
|
250
|
-
const rows = stmt.values.map(rowExprs =>
|
|
251
|
-
rowExprs.map(expr => buildExpression(ctx, expr) as PlanNode as ScalarPlanNode)
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
// Check that there are the right number of columns in each row
|
|
255
|
-
rows.forEach(row => {
|
|
256
|
-
if (row.length !== targetColumns.length) {
|
|
257
|
-
throw new QuereusError(`Column count mismatch in VALUES clause. Expected ${targetColumns.length} columns, got ${row.length}.`, StatusCode.ERROR, undefined, stmt.loc?.start.line, stmt.loc?.start.column);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// Create VALUES node with target column names
|
|
262
|
-
const targetColumnNames = targetColumns.map(col => col.name);
|
|
263
|
-
sourceNode = new ValuesNode(ctx.scope, rows, targetColumnNames);
|
|
264
|
-
|
|
265
|
-
} else if (stmt.select) {
|
|
266
|
-
// SELECT clause - build the SELECT statement
|
|
267
|
-
let parentCtes: Map<string, CTEScopeNode> = new Map();
|
|
268
|
-
if (stmt.withClause) {
|
|
269
|
-
parentCtes = buildWithClause(ctx, stmt.withClause);
|
|
270
|
-
}
|
|
271
|
-
const selectPlan = buildSelectStmt(ctx, stmt.select, parentCtes);
|
|
272
|
-
if (selectPlan.getType().typeClass !== 'relation') {
|
|
273
|
-
throw new QuereusError('SELECT statement in INSERT did not produce a relational plan.', StatusCode.INTERNAL, undefined, stmt.loc?.start.line, stmt.loc?.start.column);
|
|
274
|
-
}
|
|
275
|
-
sourceNode = selectPlan as RelationalPlanNode;
|
|
276
|
-
checkColumnsAssignable(sourceNode.getType().columns, targetColumns, stmt);
|
|
277
|
-
|
|
278
|
-
} else {
|
|
279
|
-
throw new QuereusError('INSERT statement must have a VALUES clause or a SELECT query.', StatusCode.ERROR);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// ORTHOGONAL ROW EXPANSION: Apply uniform row expansion to map any source to table structure with defaults
|
|
283
|
-
const expandedSourceNode = createRowExpansionProjection(ctx, sourceNode, targetColumns, tableReference, contextScope);
|
|
284
|
-
|
|
285
|
-
// Update targetColumns to reflect all table columns since we've expanded the source
|
|
286
|
-
const finalTargetColumns = tableReference.tableSchema.columns.map(col => columnSchemaToDef(col.name, col));
|
|
287
|
-
|
|
288
|
-
// Create OLD/NEW attributes for INSERT (OLD = all NULL, NEW = actual values)
|
|
289
|
-
const oldAttributes = tableReference.tableSchema.columns.map((col) => ({
|
|
290
|
-
id: PlanNode.nextAttrId(),
|
|
291
|
-
name: col.name,
|
|
292
|
-
type: {
|
|
293
|
-
typeClass: 'scalar' as const,
|
|
294
|
-
logicalType: col.logicalType,
|
|
295
|
-
nullable: true, // OLD values are always NULL for INSERT
|
|
296
|
-
isReadOnly: false
|
|
297
|
-
},
|
|
298
|
-
sourceRelation: `OLD.${tableReference.tableSchema.name}`
|
|
299
|
-
}));
|
|
300
|
-
|
|
301
|
-
const newAttributes = tableReference.tableSchema.columns.map((col) => ({
|
|
302
|
-
id: PlanNode.nextAttrId(),
|
|
303
|
-
name: col.name,
|
|
304
|
-
type: {
|
|
305
|
-
typeClass: 'scalar' as const,
|
|
306
|
-
logicalType: col.logicalType,
|
|
307
|
-
nullable: !col.notNull,
|
|
308
|
-
isReadOnly: false
|
|
309
|
-
},
|
|
310
|
-
sourceRelation: `NEW.${tableReference.tableSchema.name}`
|
|
311
|
-
}));
|
|
312
|
-
|
|
313
|
-
const { oldRowDescriptor, newRowDescriptor, flatRowDescriptor } = buildOldNewRowDescriptors(oldAttributes, newAttributes);
|
|
314
|
-
|
|
315
|
-
// Build context descriptor if we have context attributes
|
|
316
|
-
const contextDescriptor: RowDescriptor = contextAttributes.length > 0 ? [] : undefined as any;
|
|
317
|
-
if (contextDescriptor) {
|
|
318
|
-
contextAttributes.forEach((attr, index) => {
|
|
319
|
-
contextDescriptor[attr.id] = index;
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Build constraint checks at plan time
|
|
324
|
-
const constraintChecks = buildConstraintChecks(
|
|
325
|
-
ctx,
|
|
326
|
-
tableReference.tableSchema,
|
|
327
|
-
RowOpFlag.INSERT,
|
|
328
|
-
oldAttributes,
|
|
329
|
-
newAttributes,
|
|
330
|
-
flatRowDescriptor,
|
|
331
|
-
contextAttributes
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
const insertNode = new InsertNode(
|
|
335
|
-
ctx.scope,
|
|
336
|
-
tableReference,
|
|
337
|
-
finalTargetColumns,
|
|
338
|
-
expandedSourceNode,
|
|
339
|
-
flatRowDescriptor,
|
|
340
|
-
mutationContextValues.size > 0 ? mutationContextValues : undefined,
|
|
341
|
-
contextAttributes.length > 0 ? contextAttributes : undefined,
|
|
342
|
-
contextDescriptor
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
const constraintCheckNode = new ConstraintCheckNode(
|
|
346
|
-
ctx.scope,
|
|
347
|
-
insertNode,
|
|
348
|
-
tableReference,
|
|
349
|
-
RowOpFlag.INSERT,
|
|
350
|
-
oldRowDescriptor,
|
|
351
|
-
newRowDescriptor,
|
|
352
|
-
flatRowDescriptor,
|
|
353
|
-
constraintChecks,
|
|
354
|
-
mutationContextValues.size > 0 ? mutationContextValues : undefined,
|
|
355
|
-
contextAttributes.length > 0 ? contextAttributes : undefined,
|
|
356
|
-
contextDescriptor
|
|
357
|
-
);
|
|
358
|
-
|
|
359
|
-
// Add DML executor node to perform the actual database insert operations
|
|
360
|
-
const dmlExecutorNode = new DmlExecutorNode(
|
|
361
|
-
ctx.scope,
|
|
362
|
-
constraintCheckNode,
|
|
363
|
-
tableReference,
|
|
364
|
-
'insert',
|
|
365
|
-
stmt.onConflict,
|
|
366
|
-
mutationContextValues.size > 0 ? mutationContextValues : undefined,
|
|
367
|
-
contextAttributes.length > 0 ? contextAttributes : undefined,
|
|
368
|
-
contextDescriptor
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
const resultNode: RelationalPlanNode = dmlExecutorNode;
|
|
372
|
-
|
|
373
|
-
if (stmt.returning && stmt.returning.length > 0) {
|
|
374
|
-
// Create returning scope with OLD/NEW attribute access
|
|
375
|
-
const returningScope = new RegisteredScope(ctx.scope);
|
|
376
|
-
|
|
377
|
-
// Register OLD.* symbols (always NULL for INSERT)
|
|
378
|
-
oldAttributes.forEach((attr, columnIndex) => {
|
|
379
|
-
const tableColumn = tableReference.tableSchema.columns[columnIndex];
|
|
380
|
-
returningScope.registerSymbol(`old.${tableColumn.name.toLowerCase()}`, (exp, s) =>
|
|
381
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, columnIndex)
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// Register NEW.* symbols and unqualified column names (default to NEW)
|
|
386
|
-
newAttributes.forEach((attr, columnIndex) => {
|
|
387
|
-
const tableColumn = tableReference.tableSchema.columns[columnIndex];
|
|
388
|
-
|
|
389
|
-
// NEW.column
|
|
390
|
-
returningScope.registerSymbol(`new.${tableColumn.name.toLowerCase()}`, (exp, s) =>
|
|
391
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, columnIndex)
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
// Unqualified column (defaults to NEW)
|
|
395
|
-
returningScope.registerSymbol(tableColumn.name.toLowerCase(), (exp, s) =>
|
|
396
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, columnIndex)
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
// Table-qualified form (table.column -> NEW)
|
|
400
|
-
const tblQualified = `${tableReference.tableSchema.name.toLowerCase()}.${tableColumn.name.toLowerCase()}`;
|
|
401
|
-
returningScope.registerSymbol(tblQualified, (exp, s) =>
|
|
402
|
-
new ColumnReferenceNode(s, exp as AST.ColumnExpr, attr.type, attr.id, columnIndex)
|
|
403
|
-
);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
// Build RETURNING projections in the OLD/NEW context
|
|
407
|
-
const returningProjections = stmt.returning.map(rc => {
|
|
408
|
-
// TODO: Support RETURNING *
|
|
409
|
-
if (rc.type === 'all') throw new QuereusError('RETURNING * not yet supported', StatusCode.UNSUPPORTED);
|
|
410
|
-
|
|
411
|
-
// Infer alias from column name if not explicitly provided
|
|
412
|
-
let alias = rc.alias;
|
|
413
|
-
if (!alias && rc.expr.type === 'column') {
|
|
414
|
-
// For qualified column references like NEW.id, normalize to lowercase
|
|
415
|
-
if (rc.expr.table) {
|
|
416
|
-
alias = `${rc.expr.table.toLowerCase()}.${rc.expr.name.toLowerCase()}`;
|
|
417
|
-
} else {
|
|
418
|
-
alias = rc.expr.name.toLowerCase();
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// Validate that OLD references are not used in INSERT RETURNING
|
|
423
|
-
validateReturningExpression(rc.expr, 'INSERT');
|
|
424
|
-
|
|
425
|
-
return {
|
|
426
|
-
node: buildExpression({ ...ctx, scope: returningScope }, rc.expr) as ScalarPlanNode,
|
|
427
|
-
alias: alias
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
return new ReturningNode(ctx.scope, dmlExecutorNode, returningProjections);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return new SinkNode(ctx.scope, resultNode, 'insert');
|
|
435
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { PlanningContext } from '../planning-context.js';
|
|
2
|
-
import * as AST from '../../parser/ast.js';
|
|
3
|
-
import { QuereusError } from '../../common/errors.js';
|
|
4
|
-
import { StatusCode, type SqlValue } from '../../common/types.js';
|
|
5
|
-
import { PragmaPlanNode } from '../nodes/pragma.js';
|
|
6
|
-
import { SinkNode } from '../nodes/sink-node.js';
|
|
7
|
-
import { getSyncLiteral } from '../../parser/utils.js';
|
|
8
|
-
import type { PlanNode } from '../nodes/plan-node.js';
|
|
9
|
-
|
|
10
|
-
export function buildPragmaStmt(ctx: PlanningContext, stmt: AST.PragmaStmt): PlanNode {
|
|
11
|
-
const pragmaName = stmt.name.toLowerCase();
|
|
12
|
-
|
|
13
|
-
let value: SqlValue | undefined;
|
|
14
|
-
if (stmt.value) {
|
|
15
|
-
if (stmt.value.type === 'literal') {
|
|
16
|
-
value = getSyncLiteral(stmt.value);
|
|
17
|
-
} else if (stmt.value.type === 'identifier') {
|
|
18
|
-
value = stmt.value.name;
|
|
19
|
-
} else {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
throw new QuereusError(`Unsupported PRAGMA value type: ${(stmt.value as any).type}`, StatusCode.ERROR);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const pragmaNode = new PragmaPlanNode(ctx.scope, pragmaName, stmt, value);
|
|
26
|
-
|
|
27
|
-
// If this is a setting operation (has a value), wrap with SinkNode to ensure execution
|
|
28
|
-
if (value !== undefined) {
|
|
29
|
-
return new SinkNode(ctx.scope, pragmaNode, 'pragma-set');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Reading operation - return the PRAGMA node directly
|
|
33
|
-
return pragmaNode;
|
|
34
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import type { PlanningContext, SchemaDependency } from '../planning-context.js';
|
|
2
|
-
import type { TableSchema } from '../../schema/table.js';
|
|
3
|
-
import type { FunctionSchema } from '../../schema/function.js';
|
|
4
|
-
import type { AnyVirtualTableModule } from '../../vtab/module.js';
|
|
5
|
-
import type { CollationFunction } from '../../util/comparison.js';
|
|
6
|
-
import { QuereusError } from '../../common/errors.js';
|
|
7
|
-
import { StatusCode } from '../../common/types.js';
|
|
8
|
-
import { createLogger } from '../../common/logger.js';
|
|
9
|
-
|
|
10
|
-
const log = createLogger('planner:schema-resolution');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Resolves a table schema at build time and records the dependency.
|
|
14
|
-
*/
|
|
15
|
-
export function resolveTableSchema(
|
|
16
|
-
ctx: PlanningContext,
|
|
17
|
-
tableName: string,
|
|
18
|
-
schemaName?: string
|
|
19
|
-
): TableSchema {
|
|
20
|
-
const resolvedSchemaName = schemaName || ctx.db.schemaManager.getCurrentSchemaName();
|
|
21
|
-
const cacheKey = `table:${resolvedSchemaName}:${tableName}`;
|
|
22
|
-
|
|
23
|
-
// Check cache first
|
|
24
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
25
|
-
if (cached) {
|
|
26
|
-
log('Using cached table schema: %s.%s', resolvedSchemaName, tableName);
|
|
27
|
-
return cached as TableSchema;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Resolve table schema
|
|
31
|
-
const tableSchema = ctx.schemaManager.findTable(tableName, resolvedSchemaName);
|
|
32
|
-
if (!tableSchema) {
|
|
33
|
-
throw new QuereusError(
|
|
34
|
-
`Table not found: ${resolvedSchemaName}.${tableName}`,
|
|
35
|
-
StatusCode.ERROR
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Record dependency
|
|
40
|
-
const dependency: SchemaDependency = {
|
|
41
|
-
type: 'table',
|
|
42
|
-
schemaName: tableSchema.schemaName,
|
|
43
|
-
objectName: tableSchema.name
|
|
44
|
-
};
|
|
45
|
-
ctx.schemaDependencies.recordDependency(dependency, tableSchema);
|
|
46
|
-
|
|
47
|
-
// Cache result
|
|
48
|
-
ctx.schemaCache.set(cacheKey, tableSchema);
|
|
49
|
-
|
|
50
|
-
log('Resolved table schema: %s.%s', tableSchema.schemaName, tableSchema.name);
|
|
51
|
-
return tableSchema;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Resolves a function schema at build time and records the dependency.
|
|
56
|
-
*/
|
|
57
|
-
export function resolveFunctionSchema(
|
|
58
|
-
ctx: PlanningContext,
|
|
59
|
-
funcName: string,
|
|
60
|
-
numArgs: number
|
|
61
|
-
): FunctionSchema {
|
|
62
|
-
const cacheKey = `function:${funcName}/${numArgs}`;
|
|
63
|
-
|
|
64
|
-
// Check cache first
|
|
65
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
66
|
-
if (cached) {
|
|
67
|
-
log('Using cached function schema: %s/%d', funcName, numArgs);
|
|
68
|
-
return cached as FunctionSchema;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Resolve function schema - try exact match first
|
|
72
|
-
let functionSchema = ctx.schemaManager.findFunction(funcName, numArgs);
|
|
73
|
-
|
|
74
|
-
// If not found, try variable argument function
|
|
75
|
-
if (!functionSchema) {
|
|
76
|
-
functionSchema = ctx.schemaManager.findFunction(funcName, -1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!functionSchema) {
|
|
80
|
-
throw new QuereusError(
|
|
81
|
-
`Function not found: ${funcName}/${numArgs}`,
|
|
82
|
-
StatusCode.ERROR
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Record dependency using the actual function's numArgs
|
|
87
|
-
const dependency: SchemaDependency = {
|
|
88
|
-
type: 'function',
|
|
89
|
-
objectName: `${functionSchema.name}/${functionSchema.numArgs}`
|
|
90
|
-
};
|
|
91
|
-
ctx.schemaDependencies.recordDependency(dependency, functionSchema);
|
|
92
|
-
|
|
93
|
-
// Cache result with the requested key for future lookups
|
|
94
|
-
ctx.schemaCache.set(cacheKey, functionSchema);
|
|
95
|
-
|
|
96
|
-
log('Resolved function schema: %s/%d', functionSchema.name, functionSchema.numArgs);
|
|
97
|
-
return functionSchema;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Resolves a virtual table module at build time and records the dependency.
|
|
102
|
-
*/
|
|
103
|
-
export function resolveVtabModule(
|
|
104
|
-
ctx: PlanningContext,
|
|
105
|
-
moduleName: string
|
|
106
|
-
): { module: AnyVirtualTableModule, auxData?: unknown } {
|
|
107
|
-
const cacheKey = `vtab_module:${moduleName}`;
|
|
108
|
-
|
|
109
|
-
// Check cache first
|
|
110
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
111
|
-
if (cached) {
|
|
112
|
-
log('Using cached vtab module: %s', moduleName);
|
|
113
|
-
return cached;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Resolve vtab module
|
|
117
|
-
const moduleInfo = ctx.schemaManager.getModule(moduleName);
|
|
118
|
-
if (!moduleInfo) {
|
|
119
|
-
throw new QuereusError(
|
|
120
|
-
`Virtual table module not found: ${moduleName}`,
|
|
121
|
-
StatusCode.ERROR
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Record dependency
|
|
126
|
-
const dependency: SchemaDependency = {
|
|
127
|
-
type: 'vtab_module',
|
|
128
|
-
objectName: moduleName
|
|
129
|
-
};
|
|
130
|
-
ctx.schemaDependencies.recordDependency(dependency, moduleInfo);
|
|
131
|
-
|
|
132
|
-
// Cache result
|
|
133
|
-
ctx.schemaCache.set(cacheKey, moduleInfo);
|
|
134
|
-
|
|
135
|
-
log('Resolved vtab module: %s', moduleName);
|
|
136
|
-
return moduleInfo;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Resolves a collation function at build time and records the dependency.
|
|
141
|
-
*/
|
|
142
|
-
export function resolveCollation(
|
|
143
|
-
ctx: PlanningContext,
|
|
144
|
-
collationName: string
|
|
145
|
-
): CollationFunction {
|
|
146
|
-
const cacheKey = `collation:${collationName}`;
|
|
147
|
-
|
|
148
|
-
// Check cache first
|
|
149
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
150
|
-
if (cached) {
|
|
151
|
-
log('Using cached collation: %s', collationName);
|
|
152
|
-
return cached as CollationFunction;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Resolve collation
|
|
156
|
-
const collation = ctx.db._getCollation(collationName);
|
|
157
|
-
if (!collation) {
|
|
158
|
-
throw new QuereusError(
|
|
159
|
-
`Collation not found: ${collationName}`,
|
|
160
|
-
StatusCode.ERROR
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Record dependency
|
|
165
|
-
const dependency: SchemaDependency = {
|
|
166
|
-
type: 'collation',
|
|
167
|
-
objectName: collationName
|
|
168
|
-
};
|
|
169
|
-
ctx.schemaDependencies.recordDependency(dependency, collation);
|
|
170
|
-
|
|
171
|
-
// Cache result
|
|
172
|
-
ctx.schemaCache.set(cacheKey, collation);
|
|
173
|
-
|
|
174
|
-
log('Resolved collation: %s', collationName);
|
|
175
|
-
return collation;
|
|
176
|
-
}
|