@quereus/quereus 4.17.1 → 4.19.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 (248) hide show
  1. package/dist/src/common/types.d.ts +17 -0
  2. package/dist/src/common/types.d.ts.map +1 -1
  3. package/dist/src/common/types.js.map +1 -1
  4. package/dist/src/core/database-assertions.d.ts.map +1 -1
  5. package/dist/src/core/database-assertions.js +2 -1
  6. package/dist/src/core/database-assertions.js.map +1 -1
  7. package/dist/src/core/database-auto-analyze.d.ts +3 -3
  8. package/dist/src/core/database-auto-analyze.d.ts.map +1 -1
  9. package/dist/src/core/database-auto-analyze.js +17 -11
  10. package/dist/src/core/database-auto-analyze.js.map +1 -1
  11. package/dist/src/core/database-materialized-views-plan-builders.d.ts +11 -2
  12. package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
  13. package/dist/src/core/database-materialized-views-plan-builders.js +15 -10
  14. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
  15. package/dist/src/core/database-watchers.d.ts.map +1 -1
  16. package/dist/src/core/database-watchers.js +2 -1
  17. package/dist/src/core/database-watchers.js.map +1 -1
  18. package/dist/src/core/database.d.ts.map +1 -1
  19. package/dist/src/core/database.js +18 -10
  20. package/dist/src/core/database.js.map +1 -1
  21. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  22. package/dist/src/func/builtins/explain.js +38 -42
  23. package/dist/src/func/builtins/explain.js.map +1 -1
  24. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  25. package/dist/src/func/builtins/schema.js +39 -64
  26. package/dist/src/func/builtins/schema.js.map +1 -1
  27. package/dist/src/planner/analysis/constraint-extractor.d.ts +9 -1
  28. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  29. package/dist/src/planner/analysis/constraint-extractor.js +55 -26
  30. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  31. package/dist/src/planner/building/default-scope.d.ts +11 -1
  32. package/dist/src/planner/building/default-scope.d.ts.map +1 -1
  33. package/dist/src/planner/building/default-scope.js +13 -2
  34. package/dist/src/planner/building/default-scope.js.map +1 -1
  35. package/dist/src/planner/building/insert.d.ts.map +1 -1
  36. package/dist/src/planner/building/insert.js +161 -107
  37. package/dist/src/planner/building/insert.js.map +1 -1
  38. package/dist/src/planner/building/select-aggregates.d.ts +8 -0
  39. package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
  40. package/dist/src/planner/building/select-aggregates.js +30 -25
  41. package/dist/src/planner/building/select-aggregates.js.map +1 -1
  42. package/dist/src/planner/building/select.d.ts.map +1 -1
  43. package/dist/src/planner/building/select.js +15 -18
  44. package/dist/src/planner/building/select.js.map +1 -1
  45. package/dist/src/planner/cost/index.d.ts +9 -0
  46. package/dist/src/planner/cost/index.d.ts.map +1 -1
  47. package/dist/src/planner/cost/index.js +28 -0
  48. package/dist/src/planner/cost/index.js.map +1 -1
  49. package/dist/src/planner/debug.d.ts +5 -0
  50. package/dist/src/planner/debug.d.ts.map +1 -1
  51. package/dist/src/planner/debug.js +5 -0
  52. package/dist/src/planner/debug.js.map +1 -1
  53. package/dist/src/planner/framework/characteristics.d.ts +0 -22
  54. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  55. package/dist/src/planner/framework/characteristics.js +0 -3
  56. package/dist/src/planner/framework/characteristics.js.map +1 -1
  57. package/dist/src/planner/framework/pass.js +3 -3
  58. package/dist/src/planner/nodes/async-gather-node.d.ts +13 -0
  59. package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
  60. package/dist/src/planner/nodes/async-gather-node.js +19 -29
  61. package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
  62. package/dist/src/planner/nodes/constraint-check-node.d.ts +9 -0
  63. package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
  64. package/dist/src/planner/nodes/constraint-check-node.js +13 -0
  65. package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
  66. package/dist/src/planner/nodes/cte-node.d.ts +8 -5
  67. package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
  68. package/dist/src/planner/nodes/cte-node.js +14 -4
  69. package/dist/src/planner/nodes/cte-node.js.map +1 -1
  70. package/dist/src/planner/nodes/cte-reference-node.d.ts +9 -1
  71. package/dist/src/planner/nodes/cte-reference-node.d.ts.map +1 -1
  72. package/dist/src/planner/nodes/cte-reference-node.js +13 -0
  73. package/dist/src/planner/nodes/cte-reference-node.js.map +1 -1
  74. package/dist/src/planner/nodes/delete-node.d.ts +7 -1
  75. package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
  76. package/dist/src/planner/nodes/delete-node.js +12 -2
  77. package/dist/src/planner/nodes/delete-node.js.map +1 -1
  78. package/dist/src/planner/nodes/dml-executor-node.d.ts +2 -1
  79. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  80. package/dist/src/planner/nodes/dml-executor-node.js +8 -1
  81. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  82. package/dist/src/planner/nodes/insert-node.d.ts +8 -1
  83. package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
  84. package/dist/src/planner/nodes/insert-node.js +12 -1
  85. package/dist/src/planner/nodes/insert-node.js.map +1 -1
  86. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  87. package/dist/src/planner/nodes/join-node.js +10 -0
  88. package/dist/src/planner/nodes/join-node.js.map +1 -1
  89. package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
  90. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  91. package/dist/src/planner/nodes/plan-node-type.js +1 -0
  92. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  93. package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
  94. package/dist/src/planner/nodes/recursive-cte-node.js +7 -0
  95. package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
  96. package/dist/src/planner/nodes/remote-query-node.d.ts +7 -1
  97. package/dist/src/planner/nodes/remote-query-node.d.ts.map +1 -1
  98. package/dist/src/planner/nodes/remote-query-node.js +11 -0
  99. package/dist/src/planner/nodes/remote-query-node.js.map +1 -1
  100. package/dist/src/planner/nodes/returning-node.d.ts +4 -0
  101. package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
  102. package/dist/src/planner/nodes/returning-node.js +8 -1
  103. package/dist/src/planner/nodes/returning-node.js.map +1 -1
  104. package/dist/src/planner/nodes/scalar.d.ts +39 -0
  105. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  106. package/dist/src/planner/nodes/scalar.js +77 -0
  107. package/dist/src/planner/nodes/scalar.js.map +1 -1
  108. package/dist/src/planner/nodes/set-operation-node.d.ts +14 -1
  109. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  110. package/dist/src/planner/nodes/set-operation-node.js +22 -1
  111. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  112. package/dist/src/planner/nodes/sink-node.d.ts +9 -1
  113. package/dist/src/planner/nodes/sink-node.d.ts.map +1 -1
  114. package/dist/src/planner/nodes/sink-node.js +12 -0
  115. package/dist/src/planner/nodes/sink-node.js.map +1 -1
  116. package/dist/src/planner/nodes/table-access-nodes.d.ts +21 -0
  117. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  118. package/dist/src/planner/nodes/table-access-nodes.js +42 -3
  119. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  120. package/dist/src/planner/nodes/update-node.d.ts +7 -1
  121. package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
  122. package/dist/src/planner/nodes/update-node.js +9 -1
  123. package/dist/src/planner/nodes/update-node.js.map +1 -1
  124. package/dist/src/planner/nodes/view-mutation-node.d.ts +13 -1
  125. package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
  126. package/dist/src/planner/nodes/view-mutation-node.js +25 -1
  127. package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
  128. package/dist/src/planner/optimizer-tuning.d.ts +9 -9
  129. package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
  130. package/dist/src/planner/optimizer-tuning.js +0 -2
  131. package/dist/src/planner/optimizer-tuning.js.map +1 -1
  132. package/dist/src/planner/optimizer.d.ts.map +1 -1
  133. package/dist/src/planner/optimizer.js +9 -21
  134. package/dist/src/planner/optimizer.js.map +1 -1
  135. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
  136. package/dist/src/planner/rules/access/rule-key-set-seek.js +19 -10
  137. package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
  138. package/dist/src/planner/rules/access/rule-select-access-path.d.ts +1 -1
  139. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  140. package/dist/src/planner/rules/access/rule-select-access-path.js +51 -28
  141. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  142. package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.d.ts.map +1 -1
  143. package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.js +14 -1
  144. package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.js.map +1 -1
  145. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
  146. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +6 -4
  147. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
  148. package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -1
  149. package/dist/src/planner/rules/join/index-nested-loop.js +13 -10
  150. package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -1
  151. package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts +2 -1
  152. package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
  153. package/dist/src/planner/rules/join/rule-join-greedy-commute.js +45 -17
  154. package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -1
  155. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  156. package/dist/src/planner/rules/join/rule-join-physical-selection.js +5 -3
  157. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  158. package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts +19 -1
  159. package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts.map +1 -1
  160. package/dist/src/planner/rules/join/rule-quickpick-enumeration.js +36 -3
  161. package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +1 -1
  162. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +4 -3
  163. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
  164. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts +14 -1
  165. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
  166. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +200 -13
  167. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  168. package/dist/src/planner/stats/catalog-stats.js +1 -1
  169. package/dist/src/planner/stats/catalog-stats.js.map +1 -1
  170. package/dist/src/planner/stats/index.d.ts.map +1 -1
  171. package/dist/src/planner/stats/index.js +3 -4
  172. package/dist/src/planner/stats/index.js.map +1 -1
  173. package/dist/src/planner/stats/table-cardinality.d.ts +6 -6
  174. package/dist/src/planner/stats/table-cardinality.js +7 -7
  175. package/dist/src/planner/stats/table-cardinality.js.map +1 -1
  176. package/dist/src/planner/util/column-refs.d.ts +17 -0
  177. package/dist/src/planner/util/column-refs.d.ts.map +1 -0
  178. package/dist/src/planner/util/column-refs.js +30 -0
  179. package/dist/src/planner/util/column-refs.js.map +1 -0
  180. package/dist/src/planner/util/row-estimates.d.ts +91 -0
  181. package/dist/src/planner/util/row-estimates.d.ts.map +1 -1
  182. package/dist/src/planner/util/row-estimates.js +134 -18
  183. package/dist/src/planner/util/row-estimates.js.map +1 -1
  184. package/dist/src/runtime/emit/alter-table.d.ts +25 -5
  185. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  186. package/dist/src/runtime/emit/alter-table.js +144 -62
  187. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  188. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  189. package/dist/src/runtime/emit/dml-executor.js +4 -6
  190. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  191. package/dist/src/runtime/emit/insert.d.ts.map +1 -1
  192. package/dist/src/runtime/emit/insert.js +7 -0
  193. package/dist/src/runtime/emit/insert.js.map +1 -1
  194. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  195. package/dist/src/runtime/emit/materialized-view-helpers.js +3 -3
  196. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  197. package/dist/src/runtime/emit/update.d.ts.map +1 -1
  198. package/dist/src/runtime/emit/update.js +15 -10
  199. package/dist/src/runtime/emit/update.js.map +1 -1
  200. package/dist/src/runtime/emit/write-coercion.d.ts +7 -0
  201. package/dist/src/runtime/emit/write-coercion.d.ts.map +1 -0
  202. package/dist/src/runtime/emit/write-coercion.js +20 -0
  203. package/dist/src/runtime/emit/write-coercion.js.map +1 -0
  204. package/dist/src/runtime/register.d.ts.map +1 -1
  205. package/dist/src/runtime/register.js +2 -0
  206. package/dist/src/runtime/register.js.map +1 -1
  207. package/dist/src/runtime/scalar-fusion.d.ts.map +1 -1
  208. package/dist/src/runtime/scalar-fusion.js +4 -0
  209. package/dist/src/runtime/scalar-fusion.js.map +1 -1
  210. package/dist/src/runtime/scheduler.d.ts +47 -0
  211. package/dist/src/runtime/scheduler.d.ts.map +1 -1
  212. package/dist/src/runtime/scheduler.js +105 -11
  213. package/dist/src/runtime/scheduler.js.map +1 -1
  214. package/dist/src/runtime/types.d.ts +18 -3
  215. package/dist/src/runtime/types.d.ts.map +1 -1
  216. package/dist/src/runtime/types.js +7 -5
  217. package/dist/src/runtime/types.js.map +1 -1
  218. package/dist/src/schema/catalog.d.ts +99 -2
  219. package/dist/src/schema/catalog.d.ts.map +1 -1
  220. package/dist/src/schema/catalog.js +100 -26
  221. package/dist/src/schema/catalog.js.map +1 -1
  222. package/dist/src/schema/lens-prover.d.ts.map +1 -1
  223. package/dist/src/schema/lens-prover.js +2 -1
  224. package/dist/src/schema/lens-prover.js.map +1 -1
  225. package/dist/src/schema/manager.d.ts.map +1 -1
  226. package/dist/src/schema/manager.js +10 -3
  227. package/dist/src/schema/manager.js.map +1 -1
  228. package/dist/src/schema/table.d.ts +0 -2
  229. package/dist/src/schema/table.d.ts.map +1 -1
  230. package/dist/src/schema/table.js.map +1 -1
  231. package/dist/src/vtab/best-access-plan.d.ts +89 -4
  232. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  233. package/dist/src/vtab/best-access-plan.js +76 -1
  234. package/dist/src/vtab/best-access-plan.js.map +1 -1
  235. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  236. package/dist/src/vtab/memory/module.js +27 -11
  237. package/dist/src/vtab/memory/module.js.map +1 -1
  238. package/dist/src/vtab/module.d.ts +7 -0
  239. package/dist/src/vtab/module.d.ts.map +1 -1
  240. package/dist/src/vtab/test-support/committed-read-conformance.d.ts +5 -2
  241. package/dist/src/vtab/test-support/committed-read-conformance.d.ts.map +1 -1
  242. package/dist/src/vtab/test-support/committed-read-conformance.js +55 -9
  243. package/dist/src/vtab/test-support/committed-read-conformance.js.map +1 -1
  244. package/package.json +3 -3
  245. package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts +0 -17
  246. package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +0 -1
  247. package/dist/src/planner/rules/cache/rule-cte-optimization.js +0 -69
  248. package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Column-reference walks over scalar plan subtrees.
