@quereus/quereus 4.5.0 → 4.7.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 (818) hide show
  1. package/README.md +5 -4
  2. package/dist/src/common/errors.d.ts +17 -0
  3. package/dist/src/common/errors.d.ts.map +1 -1
  4. package/dist/src/common/errors.js +21 -0
  5. package/dist/src/common/errors.js.map +1 -1
  6. package/dist/src/core/database-assertions.d.ts +4 -3
  7. package/dist/src/core/database-assertions.d.ts.map +1 -1
  8. package/dist/src/core/database-assertions.js +44 -14
  9. package/dist/src/core/database-assertions.js.map +1 -1
  10. package/dist/src/core/database-events.d.ts +161 -1
  11. package/dist/src/core/database-events.d.ts.map +1 -1
  12. package/dist/src/core/database-events.js +307 -5
  13. package/dist/src/core/database-events.js.map +1 -1
  14. package/dist/src/core/database-internal.d.ts +5 -2
  15. package/dist/src/core/database-internal.d.ts.map +1 -1
  16. package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
  17. package/dist/src/core/database-materialized-views-plan-builders.js +33 -4
  18. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
  19. package/dist/src/core/database-materialized-views-plans.d.ts +12 -2
  20. package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -1
  21. package/dist/src/core/database-materialized-views.d.ts +46 -0
  22. package/dist/src/core/database-materialized-views.d.ts.map +1 -1
  23. package/dist/src/core/database-materialized-views.js +75 -4
  24. package/dist/src/core/database-materialized-views.js.map +1 -1
  25. package/dist/src/core/database-transaction.d.ts +9 -0
  26. package/dist/src/core/database-transaction.d.ts.map +1 -1
  27. package/dist/src/core/database-transaction.js +9 -0
  28. package/dist/src/core/database-transaction.js.map +1 -1
  29. package/dist/src/core/database.d.ts +16 -2
  30. package/dist/src/core/database.d.ts.map +1 -1
  31. package/dist/src/core/database.js +56 -15
  32. package/dist/src/core/database.js.map +1 -1
  33. package/dist/src/core/derived-row-validator.d.ts.map +1 -1
  34. package/dist/src/core/derived-row-validator.js +7 -1
  35. package/dist/src/core/derived-row-validator.js.map +1 -1
  36. package/dist/src/core/statement.d.ts.map +1 -1
  37. package/dist/src/core/statement.js +15 -5
  38. package/dist/src/core/statement.js.map +1 -1
  39. package/dist/src/emit/ast-stringify.d.ts +18 -2
  40. package/dist/src/emit/ast-stringify.d.ts.map +1 -1
  41. package/dist/src/emit/ast-stringify.js +22 -4
  42. package/dist/src/emit/ast-stringify.js.map +1 -1
  43. package/dist/src/func/builtins/aggregate.js +11 -11
  44. package/dist/src/func/builtins/aggregate.js.map +1 -1
  45. package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
  46. package/dist/src/func/builtins/builtin-window-functions.js +15 -85
  47. package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
  48. package/dist/src/func/builtins/conversion.d.ts.map +1 -1
  49. package/dist/src/func/builtins/conversion.js +10 -9
  50. package/dist/src/func/builtins/conversion.js.map +1 -1
  51. package/dist/src/func/builtins/datetime.d.ts.map +1 -1
  52. package/dist/src/func/builtins/datetime.js +28 -10
  53. package/dist/src/func/builtins/datetime.js.map +1 -1
  54. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  55. package/dist/src/func/builtins/explain.js +19 -5
  56. package/dist/src/func/builtins/explain.js.map +1 -1
  57. package/dist/src/func/builtins/json.d.ts.map +1 -1
  58. package/dist/src/func/builtins/json.js +23 -17
  59. package/dist/src/func/builtins/json.js.map +1 -1
  60. package/dist/src/func/builtins/mutation.js +2 -2
  61. package/dist/src/func/builtins/mutation.js.map +1 -1
  62. package/dist/src/func/builtins/return-types.d.ts +327 -0
  63. package/dist/src/func/builtins/return-types.d.ts.map +1 -0
  64. package/dist/src/func/builtins/return-types.js +43 -0
  65. package/dist/src/func/builtins/return-types.js.map +1 -0
  66. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  67. package/dist/src/func/builtins/scalar.js +150 -79
  68. package/dist/src/func/builtins/scalar.js.map +1 -1
  69. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  70. package/dist/src/func/builtins/schema.js +43 -8
  71. package/dist/src/func/builtins/schema.js.map +1 -1
  72. package/dist/src/func/builtins/string.d.ts.map +1 -1
  73. package/dist/src/func/builtins/string.js +4 -2
  74. package/dist/src/func/builtins/string.js.map +1 -1
  75. package/dist/src/func/builtins/timespan.d.ts +3 -0
  76. package/dist/src/func/builtins/timespan.d.ts.map +1 -1
  77. package/dist/src/func/builtins/timespan.js +15 -11
  78. package/dist/src/func/builtins/timespan.js.map +1 -1
  79. package/dist/src/func/registration.d.ts +35 -1
  80. package/dist/src/func/registration.d.ts.map +1 -1
  81. package/dist/src/func/registration.js +235 -41
  82. package/dist/src/func/registration.js.map +1 -1
  83. package/dist/src/index.d.ts +14 -7
  84. package/dist/src/index.d.ts.map +1 -1
  85. package/dist/src/index.js +15 -6
  86. package/dist/src/index.js.map +1 -1
  87. package/dist/src/parser/ast.d.ts +58 -1
  88. package/dist/src/parser/ast.d.ts.map +1 -1
  89. package/dist/src/parser/parser.d.ts +46 -0
  90. package/dist/src/parser/parser.d.ts.map +1 -1
  91. package/dist/src/parser/parser.js +161 -45
  92. package/dist/src/parser/parser.js.map +1 -1
  93. package/dist/src/parser/utils.d.ts +13 -1
  94. package/dist/src/parser/utils.d.ts.map +1 -1
  95. package/dist/src/parser/utils.js +14 -0
  96. package/dist/src/parser/utils.js.map +1 -1
  97. package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -1
  98. package/dist/src/planner/analysis/assertion-classifier.js +7 -2
  99. package/dist/src/planner/analysis/assertion-classifier.js.map +1 -1
  100. package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -1
  101. package/dist/src/planner/analysis/assertion-hoist-cache.js +5 -0
  102. package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -1
  103. package/dist/src/planner/analysis/change-scope.d.ts +11 -3
  104. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
  105. package/dist/src/planner/analysis/change-scope.js +5 -4
  106. package/dist/src/planner/analysis/change-scope.js.map +1 -1
  107. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
  108. package/dist/src/planner/analysis/check-extraction.js +37 -4
  109. package/dist/src/planner/analysis/check-extraction.js.map +1 -1
  110. package/dist/src/planner/analysis/comparison-collation.d.ts +20 -22
  111. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
  112. package/dist/src/planner/analysis/comparison-collation.js +29 -26
  113. package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
  114. package/dist/src/planner/analysis/constraint-extractor.d.ts +0 -7
  115. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  116. package/dist/src/planner/analysis/constraint-extractor.js +59 -59
  117. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  118. package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
  119. package/dist/src/planner/analysis/coverage-prover.js +13 -5
  120. package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
  121. package/dist/src/planner/analysis/equi-correlation.d.ts +6 -1
  122. package/dist/src/planner/analysis/equi-correlation.d.ts.map +1 -1
  123. package/dist/src/planner/analysis/equi-correlation.js +8 -1
  124. package/dist/src/planner/analysis/equi-correlation.js.map +1 -1
  125. package/dist/src/planner/analysis/predicate-dependencies.d.ts +34 -0
  126. package/dist/src/planner/analysis/predicate-dependencies.d.ts.map +1 -0
  127. package/dist/src/planner/analysis/predicate-dependencies.js +60 -0
  128. package/dist/src/planner/analysis/predicate-dependencies.js.map +1 -0
  129. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +1 -1
  130. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
  131. package/dist/src/planner/analysis/query-rewrite-matcher.js +0 -26
  132. package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
  133. package/dist/src/planner/building/alter-table.d.ts.map +1 -1
  134. package/dist/src/planner/building/alter-table.js +117 -43
  135. package/dist/src/planner/building/alter-table.js.map +1 -1
  136. package/dist/src/planner/building/coercion.d.ts +21 -45
  137. package/dist/src/planner/building/coercion.d.ts.map +1 -1
  138. package/dist/src/planner/building/coercion.js +42 -91
  139. package/dist/src/planner/building/coercion.js.map +1 -1
  140. package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
  141. package/dist/src/planner/building/constraint-builder.js +9 -5
  142. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  143. package/dist/src/planner/building/create-assertion.d.ts.map +1 -1
  144. package/dist/src/planner/building/create-assertion.js +72 -1
  145. package/dist/src/planner/building/create-assertion.js.map +1 -1
  146. package/dist/src/planner/building/create-view.d.ts +6 -1
  147. package/dist/src/planner/building/create-view.d.ts.map +1 -1
  148. package/dist/src/planner/building/create-view.js +12 -3
  149. package/dist/src/planner/building/create-view.js.map +1 -1
  150. package/dist/src/planner/building/ddl.d.ts.map +1 -1
  151. package/dist/src/planner/building/ddl.js +6 -2
  152. package/dist/src/planner/building/ddl.js.map +1 -1
  153. package/dist/src/planner/building/delete.d.ts.map +1 -1
  154. package/dist/src/planner/building/delete.js +23 -10
  155. package/dist/src/planner/building/delete.js.map +1 -1
  156. package/dist/src/planner/building/dml-target.d.ts.map +1 -1
  157. package/dist/src/planner/building/dml-target.js +4 -0
  158. package/dist/src/planner/building/dml-target.js.map +1 -1
  159. package/dist/src/planner/building/drop-assertion.d.ts.map +1 -1
  160. package/dist/src/planner/building/drop-assertion.js +3 -1
  161. package/dist/src/planner/building/drop-assertion.js.map +1 -1
  162. package/dist/src/planner/building/expression.d.ts +17 -0
  163. package/dist/src/planner/building/expression.d.ts.map +1 -1
  164. package/dist/src/planner/building/expression.js +28 -17
  165. package/dist/src/planner/building/expression.js.map +1 -1
  166. package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
  167. package/dist/src/planner/building/foreign-key-builder.js +7 -5
  168. package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
  169. package/dist/src/planner/building/function-call.d.ts +35 -0
  170. package/dist/src/planner/building/function-call.d.ts.map +1 -1
  171. package/dist/src/planner/building/function-call.js +60 -42
  172. package/dist/src/planner/building/function-call.js.map +1 -1
  173. package/dist/src/planner/building/insert.d.ts.map +1 -1
  174. package/dist/src/planner/building/insert.js +185 -48
  175. package/dist/src/planner/building/insert.js.map +1 -1
  176. package/dist/src/planner/building/materialized-view.d.ts.map +1 -1
  177. package/dist/src/planner/building/materialized-view.js +3 -1
  178. package/dist/src/planner/building/materialized-view.js.map +1 -1
  179. package/dist/src/planner/building/schema-authored-context.d.ts +69 -0
  180. package/dist/src/planner/building/schema-authored-context.d.ts.map +1 -0
  181. package/dist/src/planner/building/schema-authored-context.js +75 -0
  182. package/dist/src/planner/building/schema-authored-context.js.map +1 -0
  183. package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
  184. package/dist/src/planner/building/schema-resolution.js +7 -4
  185. package/dist/src/planner/building/schema-resolution.js.map +1 -1
  186. package/dist/src/planner/building/select-aggregates.d.ts +188 -3
  187. package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
  188. package/dist/src/planner/building/select-aggregates.js +449 -65
  189. package/dist/src/planner/building/select-aggregates.js.map +1 -1
  190. package/dist/src/planner/building/select-compound.js +2 -2
  191. package/dist/src/planner/building/select-compound.js.map +1 -1
  192. package/dist/src/planner/building/select-context.d.ts +98 -0
  193. package/dist/src/planner/building/select-context.d.ts.map +1 -1
  194. package/dist/src/planner/building/select-context.js +120 -37
  195. package/dist/src/planner/building/select-context.js.map +1 -1
  196. package/dist/src/planner/building/select-modifiers.d.ts +10 -3
  197. package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
  198. package/dist/src/planner/building/select-modifiers.js +29 -8
  199. package/dist/src/planner/building/select-modifiers.js.map +1 -1
  200. package/dist/src/planner/building/select-ordinal.d.ts +64 -19
  201. package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
  202. package/dist/src/planner/building/select-ordinal.js +79 -30
  203. package/dist/src/planner/building/select-ordinal.js.map +1 -1
  204. package/dist/src/planner/building/select-projections.d.ts +1 -1
  205. package/dist/src/planner/building/select-projections.d.ts.map +1 -1
  206. package/dist/src/planner/building/select-projections.js +18 -11
  207. package/dist/src/planner/building/select-projections.js.map +1 -1
  208. package/dist/src/planner/building/select-window.d.ts +13 -3
  209. package/dist/src/planner/building/select-window.d.ts.map +1 -1
  210. package/dist/src/planner/building/select-window.js +142 -37
  211. package/dist/src/planner/building/select-window.js.map +1 -1
  212. package/dist/src/planner/building/select.d.ts +37 -1
  213. package/dist/src/planner/building/select.d.ts.map +1 -1
  214. package/dist/src/planner/building/select.js +240 -109
  215. package/dist/src/planner/building/select.js.map +1 -1
  216. package/dist/src/planner/building/update.d.ts.map +1 -1
  217. package/dist/src/planner/building/update.js +27 -13
  218. package/dist/src/planner/building/update.js.map +1 -1
  219. package/dist/src/planner/building/view-mutation-builder.d.ts +1 -1
  220. package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
  221. package/dist/src/planner/building/view-mutation-builder.js +102 -8
  222. package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
  223. package/dist/src/planner/building/with.d.ts.map +1 -1
  224. package/dist/src/planner/building/with.js +34 -4
  225. package/dist/src/planner/building/with.js.map +1 -1
  226. package/dist/src/planner/cache/correlation-detector.d.ts +15 -0
  227. package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
  228. package/dist/src/planner/cache/correlation-detector.js +26 -0
  229. package/dist/src/planner/cache/correlation-detector.js.map +1 -1
  230. package/dist/src/planner/cache/materialization-advisory.d.ts +7 -0
  231. package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
  232. package/dist/src/planner/cache/materialization-advisory.js +12 -3
  233. package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
  234. package/dist/src/planner/cost/conjunct-cost.d.ts +40 -0
  235. package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -1
  236. package/dist/src/planner/cost/conjunct-cost.js +45 -0
  237. package/dist/src/planner/cost/conjunct-cost.js.map +1 -1
  238. package/dist/src/planner/cost/index.d.ts +10 -0
  239. package/dist/src/planner/cost/index.d.ts.map +1 -1
  240. package/dist/src/planner/cost/index.js +15 -0
  241. package/dist/src/planner/cost/index.js.map +1 -1
  242. package/dist/src/planner/framework/characteristics.d.ts +9 -0
  243. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  244. package/dist/src/planner/framework/characteristics.js.map +1 -1
  245. package/dist/src/planner/framework/pass.d.ts +2 -0
  246. package/dist/src/planner/framework/pass.d.ts.map +1 -1
  247. package/dist/src/planner/framework/pass.js +15 -0
  248. package/dist/src/planner/framework/pass.js.map +1 -1
  249. package/dist/src/planner/mutation/backward-body.d.ts.map +1 -1
  250. package/dist/src/planner/mutation/backward-body.js +4 -1
  251. package/dist/src/planner/mutation/backward-body.js.map +1 -1
  252. package/dist/src/planner/mutation/body-context.d.ts +23 -0
  253. package/dist/src/planner/mutation/body-context.d.ts.map +1 -0
  254. package/dist/src/planner/mutation/body-context.js +26 -0
  255. package/dist/src/planner/mutation/body-context.js.map +1 -0
  256. package/dist/src/planner/mutation/cte-flatten.js +15 -2
  257. package/dist/src/planner/mutation/cte-flatten.js.map +1 -1
  258. package/dist/src/planner/mutation/decomposition.d.ts +8 -0
  259. package/dist/src/planner/mutation/decomposition.d.ts.map +1 -1
  260. package/dist/src/planner/mutation/decomposition.js +8 -3
  261. package/dist/src/planner/mutation/decomposition.js.map +1 -1
  262. package/dist/src/planner/mutation/lens-enforcement.js +1 -1
  263. package/dist/src/planner/mutation/multi-source.d.ts +7 -0
  264. package/dist/src/planner/mutation/multi-source.d.ts.map +1 -1
  265. package/dist/src/planner/mutation/multi-source.js +5 -0
  266. package/dist/src/planner/mutation/multi-source.js.map +1 -1
  267. package/dist/src/planner/mutation/mutation-diagnostic.d.ts +1 -1
  268. package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -1
  269. package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -1
  270. package/dist/src/planner/mutation/scope-transform.d.ts +32 -0
  271. package/dist/src/planner/mutation/scope-transform.d.ts.map +1 -1
  272. package/dist/src/planner/mutation/scope-transform.js +181 -33
  273. package/dist/src/planner/mutation/scope-transform.js.map +1 -1
  274. package/dist/src/planner/mutation/set-op.d.ts.map +1 -1
  275. package/dist/src/planner/mutation/set-op.js +66 -16
  276. package/dist/src/planner/mutation/set-op.js.map +1 -1
  277. package/dist/src/planner/mutation/single-source.d.ts.map +1 -1
  278. package/dist/src/planner/mutation/single-source.js +100 -24
  279. package/dist/src/planner/mutation/single-source.js.map +1 -1
  280. package/dist/src/planner/nodes/add-constraint-node.d.ts +15 -1
  281. package/dist/src/planner/nodes/add-constraint-node.d.ts.map +1 -1
  282. package/dist/src/planner/nodes/add-constraint-node.js +10 -1
  283. package/dist/src/planner/nodes/add-constraint-node.js.map +1 -1
  284. package/dist/src/planner/nodes/aggregate-node.d.ts +15 -0
  285. package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
  286. package/dist/src/planner/nodes/aggregate-node.js +32 -17
  287. package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
  288. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  289. package/dist/src/planner/nodes/alias-node.js +2 -1
  290. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  291. package/dist/src/planner/nodes/alter-table-node.d.ts +51 -10
  292. package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
  293. package/dist/src/planner/nodes/alter-table-node.js +49 -2
  294. package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
  295. package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
  296. package/dist/src/planner/nodes/asof-scan-node.js +4 -1
  297. package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
  298. package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
  299. package/dist/src/planner/nodes/asserted-keys-node.js +2 -1
  300. package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
  301. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  302. package/dist/src/planner/nodes/bloom-join-node.js +8 -3
  303. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  304. package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
  305. package/dist/src/planner/nodes/cache-node.js +2 -1
  306. package/dist/src/planner/nodes/cache-node.js.map +1 -1
  307. package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
  308. package/dist/src/planner/nodes/constraint-check-node.js +17 -19
  309. package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
  310. package/dist/src/planner/nodes/create-assertion-node.d.ts +2 -1
  311. package/dist/src/planner/nodes/create-assertion-node.d.ts.map +1 -1
  312. package/dist/src/planner/nodes/create-assertion-node.js +5 -2
  313. package/dist/src/planner/nodes/create-assertion-node.js.map +1 -1
  314. package/dist/src/planner/nodes/cte-node.d.ts +19 -9
  315. package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
  316. package/dist/src/planner/nodes/cte-node.js +25 -9
  317. package/dist/src/planner/nodes/cte-node.js.map +1 -1
  318. package/dist/src/planner/nodes/delete-node.d.ts +20 -2
  319. package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
  320. package/dist/src/planner/nodes/delete-node.js +11 -2
  321. package/dist/src/planner/nodes/delete-node.js.map +1 -1
  322. package/dist/src/planner/nodes/distinct-node.d.ts +6 -0
  323. package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
  324. package/dist/src/planner/nodes/distinct-node.js +10 -2
  325. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  326. package/dist/src/planner/nodes/dml-executor-node.d.ts +58 -1
  327. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  328. package/dist/src/planner/nodes/dml-executor-node.js +107 -15
  329. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  330. package/dist/src/planner/nodes/drop-assertion-node.d.ts +2 -1
  331. package/dist/src/planner/nodes/drop-assertion-node.d.ts.map +1 -1
  332. package/dist/src/planner/nodes/drop-assertion-node.js +5 -2
  333. package/dist/src/planner/nodes/drop-assertion-node.js.map +1 -1
  334. package/dist/src/planner/nodes/eager-prefetch-node.d.ts.map +1 -1
  335. package/dist/src/planner/nodes/eager-prefetch-node.js +2 -1
  336. package/dist/src/planner/nodes/eager-prefetch-node.js.map +1 -1
  337. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts +5 -0
  338. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
  339. package/dist/src/planner/nodes/fanout-lookup-join-node.js +13 -6
  340. package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
  341. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  342. package/dist/src/planner/nodes/filter.js +18 -5
  343. package/dist/src/planner/nodes/filter.js.map +1 -1
  344. package/dist/src/planner/nodes/hash-aggregate.d.ts +1 -0
  345. package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
  346. package/dist/src/planner/nodes/hash-aggregate.js +21 -16
  347. package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
  348. package/dist/src/planner/nodes/insert-node.d.ts +19 -2
  349. package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
  350. package/dist/src/planner/nodes/insert-node.js +10 -2
  351. package/dist/src/planner/nodes/insert-node.js.map +1 -1
  352. package/dist/src/planner/nodes/join-node.d.ts +20 -1
  353. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  354. package/dist/src/planner/nodes/join-node.js +30 -9
  355. package/dist/src/planner/nodes/join-node.js.map +1 -1
  356. package/dist/src/planner/nodes/join-utils.d.ts +21 -0
  357. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  358. package/dist/src/planner/nodes/join-utils.js +26 -0
  359. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  360. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +42 -10
  361. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -1
  362. package/dist/src/planner/nodes/key-set-semi-join-node.js +90 -17
  363. package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -1
  364. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts +5 -0
  365. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
  366. package/dist/src/planner/nodes/lens-auxiliary-access-node.js +2 -1
  367. package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
  368. package/dist/src/planner/nodes/limit-offset.d.ts +6 -0
  369. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  370. package/dist/src/planner/nodes/limit-offset.js +10 -2
  371. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  372. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  373. package/dist/src/planner/nodes/merge-join-node.js +8 -3
  374. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  375. package/dist/src/planner/nodes/ordinal-slice-node.d.ts +5 -0
  376. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
  377. package/dist/src/planner/nodes/ordinal-slice-node.js +9 -2
  378. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
  379. package/dist/src/planner/nodes/plan-node.d.ts +29 -0
  380. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  381. package/dist/src/planner/nodes/plan-node.js +12 -0
  382. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  383. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  384. package/dist/src/planner/nodes/project-node.js +18 -36
  385. package/dist/src/planner/nodes/project-node.js.map +1 -1
  386. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  387. package/dist/src/planner/nodes/reference.js +3 -2
  388. package/dist/src/planner/nodes/reference.js.map +1 -1
  389. package/dist/src/planner/nodes/retrieve-node.d.ts +16 -2
  390. package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
  391. package/dist/src/planner/nodes/retrieve-node.js +10 -2
  392. package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
  393. package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
  394. package/dist/src/planner/nodes/returning-node.js +13 -32
  395. package/dist/src/planner/nodes/returning-node.js.map +1 -1
  396. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  397. package/dist/src/planner/nodes/scalar.js +5 -18
  398. package/dist/src/planner/nodes/scalar.js.map +1 -1
  399. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  400. package/dist/src/planner/nodes/sort.js +3 -1
  401. package/dist/src/planner/nodes/sort.js.map +1 -1
  402. package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -0
  403. package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
  404. package/dist/src/planner/nodes/stream-aggregate.js +22 -20
  405. package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
  406. package/dist/src/planner/nodes/table-access-nodes.d.ts +89 -1
  407. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  408. package/dist/src/planner/nodes/table-access-nodes.js +69 -2
  409. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  410. package/dist/src/planner/nodes/update-node.d.ts +19 -2
  411. package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
  412. package/dist/src/planner/nodes/update-node.js +10 -2
  413. package/dist/src/planner/nodes/update-node.js.map +1 -1
  414. package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
  415. package/dist/src/planner/nodes/window-function.js +8 -0
  416. package/dist/src/planner/nodes/window-function.js.map +1 -1
  417. package/dist/src/planner/nodes/window-node.d.ts +1 -1
  418. package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
  419. package/dist/src/planner/nodes/window-node.js +3 -1
  420. package/dist/src/planner/nodes/window-node.js.map +1 -1
  421. package/dist/src/planner/optimizer.d.ts +27 -1
  422. package/dist/src/planner/optimizer.d.ts.map +1 -1
  423. package/dist/src/planner/optimizer.js +130 -10
  424. package/dist/src/planner/optimizer.js.map +1 -1
  425. package/dist/src/planner/planning-context.d.ts +24 -0
  426. package/dist/src/planner/planning-context.d.ts.map +1 -1
  427. package/dist/src/planner/planning-context.js.map +1 -1
  428. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +78 -20
  429. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
  430. package/dist/src/planner/rules/access/rule-key-set-seek.js +296 -135
  431. package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
  432. package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
  433. package/dist/src/planner/rules/access/rule-monotonic-range-access.js +2 -2
  434. package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
  435. package/dist/src/planner/rules/access/rule-select-access-path.d.ts +30 -1
  436. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  437. package/dist/src/planner/rules/access/rule-select-access-path.js +70 -5
  438. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  439. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts +7 -4
  440. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -1
  441. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +39 -5
  442. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -1
  443. package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
  444. package/dist/src/planner/rules/cache/rule-cte-optimization.js +15 -2
  445. package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
  446. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +10 -3
  447. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
  448. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
  449. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +6 -4
  450. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
  451. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +5 -31
  452. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
  453. package/dist/src/planner/rules/join/equi-pair-extractor.js +4 -44
  454. package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
  455. package/dist/src/planner/rules/join/index-nested-loop.d.ts +49 -0
  456. package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -0
  457. package/dist/src/planner/rules/join/index-nested-loop.js +291 -0
  458. package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -0
  459. package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +8 -8
  460. package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts +4 -0
  461. package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
  462. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +50 -15
  463. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
  464. package/dist/src/planner/rules/join/rule-join-elimination.d.ts +6 -0
  465. package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -1
  466. package/dist/src/planner/rules/join/rule-join-elimination.js +25 -9
  467. package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -1
  468. package/dist/src/planner/rules/join/rule-join-key-inference.d.ts +7 -0
  469. package/dist/src/planner/rules/join/rule-join-key-inference.d.ts.map +1 -1
  470. package/dist/src/planner/rules/join/rule-join-key-inference.js +23 -11
  471. package/dist/src/planner/rules/join/rule-join-key-inference.js.map +1 -1
  472. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +10 -4
  473. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  474. package/dist/src/planner/rules/join/rule-join-physical-selection.js +115 -29
  475. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  476. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts +2 -0
  477. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
  478. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +18 -4
  479. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
  480. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts +2 -2
  481. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -1
  482. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +19 -22
  483. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -1
  484. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts +21 -8
  485. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -1
  486. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +70 -14
  487. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -1
  488. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +56 -17
  489. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
  490. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +103 -154
  491. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
  492. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts +76 -0
  493. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts.map +1 -0
  494. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js +208 -0
  495. package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js.map +1 -0
  496. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +14 -11
  497. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -1
  498. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +21 -85
  499. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
  500. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +7 -1
  501. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -1
  502. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +18 -22
  503. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
  504. package/dist/src/planner/rules/shared/access-leaf.d.ts +52 -0
  505. package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -0
  506. package/dist/src/planner/rules/shared/access-leaf.js +95 -0
  507. package/dist/src/planner/rules/shared/access-leaf.js.map +1 -0
  508. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -1
  509. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +17 -7
  510. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -1
  511. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +3 -1
  512. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -1
  513. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +26 -9
  514. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
  515. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  516. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +69 -11
  517. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  518. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts +17 -7
  519. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
  520. package/dist/src/planner/rules/window/rule-monotonic-window.js +124 -87
  521. package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
  522. package/dist/src/planner/scopes/aliased.d.ts.map +1 -1
  523. package/dist/src/planner/scopes/aliased.js +6 -0
  524. package/dist/src/planner/scopes/aliased.js.map +1 -1
  525. package/dist/src/planner/stats/catalog-stats.d.ts +44 -13
  526. package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
  527. package/dist/src/planner/stats/catalog-stats.js +137 -61
  528. package/dist/src/planner/stats/catalog-stats.js.map +1 -1
  529. package/dist/src/planner/stats/conjunct-selectivity.d.ts +48 -0
  530. package/dist/src/planner/stats/conjunct-selectivity.d.ts.map +1 -0
  531. package/dist/src/planner/stats/conjunct-selectivity.js +168 -0
  532. package/dist/src/planner/stats/conjunct-selectivity.js.map +1 -0
  533. package/dist/src/planner/stats/index.d.ts +22 -3
  534. package/dist/src/planner/stats/index.d.ts.map +1 -1
  535. package/dist/src/planner/stats/index.js.map +1 -1
  536. package/dist/src/planner/stats/table-cardinality.d.ts +28 -0
  537. package/dist/src/planner/stats/table-cardinality.d.ts.map +1 -0
  538. package/dist/src/planner/stats/table-cardinality.js +29 -0
  539. package/dist/src/planner/stats/table-cardinality.js.map +1 -0
  540. package/dist/src/planner/stored-body-context.d.ts +57 -0
  541. package/dist/src/planner/stored-body-context.d.ts.map +1 -0
  542. package/dist/src/planner/stored-body-context.js +64 -0
  543. package/dist/src/planner/stored-body-context.js.map +1 -0
  544. package/dist/src/planner/util/column-origins.d.ts +29 -8
  545. package/dist/src/planner/util/column-origins.d.ts.map +1 -1
  546. package/dist/src/planner/util/column-origins.js +74 -14
  547. package/dist/src/planner/util/column-origins.js.map +1 -1
  548. package/dist/src/planner/util/fd-utils.d.ts +32 -8
  549. package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
  550. package/dist/src/planner/util/fd-utils.js +46 -9
  551. package/dist/src/planner/util/fd-utils.js.map +1 -1
  552. package/dist/src/planner/util/ind-utils.d.ts +66 -19
  553. package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
  554. package/dist/src/planner/util/ind-utils.js +91 -21
  555. package/dist/src/planner/util/ind-utils.js.map +1 -1
  556. package/dist/src/planner/util/key-utils.d.ts +36 -3
  557. package/dist/src/planner/util/key-utils.d.ts.map +1 -1
  558. package/dist/src/planner/util/key-utils.js +57 -7
  559. package/dist/src/planner/util/key-utils.js.map +1 -1
  560. package/dist/src/planner/util/output-names.d.ts +12 -0
  561. package/dist/src/planner/util/output-names.d.ts.map +1 -0
  562. package/dist/src/planner/util/output-names.js +20 -0
  563. package/dist/src/planner/util/output-names.js.map +1 -0
  564. package/dist/src/planner/util/row-estimates.d.ts +39 -0
  565. package/dist/src/planner/util/row-estimates.d.ts.map +1 -0
  566. package/dist/src/planner/util/row-estimates.js +68 -0
  567. package/dist/src/planner/util/row-estimates.js.map +1 -0
  568. package/dist/src/planner/util/row-population.d.ts +42 -0
  569. package/dist/src/planner/util/row-population.d.ts.map +1 -0
  570. package/dist/src/planner/util/row-population.js +71 -0
  571. package/dist/src/planner/util/row-population.js.map +1 -0
  572. package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
  573. package/dist/src/runtime/deferred-constraint-queue.js +3 -2
  574. package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
  575. package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
  576. package/dist/src/runtime/emit/add-constraint.js +60 -6
  577. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  578. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  579. package/dist/src/runtime/emit/aggregate.js +4 -4
  580. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  581. package/dist/src/runtime/emit/alter-schema-event.d.ts +97 -0
  582. package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -0
  583. package/dist/src/runtime/emit/alter-schema-event.js +87 -0
  584. package/dist/src/runtime/emit/alter-schema-event.js.map +1 -0
  585. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  586. package/dist/src/runtime/emit/alter-table.js +582 -236
  587. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  588. package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
  589. package/dist/src/runtime/emit/analyze.js +50 -7
  590. package/dist/src/runtime/emit/analyze.js.map +1 -1
  591. package/dist/src/runtime/emit/assertion-drop-guard.d.ts +37 -0
  592. package/dist/src/runtime/emit/assertion-drop-guard.d.ts.map +1 -0
  593. package/dist/src/runtime/emit/assertion-drop-guard.js +59 -0
  594. package/dist/src/runtime/emit/assertion-drop-guard.js.map +1 -0
  595. package/dist/src/runtime/emit/assertion-rename-helpers.d.ts +33 -0
  596. package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -0
  597. package/dist/src/runtime/emit/assertion-rename-helpers.js +124 -0
  598. package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -0
  599. package/dist/src/runtime/emit/cast.d.ts.map +1 -1
  600. package/dist/src/runtime/emit/cast.js +4 -19
  601. package/dist/src/runtime/emit/cast.js.map +1 -1
  602. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  603. package/dist/src/runtime/emit/constraint-check.js +10 -227
  604. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  605. package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
  606. package/dist/src/runtime/emit/create-assertion.js +31 -14
  607. package/dist/src/runtime/emit/create-assertion.js.map +1 -1
  608. package/dist/src/runtime/emit/cte.d.ts.map +1 -1
  609. package/dist/src/runtime/emit/cte.js +11 -6
  610. package/dist/src/runtime/emit/cte.js.map +1 -1
  611. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  612. package/dist/src/runtime/emit/dml-executor.js +233 -28
  613. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  614. package/dist/src/runtime/emit/drop-assertion.js +8 -8
  615. package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
  616. package/dist/src/runtime/emit/drop-column-guards.d.ts +151 -0
  617. package/dist/src/runtime/emit/drop-column-guards.d.ts.map +1 -0
  618. package/dist/src/runtime/emit/drop-column-guards.js +230 -0
  619. package/dist/src/runtime/emit/drop-column-guards.js.map +1 -0
  620. package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
  621. package/dist/src/runtime/emit/drop-index.js +4 -3
  622. package/dist/src/runtime/emit/drop-index.js.map +1 -1
  623. package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
  624. package/dist/src/runtime/emit/drop-table.js +6 -0
  625. package/dist/src/runtime/emit/drop-table.js.map +1 -1
  626. package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
  627. package/dist/src/runtime/emit/drop-view.js +4 -0
  628. package/dist/src/runtime/emit/drop-view.js.map +1 -1
  629. package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
  630. package/dist/src/runtime/emit/hash-aggregate.js +2 -2
  631. package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
  632. package/dist/src/runtime/emit/join.d.ts.map +1 -1
  633. package/dist/src/runtime/emit/join.js +8 -67
  634. package/dist/src/runtime/emit/join.js.map +1 -1
  635. package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -1
  636. package/dist/src/runtime/emit/key-set-semi-join.js +11 -3
  637. package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -1
  638. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +4 -4
  639. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  640. package/dist/src/runtime/emit/materialized-view-helpers.js +34 -22
  641. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  642. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
  643. package/dist/src/runtime/emit/materialized-view.js +7 -2
  644. package/dist/src/runtime/emit/materialized-view.js.map +1 -1
  645. package/dist/src/runtime/emit/operand-comparator.d.ts +30 -0
  646. package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -1
  647. package/dist/src/runtime/emit/operand-comparator.js +34 -0
  648. package/dist/src/runtime/emit/operand-comparator.js.map +1 -1
  649. package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
  650. package/dist/src/runtime/emit/recursive-cte.js +4 -5
  651. package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
  652. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  653. package/dist/src/runtime/emit/schema-declarative.js +30 -0
  654. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  655. package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
  656. package/dist/src/runtime/emit/subquery.js +153 -52
  657. package/dist/src/runtime/emit/subquery.js.map +1 -1
  658. package/dist/src/runtime/emit/update.d.ts.map +1 -1
  659. package/dist/src/runtime/emit/update.js +18 -6
  660. package/dist/src/runtime/emit/update.js.map +1 -1
  661. package/dist/src/runtime/emit/window.js +36 -23
  662. package/dist/src/runtime/emit/window.js.map +1 -1
  663. package/dist/src/runtime/row-constraints.d.ts +85 -0
  664. package/dist/src/runtime/row-constraints.d.ts.map +1 -0
  665. package/dist/src/runtime/row-constraints.js +239 -0
  666. package/dist/src/runtime/row-constraints.js.map +1 -0
  667. package/dist/src/runtime/types.d.ts +8 -11
  668. package/dist/src/runtime/types.d.ts.map +1 -1
  669. package/dist/src/runtime/types.js.map +1 -1
  670. package/dist/src/schema/assertion.d.ts +14 -1
  671. package/dist/src/schema/assertion.d.ts.map +1 -1
  672. package/dist/src/schema/assertion.js +14 -1
  673. package/dist/src/schema/assertion.js.map +1 -1
  674. package/dist/src/schema/catalog-persistability.d.ts +19 -16
  675. package/dist/src/schema/catalog-persistability.d.ts.map +1 -1
  676. package/dist/src/schema/catalog-persistability.js +92 -20
  677. package/dist/src/schema/catalog-persistability.js.map +1 -1
  678. package/dist/src/schema/catalog.d.ts +73 -2
  679. package/dist/src/schema/catalog.d.ts.map +1 -1
  680. package/dist/src/schema/catalog.js +220 -39
  681. package/dist/src/schema/catalog.js.map +1 -1
  682. package/dist/src/schema/column-source-resolver.d.ts +18 -0
  683. package/dist/src/schema/column-source-resolver.d.ts.map +1 -0
  684. package/dist/src/schema/column-source-resolver.js +22 -0
  685. package/dist/src/schema/column-source-resolver.js.map +1 -0
  686. package/dist/src/schema/column.d.ts +26 -3
  687. package/dist/src/schema/column.d.ts.map +1 -1
  688. package/dist/src/schema/column.js.map +1 -1
  689. package/dist/src/schema/constraint-builder.d.ts.map +1 -1
  690. package/dist/src/schema/constraint-builder.js +7 -1
  691. package/dist/src/schema/constraint-builder.js.map +1 -1
  692. package/dist/src/schema/ddl-generator.d.ts.map +1 -1
  693. package/dist/src/schema/ddl-generator.js +27 -6
  694. package/dist/src/schema/ddl-generator.js.map +1 -1
  695. package/dist/src/schema/function.d.ts +32 -1
  696. package/dist/src/schema/function.d.ts.map +1 -1
  697. package/dist/src/schema/function.js +10 -2
  698. package/dist/src/schema/function.js.map +1 -1
  699. package/dist/src/schema/lens-compiler.d.ts.map +1 -1
  700. package/dist/src/schema/lens-compiler.js +203 -51
  701. package/dist/src/schema/lens-compiler.js.map +1 -1
  702. package/dist/src/schema/lens-prover.d.ts +2 -3
  703. package/dist/src/schema/lens-prover.d.ts.map +1 -1
  704. package/dist/src/schema/lens-prover.js +19 -11
  705. package/dist/src/schema/lens-prover.js.map +1 -1
  706. package/dist/src/schema/manager.d.ts +115 -20
  707. package/dist/src/schema/manager.d.ts.map +1 -1
  708. package/dist/src/schema/manager.js +202 -70
  709. package/dist/src/schema/manager.js.map +1 -1
  710. package/dist/src/schema/rename-rewriter.d.ts +142 -0
  711. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  712. package/dist/src/schema/rename-rewriter.js +254 -9
  713. package/dist/src/schema/rename-rewriter.js.map +1 -1
  714. package/dist/src/schema/reserved-tags.d.ts +1 -1
  715. package/dist/src/schema/reserved-tags.d.ts.map +1 -1
  716. package/dist/src/schema/reserved-tags.js +4 -3
  717. package/dist/src/schema/reserved-tags.js.map +1 -1
  718. package/dist/src/schema/schema-differ.d.ts +16 -0
  719. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  720. package/dist/src/schema/schema-differ.js +225 -38
  721. package/dist/src/schema/schema-differ.js.map +1 -1
  722. package/dist/src/schema/table.d.ts +149 -1
  723. package/dist/src/schema/table.d.ts.map +1 -1
  724. package/dist/src/schema/table.js +248 -1
  725. package/dist/src/schema/table.js.map +1 -1
  726. package/dist/src/schema/unique-enforcement.d.ts +5 -3
  727. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  728. package/dist/src/schema/unique-enforcement.js +5 -3
  729. package/dist/src/schema/unique-enforcement.js.map +1 -1
  730. package/dist/src/schema/view.d.ts +11 -0
  731. package/dist/src/schema/view.d.ts.map +1 -1
  732. package/dist/src/schema/view.js +12 -0
  733. package/dist/src/schema/view.js.map +1 -1
  734. package/dist/src/types/builtin-types.d.ts +54 -0
  735. package/dist/src/types/builtin-types.d.ts.map +1 -1
  736. package/dist/src/types/builtin-types.js +123 -34
  737. package/dist/src/types/builtin-types.js.map +1 -1
  738. package/dist/src/types/cast-semantics.d.ts +42 -0
  739. package/dist/src/types/cast-semantics.d.ts.map +1 -1
  740. package/dist/src/types/cast-semantics.js +64 -0
  741. package/dist/src/types/cast-semantics.js.map +1 -1
  742. package/dist/src/types/comparison-coercion.d.ts +101 -0
  743. package/dist/src/types/comparison-coercion.d.ts.map +1 -0
  744. package/dist/src/types/comparison-coercion.js +162 -0
  745. package/dist/src/types/comparison-coercion.js.map +1 -0
  746. package/dist/src/types/index.d.ts +2 -2
  747. package/dist/src/types/index.d.ts.map +1 -1
  748. package/dist/src/types/index.js +2 -2
  749. package/dist/src/types/index.js.map +1 -1
  750. package/dist/src/types/logical-type.d.ts +7 -0
  751. package/dist/src/types/logical-type.d.ts.map +1 -1
  752. package/dist/src/types/logical-type.js.map +1 -1
  753. package/dist/src/types/validation.d.ts +56 -0
  754. package/dist/src/types/validation.d.ts.map +1 -1
  755. package/dist/src/types/validation.js +68 -0
  756. package/dist/src/types/validation.js.map +1 -1
  757. package/dist/src/util/{working-table-iterable.d.ts → array-row-iterable.d.ts} +6 -6
  758. package/dist/src/util/array-row-iterable.d.ts.map +1 -0
  759. package/dist/src/util/{working-table-iterable.js → array-row-iterable.js} +6 -6
  760. package/dist/src/util/array-row-iterable.js.map +1 -0
  761. package/dist/src/util/coercion.d.ts +8 -0
  762. package/dist/src/util/coercion.d.ts.map +1 -1
  763. package/dist/src/util/coercion.js +8 -0
  764. package/dist/src/util/coercion.js.map +1 -1
  765. package/dist/src/util/comparison.d.ts +16 -3
  766. package/dist/src/util/comparison.d.ts.map +1 -1
  767. package/dist/src/util/comparison.js +21 -5
  768. package/dist/src/util/comparison.js.map +1 -1
  769. package/dist/src/util/key-serializer.d.ts +46 -0
  770. package/dist/src/util/key-serializer.d.ts.map +1 -1
  771. package/dist/src/util/key-serializer.js +47 -0
  772. package/dist/src/util/key-serializer.js.map +1 -1
  773. package/dist/src/util/value-set.d.ts +21 -0
  774. package/dist/src/util/value-set.d.ts.map +1 -0
  775. package/dist/src/util/value-set.js +22 -0
  776. package/dist/src/util/value-set.js.map +1 -0
  777. package/dist/src/vtab/capabilities.d.ts +1 -1
  778. package/dist/src/vtab/events.d.ts +8 -1
  779. package/dist/src/vtab/events.d.ts.map +1 -1
  780. package/dist/src/vtab/events.js.map +1 -1
  781. package/dist/src/vtab/manifest.d.ts +15 -0
  782. package/dist/src/vtab/manifest.d.ts.map +1 -1
  783. package/dist/src/vtab/memory/layer/alter-column.d.ts +147 -0
  784. package/dist/src/vtab/memory/layer/alter-column.d.ts.map +1 -0
  785. package/dist/src/vtab/memory/layer/alter-column.js +214 -0
  786. package/dist/src/vtab/memory/layer/alter-column.js.map +1 -0
  787. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  788. package/dist/src/vtab/memory/layer/base.js +4 -3
  789. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  790. package/dist/src/vtab/memory/layer/interface.d.ts +2 -2
  791. package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
  792. package/dist/src/vtab/memory/layer/manager.d.ts +176 -25
  793. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  794. package/dist/src/vtab/memory/layer/manager.js +569 -558
  795. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  796. package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
  797. package/dist/src/vtab/memory/layer/scan-layer.js +32 -5
  798. package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
  799. package/dist/src/vtab/memory/layer/transaction.d.ts +101 -15
  800. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  801. package/dist/src/vtab/memory/layer/transaction.js +133 -45
  802. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  803. package/dist/src/vtab/memory/module.d.ts +16 -1
  804. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  805. package/dist/src/vtab/memory/module.js +64 -3
  806. package/dist/src/vtab/memory/module.js.map +1 -1
  807. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  808. package/dist/src/vtab/memory/table.js +11 -6
  809. package/dist/src/vtab/memory/table.js.map +1 -1
  810. package/dist/src/vtab/module.d.ts +77 -23
  811. package/dist/src/vtab/module.d.ts.map +1 -1
  812. package/dist/src/vtab/table.d.ts +9 -2
  813. package/dist/src/vtab/table.d.ts.map +1 -1
  814. package/dist/src/vtab/table.js +1 -1
  815. package/dist/src/vtab/table.js.map +1 -1
  816. package/package.json +3 -3
  817. package/dist/src/util/working-table-iterable.d.ts.map +0 -1
  818. package/dist/src/util/working-table-iterable.js.map +0 -1
