@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
@@ -1,19 +1,14 @@
1
1
  import { asRun } from '../types.js';
2
2
  import { emitPlanNode, emitCallFromPlan } from '../emitters.js';
3
- import { isAggregateFunctionSchema } from '../../schema/function.js';
4
- import { AggregateFunctionCallNode } from '../../planner/nodes/aggregate-function.js';
5
3
  import { isRelationalNode } from '../../planner/nodes/plan-node.js';
6
4
  import { createValueSet } from '../../util/value-set.js';
7
5
  import { logContextPush, logContextPop } from '../utils.js';
8
- import { coerceForAggregate } from '../../util/coercion.js';
9
- import { quereusError } from '../../common/errors.js';
10
- import { StatusCode } from '../../common/types.js';
11
6
  import { buildRowDescriptor } from '../../util/row-descriptor.js';
12
7
  import { serializeKeyNullGrouping } from '../../util/key-serializer.js';
13
8
  import { semanticKeyTransform } from '../../util/comparison.js';
14
9
  import { hashKeyCollationName } from '../../planner/analysis/comparison-collation.js';
15
10
  import { cloneInitialValue, findSourceRelation, ctxLog } from './aggregate.js';
16
- import { bindAggregateSchemas, buildDistinctComparators, computeAggregateSkipCoercion } from './aggregate-setup.js';
11
+ import { bindAggregateSchemas, buildDistinctComparators, computeAggregateValueTransforms, emitAggregateArgInstructions, evalArgsSync } from './aggregate-setup.js';
17
12
  export function emitHashAggregate(plan, ctx) {
18
13
  const sourceRelation = findSourceRelation(plan.source);
19
14
  const sourceAttributes = plan.source.getAttributes();
@@ -46,25 +41,19 @@ export function emitHashAggregate(plan, ctx) {
46
41
  const keyCanonicalizers = plan.groupBy.map(expr => semanticKeyTransform(expr.getType().logicalType));
47
42
  const hasKeyCanonicalizer = keyCanonicalizers.some(c => c !== undefined);
48
43
  const distinctComparators = buildDistinctComparators(plan.aggregates, ctx);
49
- const aggregateSkipCoercion = computeAggregateSkipCoercion(plan.aggregates);
50
- const { schemas: aggregateSchemas, distinctFlags: aggregateDistinctFlags } = bindAggregateSchemas(plan.aggregates, ctx);
44
+ const aggregateValueTransforms = computeAggregateValueTransforms(plan.aggregates);
45
+ const { schemas: aggregateSchemas, distinctFlags: aggregateDistinctFlags, argCounts: aggregateArgCounts } = bindAggregateSchemas(plan.aggregates, ctx);
51
46
  async function* run(ctx, sourceRows, ...groupByAndAggregateArgs) {
52
47
  const numGroupBy = plan.groupBy.length;
53
48
  const groupByFunctions = groupByAndAggregateArgs.slice(0, numGroupBy);
54
49
  let aggregateArgOffset = numGroupBy;
55
50
  const aggregateArgFunctions = [];
56
- for (const agg of plan.aggregates) {
57
- const funcNode = agg.expression;
58
- if (!(funcNode instanceof AggregateFunctionCallNode)) {
59
- quereusError(`Expected AggregateFunctionCallNode but got ${funcNode.constructor.name}`, StatusCode.INTERNAL);
60
- }
61
- const args = funcNode.args || [];
62
- const aggregateArgs = groupByAndAggregateArgs.slice(aggregateArgOffset, aggregateArgOffset + args.length);
63
- aggregateArgFunctions.push(aggregateArgs);
64
- aggregateArgOffset += args.length;
51
+ for (const argCount of aggregateArgCounts) {
52
+ aggregateArgFunctions.push(groupByAndAggregateArgs.slice(aggregateArgOffset, aggregateArgOffset + argCount));
53
+ aggregateArgOffset += argCount;
65
54
  }
66
55
  function createAccumulators() {
67
- return aggregateSchemas.map(schema => cloneInitialValue(isAggregateFunctionSchema(schema) ? schema.initialValue : undefined));
56
+ return aggregateSchemas.map(schema => cloneInitialValue(schema.initialValue));
68
57
  }
69
58
  function createDistinctTrees() {
70
59
  return aggregateDistinctFlags.map((isDistinct, i) => isDistinct ? createValueSet(distinctComparators[i]) : null);
@@ -80,30 +69,16 @@ export function emitHashAggregate(plan, ctx) {
80
69
  logContextPush(scanRowDescriptor, 'scan-row', sourceAttributes);
81
70
  try {
82
71
  for (let i = 0; i < plan.aggregates.length; i++) {
83
- const schema = aggregateSchemas[i];
84
72
  const isDistinct = aggregateDistinctFlags[i];
85
- const funcNode = plan.aggregates[i].expression;
86
- if (!(funcNode instanceof AggregateFunctionCallNode)) {
87
- quereusError(`Expected AggregateFunctionCallNode but got ${funcNode.constructor.name}`, StatusCode.INTERNAL);
88
- }
89
- const args = funcNode.args || [];
90
- const argFunctions = aggregateArgFunctions[i];
91
- const skipCoercion = aggregateSkipCoercion[i];
92
- const argValues = [];
93
- for (let j = 0; j < args.length; j++) {
94
- const rawValue = await argFunctions[j](ctx);
95
- const coercedValue = skipCoercion ? rawValue : coerceForAggregate(rawValue, funcNode.functionName || 'unknown');
96
- argValues.push(coercedValue);
97
- }
73
+ const argValuesMaybe = evalArgsSync(ctx, aggregateArgFunctions[i], aggregateValueTransforms[i]);
74
+ const argValues = argValuesMaybe instanceof Promise ? await argValuesMaybe : argValuesMaybe;
98
75
  if (isDistinct) {
99
76
  const distinctValue = argValues.length === 1 ? argValues[0] : argValues;
100
77
  const existingPath = distinctTrees[i].insert(distinctValue);
101
78
  if (!existingPath.on)
102
79
  continue;
103
80
  }
104
- if (isAggregateFunctionSchema(schema)) {
105
- accumulators[i] = schema.stepFunction(accumulators[i], ...argValues);
106
- }
81
+ accumulators[i] = aggregateSchemas[i].stepFunction(accumulators[i], ...argValues);
107
82
  }
108
83
  }
109
84
  finally {
@@ -113,15 +88,7 @@ export function emitHashAggregate(plan, ctx) {
113
88
  }
114
89
  const aggregateRow = [];
115
90
  for (let i = 0; i < plan.aggregates.length; i++) {
116
- const schema = aggregateSchemas[i];
117
- let finalValue;
118
- if (isAggregateFunctionSchema(schema)) {
119
- finalValue = schema.finalizeFunction(accumulators[i]);
120
- }
121
- else {
122
- finalValue = accumulators[i];
123
- }
124
- aggregateRow.push(finalValue);
91
+ aggregateRow.push(aggregateSchemas[i].finalizeFunction(accumulators[i]));
125
92
  }
126
93
  const fullRow = lastSourceRow ? [...aggregateRow, ...lastSourceRow] : aggregateRow;
127
94
  if (lastSourceRow) {
@@ -151,10 +118,8 @@ export function emitHashAggregate(plan, ctx) {
151
118
  logContextPush(scanRowDescriptor, 'scan-row', sourceAttributes);
152
119
  try {
153
120
  // Evaluate GROUP BY expressions
154
- const groupValues = [];
155
- for (const groupByFunc of groupByFunctions) {
156
- groupValues.push(await groupByFunc(ctx));
157
- }
121
+ const groupValuesMaybe = evalArgsSync(ctx, groupByFunctions);
122
+ const groupValues = groupValuesMaybe instanceof Promise ? await groupValuesMaybe : groupValuesMaybe;
158
123
  // Serialize key using collation-aware serialization (NULLs group together per SQL standard)
159
124
  const keyValues = hasKeyCanonicalizer
160
125
  ? groupValues.map((v, i) => keyCanonicalizers[i] ? keyCanonicalizers[i](v) : v)
@@ -173,30 +138,16 @@ export function emitHashAggregate(plan, ctx) {
173
138
  }
174
139
  // Evaluate aggregate arguments and step accumulators
175
140
  for (let i = 0; i < plan.aggregates.length; i++) {
176
- const schema = aggregateSchemas[i];
177
141
  const isDistinct = aggregateDistinctFlags[i];
178
- const funcNode = plan.aggregates[i].expression;
179
- if (!(funcNode instanceof AggregateFunctionCallNode)) {
180
- quereusError(`Expected AggregateFunctionCallNode but got ${funcNode.constructor.name}`, StatusCode.INTERNAL);
181
- }
182
- const args = funcNode.args || [];
183
- const argFunctions = aggregateArgFunctions[i];
184
- const skipCoercion = aggregateSkipCoercion[i];
185
- const argValues = [];
186
- for (let j = 0; j < args.length; j++) {
187
- const rawValue = await argFunctions[j](ctx);
188
- const coercedValue = skipCoercion ? rawValue : coerceForAggregate(rawValue, funcNode.functionName || 'unknown');
189
- argValues.push(coercedValue);
190
- }
142
+ const argValuesMaybe = evalArgsSync(ctx, aggregateArgFunctions[i], aggregateValueTransforms[i]);
143
+ const argValues = argValuesMaybe instanceof Promise ? await argValuesMaybe : argValuesMaybe;
191
144
  if (isDistinct) {
192
145
  const distinctValue = argValues.length === 1 ? argValues[0] : argValues;
193
146
  const existingPath = group.distinctTrees[i].insert(distinctValue);
194
147
  if (!existingPath.on)
195
148
  continue;
196
149
  }
197
- if (isAggregateFunctionSchema(schema)) {
198
- group.accumulators[i] = schema.stepFunction(group.accumulators[i], ...argValues);
199
- }
150
+ group.accumulators[i] = aggregateSchemas[i].stepFunction(group.accumulators[i], ...argValues);
200
151
  }
201
152
  }
202
153
  finally {
@@ -211,15 +162,7 @@ export function emitHashAggregate(plan, ctx) {
211
162
  aggregateRow.push(...group.groupValues);
212
163
  // Finalized aggregate values
213
164
  for (let i = 0; i < plan.aggregates.length; i++) {
214
- const schema = aggregateSchemas[i];
215
- let finalValue;
216
- if (isAggregateFunctionSchema(schema)) {
217
- finalValue = schema.finalizeFunction(group.accumulators[i]);
218
- }
219
- else {
220
- finalValue = group.accumulators[i];
221
- }
222
- aggregateRow.push(finalValue);
165
+ aggregateRow.push(aggregateSchemas[i].finalizeFunction(group.accumulators[i]));
223
166
  }
224
167
  // Set up combined context (output + representative source row) for HAVING
225
168
  const fullRow = [...aggregateRow, ...group.representativeSourceRow];
@@ -252,20 +195,7 @@ export function emitHashAggregate(plan, ctx) {
252
195
  }
253
196
  const sourceInstruction = emitPlanNode(plan.source, ctx);
254
197
  const groupByInstructions = plan.groupBy.map(expr => emitCallFromPlan(expr, ctx));
255
- const aggregateArgInstructions = [];
256
- for (const agg of plan.aggregates) {
257
- const funcNode = agg.expression;
258
- if (!(funcNode instanceof AggregateFunctionCallNode)) {
259
- quereusError(`Expected AggregateFunctionCallNode but got ${funcNode.constructor.name}`, StatusCode.INTERNAL);
260
- }
261
- const args = funcNode.args || [];
262
- for (const arg of args) {
263
- if (!arg) {
264
- quereusError(`Aggregate argument is undefined for function ${funcNode.functionName}`, StatusCode.INTERNAL);
265
- }
266
- aggregateArgInstructions.push(emitCallFromPlan(arg, ctx));
267
- }
268
- }
198
+ const aggregateArgInstructions = emitAggregateArgInstructions(plan.aggregates, ctx);
269
199
  return {
270
200
  params: [sourceInstruction, ...groupByInstructions, ...aggregateArgInstructions],
271
201
  run: asRun(run),
@@ -1 +1 @@
1
- {"version":3,"file":"hash-aggregate.js","sourceRoot":"","sources":["../../../../src/runtime/emit/hash-aggregate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAUpH,MAAM,UAAU,iBAAiB,CAAC,IAAuB,EAAE,GAAoB;IAC9E,MAAM,cAAc,GAAG,kBAAkB,CAAC,IAAI,CAAC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E,KAAK,CAAC,GAAG,CAAC;QACf,IAAI,EAAE,kBAAkB,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,QAAQ;KACtI,CAAC;AACH,CAAC"}
@@ -1,5 +1,18 @@
1
1
  import type { Instruction } from "../types.js";
2
2
  import type { LiteralNode } from "../../planner/nodes/scalar.js";
3
3
  import type { EmissionContext } from "../emission-context.js";
4
- export declare function emitLiteral(plan: LiteralNode, _ctx: EmissionContext): Instruction;
4
+ import { type ScalarOpSpec } from "./scalar-op.js";
5
+ /**
6
+ * Zero-operand spec yielding the literal's value, or `undefined` when the value is an
7
+ * unresolved Promise.
8
+ *
9
+ * The constant-folding pass (planner/analysis/const-pass.ts) parks the result of an
10
+ * *async* fold straight into `LiteralExpr.value` without awaiting it and lets the
11
+ * scheduler resolve it, so a literal's body is `MaybePromise<SqlValue>` in general —
12
+ * which is not a {@link ScalarOpSpec} body. Rather than widen the spec contract for
13
+ * every scalar op, that rare arm has no spec and its consumers fall back: the emitter
14
+ * below builds the Instruction itself, and a fusion consumer must decline to fuse.
15
+ */
16
+ export declare function buildLiteralSpec(plan: LiteralNode): ScalarOpSpec | undefined;
17
+ export declare function emitLiteral(plan: LiteralNode, ctx: EmissionContext): Instruction;
5
18
  //# sourceMappingURL=literal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/literal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,GAAG,WAAW,CAUjF"}
1
+ {"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/literal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAS5E;AAOD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAUhF"}
@@ -1,13 +1,39 @@
1
- import { asRun } from "../types.js";
2
1
  import { safeJsonStringify } from "../../util/serialization.js";
3
- export function emitLiteral(plan, _ctx) {
4
- function run(_rctx) {
5
- return plan.expression.value;
6
- }
2
+ import { emitScalarOp } from "./scalar-op.js";
3
+ /**
4
+ * Zero-operand spec yielding the literal's value, or `undefined` when the value is an
5
+ * unresolved Promise.
6
+ *
7
+ * The constant-folding pass (planner/analysis/const-pass.ts) parks the result of an
8
+ * *async* fold straight into `LiteralExpr.value` without awaiting it and lets the
9
+ * scheduler resolve it, so a literal's body is `MaybePromise<SqlValue>` in general —
10
+ * which is not a {@link ScalarOpSpec} body. Rather than widen the spec contract for
11
+ * every scalar op, that rare arm has no spec and its consumers fall back: the emitter
12
+ * below builds the Instruction itself, and a fusion consumer must decline to fuse.
13
+ */
14
+ export function buildLiteralSpec(plan) {
15
+ const value = plan.expression.value;
16
+ if (value instanceof Promise)
17
+ return undefined;
18
+ return {
19
+ operands: [],
20
+ run: (_rctx) => value,
21
+ note: literalNote(value)
22
+ };
23
+ }
24
+ /** Note text shared by both arms — `safeJsonStringify` of a Promise spells `{}`, as before. */
25
+ function literalNote(value) {
26
+ return `literal(${safeJsonStringify(value)})`;
27
+ }
28
+ export function emitLiteral(plan, ctx) {
29
+ const spec = buildLiteralSpec(plan);
30
+ if (spec)
31
+ return emitScalarOp(spec, ctx);
32
+ const deferred = plan.expression.value;
7
33
  return {
8
34
  params: [],
9
- run: asRun(run),
10
- note: `literal(${safeJsonStringify(plan.expression.value)})`
35
+ run: (_rctx) => deferred,
36
+ note: literalNote(deferred)
11
37
  };
12
38
  }
13
39
  //# sourceMappingURL=literal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../../src/runtime/emit/literal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,IAAqB;IACnE,SAAS,GAAG,CAAC,KAAqB;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,OAAO;QACN,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QACf,IAAI,EAAE,WAAW,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG;KAC5D,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../../src/runtime/emit/literal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAqB,MAAM,gBAAgB,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAiB;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IACpC,IAAI,KAAK,YAAY,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/C,OAAO;QACN,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,CAAC,KAAqB,EAAE,EAAE,CAAC,KAAK;QACrC,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;KACxB,CAAC;AACH,CAAC;AAED,+FAA+F;AAC/F,SAAS,WAAW,CAAC,KAAmC;IACvD,OAAO,WAAW,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,GAAoB;IAClE,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,IAAI;QAAE,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IACvC,OAAO;QACN,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,CAAC,KAAqB,EAAE,EAAE,CAAC,QAAQ;QACxC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC;KAC3B,CAAC;AACH,CAAC"}
@@ -376,8 +376,14 @@ export declare function createMaintainedTable(db: Database, stmt: AST.CreateTabl
376
376
  * behavior. The caller is responsible for staleness re-validation when relevant;
377
377
  * this helper assumes the derivation body plans. Throws if the table is missing
378
378
  * from the catalog.
379
+ *
380
+ * `validationColumns` is the reshape arm's column preview
381
+ * ({@link previewReshapedColumns}) — the type/collation attributes the reshape's
382
+ * still-pending post-reconcile ops are about to land — forwarded to the scan so
383
+ * the CHECK / FK resolve against the final declared shape. `undefined` on every
384
+ * other path (and on a reshape that shifts neither attribute).
379
385
  */
380
- export declare function rebuildBacking(db: Database, mv: MaintainedTableSchema): Promise<void>;
386
+ export declare function rebuildBacking(db: Database, mv: MaintainedTableSchema, validationColumns?: readonly ColumnSchema[]): Promise<void>;
381
387
  /**
382
388
  * True iff the live backing `TableSchema` is structurally identical to what the
383
389
  * derived `shape` would build — so a `refresh` can take the data-only fast path
@@ -1 +1 @@
1
- {"version":3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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAsB,kCAAkC,CACvD,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAwCf"}
@@ -777,14 +777,30 @@ function hasApplicableConstraints(db, mt) {
777
777
  * the LIVE record here. So the live record is swapped for a constraint-stripped
778
778
  * clone for the duration of the scans (the ADD COLUMN intermediate-schema
779
779
  * discipline, see `runtime/emit/alter-table.ts`), then restored.
780
+ *
781
+ * `validationColumns` (the reshape arms only, {@link previewReshapedColumns})
782
+ * overrides the clone's column list with the attributes the reshape is ABOUT TO
783
+ * land, so a CHECK / FK resolves its affinity and collation from the final
784
+ * declared shape rather than the one being replaced. Comparison semantics are a
785
+ * function of the DECLARED column attributes, and the reshape's `retype` /
786
+ * `recollate` module ops run after this scan (they convert stored rows, so they
787
+ * must); without the override this scan would evaluate `v < '9'` on a column
788
+ * moving TEXT → INTEGER as a text comparison and admit a row that violates the
789
+ * constraint under the type it is about to have. Omitted (⇒ `mt.columns`) on
790
+ * every non-reshape path, so those stay byte-identical.
780
791
  */
781
- async function validateDeclaredConstraintsOverContents(db, mt) {
792
+ async function validateDeclaredConstraintsOverContents(db, mt, validationColumns) {
782
793
  const applicableChecks = mt.checkConstraints.filter(c => (c.operations & (RowOpFlag.INSERT | RowOpFlag.UPDATE)) !== 0);
783
794
  const fks = mt.foreignKeys ?? [];
784
795
  if (applicableChecks.length === 0 && fks.length === 0)
785
796
  return;
786
797
  const schema = db.schemaManager.getSchemaOrFail(mt.schemaName);
787
- const stripped = { ...mt, checkConstraints: Object.freeze([]), foreignKeys: undefined };
798
+ const stripped = {
799
+ ...mt,
800
+ columns: validationColumns ?? mt.columns,
801
+ checkConstraints: Object.freeze([]),
802
+ foreignKeys: undefined,
803
+ };
788
804
  schema.addTable(stripped);
789
805
  try {
790
806
  await validateChecksOverExistingRows(db, mt, applicableChecks, (check, exprSql) => maintainedTableCheckViolationError(mt.schemaName, mt.name, check.name ?? `_check_${mt.checkConstraints.indexOf(check)}`, exprSql));
@@ -1079,8 +1095,11 @@ discardBackingOnFailure = false) {
1079
1095
  changes = await host.applyMaintenance(conn, [{ kind: 'replace-all', rows }]);
1080
1096
  // Declared CHECK / child-side FK over the reconciled (derived) row set —
1081
1097
  // inside this try so a violation restores the prior record; the pending
1082
- // reconcile writes roll back with the failing statement.
1083
- await validateDeclaredConstraintsOverContents(db, live);
1098
+ // reconcile writes roll back with the failing statement. On the reshape arm
1099
+ // the scan resolves against the attributes the post-reconcile ops below are
1100
+ // about to land, keeping this path identical to the refresh reshape arm
1101
+ // (`reshapeBackingInPlace` → `rebuildBacking`).
1102
+ await validateDeclaredConstraintsOverContents(db, live, reshapePlan ? previewReshapedColumns(live, shape) : undefined);
1084
1103
  if (reshapePlan && reshapePlan.postReconcileOps.length > 0) {
1085
1104
  // Data-validating attribute ops (retype / recollate / tighten NOT NULL)
1086
1105
  // must validate the RECONCILED body rows, not the stale backing — but the
@@ -1320,8 +1339,14 @@ export async function createMaintainedTable(db, stmt) {
1320
1339
  * behavior. The caller is responsible for staleness re-validation when relevant;
1321
1340
  * this helper assumes the derivation body plans. Throws if the table is missing
1322
1341
  * from the catalog.
1342
+ *
1343
+ * `validationColumns` is the reshape arm's column preview
1344
+ * ({@link previewReshapedColumns}) — the type/collation attributes the reshape's
1345
+ * still-pending post-reconcile ops are about to land — forwarded to the scan so
1346
+ * the CHECK / FK resolve against the final declared shape. `undefined` on every
1347
+ * other path (and on a reshape that shifts neither attribute).
1323
1348
  */
1324
- export async function rebuildBacking(db, mv) {
1349
+ export async function rebuildBacking(db, mv, validationColumns) {
1325
1350
  const bodySql = astToString(mv.derivation.selectAst);
1326
1351
  const rows = await collectBodyRows(db, mv.schemaName, bodySql);
1327
1352
  const backing = db.schemaManager.getTable(mv.schemaName, mv.name);
@@ -1367,23 +1392,15 @@ export async function rebuildBacking(db, mv) {
1367
1392
  // leaving the pre-refresh committed contents intact (the MV stays stale, so the
1368
1393
  // next read re-validates rather than serving the rejected set).
1369
1394
  //
1370
- // Documented limitation (collation-sensitive CHECK on the reshape arm): on the
1371
- // reshape path this scan validates the rows in their PRE-recollate physical form
1372
- // — the catalog column still carries the OLD collation here, and any
1373
- // `recollate` op runs post-reconcile in reshapeBackingInPlace, AFTER this commit.
1374
- // So a CHECK whose truth flips under a recollate-during-reshape (e.g. `v <> 'abc'`
1375
- // with v recollated BINARY → NOCASE over a row 'ABC') passes here and is then
1376
- // recollated into a violating state. The same class of corner applies to a
1377
- // `retype` op (it shares this `postReconcileOps` batch): a CHECK whose truth flips
1378
- // under the column's NEW affinity (e.g. `v < '9'` retyped TEXT → INTEGER over a
1379
- // row '10' — lexicographic-true then numeric-false) passes here and is retyped into
1380
- // violation. Not closed: this commit is load-bearing (commit-first parity + the
1381
- // post-reconcile ops scan committed contents), and the attach reshape path uses the
1382
- // identical ordering. See docs/materialized-views.md § REFRESH MATERIALIZED VIEW
1383
- // "Known limitation — collation-sensitive CHECK" / "… type-sensitive CHECK" and
1384
- // maintained-table-refresh-revalidation.spec.ts § "reshape arm: collation-
1385
- // sensitive CHECK" / "reshape arm: type-sensitive CHECK".
1386
- await validateDeclaredConstraintsOverContents(db, backing);
1395
+ // On the reshape arm `validationColumns` carries the attributes the reshape is
1396
+ // about to land ({@link previewReshapedColumns}), so a CHECK / FK is evaluated
1397
+ // under the column's FINAL type and collation even though the `retype` /
1398
+ // `recollate` module ops still run post-reconcile in reshapeBackingInPlace. That
1399
+ // keeps this commit's ordering exactly as it was — the scan stays before the
1400
+ // commit, the post-reconcile ops still scan committed contents — while removing
1401
+ // the wrong-semantics gap. The attach reshape path passes the same preview at its
1402
+ // own call site, so both arms reject identically.
1403
+ await validateDeclaredConstraintsOverContents(db, backing, validationColumns);
1387
1404
  await conn.commit();
1388
1405
  }
1389
1406
  /**
@@ -2111,6 +2128,76 @@ function reshapeOpToChange(op) {
2111
2128
  function graftReshapedRecord(moduleSchema, source) {
2112
2129
  return { ...moduleSchema, derivation: source.derivation, tags: source.tags };
2113
2130
  }
2131
+ /**
2132
+ * The column list a reshape is ABOUT TO land, for the declared-constraint scan that
2133
+ * runs mid-reshape ({@link validateDeclaredConstraintsOverContents}).
2134
+ *
2135
+ * A reshape's data-validating ops (`retype` / `recollate`) must run AFTER the data
2136
+ * reconcile — they convert/re-key STORED rows, so running them first would validate
2137
+ * the about-to-be-discarded contents and throw spuriously. But a SQL comparison
2138
+ * takes its type affinity and its collation from the column's DECLARED attributes,
2139
+ * so a scan against the live (pre-op) record evaluates a declared CHECK under the
2140
+ * attributes the reshape is replacing: `check (v < '9')` on a column moving
2141
+ * TEXT → INTEGER compares as text ('10' < '9' is true) and never as the numeric
2142
+ * comparison it is becoming. Previewing the attributes fixes the semantics without
2143
+ * moving a single op — the scan stays exactly where it was, still before the commit.
2144
+ *
2145
+ * Maps `live`'s columns onto `shape`'s **by name** (names and order already agree:
2146
+ * the reshape's pre-reconcile batch has applied every rename / add / drop before
2147
+ * either caller reaches this) and overrides only `logicalType` and `collation`.
2148
+ * Returns `undefined` when neither attribute shifts, so a reshape with no
2149
+ * `retype`/`recollate` — and every non-reshape path — behaves exactly as before.
2150
+ *
2151
+ * Deliberately NOT previewed:
2152
+ * - **`notNull`.** The tighten-NOT-NULL op stays a post-reconcile module op and
2153
+ * keeps validating there. Declaring `notNull` early would let the optimizer fold
2154
+ * a nullability-sensitive CHECK into a vacuous pass — the same class of unsound
2155
+ * folding the caller's constraint-stripped-clone swap exists to prevent.
2156
+ * - **`defaultValue` and the generated-column attributes.** A reshape never moves
2157
+ * them, so previewing them could only introduce drift.
2158
+ *
2159
+ * Physical-PK columns need no special handling: `describePhysicalPkChange` refuses
2160
+ * a reshape whose key column changes type or collation, so a previewed attribute
2161
+ * can never desynchronize the key encoding `assertRefreshRowsAreSet` or the host's
2162
+ * keyed diff rely on.
2163
+ *
2164
+ * NOTE: the scan sees the rebuilt values in their PRE-conversion physical form but
2165
+ * under the POST-conversion declared type. These agree in practice — the target
2166
+ * attribute is derived FROM the body's own output type, so the body already emits
2167
+ * values of the new type. A retype whose conversion genuinely rewrites the value
2168
+ * (a text → date canonicalization turning '2024-06-05T00:00:00Z' into '2024-06-05')
2169
+ * would have the CHECK see the un-normalized spelling. Not chased; revisit if a
2170
+ * value-rewriting conversion is ever added to the reshape's op set.
2171
+ *
2172
+ * NOTE: with the preview in place, a body emitting a value that does not conform to
2173
+ * its own declared output type now trips the physical-representation checker
2174
+ * (`QUEREUS_REPR_STRICT`) at this scan rather than sliding through. That is a
2175
+ * genuine defect surfacing at the earliest honest point, not a regression.
2176
+ *
2177
+ * NOTE: this RE-DERIVES the attribute shift from live-vs-shape rather than reading
2178
+ * `ReshapePlan.postReconcileOps`, which is the authoritative list of the `retype` /
2179
+ * `recollate` ops that will actually run. The two agree today because the
2180
+ * pre-reconcile structural ops preserve attributes exactly ({@link backingColumnDef}
2181
+ * carries type + collation through a rename, and an `add` lands the shape column's
2182
+ * own attributes), so every live-vs-shape shift has a queued op and vice versa. If a
2183
+ * structural op ever stops preserving an attribute, this would preview an attribute
2184
+ * no op lands and the scan would reject rows the finished reshape accepts — build the
2185
+ * preview from `postReconcileOps` then.
2186
+ */
2187
+ function previewReshapedColumns(live, shape) {
2188
+ const byName = new Map(shape.columns.map(c => [c.name.toLowerCase(), c]));
2189
+ let shifted = false;
2190
+ const preview = live.columns.map(col => {
2191
+ const target = byName.get(col.name.toLowerCase());
2192
+ if (!target)
2193
+ return col;
2194
+ if (backingTypeMatches(col, target) && backingCollationMatches(col, target))
2195
+ return col;
2196
+ shifted = true;
2197
+ return { ...col, logicalType: target.logicalType, collation: target.collation };
2198
+ });
2199
+ return shifted ? Object.freeze(preview) : undefined;
2200
+ }
2114
2201
  /**
2115
2202
  * The sited error a refresh raises when the re-derived body shape cannot be
2116
2203
  * reconciled onto the live maintained table in place — an interleaving column
@@ -2209,8 +2296,10 @@ async function reshapeBackingInPlace(db, mv, shape, plan) {
2209
2296
  let live = graftReshapedRecord(current, mv);
2210
2297
  schema.addTable(live);
2211
2298
  // Data reconcile: re-run the body and swap contents (the identity-preserving
2212
- // data-only path — same host, same incarnation).
2213
- await rebuildBacking(db, live);
2299
+ // data-only path — same host, same incarnation). The column preview lets that
2300
+ // path's declared-constraint scan resolve against the type/collation the
2301
+ // post-reconcile ops below will land, not the ones they replace.
2302
+ await rebuildBacking(db, live, previewReshapedColumns(live, shape));
2214
2303
  // Post-reconcile data-validating ops (retype / recollate / tighten NOT NULL): the
2215
2304
  // reconciled body rows satisfy the new attribute where the discarded backing
2216
2305
  // might not, so each validates the fresh data, not the stale rows. Re-register
@@ -2221,14 +2310,14 @@ async function reshapeBackingInPlace(db, mv, shape, plan) {
2221
2310
  // partial throw. Per-op registration keeps the catalog tracking the module so a
2222
2311
  // mid-batch failure leaves a coherent, re-runnable table.
2223
2312
  //
2224
- // NOTE: a `recollate` here applies AFTER step 3's rebuildBacking has already
2225
- // validated + committed the rows under the OLD collation — so a collation-
2226
- // sensitive declared CHECK whose truth flips under this recollate is not caught
2227
- // by that scan. A `retype` in this same batch is the affinity analog: a CHECK
2228
- // whose truth flips under the column's NEW logical type (e.g. `v < '9'` retyped
2229
- // TEXT → INTEGER) is likewise validated under the OLD type and missed (documented
2230
- // limitation; see the note in rebuildBacking's constraint-bearing branch and
2231
- // docs/materialized-views.md § REFRESH MATERIALIZED VIEW).
2313
+ // These ops still run after step 3's rebuildBacking has validated + committed,
2314
+ // but the declared-CHECK/FK scan inside that step is no longer blind to them:
2315
+ // the `previewReshapedColumns` argument above hands it the type/collation each
2316
+ // `retype` / `recollate` here is about to land, so a constraint whose truth
2317
+ // flips under the new attribute (`v <> 'abc'` recollated BINARY → NOCASE over
2318
+ // 'ABC'; `v < '9'` retyped TEXT → INTEGER over '10') is rejected there, before
2319
+ // the commit, with nothing written. A tighten-NOT-NULL is deliberately NOT
2320
+ // previewed and keeps validating right here — see previewReshapedColumns.
2232
2321
  for (const op of plan.postReconcileOps) {
2233
2322
  current = await module.alterTable(db, mv.schemaName, mv.name, reshapeOpToChange(op));
2234
2323
  live = graftReshapedRecord(current, mv);