3
+ *
4
+ * Lives here rather than in `analysis/constraint-extractor.ts` so that
5
+ * `planner/nodes/` can import it as a *value*: the runtime cycle
6
+ * `constraint-extractor → nodes/reference → …` is real, and this module
7
+ * deliberately depends on nothing but the node-type enum.
8
+ */
9
+ import { PlanNodeType } from '../nodes/plan-node-type.js';
10
+ /**
11
+ * Collect the attributeIds of every ColumnReference in a scalar subtree.
12
+ * Walking into children (rather than only unwrapping a top-level Cast) reaches
13
+ * references nested inside arithmetic, function calls, casts, etc. — e.g.
14
+ * `outer.id + 1`, `coalesce(outer.id, 0)`, `cast(outer.id + 1 as integer)`.
15
+ */
16
+ export function collectColumnRefAttributeIds(node) {
17
+ const ids = [];
18
+ const stack = [node];
19
+ while (stack.length) {
20
+ const n = stack.pop();
21
+ if (n.nodeType === PlanNodeType.ColumnReference) {
22
+ ids.push(n.attributeId);
23
+ }
24
+ for (const c of n.getChildren()) {
25
+ stack.push(c);
26
+ }
27
+ }
28
+ return ids;
29
+ }
30
+ //# sourceMappingURL=column-refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-refs.js","sourceRoot":"","sources":["../../../../src/planner/util/column-refs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAoB;IAChE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,KAAK,GAAqB,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QACvB,IAAI,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,eAAe,EAAE,CAAC;YACjD,GAAG,CAAC,IAAI,CAAE,CAAoC,CAAC,WAAW,CAAC,CAAC;QAC7D,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,CAA8B,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -36,4 +36,95 @@ export declare function physicalSourceRows(childPhysical: PhysicalProperties | u
36
36
  * @param groupDivisor rows-per-group assumption for the grouped estimate