@@ -6,17 +6,43 @@ import { StatusCode } from '../../common/types.js';
6
6
  import { PlanNode } from '../nodes/plan-node.js';
7
7
  import { buildExpression } from './expression.js';
8
8
  import { buildRowDefaultScope } from './default-scope.js';
9
- import { validateDeterministicDefault } from '../validation/determinism-validator.js';
9
+ import { validateDeterministicDefault, validateDeterministicGenerated } from '../validation/determinism-validator.js';
10
10
  import { tryFoldLiteral } from '../../parser/utils.js';
11
11
  import { inferType } from '../../types/registry.js';
12
12
  import { columnSchemaToScalarType } from '../type-utils.js';
13
- import { expressionToString } from '../../emit/ast-stringify.js';
13
+ import { astToString, expressionToString } from '../../emit/ast-stringify.js';
14
14
  import { validateReservedTags } from '../../schema/reserved-tags.js';
15
+ import { validateAddColumnGeneratedRefs } from '../../schema/table.js';
15
16
  import { columnTagDiagnostics, raiseStmtTagDiagnostics } from './tag-diagnostics.js';
16
17
  import { planViewBody } from './create-view.js';
18
+ import { schemaAuthoredContext } from './schema-authored-context.js';
17
19
  export function buildAlterTableStmt(ctx, stmt) {
18
20
  const tableRetrieve = buildTableReference({ type: 'table', table: stmt.table }, ctx);
19
21
  const tableReference = tableRetrieve.tableRef; // Extract the actual TableReferenceNode
22
+ // Canonical, fully-qualified SQL for the whole statement, rendered ONCE here — the one
23
+ // place that holds the parsed action and the resolved table together. Rendered from a
24
+ // SYNTHETIC statement whose table identifier is rebuilt from the resolved TableSchema,
25
+ // not from `stmt.table` as the user wrote it: an unqualified `alter table orders …`
26
+ // must not become a statement a receiver resolves against a different default schema.
27
+ // Same qualification rule as `generateTableDDL` / the schema differ's synthetic ALTER
28
+ // (schema-differ.ts), so the two wire sources agree. The runtime arms thread it to the
29
+ // module (`SchemaChangeInfo.ddl` / `renameTable`'s `ddl`) and onto the public
30
+ // schema-change event.
31
+ //
32
+ // NOTE: rendered for EVERY arm, including the four that never announce anything (the tag
33
+ // arms, `set`/`drop maintained`) — `set maintained as <select>` therefore stringifies its
34
+ // whole SELECT body for a string nobody reads. Free today: ALTER is not a hot path and
35
+ // each statement builds once. If those arms ever start carrying a rendering cost that
36
+ // matters, render lazily and hand the arms a thunk instead of a string.
37
+ const { schemaName, name: tableName } = tableReference.tableSchema;
38
+ const canonicalStmt = {
39
+ type: 'alterTable',
40
+ table: schemaName.toLowerCase() === 'main'
41
+ ? { type: 'identifier', name: tableName }
42
+ : { type: 'identifier', name: tableName, schema: schemaName },
43
+ action: stmt.action,
44
+ };
45
+ const sql = astToString(canonicalStmt);
20
46
  switch (stmt.action.type) {
21
47
  case 'addConstraint': {
22
48
  // Reject a typo'd / mis-sited reserved `quereus.*` tag on the constraint at
@@ -29,19 +55,19 @@ export function buildAlterTableStmt(ctx, stmt) {
29
55
  ...stmt.action.constraint,
30
56
  operations
31
57
  };
32
- return new AddConstraintNode(ctx.scope, tableReference, constraintWithBitmask);
58
+ return new AddConstraintNode(ctx.scope, tableReference, constraintWithBitmask, sql);
33
59
  }
34
60
  case 'renameTable':
35
61
  return new AlterTableNode(ctx.scope, tableReference, {
36
62
  type: 'renameTable',
37
63
  newName: stmt.action.newName,
38
- });
64
+ }, sql);
39
65
  case 'renameColumn':
