@quereus/quereus 4.4.1 → 4.6.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 (593) hide show
  1. package/README.md +5 -4
  2. package/dist/src/core/database-events.d.ts +99 -1
  3. package/dist/src/core/database-events.d.ts.map +1 -1
  4. package/dist/src/core/database-events.js +219 -3
  5. package/dist/src/core/database-events.js.map +1 -1
  6. package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
  7. package/dist/src/core/database-materialized-views-analysis.js +1 -0
  8. package/dist/src/core/database-materialized-views-analysis.js.map +1 -1
  9. package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
  10. package/dist/src/core/database-materialized-views-plan-builders.js +29 -2
  11. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
  12. package/dist/src/core/database-transaction.d.ts +9 -0
  13. package/dist/src/core/database-transaction.d.ts.map +1 -1
  14. package/dist/src/core/database-transaction.js +9 -0
  15. package/dist/src/core/database-transaction.js.map +1 -1
  16. package/dist/src/core/database.d.ts +7 -1
  17. package/dist/src/core/database.d.ts.map +1 -1
  18. package/dist/src/core/database.js +20 -5
  19. package/dist/src/core/database.js.map +1 -1
  20. package/dist/src/func/builtins/aggregate.js +11 -11
  21. package/dist/src/func/builtins/aggregate.js.map +1 -1
  22. package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
  23. package/dist/src/func/builtins/builtin-window-functions.js +15 -85
  24. package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
  25. package/dist/src/func/builtins/conversion.d.ts.map +1 -1
  26. package/dist/src/func/builtins/conversion.js +10 -9
  27. package/dist/src/func/builtins/conversion.js.map +1 -1
  28. package/dist/src/func/builtins/datetime.d.ts.map +1 -1
  29. package/dist/src/func/builtins/datetime.js +28 -10
  30. package/dist/src/func/builtins/datetime.js.map +1 -1
  31. package/dist/src/func/builtins/json.d.ts.map +1 -1
  32. package/dist/src/func/builtins/json.js +23 -17
  33. package/dist/src/func/builtins/json.js.map +1 -1
  34. package/dist/src/func/builtins/mutation.js +2 -2
  35. package/dist/src/func/builtins/mutation.js.map +1 -1
  36. package/dist/src/func/builtins/return-types.d.ts +327 -0
  37. package/dist/src/func/builtins/return-types.d.ts.map +1 -0
  38. package/dist/src/func/builtins/return-types.js +43 -0
  39. package/dist/src/func/builtins/return-types.js.map +1 -0
  40. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  41. package/dist/src/func/builtins/scalar.js +193 -37
  42. package/dist/src/func/builtins/scalar.js.map +1 -1
  43. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  44. package/dist/src/func/builtins/schema.js +11 -3
  45. package/dist/src/func/builtins/schema.js.map +1 -1
  46. package/dist/src/func/builtins/string.d.ts.map +1 -1
  47. package/dist/src/func/builtins/string.js +4 -2
  48. package/dist/src/func/builtins/string.js.map +1 -1
  49. package/dist/src/func/builtins/timespan.d.ts +3 -0
  50. package/dist/src/func/builtins/timespan.d.ts.map +1 -1
  51. package/dist/src/func/builtins/timespan.js +15 -11
  52. package/dist/src/func/builtins/timespan.js.map +1 -1
  53. package/dist/src/func/registration.d.ts +39 -1
  54. package/dist/src/func/registration.d.ts.map +1 -1
  55. package/dist/src/func/registration.js +236 -41
  56. package/dist/src/func/registration.js.map +1 -1
  57. package/dist/src/index.d.ts +14 -7
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/index.js +14 -5
  60. package/dist/src/index.js.map +1 -1
  61. package/dist/src/parser/parser.d.ts +46 -0
  62. package/dist/src/parser/parser.d.ts.map +1 -1
  63. package/dist/src/parser/parser.js +160 -44
  64. package/dist/src/parser/parser.js.map +1 -1
  65. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
  66. package/dist/src/planner/analysis/check-extraction.js +37 -4
  67. package/dist/src/planner/analysis/check-extraction.js.map +1 -1
  68. package/dist/src/planner/analysis/coarsened-key.d.ts +4 -3
  69. package/dist/src/planner/analysis/coarsened-key.d.ts.map +1 -1
  70. package/dist/src/planner/analysis/coarsened-key.js +37 -3
  71. package/dist/src/planner/analysis/coarsened-key.js.map +1 -1
  72. package/dist/src/planner/analysis/comparison-collation.d.ts +41 -13
  73. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
  74. package/dist/src/planner/analysis/comparison-collation.js +51 -14
  75. package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
  76. package/dist/src/planner/analysis/constraint-extractor.d.ts +0 -7
  77. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  78. package/dist/src/planner/analysis/constraint-extractor.js +59 -59
  79. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  80. package/dist/src/planner/analysis/coverage-prover.d.ts +13 -2
  81. package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
  82. package/dist/src/planner/analysis/coverage-prover.js +10 -14
  83. package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
  84. package/dist/src/planner/analysis/predicate-conjuncts.d.ts +10 -4
  85. package/dist/src/planner/analysis/predicate-conjuncts.d.ts.map +1 -1
  86. package/dist/src/planner/analysis/predicate-conjuncts.js +28 -7
  87. package/dist/src/planner/analysis/predicate-conjuncts.js.map +1 -1
  88. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
  89. package/dist/src/planner/analysis/query-rewrite-matcher.js +8 -27
  90. package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
  91. package/dist/src/planner/analysis/scalar-subqueries.d.ts +22 -3
  92. package/dist/src/planner/analysis/scalar-subqueries.d.ts.map +1 -1
  93. package/dist/src/planner/analysis/scalar-subqueries.js +32 -3
  94. package/dist/src/planner/analysis/scalar-subqueries.js.map +1 -1
  95. package/dist/src/planner/analysis/set-op-type-merge.d.ts +64 -0
  96. package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -0
  97. package/dist/src/planner/analysis/set-op-type-merge.js +97 -0
  98. package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -0
  99. package/dist/src/planner/building/alter-table.d.ts.map +1 -1
  100. package/dist/src/planner/building/alter-table.js +65 -27
  101. package/dist/src/planner/building/alter-table.js.map +1 -1
  102. package/dist/src/planner/building/coercion.d.ts +54 -0
  103. package/dist/src/planner/building/coercion.d.ts.map +1 -0
  104. package/dist/src/planner/building/coercion.js +88 -0
  105. package/dist/src/planner/building/coercion.js.map +1 -0
  106. package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
  107. package/dist/src/planner/building/constraint-builder.js +5 -18
  108. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  109. package/dist/src/planner/building/expression.d.ts +17 -0
  110. package/dist/src/planner/building/expression.d.ts.map +1 -1
  111. package/dist/src/planner/building/expression.js +23 -115
  112. package/dist/src/planner/building/expression.js.map +1 -1
  113. package/dist/src/planner/building/function-call.d.ts.map +1 -1
  114. package/dist/src/planner/building/function-call.js +13 -0
  115. package/dist/src/planner/building/function-call.js.map +1 -1
  116. package/dist/src/planner/building/select-aggregates.d.ts +1 -1
  117. package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
  118. package/dist/src/planner/building/select-aggregates.js +53 -2
  119. package/dist/src/planner/building/select-aggregates.js.map +1 -1
  120. package/dist/src/planner/building/select-compound.d.ts.map +1 -1
  121. package/dist/src/planner/building/select-compound.js +10 -6
  122. package/dist/src/planner/building/select-compound.js.map +1 -1
  123. package/dist/src/planner/building/select-context.d.ts +7 -0
  124. package/dist/src/planner/building/select-context.d.ts.map +1 -1
  125. package/dist/src/planner/building/select-context.js +10 -40
  126. package/dist/src/planner/building/select-context.js.map +1 -1
  127. package/dist/src/planner/building/select.d.ts +37 -1
  128. package/dist/src/planner/building/select.d.ts.map +1 -1
  129. package/dist/src/planner/building/select.js +112 -51
  130. package/dist/src/planner/building/select.js.map +1 -1
  131. package/dist/src/planner/cost/conjunct-cost.d.ts +82 -0
  132. package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -0
  133. package/dist/src/planner/cost/conjunct-cost.js +107 -0
  134. package/dist/src/planner/cost/conjunct-cost.js.map +1 -0
  135. package/dist/src/planner/cost/index.d.ts +10 -0
  136. package/dist/src/planner/cost/index.d.ts.map +1 -1
  137. package/dist/src/planner/cost/index.js +15 -0
  138. package/dist/src/planner/cost/index.js.map +1 -1
  139. package/dist/src/planner/mutation/propagate.d.ts.map +1 -1
  140. package/dist/src/planner/mutation/propagate.js +1 -0
  141. package/dist/src/planner/mutation/propagate.js.map +1 -1
  142. package/dist/src/planner/nodes/aggregate-node.d.ts +6 -0
  143. package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
  144. package/dist/src/planner/nodes/aggregate-node.js +10 -2
  145. package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
  146. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  147. package/dist/src/planner/nodes/alias-node.js +2 -1
  148. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  149. package/dist/src/planner/nodes/alter-table-node.d.ts +24 -8
  150. package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
  151. package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
  152. package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
  153. package/dist/src/planner/nodes/asof-scan-node.js +4 -1
  154. package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
  155. package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
  156. package/dist/src/planner/nodes/asserted-keys-node.js +2 -1
  157. package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
  158. package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
  159. package/dist/src/planner/nodes/async-gather-node.js +19 -8
  160. package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
  161. package/dist/src/planner/nodes/bloom-join-node.d.ts +2 -0
  162. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  163. package/dist/src/planner/nodes/bloom-join-node.js +17 -7
  164. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  165. package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
  166. package/dist/src/planner/nodes/cache-node.js +2 -1
  167. package/dist/src/planner/nodes/cache-node.js.map +1 -1
  168. package/dist/src/planner/nodes/distinct-node.d.ts +6 -0
  169. package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
  170. package/dist/src/planner/nodes/distinct-node.js +10 -2
  171. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  172. package/dist/src/planner/nodes/eager-prefetch-node.d.ts.map +1 -1
  173. package/dist/src/planner/nodes/eager-prefetch-node.js +2 -1
  174. package/dist/src/planner/nodes/eager-prefetch-node.js.map +1 -1
  175. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts +5 -0
  176. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
  177. package/dist/src/planner/nodes/fanout-lookup-join-node.js +13 -6
  178. package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
  179. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  180. package/dist/src/planner/nodes/filter.js +12 -5
  181. package/dist/src/planner/nodes/filter.js.map +1 -1
  182. package/dist/src/planner/nodes/hash-aggregate.d.ts +6 -0
  183. package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
  184. package/dist/src/planner/nodes/hash-aggregate.js +10 -2
  185. package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
  186. package/dist/src/planner/nodes/join-node.d.ts +25 -1
  187. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  188. package/dist/src/planner/nodes/join-node.js +38 -10
  189. package/dist/src/planner/nodes/join-node.js.map +1 -1
  190. package/dist/src/planner/nodes/join-utils.d.ts +78 -0
  191. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  192. package/dist/src/planner/nodes/join-utils.js +73 -0
  193. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  194. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +87 -0
  195. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -0
  196. package/dist/src/planner/nodes/key-set-semi-join-node.js +141 -0
  197. package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -0
  198. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
  199. package/dist/src/planner/nodes/lens-auxiliary-access-node.js +2 -1
  200. package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
  201. package/dist/src/planner/nodes/limit-offset.d.ts +6 -0
  202. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  203. package/dist/src/planner/nodes/limit-offset.js +10 -2
  204. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  205. package/dist/src/planner/nodes/merge-join-node.d.ts +2 -0
  206. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  207. package/dist/src/planner/nodes/merge-join-node.js +21 -8
  208. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  209. package/dist/src/planner/nodes/ordinal-slice-node.d.ts +5 -0
  210. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
  211. package/dist/src/planner/nodes/ordinal-slice-node.js +9 -2
  212. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
  213. package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
  214. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  215. package/dist/src/planner/nodes/plan-node-type.js +1 -0
  216. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  217. package/dist/src/planner/nodes/plan-node.d.ts +24 -0
  218. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  219. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  220. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  221. package/dist/src/planner/nodes/project-node.js +2 -1
  222. package/dist/src/planner/nodes/project-node.js.map +1 -1
  223. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  224. package/dist/src/planner/nodes/reference.js +3 -2
  225. package/dist/src/planner/nodes/reference.js.map +1 -1
  226. package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
  227. package/dist/src/planner/nodes/retrieve-node.js +2 -1
  228. package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
  229. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  230. package/dist/src/planner/nodes/scalar.js +5 -18
  231. package/dist/src/planner/nodes/scalar.js.map +1 -1
  232. package/dist/src/planner/nodes/set-operation-node.d.ts +68 -16
  233. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  234. package/dist/src/planner/nodes/set-operation-node.js +147 -26
  235. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  236. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  237. package/dist/src/planner/nodes/sort.js +3 -1
  238. package/dist/src/planner/nodes/sort.js.map +1 -1
  239. package/dist/src/planner/nodes/stream-aggregate.d.ts +6 -0
  240. package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
  241. package/dist/src/planner/nodes/stream-aggregate.js +10 -2
  242. package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
  243. package/dist/src/planner/nodes/table-access-nodes.d.ts +19 -1
  244. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  245. package/dist/src/planner/nodes/table-access-nodes.js +18 -2
  246. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  247. package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
  248. package/dist/src/planner/nodes/window-function.js +8 -0
  249. package/dist/src/planner/nodes/window-function.js.map +1 -1
  250. package/dist/src/planner/nodes/window-node.d.ts +1 -1
  251. package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
  252. package/dist/src/planner/nodes/window-node.js +3 -1
  253. package/dist/src/planner/nodes/window-node.js.map +1 -1
  254. package/dist/src/planner/optimizer.d.ts +9 -1
  255. package/dist/src/planner/optimizer.d.ts.map +1 -1
  256. package/dist/src/planner/optimizer.js +126 -6
  257. package/dist/src/planner/optimizer.js.map +1 -1
  258. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +68 -0
  259. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -0
  260. package/dist/src/planner/rules/access/rule-key-set-seek.js +343 -0
  261. package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -0
  262. package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
  263. package/dist/src/planner/rules/access/rule-monotonic-range-access.js +2 -2
  264. package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
  265. package/dist/src/planner/rules/access/rule-select-access-path.d.ts +46 -0
  266. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  267. package/dist/src/planner/rules/access/rule-select-access-path.js +54 -13
  268. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  269. package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
  270. package/dist/src/planner/rules/cache/rule-cte-optimization.js +9 -0
  271. package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
  272. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
  273. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +6 -4
  274. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
  275. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +49 -49
  276. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
  277. package/dist/src/planner/rules/join/equi-pair-extractor.js +54 -58
  278. package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
  279. package/dist/src/planner/rules/join/index-nested-loop.d.ts +49 -0
  280. package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -0
  281. package/dist/src/planner/rules/join/index-nested-loop.js +285 -0
  282. package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -0
  283. package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +8 -8
  284. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +10 -4
  285. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  286. package/dist/src/planner/rules/join/rule-join-physical-selection.js +97 -29
  287. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  288. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
  289. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +15 -5
  290. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
  291. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +1 -1
  292. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +1 -1
  293. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts +43 -0
  294. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -0
  295. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +119 -0
  296. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -0
  297. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +44 -3
  298. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
  299. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +142 -18
  300. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
  301. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts +73 -0
  302. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts.map +1 -0
  303. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js +205 -0
  304. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js.map +1 -0
  305. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +14 -11
  306. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -1
  307. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +21 -85
  308. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
  309. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +10 -2
  310. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -1
  311. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +20 -2
  312. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
  313. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
  314. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +18 -3
  315. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  316. package/dist/src/planner/rules/shared/access-leaf.d.ts +39 -0
  317. package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -0
  318. package/dist/src/planner/rules/shared/access-leaf.js +79 -0
  319. package/dist/src/planner/rules/shared/access-leaf.js.map +1 -0
  320. package/dist/src/planner/rules/shared/index-style-context.d.ts +17 -0
  321. package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -1
  322. package/dist/src/planner/rules/shared/index-style-context.js +7 -0
  323. package/dist/src/planner/rules/shared/index-style-context.js.map +1 -1
  324. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -1
  325. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +18 -8
  326. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -1
  327. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +3 -1
  328. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -1
  329. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +27 -10
  330. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
  331. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +24 -6
  332. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  333. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +243 -70
  334. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  335. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts +17 -7
  336. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
  337. package/dist/src/planner/rules/window/rule-monotonic-window.js +124 -87
  338. package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
  339. package/dist/src/planner/scopes/aliased.d.ts.map +1 -1
  340. package/dist/src/planner/scopes/aliased.js +6 -0
  341. package/dist/src/planner/scopes/aliased.js.map +1 -1
  342. package/dist/src/planner/stats/catalog-stats.d.ts +87 -4
  343. package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
  344. package/dist/src/planner/stats/catalog-stats.js +250 -28
  345. package/dist/src/planner/stats/catalog-stats.js.map +1 -1
  346. package/dist/src/planner/stats/conjunct-selectivity.d.ts +48 -0
  347. package/dist/src/planner/stats/conjunct-selectivity.d.ts.map +1 -0
  348. package/dist/src/planner/stats/conjunct-selectivity.js +168 -0
  349. package/dist/src/planner/stats/conjunct-selectivity.js.map +1 -0
  350. package/dist/src/planner/stats/index.d.ts +36 -2
  351. package/dist/src/planner/stats/index.d.ts.map +1 -1
  352. package/dist/src/planner/stats/index.js.map +1 -1
  353. package/dist/src/planner/stats/selectivity-combine.d.ts +53 -0
  354. package/dist/src/planner/stats/selectivity-combine.d.ts.map +1 -0
  355. package/dist/src/planner/stats/selectivity-combine.js +75 -0
  356. package/dist/src/planner/stats/selectivity-combine.js.map +1 -0
  357. package/dist/src/planner/stats/table-cardinality.d.ts +28 -0
  358. package/dist/src/planner/stats/table-cardinality.d.ts.map +1 -0
  359. package/dist/src/planner/stats/table-cardinality.js +29 -0
  360. package/dist/src/planner/stats/table-cardinality.js.map +1 -0
  361. package/dist/src/planner/util/column-origins.d.ts +79 -0
  362. package/dist/src/planner/util/column-origins.d.ts.map +1 -0
  363. package/dist/src/planner/util/column-origins.js +150 -0
  364. package/dist/src/planner/util/column-origins.js.map +1 -0
  365. package/dist/src/planner/util/fd-utils.d.ts +32 -8
  366. package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
  367. package/dist/src/planner/util/fd-utils.js +46 -9
  368. package/dist/src/planner/util/fd-utils.js.map +1 -1
  369. package/dist/src/planner/util/ind-utils.d.ts +56 -17
  370. package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
  371. package/dist/src/planner/util/ind-utils.js +82 -21
  372. package/dist/src/planner/util/ind-utils.js.map +1 -1
  373. package/dist/src/planner/util/key-utils.d.ts +20 -2
  374. package/dist/src/planner/util/key-utils.d.ts.map +1 -1
  375. package/dist/src/planner/util/key-utils.js +37 -3
  376. package/dist/src/planner/util/key-utils.js.map +1 -1
  377. package/dist/src/planner/util/row-estimates.d.ts +28 -0
  378. package/dist/src/planner/util/row-estimates.d.ts.map +1 -0
  379. package/dist/src/planner/util/row-estimates.js +40 -0
  380. package/dist/src/planner/util/row-estimates.js.map +1 -0
  381. package/dist/src/planner/util/row-population.d.ts +42 -0
  382. package/dist/src/planner/util/row-population.d.ts.map +1 -0
  383. package/dist/src/planner/util/row-population.js +71 -0
  384. package/dist/src/planner/util/row-population.js.map +1 -0
  385. package/dist/src/runtime/deferred-constraint-queue.d.ts +40 -0
  386. package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
  387. package/dist/src/runtime/deferred-constraint-queue.js +90 -9
  388. package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
  389. package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
  390. package/dist/src/runtime/emit/add-constraint.js +39 -1
  391. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  392. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  393. package/dist/src/runtime/emit/aggregate.js +4 -4
  394. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  395. package/dist/src/runtime/emit/alter-schema-event.d.ts +42 -0
  396. package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -0
  397. package/dist/src/runtime/emit/alter-schema-event.js +28 -0
  398. package/dist/src/runtime/emit/alter-schema-event.js.map +1 -0
  399. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  400. package/dist/src/runtime/emit/alter-table.js +386 -154
  401. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  402. package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
  403. package/dist/src/runtime/emit/analyze.js +35 -3
  404. package/dist/src/runtime/emit/analyze.js.map +1 -1
  405. package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
  406. package/dist/src/runtime/emit/asof-scan.js +8 -3
  407. package/dist/src/runtime/emit/asof-scan.js.map +1 -1
  408. package/dist/src/runtime/emit/between.d.ts.map +1 -1
  409. package/dist/src/runtime/emit/between.js +4 -38
  410. package/dist/src/runtime/emit/between.js.map +1 -1
  411. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  412. package/dist/src/runtime/emit/binary.js +2 -23
  413. package/dist/src/runtime/emit/binary.js.map +1 -1
  414. package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
  415. package/dist/src/runtime/emit/bloom-join.js +6 -35
  416. package/dist/src/runtime/emit/bloom-join.js.map +1 -1
  417. package/dist/src/runtime/emit/case.d.ts.map +1 -1
  418. package/dist/src/runtime/emit/case.js +40 -6
  419. package/dist/src/runtime/emit/case.js.map +1 -1
  420. package/dist/src/runtime/emit/cast.d.ts.map +1 -1
  421. package/dist/src/runtime/emit/cast.js +4 -19
  422. package/dist/src/runtime/emit/cast.js.map +1 -1
  423. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  424. package/dist/src/runtime/emit/constraint-check.js +32 -8
  425. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  426. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  427. package/dist/src/runtime/emit/dml-executor.js +90 -50
  428. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  429. package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
  430. package/dist/src/runtime/emit/drop-index.js +4 -3
  431. package/dist/src/runtime/emit/drop-index.js.map +1 -1
  432. package/dist/src/runtime/emit/filter.d.ts +18 -0
  433. package/dist/src/runtime/emit/filter.d.ts.map +1 -1
  434. package/dist/src/runtime/emit/filter.js +52 -10
  435. package/dist/src/runtime/emit/filter.js.map +1 -1
  436. package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
  437. package/dist/src/runtime/emit/hash-aggregate.js +2 -2
  438. package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
  439. package/dist/src/runtime/emit/join-key-extractor.d.ts +46 -0
  440. package/dist/src/runtime/emit/join-key-extractor.d.ts.map +1 -0
  441. package/dist/src/runtime/emit/join-key-extractor.js +60 -0
  442. package/dist/src/runtime/emit/join-key-extractor.js.map +1 -0
  443. package/dist/src/runtime/emit/join.d.ts.map +1 -1
  444. package/dist/src/runtime/emit/join.js +8 -46
  445. package/dist/src/runtime/emit/join.js.map +1 -1
  446. package/dist/src/runtime/emit/key-set-semi-join.d.ts +29 -0
  447. package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -0
  448. package/dist/src/runtime/emit/key-set-semi-join.js +149 -0
  449. package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -0
  450. package/dist/src/runtime/emit/merge-join.d.ts.map +1 -1
  451. package/dist/src/runtime/emit/merge-join.js +15 -8
  452. package/dist/src/runtime/emit/merge-join.js.map +1 -1
  453. package/dist/src/runtime/emit/operand-comparator.d.ts +70 -0
  454. package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -0
  455. package/dist/src/runtime/emit/operand-comparator.js +93 -0
  456. package/dist/src/runtime/emit/operand-comparator.js.map +1 -0
  457. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  458. package/dist/src/runtime/emit/scan.js +11 -2
  459. package/dist/src/runtime/emit/scan.js.map +1 -1
  460. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  461. package/dist/src/runtime/emit/schema-declarative.js +30 -0
  462. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  463. package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
  464. package/dist/src/runtime/emit/subquery.js +153 -52
  465. package/dist/src/runtime/emit/subquery.js.map +1 -1
  466. package/dist/src/runtime/emit/window.js +36 -23
  467. package/dist/src/runtime/emit/window.js.map +1 -1
  468. package/dist/src/runtime/parallel-driver.d.ts +5 -2
  469. package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
  470. package/dist/src/runtime/parallel-driver.js +6 -2
  471. package/dist/src/runtime/parallel-driver.js.map +1 -1
  472. package/dist/src/runtime/register.d.ts.map +1 -1
  473. package/dist/src/runtime/register.js +2 -0
  474. package/dist/src/runtime/register.js.map +1 -1
  475. package/dist/src/runtime/types.d.ts +7 -0
  476. package/dist/src/runtime/types.d.ts.map +1 -1
  477. package/dist/src/runtime/types.js.map +1 -1
  478. package/dist/src/schema/catalog-persistability.d.ts +19 -16
  479. package/dist/src/schema/catalog-persistability.d.ts.map +1 -1
  480. package/dist/src/schema/catalog-persistability.js +76 -20
  481. package/dist/src/schema/catalog-persistability.js.map +1 -1
  482. package/dist/src/schema/catalog.d.ts +67 -2
  483. package/dist/src/schema/catalog.d.ts.map +1 -1
  484. package/dist/src/schema/catalog.js +194 -3
  485. package/dist/src/schema/catalog.js.map +1 -1
  486. package/dist/src/schema/column.d.ts +26 -3
  487. package/dist/src/schema/column.d.ts.map +1 -1
  488. package/dist/src/schema/column.js.map +1 -1
  489. package/dist/src/schema/ddl-generator.d.ts.map +1 -1
  490. package/dist/src/schema/ddl-generator.js +19 -6
  491. package/dist/src/schema/ddl-generator.js.map +1 -1
  492. package/dist/src/schema/function.d.ts +40 -0
  493. package/dist/src/schema/function.d.ts.map +1 -1
  494. package/dist/src/schema/function.js +10 -2
  495. package/dist/src/schema/function.js.map +1 -1
  496. package/dist/src/schema/manager.d.ts +84 -7
  497. package/dist/src/schema/manager.d.ts.map +1 -1
  498. package/dist/src/schema/manager.js +153 -53
  499. package/dist/src/schema/manager.js.map +1 -1
  500. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  501. package/dist/src/schema/schema-differ.js +104 -28
  502. package/dist/src/schema/schema-differ.js.map +1 -1
  503. package/dist/src/schema/table.d.ts +149 -1
  504. package/dist/src/schema/table.d.ts.map +1 -1
  505. package/dist/src/schema/table.js +248 -1
  506. package/dist/src/schema/table.js.map +1 -1
  507. package/dist/src/schema/unique-enforcement.d.ts +5 -3
  508. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  509. package/dist/src/schema/unique-enforcement.js +5 -3
  510. package/dist/src/schema/unique-enforcement.js.map +1 -1
  511. package/dist/src/types/builtin-types.d.ts +16 -0
  512. package/dist/src/types/builtin-types.d.ts.map +1 -1
  513. package/dist/src/types/builtin-types.js +76 -12
  514. package/dist/src/types/builtin-types.js.map +1 -1
  515. package/dist/src/types/cast-semantics.d.ts +42 -0
  516. package/dist/src/types/cast-semantics.d.ts.map +1 -1
  517. package/dist/src/types/cast-semantics.js +64 -0
  518. package/dist/src/types/cast-semantics.js.map +1 -1
  519. package/dist/src/types/comparison-coercion.d.ts +101 -0
  520. package/dist/src/types/comparison-coercion.d.ts.map +1 -0
  521. package/dist/src/types/comparison-coercion.js +162 -0
  522. package/dist/src/types/comparison-coercion.js.map +1 -0
  523. package/dist/src/types/index.d.ts +2 -2
  524. package/dist/src/types/index.d.ts.map +1 -1
  525. package/dist/src/types/index.js +2 -2
  526. package/dist/src/types/index.js.map +1 -1
  527. package/dist/src/types/logical-type.d.ts +7 -0
  528. package/dist/src/types/logical-type.d.ts.map +1 -1
  529. package/dist/src/types/logical-type.js.map +1 -1
  530. package/dist/src/types/validation.d.ts +56 -0
  531. package/dist/src/types/validation.d.ts.map +1 -1
  532. package/dist/src/types/validation.js +68 -0
  533. package/dist/src/types/validation.js.map +1 -1
  534. package/dist/src/util/coercion.d.ts +8 -0
  535. package/dist/src/util/coercion.d.ts.map +1 -1
  536. package/dist/src/util/coercion.js +8 -0
  537. package/dist/src/util/coercion.js.map +1 -1
  538. package/dist/src/util/comparison.d.ts +41 -3
  539. package/dist/src/util/comparison.d.ts.map +1 -1
  540. package/dist/src/util/comparison.js +52 -5
  541. package/dist/src/util/comparison.js.map +1 -1
  542. package/dist/src/util/key-serializer.d.ts +46 -0
  543. package/dist/src/util/key-serializer.d.ts.map +1 -1
  544. package/dist/src/util/key-serializer.js +47 -0
  545. package/dist/src/util/key-serializer.js.map +1 -1
  546. package/dist/src/util/value-set.d.ts +21 -0
  547. package/dist/src/util/value-set.d.ts.map +1 -0
  548. package/dist/src/util/value-set.js +22 -0
  549. package/dist/src/util/value-set.js.map +1 -0
  550. package/dist/src/vtab/best-access-plan.d.ts +87 -0
  551. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  552. package/dist/src/vtab/best-access-plan.js +87 -0
  553. package/dist/src/vtab/best-access-plan.js.map +1 -1
  554. package/dist/src/vtab/capabilities.d.ts +1 -1
  555. package/dist/src/vtab/events.d.ts +5 -1
  556. package/dist/src/vtab/events.d.ts.map +1 -1
  557. package/dist/src/vtab/events.js.map +1 -1
  558. package/dist/src/vtab/memory/layer/alter-column.d.ts +147 -0
  559. package/dist/src/vtab/memory/layer/alter-column.d.ts.map +1 -0
  560. package/dist/src/vtab/memory/layer/alter-column.js +214 -0
  561. package/dist/src/vtab/memory/layer/alter-column.js.map +1 -0
  562. package/dist/src/vtab/memory/layer/base.d.ts +6 -4
  563. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  564. package/dist/src/vtab/memory/layer/base.js +10 -7
  565. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  566. package/dist/src/vtab/memory/layer/interface.d.ts +2 -2
  567. package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
  568. package/dist/src/vtab/memory/layer/manager.d.ts +232 -39
  569. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  570. package/dist/src/vtab/memory/layer/manager.js +657 -519
  571. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  572. package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
  573. package/dist/src/vtab/memory/layer/scan-layer.js +32 -5
  574. package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
  575. package/dist/src/vtab/memory/layer/transaction.d.ts +111 -16
  576. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  577. package/dist/src/vtab/memory/layer/transaction.js +154 -51
  578. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  579. package/dist/src/vtab/memory/module.d.ts +14 -2
  580. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  581. package/dist/src/vtab/memory/module.js +53 -40
  582. package/dist/src/vtab/memory/module.js.map +1 -1
  583. package/dist/src/vtab/memory/table.d.ts +1 -1
  584. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  585. package/dist/src/vtab/memory/table.js +15 -3
  586. package/dist/src/vtab/memory/table.js.map +1 -1
  587. package/dist/src/vtab/module.d.ts +51 -21
  588. package/dist/src/vtab/module.d.ts.map +1 -1
  589. package/dist/src/vtab/table.d.ts +10 -2
  590. package/dist/src/vtab/table.d.ts.map +1 -1
  591. package/dist/src/vtab/table.js +1 -1
  592. package/dist/src/vtab/table.js.map +1 -1
  593. package/package.json +3 -3