37
37
  */
38
38
  export declare function aggregateRowsFrom(sourceRows: number | undefined, grouped: boolean, groupDivisor: number): number | undefined;
39
+ /**
40
+ * ## Data-modifying nodes: rows EMITTED, not rows written
41
+ *
42
+ * Every estimate in this file counts the rows a node puts on its own output
43
+ * stream. For the write family (`InsertNode`, `UpdateNode`, `DeleteNode`,
44
+ * `ConstraintCheckNode`, `DmlExecutorNode`, `ReturningNode`) that stream tracks
45
+ * the source at most one-for-one — the prep nodes yield one flat OLD/NEW row per
46
+ * source row and `ReturningNode` projects one row per written row — so every
47
+ * member relays its source count unchanged.
48
+ *
49
+ * That relay is an UPPER BOUND, not an exact count, because two members can drop
50
+ * a row silently. `ConstraintCheckNode` skips a row whose NOT NULL / CHECK
51
+ * violation resolves to `IGNORE` (`runtime/row-constraints.ts` returns
52
+ * `{ skip: true }` and the emitter `continue`s), and `DmlExecutorNode` yields
53
+ * nothing for a row it did not write (`insert or ignore` onto an existing key,
54
+ * `on conflict do nothing`, an update whose row is no longer there). Neither skip
55
+ * rate is modelled: both are properties of the data, not of the plan, and
56
+ * inventing a discount would be less honest than the bound. Consumers of a
57
+ * write's estimate size buffers and pick strategies, which an upper bound serves
58
+ * correctly.
59
+ *
60
+ * The two readings only diverge at the statement boundary, and that boundary is
61
+ * a different node: a statement with no `returning` is topped by a `SinkNode`,
62
+ * which drains the write stream and reports the single changes-count row
63
+ * (`SinkNode.estimatedRows === 1`). So a consumer reading `estimatedRows` on a
64
+ * DML node is asking "how much work flows through this write pipeline", which is
65
+ * what sort strategy / cache thresholds above it want; a consumer asking "how
66
+ * many rows does this statement hand back" reads the Sink.
67
+ */
68
+ /** Largest row estimate the relay will emit; see {@link clampRowEstimate}. */
69
+ export declare const MAX_ROW_ESTIMATE: number;
70
+ /**
71
+ * Normalize a composed row estimate to a finite, non-negative integer.
72
+ *
73
+ * Combinators that multiply (`crossProduct`) can push three large branches past
74
+ * `Number.MAX_SAFE_INTEGER` and on to `Infinity`; consumers do arithmetic on
75
+ * this value (selectivity multiplication, cache thresholds), so an `Infinity` or
76
+ * a fractional count leaks into cost comparisons and EXPLAIN output. Saturate at
77
+ * `MAX_ROW_ESTIMATE` instead — a saturated estimate is still "astronomically
78
+ * large", which is all any consumer does with it. `NaN` cannot survive either:
79
+ * it saturates too, since the only way to produce one here is an overflowed
80
+ * intermediate.
81
+ */
82
+ export declare function clampRowEstimate(rows: number): number;
83
+ /** The set operations `SetOperationNode` can carry. */
84
+ export type SetOperationKind = 'union' | 'unionAll' | 'intersect' | 'except';
85
+ /**
86
+ * A set operation's output cardinality as a pure function of its branches' —
87
+ * shared by `SetOperationNode`'s logical `estimatedRows` getter and its
88
+ * `computePhysical` (which feeds it the PHYSICAL branch counts) so the two
89
+ * cannot drift.
90
+ *
91
+ * - `unionAll` — the sum; no rows are removed.
92
+ * - `union` — the true count lies in `max(branches) … sum(branches)` and the
93
+ * deduplication factor is unknown, so report the **sum**: the honest upper
94
+ * bound. The deduplication happens inside the node's own emitter
95
+ * (`runtime/emit/set-operation.ts`), not in a `Distinct` above it, so nothing
96
+ * downstream narrows this claim — it stays an upper bound for the whole plan.
97
+ * - `intersect` — the min; the result is a subset of both branches.
98
+ * - `except` — the left branch's count. The right branch can only remove rows,
99
+ * so the left count is an upper bound and the result can never go negative.
100
+ *
101
+ * `undefined` propagates from any branch the formula actually reads. `except`
102
+ * reads only the left branch, so an unknown right side does not blank it —
103
+ * the left bound is exactly as sound then as it is with a known right side.
104
+ */
105
+ export declare function setOperationRowsFrom(op: SetOperationKind, leftRows: number | undefined, rightRows: number | undefined): number | undefined;
106
+ /** The combinators `AsyncGatherNode` can carry. */
107
+ export type GatherCombinatorKind = 'unionAll' | 'zipByKey' | 'crossProduct';
108
+ /**
109
+ * An `AsyncGatherNode`'s output cardinality as a pure function of its branches' —
110
+ * shared by its logical `estimatedRows` getter and its `computePhysical` (which
111
+ * feeds it the PHYSICAL branch counts), the same discipline
112
+ * {@link aggregateRowsFrom} applies to the aggregate family.
113
+ *
114
+ * - `unionAll` — the sum, matching {@link setOperationRowsFrom}: a
115
+ * PostOptimization rule substitutes a gather for a `union all`, and the two
116
+ * shapes must not report different counts for the same rows.
117
+ * - `zipByKey` — the max. Distinct keys across branches bound the result at
118
+ * `max(branches) … sum(branches)`; heavily overlapping keys is the normal case.
119
+ * NOTE: this is the only arm that picks the LOW end of its range — every other
120
+ * arm reports the upper bound. Now that the number is also stamped physically,
121
+ * a low-key-overlap workload can under-size a buffer above the gather; if that
122
+ * ever shows up, move this arm to the sum like the others.
123
+ * - `crossProduct` — the product, saturated by {@link clampRowEstimate} so three
124
+ * large branches cannot emit `Infinity`.
125
+ *
126
+ * Any unknown branch makes the whole result unknown — every branch is an input
127
+ * to all three formulas.
128
+ */
129
+ export declare function gatherRowsFrom(kind: GatherCombinatorKind, branchRows: readonly (number | undefined)[]): number | undefined;
39
130
  //# sourceMappingURL=row-estimates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"row-estimates.d.ts","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF;;;;;;;;GAQG;AAYH,wBAAgB,kBAAkB,CACjC,aAAa,EAAE,kBAAkB,GAAG,SAAS,EAC7C,MAAM,EAAE,kBAAkB,GACxB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAiBpB"}