40
66
  return new AlterTableNode(ctx.scope, tableReference, {
41
67
  type: 'renameColumn',
42
68
  oldName: stmt.action.oldName,
43
69
  newName: stmt.action.newName,
44
- });
70
+ }, sql);
45
71
  case 'addColumn': {
46
72
  const column = stmt.action.column;
47
73
  // Reject a typo'd / mis-sited reserved `quereus.*` tag on the new column or any
@@ -53,7 +79,10 @@ export function buildAlterTableStmt(ctx, stmt) {
53
79
  // columns / non-determinism rejected; `new.<column>` accepted with its build
54
80
  // deferred). This runs before building the backfill so a bare-column default
55
81
  // is rejected here rather than silently resolving against the existing columns
56
- // the backfill scope exposes.
82
+ // the backfill scope exposes. DEFAULT only: a GENERATED ALWAYS AS expression is
83
+ // written with bare column references by definition, so this validator would
84
+ // reject every legal one. Its determinism is checked inside
85
+ // `buildAddColumnBackfill` instead, with the generated-flavoured validator.
57
86
  const defaultConstraint = column.constraints?.find(c => c.type === 'default');
58
87
  if (defaultConstraint?.expr) {
59
88
  const hasMutationContext = !!tableReference.tableSchema.mutationContext
@@ -61,41 +90,42 @@ export function buildAlterTableStmt(ctx, stmt) {
61
90
  ctx.schemaManager.validateAddColumnDefault(defaultConstraint.expr, column.name, tableReference.tableSchema.name, hasMutationContext);
62
91
  }
63
92
  const backfill = buildAddColumnBackfill(ctx, tableReference, column);
64
- // For the per-row (evaluator) default path, enforce any CHECK on the new column
65
- // against each backfilled row by compiling the predicates here and evaluating them
66
- // inside the per-row backfill hook (mirrors the NOT NULL per-row path) — a violating
67
- // row aborts the ALTER before any tree/batch swap. The literal-default path is left to
68
- // the post-backfill scan (`validateBackfillAgainstChecks`), so checks are only
69
- // compiled when a backfill is present.
93
+ // For the per-row (evaluator) path — a non-foldable DEFAULT or a GENERATED ALWAYS AS
94
+ // expression — enforce any CHECK on the new column against each backfilled row by
95
+ // compiling the predicates here and evaluating them inside the per-row backfill hook
96
+ // (mirrors the NOT NULL per-row path) — a violating row aborts the ALTER before any
97
+ // tree/batch swap. The literal-default path is left to the post-backfill scan
98
+ // (`validateBackfillAgainstChecks`), so checks are only compiled when a backfill is
99
+ // present.
70
100
  const checks = backfill ? buildAddColumnChecks(ctx, tableReference, column) : undefined;
71
101
  return new AlterTableNode(ctx.scope, tableReference, {
72
102
  type: 'addColumn',
73
103
  column,
74
104
  backfill,
75
105
  checks,
76
- });
106
+ }, sql);
77
107
  }
