@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
package/src/util/hash.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hash and encoding utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Computes FNV-1a hash of a string (64-bit variant)
|
|
7
|
-
* Returns an 8-byte array representing the hash
|
|
8
|
-
*
|
|
9
|
-
* FNV-1a is a fast, non-cryptographic hash function with good distribution.
|
|
10
|
-
* See: http://www.isthe.com/chongo/tech/comp/fnv/
|
|
11
|
-
*/
|
|
12
|
-
export function fnv1aHash(str: string): Uint8Array {
|
|
13
|
-
// FNV-1a 64-bit parameters
|
|
14
|
-
// Using two 32-bit integers to represent 64-bit hash (JavaScript limitation)
|
|
15
|
-
let hashHigh = 0xcbf29ce4; // Upper 32 bits of FNV offset basis
|
|
16
|
-
let hashLow = 0x84222325; // Lower 32 bits of FNV offset basis
|
|
17
|
-
|
|
18
|
-
const fnvPrimeHigh = 0x00000100; // Upper 32 bits of FNV prime
|
|
19
|
-
const fnvPrimeLow = 0x000001b3; // Lower 32 bits of FNV prime
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < str.length; i++) {
|
|
22
|
-
const charCode = str.charCodeAt(i);
|
|
23
|
-
|
|
24
|
-
// XOR with byte (handle multi-byte characters)
|
|
25
|
-
hashLow ^= charCode & 0xff;
|
|
26
|
-
|
|
27
|
-
// Multiply by FNV prime (64-bit multiplication using 32-bit parts)
|
|
28
|
-
const aHigh = hashHigh;
|
|
29
|
-
const aLow = hashLow;
|
|
30
|
-
|
|
31
|
-
hashLow = (aLow * fnvPrimeLow) >>> 0;
|
|
32
|
-
hashHigh = (aHigh * fnvPrimeLow + aLow * fnvPrimeHigh + (hashLow / 0x100000000)) >>> 0;
|
|
33
|
-
hashLow = hashLow >>> 0;
|
|
34
|
-
|
|
35
|
-
// Handle high byte of character if present
|
|
36
|
-
if (charCode > 0xff) {
|
|
37
|
-
hashLow ^= (charCode >>> 8) & 0xff;
|
|
38
|
-
const bHigh = hashHigh;
|
|
39
|
-
const bLow = hashLow;
|
|
40
|
-
hashLow = (bLow * fnvPrimeLow) >>> 0;
|
|
41
|
-
hashHigh = (bHigh * fnvPrimeLow + bLow * fnvPrimeHigh + (hashLow / 0x100000000)) >>> 0;
|
|
42
|
-
hashLow = hashLow >>> 0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Convert to 8-byte array
|
|
47
|
-
const bytes = new Uint8Array(8);
|
|
48
|
-
bytes[0] = (hashHigh >>> 24) & 0xff;
|
|
49
|
-
bytes[1] = (hashHigh >>> 16) & 0xff;
|
|
50
|
-
bytes[2] = (hashHigh >>> 8) & 0xff;
|
|
51
|
-
bytes[3] = hashHigh & 0xff;
|
|
52
|
-
bytes[4] = (hashLow >>> 24) & 0xff;
|
|
53
|
-
bytes[5] = (hashLow >>> 16) & 0xff;
|
|
54
|
-
bytes[6] = (hashLow >>> 8) & 0xff;
|
|
55
|
-
bytes[7] = hashLow & 0xff;
|
|
56
|
-
|
|
57
|
-
return bytes;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Converts a byte array to base64url encoding
|
|
62
|
-
* (URL-safe base64 without padding: uses - and _ instead of + and /, no = padding)
|
|
63
|
-
*
|
|
64
|
-
* Base64url is defined in RFC 4648 Section 5.
|
|
65
|
-
*/
|
|
66
|
-
export function toBase64Url(bytes: Uint8Array): string {
|
|
67
|
-
const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
68
|
-
let result = '';
|
|
69
|
-
|
|
70
|
-
for (let i = 0; i < bytes.length; i += 3) {
|
|
71
|
-
// Get 3 bytes (24 bits) and convert to 4 base64 characters (6 bits each)
|
|
72
|
-
const byte1 = bytes[i];
|
|
73
|
-
const byte2 = i + 1 < bytes.length ? bytes[i + 1] : 0;
|
|
74
|
-
const byte3 = i + 2 < bytes.length ? bytes[i + 2] : 0;
|
|
75
|
-
|
|
76
|
-
const triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
|
77
|
-
|
|
78
|
-
result += base64Chars[(triplet >>> 18) & 0x3f];
|
|
79
|
-
result += base64Chars[(triplet >>> 12) & 0x3f];
|
|
80
|
-
if (i + 1 < bytes.length) {
|
|
81
|
-
result += base64Chars[(triplet >>> 6) & 0x3f];
|
|
82
|
-
}
|
|
83
|
-
if (i + 2 < bytes.length) {
|
|
84
|
-
result += base64Chars[triplet & 0x3f];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
|
package/src/util/latches.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight implementation of a mutex lock queue for managing concurrent access.
|
|
3
|
-
*/
|
|
4
|
-
export class Latches {
|
|
5
|
-
// Stores the promise representing the completion of the last queued operation for a key.
|
|
6
|
-
private static lockQueues = new Map<string, Promise<void>>();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Acquires a lock for the given key. Waits if another operation holds the lock.
|
|
10
|
-
* Returns a release function that must be called to release the lock.
|
|
11
|
-
*
|
|
12
|
-
* @param key A unique string identifier for the resource to lock.
|
|
13
|
-
* Should use `ClassName.methodName:${id}` format to avoid conflicts.
|
|
14
|
-
* @returns A function that must be called to release the lock
|
|
15
|
-
*/
|
|
16
|
-
static async acquire(key: string): Promise<() => void> {
|
|
17
|
-
// Get the promise the current operation needs to wait for (if any)
|
|
18
|
-
const currentTail = this.lockQueues.get(key) ?? Promise.resolve();
|
|
19
|
-
|
|
20
|
-
let resolveNewTail!: () => void;
|
|
21
|
-
// Create the promise that the *next* operation will wait for
|
|
22
|
-
const newTail = new Promise<void>(resolve => {
|
|
23
|
-
resolveNewTail = resolve;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Immediately set the new promise as the tail for this key
|
|
27
|
-
this.lockQueues.set(key, newTail);
|
|
28
|
-
|
|
29
|
-
// Wait for the previous operation (if any) to complete
|
|
30
|
-
await currentTail;
|
|
31
|
-
|
|
32
|
-
// Return the function to release *this* lock
|
|
33
|
-
const release = () => {
|
|
34
|
-
// Signal that this operation is complete
|
|
35
|
-
resolveNewTail();
|
|
36
|
-
|
|
37
|
-
// If this promise is still the current tail in the map,
|
|
38
|
-
// it means no other operation queued up behind this one while it was running.
|
|
39
|
-
// We can safely remove the entry from the map to prevent unbounded growth.
|
|
40
|
-
if (this.lockQueues.get(key) === newTail) {
|
|
41
|
-
this.lockQueues.delete(key);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return release;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { Row, SqlValue } from '../common/types.js';
|
|
2
|
-
import type { TableSchema } from '../schema/table.js';
|
|
3
|
-
import type * as AST from '../parser/ast.js';
|
|
4
|
-
import { insertToString, updateToString, deleteToString } from './ast-stringify.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Builds a deterministic INSERT statement for mutation logging.
|
|
8
|
-
* Creates an AST and uses insertToString for consistency.
|
|
9
|
-
*/
|
|
10
|
-
export function buildInsertStatement(
|
|
11
|
-
tableSchema: TableSchema,
|
|
12
|
-
newRow: Row,
|
|
13
|
-
contextRow?: Row
|
|
14
|
-
): string {
|
|
15
|
-
// Build INSERT AST
|
|
16
|
-
const stmt: AST.InsertStmt = {
|
|
17
|
-
type: 'insert',
|
|
18
|
-
table: { type: 'identifier', name: tableSchema.name },
|
|
19
|
-
columns: tableSchema.columns.map(col => col.name),
|
|
20
|
-
values: [newRow.map(sqlValueToLiteralExpr)],
|
|
21
|
-
contextValues: buildContextAssignments(tableSchema, contextRow)
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return insertToString(stmt);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Builds a deterministic UPDATE statement for mutation logging.
|
|
29
|
-
*/
|
|
30
|
-
export function buildUpdateStatement(
|
|
31
|
-
tableSchema: TableSchema,
|
|
32
|
-
newRow: Row,
|
|
33
|
-
oldKeyValues: Row,
|
|
34
|
-
contextRow?: Row
|
|
35
|
-
): string {
|
|
36
|
-
const pkDef = tableSchema.primaryKeyDefinition;
|
|
37
|
-
|
|
38
|
-
// Build UPDATE AST
|
|
39
|
-
const stmt: AST.UpdateStmt = {
|
|
40
|
-
type: 'update',
|
|
41
|
-
table: { type: 'identifier', name: tableSchema.name },
|
|
42
|
-
contextValues: buildContextAssignments(tableSchema, contextRow),
|
|
43
|
-
assignments: tableSchema.columns.map((col, idx) => ({
|
|
44
|
-
column: col.name,
|
|
45
|
-
value: sqlValueToLiteralExpr(newRow[idx])
|
|
46
|
-
})),
|
|
47
|
-
where: buildWhereClause(pkDef, oldKeyValues, tableSchema)
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return updateToString(stmt);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Builds a deterministic DELETE statement for mutation logging.
|
|
55
|
-
*/
|
|
56
|
-
export function buildDeleteStatement(
|
|
57
|
-
tableSchema: TableSchema,
|
|
58
|
-
oldKeyValues: Row,
|
|
59
|
-
contextRow?: Row
|
|
60
|
-
): string {
|
|
61
|
-
const pkDef = tableSchema.primaryKeyDefinition;
|
|
62
|
-
|
|
63
|
-
// Build DELETE AST
|
|
64
|
-
const stmt: AST.DeleteStmt = {
|
|
65
|
-
type: 'delete',
|
|
66
|
-
table: { type: 'identifier', name: tableSchema.name },
|
|
67
|
-
contextValues: buildContextAssignments(tableSchema, contextRow),
|
|
68
|
-
where: buildWhereClause(pkDef, oldKeyValues, tableSchema)
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return deleteToString(stmt);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Converts a SqlValue to a LiteralExpr AST node.
|
|
76
|
-
*/
|
|
77
|
-
function sqlValueToLiteralExpr(value: SqlValue): AST.LiteralExpr {
|
|
78
|
-
return {
|
|
79
|
-
type: 'literal',
|
|
80
|
-
value: value
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Builds context assignments from context row values.
|
|
86
|
-
*/
|
|
87
|
-
function buildContextAssignments(
|
|
88
|
-
tableSchema: TableSchema,
|
|
89
|
-
contextRow?: Row
|
|
90
|
-
): AST.ContextAssignment[] | undefined {
|
|
91
|
-
if (!contextRow || contextRow.length === 0 || !tableSchema.mutationContext) {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return tableSchema.mutationContext.map((ctx, idx) => ({
|
|
96
|
-
name: ctx.name,
|
|
97
|
-
value: sqlValueToLiteralExpr(contextRow[idx])
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Builds a WHERE clause for primary key matching.
|
|
103
|
-
* Returns an AND expression of pk_col = value for each PK column.
|
|
104
|
-
*/
|
|
105
|
-
function buildWhereClause(
|
|
106
|
-
pkDef: TableSchema['primaryKeyDefinition'],
|
|
107
|
-
keyValues: Row,
|
|
108
|
-
tableSchema: TableSchema
|
|
109
|
-
): AST.Expression {
|
|
110
|
-
const conditions: AST.Expression[] = pkDef.map((pkCol, idx) => ({
|
|
111
|
-
type: 'binary' as const,
|
|
112
|
-
operator: '=' as const,
|
|
113
|
-
left: { type: 'column' as const, name: tableSchema.columns[pkCol.index].name },
|
|
114
|
-
right: sqlValueToLiteralExpr(keyValues[idx])
|
|
115
|
-
}));
|
|
116
|
-
|
|
117
|
-
if (conditions.length === 0) {
|
|
118
|
-
// Table has no primary key - return a tautology (WHERE 1)
|
|
119
|
-
// Note: UPDATE/DELETE without row identification will affect all rows
|
|
120
|
-
return { type: 'literal', value: 1 };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (conditions.length === 1) {
|
|
124
|
-
return conditions[0];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Build nested AND expressions: (a AND b) AND c AND ...
|
|
128
|
-
return conditions.reduce((acc, cond) => ({
|
|
129
|
-
type: 'binary' as const,
|
|
130
|
-
operator: 'and' as const,
|
|
131
|
-
left: acc,
|
|
132
|
-
right: cond
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
|
package/src/util/patterns.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '../common/logger.js';
|
|
2
|
-
|
|
3
|
-
const log = createLogger('util:patterns');
|
|
4
|
-
const errorLog = log.extend('error');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Simple LIKE pattern matching implementation.
|
|
8
|
-
* Supports SQL LIKE patterns:
|
|
9
|
-
* - % matches any sequence of characters (including empty sequence)
|
|
10
|
-
* - _ matches any single character
|
|
11
|
-
*
|
|
12
|
-
* @param pattern The LIKE pattern
|
|
13
|
-
* @param text The text to match against
|
|
14
|
-
* @returns true if the text matches the pattern, false otherwise
|
|
15
|
-
*/
|
|
16
|
-
export function simpleLike(pattern: string, text: string): boolean {
|
|
17
|
-
// Escape regex special characters except % and _
|
|
18
|
-
const escapedPattern = pattern.replace(/[.*+^${}()|[\]\\]/g, '\\$&');
|
|
19
|
-
// Convert SQL LIKE wildcards to regex equivalents
|
|
20
|
-
const regexPattern = escapedPattern.replace(/%/g, '.*').replace(/_/g, '.');
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
24
|
-
return regex.test(text);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
errorLog('Invalid LIKE pattern converted to regex: ^%s$, %O', regexPattern, e);
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Simple GLOB pattern matching implementation.
|
|
33
|
-
* Supports SQL GLOB patterns:
|
|
34
|
-
* - * matches any sequence of characters (including empty sequence)
|
|
35
|
-
* - ? matches any single character
|
|
36
|
-
*
|
|
37
|
-
* @param pattern The GLOB pattern
|
|
38
|
-
* @param text The text to match against
|
|
39
|
-
* @returns true if the text matches the pattern, false otherwise
|
|
40
|
-
*/
|
|
41
|
-
export function simpleGlob(pattern: string, text: string): boolean {
|
|
42
|
-
// Escape regex special characters except * and ?
|
|
43
|
-
const escapedPattern = pattern.replace(/[.*+^${}()|[\]\\]/g, '\\$&');
|
|
44
|
-
// Convert SQL GLOB wildcards to regex equivalents
|
|
45
|
-
const regexPattern = escapedPattern
|
|
46
|
-
.replace(/\\\*/g, '.*')
|
|
47
|
-
.replace(/\\\?/g, '.');
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
51
|
-
return regex.test(text);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
errorLog('Invalid GLOB pattern converted to regex: ^%s$, %O', regexPattern, e);
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { ScalarPlanNode } from '../planner/nodes/plan-node.js';
|
|
2
|
-
import { expressionToString } from './ast-stringify.js';
|
|
3
|
-
import type { ScalarType } from '../common/datatype.js';
|
|
4
|
-
import { SqlDataType } from '../common/types.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Convert a ScalarPlanNode to its string representation for use in plan descriptions.
|
|
8
|
-
*/
|
|
9
|
-
export function formatExpression(node: ScalarPlanNode): string {
|
|
10
|
-
return expressionToString(node.expression);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Convert multiple ScalarPlanNodes to a comma-separated string.
|
|
15
|
-
*/
|
|
16
|
-
export function formatExpressionList(nodes: readonly ScalarPlanNode[]): string {
|
|
17
|
-
return nodes.map(formatExpression).join(', ');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Format a scalar type to a simple string representation.
|
|
22
|
-
*/
|
|
23
|
-
export function formatScalarType(type: ScalarType): string {
|
|
24
|
-
return type.logicalType.name;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Format projection for display (expression with optional alias).
|
|
29
|
-
*/
|
|
30
|
-
export function formatProjection(expr: ScalarPlanNode, alias?: string): string {
|
|
31
|
-
const exprStr = formatExpression(expr);
|
|
32
|
-
return alias && alias !== exprStr ? `${exprStr} AS ${alias}` : exprStr;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Format sort key for display.
|
|
37
|
-
*/
|
|
38
|
-
export function formatSortKey(
|
|
39
|
-
expr: ScalarPlanNode,
|
|
40
|
-
direction: 'asc' | 'desc',
|
|
41
|
-
nulls?: 'first' | 'last'
|
|
42
|
-
): string {
|
|
43
|
-
const parts = [formatExpression(expr), direction.toUpperCase()];
|
|
44
|
-
if (nulls) {
|
|
45
|
-
parts.push(`NULLS ${nulls.toUpperCase()}`);
|
|
46
|
-
}
|
|
47
|
-
return parts.join(' ');
|
|
48
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin registration helper for static plugin loading
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for registering plugins without dynamic imports,
|
|
5
|
-
* which is useful for React Native and other environments where dynamic imports
|
|
6
|
-
* are not supported.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Database } from '../core/database.js';
|
|
10
|
-
import type { PluginRegistrations } from '../vtab/manifest.js';
|
|
11
|
-
import type { SqlValue } from '../common/types.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Plugin function type - what a plugin exports as its default export
|
|
15
|
-
*/
|
|
16
|
-
export type PluginFunction = (
|
|
17
|
-
db: Database,
|
|
18
|
-
config?: Record<string, SqlValue>
|
|
19
|
-
) => Promise<PluginRegistrations> | PluginRegistrations;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Register a plugin's components with the database.
|
|
23
|
-
*
|
|
24
|
-
* This is a helper function for static plugin loading that handles calling
|
|
25
|
-
* the plugin function and registering all returned components (vtables,
|
|
26
|
-
* functions, collations, types) with the database.
|
|
27
|
-
*
|
|
28
|
-
* @param db Database instance to register with
|
|
29
|
-
* @param plugin Plugin function (the default export from a plugin module)
|
|
30
|
-
* @param config Optional configuration object to pass to the plugin
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* import { Database } from '@quereus/quereus';
|
|
35
|
-
* import { registerPlugin } from '@quereus/quereus';
|
|
36
|
-
* import myPlugin from './plugins/my-plugin';
|
|
37
|
-
*
|
|
38
|
-
* const db = new Database();
|
|
39
|
-
* await registerPlugin(db, myPlugin, { apiKey: 'secret' });
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* // Register multiple plugins
|
|
45
|
-
* await registerPlugin(db, stringFunctions);
|
|
46
|
-
* await registerPlugin(db, customCollations);
|
|
47
|
-
* await registerPlugin(db, jsonTable, { cacheSize: 100 });
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export async function registerPlugin(
|
|
51
|
-
db: Database,
|
|
52
|
-
plugin: PluginFunction,
|
|
53
|
-
config: Record<string, SqlValue> = {}
|
|
54
|
-
): Promise<void> {
|
|
55
|
-
// Call the plugin function to get registrations
|
|
56
|
-
const registrations = await plugin(db, config);
|
|
57
|
-
|
|
58
|
-
// Register virtual table modules
|
|
59
|
-
if (registrations.vtables) {
|
|
60
|
-
for (const vtable of registrations.vtables) {
|
|
61
|
-
try {
|
|
62
|
-
db.registerVtabModule(vtable.name, vtable.module, vtable.auxData);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Failed to register vtable module '${vtable.name}': ${error instanceof Error ? error.message : String(error)}`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Register functions
|
|
72
|
-
if (registrations.functions) {
|
|
73
|
-
for (const func of registrations.functions) {
|
|
74
|
-
try {
|
|
75
|
-
db.registerFunction(func.schema);
|
|
76
|
-
} catch (error) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Failed to register function '${func.schema.name}/${func.schema.numArgs}': ${error instanceof Error ? error.message : String(error)}`
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Register collations
|
|
85
|
-
if (registrations.collations) {
|
|
86
|
-
for (const collation of registrations.collations) {
|
|
87
|
-
try {
|
|
88
|
-
db.registerCollation(collation.name, collation.func);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
throw new Error(
|
|
91
|
-
`Failed to register collation '${collation.name}': ${error instanceof Error ? error.message : String(error)}`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Register types
|
|
98
|
-
if (registrations.types) {
|
|
99
|
-
for (const type of registrations.types) {
|
|
100
|
-
try {
|
|
101
|
-
db.registerType(type.name, type.definition);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
throw new Error(
|
|
104
|
-
`Failed to register type '${type.name}': ${error instanceof Error ? error.message : String(error)}`
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { RowDescriptor, Attribute } from '../planner/nodes/plan-node.js';
|
|
2
|
-
import type { Row } from '../common/types.js';
|
|
3
|
-
import { TEXT_TYPE } from '../types/builtin-types.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Utility to build a RowDescriptor (attributeId → columnIndex mapping)
|
|
7
|
-
* for any relational plan node.
|
|
8
|
-
*/
|
|
9
|
-
export function buildRowDescriptor(attributes: readonly Attribute[]): RowDescriptor {
|
|
10
|
-
const descriptor: RowDescriptor = [];
|
|
11
|
-
attributes.forEach((attr, index) => {
|
|
12
|
-
descriptor[attr.id] = index;
|
|
13
|
-
});
|
|
14
|
-
return descriptor;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates OLD and NEW row descriptors for mutation operations.
|
|
19
|
-
* Returns descriptors where OLD columns are at indices 0..n-1 and NEW columns at n..2n-1
|
|
20
|
-
*/
|
|
21
|
-
export function buildOldNewRowDescriptors(
|
|
22
|
-
oldAttributes: Attribute[],
|
|
23
|
-
newAttributes: Attribute[]
|
|
24
|
-
): {
|
|
25
|
-
oldRowDescriptor: RowDescriptor;
|
|
26
|
-
newRowDescriptor: RowDescriptor;
|
|
27
|
-
flatRowDescriptor: RowDescriptor;
|
|
28
|
-
} {
|
|
29
|
-
const oldRowDescriptor: RowDescriptor = [];
|
|
30
|
-
const newRowDescriptor: RowDescriptor = [];
|
|
31
|
-
const flatRowDescriptor: RowDescriptor = [];
|
|
32
|
-
|
|
33
|
-
// OLD attributes occupy indices 0..n-1
|
|
34
|
-
oldAttributes.forEach((attr, index) => {
|
|
35
|
-
oldRowDescriptor[attr.id] = index;
|
|
36
|
-
flatRowDescriptor[attr.id] = index;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// NEW attributes occupy indices n..2n-1
|
|
40
|
-
newAttributes.forEach((attr, index) => {
|
|
41
|
-
const flatIndex = oldAttributes.length + index;
|
|
42
|
-
newRowDescriptor[attr.id] = index;
|
|
43
|
-
flatRowDescriptor[attr.id] = flatIndex;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return { oldRowDescriptor, newRowDescriptor, flatRowDescriptor };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Composes a flat row from OLD and NEW row values.
|
|
51
|
-
* Result format: [oldCol0, oldCol1, ..., oldColN, newCol0, newCol1, ..., newColN]
|
|
52
|
-
*/
|
|
53
|
-
export function composeOldNewRow(oldRow: Row | null, newRow: Row | null, columnCount: number): Row {
|
|
54
|
-
const flatRow: Row = new Array(columnCount * 2);
|
|
55
|
-
|
|
56
|
-
// Fill OLD section (indices 0..n-1)
|
|
57
|
-
for (let i = 0; i < columnCount; i++) {
|
|
58
|
-
flatRow[i] = oldRow ? oldRow[i] : null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Fill NEW section (indices n..2n-1)
|
|
62
|
-
for (let i = 0; i < columnCount; i++) {
|
|
63
|
-
flatRow[columnCount + i] = newRow ? newRow[i] : null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return flatRow;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Extracts NEW values from a flat OLD/NEW row
|
|
71
|
-
*/
|
|
72
|
-
export function extractNewRowFromFlat(flatRow: Row, columnCount: number): Row {
|
|
73
|
-
return flatRow.slice(columnCount, columnCount * 2);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Extracts OLD values from a flat OLD/NEW row
|
|
78
|
-
*/
|
|
79
|
-
export function extractOldRowFromFlat(flatRow: Row, columnCount: number): Row {
|
|
80
|
-
return flatRow.slice(0, columnCount);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Helper to build Attribute array from flatRowDescriptor for DML nodes.
|
|
85
|
-
* This is used by UpdateNode and DeleteNode to expose their flat row layout.
|
|
86
|
-
*/
|
|
87
|
-
export function buildAttributesFromFlatDescriptor(flatRowDescriptor: RowDescriptor): Attribute[] {
|
|
88
|
-
const attributes: Attribute[] = [];
|
|
89
|
-
for (const attrIdStr in flatRowDescriptor) {
|
|
90
|
-
const attrId = parseInt(attrIdStr);
|
|
91
|
-
const index = flatRowDescriptor[attrId];
|
|
92
|
-
attributes[index] = {
|
|
93
|
-
id: attrId,
|
|
94
|
-
name: `attr_${attrId}`,
|
|
95
|
-
type: {
|
|
96
|
-
typeClass: 'scalar' as const,
|
|
97
|
-
logicalType: TEXT_TYPE,
|
|
98
|
-
nullable: true,
|
|
99
|
-
isReadOnly: false
|
|
100
|
-
},
|
|
101
|
-
sourceRelation: 'unknown'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return attributes;
|
|
105
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for safe serialization, particularly handling BigInt and Uint8Arrays.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
-
import { createLogger } from '../common/logger.js';
|
|
7
|
-
|
|
8
|
-
const log = createLogger('util:serialization');
|
|
9
|
-
const errorLog = log.extend('error');
|
|
10
|
-
|
|
11
|
-
export function jsonStringify(obj: any, space?: string | number): string {
|
|
12
|
-
return JSON.stringify(
|
|
13
|
-
obj,
|
|
14
|
-
(_, value) => {
|
|
15
|
-
if (typeof value === 'bigint') {
|
|
16
|
-
// Convert to number if it's within safe integer limits for JSON
|
|
17
|
-
if (value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
18
|
-
return Number(value);
|
|
19
|
-
}
|
|
20
|
-
// Otherwise, convert to string (without 'n' suffix for standard JSON)
|
|
21
|
-
return value.toString();
|
|
22
|
-
} else if (value instanceof Uint8Array) {
|
|
23
|
-
return `0x${Buffer.from(value).toString('hex')}`; // Keep existing Uint8Array handling
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
},
|
|
27
|
-
space
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Safely stringifies an object to JSON, converting BigInts to strings
|
|
33
|
-
* ending with 'n' to avoid serialization errors.
|
|
34
|
-
*
|
|
35
|
-
* @param obj The object to stringify.
|
|
36
|
-
* @param space Optional spacing argument for JSON.stringify.
|
|
37
|
-
* @returns JSON string representation.
|
|
38
|
-
*/
|
|
39
|
-
export function safeJsonStringify(obj: any, space?: string | number): string {
|
|
40
|
-
try {
|
|
41
|
-
return jsonStringify(obj, space);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
// Fallback in case of unexpected stringify errors
|
|
44
|
-
errorLog("safeJsonStringify failed:", e);
|
|
45
|
-
return `[Unserializable Object: ${e instanceof Error ? e.message : String(e)}]`;
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/util/sql-literal.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SqlValue } from '../common/types.js';
|
|
2
|
-
import { expressionToString } from './ast-stringify.js';
|
|
3
|
-
import type * as AST from '../parser/ast.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Converts a SqlValue to its SQL literal string representation.
|
|
7
|
-
* This is used for mutation logging to create deterministic, replayable SQL statements.
|
|
8
|
-
* Uses the existing expressionToString function for consistency.
|
|
9
|
-
*
|
|
10
|
-
* @param value The value to convert to a SQL literal
|
|
11
|
-
* @returns SQL literal string representation
|
|
12
|
-
*/
|
|
13
|
-
export function sqlValueToLiteral(value: SqlValue): string {
|
|
14
|
-
// Create a literal expression AST node and use expressionToString
|
|
15
|
-
const literalExpr: AST.LiteralExpr = {
|
|
16
|
-
type: 'literal',
|
|
17
|
-
value: value
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return expressionToString(literalExpr);
|
|
21
|
-
}
|
|
22
|
-
|