@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/cached.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** Minimalistic caching utility. */
|
|
2
|
-
export class Cached<T> {
|
|
3
|
-
private cachedValue: T | undefined;
|
|
4
|
-
|
|
5
|
-
constructor(private readonly compute: () => T) {}
|
|
6
|
-
|
|
7
|
-
get value(): T {
|
|
8
|
-
if (this.cachedValue === undefined) { // More strict than truthy
|
|
9
|
-
this.cachedValue = this.compute();
|
|
10
|
-
}
|
|
11
|
-
return this.cachedValue;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
set value(value: T) {
|
|
15
|
-
this.cachedValue = value;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get hasValue(): boolean {
|
|
19
|
-
return this.cachedValue !== undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
clear() {
|
|
23
|
-
this.cachedValue = undefined;
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/util/coercion.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { SqlValue } from '../common/types.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SQL type coercion utilities.
|
|
5
|
-
* Different SQL contexts have different coercion rules.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Attempts to convert a value to a number if it's a numeric string.
|
|
10
|
-
* Returns the original value if conversion is not appropriate.
|
|
11
|
-
* Used for comparison contexts where numeric strings should be treated as numbers.
|
|
12
|
-
*/
|
|
13
|
-
export function tryCoerceToNumber(value: SqlValue): SqlValue {
|
|
14
|
-
if (typeof value === 'string' && value.trim() !== '') {
|
|
15
|
-
// Try to parse as number
|
|
16
|
-
const trimmed = value.trim();
|
|
17
|
-
const asNumber = Number(trimmed);
|
|
18
|
-
if (!isNaN(asNumber) && isFinite(asNumber)) {
|
|
19
|
-
// Check if it's an integer or float
|
|
20
|
-
return Number.isInteger(asNumber) ? Math.trunc(asNumber) : asNumber;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Converts a value to a number for arithmetic contexts.
|
|
28
|
-
* Non-numeric strings become 0 (SQL arithmetic semantics).
|
|
29
|
-
* Used for +, -, *, /, % operations.
|
|
30
|
-
*/
|
|
31
|
-
export function coerceToNumberForArithmetic(value: SqlValue): number {
|
|
32
|
-
if (typeof value === 'number') {
|
|
33
|
-
return value;
|
|
34
|
-
} else if (typeof value === 'boolean') {
|
|
35
|
-
return value ? 1 : 0;
|
|
36
|
-
} else if (typeof value === 'string') {
|
|
37
|
-
const parsed = Number(value.trim());
|
|
38
|
-
return isNaN(parsed) ? 0 : parsed; // Non-numeric strings become 0
|
|
39
|
-
} else {
|
|
40
|
-
return 0; // Blobs, null, etc. become 0
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Performs SQL type coercion for comparison operations.
|
|
46
|
-
* If one operand is numeric and the other is text that can be converted to a number,
|
|
47
|
-
* converts the text to a number before comparison.
|
|
48
|
-
*/
|
|
49
|
-
export function coerceForComparison(v1: SqlValue, v2: SqlValue): [SqlValue, SqlValue] {
|
|
50
|
-
// If either value is null, no coercion needed
|
|
51
|
-
if (v1 === null || v2 === null) {
|
|
52
|
-
return [v1, v2];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const v1IsNumeric = typeof v1 === 'number' || typeof v1 === 'bigint' || typeof v1 === 'boolean';
|
|
56
|
-
const v2IsNumeric = typeof v2 === 'number' || typeof v2 === 'bigint' || typeof v2 === 'boolean';
|
|
57
|
-
const v1IsText = typeof v1 === 'string';
|
|
58
|
-
const v2IsText = typeof v2 === 'string';
|
|
59
|
-
|
|
60
|
-
// Case 1: v1 is numeric, v2 is text -> try to convert v2 to numeric
|
|
61
|
-
if (v1IsNumeric && v2IsText) {
|
|
62
|
-
const coercedV2 = tryCoerceToNumber(v2);
|
|
63
|
-
return [v1, coercedV2];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Case 2: v1 is text, v2 is numeric -> try to convert v1 to numeric
|
|
67
|
-
if (v1IsText && v2IsNumeric) {
|
|
68
|
-
const coercedV1 = tryCoerceToNumber(v1);
|
|
69
|
-
return [coercedV1, v2];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// No coercion needed or possible
|
|
73
|
-
return [v1, v2];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Coerces a value for aggregate function arguments.
|
|
78
|
-
* Most aggregate functions should accept numeric strings as numbers.
|
|
79
|
-
* For COUNT, no coercion needed. For SUM/AVG, numeric strings should be converted.
|
|
80
|
-
*/
|
|
81
|
-
export function coerceForAggregate(value: SqlValue, functionName: string): SqlValue {
|
|
82
|
-
// COUNT and similar functions don't need numeric coercion
|
|
83
|
-
if (functionName.toUpperCase() === 'COUNT' ||
|
|
84
|
-
functionName.toUpperCase() === 'GROUP_CONCAT' ||
|
|
85
|
-
functionName.toUpperCase().startsWith('JSON_')) {
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Numeric aggregates (SUM, AVG, MIN, MAX) should coerce numeric strings
|
|
90
|
-
if (typeof value === 'string' && value.trim() !== '') {
|
|
91
|
-
const coerced = tryCoerceToNumber(value);
|
|
92
|
-
return coerced;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Determines if a value should be treated as numeric in the given context.
|
|
100
|
-
*/
|
|
101
|
-
export function isNumericValue(value: SqlValue): boolean {
|
|
102
|
-
if (value === null) return false;
|
|
103
|
-
if (typeof value === 'number' || typeof value === 'bigint' || typeof value === 'boolean') {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
if (typeof value === 'string') {
|
|
107
|
-
const trimmed = value.trim();
|
|
108
|
-
if (trimmed === '') return false;
|
|
109
|
-
const asNumber = Number(trimmed);
|
|
110
|
-
return !isNaN(asNumber) && isFinite(asNumber);
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
}
|
package/src/util/comparison.ts
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import type { Row, SqlValue } from '../common/types.js';
|
|
2
|
-
import { createLogger } from '../common/logger.js';
|
|
3
|
-
import type { LogicalType, CollationFunction } from '../types/logical-type.js';
|
|
4
|
-
import { StatusCode } from '../common/types.js';
|
|
5
|
-
import { QuereusError } from '../common/errors.js';
|
|
6
|
-
|
|
7
|
-
const log = createLogger('util:comparison');
|
|
8
|
-
const warnLog = log.extend('warn');
|
|
9
|
-
|
|
10
|
-
// Re-export CollationFunction for backward compatibility
|
|
11
|
-
export type { CollationFunction };
|
|
12
|
-
|
|
13
|
-
// Map to store registered collations
|
|
14
|
-
const collations = new Map<string, CollationFunction>();
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Binary (default) collation function.
|
|
18
|
-
* Performs standard lexicographical comparison of strings.
|
|
19
|
-
*/
|
|
20
|
-
export const BINARY_COLLATION: CollationFunction = (a, b) => {
|
|
21
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Case-insensitive collation function.
|
|
26
|
-
* Compares strings after converting them to lowercase.
|
|
27
|
-
*/
|
|
28
|
-
export const NOCASE_COLLATION: CollationFunction = (a, b) => {
|
|
29
|
-
const lowerA = a.toLowerCase();
|
|
30
|
-
const lowerB = b.toLowerCase();
|
|
31
|
-
return lowerA < lowerB ? -1 : lowerA > lowerB ? 1 : 0;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Right-trim collation function.
|
|
36
|
-
* Compares strings after removing trailing spaces.
|
|
37
|
-
*/
|
|
38
|
-
export const RTRIM_COLLATION: CollationFunction = (a, b) => {
|
|
39
|
-
let lenA = a.length;
|
|
40
|
-
let lenB = b.length;
|
|
41
|
-
|
|
42
|
-
while (lenA > 0 && a[lenA - 1] === ' ') lenA--;
|
|
43
|
-
while (lenB > 0 && b[lenB - 1] === ' ') lenB--;
|
|
44
|
-
|
|
45
|
-
const minLen = Math.min(lenA, lenB);
|
|
46
|
-
for (let i = 0; i < minLen; i++) {
|
|
47
|
-
if (a[i] !== b[i]) {
|
|
48
|
-
return a[i] < b[i] ? -1 : 1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return lenA - lenB;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// Register built-in collations
|
|
56
|
-
collations.set('BINARY', BINARY_COLLATION);
|
|
57
|
-
collations.set('NOCASE', NOCASE_COLLATION);
|
|
58
|
-
collations.set('RTRIM', RTRIM_COLLATION);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Registers a collation function with the given name.
|
|
62
|
-
* @param name The name of the collation (case-insensitive)
|
|
63
|
-
* @param func The collation function to register
|
|
64
|
-
*/
|
|
65
|
-
export function registerCollation(name: string, func: CollationFunction): void {
|
|
66
|
-
const upperName = name.toUpperCase();
|
|
67
|
-
if (collations.has(upperName)) {
|
|
68
|
-
warnLog(`Overwriting existing collation: %s`, upperName);
|
|
69
|
-
}
|
|
70
|
-
collations.set(upperName, func);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gets a registered collation function by name.
|
|
75
|
-
* @param name The collation name (case-insensitive)
|
|
76
|
-
* @returns The collation function, or undefined if not found
|
|
77
|
-
*/
|
|
78
|
-
export function getCollation(name: string): CollationFunction | undefined {
|
|
79
|
-
return collations.get(name.toUpperCase());
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Resolves a collation name to its function. Optimized for hot path usage.
|
|
84
|
-
* @param collationName The collation name
|
|
85
|
-
* @returns The collation function (defaults to BINARY if not found)
|
|
86
|
-
*/
|
|
87
|
-
export function resolveCollation(collationName: string): CollationFunction {
|
|
88
|
-
if (collationName === 'BINARY') return BINARY_COLLATION; // Fast path for most common case
|
|
89
|
-
const func = collations.get(collationName.toUpperCase());
|
|
90
|
-
if (!func) {
|
|
91
|
-
warnLog(`Unknown collation requested: %s. Falling back to BINARY.`, collationName);
|
|
92
|
-
return BINARY_COLLATION;
|
|
93
|
-
}
|
|
94
|
-
return func;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Evaluates a JavaScript value according to simplified, JS-idiomatic truthiness rules.
|
|
99
|
-
* - null/undefined are false
|
|
100
|
-
* - boolean is its own value
|
|
101
|
-
* - number: 0 is false, non-zero is true
|
|
102
|
-
* - bigint: 0n is false, non-zero is true
|
|
103
|
-
* - string: empty string is false, non-empty is true
|
|
104
|
-
* - Uint8Array (BLOB): always false
|
|
105
|
-
*
|
|
106
|
-
* @param value The value to evaluate
|
|
107
|
-
* @returns True or false
|
|
108
|
-
*/
|
|
109
|
-
export function evaluateIsTrue(value: SqlValue): boolean {
|
|
110
|
-
if (value === null || value === undefined) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
switch (typeof value) {
|
|
114
|
-
case 'boolean':
|
|
115
|
-
return value;
|
|
116
|
-
case 'number':
|
|
117
|
-
return value !== 0;
|
|
118
|
-
case 'bigint':
|
|
119
|
-
return value !== 0n;
|
|
120
|
-
case 'string':
|
|
121
|
-
return value.length > 0;
|
|
122
|
-
case 'object':
|
|
123
|
-
if (value instanceof Uint8Array) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
default:
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Represents SQLite storage classes for comparison purposes */
|
|
133
|
-
enum StorageClass {
|
|
134
|
-
NULL = 0,
|
|
135
|
-
NUMERIC = 1, // INTEGER or REAL
|
|
136
|
-
TEXT = 2,
|
|
137
|
-
BLOB = 3,
|
|
138
|
-
UNKNOWN = 99
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Determines the effective storage class for comparison, converting boolean to numeric.
|
|
143
|
-
* Optimized with early returns for common cases.
|
|
144
|
-
*/
|
|
145
|
-
function getStorageClass(v: SqlValue): StorageClass {
|
|
146
|
-
if (v === null) return StorageClass.NULL; // Most common null check
|
|
147
|
-
|
|
148
|
-
const type = typeof v;
|
|
149
|
-
// Fast path for numbers (most common non-null case)
|
|
150
|
-
if (type === 'number') return StorageClass.NUMERIC;
|
|
151
|
-
if (type === 'string') return StorageClass.TEXT;
|
|
152
|
-
if (type === 'boolean' || type === 'bigint') return StorageClass.NUMERIC;
|
|
153
|
-
if (type === 'object' && v instanceof Uint8Array) return StorageClass.BLOB;
|
|
154
|
-
|
|
155
|
-
return StorageClass.UNKNOWN;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Returns the SQLite fundamental datatype name of a value.
|
|
160
|
-
* @param v The value
|
|
161
|
-
* @returns The datatype name as a string
|
|
162
|
-
*/
|
|
163
|
-
export function getSqlDataTypeName(v: SqlValue): 'null' | 'integer' | 'real' | 'text' | 'blob' {
|
|
164
|
-
if (v === null || v === undefined) return 'null';
|
|
165
|
-
const type = typeof v;
|
|
166
|
-
if (type === 'boolean') return 'integer';
|
|
167
|
-
if (type === 'number') {
|
|
168
|
-
return Number.isInteger(v) ? 'integer' : 'real';
|
|
169
|
-
}
|
|
170
|
-
if (type === 'bigint') return 'integer';
|
|
171
|
-
if (type === 'string') return 'text';
|
|
172
|
-
if (type === 'object' && v instanceof Uint8Array) return 'blob';
|
|
173
|
-
return 'null';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Fast path comparison for two numbers (most common case).
|
|
178
|
-
* @param a First number
|
|
179
|
-
* @param b Second number
|
|
180
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
|
181
|
-
*/
|
|
182
|
-
function compareNumbers(a: number | bigint, b: number | bigint): number {
|
|
183
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Optimized comparison for same-type values.
|
|
188
|
-
* @param a First value
|
|
189
|
-
* @param b Second value
|
|
190
|
-
* @param storageClass The storage class of both values
|
|
191
|
-
* @param collationFunc The collation function (for TEXT types)
|
|
192
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
|
193
|
-
*/
|
|
194
|
-
function compareSameType(a: SqlValue, b: SqlValue, storageClass: StorageClass, collationFunc: CollationFunction): number {
|
|
195
|
-
switch (storageClass) {
|
|
196
|
-
case StorageClass.NUMERIC: {
|
|
197
|
-
// Convert booleans to numbers inline for efficiency
|
|
198
|
-
const valA = typeof a === 'boolean' ? (a ? 1 : 0) : a as number | bigint;
|
|
199
|
-
const valB = typeof b === 'boolean' ? (b ? 1 : 0) : b as number | bigint;
|
|
200
|
-
return compareNumbers(valA, valB);
|
|
201
|
-
}
|
|
202
|
-
case StorageClass.TEXT: {
|
|
203
|
-
return collationFunc(a as string, b as string);
|
|
204
|
-
}
|
|
205
|
-
case StorageClass.BLOB: {
|
|
206
|
-
const blobA = a as Uint8Array;
|
|
207
|
-
const blobB = b as Uint8Array;
|
|
208
|
-
const len = Math.min(blobA.length, blobB.length);
|
|
209
|
-
for (let i = 0; i < len; i++) {
|
|
210
|
-
if (blobA[i] !== blobB[i]) {
|
|
211
|
-
return blobA[i] < blobB[i] ? -1 : 1;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return blobA.length < blobB.length ? -1 : blobA.length > blobB.length ? 1 : 0;
|
|
215
|
-
}
|
|
216
|
-
default: {
|
|
217
|
-
return 0;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Compares two SQLite values based on SQLite's comparison rules.
|
|
224
|
-
* Follows SQLite's type ordering: NULL < Numeric < TEXT < BLOB
|
|
225
|
-
*
|
|
226
|
-
* @param a First value
|
|
227
|
-
* @param b Second value
|
|
228
|
-
* @param collationName The collation to use for text comparison (defaults to BINARY)
|
|
229
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
|
230
|
-
*/
|
|
231
|
-
export function compareSqlValues(a: SqlValue, b: SqlValue, collationName: string = 'BINARY'): number {
|
|
232
|
-
const collationFunc = collationName === 'BINARY' ? BINARY_COLLATION : resolveCollation(collationName);
|
|
233
|
-
return compareSqlValuesFast(a, b, collationFunc);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Optimized version of compareSqlValues that takes a pre-resolved collation function.
|
|
238
|
-
* This avoids the collation lookup on every call.
|
|
239
|
-
*
|
|
240
|
-
* @param a First value
|
|
241
|
-
* @param b Second value
|
|
242
|
-
* @param collationFunc Pre-resolved collation function
|
|
243
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
|
244
|
-
*/
|
|
245
|
-
export function compareSqlValuesFast(a: SqlValue, b: SqlValue, collationFunc: CollationFunction): number {
|
|
246
|
-
const classA = getStorageClass(a);
|
|
247
|
-
const classB = getStorageClass(b);
|
|
248
|
-
|
|
249
|
-
// Fast path: NULL comparisons
|
|
250
|
-
if (classA === StorageClass.NULL) {
|
|
251
|
-
return classB === StorageClass.NULL ? 0 : -1;
|
|
252
|
-
}
|
|
253
|
-
if (classB === StorageClass.NULL) {
|
|
254
|
-
return 1;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Fast path: same type comparison
|
|
258
|
-
if (classA === classB) {
|
|
259
|
-
return compareSameType(a, b, classA, collationFunc);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Different types: compare by storage class ordering
|
|
263
|
-
return classA - classB;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Direction flags for optimized comparisons (avoids string comparison in hot path)
|
|
268
|
-
*/
|
|
269
|
-
export const enum SortDirection {
|
|
270
|
-
ASC = 0,
|
|
271
|
-
DESC = 1
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* NULL ordering flags for optimized comparisons
|
|
276
|
-
*/
|
|
277
|
-
export const enum NullsOrdering {
|
|
278
|
-
DEFAULT = 0, // Use SQLite default (nulls first for ASC, nulls last for DESC)
|
|
279
|
-
FIRST = 1,
|
|
280
|
-
LAST = 2
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Highly optimized comparison function for ORDER BY operations.
|
|
285
|
-
* Takes pre-resolved collation function and numeric flags to avoid string comparisons.
|
|
286
|
-
*
|
|
287
|
-
* @param a First value
|
|
288
|
-
* @param b Second value
|
|
289
|
-
* @param direction Sort direction (SortDirection.ASC or SortDirection.DESC)
|
|
290
|
-
* @param nullsOrdering NULL ordering (NullsOrdering enum)
|
|
291
|
-
* @param collationFunc Pre-resolved collation function
|
|
292
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b (after applying direction and null ordering)
|
|
293
|
-
*/
|
|
294
|
-
export function compareWithOrderByFast(
|
|
295
|
-
a: SqlValue,
|
|
296
|
-
b: SqlValue,
|
|
297
|
-
direction: SortDirection,
|
|
298
|
-
nullsOrdering: NullsOrdering,
|
|
299
|
-
collationFunc: CollationFunction
|
|
300
|
-
): number {
|
|
301
|
-
let comparison: number;
|
|
302
|
-
|
|
303
|
-
// Fast path: both values are non-NULL (most common case)
|
|
304
|
-
if (a !== null && b !== null) {
|
|
305
|
-
comparison = compareSqlValuesFast(a, b, collationFunc);
|
|
306
|
-
} else if (a === null && b === null) {
|
|
307
|
-
comparison = 0;
|
|
308
|
-
} else if (a === null) {
|
|
309
|
-
// Handle NULL ordering with numeric flags (faster than string comparison)
|
|
310
|
-
if (nullsOrdering === NullsOrdering.LAST) {
|
|
311
|
-
comparison = 1; // nulls last
|
|
312
|
-
} else if (nullsOrdering === NullsOrdering.FIRST) {
|
|
313
|
-
comparison = -1; // nulls first
|
|
314
|
-
} else {
|
|
315
|
-
// Default behavior: nulls first for ASC, nulls last for DESC
|
|
316
|
-
comparison = direction === SortDirection.DESC ? 1 : -1;
|
|
317
|
-
}
|
|
318
|
-
} else { // b === null
|
|
319
|
-
if (nullsOrdering === NullsOrdering.LAST) {
|
|
320
|
-
comparison = -1; // nulls last (b is null, so a comes first)
|
|
321
|
-
} else if (nullsOrdering === NullsOrdering.FIRST) {
|
|
322
|
-
comparison = 1; // nulls first (b is null, so b comes first)
|
|
323
|
-
} else {
|
|
324
|
-
// Default behavior: nulls first for ASC, nulls last for DESC
|
|
325
|
-
comparison = direction === SortDirection.DESC ? -1 : 1;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Apply DESC direction (branchless when direction is ASC)
|
|
330
|
-
return direction === SortDirection.DESC ? -comparison : comparison;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Compares two SQL values with ORDER BY semantics including direction and NULL ordering.
|
|
335
|
-
* This consolidates the comparison logic used by both sort and window operations.
|
|
336
|
-
*
|
|
337
|
-
* @param a First value
|
|
338
|
-
* @param b Second value
|
|
339
|
-
* @param direction Sort direction ('asc' or 'desc')
|
|
340
|
-
* @param nullsOrdering Explicit NULLS ordering ('first', 'last', or undefined for default)
|
|
341
|
-
* @param collationName The collation to use for text comparison (defaults to BINARY)
|
|
342
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b (after applying direction and null ordering)
|
|
343
|
-
*/
|
|
344
|
-
export function compareWithOrderBy(
|
|
345
|
-
a: SqlValue,
|
|
346
|
-
b: SqlValue,
|
|
347
|
-
direction: 'asc' | 'desc' = 'asc',
|
|
348
|
-
nullsOrdering?: 'first' | 'last',
|
|
349
|
-
collationName: string = 'BINARY'
|
|
350
|
-
): number {
|
|
351
|
-
// Convert to optimized flags and use fast path
|
|
352
|
-
const directionFlag = direction === 'desc' ? SortDirection.DESC : SortDirection.ASC;
|
|
353
|
-
const nullsFlag = nullsOrdering === 'first'
|
|
354
|
-
? NullsOrdering.FIRST
|
|
355
|
-
: nullsOrdering === 'last'
|
|
356
|
-
? NullsOrdering.LAST
|
|
357
|
-
: NullsOrdering.DEFAULT;
|
|
358
|
-
const collationFunc = collationName === 'BINARY' ? BINARY_COLLATION : resolveCollation(collationName);
|
|
359
|
-
|
|
360
|
-
return compareWithOrderByFast(a, b, directionFlag, nullsFlag, collationFunc);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Factory function to create optimized comparison functions for repeated use.
|
|
365
|
-
* Pre-resolves collation and converts string flags to numeric for maximum performance.
|
|
366
|
-
*
|
|
367
|
-
* @param direction Sort direction ('asc' or 'desc')
|
|
368
|
-
* @param nullsOrdering Explicit NULLS ordering ('first', 'last', or undefined for default)
|
|
369
|
-
* @param collationName The collation to use for text comparison (defaults to BINARY)
|
|
370
|
-
* @returns An optimized comparison function
|
|
371
|
-
*/
|
|
372
|
-
export function createOrderByComparator(
|
|
373
|
-
direction: 'asc' | 'desc' = 'asc',
|
|
374
|
-
nullsOrdering?: 'first' | 'last',
|
|
375
|
-
collationName: string = 'BINARY'
|
|
376
|
-
): (a: SqlValue, b: SqlValue) => number {
|
|
377
|
-
const collationFunc = collationName === 'BINARY' ? BINARY_COLLATION : resolveCollation(collationName);
|
|
378
|
-
return createOrderByComparatorFast(direction, nullsOrdering, collationFunc);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Optimized factory function that takes a pre-resolved collation function.
|
|
383
|
-
* This is the most efficient option when the collation function is already available.
|
|
384
|
-
*
|
|
385
|
-
* @param direction Sort direction ('asc' or 'desc')
|
|
386
|
-
* @param nullsOrdering Explicit NULLS ordering ('first', 'last', or undefined for default)
|
|
387
|
-
* @param collationFunc Pre-resolved collation function
|
|
388
|
-
* @returns An optimized comparison function
|
|
389
|
-
*/
|
|
390
|
-
export function createOrderByComparatorFast(
|
|
391
|
-
direction: 'asc' | 'desc' = 'asc',
|
|
392
|
-
nullsOrdering?: 'first' | 'last',
|
|
393
|
-
collationFunc: CollationFunction = BINARY_COLLATION
|
|
394
|
-
): (a: SqlValue, b: SqlValue) => number {
|
|
395
|
-
const directionFlag = direction === 'desc' ? SortDirection.DESC : SortDirection.ASC;
|
|
396
|
-
const nullsFlag = nullsOrdering === 'first'
|
|
397
|
-
? NullsOrdering.FIRST
|
|
398
|
-
: nullsOrdering === 'last'
|
|
399
|
-
? NullsOrdering.LAST
|
|
400
|
-
: NullsOrdering.DEFAULT;
|
|
401
|
-
|
|
402
|
-
// Return a closure that captures the pre-resolved values
|
|
403
|
-
return (a: SqlValue, b: SqlValue): number => {
|
|
404
|
-
return compareWithOrderByFast(a, b, directionFlag, nullsFlag, collationFunc);
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Determines if a SqlValue is truthy for filter purposes.
|
|
410
|
-
* In SQL semantics:
|
|
411
|
-
* - NULL is falsy
|
|
412
|
-
* - 0 (number) is falsy
|
|
413
|
-
* - Empty string is falsy
|
|
414
|
-
* - false (boolean) is falsy
|
|
415
|
-
* - Everything else is truthy
|
|
416
|
-
*/
|
|
417
|
-
export function isTruthy(value: SqlValue): boolean {
|
|
418
|
-
return (typeof value === 'string') ? value.length > 0 : !!value;
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Compares two rows for SQL DISTINCT semantics.
|
|
422
|
-
* Returns -1, 0, or 1 for BTree ordering.
|
|
423
|
-
*/
|
|
424
|
-
export function compareRows(a: Row, b: Row): number {
|
|
425
|
-
// Let's assume correct rows
|
|
426
|
-
// if (a.length !== b.length) {
|
|
427
|
-
// return a.length - b.length;
|
|
428
|
-
// }
|
|
429
|
-
// Compare each value using SQL semantics
|
|
430
|
-
for (let i = 0; i < a.length; i++) {
|
|
431
|
-
const comparison = compareSqlValues(a[i], b[i]);
|
|
432
|
-
if (comparison !== 0) {
|
|
433
|
-
return comparison;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
return 0;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Type-aware comparison function that uses logical type information.
|
|
442
|
-
* This eliminates runtime type detection and uses type-specific comparison logic.
|
|
443
|
-
*
|
|
444
|
-
* @param a First value
|
|
445
|
-
* @param b Second value
|
|
446
|
-
* @param typeA Logical type of first value
|
|
447
|
-
* @param typeB Logical type of second value (should match typeA for strict typing)
|
|
448
|
-
* @param collation Optional collation function for TEXT types
|
|
449
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
|
450
|
-
* @throws QuereusError if types don't match (strict typing)
|
|
451
|
-
*/
|
|
452
|
-
export function compareTypedValues(
|
|
453
|
-
a: SqlValue,
|
|
454
|
-
b: SqlValue,
|
|
455
|
-
typeA: LogicalType,
|
|
456
|
-
typeB: LogicalType,
|
|
457
|
-
collation?: CollationFunction
|
|
458
|
-
): number {
|
|
459
|
-
// NULL handling
|
|
460
|
-
if (a === null && b === null) return 0;
|
|
461
|
-
if (a === null) return -1;
|
|
462
|
-
if (b === null) return 1;
|
|
463
|
-
|
|
464
|
-
// Type mismatch error (strict typing)
|
|
465
|
-
if (typeA !== typeB) {
|
|
466
|
-
throw new QuereusError(
|
|
467
|
-
`Type mismatch in comparison: ${typeA.name} vs ${typeB.name}`,
|
|
468
|
-
StatusCode.MISMATCH
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Use type-specific comparison if available
|
|
473
|
-
if (typeA.compare) {
|
|
474
|
-
return typeA.compare(a, b, collation);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// Fallback to default comparison based on physical type
|
|
478
|
-
// This shouldn't happen for built-in types, but provides safety for custom types
|
|
479
|
-
return compareSqlValuesFast(a, b, collation ?? BINARY_COLLATION);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Create a type-aware comparator function for a specific logical type.
|
|
484
|
-
* This is optimized for use in indexes and sorts where the type is known at creation time.
|
|
485
|
-
*
|
|
486
|
-
* @param type The logical type
|
|
487
|
-
* @param collation Optional collation function for TEXT types
|
|
488
|
-
* @returns A comparator function
|
|
489
|
-
*/
|
|
490
|
-
export function createTypedComparator(
|
|
491
|
-
type: LogicalType,
|
|
492
|
-
collation?: CollationFunction
|
|
493
|
-
): (a: SqlValue, b: SqlValue) => number {
|
|
494
|
-
// Pre-resolve the comparison function
|
|
495
|
-
const compareFunc = type.compare;
|
|
496
|
-
|
|
497
|
-
if (compareFunc) {
|
|
498
|
-
// Type has custom comparison
|
|
499
|
-
return (a: SqlValue, b: SqlValue) => {
|
|
500
|
-
if (a === null && b === null) return 0;
|
|
501
|
-
if (a === null) return -1;
|
|
502
|
-
if (b === null) return 1;
|
|
503
|
-
return compareFunc(a, b, collation);
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Fallback to default comparison
|
|
508
|
-
const collationFunc = collation ?? BINARY_COLLATION;
|
|
509
|
-
return (a: SqlValue, b: SqlValue) => compareSqlValuesFast(a, b, collationFunc);
|
|
510
|
-
}
|
package/src/util/environment.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-platform environment variable utilities
|
|
3
|
-
* Works in Node.js, browsers, and React Native
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { createLogger } from '../common/logger.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Cross-platform environment variable accessor
|
|
10
|
-
* Works in Node.js, browsers, and React Native
|
|
11
|
-
*
|
|
12
|
-
* @param key The environment variable name
|
|
13
|
-
* @returns The environment variable value or undefined if not found
|
|
14
|
-
*/
|
|
15
|
-
export function getEnvVar(key: string): string | undefined {
|
|
16
|
-
// Node.js environment
|
|
17
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
18
|
-
return process.env[key];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Browser environment - check if globalThis has the variable
|
|
22
|
-
// This allows setting environment variables like: globalThis.DEBUG = "quereus:*"
|
|
23
|
-
if (typeof globalThis !== 'undefined' && (globalThis as Record<string, unknown>)[key]) {
|
|
24
|
-
return (globalThis as Record<string, unknown>)[key] as string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// React Native or other environments might set environment variables differently
|
|
28
|
-
// For now, return undefined for unsupported environments
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Check if debug logging is enabled for a specific namespace
|
|
34
|
-
* Uses the debug library's own enabled property via createLogger
|
|
35
|
-
*
|
|
36
|
-
* @param namespace The debug namespace to check (without the 'quereus:' prefix)
|
|
37
|
-
* @returns true if debug logging is enabled for the namespace
|
|
38
|
-
*/
|
|
39
|
-
export function isDebugEnabled(namespace: string): boolean {
|
|
40
|
-
const logger = createLogger(namespace);
|
|
41
|
-
return logger.enabled;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if a feature flag is enabled
|
|
46
|
-
*
|
|
47
|
-
* @param flagName The feature flag name
|
|
48
|
-
* @returns true if the flag is set to 'true'
|
|
49
|
-
*/
|
|
50
|
-
export function isFeatureEnabled(flagName: string): boolean {
|
|
51
|
-
return getEnvVar(flagName) === 'true';
|
|
52
|
-
}
|