78
108
  case 'dropColumn':
79
109
  return new AlterTableNode(ctx.scope, tableReference, {
80
110
  type: 'dropColumn',
81
111
  name: stmt.action.name,
82
- });
112
+ }, sql);
83
113
  case 'dropConstraint':
84
114
  return new AlterTableNode(ctx.scope, tableReference, {
85
115
  type: 'dropConstraint',
86
116
  name: stmt.action.name,
87
- });
117
+ }, sql);
88
118
  case 'renameConstraint':
89
119
  return new AlterTableNode(ctx.scope, tableReference, {
90
120
  type: 'renameConstraint',
91
121
  oldName: stmt.action.oldName,
92
122
  newName: stmt.action.newName,
93
- });
123
+ }, sql);
94
124
  case 'alterPrimaryKey':
95
125
  return new AlterTableNode(ctx.scope, tableReference, {
96
126
  type: 'alterPrimaryKey',
97
127
  columns: stmt.action.columns,
98
- });
128
+ }, sql);
99
129
  case 'alterColumn':
100
130
  return new AlterTableNode(ctx.scope, tableReference, {
101
131
  type: 'alterColumn',
@@ -104,7 +134,7 @@ export function buildAlterTableStmt(ctx, stmt) {
104
134
  setDataType: stmt.action.setDataType,
105
135
  setDefault: stmt.action.setDefault,
106
136
  setCollation: stmt.action.setCollation,
107
- });
137
+ }, sql);
108
138
  case 'setTags': {
109
139
  // Validate any reserved `quereus.*` tags at the matching site so a typo
110
140
  // (e.g. `quereus.expose_implicit_indx`) fails loudly here rather than being
@@ -122,7 +152,7 @@ export function buildAlterTableStmt(ctx, stmt) {
122
152
  target,
123
153
  mode: stmt.action.mode,
124
154
  tags: stmt.action.tags,
125
- });
155
+ }, sql);
126
156
  }