@@ -38,6 +38,39 @@ export interface RangeSpec {
38
38
  value: SqlValue;
39
39
  };
40
40
  }
41
+ /**
42
+ * Describes an `IN` constraint whose member values are produced at execution time
43
+ * (typically from a subquery), so the planner cannot name them. Present ⇒ `value`
44
+ * is absent.
45
+ *
46
+ * A module that accepts such a constraint (`handledFilters[i] = true`, plus
47
+ * `indexName` and `seekColumnIndexes`) promises only that it can serve the column as
48
+ * a multi-seek on the named index. In exchange the engine promises that at `query()`
49
+ * time the module receives an ordinary `plan=5` multi-seek `FilterInfo` — the same
50
+ * shape a literal `IN (…)` list produces, with `1 ≤ K ≤ maxCount` seek keys — so no
51
+ * module runtime needs to change and nothing distinguishes a runtime-derived set from
52
+ * a hand-written list. Declining is always safe. See `docs/module-authoring.md`
53
+ * § "Runtime-valued `IN` sets".
54
+ */
55
+ export interface RuntimeSetSpec {
56
+ /**
57
+ * Hard ceiling on the number of seek keys the engine will deliver at query() time.
58
+ * The engine enforces it: a larger set never reaches the module — the engine falls
59
+ * back to a full scan on its own.
60
+ */
61
+ readonly maxCount: number;
62
+ /**
63
+ * Planner's estimate of the actual count, when it has one. Advisory — a module may
64
+ * price against it but must still be correct for any count in `1..maxCount`. When
65
+ * present it is an integer in `0..maxCount` (0 meaning "probably empty").
66
+ *
67
+ * NOTE: no shipped module reads this — both price against `maxCount`, i.e. worst case.
68
+ * If the engine ever probes with a large ceiling for a typically tiny set, those plans
69
+ * will look more expensive than they are and may lose to a scan they should beat;
70
+ * blend `estimatedCount` into the cost (not into the safety gates) at that point.
71
+ */
72
+ readonly estimatedCount?: number;
73
+ }
41
74
  /**
42
75
  * A predicate constraint extracted from WHERE clause
43
76
  */
