@quereus/quereus 4.20.3 → 4.21.1

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 (68) hide show
  1. package/README.md +2 -0
  2. package/dist/src/common/constants.d.ts +8 -1
  3. package/dist/src/common/constants.d.ts.map +1 -1
  4. package/dist/src/common/constants.js +7 -0
  5. package/dist/src/common/constants.js.map +1 -1
  6. package/dist/src/core/database.d.ts +4 -1
  7. package/dist/src/core/database.d.ts.map +1 -1
  8. package/dist/src/core/database.js +10 -4
  9. package/dist/src/core/database.js.map +1 -1
  10. package/dist/src/core/statement.d.ts +12 -0
  11. package/dist/src/core/statement.d.ts.map +1 -1
  12. package/dist/src/core/statement.js +20 -2
  13. package/dist/src/core/statement.js.map +1 -1
  14. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  15. package/dist/src/func/builtins/scalar.js +3 -0
  16. package/dist/src/func/builtins/scalar.js.map +1 -1
  17. package/dist/src/func/registration.d.ts +4 -0
  18. package/dist/src/func/registration.d.ts.map +1 -1
  19. package/dist/src/func/registration.js +11 -1
  20. package/dist/src/func/registration.js.map +1 -1
  21. package/dist/src/index.d.ts +2 -0
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/index.js +1 -0
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/planner/analysis/change-scope.d.ts +58 -2
  26. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
  27. package/dist/src/planner/analysis/change-scope.js +94 -73
  28. package/dist/src/planner/analysis/change-scope.js.map +1 -1
  29. package/dist/src/planner/analysis/non-det-functions.d.ts +10 -0
  30. package/dist/src/planner/analysis/non-det-functions.d.ts.map +1 -0
  31. package/dist/src/planner/analysis/non-det-functions.js +17 -0
  32. package/dist/src/planner/analysis/non-det-functions.js.map +1 -0
  33. package/dist/src/planner/analysis/value-provenance.d.ts +119 -0
  34. package/dist/src/planner/analysis/value-provenance.d.ts.map +1 -0
  35. package/dist/src/planner/analysis/value-provenance.js +416 -0
  36. package/dist/src/planner/analysis/value-provenance.js.map +1 -0
  37. package/dist/src/planner/analysis/write-scope.d.ts +150 -0
  38. package/dist/src/planner/analysis/write-scope.d.ts.map +1 -0
  39. package/dist/src/planner/analysis/write-scope.js +95 -0
  40. package/dist/src/planner/analysis/write-scope.js.map +1 -0
  41. package/dist/src/planner/analysis/write-site-analysis.d.ts +67 -0
  42. package/dist/src/planner/analysis/write-site-analysis.d.ts.map +1 -0
  43. package/dist/src/planner/analysis/write-site-analysis.js +354 -0
  44. package/dist/src/planner/analysis/write-site-analysis.js.map +1 -0
  45. package/dist/src/planner/building/delete.d.ts.map +1 -1
  46. package/dist/src/planner/building/delete.js +9 -1
  47. package/dist/src/planner/building/delete.js.map +1 -1
  48. package/dist/src/planner/building/insert.d.ts.map +1 -1
  49. package/dist/src/planner/building/insert.js +8 -1
  50. package/dist/src/planner/building/insert.js.map +1 -1
  51. package/dist/src/planner/building/update.d.ts.map +1 -1
  52. package/dist/src/planner/building/update.js +9 -2
  53. package/dist/src/planner/building/update.js.map +1 -1
  54. package/dist/src/planner/nodes/dml-executor-node.d.ts +18 -1
  55. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  56. package/dist/src/planner/nodes/dml-executor-node.js +12 -2
  57. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  58. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  59. package/dist/src/runtime/emit/dml-executor.js +39 -12
  60. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  61. package/dist/src/schema/assertion.d.ts +3 -1
  62. package/dist/src/schema/assertion.d.ts.map +1 -1
  63. package/dist/src/schema/assertion.js.map +1 -1
  64. package/dist/src/vtab/table.d.ts +16 -0
  65. package/dist/src/vtab/table.d.ts.map +1 -1
  66. package/dist/src/vtab/table.js +7 -0
  67. package/dist/src/vtab/table.js.map +1 -1
  68. package/package.json +3 -3