127
157
  case 'dropTags': {
128
158
  // DROP TAGS removes tags by key, so there is NO reserved-tag value
@@ -133,7 +163,7 @@ export function buildAlterTableStmt(ctx, stmt) {
133
163
  type: 'dropTags',
134
164
  target: stmt.action.target,
135
165
  keys: stmt.action.keys,
136
- });
166
+ }, sql);
137
167
  }
138
168
  case 'setMaintained': {
139
169
  // SET MAINTAINED AS <body> — attach / re-attach a derivation. Reuse the
@@ -146,7 +176,9 @@ export function buildAlterTableStmt(ctx, stmt) {
146
176
  // reshape-on-attach (attachMaintainedDerivation), so a build-time arity
147
177
  // gate would block legitimate reshapes.
148
178
  const tableSchema = tableReference.tableSchema;
149
- planViewBody(ctx, tableSchema.name, stmt.action.select);
179
+ // Home-schema body path: the derivation's unqualified source names must
180
+ // resolve next to the table the derivation attaches to.
181
+ planViewBody(ctx, tableSchema.name, stmt.action.select, tableSchema.schemaName);
150
182
  // Mirror the create-form gate: a generated column would silently diverge
151
183
  // from its expression once the body supplies every column's value.
152
184
  const generated = tableSchema.columns.find(c => c.generated);
@@ -163,12 +195,12 @@ export function buildAlterTableStmt(ctx, stmt) {
163
195
  type: 'setMaintained',
164
196
  columns: stmt.action.columns,
165
197
  select: stmt.action.select,
166
- });
198
+ }, sql);
167
199
  }
