@quereus/quereus 4.9.0 → 4.10.0

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.
Files changed (147) hide show
  1. package/dist/src/core/database.d.ts.map +1 -1
  2. package/dist/src/core/database.js +19 -4
  3. package/dist/src/core/database.js.map +1 -1
  4. package/dist/src/core/statement.d.ts.map +1 -1
  5. package/dist/src/core/statement.js +74 -15
  6. package/dist/src/core/statement.js.map +1 -1
  7. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  8. package/dist/src/func/builtins/aggregate.js +85 -33
  9. package/dist/src/func/builtins/aggregate.js.map +1 -1
  10. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  11. package/dist/src/func/builtins/explain.js +9 -2
  12. package/dist/src/func/builtins/explain.js.map +1 -1
  13. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  14. package/dist/src/func/builtins/scalar.js +4 -2
  15. package/dist/src/func/builtins/scalar.js.map +1 -1
  16. package/dist/src/func/registration.d.ts +6 -0
  17. package/dist/src/func/registration.d.ts.map +1 -1
  18. package/dist/src/func/registration.js +1 -0
  19. package/dist/src/func/registration.js.map +1 -1
  20. package/dist/src/index.d.ts +1 -0
  21. package/dist/src/index.d.ts.map +1 -1
  22. package/dist/src/index.js +6 -0
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  25. package/dist/src/planner/nodes/scalar.js +13 -1
  26. package/dist/src/planner/nodes/scalar.js.map +1 -1
  27. package/dist/src/runtime/emission-context.d.ts +14 -1
  28. package/dist/src/runtime/emission-context.d.ts.map +1 -1
  29. package/dist/src/runtime/emission-context.js +17 -5
  30. package/dist/src/runtime/emission-context.js.map +1 -1
  31. package/dist/src/runtime/emit/aggregate-setup.d.ts +44 -8
  32. package/dist/src/runtime/emit/aggregate-setup.d.ts.map +1 -1
  33. package/dist/src/runtime/emit/aggregate-setup.js +79 -15
  34. package/dist/src/runtime/emit/aggregate-setup.js.map +1 -1
  35. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  36. package/dist/src/runtime/emit/aggregate.js +21 -106
  37. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  38. package/dist/src/runtime/emit/asof-scan.js +1 -1
  39. package/dist/src/runtime/emit/asof-scan.js.map +1 -1
  40. package/dist/src/runtime/emit/between.d.ts +2 -0
  41. package/dist/src/runtime/emit/between.d.ts.map +1 -1
  42. package/dist/src/runtime/emit/between.js +7 -8
  43. package/dist/src/runtime/emit/between.js.map +1 -1
  44. package/dist/src/runtime/emit/binary.d.ts +27 -5
  45. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  46. package/dist/src/runtime/emit/binary.js +266 -177
  47. package/dist/src/runtime/emit/binary.js.map +1 -1
  48. package/dist/src/runtime/emit/case.d.ts +34 -0
  49. package/dist/src/runtime/emit/case.d.ts.map +1 -1
  50. package/dist/src/runtime/emit/case.js +18 -11
  51. package/dist/src/runtime/emit/case.js.map +1 -1
  52. package/dist/src/runtime/emit/cast.d.ts +2 -0
  53. package/dist/src/runtime/emit/cast.d.ts.map +1 -1
  54. package/dist/src/runtime/emit/cast.js +7 -5
  55. package/dist/src/runtime/emit/cast.js.map +1 -1
  56. package/dist/src/runtime/emit/column-reference.d.ts +3 -1
  57. package/dist/src/runtime/emit/column-reference.d.ts.map +1 -1
  58. package/dist/src/runtime/emit/column-reference.js +6 -2
  59. package/dist/src/runtime/emit/column-reference.js.map +1 -1
  60. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  61. package/dist/src/runtime/emit/dml-executor.js +21 -0
  62. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  63. package/dist/src/runtime/emit/filter.d.ts +1 -1
  64. package/dist/src/runtime/emit/filter.js +1 -1
  65. package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
  66. package/dist/src/runtime/emit/hash-aggregate.js +18 -88
  67. package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
  68. package/dist/src/runtime/emit/literal.d.ts +14 -1
  69. package/dist/src/runtime/emit/literal.d.ts.map +1 -1
  70. package/dist/src/runtime/emit/literal.js +33 -7
  71. package/dist/src/runtime/emit/literal.js.map +1 -1
  72. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +7 -1
  73. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  74. package/dist/src/runtime/emit/materialized-view-helpers.js +121 -32
  75. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  76. package/dist/src/runtime/emit/parameter.d.ts +3 -1
  77. package/dist/src/runtime/emit/parameter.d.ts.map +1 -1
  78. package/dist/src/runtime/emit/parameter.js +7 -2
  79. package/dist/src/runtime/emit/parameter.js.map +1 -1
  80. package/dist/src/runtime/emit/scalar-function.d.ts +29 -1
  81. package/dist/src/runtime/emit/scalar-function.d.ts.map +1 -1
  82. package/dist/src/runtime/emit/scalar-function.js +66 -16
  83. package/dist/src/runtime/emit/scalar-function.js.map +1 -1
  84. package/dist/src/runtime/emit/scalar-op.d.ts +63 -0
  85. package/dist/src/runtime/emit/scalar-op.d.ts.map +1 -0
  86. package/dist/src/runtime/emit/scalar-op.js +37 -0
  87. package/dist/src/runtime/emit/scalar-op.js.map +1 -0
  88. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  89. package/dist/src/runtime/emit/scan.js +19 -1
  90. package/dist/src/runtime/emit/scan.js.map +1 -1
  91. package/dist/src/runtime/emit/temporal-arithmetic.d.ts +18 -8
  92. package/dist/src/runtime/emit/temporal-arithmetic.d.ts.map +1 -1
  93. package/dist/src/runtime/emit/temporal-arithmetic.js +29 -311
  94. package/dist/src/runtime/emit/temporal-arithmetic.js.map +1 -1
  95. package/dist/src/runtime/emit/unary.d.ts +2 -0
  96. package/dist/src/runtime/emit/unary.d.ts.map +1 -1
  97. package/dist/src/runtime/emit/unary.js +125 -53
  98. package/dist/src/runtime/emit/unary.js.map +1 -1
  99. package/dist/src/runtime/emitters.d.ts +22 -0
  100. package/dist/src/runtime/emitters.d.ts.map +1 -1
  101. package/dist/src/runtime/emitters.js +29 -0
  102. package/dist/src/runtime/emitters.js.map +1 -1
  103. package/dist/src/runtime/scalar-fusion.d.ts +47 -0
  104. package/dist/src/runtime/scalar-fusion.d.ts.map +1 -0
  105. package/dist/src/runtime/scalar-fusion.js +275 -0
  106. package/dist/src/runtime/scalar-fusion.js.map +1 -0
  107. package/dist/src/runtime/strict-flags.d.ts +9 -0
  108. package/dist/src/runtime/strict-flags.d.ts.map +1 -1
  109. package/dist/src/runtime/strict-flags.js +9 -0
  110. package/dist/src/runtime/strict-flags.js.map +1 -1
  111. package/dist/src/runtime/strict-fork.js +2 -2
  112. package/dist/src/runtime/strict-fork.js.map +1 -1
  113. package/dist/src/runtime/strict-representation.d.ts +78 -0
  114. package/dist/src/runtime/strict-representation.d.ts.map +1 -0
  115. package/dist/src/runtime/strict-representation.js +159 -0
  116. package/dist/src/runtime/strict-representation.js.map +1 -0
  117. package/dist/src/schema/function.d.ts +15 -0
  118. package/dist/src/schema/function.d.ts.map +1 -1
  119. package/dist/src/schema/function.js.map +1 -1
  120. package/dist/src/types/builtin-types.d.ts.map +1 -1
  121. package/dist/src/types/builtin-types.js +17 -8
  122. package/dist/src/types/builtin-types.js.map +1 -1
  123. package/dist/src/types/temporal-ops.d.ts +119 -0
  124. package/dist/src/types/temporal-ops.d.ts.map +1 -0
  125. package/dist/src/types/temporal-ops.js +348 -0
  126. package/dist/src/types/temporal-ops.js.map +1 -0
  127. package/dist/src/types/temporal-types.d.ts.map +1 -1
  128. package/dist/src/types/temporal-types.js +8 -3
  129. package/dist/src/types/temporal-types.js.map +1 -1
  130. package/dist/src/util/coercion.d.ts +22 -7
  131. package/dist/src/util/coercion.d.ts.map +1 -1
  132. package/dist/src/util/coercion.js +28 -15
  133. package/dist/src/util/coercion.js.map +1 -1
  134. package/dist/src/util/comparison.d.ts +25 -0
  135. package/dist/src/util/comparison.d.ts.map +1 -1
  136. package/dist/src/util/comparison.js +25 -0
  137. package/dist/src/util/comparison.js.map +1 -1
  138. package/dist/src/util/key-tuple-codec.d.ts +12 -3
  139. package/dist/src/util/key-tuple-codec.d.ts.map +1 -1
  140. package/dist/src/util/key-tuple-codec.js.map +1 -1
  141. package/dist/src/util/numeric-canonical.d.ts +26 -0
  142. package/dist/src/util/numeric-canonical.d.ts.map +1 -0
  143. package/dist/src/util/numeric-canonical.js +66 -0
  144. package/dist/src/util/numeric-canonical.js.map +1 -0
  145. package/dist/src/vtab/module.d.ts +25 -0
  146. package/dist/src/vtab/module.d.ts.map +1 -1
  147. package/package.json +4 -3