1
+ {"version":3,"file":"row-estimates.d.ts","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF;;;;;;;;GAQG;AAMH,wBAAgB,kBAAkB,CACjC,aAAa,EAAE,kBAAkB,GAAG,SAAS,EAC7C,MAAM,EAAE,kBAAkB,GACxB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAapB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,QAA0B,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,gBAAgB,EACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAQpB;AAED,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,oBAAoB,EAC1B,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACzC,MAAM,GAAG,SAAS,CAoBpB"}
@@ -23,17 +23,11 @@
23
23
  * there the logical getter is the only number available, and it is still the
24
24
  * pre-optimization truth.
25
25
  */
26
- // NOTE: `SchemaManager` hardcodes `TableSchema.estimatedRows` to 0 at CREATE TABLE,
27
- // so a never-analyzed table's scan reports 0 — a value that means "unknown", not
28
- // "empty" (see the NOTE in `planner/stats/table-cardinality.ts`). That 0 now travels
29
- // much further than it used to: before this relay it died at the first operator that
30
- // read a logical getter, and consumers fell back to their own defaults instead. Any
31
- // consumer that reads a row estimate as a *magnitude* must therefore spell 0 as
32
- // unknown — `rule-cte-optimization` gates on `sourceSize > 0` and had to be taught
33
- // this (its `|| defaultRowEstimate` matches `vtab/memory/module.ts`); threshold
34
- // consumers that floor (the cache threshold's min of 1000) or use a `>` test are
35
- // unaffected. The real fix is distinguishing unknown from empty at the source —
36
- // not clamping here, which would erase a genuinely empty analyzed table.
26
+ // Invariant: a row estimate has exactly two spellings — `undefined` means "nobody
27
+ // knows" and a number (including a real 0, from an analyzed empty table) means
28
+ // "measured or derived" (see `planner/stats/table-cardinality.ts`). A never-analyzed
29
+ // table's scan reports `undefined`, not 0, so this relay may propagate any number it
30
+ // sees as a genuine magnitude; consumers apply their own default only on `undefined`.
37
31
  export function physicalSourceRows(childPhysical, source) {
38
32
  return childPhysical?.estimatedRows ?? source.estimatedRows;
39
33
  }