168
200
  case 'dropMaintained':
169
201
  // Maintained-ness is checked in the emitter against the LIVE table (the
170
202
  // build-time schema may be a cached statement's snapshot).
171
- return new AlterTableNode(ctx.scope, tableReference, { type: 'dropMaintained' });
203
+ return new AlterTableNode(ctx.scope, tableReference, { type: 'dropMaintained' }, sql);
172
204
  default:
173
205
  throw new QuereusError(
174
206
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -176,26 +208,43 @@ export function buildAlterTableStmt(ctx, stmt) {
176
208
  }
177
209
  }
178
210
  /**
179
- * Compile the per-row backfill of an ADD COLUMN whose DEFAULT does not fold to a
180
- * literal (e.g. `new.<col>`). Mirrors the single-source INSERT row-expansion and the
181
- * view-write key default: the default is built against the table's *existing* columns
182
- * as the "supplied" row, so `new.<col>` resolves to the existing row's sibling during
183
- * backfill. Returns `undefined` for a missing or literal-folding default (the module
184
- * bulk-writes those), so the common case allocates nothing.
211
+ * Compile the per-row backfill of an ADD COLUMN that carries a per-row value source:
212
+ * a DEFAULT that does not fold to a literal (e.g. `new.<col>`), or a GENERATED ALWAYS
213
+ * AS expression (whatever its VIRTUAL / STORED spelling — this engine materializes a
214
+ * generated value at write time either way). Mirrors the single-source INSERT
215
+ * row-expansion and the view-write key default: the expression is built against the
216
+ * table's *existing* columns as the "supplied" row, so both `new.<col>` and the bare
217
+ * `<col>` a generated expression uses resolve to the existing row's sibling during
218
+ * backfill. Returns `undefined` when the column carries neither, or for a
219
+ * literal-folding DEFAULT (the module bulk-writes that from the column's
220
+ * `defaultValue`), so the common case allocates nothing.
185
221
  */