@@ -52,7 +85,49 @@ export interface PredicateConstraint {
52
85
  usable: boolean;
53
86
  /** Range specifications for OR_RANGE constraints */
54
87
  ranges?: RangeSpec[];
88
+ /**
89
+ * Set only when `op === 'IN'` and the members are not known at plan time.
90
+ * Mutually exclusive with `value` — see {@link RuntimeSetSpec}.
91
+ */
92
+ readonly runtimeSet?: RuntimeSetSpec;
55
93
  }
94
+ /**
95
+ * Number of seek keys an equality-role filter contributes at plan time, or null when
96
+ * the filter cannot fill an equality role at all:
97
+ *
98
+ * `=` → 1
99
+ * literal `IN` → `value.length` (elements may be `undefined` for parameter
100
+ * bindings — only the LENGTH is meaningful at plan time)
101
+ * runtime-set `IN` → `runtimeSet.maxCount`, the WORST case; the delivered count
102
+ * is anywhere in `1..maxCount`
103
+ * anything else → null
104
+ *
105
+ * A malformed shape — an empty literal list, a `maxCount` that is not a positive integer —
106
+ * returns null, so a module declines it and it survives as a residual. That mirrors the
107
+ * literal arm's long-standing non-empty-array gate and holds even when
108
+ * {@link validateAccessPlanRequest} was never called (the store module, for one, does not
109
+ * call it), so a bad request degrades to a scan rather than to a zero-key seek.
110
+ *
111
+ * For plan-time-known values this mirrors the exact predicate
112
+ * `rule-select-access-path`'s `eqBySeekCol` uses to pick its per-column equality
113
+ * constraint, so a module's positional claim and the rule's pick cannot disagree. The
114
+ * runtime-set arm has no counterpart there because nothing in the planner emits
115
+ * `runtimeSet` yet — `feat-key-set-semi-join` supplies the engine half and lowers a
116
+ * runtime set to a literal seek-key list before the rule ever sees it.
117
+ */
118
+ export declare function equalitySeekKeyCount(f: PredicateConstraint): number | null;
119
+ /**
120
+ * True when the filter may seek more than one key — i.e. it walks the index in seek-key
121
+ * order rather than column order, so a plan built on it cannot claim `providesOrdering`
122
+ * over that column and is not a scan-constant.
123
+ *
124
+ * A well-formed runtime set is ALWAYS multi-valued here, even at `maxCount === 1`: the
125
+ * delivered count is not knowable at plan time, and mistaking a multi-seek for a constant
126
+ * would elide a `Sort` the plan needs. (That is the one case where this disagrees with
127
+ * `equalitySeekKeyCount(f) > 1`; the conservative answer is the safe one.) A malformed
128
+ * one fills no equality role at all, so it is not multi-valued either.
129
+ */
130
+ export declare function isMultiValueEquality(f: PredicateConstraint): boolean;
56
131
  /**
57
132
  * Ordering specification for ORDER BY clauses
58
133
  */