@@ -0,0 +1,275 @@
1
+ import { StatusCode } from '../common/types.js';
2
+ import { QuereusError } from '../common/errors.js';
3
+ import { PlanNodeType } from '../planner/nodes/plan-node-type.js';
4
+ import { isScalarFunctionSchema } from '../schema/function.js';
5
+ import { assertSpecArity } from './emit/scalar-op.js';
6
+ import { buildScalarFunctionRun } from './emit/scalar-function.js';
7
+ import { buildLiteralSpec } from './emit/literal.js';
8
+ import { buildColumnReferenceSpec } from './emit/column-reference.js';
9
+ import { buildParameterSpec } from './emit/parameter.js';
10
+ import { buildCastSpec } from './emit/cast.js';
11
+ import { buildUnaryOpSpec } from './emit/unary.js';
12
+ import { buildBetweenSpec } from './emit/between.js';
13
+ import { buildBinaryOpSpec } from './emit/binary.js';
14
+ import { buildCaseMatcher } from './emit/case.js';
15
+ import { isTruthy } from '../util/comparison.js';
16
+ /**
17
+ * Largest fused subtree depth. Fused closures nest on the JS call stack where the
18
+ * scheduler's linearized instruction loop did not, so a pathologically deep expression
19
+ * (`a+a+a+…` thousands of terms) could overflow the stack where it works unfused.
20
+ * Past this depth the expression offered to {@link tryFuseScalar} falls back whole to the
21
+ * sub-program path — correct, just unoptimized. Fusion is still retried from depth 0 at
22
+ * every nested `emitCallFromPlan` site the fallback emission reaches (CASE branches, an
23
+ * AND/OR short-circuit right leg), so a deep tree fuses in pieces below those seams rather
24
+ * than not at all. 32 is far above any real expression's nesting.
25
+ */
26
+ export const MAX_FUSION_DEPTH = 32;
27
+ /**
28
+ * Compile `plan` into a single closure, or return undefined if any node in the subtree
29
+ * cannot be fused (an unsupported node type, a subquery, anything that can return a
30
+ * Promise, or a subtree deeper than {@link MAX_FUSION_DEPTH}). Undefined is the normal
31
+ * answer for most of the plan tree; the caller falls back to the sub-program path
32
+ * unchanged.
33
+ *
34
+ * Every fused body comes from the node's own {@link ScalarOpSpec} builder (or, for
35
+ * CASE, from `buildCaseMatcher`) — the same functions the instruction emitters run —
36
+ * so a fused expression and its instruction form cannot disagree on semantics, error
37
+ * messages, or evaluation counts. This compiler only changes HOW operand values reach
38
+ * those bodies: direct nested calls instead of scheduler slots.
39
+ *
40
+ * A scalar function call fuses only when it is provably synchronous — see
41
+ * {@link fuseScalarFunctionCall}. The AND/OR short-circuit form declines through
42
+ * `buildBinaryOpSpec` returning undefined, and subquery/window/aggregate/relational
43
+ * nodes decline as unknown node types — which also keeps every `emitCallFromPlan` call
44
+ * site that passes a relational plan (cache sources, join legs, view-mutation programs)
45
+ * on the sub-program path for free.
46
+ */
47
+ export function tryFuseScalar(plan, ctx) {
48
+ return fuseNode(plan, ctx, 0);
49
+ }
50
+ // NOTE: a subtree that declines partway has already built every spec above the declining
51
+ // node — resolving collations, compiling a constant LIKE matcher — and those are then
52
+ // rebuilt by the fallback `emitPlanNode`. Emit-time only, bounded by subtree size, and the
53
+ // idempotent work (collation lookups record into a Set) cannot diverge. Fine today; if emit
54
+ // latency ever shows up on function-heavy expressions, pre-walk the subtree for unfusable
55
+ // node types before building any spec.
56
+ /** Per-node dispatch. `depth` counts the closure frames already wrapping this node. */
57
+ function fuseNode(plan, ctx, depth) {
58
+ if (depth > MAX_FUSION_DEPTH)
59
+ return undefined;
60
+ switch (plan.nodeType) {
61
+ case PlanNodeType.Literal: {
62
+ // Undefined when the literal holds an unresolved async constant-fold result —
63
+ // the scheduler resolves that Promise; a fused closure could not.
64
+ const spec = buildLiteralSpec(plan);
65
+ return spec && fuseSpec(spec, ctx, depth);
66
+ }
67
+ case PlanNodeType.ColumnReference:
68
+ return fuseSpec(buildColumnReferenceSpec(plan), ctx, depth);
69
+ case PlanNodeType.ParameterReference:
70
+ return fuseSpec(buildParameterSpec(plan), ctx, depth);
71
+ case PlanNodeType.Collate:
72
+ // No runtime effect (mirrors emitCollate) — fuse straight through to the
73
+ // operand. Adds no closure frame, so depth is unchanged.
74
+ return fuseNode(plan.operand, ctx, depth);
75
+ case PlanNodeType.Cast:
76
+ return fuseSpec(buildCastSpec(plan), ctx, depth);
77
+ case PlanNodeType.UnaryOp:
78
+ return fuseSpec(buildUnaryOpSpec(plan), ctx, depth);
79
+ case PlanNodeType.Between:
80
+ return fuseSpec(buildBetweenSpec(plan, ctx), ctx, depth);
81
+ case PlanNodeType.BinaryOp: {
82
+ // Undefined for the AND/OR short-circuit form (subquery right operand),
83
+ // whose right leg is a deferred sub-program rather than a value.
84
+ const spec = buildBinaryOpSpec(plan, ctx);
85
+ return spec && fuseSpec(spec, ctx, depth);
86
+ }
87
+ case PlanNodeType.CaseExpr:
88
+ return fuseCase(plan, ctx, depth);
89
+ case PlanNodeType.ScalarFunctionCall:
90
+ return fuseScalarFunctionCall(plan, ctx, depth);
91
+ default:
92
+ return undefined;
93
+ }
94
+ }
95
+ /**
96
+ * The `AsyncFunction` constructor, which has no global binding — reachable only off an
97
+ * instance. An `async function` / `async` arrow carries `AsyncFunction.prototype` on its
98
+ * prototype chain, so `impl instanceof AsyncFunction` recognizes one.
99
+ *
100
+ * NOTE: `instanceof` is realm-local. A plugin loaded into a *different* JS realm (a worker,
101
+ * an iframe, a `node:vm` context) carries that realm's `AsyncFunction.prototype`, so its
102
+ * async implementation would not be recognized and would fall to step 4's guard — a thrown
103
+ * error with the `isAsync` remedy rather than a wrong answer. No loader in this repo crosses
104
+ * a realm (plugin-loader uses same-realm dynamic `import()`); if one ever does, widen this
105
+ * to also accept `impl[Symbol.toStringTag] === 'AsyncFunction'`, which is realm-agnostic.
106
+ */
107
+ const AsyncFunction = (async () => { }).constructor;
108
+ /**
109
+ * Fuse a scalar function call, but only when its implementation is provably
110
+ * synchronous. A fused node's contract is a plain `SqlValue`, while a `ScalarFunc` is
111
+ * typed `(...args) => MaybePromise<SqlValue>`; admitting `MaybePromise` into the fused
112
+ * contract would put a Promise check and a `.then` path on every node in the chain,
113
+ * which is the sub-program overhead this compiler exists to delete. So the decision is
114
+ * made once here, at emit time, in this order:
115
+ *
116
+ * 1. **A `customEmitter` never fuses.** It builds its own `Instruction` — possibly with
117
+ * sub-programs or async behavior — and this compiler cannot see inside it. Today that
118
+ * excludes `nullif`, `greatest`, `least`, `json_schema` and `mutation_ordinal`;
119
+ * giving custom emitters a fusion hook is parked in
120
+ * `tickets/backlog/feat-fuse-custom-emitter-scalar-functions.md`.
121
+ * 2. **`isAsync === true` never fuses** — the author's explicit declaration.
122
+ * 3. **A declared `async` implementation never fuses**, auto-detected, so the ordinary
123
+ * async UDF needs no flag.
124
+ * 4. **Otherwise fuse, with a guard**: a non-`async` implementation that returns a
125
+ * Promise anyway is invisible to step 3, so the fused body checks and throws a
126
+ * `QuereusError` naming the function and the `isAsync` remedy. One `instanceof` per
127
+ * call — negligible beside the sub-program it replaces — and it converts a silent
128
+ * wrong answer (a Promise flowing on as if it were a value, comparing as garbage)
129
+ * into a loud, actionable error.
130
+ *
131
+ * The body itself is {@link buildScalarFunctionRun}, the same one
132
+ * `emitScalarFunctionCallDefault` gives the scheduler, so a fused call and an
133
+ * instruction call cannot disagree on error text, arity checking or the `REPR_STRICT`
134
+ * return check. Operands compose by arity like every other fused node — including the
135
+ * variadic case (`numArgs === -1`, e.g. `coalesce`), which needs no special handling
136
+ * because the composition switches on `operands.length`, not on the declared arity.
137
+ */
138
+ function fuseScalarFunctionCall(plan, ctx, depth) {
139
+ const schema = plan.functionSchema;
140
+ // Not a scalar schema at all: `emitScalarFunctionCall` reports that, and the unfused
141
+ // path it falls back to still does. Decline rather than duplicate the diagnosis.
142
+ if (!isScalarFunctionSchema(schema))
143
+ return undefined;
144
+ if (schema.customEmitter)
145
+ return undefined;
146
+ if (schema.isAsync)
147
+ return undefined;
148
+ if (schema.implementation instanceof AsyncFunction)
149
+ return undefined;
150
+ const body = buildScalarFunctionRun(plan);
151
+ const functionName = plan.expression.name.toLowerCase();
152
+ const loc = plan.expression.loc?.start;
153
+ const guarded = (rctx, ...args) => {
154
+ const result = body(rctx, ...args);
155
+ if (result instanceof Promise) {
156
+ throw new QuereusError(`Function ${functionName} returned a Promise but is not declared asynchronous. `
157
+ + `Declare isAsync: true on its registration so the engine keeps it off the fused expression path.`, StatusCode.ERROR, undefined, loc?.line, loc?.column);
158
+ }
159
+ return result;
160
+ };
161
+ return composeFused(guarded, plan.operands, ctx, depth);
162
+ }
163
+ /** Check the spec's body arity, then compose it with its fused operands. */
164
+ function fuseSpec(spec, ctx, depth) {
165
+ assertSpecArity(spec);
166
+ return composeFused(spec.run, spec.operands, ctx, depth);
167
+ }
168
+ /**
169
+ * Compose a synchronous body with its fused operands, specialized by arity so the common
170
+ * cases allocate nothing per row and stay monomorphic. Closure composition only — no
171
+ * `new Function`/`eval`, which are unavailable under a Content-Security-Policy and under
172
+ * React Native.
173
+ *
174
+ * Shared by the {@link ScalarOpSpec} nodes and by {@link fuseScalarFunctionCall}, whose
175
+ * variadic body has no fixed parameter count to assert (hence the assert living in
176
+ * {@link fuseSpec}, not here). The switch is on how many operands are actually
177
+ * evaluated, so a variadic function's call site lands in whichever fixed arm matches
178
+ * its argument count.
179
+ */
180
+ function composeFused(run, operands, ctx, depth) {
181
+ switch (operands.length) {
182
+ case 0:
183
+ // The body already IS the fused closure — wrapping it would add a call frame
184
+ // per row to the two most common leaves in any query (column refs, literals).
185
+ return run;
186
+ case 1: {
187
+ const a = fuseNode(operands[0], ctx, depth + 1);
188
+ return a && ((rctx) => run(rctx, a(rctx)));
189
+ }
190
+ case 2: {
191
+ const a = fuseNode(operands[0], ctx, depth + 1);
192
+ if (!a)
193
+ return undefined;
194
+ const b = fuseNode(operands[1], ctx, depth + 1);
195
+ return b && ((rctx) => run(rctx, a(rctx), b(rctx)));
196
+ }
197
+ case 3: {
198
+ const a = fuseNode(operands[0], ctx, depth + 1);
199
+ if (!a)
200
+ return undefined;
201
+ const b = fuseNode(operands[1], ctx, depth + 1);
202
+ if (!b)
203
+ return undefined;
204
+ const c = fuseNode(operands[2], ctx, depth + 1);
205
+ return c && ((rctx) => run(rctx, a(rctx), b(rctx), c(rctx)));
206
+ }
207
+ default: {
208
+ // No spec is wider than 3 operands; a wide variadic call (`coalesce(a,b,c,d)`)
209
+ // lands here. An args array + spread is still far cheaper than a sub-program.
210
+ const fused = [];
211
+ for (const operand of operands) {
212
+ const f = fuseNode(operand, ctx, depth + 1);
213
+ if (!f)
214
+ return undefined;
215
+ fused.push(f);
216
+ }
217
+ return (rctx) => run(rctx, ...fused.map(f => f(rctx)));
218
+ }
219
+ }
220
+ }
221
+ /**
222
+ * CASE is the one covered node that is not a flat {@link ScalarOpSpec}: its branches are
223
+ * lazy. Fuse it only when the base (if any) AND every WHEN/THEN/ELSE fuse — all-or-nothing
224
+ * avoids a mixed contract where some branches are closures and some are sub-programs
225
+ * returning `MaybePromise`. The fused body keeps SQL's evaluation rules exactly as
226
+ * `emitCaseExpr` has them: WHEN clauses left to right, stop at the first match, evaluate
227
+ * ONLY the selected result, never touch a later clause. Match decisions come from
228
+ * `buildCaseMatcher`, so a fused CASE and an instruction CASE cannot disagree.
229
+ *
230
+ * Branch closures are invoked from inside the CASE closure, so their frames stack —
231
+ * they count toward the depth cap (depth + 1), same as spec operands.
232
+ */
233
+ function fuseCase(plan, ctx, depth) {
234
+ const whens = [];
235
+ const thens = [];
236
+ for (const clause of plan.whenThenClauses) {
237
+ const when = fuseNode(clause.when, ctx, depth + 1);
238
+ if (!when)
239
+ return undefined;
240
+ const then = fuseNode(clause.then, ctx, depth + 1);
241
+ if (!then)
242
+ return undefined;
243
+ whens.push(when);
244
+ thens.push(then);
245
+ }
246
+ const elseFn = plan.elseExpr ? fuseNode(plan.elseExpr, ctx, depth + 1) : undefined;
247
+ if (plan.elseExpr && !elseFn)
248
+ return undefined;
249
+ const clauseCount = whens.length;
250
+ // Simple CASE: base compared against each WHEN under the per-clause pre-resolved
251
+ // comparator (collation + type routing). A NULL base matches nothing.
252
+ if (plan.baseExpr) {
253
+ const base = fuseNode(plan.baseExpr, ctx, depth + 1);
254
+ if (!base)
255
+ return undefined;
256
+ const matcher = buildCaseMatcher(plan, ctx);
257
+ return (rctx) => {
258
+ const baseValue = base(rctx);
259
+ for (let i = 0; i < clauseCount; i++) {
260
+ if (matcher.matches(i, baseValue, whens[i](rctx)))
261
+ return thens[i](rctx);
262
+ }
263
+ return elseFn ? elseFn(rctx) : null;
264
+ };
265
+ }
266
+ // Searched CASE: first truthy WHEN selects its THEN.
267
+ return (rctx) => {
268
+ for (let i = 0; i < clauseCount; i++) {
269
+ if (isTruthy(whens[i](rctx)))
270
+ return thens[i](rctx);
271
+ }
272
+ return elseFn ? elseFn(rctx) : null;
273
+ };
274
+ }
275
+ //# sourceMappingURL=scalar-fusion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar-fusion.js","sourceRoot":"","sources":["../../../src/runtime/scalar-fusion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAYlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAuC,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,E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,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;oBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1E,CAAC;YACD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrC,CAAC,CAAC;IACH,CAAC;IAED,qDAAqD;IACrD,OAAO,CAAC,IAAI,EAAE,EAAE;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC,CAAC;AACH,CAAC"}
@@ -19,4 +19,13 @@ export declare const FORK_STRICT: boolean;
19
19
  * § Invariant: source-attr contexts and child pulls.