@@ -54,15 +48,137 @@ export function aggregateRowsFrom(sourceRows, grouped, groupDivisor) {
54
48
  // (including the unknown sentinel — the count is not a function of the source).
55
49
  if (!grouped)
56
50
  return 1;
57
- // 0 must pass through unchanged. It is both the genuinely-empty count (0 rows
58
- // in ⇒ 0 groups out) and the never-analyzed "unknown" sentinel (see the NOTE
59
- // on `physicalSourceRows`), and flooring it to 1 conflates them: unknown would
60
- // leave here as a confident single row, which reads as a real magnitude and
61
- // silently defeats every downstream `|| default` unknown-guard —
62
- // `rule-join-physical-selection` costed a 1x1 join and kept the nested loop
63
- // where both sides were un-analyzed grouped aggregates.
51
+ // 0 passes through unchanged: it now only ever means a genuinely empty source
52
+ // (never-analyzed is `undefined`, handled above), and 0 rows in ⇒ 0 groups
53
+ // out. Flooring it to 1 would claim a row an empty table cannot produce.
64
54
  if (sourceRows === 0)
65
55
  return 0;
66
56
  return Math.max(1, Math.floor(sourceRows / groupDivisor));
67
57
  }
58
+ /**
59
+ * ## Data-modifying nodes: rows EMITTED, not rows written
60
+ *
61
+ * Every estimate in this file counts the rows a node puts on its own output
62
+ * stream. For the write family (`InsertNode`, `UpdateNode`, `DeleteNode`,
63
+ * `ConstraintCheckNode`, `DmlExecutorNode`, `ReturningNode`) that stream tracks
64
+ * the source at most one-for-one — the prep nodes yield one flat OLD/NEW row per
65
+ * source row and `ReturningNode` projects one row per written row — so every
66
+ * member relays its source count unchanged.
67
+ *
68
+ * That relay is an UPPER BOUND, not an exact count, because two members can drop
69
+ * a row silently. `ConstraintCheckNode` skips a row whose NOT NULL / CHECK
70
+ * violation resolves to `IGNORE` (`runtime/row-constraints.ts` returns
71
+ * `{ skip: true }` and the emitter `continue`s), and `DmlExecutorNode` yields
72
+ * nothing for a row it did not write (`insert or ignore` onto an existing key,
73
+ * `on conflict do nothing`, an update whose row is no longer there). Neither skip
74
+ * rate is modelled: both are properties of the data, not of the plan, and
75
+ * inventing a discount would be less honest than the bound. Consumers of a
76
+ * write's estimate size buffers and pick strategies, which an upper bound serves
77
+ * correctly.
78
+ *
79
+ * The two readings only diverge at the statement boundary, and that boundary is
80
+ * a different node: a statement with no `returning` is topped by a `SinkNode`,
81
+ * which drains the write stream and reports the single changes-count row
82
+ * (`SinkNode.estimatedRows === 1`). So a consumer reading `estimatedRows` on a
83
+ * DML node is asking "how much work flows through this write pipeline", which is
84
+ * what sort strategy / cache thresholds above it want; a consumer asking "how
85
+ * many rows does this statement hand back" reads the Sink.
86
+ */
87
+ /** Largest row estimate the relay will emit; see {@link clampRowEstimate}. */
88
+ export const MAX_ROW_ESTIMATE = Number.MAX_SAFE_INTEGER;
89
+ /**
90
+ * Normalize a composed row estimate to a finite, non-negative integer.
91
+ *
92
+ * Combinators that multiply (`crossProduct`) can push three large branches past
93
+ * `Number.MAX_SAFE_INTEGER` and on to `Infinity`; consumers do arithmetic on
94
+ * this value (selectivity multiplication, cache thresholds), so an `Infinity` or
95
+ * a fractional count leaks into cost comparisons and EXPLAIN output. Saturate at
96
+ * `MAX_ROW_ESTIMATE` instead — a saturated estimate is still "astronomically
97
+ * large", which is all any consumer does with it. `NaN` cannot survive either:
98
+ * it saturates too, since the only way to produce one here is an overflowed
99
+ * intermediate.
100
+ */
101
+ export function clampRowEstimate(rows) {
102
+ if (Number.isNaN(rows))
103
+ return MAX_ROW_ESTIMATE;
104
+ if (rows >= MAX_ROW_ESTIMATE)
105
+ return MAX_ROW_ESTIMATE;
106
+ return Math.max(0, Math.floor(rows));
107
+ }
108
+ /**
109
+ * A set operation's output cardinality as a pure function of its branches' —
110
+ * shared by `SetOperationNode`'s logical `estimatedRows` getter and its
111
+ * `computePhysical` (which feeds it the PHYSICAL branch counts) so the two
112
+ * cannot drift.
113
+ *
114
+ * - `unionAll` — the sum; no rows are removed.
115
+ * - `union` — the true count lies in `max(branches) … sum(branches)` and the
116
+ * deduplication factor is unknown, so report the **sum**: the honest upper
117
+ * bound. The deduplication happens inside the node's own emitter
118
+ * (`runtime/emit/set-operation.ts`), not in a `Distinct` above it, so nothing
119
+ * downstream narrows this claim — it stays an upper bound for the whole plan.
120
+ * - `intersect` — the min; the result is a subset of both branches.
121
+ * - `except` — the left branch's count. The right branch can only remove rows,
122
+ * so the left count is an upper bound and the result can never go negative.
123
+ *
124
+ * `undefined` propagates from any branch the formula actually reads. `except`
125
+ * reads only the left branch, so an unknown right side does not blank it —
126
+ * the left bound is exactly as sound then as it is with a known right side.
127
+ */
128
+ export function setOperationRowsFrom(op, leftRows, rightRows) {
129
+ if (leftRows === undefined)
130
+ return undefined;
131
+ // The right branch subtracts; it is not an input to the upper bound.
132
+ if (op === 'except')
133
+ return clampRowEstimate(leftRows);
134
+ if (rightRows === undefined)
135
+ return undefined;
136
+ if (op === 'intersect')
137
+ return clampRowEstimate(Math.min(leftRows, rightRows));
138
+ // union / unionAll: sum (see the `union` note above).
139
+ return clampRowEstimate(leftRows + rightRows);
140
+ }
141
+ /**
142
+ * An `AsyncGatherNode`'s output cardinality as a pure function of its branches' —
143
+ * shared by its logical `estimatedRows` getter and its `computePhysical` (which
144
+ * feeds it the PHYSICAL branch counts), the same discipline
145
+ * {@link aggregateRowsFrom} applies to the aggregate family.
146
+ *
147
+ * - `unionAll` — the sum, matching {@link setOperationRowsFrom}: a
148
+ * PostOptimization rule substitutes a gather for a `union all`, and the two
149
+ * shapes must not report different counts for the same rows.
150
+ * - `zipByKey` — the max. Distinct keys across branches bound the result at
151
+ * `max(branches) … sum(branches)`; heavily overlapping keys is the normal case.
152
+ * NOTE: this is the only arm that picks the LOW end of its range — every other
153
+ * arm reports the upper bound. Now that the number is also stamped physically,
154
+ * a low-key-overlap workload can under-size a buffer above the gather; if that
155
+ * ever shows up, move this arm to the sum like the others.
156
+ * - `crossProduct` — the product, saturated by {@link clampRowEstimate} so three
157
+ * large branches cannot emit `Infinity`.
158
+ *
159
+ * Any unknown branch makes the whole result unknown — every branch is an input
160
+ * to all three formulas.
161
+ */
162
+ export function gatherRowsFrom(kind, branchRows) {
163
+ let acc = kind === 'crossProduct' ? 1 : 0;
164
+ for (const rows of branchRows) {
165
+ if (rows === undefined)
166
+ return undefined;
167
+ switch (kind) {
168
+ case 'unionAll':
169
+ acc += rows;
170
+ break;
171
+ case 'zipByKey':
172
+ acc = Math.max(acc, rows);
173
+ break;
174
+ case 'crossProduct':
175
+ // Saturate every step, not just the result: an overflowed `Infinity`
176
+ // intermediate followed by a provably-empty branch would otherwise
177
+ // multiply out to `NaN`.
178
+ acc = clampRowEstimate(acc * rows);
179
+ break;
180
+ }
181
+ }
182
+ return clampRowEstimate(acc);
183
+ }
68
184
  //# sourceMappingURL=row-estimates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"row-estimates.js","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;GAQG;AACH,oFAAoF;AACpF,iFAAiF;AACjF,qFAAqF;AACrF,qFAAqF;AACrF,oFAAoF;AACpF,gFAAgF;AAChF,mFAAmF;AACnF,gFAAgF;AAChF,iFAAiF;AACjF,gFAAgF;AAChF,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CACjC,aAA6C,EAC7C,MAA0B;IAE1B,OAAO,aAAa,EAAE,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC;AAC7D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,UAA8B,EAC9B,OAAgB,EAChB,YAAoB;IAEpB,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,6EAA6E;IAC7E,gFAAgF;IAChF,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,CAAC;IAEvB,8EAA8E;IAC9E,6EAA6E;IAC7E,+EAA+E;IAC/E,4EAA4E;IAC5E,iEAAiE;IACjE,4EAA4E;IAC5E,wDAAwD;IACxD,IAAI,UAAU,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC;AAC3D,CAAC"}