186
222
  function buildAddColumnBackfill(ctx, tableReference, columnDef) {
223
+ // A column declares a DEFAULT or a GENERATED ALWAYS AS, never both —
224
+ // `columnDefToSchema` rejects the pair — so at most one arm applies.
225
+ const generatedExpr = columnDef.constraints?.find(c => c.type === 'generated')?.generated?.expr;
187
226
  const defaultExpr = columnDef.constraints?.find(c => c.type === 'default')?.expr;
188
- if (!defaultExpr)
227
+ const sourceExpr = generatedExpr ?? defaultExpr;
228
+ if (!sourceExpr)
189
229
  return undefined;
190
- // Literal / NULL defaults fold and are bulk-written by the module — no per-row node.
191
- if (tryFoldLiteral(defaultExpr) !== undefined)
230
+ // Literal / NULL DEFAULTs fold and are bulk-written by the module — no per-row node.
231
+ // Deliberately NOT taken on the generated arm: a generated column has no
232
+ // `defaultValue` for the module to bulk-write, so short-circuiting a constant
233
+ // generated expression (`generated always as (2)`) would leave every existing row
234
+ // NULL. The generated arm always builds the per-row node.
235
+ if (!generatedExpr && tryFoldLiteral(sourceExpr) !== undefined)
192
236
  return undefined;
193
237
  const tableSchema = tableReference.tableSchema;
194
- // Fresh attributes for the existing columns, referenced only by this default's
195
- // `new.<col>` column refs and resolved at runtime via the row slot the emitter
196
- // installs over each existing row. Minting fresh (rather than reusing the table
197
- // reference's attributes) keeps the node self-contained so the optimizer can't
198
- // dangle it.
238
+ // Report a bad generated expression the way CREATE TABLE reports it, before the
239
+ // compile below turns an unresolvable (or self-referencing) name into a generic
240
+ // "Column not found".
241
+ if (generatedExpr) {
242
+ validateAddColumnGeneratedRefs(generatedExpr, columnDef.name, tableSchema.columns, tableSchema.name);
243
+ }
244
+ // Fresh attributes for the existing columns, referenced only by this expression's
245
+ // column refs and resolved at runtime via the row slot the emitter installs over
246
+ // each existing row. Minting fresh (rather than reusing the table reference's
247
+ // attributes) keeps the node self-contained so the optimizer can't dangle it.
199
248
  const rowAttrs = tableSchema.columns.map(column => ({
200
249
  id: PlanNode.nextAttrId(),
201
250
  name: column.name,
@@ -203,17 +252,38 @@ function buildAddColumnBackfill(ctx, tableReference, columnDef) {
203
252
  sourceRelation: 'add-column-backfill',
204
253
  }));
205
254
  const rowScope = buildRowDefaultScope(ctx.scope, tableSchema.columns, rowAttrs);
206
- const node = buildExpression({ ...ctx, scope: rowScope }, defaultExpr);
255
+ // Schema-authored SQL, wrapped exactly as the three DML builders wrap theirs, so the
256
+ // backfill expression resolves bare relation names against the altered table's own
257
+ // schema — not whatever path the ALTER runs on. The CTE half of the wrapper is inert
258
+ // here (ALTER is not an `AST.QueryExpr`, so it can neither be a CTE body nor carry a
259
+ // `with` clause of its own); the schema-path half is the load-bearing part.
260
+ const node = buildExpression({ ...schemaAuthoredContext(ctx, tableSchema.schemaName), scope: rowScope }, sourceExpr);
261
+ // Same validator each arm's write-path build site uses, so an ALTER accepts exactly
262
+ // what the equivalent CREATE TABLE + INSERT accepts. Both honour
263
+ // `nondeterministic_schema`, so the escape hatch is unchanged.
207
264
  if (!ctx.db.options.getBooleanOption('nondeterministic_schema')) {
208
- validateDeterministicDefault(node, columnDef.name, tableSchema.name);
265
+ if (generatedExpr) {
266
+ validateDeterministicGenerated(node, columnDef.name, tableSchema.name);
267
+ }
268
+ else {
269
+ validateDeterministicDefault(node, columnDef.name, tableSchema.name);
270
+ }
209
271
  }
210
272
  const rowDescriptor = [];
211
273
  rowAttrs.forEach((attr, index) => { rowDescriptor[attr.id] = index; });
212
- return { node, rowDescriptor };
274
+ // The evaluated value has to reach storage in the new column's declared form, exactly as an
275
+ // INSERT's would. Skip the conversion when the expression's static type already IS that type
276
+ // (identity comparison — the registry hands out one shared LogicalType instance per type),
277
+ // mirroring `buildRowCoercion`: re-converting an already-converted value is destructive for
278
+ // JSON. See `AddColumnBackfill.coerceTo`.
279
+ const newColumnType = inferType(columnDef.dataType);
280
+ const coerceTo = node.getType().logicalType === newColumnType ? undefined : newColumnType;
281
+ return { node, rowDescriptor, coerceTo };
213
282
  }
214
283
  /**
215
- * Compile the column-level CHECK predicates of an ADD COLUMN whose DEFAULT does not fold
216
- * to a literal, so they can be enforced per backfilled row inside the backfill hook. Each
284
+ * Compile the column-level CHECK predicates of an ADD COLUMN that backfills per row (a
285
+ * non-foldable DEFAULT or a GENERATED ALWAYS AS expression), so they can be enforced per
286
+ * backfilled row inside the backfill hook. Each
217
287
  * predicate is built against a row scope covering the table's *existing* columns plus the
218
288
  * *new* column, so a CHECK referencing the new column (bare `<col>` or `new.<col>`) and any
219
289
  * existing sibling resolves. The new column sits at position `existingColumns.length` in the
@@ -256,8 +326,12 @@ function buildAddColumnChecks(ctx, tableReference, columnDef) {
256
326
  const rowAttrs = [...existingAttrs, newColAttr];
257
327
  const targetColumns = [...tableSchema.columns, { name: columnDef.name }];
258
328
  const rowScope = buildRowDefaultScope(ctx.scope, targetColumns, rowAttrs);
329
+ // Schema-authored, same as the backfill expression above and as every CHECK the DML
330
+ // builders compile: a bare relation name means the ALTERED table's own schema, not
331
+ // whatever path the ALTER runs on.
332
+ const checkCtx = { ...schemaAuthoredContext(ctx, tableSchema.schemaName), scope: rowScope };
259
333
  const predicates = checkConstraints.map(con => ({
260
- node: buildExpression({ ...ctx, scope: rowScope }, con.expr),
334
+ node: buildExpression(checkCtx, con.expr),
261
335
  name: con.name,
262
336
  exprText: expressionToString(con.expr),
263
337
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"alter-table.js","sourceRoot":"","sources":["../../../../src/planner/building/alter-table.ts"],"names":[],"mappings":"AAEA,OAAO,EAA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ACpF,mFAAmF;IACnF,mCAAmC;IACnC,MAAM,QAAQ,GAAG,EAAE,GAAG,qBAAqB,CAAC,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5F,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAK,CAAmB;QAC5D,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,QAAQ,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAK,CAAC;KACxC,CAAC,CAAC,CAAC;IAEJ,MAAM,aAAa,GAAkB,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AACvC,CAAC"}
@@ -8,62 +8,33 @@ import type { ScalarPlanNode } from '../nodes/plan-node.js';
8
8
  * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}) —
9
9
  * reconciles its operands through this one module so none of them can drift
10
10
  * from the others.
11
+ *
12
+ * This file owns only the *rewrite*: which operand gets wrapped in a synthetic
13
+ * `CastNode`. The decision of which operand converts and to what lives in
14
+ * `types/comparison-coercion.ts`, shared with the emit-time consumer
15
+ * (`runtime/emit/operand-comparator.ts` `makeComparisonGroup`) that serves the
16
+ * builtins which return one of their arguments and so cannot be rewritten here.
11
17
  */
12
18
  /**
13
19
  * Reconcile operands of a comparison whose plan-time types cannot be compared
14
20
  * meaningfully as-is, by wrapping one side in a synthetic CastNode.
15
21
  * Returns `[left, right]` — possibly with one side replaced by a CastNode.
16
22
  *
17
- * Two pairings are handled, in this order:
18
- *
19
- * 1. **Object-physical vs anything else.** JSON is the engine's only logical type
20
- * whose `physicalType` is `PhysicalType.OBJECT`: its runtime values are native
21
- * JS objects/arrays, which `compareSqlValuesFast` short-circuits against any
22
- * other storage class — so `json_col = '{"a":1}'` was unconditionally false,
23
- * even for byte-identical text. The non-object side is cast to the object
24
- * side's type, never the reverse: casting the JSON side to text would make
25
- * equality depend on spelling and put `=` out of step with the index, which
26
- * compares structurally.
27
- *
28
- * The gate is deliberately `physicalType === OBJECT`, **not**
29
- * `semanticOrdering`. DATE/TIME/DATETIME/TIMESPAN also carry semantic ordering
30
- * but are physically text, and the runtime's `tryTemporalComparison` already
31
- * reconciles them; routing them through a cast would change behavior for no
32
- * gain.
33
- *
34
- * A cast to JSON is lenient (see `runtime/emit/cast.ts`): text that does not
35
- * parse comes back unchanged, so `json_col = 'not json'` is false rather than
36
- * an error. Note the consequence for JSON *string scalars*, which are stored
37
- * as plain JS strings: a column holding `"hello"` matches BOTH the SQL literal
38
- * `'"hello"'` (parses to the JSON string `hello`) and the bare `'hello'` (does
39
- * not parse, falls back to the raw string `hello`, which `JSON_TYPE.compare`
40
- * then compares as text). Only the first form generalizes — `'[1,2]'` matches
41
- * the JSON array while a bare `[1,2]` is not SQL text at all.
42
- *
43
- * 2. **Numeric vs textual.** The textual operand is cast to the numeric side's
44
- * type name (e.g. 'INTEGER' or 'REAL') so the runtime can take the fast path.
23
+ * See {@link crossTypeCoercion} for the rule (object-physical vs anything else,
24
+ * then numeric vs textual) and why each side is chosen.
45
25
  */
46
26
  export declare function insertCrossTypeCoercion(scope: Scope, left: ScalarPlanNode, right: ScalarPlanNode): [ScalarPlanNode, ScalarPlanNode];
47
27
  /**
48
- * Apply the object-physical arm of {@link insertCrossTypeCoercion} across the
49
- * one-probe-against-many-values shape shared by an IN value list and a simple
50
- * CASE, so `json_col in ('{"a":1}')` and `case json_col when '{"a":1}' …` agree
51
- * with `json_col = '{"a":1}'`.
52
- *
53
- * Scoped to the object-physical pairing on purpose. The numeric ↔ textual arm has
54
- * never been applied to either site (`int_col in ('1')` is false today for the same
55
- * underlying reason), and turning it on here would change unrelated behavior; that
56
- * case is tracked by `bug-numeric-text-coercion-skips-in-and-case`. Note `=` and
57
- * BETWEEN DO apply it, so those two forms currently disagree with IN / simple CASE
58
- * on a numeric column compared against a numeric-looking string.
59
- *
60
- * The probe is shared by every value, so it is wrapped at most once — if any value
61
- * is object-physical while the probe is not, the probe is cast first and the values
62
- * are then reconciled against it.
28
+ * Apply {@link comparisonGroupCoercions} across the one-probe-against-many-values
29
+ * shape shared by an IN value list, a simple CASE and a scalar builtin's
30
+ * comparison group, so `json_col in ('{"a":1}')`, `int_col in ('1')` and
31
+ * `case int_col when '1' …` all agree with the `=` spelling of the same
32
+ * comparison. See that function for the probe-vs-value asymmetry and the one
33
+ * documented gap it leaves.
63
34
  */
64
- export declare function coerceObjectPhysicalSet(scope: Scope, probe: ScalarPlanNode, values: ScalarPlanNode[]): [ScalarPlanNode, ScalarPlanNode[]];
35
+ export declare function coerceComparisonSet(scope: Scope, probe: ScalarPlanNode, values: ScalarPlanNode[]): [ScalarPlanNode, ScalarPlanNode[]];
65
36
  /**
66
- * Apply {@link coerceObjectPhysicalSet} across the argument positions a scalar
37
+ * Apply {@link coerceComparisonSet} across the argument positions a scalar
67
38
  * function declares as one comparison group
68
39
  * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}),
69
40
  * so `nullif(json_col, '{"a":1}')` reconciles its operands exactly as
@@ -71,6 +42,11 @@ export declare function coerceObjectPhysicalSet(scope: Scope, probe: ScalarPlanN
71
42
  * the rest the value-list role; positions outside the argument list are ignored
72
43
  * (defensive — a well-formed declaration never names one). Mutates `args` in
73
44
  * place, replacing coerced members with their CastNode wrappers.
45
+ *
46
+ * NOT for a function that returns one of its arguments verbatim
47
+ * ({@link import('../../schema/function.js').BaseFunctionSchema.returnsArg}):
48
+ * replacing the argument replaces the *returned value* too. Those go through
49
+ * `makeComparisonGroup` at emit time instead.
74
50
  */
75
51
  export declare function coerceComparisonGroup(scope: Scope, comparesArgs: 'all' | readonly number[], args: ScalarPlanNode[]): void;
76
52
  /** Create a synthetic CastNode wrapping `operand` with the given target type name. */
@@ -1 +1 @@
1
- {"version":3,"file":"coercion.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,cAAc,GACnB,CAAC,cAAc,EAAE,cAAc,CAAC,CAmClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,cAAc,EAAE,GACtB,CAAC,cAAc,EAAE,cAAc,EAAE,CAAC,CAWpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,KAAK,GAAG,SAAS,MAAM,EAAE,EACvC,IAAI,EAAE,cAAc,EAAE,GACpB,IAAI,CAUN;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CACzB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,GAChB,QAAQ,CAQV"}
1
+ {"version":3,"file":"coercion.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAA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