20
20
  */
21
21
  export declare const CONTEXT_STRICT: boolean;
22
+ /**
23
+ * `QUEREUS_REPR_STRICT` — physical-representation assertions. Verifies at four
24
+ * runtime seams (vtab scan output, DML write, UDF return, statement row egress)
25
+ * that every value is in the JavaScript form its declared type promises — R1
26
+ * (canonical numeric form) and R2 (per-declared-type value space) of
27
+ * docs/types.md § Physical representation. Off, the checks are a single
28
+ * already-false branch. See strict-representation.ts.
29
+ */
30
+ export declare const REPR_STRICT: boolean;
22
31
  //# sourceMappingURL=strict-flags.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strict-flags.d.ts","sourceRoot":"","sources":["../../../src/runtime/strict-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,sFAAsF;AACtF,eAAO,MAAM,WAAW,SAAkC,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,SAAqC,CAAC"}
1
+ {"version":3,"file":"strict-flags.d.ts","sourceRoot":"","sources":["../../../src/runtime/strict-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,sFAAsF;AACtF,eAAO,MAAM,WAAW,SAAkC,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,SAAqC,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,SAAkC,CAAC"}
@@ -23,4 +23,13 @@ export const FORK_STRICT = readFlag('QUEREUS_FORK_STRICT');
23
23
  * § Invariant: source-attr contexts and child pulls.
24
24
  */
25
25
  export const CONTEXT_STRICT = readFlag('QUEREUS_CONTEXT_STRICT');
26
+ /**
27
+ * `QUEREUS_REPR_STRICT` — physical-representation assertions. Verifies at four
28
+ * runtime seams (vtab scan output, DML write, UDF return, statement row egress)
29
+ * that every value is in the JavaScript form its declared type promises — R1
30
+ * (canonical numeric form) and R2 (per-declared-type value space) of
31
+ * docs/types.md § Physical representation. Off, the checks are a single
32
+ * already-false branch. See strict-representation.ts.
33
+ */
34
+ export const REPR_STRICT = readFlag('QUEREUS_REPR_STRICT');
26
35
  //# sourceMappingURL=strict-flags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"strict-flags.js","sourceRoot":"","sources":["../../../src/runtime/strict-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,SAAS,QAAQ,CAAC,IAAY;IAC7B,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,MAAM,CAAC;AAC1C,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"strict-flags.js","sourceRoot":"","sources":["../../../src/runtime/strict-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,SAAS,QAAQ,CAAC,IAAY;IAC7B,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,MAAM,CAAC;AAC1C,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,wBAAwB,CAAC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC"}
@@ -14,7 +14,7 @@ import { FORK_STRICT, CONTEXT_STRICT } from './strict-flags.js';
14
14
  * forks is being driven throws. State is tracked **per parent map** (not
15
15
  * globally) so concurrent unrelated drivers don't interfere, forks may mutate
16
16
  * their own fresh maps freely, and sub-forks are independently tracked.
17
- * See docs/runtime.md § Parallel runtime fork contract.
17
+ * See docs/runtime-parallel.md § Parallel runtime fork contract.
18
18
  *
19
19
  * 2. **`QUEREUS_CONTEXT_STRICT`** — stale-shadow detection. Maintains a per-
20
20
  * descriptor epoch and a per-attribute index-winner map so `assertNoShadow`
@@ -39,7 +39,7 @@ export function strictForkEnabled() {
39
39
  }
40
40
  function violation(target, count) {
41
41
  throw new QuereusError(`strict-fork: parent context mutated ${target} while ${count} fork(s) are active. ` +
42
- `This is a fork-contract violation. See docs/runtime.md § Parallel runtime fork contract.`, StatusCode.INTERNAL);
42
+ `This is a fork-contract violation. See docs/runtime-parallel.md § Parallel runtime fork contract.`, StatusCode.INTERNAL);
43
43
  }