@@ -248,6 +323,18 @@ export declare class AccessPlanBuilder {
248
323
  */
249
324
  build(): BestAccessPlanResult;
250
325
  }
326
+ /**
327
+ * Validate the REQUEST the engine hands a module, before the module can improvise on a
328
+ * shape it was never promised. Called from {@link validateAccessPlan}, so every module
329
+ * that follows the validate-your-plan convention gets it without a second call site.
330
+ *
331
+ * The checks are all on {@link RuntimeSetSpec}: it must ride an `IN`, it must not carry
332
+ * plan-time `value`s (a module reading `value` on a runtime set would seek on garbage),
333
+ * its ceiling must be a usable count, and an advisory `estimatedCount` must fall within
334
+ * that ceiling — an estimate above `maxCount` describes a set the engine has promised
335
+ * never to deliver, so it is an engine bug rather than a pessimistic guess.
336
+ */
337
+ export declare function validateAccessPlanRequest(request: BestAccessPlanRequest): void;
251
338
  /**
252
339
  * Validation function for access plan results
253
340
  * Throws if the plan violates basic contracts
@@ -1 +1 @@
1
- {"version":3,"file":"best-access-plan.d.ts","sourceRoot":"","sources":["../../../src/vt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AC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA8B9E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,oBAAoB,GAC1B,IAAI,CAwGN"}
@@ -5,6 +5,62 @@
5
5
  import { quereusError } from '../common/errors.js';
6
6
  import { StatusCode } from '../common/types.js';
7
7
  import { validateIndexDescriptor } from './index-descriptor.js';
8
+ /**
9
+ * Number of seek keys an equality-role filter contributes at plan time, or null when
10
+ * the filter cannot fill an equality role at all:
11
+ *
12
+ * `=` → 1
13
+ * literal `IN` → `value.length` (elements may be `undefined` for parameter
14
+ * bindings — only the LENGTH is meaningful at plan time)
15
+ * runtime-set `IN` → `runtimeSet.maxCount`, the WORST case; the delivered count
16
+ * is anywhere in `1..maxCount`
17
+ * anything else → null
18
+ *
19
+ * A malformed shape — an empty literal list, a `maxCount` that is not a positive integer —
20
+ * returns null, so a module declines it and it survives as a residual. That mirrors the
21
+ * literal arm's long-standing non-empty-array gate and holds even when
22
+ * {@link validateAccessPlanRequest} was never called (the store module, for one, does not
23
+ * call it), so a bad request degrades to a scan rather than to a zero-key seek.
24
+ *
25
+ * For plan-time-known values this mirrors the exact predicate
26
+ * `rule-select-access-path`'s `eqBySeekCol` uses to pick its per-column equality
27
+ * constraint, so a module's positional claim and the rule's pick cannot disagree. The
28
+ * runtime-set arm has no counterpart there because nothing in the planner emits
29
+ * `runtimeSet` yet — `feat-key-set-semi-join` supplies the engine half and lowers a
30
+ * runtime set to a literal seek-key list before the rule ever sees it.
31
+ */
32
+ export function equalitySeekKeyCount(f) {
33
+ if (f.op === '=')
34
+ return 1;
35
+ if (f.op === 'IN') {
36
+ if (f.runtimeSet) {
37
+ const { maxCount } = f.runtimeSet;
38
+ return Number.isInteger(maxCount) && maxCount > 0 ? maxCount : null;
39
+ }
40
+ if (Array.isArray(f.value) && f.value.length > 0) {
41
+ return f.value.length;
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ /**
47
+ * True when the filter may seek more than one key — i.e. it walks the index in seek-key
48
+ * order rather than column order, so a plan built on it cannot claim `providesOrdering`
49
+ * over that column and is not a scan-constant.
50
+ *
51
+ * A well-formed runtime set is ALWAYS multi-valued here, even at `maxCount === 1`: the
52
+ * delivered count is not knowable at plan time, and mistaking a multi-seek for a constant
53
+ * would elide a `Sort` the plan needs. (That is the one case where this disagrees with
54
+ * `equalitySeekKeyCount(f) > 1`; the conservative answer is the safe one.) A malformed
55
+ * one fills no equality role at all, so it is not multi-valued either.
56
+ */
57
+ export function isMultiValueEquality(f) {
58
+ if (f.op !== 'IN')
59
+ return false;
60
+ if (f.runtimeSet)
61
+ return equalitySeekKeyCount(f) !== null;
62
+ return Array.isArray(f.value) && f.value.length > 1;
63
+ }
8
64
  /**
9
65
  * Builder class for constructing access plan results
10
66
  */
@@ -123,11 +179,42 @@ export class AccessPlanBuilder {
123
179
  return this.result;
124
180
  }
125
181
  }
182
+ /**
183
+ * Validate the REQUEST the engine hands a module, before the module can improvise on a
184
+ * shape it was never promised. Called from {@link validateAccessPlan}, so every module
185
+ * that follows the validate-your-plan convention gets it without a second call site.
186
+ *
187
+ * The checks are all on {@link RuntimeSetSpec}: it must ride an `IN`, it must not carry
188
+ * plan-time `value`s (a module reading `value` on a runtime set would seek on garbage),
189
+ * its ceiling must be a usable count, and an advisory `estimatedCount` must fall within
190
+ * that ceiling — an estimate above `maxCount` describes a set the engine has promised
191
+ * never to deliver, so it is an engine bug rather than a pessimistic guess.
192
+ */
193
+ export function validateAccessPlanRequest(request) {
194
+ for (const filter of request.filters) {
195
+ if (!filter.runtimeSet)
196
+ continue;
197
+ if (filter.op !== 'IN') {
198
+ quereusError(`runtimeSet is only valid on an 'IN' constraint, got '${filter.op}' on column ${filter.columnIndex}`, StatusCode.FORMAT);
199
+ }
200
+ if (filter.value !== undefined) {
201
+ quereusError(`runtimeSet and value are mutually exclusive (column ${filter.columnIndex}); a runtime set has no plan-time members`, StatusCode.FORMAT);
202
+ }
203
+ const { maxCount, estimatedCount } = filter.runtimeSet;
204
+ if (!Number.isInteger(maxCount) || maxCount < 1) {
205
+ quereusError(`runtimeSet.maxCount must be an integer >= 1, got ${maxCount} on column ${filter.columnIndex}`, StatusCode.FORMAT);
206
+ }
207
+ if (estimatedCount !== undefined && (!Number.isInteger(estimatedCount) || estimatedCount < 0 || estimatedCount > maxCount)) {
208
+ quereusError(`runtimeSet.estimatedCount must be an integer in 0..${maxCount}, got ${estimatedCount} on column ${filter.columnIndex}`, StatusCode.FORMAT);
209
+ }
210
+ }
211
+ }
126
212
  /**
127
213
  * Validation function for access plan results
128
214
  * Throws if the plan violates basic contracts
129
215
  */
130
216
  export function validateAccessPlan(request, result) {
217
+ validateAccessPlanRequest(request);
131
218
  // Validate handledFilters array length
132
219
  if (result.handledFilters.length !== request.filters.length) {
133
220
  quereusError(`handledFilters length (${result.handledFilters.length}) must match filters length (${request.filters.length})`, StatusCode.FORMAT);
@@ -1 +1 @@
1
- {"version":3,"file":"best-access-plan.js","sourceRoot":"","sources":["../../../src/vtab/best-access-plan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAA2B,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAC;AA2LtF;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACrB,MAAM,GAAkC,EAAE,CAAC;IAEnD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAqB;QACpC,OAAO,IAAI,iBAAiB,EAAE;aAC5B,OAAO,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,uBAAuB;aACpD,OAAO,CAAC,aAAa,CAAC;aACtB,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,WAAmB,EAAE,YAAoB,GAAG;QAC1D,OAAO,IA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,MAAM,eAAe,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,EACrF,UAAU,CAAC,MAAM,CACjB,CAAC;QACH,CAAC;IACF,CAAC;IAED,0DAA0D;IAC1D,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACvD,YAAY,CACX,oDAAoD,EACpD,UAAU,CAAC,MAAM,CACjB,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,IAAI,MAAM,CAAC,iBAAiB,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACrD,YAAY,CACX,kDAAkD,EAClD,UAAU,CAAC,MAAM,CACjB,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -24,7 +24,7 @@ import type { SqlValue, Row, CompareFn } from '../common/types.js';
24
24
  * Consumed by the `ddl_transaction_policy = 'strict'` gate, which refuses a
25
25
  * module-dispatching DDL statement inside an explicit transaction on any module
26
26
  * whose tier is not `'transactional'`. See `runtime/emit/ddl-transaction-policy.ts`
27
- * and docs/module-authoring.md § "Capability negotiation surface".
27
+ * and docs/module-capabilities.md § "DDL transactionality tiers".
28
28
  */
29
29
  export type DdlTransactionality = 'transactional' | 'non-transactional' | 'auto-commit';
30
30
  /**
@@ -10,6 +10,10 @@ import type { AnyVirtualTableModule } from './module.js';
10
10
  export declare function tryGetEventEmitter(module: AnyVirtualTableModule): VTableEventEmitter | undefined;
11
11
  /**
12
12
  * Data change event emitted when mutations are committed.
13
+ *
14
+ * Producers owe the key contract in `docs/usage.md` § Subscribing to Data Changes: `key` is
15
+ * projected from the event's own row image, and an `update` never moves a row (a relocating
16
+ * primary-key change is a `delete` at the old key then an `insert` at the new one).
13
17
  */
14
18
  export interface VTableDataChangeEvent {
15
19
  /** The type of mutation operation */
@@ -18,7 +22,7 @@ export interface VTableDataChangeEvent {
18
22
  schemaName: string;
19
23
  /** Table name */
20
24
  tableName: string;
21
- /** Primary key values */
25
+ /** Primary key projected from this event's own image: `newRow` for insert/update, `oldRow` for delete */
22
26
  key?: SqlValue[];
23
27
  /** Previous row data (for update/delete) */
24
28
  oldRow?: Row;
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/vtab/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAKzD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,kBAAkB,GAAG,SAAS,CAQhG;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,qCAAqC;IACrC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrC,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC;IACjB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,uCAAuC;IACvC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,mCAAmC;IACnC,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC,wCAAwC;IACxC,UAAU,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IACzC,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAA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ED,cAAc,CAAC,QAAoC;QAClD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,kBAAkB;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,gBAAgB,CAAC,KAA8B;QAC9C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACJ,QAAQ,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,QAAQ,CAAC,8CAA8C,EACtD,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;IACF,CAAC;IAED,kBAAkB;QACjB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IACzB,CAAC;CACD"}
@@ -0,0 +1,147 @@
1
+ import type { Expression } from '../../../parser/ast.js';
2
+ import type { ColumnSchema } from '../../../schema/column.js';
3
+ import { type TableSchema } from '../../../schema/table.js';
4
+ import { type SqlValue } from '../../../common/types.js';
5
+ import type { Row } from '../../../common/types.js';
6
+ /**
7
+ * The decide-and-validate half of `MemoryTableManager.alterColumn`.
8
+ *
9
+ * Everything here is a function of the PRE-change {@link TableSchema} plus the DDL
10
+ * transaction's effective rows. It may THROW — that is how an illegal ALTER is rejected —
11
+ * but it never mutates the manager, the base layer, or any open transaction layer. That
12
+ * split is the "validate before any mutation" guarantee the ALTER paths depend on: the
13
+ * manager runs every function in this file (plus its own re-keyed UNIQUE / primary-key
14
+ * probes) before its first write, so a rejection leaves the table exactly as it was.
15
+ *
16
+ * The apply half — base rebuild, open-layer propagation, rollback — stays on the manager,
17
+ * which owns that state.
18
+ */
19
+ /** The single-attribute change one `alter column` statement asks for. */
20
+ export interface AlterColumnChange {
21
+ columnName: string;
22
+ setNotNull?: boolean;
23
+ setDataType?: string;
24
+ setDefault?: Expression | null;
25
+ setCollation?: string;
26
+ }
27
+ /**
28
+ * A physical rewrite of every stored value in the altered column: `set data type` (every
29
+ * non-alias retype — values normalize to the new type's canonical spelling even when the
30
+ * storage class is unchanged) and the `set not null` null → DEFAULT backfill.
31
+ *
32
+ * The manager applies it by REPLACING the base primary tree with a freshly-built one (never
33
+ * an in-place mutation, which inheritree forbids while the open transaction's layers derive
34
+ * from it) and converting the transaction's own-written rows in every open layer.
35
+ */
36
+ export interface ValueRewrite {
37
+ readonly convert: (v: SqlValue) => SqlValue;
38
+ /**
39
+ * Route NULLs through `convert` too. Set by the `set not null` backfill (null → DEFAULT);
40
+ * `set data type` leaves nulls untouched.
41
+ */
42
+ readonly convertNulls: boolean;
43
+ }
44
+ /** What one attribute handler decided: the column schema it produces, plus its consequences. */
45
+ export interface ColumnAttributeChange {
46
+ readonly newCol: ColumnSchema;
47
+ /**
48
+ * The collation NAME moved, which re-keys any PK / UNIQUE / index that orders by this
49
+ * column — so the structures need the re-sort + uniqueness re-validation. False for a
50
+ * metadata-only `set collate` that merely marks an already-matching collation explicit.
51
+ */
52
+ readonly collationChanged: boolean;
53
+ /**
54
+ * A `set data type` moved to a type that ORDERS values differently
55
+ * ({@link comparisonSemanticsDiffer}). Same consequence as a collation change — every
56
+ * structure keyed by the column has to be re-sorted and its uniqueness re-judged — but a
57
+ * separate flag, because the index-column collation propagation and the primary-tree
58
+ * re-key belong to `set collate` alone. Usually coincides with {@link rewrite} (every
59
+ * non-alias retype sets that), whose full-rebuild path subsumes the comparator-only re-sort.
60
+ */
61
+ readonly comparatorChanged: boolean;
62
+ /** Set when the stored values themselves must be rewritten; null for a schema-only change. */
63
+ readonly rewrite: ValueRewrite | null;
64
+ }
65
+ /** {@link ColumnAttributeChange} resolved against the table: post-change schema + rebuild consequences. */
66
+ export interface AlterColumnPlan {
67
+ readonly colIndex: number;
68
+ readonly newSchema: TableSchema;
69
+ readonly rewrite: ValueRewrite | null;
70
+ /**
71
+ * The comparators the structures are keyed by moved: `set collate` (values untouched) or a
72
+ * retype into a differently-ordering type (which, unless it is an alias retype, ALSO sets
73
+ * {@link rewrite}, whose full-rebuild path subsumes the comparator-only re-sort).
74
+ */
75
+ readonly structuresRekeyed: boolean;
76
+ /** `set collate` moved a PRIMARY KEY member's collation — the primary tree itself re-keys. */
77
+ readonly pkColumnRekeyed: boolean;
78
+ }
79
+ /**
80
+ * The DDL transaction's EFFECTIVE rows: committed rows overlaid with its own pending writes. A
81
+ * value the transaction can SEE rejects the ALTER; one only in a row it has DELETED does not block
82
+ * it. Re-callable — each scan gets a fresh stream.
83
+ *
84
+ * Either flavour: the manager's own layered walk is synchronous, a wrapper module's overlay (the
85
+ * isolation layer) is an `EffectiveRowSource` and therefore async. {@link scanEffectiveRows} keeps
86
+ * the sync one sync.
87
+ */
88
+ export type EffectiveRows = () => Iterable<Row> | AsyncIterable<Row>;
89
+ /** Everything the attribute handlers read beyond the change itself. */
90
+ export interface AlterColumnContext {
91
+ readonly schema: TableSchema;
92
+ readonly tableName: string;
93
+ /** The column name as the statement spelled it — error messages echo it verbatim. */
94
+ readonly columnName: string;
95
+ readonly colIndex: number;
96
+ readonly effectiveRows: EffectiveRows;
97
+ readonly isCollationRegistered: (name: string) => boolean;
98
+ }
99
+ /**
100
+ * Resolve the one populated attribute in `change`. Returns null when the column is already in
101
+ * the requested state — a no-op ALTER the manager returns from without touching anything.
102
+ */
103
+ export declare function planColumnAttributeChange(ctx: AlterColumnContext, change: AlterColumnChange): Promise<ColumnAttributeChange | null>;
104
+ /**
105
+ * `set collate`. A user declaration with the same standing as a CREATE-time COLLATE clause, so
106
+ * the collation is marked explicit (rank 2 in the comparison lattice) regardless of the column's
107
+ * creation history — including `set collate binary`. When only the name matches but the column
108
+ * was not yet explicit (a defaulted collation, or one inherited from session default_collation),
109
+ * flipping the flag is METADATA-ONLY: the collation bytes are unchanged, so the physical re-sort
110
+ * / re-key / UNIQUE re-validation are skipped. A different name takes the full path.
111
+ */
112
+ export declare function planSetCollation(ctx: AlterColumnContext, requested: string): ColumnAttributeChange | null;
113
+ /** `set not null` / `drop not null`. */
114
+ export declare function planSetNotNull(ctx: AlterColumnContext, setNotNull: boolean): Promise<ColumnAttributeChange | null>;
115
+ /**
116
+ * `set data type`.
117
+ *
118
+ * Gates on logical-type IDENTITY, not the physical storage class: `inferType` flattens aliases to
119
+ * the shared type object (`varchar(50)` IS `TEXT_TYPE`, `bigint` IS `INTEGER_TYPE`), so an alias
120
+ * retype is schema-only — no scan, no rewrite, no re-key. Every OTHER retype validates AND
121
+ * normalizes every value, whether or not the storage class changes: a same-class move (text →
122
+ * date) must reject values the new type refuses ('hello') and rewrite the rest to the new type's
123
+ * canonical spelling ('2024-06-05T00:00:00Z' → '2024-06-05'), or the column holds values no
124
+ * INSERT could have produced — unfindable by equality (DATE compares BINARY over the stored text)
125
+ * and invisible to UNIQUE.
126
+ *
127
+ * NOTE: the rewrite is unconditional once the types differ, even when every converted value comes
128
+ * back byte-identical (already-canonical ISO durations on a text → timespan). That costs a full
129
+ * base-tree + secondary-index rebuild, and a physical rewrite of every row on the store leg. If
130
+ * ALTER on large tables ever shows up as slow, have the convert pre-pass record whether any value
131
+ * actually moved and, when none did, fall through to the comparator-only re-key.
132
+ */
133
+ export declare function planSetDataType(ctx: AlterColumnContext, dataType: string): Promise<ColumnAttributeChange>;
134
+ /**
135
+ * Build the post-change {@link TableSchema} and the flags the apply half keys off.
136
+ *
137
+ * Every re-keying change REBUILDS the IndexSchema objects, because their identity is the
138
+ * discriminator `TransactionLayer.adoptSchema` uses to decide an open layer's MemoryIndex must be
139
+ * replaced rather than kept (an index it holds under an object the new schema still carries is
140
+ * left alone). SET COLLATE has a field to write — the index column's own collation. A
141
+ * comparator-only retype has none: an index column carries no logical type, it reads the column's
142
+ * from `newSchema.columns`, so the fresh object IS the whole signal. Without it the base rebuilt
143
+ * its trees under the new comparator while the DDL transaction's own layers went on comparing the
144
+ * old way — and shadowed the base's rebuilt trees once the pending layer became the committed head.
145
+ */
146
+ export declare function buildAlterColumnPlan(schema: TableSchema, colIndex: number, change: ColumnAttributeChange): AlterColumnPlan;
147
+ //# sourceMappingURL=alter-column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alter-column.d.ts","sourceRoot":"","sources":["../../../../../src/vtab/memory/layer/alter-column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAiD,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC3G,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;;;;;;;;;GAYG;AAEH,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,QAAQ,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAC/B;AAED,gGAAgG;AAChG,MAAM,WAAW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