@@ -0,0 +1,416 @@
1
+ import { FunctionFlags } from '../../common/constants.js';
2
+ import { createLogger } from '../../common/logger.js';
3
+ import { PhysicalType } from '../../types/logical-type.js';
4
+ import { ANY_TYPE, BLOB_TYPE, TEXT_TYPE } from '../../types/builtin-types.js';
5
+ import { buildCellCoercion } from '../../types/validation.js';
6
+ import { PlanNodeType } from '../nodes/plan-node-type.js';
7
+ import { classifyNonDetFunction } from './non-det-functions.js';
8
+ import { planTimeLiteralValue } from './predicate-shape.js';
9
+ import { sqlValueIdentical } from '../../util/comparison.js';
10
+ const log = createLogger('planner:analysis:value-provenance');
11
+ /**
12
+ * Operators that keep a `fresh` operand fresh: injective over the values a fresh source
13
+ * produces, so a unique input stays unique. Holds only when the fresh operand is the
14
+ * operator's single non-literal operand (`||` qualifies only against a literal).
15
+ *
16
+ * Only `hex` is injective over a blob. The others render a blob operand as text first,
17
+ * and that decode is non-fatal — invalid UTF-8 collapses to U+FFFD (`util/value-text.ts`)
18
+ * — so over a statically blob-typed fresh operand they yield `other`. A `cast`, and the
19
+ * planner's write coercion (otherwise looked through, like `collate`), keep `fresh` only
20
+ * across a lossless conversion: see {@link conversionKeepsFresh}.
21
+ *
22
+ * NOTE: `lower` / `upper` are injective only over single-case text — they are listed for
23
+ * the common `lower(hex(randomblob(16)))` id spelling. Revisit when a module needs another
24
+ * wrapper recognised, or a case-mixed fresh text source makes lowercasing lossy.
25
+ */
26
+ export const FRESH_PRESERVING_WRAPPERS = {
27
+ functions: new Set(['hex', 'lower', 'upper']),
28
+ /** The subset of `functions` injective over a blob operand too. */
29
+ blobSafeFunctions: new Set(['hex']),
30
+ nodeTypes: new Set([PlanNodeType.Cast]),
31
+ binaryOperators: new Set(['||']),
32
+ };
33
+ /** `randomblob(n)` is fresh only for a literal n of at least this many bytes (128 bits). */
34
+ const FRESH_RANDOMBLOB_MIN_BYTES = 16;
35
+ const OTHER = { kind: 'other' };
36
+ const RANK = {
37
+ literal: 0, input: 1, fresh: 2, volatile: 3, self: 4, other: 5,
38
+ };
39
+ const OPERATOR_NODE_TYPES = new Set([
40
+ PlanNodeType.UnaryOp, PlanNodeType.BinaryOp, PlanNodeType.CaseExpr, PlanNodeType.Cast, PlanNodeType.Between,
41
+ ]);
42
+ /* --- Expression classification ------------------------------------------------ */
43
+ /** Classify one scalar expression bottom-up against `env`. */
44
+ export function classifyExpression(expr, env) {
45
+ switch (expr.nodeType) {
46
+ case PlanNodeType.Literal: {
47
+ const value = planTimeLiteralValue(expr);
48
+ return value === undefined ? { kind: 'literal' } : { kind: 'literal', value };
49
+ }
50
+ case PlanNodeType.ParameterReference:
51
+ return { kind: 'input', parameters: [expr.nameOrIndex], contexts: [] };
52
+ case PlanNodeType.ColumnReference:
53
+ return classifyColumnReference(expr, env);
54
+ case PlanNodeType.ScalarFunctionCall:
55
+ return classifyFunctionCall(expr, env);
56
+ case PlanNodeType.WriteCoercion:
57
+ return classifyWriteCoercion(expr, env);
58
+ case PlanNodeType.Collate:
59
+ // Identity on the value: only the comparison collation changes.
60
+ return classifyExpression(expr.operand, env);
61
+ case PlanNodeType.In:
62
+ return expr.source ? OTHER : classifyOperator(expr, env);
63
+ default:
64
+ // ScalarSubquery / Exists read other rows; anything else is undescribable.
65
+ return OPERATOR_NODE_TYPES.has(expr.nodeType) ? classifyOperator(expr, env) : OTHER;
66
+ }
67
+ }
68
+ /**
69
+ * The planner's conversion of an inserted cell to its column's declared type. The insert
70
+ * builder wraps nearly every cell in one, so it is not an operator (that would strip
71
+ * `value` from almost every inserted literal). A source already in table shape gets no
72
+ * wrap; `classifyInsertColumns` applies the same conversion rule for that path.
73
+ */
74
+ function classifyWriteCoercion(node, env) {
75
+ const operand = classifyExpression(node.operand, env);
76
+ return afterWriteConversion(operand, node.operand.getType().logicalType, node.targetType.logicalType, node.columnName);
77
+ }
78
+ /**
79
+ * `provenance` of a value of static type `from` once the write converts it to a column of
80
+ * declared type `to` (`buildCellCoercion` — the insert path's write coercion and the
81
+ * UPDATE / DO UPDATE assignment conversion alike): a literal's `value` becomes its stored
82
+ * form, and a fresh value stays fresh only across a lossless conversion.
83
+ */
84
+ function afterWriteConversion(provenance, from, to, columnName) {
85
+ switch (provenance.kind) {
86
+ case 'fresh':
87
+ return conversionKeepsFresh(from, to) ? provenance : OTHER;
88
+ case 'literal':
89
+ return provenance.value === undefined ? provenance : writtenLiteral(provenance.value, from, to, columnName);
90
+ default:
91
+ return provenance;
92
+ }
93
+ }
94
+ function writtenLiteral(value, from, to, columnName) {
95
+ const coerce = buildCellCoercion(from, to, columnName);
96
+ if (!coerce)
97
+ return { kind: 'literal', value };
98
+ try {
99
+ return { kind: 'literal', value: coerce(value) };
100
+ }
101
+ catch (e) {
102
+ // The write raises this same mismatch when the statement runs; until then there is
103
+ // no stored value to report.
104
+ log('literal for column %s does not convert to its declared type: %s', columnName, e instanceof Error ? e.message : String(e));
105
+ return { kind: 'literal' };
106
+ }
107
+ }
108
+ /**
109
+ * Whether converting a fresh value of static type `from` to `to` keeps it unique. Identity
110
+ * and text→blob (UTF-8 encoding) do; blob→text decodes non-fatally, and a numeric,
111
+ * temporal or JSON parse normalizes, so neither does. A source of unknown type (`ANY` —
112
+ * e.g. a function registered without a return type) is trusted on the registrant's promise.
113
+ *
114
+ * NOTE: so an untyped fresh function returning a blob, written to a text column, stays
115
+ * `fresh` although the decode is lossy. Revisit if `fresh: true` comes to require a
116
+ * declared return type.
117
+ */
118
+ function conversionKeepsFresh(from, to) {
119
+ if (from === to || from === ANY_TYPE || to === ANY_TYPE)
120
+ return true;
121
+ if (to === TEXT_TYPE)
122
+ return from.physicalType === PhysicalType.TEXT;
123
+ if (to === BLOB_TYPE)
124
+ return from.physicalType === PhysicalType.TEXT || from.physicalType === PhysicalType.BLOB;
125
+ return false;
126
+ }
127
+ function classifyColumnReference(ref, env) {
128
+ const binding = env.attributes.get(ref.attributeId);
129
+ switch (binding?.kind) {
130
+ case 'self': return { kind: 'self', columns: [binding.column] };
131
+ case 'context': return { kind: 'input', parameters: [], contexts: [binding.name] };
132
+ // A column this write has not classified yet (a cycle the builder's topological
133
+ // ordering should make impossible) has no known provenance.
134
+ case 'new': return env.newColumns?.get(binding.column) ?? OTHER;
135
+ case 'value': return binding.provenance;
136
+ default: return OTHER;
137
+ }
138
+ }
139
+ function classifyFunctionCall(call, env) {
140
+ const schema = call.functionSchema;
141
+ const name = schema.name.toLowerCase();
142
+ if ((schema.flags & FunctionFlags.FRESH) !== 0)
143
+ return { kind: 'fresh', function: name };
144
+ if ((schema.flags & FunctionFlags.DETERMINISTIC) !== 0)
145
+ return classifyOperator(call, env);
146
+ if (name === 'randomblob' && isFreshRandomblobLength(call.operands))
147
+ return { kind: 'fresh', function: name };
148
+ // A volatile call is itself a volatile operand over its arguments.
149
+ const operands = call.operands.map(operand => classifyExpression(operand, env));
150
+ return combineOperands([{ kind: 'volatile', sources: [classifyNonDetFunction(name)] }, ...operands], false);
151
+ }
152
+ function isFreshRandomblobLength(operands) {
153
+ if (operands.length !== 1)
154
+ return false;
155
+ const n = planTimeLiteralValue(operands[0]);
156
+ return (typeof n === 'number' && Number.isInteger(n) && n >= FRESH_RANDOMBLOB_MIN_BYTES)
157
+ || (typeof n === 'bigint' && n >= BigInt(FRESH_RANDOMBLOB_MIN_BYTES));
158
+ }
159
+ function classifyOperator(expr, env) {
160
+ const children = expr.getChildren();
161
+ const operands = children.map(child => classifyExpression(child, env));
162
+ const freshIndex = operands.findIndex(p => p.kind === 'fresh');
163
+ return combineOperands(operands, freshIndex >= 0 && wrapperKeepsFresh(expr, children[freshIndex]));
164
+ }
165
+ /** Whether `expr` is a fresh-preserving wrapper over its operand `freshOperand`. */
166
+ function wrapperKeepsFresh(expr, freshOperand) {
167
+ const operandType = freshOperand.getType().logicalType;
168
+ const isBlob = operandType.physicalType === PhysicalType.BLOB;
169
+ switch (expr.nodeType) {
170
+ case PlanNodeType.ScalarFunctionCall: {
171
+ const name = expr.functionSchema.name.toLowerCase();
172
+ return FRESH_PRESERVING_WRAPPERS.functions.has(name)
173
+ && (!isBlob || FRESH_PRESERVING_WRAPPERS.blobSafeFunctions.has(name));
174
+ }
175
+ case PlanNodeType.BinaryOp:
176
+ return !isBlob && FRESH_PRESERVING_WRAPPERS.binaryOperators.has(expr.expression.operator);
177
+ default:
178
+ return FRESH_PRESERVING_WRAPPERS.nodeTypes.has(expr.nodeType)
179
+ && conversionKeepsFresh(operandType, expr.getType().logicalType);
180
+ }
181
+ }
182
+ /**
183
+ * Combine an operator's operand provenances: the highest rank wins and the detail
184
+ * arrays of that kind are unioned. A computed constant drops its literal `value`.
185
+ * A fresh operand survives only through a fresh-preserving wrapper whose single
186
+ * non-literal operand it is; otherwise a non-injective function of a unique value is
187
+ * not unique, so the result is `other`.
188
+ */
189
+ function combineOperands(operands, preservesFresh) {
190
+ const fresh = operands.find(p => p.kind === 'fresh');
191
+ if (fresh) {
192
+ const nonLiteral = operands.filter(p => p.kind !== 'literal');
193
+ return preservesFresh && nonLiteral.length === 1 ? fresh : OTHER;
194
+ }
195
+ return joinByRank(operands);
196
+ }
197
+ /** Highest-rank kind among `parts` (no `fresh` among them), with that kind's details unioned. */
198
+ function joinByRank(parts) {
199
+ let top = 'literal';
200
+ for (const part of parts) {
201
+ if (RANK[part.kind] > RANK[top])
202
+ top = part.kind;
203
+ }
204
+ switch (top) {
205
+ case 'literal':
206
+ return { kind: 'literal' };
207
+ case 'input':
208
+ return {
209
+ kind: 'input',
210
+ parameters: unionDetails(parts, p => p.kind === 'input' ? p.parameters : [], String),
211
+ contexts: unionDetails(parts, p => p.kind === 'input' ? p.contexts : [], String),
212
+ };
213
+ case 'volatile':
214
+ return { kind: 'volatile', sources: unionDetails(parts, p => p.kind === 'volatile' ? p.sources : [], nonDetSourceKey) };
215
+ case 'self':
216
+ return { kind: 'self', columns: unionDetails(parts, p => p.kind === 'self' ? p.columns : [], String) };
217
+ default:
218
+ return OTHER;
219
+ }
220
+ }
221
+ function unionDetails(parts, pick, keyOf) {
222
+ const seen = new Map();
223
+ for (const part of parts) {
224
+ for (const item of pick(part)) {
225
+ const key = keyOf(item);
226
+ if (!seen.has(key))
227
+ seen.set(key, item);
228
+ }
229
+ }
230
+ return [...seen.values()];
231
+ }
232
+ function nonDetSourceKey(source) {
233
+ switch (source.kind) {
234
+ case 'volatileUdf': return `udf:${source.name}`;
235
+ case 'parameter': return `param:${String(source.index)}`;
236
+ default: return source.kind;
237
+ }
238
+ }
239
+ /**
240
+ * Join one column's cells across the rows of a multi-row VALUES. Not an operator: each
241
+ * row's value is written as is, so a column stays fresh only when every row draws from
242
+ * the same fresh source, and stays a literal with a `value` only when every row agrees.
243
+ */
244
+ function joinRows(cells) {
245
+ if (cells.length === 1)
246
+ return cells[0];
247
+ if (cells.some(cell => cell.kind === 'fresh')) {
248
+ const first = cells[0];
249
+ return first.kind === 'fresh' && cells.every(cell => cell.kind === 'fresh' && cell.function === first.function)
250
+ ? first
251
+ : OTHER;
252
+ }
253
+ const joined = joinByRank(cells);
254
+ if (joined.kind === 'literal') {
255
+ const first = cells[0];
256
+ const value = first?.kind === 'literal' ? first.value : undefined;
257
+ const agree = value !== undefined
258
+ && cells.every(cell => cell.kind === 'literal' && cell.value !== undefined && sqlValueIdentical(cell.value, value));
259
+ return agree ? { kind: 'literal', value } : joined;
260
+ }
261
+ return joined;
262
+ }
263
+ /* --- Relational walk (INSERT source) ------------------------------------------- */
264
+ /**
265
+ * Provenance of each output attribute of an INSERT source: walks the ProjectNode chain
266
+ * the insert builder stacks (row expansion, expression defaults, generated columns) down
267
+ * to a ValuesNode. A chain that bottoms out in any other relational node contributes
268
+ * nothing, so references into it classify `other`.
269
+ */
270
+ function relationProvenance(rel, env) {
271
+ switch (rel.nodeType) {
272
+ case PlanNodeType.Values:
273
+ return valuesProvenance(rel, env);
274
+ case PlanNodeType.Project:
275
+ return projectProvenance(rel, env);
276
+ default:
277
+ return new Map();
278
+ }
279
+ }
280
+ function valuesProvenance(values, env) {
281
+ const out = new Map();
282
+ values.getAttributes().forEach((attr, colIdx) => {
283
+ out.set(attr.id, joinRows(values.rows.map(row => classifyExpression(row[colIdx], env))));
284
+ });
285
+ return out;
286
+ }
287
+ function projectProvenance(project, env) {
288
+ const inner = relationProvenance(project.source, env);
289
+ const innerEnv = withValueBindings(env, inner);
290
+ const out = new Map();
291
+ const attributes = project.getAttributes();
292
+ project.projections.forEach((projection, i) => {
293
+ out.set(attributes[i].id, classifyExpression(projection.node, innerEnv));
294
+ });
295
+ return out;
296
+ }
297
+ function withValueBindings(env, provenances) {
298
+ if (provenances.size === 0)
299
+ return env;
300
+ const attributes = new Map(env.attributes);
301
+ for (const [id, provenance] of provenances)
302
+ attributes.set(id, { kind: 'value', provenance });
303
+ return { ...env, attributes };
304
+ }
305
+ /* --- Environments ---------------------------------------------------------------- */
306
+ function contextBindings(contextAttributes) {
307
+ const out = new Map();
308
+ for (const attr of contextAttributes ?? []) {
309
+ out.set(attr.id, { kind: 'context', name: attr.name.toLowerCase() });
310
+ }
311
+ return out;
312
+ }
313
+ /** Each attribute id of a row descriptor, paired with the column name at its index. */
314
+ function descriptorColumns(descriptor, columnNames) {
315
+ const out = new Map();
316
+ descriptor?.forEach((colIdx, attrId) => {
317
+ const column = columnNames[colIdx];
318
+ if (column !== undefined)
319
+ out.set(attrId, column);
320
+ });
321
+ return out;
322
+ }
323
+ /**
324
+ * Classify a list of assignments in order. A user assignment reads the target row's
325
+ * previous values (`baseEnv`); a generated-column recompute is evaluated against the
326
+ * post-assignment row, so its reference to a previous-value attribute of a column already
327
+ * assigned resolves to that assignment's provenance instead.
328
+ */
329
+ function classifyAssignments(assignments, baseEnv, selfAttributeColumns) {
330
+ const written = [];
331
+ const assigned = new Map();
332
+ for (const { target, value, isGenerated } of assignments) {
333
+ const column = target.name.toLowerCase();
334
+ const env = isGenerated ? postAssignmentEnv(baseEnv, selfAttributeColumns, assigned) : baseEnv;
335
+ // Assignments carry no write-coercion node; the executor converts each value to
336
+ // the column's declared type before storing it (and before a generated column reads it).
337
+ const provenance = afterWriteConversion(classifyExpression(value, env), value.getType().logicalType, target.logicalType, target.name);
338
+ assigned.set(column, provenance);
339
+ written.push({ column, provenance });
340
+ }
341
+ return written;
342
+ }
343
+ function postAssignmentEnv(baseEnv, selfAttributeColumns, assigned) {
344
+ const attributes = new Map(baseEnv.attributes);
345
+ for (const [attrId, column] of selfAttributeColumns) {
346
+ const provenance = assigned.get(column);
347
+ if (provenance)
348
+ attributes.set(attrId, { kind: 'value', provenance });
349
+ }
350
+ return { ...baseEnv, attributes };
351
+ }
352
+ /* --- Entry points ---------------------------------------------------------------- */
353
+ /** One entry per table column, in schema order: the value the INSERT writes there. */
354
+ export function classifyInsertColumns(node) {
355
+ const env = { attributes: contextBindings(node.contextAttributes) };
356
+ const provenances = relationProvenance(node.source, env);
357
+ const sourceAttributes = node.source.getAttributes();
358
+ return node.table.tableSchema.columns.map((col, i) => {
359
+ const attr = sourceAttributes[i];
360
+ const provenance = attr && provenances.get(attr.id);
361
+ // emitInsert converts each cell from its source attribute's static type to the
362
+ // column's declared type, whether or not the builder planned a WriteCoercionNode
363
+ // (a source already in table shape gets none). Behind a planned coercion the
364
+ // attribute already carries the declared type, so a fresh label passes unchanged
365
+ // and a literal's converted value passes buildCellCoercion's identity guard as-is.
366
+ return {
367
+ column: col.name.toLowerCase(),
368
+ provenance: provenance ? afterWriteConversion(provenance, attr.type.logicalType, col.logicalType, col.name) : OTHER,
369
+ };
370
+ });
371
+ }
372
+ /** One entry per assignment (user SETs, then generated recomputes), in assignment order. */
373
+ export function classifyUpdateColumns(node) {
374
+ const { columns, columnIndexMap } = node.table.tableSchema;
375
+ // SET and WHERE bind to the source relation's attributes — the target row's previous values.
376
+ const selfAttributeColumns = new Map();
377
+ node.source.getAttributes().forEach((attr, i) => {
378
+ selfAttributeColumns.set(attr.id, (columns[i]?.name ?? attr.name).toLowerCase());
379
+ });
380
+ const attributes = contextBindings(node.contextAttributes);
381
+ for (const [attrId, column] of selfAttributeColumns)
382
+ attributes.set(attrId, { kind: 'self', column });
383
+ const assignments = node.assignments.flatMap(a => {
384
+ const target = columns[columnIndexMap.get(a.targetColumn.name.toLowerCase()) ?? -1];
385
+ return target ? [{ target, value: a.value, isGenerated: a.isGenerated === true }] : [];
386
+ });
387
+ return classifyAssignments(assignments, { attributes }, selfAttributeColumns);
388
+ }
389
+ /**
390
+ * The DO UPDATE arm's assignments (empty for DO NOTHING) on `table`, the statement's
391
+ * target. `insertColumns` is the statement's {@link classifyInsertColumns} result: NEW
392
+ * references resolve to it; existing-row references are `self`.
393
+ */
394
+ export function classifyUpsertUpdateColumns(clause, table, insertColumns) {
395
+ if (clause.action !== 'update' || !clause.assignments)
396
+ return [];
397
+ const columnNames = table.columns.map(c => c.name.toLowerCase());
398
+ const selfAttributeColumns = descriptorColumns(clause.existingRowDescriptor, columnNames);
399
+ const attributes = new Map();
400
+ for (const [attrId, column] of descriptorColumns(clause.newRowDescriptor, columnNames)) {
401
+ attributes.set(attrId, { kind: 'new', column });
402
+ }
403
+ for (const [attrId, column] of selfAttributeColumns)
404
+ attributes.set(attrId, { kind: 'self', column });
405
+ const env = {
406
+ attributes,
407
+ newColumns: new Map(insertColumns.map(c => [c.column, c.provenance])),
408
+ };
409
+ const generated = new Set(clause.generatedAssignmentColumns ?? []);
410
+ const assignments = [...clause.assignments].flatMap(([colIdx, value]) => {
411
+ const target = table.columns[colIdx];
412
+ return target ? [{ target, value, isGenerated: generated.has(colIdx) }] : [];
413
+ });
414
+ return classifyAssignments(assignments, env, selfAttributeColumns);
415
+ }
416
+ //# sourceMappingURL=value-provenance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-provenance.js","sourceRoot":"","sources":["../../../../src/planner/analysis/value-provenance.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAoB,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,C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,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;KACrE,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE;QACvE,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAA6B,CAAC;QACjE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,mBAAmB,CAAC,WAAW,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Public write-scope data contract.
3
+ *
4
+ * `WriteScope` describes a prepared write statement (INSERT, UPDATE, DELETE) for a
5
+ * host that will replay it later over state another writer may have changed: which
6
+ * rows it targets and how it chose them, where each written value comes from, what
7
+ * else it reads, which constraints could reject it, and whether re-applying it to its
8
+ * own result would change anything. It reuses change-scope's vocabulary
9
+ * (`QualifiedName`, `TableWatch`, `ScopeValue`, `NonDetSource`) so a host already
10
+ * consuming change scopes reads it without learning new shapes.
11
+ *
12
+ * The analysis itself runs on the write site's logical plan, captured at build time
13
+ * (`write-site-analysis.ts`); this module holds the contract, the parameter binder and
14
+ * the serializers. See docs/write-scope.md.
15
+ */
16
+ import type { SqlParameters, SqlValue } from '../../common/types.js';
17
+ import type { Database } from '../../core/database.js';
18
+ import type { PlanNode } from '../nodes/plan-node.js';
19
+ import { type NonDetSource, type QualifiedName, type ScopeValue, type SerializedTableWatch, type TableWatch } from './change-scope.js';
20
+ import type { WrittenColumn } from './value-provenance.js';
21
+ export type { ValueProvenance, WrittenColumn } from './value-provenance.js';
22
+ export interface WriteScope {
23
+ /**
24
+ * One entry per write site in the statement, in plan order (a plain DML statement
25
+ * has one; a statement writing through a view that fans out to several base
26
+ * tables, or carrying data-modifying CTEs, has several).
27
+ */
28
+ readonly writes: ReadonlyArray<TableWrite>;
29
+ readonly nonDeterministicSources: ReadonlyArray<NonDetSource>;
30
+ readonly unboundParameters: ReadonlyArray<number | string>;
31
+ }
32
+ export interface TableWrite {
33
+ readonly table: QualifiedName;
34
+ readonly operation: 'insert' | 'update' | 'delete';
35
+ /** What happens on a constraint conflict. */
36
+ readonly disposition: WriteDisposition;
37
+ /** How existing target rows were chosen. INSERT: `none`. */
38
+ readonly selection: TargetSelection;
39
+ /**
40
+ * The values written, with provenance. INSERT: every table column in schema order.
41
+ * UPDATE: assigned columns in assignment order. DELETE: empty.
42
+ */
43
+ readonly columns: ReadonlyArray<WrittenColumn>;
44
+ /**
45
+ * Everything the write reads to decide its effect, other than the target rows' own
46
+ * key: WHERE and SET inputs, the INSERT source query, constraint-check subqueries.
47
+ * A watch on the target table itself appears here only for non-key columns it
48
+ * reads (`set n = n + 1` reads `n`; a predicate on a non-key column reads that
49
+ * column).
50
+ */
51
+ readonly reads: ReadonlyArray<TableWatch>;
52
+ /** The constraints this write is subject to, each classed by whether other rows can affect it. */
53
+ readonly constraints: ReadonlyArray<WriteConstraint>;
54
+ /**
55
+ * True when no written value depends on the target row's own previous values or
56
+ * on other rows — re-applying the write to its own result changes nothing.
57
+ * Distinct from `PhysicalProperties.idempotent` ("safe to evaluate twice in one
58
+ * transaction").
59
+ */
60
+ readonly selfIndependent: boolean;
61
+ }
62
+ export type WriteDisposition = {
63
+ readonly kind: 'abort';
64
+ } | {
65
+ readonly kind: 'fail';
66
+ } | {
67
+ readonly kind: 'rollback';
68
+ } | {
69
+ readonly kind: 'ignore';
70
+ } | {
71
+ readonly kind: 'replace';
72
+ } | {
73
+ readonly kind: 'upsert';
74
+ readonly clauses: ReadonlyArray<UpsertClause>;
75
+ };
76
+ export interface UpsertClause {
77
+ /** Conflict-target columns, or `'primary-key'` when the clause named none. */
78
+ readonly target: ReadonlyArray<string> | 'primary-key';
79
+ readonly action: 'nothing' | 'update';
80
+ /** DO UPDATE assignments with provenance (empty for `nothing`). */
81
+ readonly columns: ReadonlyArray<WrittenColumn>;
82
+ /** True when the DO UPDATE arm carries a WHERE. */
83
+ readonly conditional: boolean;
84
+ }
85
+ export type TargetSelection = {
86
+ readonly kind: 'none';
87
+ }
88
+ /** Chosen by equality on a unique key; `values` as in `WatchScope.rows` (literals, or parameter placeholders until bound). */
89
+ | {
90
+ readonly kind: 'rows';
91
+ readonly key: ReadonlyArray<string>;
92
+ readonly values: ReadonlyArray<ReadonlyArray<ScopeValue>>;
93
+ }
94
+ /** Chosen by any other predicate, or no predicate, or a key the analysis could not decode. */
95
+ | {
96
+ readonly kind: 'global';
97
+ };
98
+ export interface WriteConstraint {
99
+ readonly name?: string;
100
+ readonly kind: 'primary-key' | 'unique' | 'not-null' | 'check' | 'foreign-key-child' | 'foreign-key-parent' | 'assertion';
101
+ /**
102
+ * Target-table columns the constraint involves (the key columns; the NOT NULL
103
+ * column; the columns an FK references or is referenced by; empty when unknown,
104
+ * e.g. an assertion).
105
+ */
106
+ readonly columns: ReadonlyArray<string>;
107
+ /**
108
+ * `row`: decidable from the written row alone. `cross-row`: other rows can make it
109
+ * pass or fail — every key, every FK, every assertion, and a CHECK that contains a
110
+ * subquery or a committed-state reference.
111
+ */
112
+ readonly locality: 'row' | 'cross-row';
113
+ /** When it is enforced. Assertions are always `deferred` (commit time). */
114
+ readonly timing: 'immediate' | 'deferred';
115
+ /** For `unique`: the constraint has a predicate. */
116
+ readonly partial?: boolean;
117
+ /** For FKs and assertions: the other table involved (an assertion lists its first other dependent table, if any). */
118
+ readonly references?: QualifiedName;
119
+ }
120
+ /**
121
+ * The write scope of a built plan: every write site's memoized analysis, in plan
122
+ * order, with the non-deterministic sources and unbound parameters unioned. A plan
123
+ * with no write site yields empty `writes`, never `undefined`.
124
+ */
125
+ export declare function analyzeWriteScope(plan: PlanNode, db: Database): WriteScope;
126
+ /**
127
+ * Substitute bound parameters into every selection and read watch, dropping the bound
128
+ * indices from `unboundParameters` and `nonDeterministicSources`. Same key spellings,
129
+ * and the same `MisuseError` on binding one parameter twice, as change-scope's
130
+ * `bindParameters` — which does the work, per watch.
131
+ */
132
+ export declare function bindWriteParameters(scope: WriteScope, params: SqlParameters | SqlValue[]): WriteScope;
133
+ /**
134
+ * Substitute bound parameters into one write's selection and read watches. The DML
135
+ * executor applies it per execution to the write it hands an opted-in module
136
+ * (`UpdateArgs.writeScope`).
137
+ */
138
+ export declare function bindTableWrite(write: TableWrite, params: SqlParameters | SqlValue[]): TableWrite;
139
+ export interface SerializedTableWrite extends Omit<TableWrite, 'reads'> {
140
+ readonly reads: ReadonlyArray<SerializedTableWatch>;
141
+ }
142
+ export interface SerializedWriteScope {
143
+ readonly writes: ReadonlyArray<SerializedTableWrite>;
144
+ readonly nonDeterministicSources: ReadonlyArray<NonDetSource>;
145
+ readonly unboundParameters: ReadonlyArray<number | string>;
146
+ }
147
+ /** The only non-plain field is `TableWatch.columns`; everything else is JSON already. */
148
+ export declare function serializeWriteScope(scope: WriteScope): SerializedWriteScope;
149
+ export declare function deserializeWriteScope(obj: SerializedWriteScope): WriteScope;
150
+ //# sourceMappingURL=write-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-scope.d.ts","sourceRoot":"","sources":["../../../../src/planner/analysis/write-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KA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