44
44
  /**
45
45
  * Wrap a fresh `tableContexts` Map. In non-strict mode returns the input
@@ -1 +1 @@
1
- {"version":3,"file":"strict-fork.js","sourceRoot":"","sources":["../../../src/runtime/strict-fork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAyB,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,iFAAiF;AACjF,0DAA0D;AAC1D,MAAM,WAAW,GAAG,WAAW,CAAC;AAOhC,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAE3D,+FAA+F;AAC/F,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAE3D,MAAM,UAAU,iBAAiB;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,KAAa;IAC/C,MAAM,IAAI,YAAY,CACrB,uCAAuC,MAAM,UAAU,KAAK,uBAAuB;QACnF,0FAA0F,EAC1F,UAAU,CAAC,QAAQ,CACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAsC;IAEtC,IAAI,CAAC,WAAW;QAAE,OAAO,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAc,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE;QAC5B,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS;YAC1B,MAAM,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KAAa,EAAE,MAAc;IACvD,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,MAAM,WAAW,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,WAAW;QAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACtD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,KAAK,CAAC,WAAW,EAAE,CAAC;IACpB,OAAO,KAAK,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,qBAAqB,CAAC,KAAuB;IAC5D,IAAI,CAAC,WAAW,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC3C,KAAK,CAAC,WAAW,EAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { QuereusError } from '../common/errors.js';
2
+ import { type DeepReadonly, type Row, type SqlValue } from '../common/types.js';
3
+ import { type LogicalType } from '../types/logical-type.js';
4
+ /**
5
+ * Off-by-default physical-representation assertions (`QUEREUS_REPR_STRICT`).
6
+ *
7
+ * The engine canonicalizes every value it MINTS itself (see
8
+ * `util/numeric-canonical.ts` and docs/types.md § Physical representation). Two
9
+ * ingress boundaries are deliberately left uncoerced because coercing them costs
10
+ * per row where there is nothing to win:
11
+ *
12
+ * - rows returned by a virtual-table module's `query()`, including third-party
13
+ * modules the engine cannot vet;
14
+ * - values returned by user-defined functions.
15
+ *
16
+ * For those the contract is **declared and checked, not enforced**: a module or UDF
17
+ * is obliged to return canonical values, and this harness verifies it when the flag
18
+ * is on. Same shape as the parallel-fork (`QUEREUS_FORK_STRICT`) and stale-context
19
+ * (`QUEREUS_CONTEXT_STRICT`) harnesses in `strict-fork.ts`.
20
+ *
21
+ * The two rules checked here, restated from docs/types.md § Physical representation:
22
+ *
23
+ * - **R1 — canonical numeric form.** A `SqlValue` is a JS `bigint` only when its
24
+ * magnitude is outside the safe-integer range. Applies to every value, whatever its
25
+ * declared type, including `ANY` positions.
26
+ * - **R2 — per-declared-type value space.** A value in a position of a declared type
27
+ * inhabits that type's JS value space (INTEGER → safe-integer `number` or `bigint`,
28
+ * TEXT → `string`, BLOB → `Uint8Array`, …). Implies R1.
29
+ *
30
+ * `null` is always admissible: nullability is `not null` constraint enforcement's
31
+ * job and lives elsewhere.
32
+ *
33
+ * **No capability flag.** A `representationFidelity` declaration on
34
+ * `VirtualTableModule` was considered and rejected — nothing would BEHAVE differently
35
+ * based on it, since the engine tolerates both numeric forms everywhere and will
36
+ * continue to. The obligation lives in the module contract prose (`vtab/module.ts`)
37
+ * and is enforced here in tests.
38
+ *
39
+ * Every call site is guarded by `if (REPR_STRICT)` read from the module-level const in
40
+ * `strict-flags.ts`, so with the flag off each seam is one already-false branch and
41
+ * nothing is built at emit time on this module's behalf.
42
+ */
43
+ /**
44
+ * A declared type as this checker reads it. Only `name` and `physicalType` are
45
+ * consulted, and the parameter is `DeepReadonly` so both a raw `LogicalType` (column
46
+ * schema) and the frozen one a `ScalarType` carries are accepted without a cast.
47
+ */
48
+ export type DeclaredType = DeepReadonly<LogicalType>;
49
+ /** A violation of R1/R2. Distinct class so a seam inside a re-wrapping `catch`
50
+ * (the vtab scan) can rethrow it unchanged instead of burying it in a generic
51
+ * "error during query" message. */
52
+ export declare class RepresentationError extends QuereusError {
53
+ constructor(message: string);
54
+ }
55
+ /**
56
+ * R1 for one value: no `bigint` may hold a safe-range integer. Needs no declared type,
57
+ * so this is the check for `ANY` and untyped positions.
58
+ *
59
+ * `where` names the seam and the position (column / argument) and is quoted verbatim
60
+ * into the message — make it something a plugin author who has never read this code
61
+ * can act on, e.g. `` `module 'memory' scan of main.t column 2 (id)` ``.
62
+ */
63
+ export declare function assertCanonicalValue(value: SqlValue, where: string): void;
64
+ /**
65
+ * R2 for one value in a position of declared type `type` (implies R1).
66
+ * See {@link assertCanonicalValue} for what `where` should say.
67
+ */
68
+ export declare function assertConformsToType(value: SqlValue, type: DeclaredType, where: string): void;
69
+ /**
70
+ * Row form of {@link assertConformsToType}. `types[i]` may be `undefined` — an ANY /
71
+ * untyped position, which is normal and gets R1 only, never a reported violation.
72
+ * A cell past the end of `types` is treated the same way.
73
+ *
74
+ * `columnNames[i]`, when supplied, is folded into the `where` text so the message
75
+ * names the column a plugin author declared rather than an ordinal.
76
+ */
77
+ export declare function assertRowConforms(row: Row, types: readonly (DeclaredType | undefined)[], where: string, columnNames?: readonly (string | undefined)[]): void;
78
+ //# sourceMappingURL=strict-representation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-representation.d.ts","sourceRoot":"","sources":["../../../src/runtime/strict-representation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;AAErD;;oCAEoC;AACpC,qBAAa,mBAAoB,SAAQ,YAAY;gBACxC,OAAO,EAAE,MAAM;CAK3B;AAiGD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOzE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS7F;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,EAC5C,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAC3C,IAAI,CAWN"}
@@ -0,0 +1,159 @@
1
+ import { QuereusError } from '../common/errors.js';
2
+ import { StatusCode } from '../common/types.js';
3
+ import { PhysicalType } from '../types/logical-type.js';
4
+ import { isCanonicalNumeric } from '../util/numeric-canonical.js';
5
+ import { valueToText } from '../util/value-text.js';
6
+ /** A violation of R1/R2. Distinct class so a seam inside a re-wrapping `catch`
7
+ * (the vtab scan) can rethrow it unchanged instead of burying it in a generic
8
+ * "error during query" message. */
9
+ export class RepresentationError extends QuereusError {
10
+ constructor(message) {
11
+ super(message, StatusCode.INTERNAL);
12
+ this.name = 'RepresentationError';
13
+ Object.setPrototypeOf(this, RepresentationError.prototype);
14
+ }
15
+ }
16
+ /** Longest value rendering included in a violation message before truncation. */
17
+ const MAX_RENDERED_VALUE = 80;
18
+ /**
19
+ * Render a value for a diagnostic. Routes through {@link valueToText}, which is total
20
+ * over `SqlValue` — deliberately NOT `JSON.stringify`, whose BigInt arm throws
21
+ * ("Do not know how to serialize a BigInt") on exactly the values this checker exists
22
+ * to catch.
23
+ *
24
+ * `valueToText` still stringifies a JSON *document*, so a document holding a value
25
+ * outside `JsonSqlValue` (a nested `bigint`) can throw here. That is itself
26
+ * representation drift, so the failure is folded into the message rather than
27
+ * allowed to replace the violation with a serializer error.
28
+ */
29
+ function renderValue(value) {
30
+ let text;
31
+ try {
32
+ text = valueToText(value) ?? 'null';
33
+ }
34
+ catch (e) {
35
+ const reason = e instanceof Error ? e.message : String(e);
36
+ return `<unrenderable ${jsTypeOf(value)}: ${reason}>`;
37
+ }
38
+ return text.length > MAX_RENDERED_VALUE ? `${text.slice(0, MAX_RENDERED_VALUE)}…` : text;
39
+ }
40
+ /** The JS form of a value, named the way a plugin author would recognize it. */
41
+ function jsTypeOf(value) {
42
+ if (value === null)
43
+ return 'null';
44
+ if (value instanceof Uint8Array)
45
+ return 'Uint8Array';
46
+ if (Array.isArray(value))
47
+ return 'array';
48
+ return typeof value;
49
+ }
50
+ /** The JS forms a declared type admits, for the "expected" half of a message. */
51
+ function admissibleForms(type) {
52
+ switch (type.physicalType) {
53
+ case PhysicalType.INTEGER: return 'a safe-integer number, or a bigint outside the safe-integer range';
54
+ case PhysicalType.REAL: return type.name === 'NUMERIC'
55
+ ? 'a number, or a bigint outside the safe-integer range'
56
+ : 'a number';
57
+ case PhysicalType.TEXT: return 'a string';
58
+ case PhysicalType.BLOB: return 'a Uint8Array';
59
+ case PhysicalType.BOOLEAN: return 'a boolean';
60
+ case PhysicalType.OBJECT: return 'a JSON object/array, or a JSON scalar (string/number/boolean)';
61
+ default: return 'any value in canonical form';
62
+ }
63
+ }
64
+ /**
65
+ * R2 for one non-null value that has already passed R1.
66
+ *
67
+ * Keyed on `physicalType` rather than the type's identity so plugin-registered types
68
+ * are covered too. Two arms need the type NAME as well:
69
+ *
70
+ * - **NUMERIC** shares REAL's `physicalType` (see the NOTE on `NUMERIC_TYPE` in
71
+ * `types/builtin-types.ts`) but its value space includes `bigint`.
72
+ * NOTE: matched by NAME, not by identity against the `NUMERIC_TYPE` singleton the way
73
+ * `isSeekKeySpaceNumeric` matches, because the surrounding switch is deliberately keyed
74
+ * on `physicalType` so plugin-registered types are covered. The cost is that a
75
+ * plugin-registered REAL-physical type *named* `NUMERIC` would silently inherit
76
+ * bigint admission. No such type exists in tree; if one is ever registered, give
77
+ * `LogicalType` an explicit "admits bigint" property and switch on that instead.
78
+ * - **`ANY`/NULL** (`PhysicalType.NULL`) impose no R2 constraint at all — R1 already
79
+ * passed, and an `ANY` position may legitimately hold any storage class.
80
+ *
81
+ * TIMESTAMP needs no special case: it declares `physicalType` INTEGER because it IS an
82
+ * integer instant, so it takes INTEGER's rule. The string temporals (DATE / TIME /
83
+ * DATETIME / TIMESPAN) declare TEXT and take TEXT's — R2 must not demand a `Temporal`
84
+ * object for them.
85
+ */
86
+ function conformsToType(value, type) {
87
+ switch (type.physicalType) {
88
+ case PhysicalType.INTEGER:
89
+ return typeof value === 'bigint' || (typeof value === 'number' && Number.isSafeInteger(value));
90
+ case PhysicalType.REAL:
91
+ return typeof value === 'number' || (typeof value === 'bigint' && type.name === 'NUMERIC');
92
+ case PhysicalType.TEXT:
93
+ return typeof value === 'string';
94
+ case PhysicalType.BLOB:
95
+ return value instanceof Uint8Array;
96
+ case PhysicalType.BOOLEAN:
97
+ return typeof value === 'boolean';
98
+ case PhysicalType.OBJECT:
99
+ // Mirrors JSON_TYPE.validate: a native object/array (a blob is not one), or a
100
+ // JSON scalar — a JSON string scalar is physically a plain `string`.
101
+ return (typeof value === 'object' && !(value instanceof Uint8Array))
102
+ || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
103
+ default:
104
+ // PhysicalType.NULL (ANY / NULL) and any unrecognized plugin code: R1 only.
105
+ return true;
106
+ }
107
+ }
108
+ const DOC_POINTER = 'See docs/types.md § Physical representation.';
109
+ /**
110
+ * R1 for one value: no `bigint` may hold a safe-range integer. Needs no declared type,
111
+ * so this is the check for `ANY` and untyped positions.
112
+ *
113
+ * `where` names the seam and the position (column / argument) and is quoted verbatim
114
+ * into the message — make it something a plugin author who has never read this code
115
+ * can act on, e.g. `` `module 'memory' scan of main.t column 2 (id)` ``.
116
+ */
117
+ export function assertCanonicalValue(value, where) {
118
+ if (value === null || isCanonicalNumeric(value))
119
+ return;
120
+ throw new RepresentationError(`repr-strict: non-canonical numeric at ${where}: the bigint ${renderValue(value)} is inside the ` +
121
+ `safe-integer range and must be a JS number (rule R1). Return the canonical form — ` +
122
+ `\`canonicalizeInteger\` / \`canonicalizeSqlValue\` in util/numeric-canonical.ts do this. ${DOC_POINTER}`);
123
+ }
124
+ /**
125
+ * R2 for one value in a position of declared type `type` (implies R1).
126
+ * See {@link assertCanonicalValue} for what `where` should say.
127
+ */
128
+ export function assertConformsToType(value, type, where) {
129
+ if (value === null)
130
+ return;
131
+ assertCanonicalValue(value, where);
132
+ if (conformsToType(value, type))
133
+ return;
134
+ throw new RepresentationError(`repr-strict: representation mismatch at ${where}: declared type ${type.name} admits ` +
135
+ `${admissibleForms(type)}, but the value is a JS ${jsTypeOf(value)} (${renderValue(value)}) ` +
136
+ `(rule R2). ${DOC_POINTER}`);
137
+ }
138
+ /**
139
+ * Row form of {@link assertConformsToType}. `types[i]` may be `undefined` — an ANY /
140
+ * untyped position, which is normal and gets R1 only, never a reported violation.
141
+ * A cell past the end of `types` is treated the same way.
142
+ *
143
+ * `columnNames[i]`, when supplied, is folded into the `where` text so the message
144
+ * names the column a plugin author declared rather than an ordinal.
145
+ */
146
+ export function assertRowConforms(row, types, where, columnNames) {
147
+ for (let i = 0; i < row.length; i++) {
148
+ const name = columnNames?.[i];
149
+ const at = name ? `${where} column ${i} (${name})` : `${where} column ${i}`;
150
+ const type = types[i];
151
+ if (type === undefined) {
152
+ assertCanonicalValue(row[i], at);
153
+ }
154
+ else {
155
+ assertConformsToType(row[i], type, at);
156
+ }
157
+ }
158
+ }
159
+ //# sourceMappingURL=strict-representation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-representation.js","sourceRoot":"","sources":["../../../src/runtime/strict-representation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAA8C,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAoB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAiDpD;;oCAEoC;AACpC,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IACpD,YAAY,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