1
+ {"version":3,"file":"row-estimates.js","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;GAQG;AACH,kFAAkF;AAClF,+EAA+E;AAC/E,qFAAqF;AACrF,qFAAqF;AACrF,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CACjC,aAA6C,EAC7C,MAA0B;IAE1B,OAAO,aAAa,EAAE,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC;AAC7D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,UAA8B,EAC9B,OAAgB,EAChB,YAAoB;IAEpB,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,6EAA6E;IAC7E,gFAAgF;IAChF,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,CAAC;IAEvB,8EAA8E;IAC9E,2EAA2E;IAC3E,yEAAyE;IACzE,IAAI,UAAU,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAChD,IAAI,IAAI,IAAI,gBAAgB;QAAE,OAAO,gBAAgB,CAAC;IACtD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CACnC,EAAoB,EACpB,QAA4B,EAC5B,SAA6B;IAE7B,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,qEAAqE;IACrE,IAAI,EAAE,KAAK,QAAQ;QAAE,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,IAAI,EAAE,KAAK,WAAW;QAAE,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/E,sDAAsD;IACtD,OAAO,gBAAgB,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;AAC/C,CAAC;AAKD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAC7B,IAA0B,EAC1B,UAA2C;IAE3C,IAAI,GAAG,GAAG,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QACzC,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,UAAU;gBACd,GAAG,IAAI,IAAI,CAAC;gBACZ,MAAM;YACP,KAAK,UAAU;gBACd,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC1B,MAAM;YACP,KAAK,cAAc;gBAClB,qEAAqE;gBACrE,mEAAmE;gBACnE,yBAAyB;gBACzB,GAAG,GAAG,gBAAgB,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;gBACnC,MAAM;QACR,CAAC;IACF,CAAC;IACD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
@@ -6,10 +6,30 @@ export declare function emitAlterTable(plan: AlterTableNode, ctx: EmissionContex
6
6
  /**
7
7
  * Build the shadow-table CREATE TABLE DDL used by the non-memory rebuild path.
8
8
  *
9
- * Nullability is emitted explicitly for every column, matching the "no-db"
10
- * stance of `generateTableDDL` in ddl-generator.ts: safe under any session's
11
- * `default_column_nullability` setting. DEFAULT and COLLATE are preserved so
12
- * the shadow table faithfully mirrors the original schema.
9
+ * Rendered through the canonical emitter (`generateTableDDL`) over a copy of the
10
+ * REAL `TableSchema` with only the name and key substituted, so the shadow
11
+ * carries everything the table declares — constraints, foreign keys, tags,
12
+ * defaults, collations, generated columns, the key's ON CONFLICT action — not a
13
+ * hand-picked subset. An omission in emitted DDL is never neutral: a missing
14
+ * PRIMARY KEY clause re-parses as a different key (all-columns), and a missing
15
+ * constraint re-parses as no constraint.
16
+ *
17
+ * Called WITHOUT a `db` argument: that form fully qualifies the name, always
18
+ * emits USING, and annotates nullability on every column, so the text re-parses
19
+ * to the same shape under any session's `default_column_nullability` /
20
+ * `default_vtab_module` settings. An empty `newPkDef` emits `PRIMARY KEY ()` —
21
+ * the singleton key — rather than omitting the clause (which would re-parse as
22
+ * the opposite thing: keyed by every column).
23
+ *
24
+ * The copied schema's per-column `primaryKey` flags are stale (they still mirror
25
+ * the OLD key) — harmless: the emitter reads only `primaryKeyDefinition`, and the
26
+ * shadow's real schema is built by re-parsing the emitted text.
27
+ *
28
+ * Deliberately WHOLE-TABLE only (no column subset parameter): stored constraints
29
+ * address columns by index, so a subset copy would need every constraint and
30
+ * index remapped or dropped. `ALTER TABLE … DROP COLUMN` goes through
31
+ * `module.alterTable`, never through this rebuild; if a column-dropping rebuild
32
+ * is ever wanted it must come back with deliberate constraint handling.
13
33
  */
14
- export declare function buildShadowTableDdl(tableSchema: TableSchema, shadowName: string, survivingColumns: string[], newPkDef: PrimaryKeyColumnDefinition[]): string;
34
+ export declare function buildShadowTableDdl(tableSchema: TableSchema, shadowName: string, newPkDef: PrimaryKeyColumnDefinition[]): string;
15
35
  //# sourceMappingURL=alter-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alter-table.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/alter-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqC,MAAM,yCAAyC,CAAC;AACjH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,KAAK,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAkDrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAkJtF;AA2xDD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,QAAQ,EAAE,0BAA0B,EAAE,GACpC,MAAM,CAuCR"}
1
+ {"version":3,"file":"alter-table.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/alter-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqC,MAAM,yCAAyC,CAAC;AACjH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,KAAK,EAAE,WAAW,EAAE,0BAA0B,EAAe,MAAM,uBAAuB,CAAC;AAmDlG,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,GAAG,WAAW,CAkJtF;AAyyDD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,0BAA0B,EAAE,GACpC,MAAM,CAMR"}