@quereus/quereus 4.10.0 → 4.12.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 (457) hide show
  1. package/dist/src/common/type-inference.d.ts +12 -6
  2. package/dist/src/common/type-inference.d.ts.map +1 -1
  3. package/dist/src/common/type-inference.js +12 -24
  4. package/dist/src/common/type-inference.js.map +1 -1
  5. package/dist/src/core/database-assertions.d.ts.map +1 -1
  6. package/dist/src/core/database-assertions.js +7 -5
  7. package/dist/src/core/database-assertions.js.map +1 -1
  8. package/dist/src/core/database-events.d.ts +4 -3
  9. package/dist/src/core/database-events.d.ts.map +1 -1
  10. package/dist/src/core/database-events.js +4 -3
  11. package/dist/src/core/database-events.js.map +1 -1
  12. package/dist/src/core/database-materialized-views-analysis.d.ts +1 -3
  13. package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
  14. package/dist/src/core/database-materialized-views-analysis.js +1 -11
  15. package/dist/src/core/database-materialized-views-analysis.js.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 +12 -10
  18. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
  19. package/dist/src/core/database.d.ts.map +1 -1
  20. package/dist/src/core/database.js +13 -2
  21. package/dist/src/core/database.js.map +1 -1
  22. package/dist/src/core/derived-row-validator.d.ts.map +1 -1
  23. package/dist/src/core/derived-row-validator.js +14 -2
  24. package/dist/src/core/derived-row-validator.js.map +1 -1
  25. package/dist/src/core/param.d.ts +9 -0
  26. package/dist/src/core/param.d.ts.map +1 -1
  27. package/dist/src/core/param.js +21 -1
  28. package/dist/src/core/param.js.map +1 -1
  29. package/dist/src/core/statement.d.ts.map +1 -1
  30. package/dist/src/core/statement.js +38 -15
  31. package/dist/src/core/statement.js.map +1 -1
  32. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  33. package/dist/src/func/builtins/aggregate.js +7 -2
  34. package/dist/src/func/builtins/aggregate.js.map +1 -1
  35. package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
  36. package/dist/src/func/builtins/builtin-window-functions.js +27 -11
  37. package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
  38. package/dist/src/func/builtins/datetime.d.ts.map +1 -1
  39. package/dist/src/func/builtins/datetime.js +8 -3
  40. package/dist/src/func/builtins/datetime.js.map +1 -1
  41. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  42. package/dist/src/func/builtins/explain.js +9 -29
  43. package/dist/src/func/builtins/explain.js.map +1 -1
  44. package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
  45. package/dist/src/func/builtins/json-tvf.js +14 -7
  46. package/dist/src/func/builtins/json-tvf.js.map +1 -1
  47. package/dist/src/func/builtins/return-types.d.ts +29 -0
  48. package/dist/src/func/builtins/return-types.d.ts.map +1 -1
  49. package/dist/src/func/builtins/return-types.js +4 -1
  50. package/dist/src/func/builtins/return-types.js.map +1 -1
  51. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  52. package/dist/src/func/builtins/scalar.js +22 -67
  53. package/dist/src/func/builtins/scalar.js.map +1 -1
  54. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  55. package/dist/src/func/builtins/schema.js +26 -16
  56. package/dist/src/func/builtins/schema.js.map +1 -1
  57. package/dist/src/index.d.ts +1 -1
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/index.js +6 -1
  60. package/dist/src/index.js.map +1 -1
  61. package/dist/src/parser/parser.d.ts.map +1 -1
  62. package/dist/src/parser/parser.js +5 -3
  63. package/dist/src/parser/parser.js.map +1 -1
  64. package/dist/src/parser/visitor.d.ts +16 -0
  65. package/dist/src/parser/visitor.d.ts.map +1 -1
  66. package/dist/src/parser/visitor.js +16 -0
  67. package/dist/src/parser/visitor.js.map +1 -1
  68. package/dist/src/planner/analysis/assertion-plan.d.ts +33 -0
  69. package/dist/src/planner/analysis/assertion-plan.d.ts.map +1 -0
  70. package/dist/src/planner/analysis/assertion-plan.js +39 -0
  71. package/dist/src/planner/analysis/assertion-plan.js.map +1 -0
  72. package/dist/src/planner/analysis/binary-operator-class.d.ts +55 -0
  73. package/dist/src/planner/analysis/binary-operator-class.d.ts.map +1 -0
  74. package/dist/src/planner/analysis/binary-operator-class.js +57 -0
  75. package/dist/src/planner/analysis/binary-operator-class.js.map +1 -0
  76. package/dist/src/planner/analysis/binding-extractor.d.ts +9 -3
  77. package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -1
  78. package/dist/src/planner/analysis/binding-extractor.js +11 -16
  79. package/dist/src/planner/analysis/binding-extractor.js.map +1 -1
  80. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
  81. package/dist/src/planner/analysis/change-scope.js +19 -6
  82. package/dist/src/planner/analysis/change-scope.js.map +1 -1
  83. package/dist/src/planner/analysis/check-extraction.d.ts +1 -7
  84. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
  85. package/dist/src/planner/analysis/check-extraction.js.map +1 -1
  86. package/dist/src/planner/analysis/comparison-collation.d.ts +17 -0
  87. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
  88. package/dist/src/planner/analysis/comparison-collation.js +17 -5
  89. package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
  90. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  91. package/dist/src/planner/analysis/constraint-extractor.js +18 -18
  92. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  93. package/dist/src/planner/analysis/coverage-prover.d.ts +11 -7
  94. package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
  95. package/dist/src/planner/analysis/coverage-prover.js +11 -7
  96. package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
  97. package/dist/src/planner/analysis/equi-correlation.d.ts +1 -1
  98. package/dist/src/planner/analysis/equi-correlation.js +1 -1
  99. package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
  100. package/dist/src/planner/analysis/expression-fingerprint.js +0 -2
  101. package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
  102. package/dist/src/planner/analysis/key-filter.d.ts.map +1 -1
  103. package/dist/src/planner/analysis/key-filter.js +2 -3
  104. package/dist/src/planner/analysis/key-filter.js.map +1 -1
  105. package/dist/src/planner/analysis/relation-key.d.ts +104 -0
  106. package/dist/src/planner/analysis/relation-key.d.ts.map +1 -0
  107. package/dist/src/planner/analysis/relation-key.js +121 -0
  108. package/dist/src/planner/analysis/relation-key.js.map +1 -0
  109. package/dist/src/planner/analysis/scalar-param-usage.d.ts.map +1 -1
  110. package/dist/src/planner/analysis/scalar-param-usage.js +12 -4
  111. package/dist/src/planner/analysis/scalar-param-usage.js.map +1 -1
  112. package/dist/src/planner/analysis/set-op-type-merge.d.ts +9 -3
  113. package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -1
  114. package/dist/src/planner/analysis/set-op-type-merge.js +22 -8
  115. package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -1
  116. package/dist/src/planner/building/alter-table.d.ts.map +1 -1
  117. package/dist/src/planner/building/alter-table.js +31 -23
  118. package/dist/src/planner/building/alter-table.js.map +1 -1
  119. package/dist/src/planner/building/analyze.d.ts.map +1 -1
  120. package/dist/src/planner/building/analyze.js +21 -0
  121. package/dist/src/planner/building/analyze.js.map +1 -1
  122. package/dist/src/planner/building/block.d.ts.map +1 -1
  123. package/dist/src/planner/building/block.js +222 -82
  124. package/dist/src/planner/building/block.js.map +1 -1
  125. package/dist/src/planner/building/constraint-builder.d.ts +3 -2
  126. package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
  127. package/dist/src/planner/building/constraint-builder.js +20 -27
  128. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  129. package/dist/src/planner/building/delete.d.ts.map +1 -1
  130. package/dist/src/planner/building/delete.js +8 -25
  131. package/dist/src/planner/building/delete.js.map +1 -1
  132. package/dist/src/planner/building/expression.d.ts.map +1 -1
  133. package/dist/src/planner/building/expression.js +11 -3
  134. package/dist/src/planner/building/expression.js.map +1 -1
  135. package/dist/src/planner/building/foreign-key-builder.d.ts +19 -8
  136. package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
  137. package/dist/src/planner/building/foreign-key-builder.js +56 -37
  138. package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
  139. package/dist/src/planner/building/generated-column-scope.d.ts +58 -0
  140. package/dist/src/planner/building/generated-column-scope.d.ts.map +1 -0
  141. package/dist/src/planner/building/generated-column-scope.js +117 -0
  142. package/dist/src/planner/building/generated-column-scope.js.map +1 -0
  143. package/dist/src/planner/building/insert.d.ts.map +1 -1
  144. package/dist/src/planner/building/insert.js +36 -60
  145. package/dist/src/planner/building/insert.js.map +1 -1
  146. package/dist/src/planner/building/mutation-context.d.ts +63 -0
  147. package/dist/src/planner/building/mutation-context.d.ts.map +1 -0
  148. package/dist/src/planner/building/mutation-context.js +126 -0
  149. package/dist/src/planner/building/mutation-context.js.map +1 -0
  150. package/dist/src/planner/building/select-aggregates.d.ts +73 -132
  151. package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
  152. package/dist/src/planner/building/select-aggregates.js +405 -81
  153. package/dist/src/planner/building/select-aggregates.js.map +1 -1
  154. package/dist/src/planner/building/select-modifiers.d.ts +37 -8
  155. package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
  156. package/dist/src/planner/building/select-modifiers.js +8 -9
  157. package/dist/src/planner/building/select-modifiers.js.map +1 -1
  158. package/dist/src/planner/building/select-ordinal.d.ts +6 -0
  159. package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
  160. package/dist/src/planner/building/select-ordinal.js +1 -1
  161. package/dist/src/planner/building/select-ordinal.js.map +1 -1
  162. package/dist/src/planner/building/select-window.d.ts +2 -2
  163. package/dist/src/planner/building/select-window.d.ts.map +1 -1
  164. package/dist/src/planner/building/select-window.js +82 -101
  165. package/dist/src/planner/building/select-window.js.map +1 -1
  166. package/dist/src/planner/building/select.d.ts.map +1 -1
  167. package/dist/src/planner/building/select.js +78 -33
  168. package/dist/src/planner/building/select.js.map +1 -1
  169. package/dist/src/planner/building/update.d.ts.map +1 -1
  170. package/dist/src/planner/building/update.js +21 -32
  171. package/dist/src/planner/building/update.js.map +1 -1
  172. package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
  173. package/dist/src/planner/building/view-mutation-builder.js +329 -14
  174. package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
  175. package/dist/src/planner/building/with.d.ts +6 -0
  176. package/dist/src/planner/building/with.d.ts.map +1 -1
  177. package/dist/src/planner/building/with.js +52 -3
  178. package/dist/src/planner/building/with.js.map +1 -1
  179. package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
  180. package/dist/src/planner/cache/correlation-detector.js +44 -17
  181. package/dist/src/planner/cache/correlation-detector.js.map +1 -1
  182. package/dist/src/planner/framework/physical-utils.d.ts +6 -0
  183. package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
  184. package/dist/src/planner/framework/physical-utils.js +6 -0
  185. package/dist/src/planner/framework/physical-utils.js.map +1 -1
  186. package/dist/src/planner/mutation/lens-enforcement.d.ts +123 -0
  187. package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
  188. package/dist/src/planner/mutation/lens-enforcement.js +362 -5
  189. package/dist/src/planner/mutation/lens-enforcement.js.map +1 -1
  190. package/dist/src/planner/mutation/mutation-diagnostic.d.ts +1 -1
  191. package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -1
  192. package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -1
  193. package/dist/src/planner/nodes/alter-table-node.d.ts +15 -11
  194. package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
  195. package/dist/src/planner/nodes/alter-table-node.js +5 -0
  196. package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
  197. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  198. package/dist/src/planner/nodes/bloom-join-node.js +7 -0
  199. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  200. package/dist/src/planner/nodes/constraint-check-node.d.ts +16 -0
  201. package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
  202. package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
  203. package/dist/src/planner/nodes/plan-node-type.d.ts +1 -1
  204. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  205. package/dist/src/planner/nodes/plan-node-type.js +1 -1
  206. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  207. package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
  208. package/dist/src/planner/nodes/pragma.js +5 -2
  209. package/dist/src/planner/nodes/pragma.js.map +1 -1
  210. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  211. package/dist/src/planner/nodes/reference.js +9 -1
  212. package/dist/src/planner/nodes/reference.js.map +1 -1
  213. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  214. package/dist/src/planner/nodes/scalar.js +117 -91
  215. package/dist/src/planner/nodes/scalar.js.map +1 -1
  216. package/dist/src/planner/nodes/sequence-node.d.ts +50 -0
  217. package/dist/src/planner/nodes/sequence-node.d.ts.map +1 -0
  218. package/dist/src/planner/nodes/sequence-node.js +96 -0
  219. package/dist/src/planner/nodes/sequence-node.js.map +1 -0
  220. package/dist/src/planner/nodes/values-node.d.ts +8 -0
  221. package/dist/src/planner/nodes/values-node.d.ts.map +1 -1
  222. package/dist/src/planner/nodes/values-node.js +29 -6
  223. package/dist/src/planner/nodes/values-node.js.map +1 -1
  224. package/dist/src/planner/nodes/view-mutation-node.d.ts +43 -1
  225. package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
  226. package/dist/src/planner/nodes/view-mutation-node.js +27 -6
  227. package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
  228. package/dist/src/planner/nodes/window-node.d.ts +33 -4
  229. package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
  230. package/dist/src/planner/nodes/window-node.js +80 -36
  231. package/dist/src/planner/nodes/window-node.js.map +1 -1
  232. package/dist/src/planner/planning-context.d.ts +38 -1
  233. package/dist/src/planner/planning-context.d.ts.map +1 -1
  234. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
  235. package/dist/src/planner/rules/access/rule-key-set-seek.js +8 -3
  236. package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
  237. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +18 -12
  238. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
  239. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +4 -3
  240. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  241. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
  242. package/dist/src/planner/rules/window/rule-monotonic-window.js +6 -0
  243. package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
  244. package/dist/src/planner/scopes/param.d.ts.map +1 -1
  245. package/dist/src/planner/scopes/param.js +10 -5
  246. package/dist/src/planner/scopes/param.js.map +1 -1
  247. package/dist/src/planner/util/ind-utils.d.ts +25 -8
  248. package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
  249. package/dist/src/planner/util/ind-utils.js +53 -10
  250. package/dist/src/planner/util/ind-utils.js.map +1 -1
  251. package/dist/src/planner/util/key-utils.d.ts +7 -7
  252. package/dist/src/planner/util/key-utils.js +9 -9
  253. package/dist/src/planner/util/key-utils.js.map +1 -1
  254. package/dist/src/runtime/delta-executor.d.ts.map +1 -1
  255. package/dist/src/runtime/delta-executor.js +7 -2
  256. package/dist/src/runtime/delta-executor.js.map +1 -1
  257. package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
  258. package/dist/src/runtime/emit/add-constraint.js +50 -15
  259. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  260. package/dist/src/runtime/emit/alter-schema-event.d.ts +2 -43
  261. package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -1
  262. package/dist/src/runtime/emit/alter-schema-event.js +2 -53
  263. package/dist/src/runtime/emit/alter-schema-event.js.map +1 -1
  264. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  265. package/dist/src/runtime/emit/alter-table.js +70 -26
  266. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  267. package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
  268. package/dist/src/runtime/emit/analyze.js +7 -0
  269. package/dist/src/runtime/emit/analyze.js.map +1 -1
  270. package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -1
  271. package/dist/src/runtime/emit/assertion-rename-helpers.js +2 -3
  272. package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -1
  273. package/dist/src/runtime/emit/binary.d.ts +5 -0
  274. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  275. package/dist/src/runtime/emit/binary.js +22 -22
  276. package/dist/src/runtime/emit/binary.js.map +1 -1
  277. package/dist/src/runtime/emit/block.d.ts.map +1 -1
  278. package/dist/src/runtime/emit/block.js +9 -3
  279. package/dist/src/runtime/emit/block.js.map +1 -1
  280. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  281. package/dist/src/runtime/emit/constraint-check.js +22 -13
  282. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  283. package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
  284. package/dist/src/runtime/emit/create-assertion.js +71 -70
  285. package/dist/src/runtime/emit/create-assertion.js.map +1 -1
  286. package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
  287. package/dist/src/runtime/emit/create-index.js +8 -3
  288. package/dist/src/runtime/emit/create-index.js.map +1 -1
  289. package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
  290. package/dist/src/runtime/emit/create-table.js +20 -10
  291. package/dist/src/runtime/emit/create-table.js.map +1 -1
  292. package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
  293. package/dist/src/runtime/emit/create-view.js +51 -44
  294. package/dist/src/runtime/emit/create-view.js.map +1 -1
  295. package/dist/src/runtime/emit/ddl-event-scope.d.ts +71 -0
  296. package/dist/src/runtime/emit/ddl-event-scope.d.ts.map +1 -0
  297. package/dist/src/runtime/emit/ddl-event-scope.js +80 -0
  298. package/dist/src/runtime/emit/ddl-event-scope.js.map +1 -0
  299. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  300. package/dist/src/runtime/emit/dml-executor.js +28 -24
  301. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  302. package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
  303. package/dist/src/runtime/emit/drop-assertion.js +23 -17
  304. package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
  305. package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
  306. package/dist/src/runtime/emit/drop-index.js +7 -2
  307. package/dist/src/runtime/emit/drop-index.js.map +1 -1
  308. package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
  309. package/dist/src/runtime/emit/drop-table.js +16 -10
  310. package/dist/src/runtime/emit/drop-table.js.map +1 -1
  311. package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
  312. package/dist/src/runtime/emit/drop-view.js +50 -43
  313. package/dist/src/runtime/emit/drop-view.js.map +1 -1
  314. package/dist/src/runtime/emit/insert.d.ts.map +1 -1
  315. package/dist/src/runtime/emit/insert.js +2 -1
  316. package/dist/src/runtime/emit/insert.js.map +1 -1
  317. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
  318. package/dist/src/runtime/emit/materialized-view.js +87 -67
  319. package/dist/src/runtime/emit/materialized-view.js.map +1 -1
  320. package/dist/src/runtime/emit/schema-declarative.d.ts +8 -0
  321. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  322. package/dist/src/runtime/emit/schema-declarative.js +128 -25
  323. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  324. package/dist/src/runtime/emit/sequence.d.ts +17 -0
  325. package/dist/src/runtime/emit/sequence.d.ts.map +1 -0
  326. package/dist/src/runtime/emit/sequence.js +40 -0
  327. package/dist/src/runtime/emit/sequence.js.map +1 -0
  328. package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
  329. package/dist/src/runtime/emit/set-object-tags.js +40 -32
  330. package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
  331. package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
  332. package/dist/src/runtime/emit/table-valued-function.js +3 -2
  333. package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
  334. package/dist/src/runtime/emit/update.js +3 -3
  335. package/dist/src/runtime/emit/update.js.map +1 -1
  336. package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
  337. package/dist/src/runtime/emit/view-mutation.js +45 -3
  338. package/dist/src/runtime/emit/view-mutation.js.map +1 -1
  339. package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
  340. package/dist/src/runtime/foreign-key-actions.js +9 -10
  341. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  342. package/dist/src/runtime/register.d.ts.map +1 -1
  343. package/dist/src/runtime/register.js +3 -2
  344. package/dist/src/runtime/register.js.map +1 -1
  345. package/dist/src/runtime/row-constraints.d.ts +14 -8
  346. package/dist/src/runtime/row-constraints.d.ts.map +1 -1
  347. package/dist/src/runtime/row-constraints.js +41 -15
  348. package/dist/src/runtime/row-constraints.js.map +1 -1
  349. package/dist/src/runtime/strict-representation.d.ts +11 -6
  350. package/dist/src/runtime/strict-representation.d.ts.map +1 -1
  351. package/dist/src/runtime/strict-representation.js +1 -44
  352. package/dist/src/runtime/strict-representation.js.map +1 -1
  353. package/dist/src/schema/assertion.d.ts +25 -2
  354. package/dist/src/schema/assertion.d.ts.map +1 -1
  355. package/dist/src/schema/assertion.js.map +1 -1
  356. package/dist/src/schema/catalog-rendering.d.ts +38 -0
  357. package/dist/src/schema/catalog-rendering.d.ts.map +1 -0
  358. package/dist/src/schema/catalog-rendering.js +171 -0
  359. package/dist/src/schema/catalog-rendering.js.map +1 -0
  360. package/dist/src/schema/catalog.d.ts +94 -5
  361. package/dist/src/schema/catalog.d.ts.map +1 -1
  362. package/dist/src/schema/catalog.js +159 -21
  363. package/dist/src/schema/catalog.js.map +1 -1
  364. package/dist/src/schema/column-source-resolver.d.ts +9 -5
  365. package/dist/src/schema/column-source-resolver.d.ts.map +1 -1
  366. package/dist/src/schema/column-source-resolver.js +9 -5
  367. package/dist/src/schema/column-source-resolver.js.map +1 -1
  368. package/dist/src/schema/constraint-builder.d.ts +23 -7
  369. package/dist/src/schema/constraint-builder.d.ts.map +1 -1
  370. package/dist/src/schema/constraint-builder.js +60 -16
  371. package/dist/src/schema/constraint-builder.js.map +1 -1
  372. package/dist/src/schema/declared-schema-manager.d.ts +50 -0
  373. package/dist/src/schema/declared-schema-manager.d.ts.map +1 -1
  374. package/dist/src/schema/declared-schema-manager.js +52 -0
  375. package/dist/src/schema/declared-schema-manager.js.map +1 -1
  376. package/dist/src/schema/expr-scope/frame.d.ts +65 -0
  377. package/dist/src/schema/expr-scope/frame.d.ts.map +1 -0
  378. package/dist/src/schema/expr-scope/frame.js +104 -0
  379. package/dist/src/schema/expr-scope/frame.js.map +1 -0
  380. package/dist/src/schema/expr-scope/walk.d.ts +40 -0
  381. package/dist/src/schema/expr-scope/walk.d.ts.map +1 -0
  382. package/dist/src/schema/expr-scope/walk.js +260 -0
  383. package/dist/src/schema/expr-scope/walk.js.map +1 -0
  384. package/dist/src/schema/generated-column-refs.d.ts +41 -0
  385. package/dist/src/schema/generated-column-refs.d.ts.map +1 -0
  386. package/dist/src/schema/generated-column-refs.js +124 -0
  387. package/dist/src/schema/generated-column-refs.js.map +1 -0
  388. package/dist/src/schema/lens-ack.d.ts.map +1 -1
  389. package/dist/src/schema/lens-ack.js +5 -2
  390. package/dist/src/schema/lens-ack.js.map +1 -1
  391. package/dist/src/schema/lens-compiler.d.ts.map +1 -1
  392. package/dist/src/schema/lens-compiler.js +9 -1
  393. package/dist/src/schema/lens-compiler.js.map +1 -1
  394. package/dist/src/schema/lens-prover.d.ts +7 -2
  395. package/dist/src/schema/lens-prover.d.ts.map +1 -1
  396. package/dist/src/schema/lens-prover.js +105 -11
  397. package/dist/src/schema/lens-prover.js.map +1 -1
  398. package/dist/src/schema/lens.d.ts +12 -0
  399. package/dist/src/schema/lens.d.ts.map +1 -1
  400. package/dist/src/schema/lens.js +10 -0
  401. package/dist/src/schema/lens.js.map +1 -1
  402. package/dist/src/schema/manager.d.ts +48 -1
  403. package/dist/src/schema/manager.d.ts.map +1 -1
  404. package/dist/src/schema/manager.js +168 -36
  405. package/dist/src/schema/manager.js.map +1 -1
  406. package/dist/src/schema/rename/self-qualifier-strip.d.ts +16 -10
  407. package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -1
  408. package/dist/src/schema/rename/self-qualifier-strip.js +30 -213
  409. package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -1
  410. package/dist/src/schema/rename-rewriter.d.ts +4 -3
  411. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  412. package/dist/src/schema/rename-rewriter.js +4 -3
  413. package/dist/src/schema/rename-rewriter.js.map +1 -1
  414. package/dist/src/schema/schema-differ.d.ts +54 -6
  415. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  416. package/dist/src/schema/schema-differ.js +108 -42
  417. package/dist/src/schema/schema-differ.js.map +1 -1
  418. package/dist/src/schema/schema-hasher.d.ts +12 -0
  419. package/dist/src/schema/schema-hasher.d.ts.map +1 -1
  420. package/dist/src/schema/schema-hasher.js +28 -10
  421. package/dist/src/schema/schema-hasher.js.map +1 -1
  422. package/dist/src/schema/table.d.ts +117 -19
  423. package/dist/src/schema/table.d.ts.map +1 -1
  424. package/dist/src/schema/table.js +213 -71
  425. package/dist/src/schema/table.js.map +1 -1
  426. package/dist/src/types/comparison-coercion.d.ts +5 -1
  427. package/dist/src/types/comparison-coercion.d.ts.map +1 -1
  428. package/dist/src/types/comparison-coercion.js +21 -5
  429. package/dist/src/types/comparison-coercion.js.map +1 -1
  430. package/dist/src/types/representation.d.ts +65 -0
  431. package/dist/src/types/representation.d.ts.map +1 -0
  432. package/dist/src/types/representation.js +63 -0
  433. package/dist/src/types/representation.js.map +1 -0
  434. package/dist/src/types/validation.d.ts +76 -22
  435. package/dist/src/types/validation.d.ts.map +1 -1
  436. package/dist/src/types/validation.js +110 -31
  437. package/dist/src/types/validation.js.map +1 -1
  438. package/dist/src/vtab/best-access-plan.d.ts +10 -0
  439. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  440. package/dist/src/vtab/best-access-plan.js +16 -0
  441. package/dist/src/vtab/best-access-plan.js.map +1 -1
  442. package/dist/src/vtab/capabilities.d.ts +72 -4
  443. package/dist/src/vtab/capabilities.d.ts.map +1 -1
  444. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  445. package/dist/src/vtab/memory/layer/manager.js +17 -13
  446. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  447. package/dist/src/vtab/module.d.ts +13 -7
  448. package/dist/src/vtab/module.d.ts.map +1 -1
  449. package/package.json +3 -3
  450. package/dist/src/planner/nodes/array-index-node.d.ts +0 -22
  451. package/dist/src/planner/nodes/array-index-node.d.ts.map +0 -1
  452. package/dist/src/planner/nodes/array-index-node.js +0 -41
  453. package/dist/src/planner/nodes/array-index-node.js.map +0 -1
  454. package/dist/src/runtime/emit/array-index.d.ts +0 -5
  455. package/dist/src/runtime/emit/array-index.d.ts.map +0 -1
  456. package/dist/src/runtime/emit/array-index.js +0 -22
  457. package/dist/src/runtime/emit/array-index.js.map +0 -1
@@ -1,5 +1,10 @@
1
1
  import { BlockNode } from '../nodes/block.js';
2
+ import { isRelationalNode } from '../nodes/plan-node.js';
2
3
  import { buildSelectStmt } from './select.js';
4
+ import { CTENode } from '../nodes/cte-node.js';
5
+ import { SequenceNode } from '../nodes/sequence-node.js';
6
+ import { SinkNode } from '../nodes/sink-node.js';
7
+ import { buildWithClause, isDataModifyingCte } from './with.js';
3
8
  import { buildCreateTableStmt } from './ddl.js';
4
9
  import { buildCreateIndexStmt } from './ddl.js';
5
10
  import { buildDropTableStmt } from './drop-table.js';
@@ -22,92 +27,227 @@ import { quereusError } from '../../common/errors.js';
22
27
  import { StatusCode } from '../../common/types.js';
23
28
  import { buildDeclareSchemaStmt, buildDeclareLensStmt, buildDiffSchemaStmt, buildApplySchemaStmt, buildExplainSchemaStmt } from './declare-schema.js';
24
29
  export function buildBlock(ctx, statements) {
30
+ // Mark these statements' own leading WITH clauses before anything is built: a
31
+ // data-modifying member is legal only there, and `buildWithClause` rejects one
32
+ // anywhere else (see its comment). Used for `attachUnreferencedDmlCtes` too — that
33
+ // rebuild goes through `buildWithClause` on the SAME clause object and must stay
34
+ // allowed.
35
+ //
36
+ // NOTE: accepted tradeoff — several analysis paths re-plan a STORED body as if it were a
37
+ // standalone top-level statement (`db._buildPlan([view.selectAst])` in
38
+ // `func/builtins/schema.ts`, `planner/analysis/assertion-plan.ts`,
39
+ // `core/database-materialized-views-plan-builders.ts`,
40
+ // `runtime/emit/materialized-view-helpers.ts`, `schema/lens-prover.ts`,
41
+ // `func/builtins/explain.ts`), so those calls mark the body's own clause top-level and a
42
+ // body that ALREADY contains a data-modifying member is still accepted there. A "this is
43
+ // a stored body" flag on `_buildPlan` was weighed and declined: the shape is unreachable
44
+ // for anything defined after this gate landed, so it needs a definition persisted by an
45
+ // older build (or hand-injected via `importCatalog`) — and on that path an ordinary READ
46
+ // of the object already rejects (the body plans nested) and write-through has its own
47
+ // `unsupported-body-cte-dml` guard, leaving only introspection, where succeeding is more
48
+ // useful than erroring. Revisit if a legacy definition is ever found to re-drive its write
49
+ // through one of those paths — the materialized-view refresh call is the one that would.
50
+ //
51
+ // NOTE: the gate is the marker, not the nesting site — nothing asserts that `buildBlock`
52
+ // is never re-entered on a NESTED statement. A future path that did so would mark that
53
+ // statement's clause top-level and open every nested position silently. `_buildPlan` is
54
+ // the only non-test caller today; keep it that way, or make the gate positive (a "this
55
+ // clause is owned" flag set by the statement builders) rather than by-omission.
56
+ const blockCtx = { ...ctx, topLevelWithClauses: collectTopLevelWithClauses(statements) };
25
57
  const plannedStatements = statements.map((stmt) => {
26
- switch (stmt.type) {
27
- case 'select':
28
- // buildSelectStmt returns a BatchNode, which is a PlanNode.
29
- return buildSelectStmt(ctx, stmt);
30
- case 'createTable':
31
- return buildCreateTableStmt(ctx, stmt);
32
- case 'createIndex':
33
- return buildCreateIndexStmt(ctx, stmt);
34
- case 'createView':
35
- return buildCreateViewStmt(ctx, stmt);
36
- case 'createMaterializedView':
37
- return buildCreateMaterializedViewStmt(ctx, stmt);
38
- case 'refreshMaterializedView':
39
- return buildRefreshMaterializedViewStmt(ctx, stmt);
40
- case 'createAssertion':
41
- return buildCreateAssertionStmt(ctx, stmt);
42
- case 'drop': {
43
- const dropStmt = stmt;
44
- if (dropStmt.objectType === 'table') {
45
- return buildDropTableStmt(ctx, dropStmt);
46
- }
47
- else if (dropStmt.objectType === 'view') {
48
- return buildDropViewStmt(ctx, dropStmt);
49
- }
50
- else if (dropStmt.objectType === 'materializedView') {
51
- return buildDropMaterializedViewStmt(ctx, dropStmt);
52
- }
53
- else if (dropStmt.objectType === 'assertion') {
54
- return buildDropAssertionStmt(ctx, dropStmt);
55
- }
56
- else if (dropStmt.objectType === 'index') {
57
- return buildDropIndexStmt(ctx, dropStmt);
58
- }
59
- else if (dropStmt.objectType === 'trigger') {
60
- quereusError(`DROP TRIGGER is not supported`, StatusCode.UNSUPPORTED, undefined, dropStmt);
61
- }
62
- break;
63
- }
64
- case 'insert':
65
- return buildInsertStmt(ctx, stmt);
66
- case 'update':
67
- return buildUpdateStmt(ctx, stmt);
68
- case 'delete':
69
- return buildDeleteStmt(ctx, stmt);
70
- case 'begin':
71
- return buildBeginStmt(ctx, stmt);
72
- case 'commit':
73
- return buildCommitStmt(ctx, stmt);
74
- case 'rollback':
75
- return buildRollbackStmt(ctx, stmt);
76
- case 'savepoint':
77
- return buildSavepointStmt(ctx, stmt);
78
- case 'release':
79
- return buildReleaseStmt(ctx, stmt);
80
- case 'pragma':
81
- return buildPragmaStmt(ctx, stmt);
82
- case 'analyze':
83
- return buildAnalyzeStmt(ctx, stmt);
84
- case 'alterTable':
85
- return buildAlterTableStmt(ctx, stmt);
86
- case 'alterView':
87
- return buildAlterViewStmt(ctx, stmt);
88
- case 'alterMaterializedView':
89
- return buildAlterMaterializedViewStmt(ctx, stmt);
90
- case 'alterIndex':
91
- return buildAlterIndexStmt(ctx, stmt);
92
- case 'values':
93
- return buildValuesStmt(ctx, stmt);
94
- case 'declareSchema':
95
- return buildDeclareSchemaStmt(ctx, stmt);
96
- case 'declareLens':
97
- return buildDeclareLensStmt(ctx, stmt);
98
- case 'diffSchema':
99
- return buildDiffSchemaStmt(ctx, stmt);
100
- case 'applySchema':
101
- return buildApplySchemaStmt(ctx, stmt);
102
- case 'explainSchema':
103
- return buildExplainSchemaStmt(ctx, stmt);
104
- default:
105
- // Throw an exception for unsupported statement types
106
- quereusError(`Unsupported statement type: ${stmt.type}`, StatusCode.UNSUPPORTED, undefined, stmt);
107
- }
58
+ const planned = buildStatement(blockCtx, stmt);
59
+ return planned === undefined ? undefined : attachUnreferencedDmlCtes(blockCtx, stmt, planned);
108
60
  }).filter(p => p !== undefined); // Ensure we only have valid PlanNodes and cast
109
61
  // The final BatchNode for the entire batch.
110
62
  // Its scope is batchParameterScope, and it contains all successfully planned statements.
111
63
  return new BlockNode(ctx.scope, plannedStatements, { ...ctx.parameters });
112
64
  }
65
+ /** The leading `with` clause of each statement in this block, by AST object identity. */
66
+ function collectTopLevelWithClauses(statements) {
67
+ const clauses = new Set();
68
+ for (const stmt of statements) {
69
+ const { withClause } = leadingClauses(stmt);
70
+ if (withClause)
71
+ clauses.add(withClause);
72
+ }
73
+ return clauses;
74
+ }
75
+ /**
76
+ * The leading `with` clause and `with schema` path a statement carries. Only the four
77
+ * query/DML forms can have either (`Parser.statementSupportsWithClause` attaches the
78
+ * clause to exactly those), so the narrowing is the union itself rather than a cast to
79
+ * a hand-written shape.
80
+ */
81
+ function leadingClauses(stmt) {
82
+ switch (stmt.type) {
83
+ case 'select':
84
+ case 'insert':
85
+ case 'update':
86
+ case 'delete':
87
+ return stmt;
88
+ default:
89
+ return {};
90
+ }
91
+ }
92
+ function buildStatement(ctx, stmt) {
93
+ switch (stmt.type) {
94
+ case 'select':
95
+ // buildSelectStmt returns a BatchNode, which is a PlanNode.
96
+ return buildSelectStmt(ctx, stmt);
97
+ case 'createTable':
98
+ return buildCreateTableStmt(ctx, stmt);
99
+ case 'createIndex':
100
+ return buildCreateIndexStmt(ctx, stmt);
101
+ case 'createView':
102
+ return buildCreateViewStmt(ctx, stmt);
103
+ case 'createMaterializedView':
104
+ return buildCreateMaterializedViewStmt(ctx, stmt);
105
+ case 'refreshMaterializedView':
106
+ return buildRefreshMaterializedViewStmt(ctx, stmt);
107
+ case 'createAssertion':
108
+ return buildCreateAssertionStmt(ctx, stmt);
109
+ case 'drop': {
110
+ const dropStmt = stmt;
111
+ if (dropStmt.objectType === 'table') {
112
+ return buildDropTableStmt(ctx, dropStmt);
113
+ }
114
+ else if (dropStmt.objectType === 'view') {
115
+ return buildDropViewStmt(ctx, dropStmt);
116
+ }
117
+ else if (dropStmt.objectType === 'materializedView') {
118
+ return buildDropMaterializedViewStmt(ctx, dropStmt);
119
+ }
120
+ else if (dropStmt.objectType === 'assertion') {
121
+ return buildDropAssertionStmt(ctx, dropStmt);
122
+ }
123
+ else if (dropStmt.objectType === 'index') {
124
+ return buildDropIndexStmt(ctx, dropStmt);
125
+ }
126
+ else if (dropStmt.objectType === 'trigger') {
127
+ quereusError(`DROP TRIGGER is not supported`, StatusCode.UNSUPPORTED, undefined, dropStmt);
128
+ }
129
+ break;
130
+ }
131
+ case 'insert':
132
+ return buildInsertStmt(ctx, stmt);
133
+ case 'update':
134
+ return buildUpdateStmt(ctx, stmt);
135
+ case 'delete':
136
+ return buildDeleteStmt(ctx, stmt);
137
+ case 'begin':
138
+ return buildBeginStmt(ctx, stmt);
139
+ case 'commit':
140
+ return buildCommitStmt(ctx, stmt);
141
+ case 'rollback':
142
+ return buildRollbackStmt(ctx, stmt);
143
+ case 'savepoint':
144
+ return buildSavepointStmt(ctx, stmt);
145
+ case 'release':
146
+ return buildReleaseStmt(ctx, stmt);
147
+ case 'pragma':
148
+ return buildPragmaStmt(ctx, stmt);
149
+ case 'analyze':
150
+ return buildAnalyzeStmt(ctx, stmt);
151
+ case 'alterTable':
152
+ return buildAlterTableStmt(ctx, stmt);
153
+ case 'alterView':
154
+ return buildAlterViewStmt(ctx, stmt);
155
+ case 'alterMaterializedView':
156
+ return buildAlterMaterializedViewStmt(ctx, stmt);
157
+ case 'alterIndex':
158
+ return buildAlterIndexStmt(ctx, stmt);
159
+ case 'values':
160
+ return buildValuesStmt(ctx, stmt);
161
+ case 'declareSchema':
162
+ return buildDeclareSchemaStmt(ctx, stmt);
163
+ case 'declareLens':
164
+ return buildDeclareLensStmt(ctx, stmt);
165
+ case 'diffSchema':
166
+ return buildDiffSchemaStmt(ctx, stmt);
167
+ case 'applySchema':
168
+ return buildApplySchemaStmt(ctx, stmt);
169
+ case 'explainSchema':
170
+ return buildExplainSchemaStmt(ctx, stmt);
171
+ default:
172
+ // Throw an exception for unsupported statement types
173
+ quereusError(`Unsupported statement type: ${stmt.type}`, StatusCode.UNSUPPORTED, undefined, stmt);
174
+ }
175
+ }
176
+ /**
177
+ * Guarantee the write of every data-modifying `with` member the statement never
178
+ * references. A member enters the plan only when something reads it, but an
179
+ * `insert`/`update`/`delete` member is a stated effect of the statement — SQLite
180
+ * and PostgreSQL both perform it whether or not anything reads the block.
181
+ *
182
+ * This is the ONE safe attachment site: `buildBlock` is the single entry for
183
+ * user statements (`Database._buildPlan` is its only caller), sees both the
184
+ * statement AST and the finished plan, and runs once per top-level statement.
185
+ * Every site inside the statement builders is re-entered by the view
186
+ * write-through path (and once per base member by a multi-source decomposition),
187
+ * so a per-builder attachment would fan the sink out N times. A `with` clause on
188
+ * a NESTED statement (a sub-select's own clause, a stored view body) is out of
189
+ * scope, and that boundary is now ENFORCED rather than merely unimplemented:
190
+ * `buildWithClause` rejects a data-modifying member in any clause `buildBlock`
191
+ * did not mark top-level (PostgreSQL rejects the same shapes), so no position
192
+ * exists where a write would go unowned.
193
+ *
194
+ * Mechanics: each member's runtime identity (`CTENode.tableDescriptor`) is
195
+ * memoized per source AST member for the whole statement build
196
+ * (`PlanningContext.cteDescriptors`), so a member whose descriptor is absent
197
+ * from the built plan is provably unreferenced. The clause is then rebuilt —
198
+ * required because a member may read an earlier sibling — and each unreferenced
199
+ * data-modifying member's node is Sink-wrapped and sequenced AHEAD of the
200
+ * statement (a trailing effect could be skipped by a main abandoned early, e.g.
201
+ * `limit 0`). The rebuild cannot double a referenced member's write: its rebuilt
202
+ * `CTENode` shares the referenced one's descriptor, hence its one buffer.
203
+ */
204
+ function attachUnreferencedDmlCtes(ctx, stmt, plan) {
205
+ const { withClause, schemaPath } = leadingClauses(stmt);
206
+ if (!withClause)
207
+ return plan;
208
+ const dmlMembers = withClause.ctes.filter(isDataModifyingCte);
209
+ if (dmlMembers.length === 0)
210
+ return plan;
211
+ const reachable = collectCteDescriptors(plan);
212
+ const unreferenced = dmlMembers.filter(cte => {
213
+ const descriptor = ctx.cteDescriptors.get(cte);
214
+ return descriptor !== undefined && !reachable.has(descriptor);
215
+ });
216
+ if (unreferenced.length === 0)
217
+ return plan;
218
+ // Rebuild the whole clause in order (a member may read an earlier sibling);
219
+ // the descriptor memo makes this safe — see the doc comment above. The
220
+ // statement's own WITH SCHEMA path applies to its clause, so mirror the
221
+ // statement builders' `contextWithSchemaPath`.
222
+ const rebuildCtx = schemaPath ? { ...ctx, schemaPath } : ctx;
223
+ const rebuilt = buildWithClause(rebuildCtx, withClause);
224
+ const sinks = unreferenced.map(cte => {
225
+ const node = rebuilt.get(cte.name.toLowerCase());
226
+ if (!node || !isRelationalNode(node)) {
227
+ quereusError(`CTE '${cte.name}' missing from rebuilt WITH clause`, StatusCode.INTERNAL, undefined, stmt);
228
+ }
229
+ return new SinkNode(ctx.scope, node, `unreferenced-cte ${cte.name}`);
230
+ });
231
+ return new SequenceNode(ctx.scope, sinks, plan);
232
+ }
233
+ /** Every `CTENode` runtime identity reachable from `plan`. Walks `getRelations`
234
+ * as well as `getChildren` so DML write targets (outside `getChildren`) are
235
+ * covered — mirrors `collectTableRefs` in analysis/change-scope.ts. */
236
+ function collectCteDescriptors(plan) {
237
+ const descriptors = new Set();
238
+ const visited = new Set();
239
+ function walk(node) {
240
+ if (visited.has(node))
241
+ return;
242
+ visited.add(node);
243
+ if (node instanceof CTENode)
244
+ descriptors.add(node.tableDescriptor);
245
+ for (const c of node.getChildren())
246
+ walk(c);
247
+ for (const r of node.getRelations())
248
+ walk(r);
249
+ }
250
+ walk(plan);
251
+ return descriptors;
252
+ }
113
253
  //# sourceMappingURL=block.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"block.js","sourceRoot":"","sources":["../../../../src/planner/building/block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACN,+BAA+B,EAC/B,gCAAgC,EAChC,6BAA6B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC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CAAC,CAAC;IAEH,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;wEAEwE;AACxE,SAAS,qBAAqB,CAAC,IAAc;IAC5C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAY,CAAC;IACpC,SAAS,IAAI,CAAC,IAAc;QAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,IAAI,YAAY,OAAO;YAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnE,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE;YAAE,IAAI,CAAC,CAAwB,CAAC,CAAC;QACnE,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE;YAAE,IAAI,CAAC,CAAwB,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,OAAO,WAAW,CAAC;AACpB,CAAC"}
@@ -4,11 +4,12 @@ import { RowOpFlag } from '../../schema/table.js';
4
4
  import type { Attribute, RowDescriptor } from '../nodes/plan-node.js';
5
5
  import type { ConstraintCheck, NotNullDefaultPlan } from '../nodes/constraint-check-node.js';
6
6
  import type { Scope } from '../scopes/scope.js';
7
+ import { type MutationContextAttribute } from './mutation-context.js';
7
8
  /**
8
9
  * Builds constraint check expressions at plan time.
9
10
  * This allows the optimizer to see and optimize constraint expressions.
10
11
  */
11
- export declare function buildConstraintChecks(ctx: PlanningContext, tableSchema: TableSchema, operation: RowOpFlag, oldAttributes: Attribute[], newAttributes: Attribute[], _flatRowDescriptor: RowDescriptor, contextAttributes?: Attribute[],
12
+ export declare function buildConstraintChecks(ctx: PlanningContext, tableSchema: TableSchema, operation: RowOpFlag, oldAttributes: Attribute[], newAttributes: Attribute[], _flatRowDescriptor: RowDescriptor, contextAttributes?: ReadonlyArray<MutationContextAttribute>,
12
13
  /**
13
14
  * Extra CHECK constraints to enforce alongside the table's own — already
14
15
  * resolved in this table's column space. The lens layer threads its logical
@@ -36,7 +37,7 @@ additionalConstraints?: ReadonlyArray<RowConstraintSchema>): ConstraintCheck[];
36
37
  * check time in `checkNotNullConstraints` by column index (the first NOT-NULL
37
38
  * column with a NULL effective value), so don't look for it in this builder.
38
39
  */
39
- export declare function buildNotNullDefaults(ctx: PlanningContext, tableSchema: TableSchema, newAttributes: Attribute[], contextAttributes?: Attribute[],
40
+ export declare function buildNotNullDefaults(ctx: PlanningContext, tableSchema: TableSchema, newAttributes: Attribute[], contextAttributes?: ReadonlyArray<MutationContextAttribute>,
40
41
  /**
41
42
  * Parent scope for `new.<col>` resolution, threaded by a synthetic decomposition /
42
43
  * multi-source member insert (see {@link buildInsertStmt}'s `defaultRowContextScope`).
@@ -1 +1 @@
1
- {"version":3,"file":"constraint-builder.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,SAAS,EAAE,EAC1B,aAAa,EAAE,SAAS,EAAE,EAC1B,kBAAkB,EAAE,aAAa,EACjC,iBAAiB,GAAE,SAAS,EAAO;AACnC;;;;;GAKG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM,GAC7D,eAAe,EAAE,CA4KnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,SAAS,EAAE,EAC1B,iBAAiB,GAAE,SAAS,EAAO;AACnC;;;;;;;;GAQG;AACH,sBAAsB,CAAC,EAAE,KAAK,GAC7B,kBAAkB,EAAE,CAqDtB"}
1
+ {"version":3,"file":"constraint-builder.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAYhD,OAAO,EAA2D,KAAK,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAU/H;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,SAAS,EAAE,EAC1B,aAAa,EAAE,SAAS,EAAE,EAC1B,kBAAkB,EAAE,aAAa,EACjC,iBAAiB,GAAE,aAAa,CAAC,wBAAwB,CAAM;AAC/D;;;;;GAKG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM,GAC7D,eAAe,EAAE,CAwKnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,SAAS,EAAE,EAC1B,iBAAiB,GAAE,aAAa,CAAC,wBAAwB,CAAM;AAC/D;;;;;;;;GAQG;AACH,sBAAsB,CAAC,EAAE,KAAK,GAC7B,kBAAkB,EAAE,CA0CtB"}
@@ -6,9 +6,10 @@ import { hasRelationalDescendant } from '../analysis/scalar-subqueries.js';
6
6
  import { TableReferenceNode } from '../nodes/reference.js';
7
7
  import { validateDeterministicConstraint } from '../validation/determinism-validator.js';
8
8
  import { columnSchemaToScalarType } from '../type-utils.js';
9
- import { stripSelfQualifierInCheckExpression } from '../../schema/rename-rewriter.js';
9
+ import { stripSelfQualifierInSchemaExpression } from '../../schema/rename-rewriter.js';
10
10
  import { buildColumnSourceResolver } from '../../schema/column-source-resolver.js';
11
11
  import { cloneExpr } from '../mutation/scope-transform.js';
12
+ import { mutationContextVarNames, registerMutationContextSymbols } from './mutation-context.js';
12
13
  /**
13
14
  * Determines if a constraint should be checked for the given operation
14
15
  */
@@ -47,20 +48,16 @@ additionalConstraints = []) {
47
48
  const applicableConstraints = [...tableSchema.checkConstraints, ...additionalConstraints]
48
49
  .filter(constraint => shouldCheckConstraint(constraint, operation));
49
50
  const resolveColumnInSource = buildColumnSourceResolver(ctx.db);
51
+ // Bare column names a mutation context variable claims. The unqualified form is left
52
+ // to the context variable (the documented WITH CONTEXT precedence); the shadowed
53
+ // column stays reachable as `new.<col>` / `old.<col>`.
54
+ const shadowedByContext = mutationContextVarNames(contextAttributes);
50
55
  // Build expression nodes for each constraint
51
56
  return applicableConstraints.map(constraint => {
52
57
  // Create scope with OLD/NEW column access for constraint evaluation
53
58
  const constraintScope = new RegisteredScope(ctx.scope);
54
59
  // Register mutation context variables FIRST (so they shadow column names if conflicts exist)
55
- contextAttributes.forEach((attr, contextVarIndex) => {
56
- if (contextVarIndex < (tableSchema.mutationContext?.length || 0)) {
57
- const contextVar = tableSchema.mutationContext[contextVarIndex];
58
- const varNameLower = contextVar.name.toLowerCase();
59
- // Register both unqualified and qualified names
60
- constraintScope.registerSymbol(varNameLower, (exp, s) => new ColumnReferenceNode(s, exp, attr.type, attr.id, contextVarIndex));
61
- constraintScope.registerSymbol(`context.${varNameLower}`, (exp, s) => new ColumnReferenceNode(s, exp, attr.type, attr.id, contextVarIndex));
62
- }
63
- });
60
+ registerMutationContextSymbols(constraintScope, contextAttributes);
64
61
  // The per-relation write-row correlation for THIS op's target relation — the
65
62
  // decomposition analogue of `NEW`. A lens row-local CHECK rewritten over a multi-member
66
63
  // decomposition qualifies its write-row terms with `writeRowRelationCorrelation(owning
@@ -89,8 +86,9 @@ additionalConstraints = []) {
89
86
  // Relation-qualified write-row correlation (lens decomposition rewrite) — the
90
87
  // `<corr>.<col>` analogue of `new.<col>` for this member relation.
91
88
  constraintScope.registerSymbol(`${writeRowCorr}.${colNameLower}`, (exp, s) => new ColumnReferenceNode(s, exp, newColumnType, newAttrId, tableColIndex));
92
- // For INSERT/UPDATE, unqualified column defaults to NEW
93
- if (operation === RowOpFlag.INSERT || operation === RowOpFlag.UPDATE) {
89
+ // For INSERT/UPDATE, unqualified column defaults to NEW — unless a mutation
90
+ // context variable claims the bare name.
91
+ if ((operation === RowOpFlag.INSERT || operation === RowOpFlag.UPDATE) && !shadowedByContext.has(colNameLower)) {
94
92
  constraintScope.registerSymbol(colNameLower, (exp, s) => new ColumnReferenceNode(s, exp, newColumnType, newAttrId, tableColIndex));
95
93
  }
96
94
  }
@@ -101,8 +99,9 @@ additionalConstraints = []) {
101
99
  const oldColumnType = columnSchemaToScalarType(tableColumn, { nullable: true });
102
100
  // OLD.column
103
101
  constraintScope.registerSymbol(`old.${colNameLower}`, (exp, s) => new ColumnReferenceNode(s, exp, oldColumnType, oldAttrId, tableColIndex));
104
- // For DELETE, unqualified column defaults to OLD
105
- if (operation === RowOpFlag.DELETE) {
102
+ // For DELETE, unqualified column defaults to OLD — unless a mutation context
103
+ // variable claims the bare name.
104
+ if (operation === RowOpFlag.DELETE && !shadowedByContext.has(colNameLower)) {
106
105
  constraintScope.registerSymbol(colNameLower, (exp, s) => new ColumnReferenceNode(s, exp, oldColumnType, oldAttrId, tableColIndex));
107
106
  }
108
107
  }
@@ -131,7 +130,7 @@ additionalConstraints = []) {
131
130
  // peers' parent-chain fallback.
132
131
  let constraintExpr = constraint.expr;
133
132
  const stripped = cloneExpr(constraint.expr);
134
- if (stripSelfQualifierInCheckExpression(stripped, tableSchema.name, tableSchema.schemaName, resolveColumnInSource)) {
133
+ if (stripSelfQualifierInSchemaExpression(stripped, tableSchema.name, tableSchema.schemaName, resolveColumnInSource)) {
135
134
  constraintExpr = stripped;
136
135
  }
137
136
  const expression = buildExpression(constraintCtx, constraintExpr);
@@ -154,7 +153,9 @@ additionalConstraints = []) {
154
153
  deferrable: needsDeferred,
155
154
  initiallyDeferred: needsDeferred,
156
155
  needsDeferred,
157
- kind: 'check'
156
+ kind: 'check',
157
+ violationMessage: constraint.violationMessage,
158
+ messageValued: constraint.messageValued
158
159
  };
159
160
  }
160
161
  finally {
@@ -197,6 +198,8 @@ export function buildNotNullDefaults(ctx, tableSchema, newAttributes, contextAtt
197
198
  */
198
199
  defaultRowContextScope) {
199
200
  const result = [];
201
+ // Bare column names a mutation context variable claims (see buildConstraintChecks).
202
+ const reservedKeys = mutationContextVarNames(contextAttributes);
200
203
  for (let columnIndex = 0; columnIndex < tableSchema.columns.length; columnIndex++) {
201
204
  const column = tableSchema.columns[columnIndex];
202
205
  if (!column.notNull)
@@ -205,19 +208,9 @@ defaultRowContextScope) {
205
208
  if (!defaultExpr || typeof defaultExpr !== 'object' || !('type' in defaultExpr))
206
209
  continue;
207
210
  const scope = new RegisteredScope(defaultRowContextScope ?? ctx.scope);
208
- const reservedKeys = new Set();
209
211
  // Mutation context variables first so they shadow column names if conflicts exist
210
212
  // (matches createRowExpansionProjection's resolution order).
211
- contextAttributes.forEach((attr, contextVarIndex) => {
212
- if (contextVarIndex < (tableSchema.mutationContext?.length || 0)) {
213
- const contextVar = tableSchema.mutationContext[contextVarIndex];
214
- const varNameLower = contextVar.name.toLowerCase();
215
- scope.registerSymbol(varNameLower, (exp, s) => new ColumnReferenceNode(s, exp, attr.type, attr.id, contextVarIndex));
216
- scope.registerSymbol(`context.${varNameLower}`, (exp, s) => new ColumnReferenceNode(s, exp, attr.type, attr.id, contextVarIndex));
217
- reservedKeys.add(varNameLower);
218
- reservedKeys.add(`context.${varNameLower}`);
219
- }
220
- });
213
+ registerMutationContextSymbols(scope, contextAttributes);
221
214
  // Register NEW columns (DEFAULT can reference siblings as in row-expansion).
222
215
  // Skip the unqualified form when shadowed by a mutation context variable; the
223
216
  // qualified `new.<col>` form remains available.
@@ -1 +1 @@
1
- {"version":3,"file":"constraint-builder.js","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,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AAW,GAAG,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,EAAE,WAA6B,CAAmB,CAAC;QAClG,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,WAA6B,EAAE,WAAW,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,IAAoB;IAChD,MAAM,KAAK,GAAe,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QACvB,IAAI,CAAC,YAAY,kBAAkB,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"constraint-builder.js","sourceRoot":"","sources":["../../../../src/planner/building/constraint-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE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CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAoF,MAAM,uBAAuB,CAAC;AASnI,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAmB5E,wBAAgB,eAAe,CAC7B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,GAAG,CAAC,UAAU;AACpB;;;;;;;GAOG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM;AAC9D;;;;;;GAMG;AACH,UAAU,UAAQ,GACjB,QAAQ,CAmUV"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAoE,MAAM,uBAAuB,CAAC;AASnH,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAoB5E,wBAAgB,eAAe,CAC7B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,GAAG,CAAC,UAAU;AACpB;;;;;;;GAOG;AACH,qBAAqB,GAAE,aAAa,CAAC,mBAAmB,CAAM;AAC9D;;;;;;GAMG;AACH,UAAU,UAAQ,GACjB,QAAQ,CA+SV"}
@@ -28,6 +28,7 @@ import { raiseStmtTagDiagnostics } from './tag-diagnostics.js';
28
28
  import { buildWithContext } from './select-context.js';
29
29
  import { resolveCteTarget, contextForCteTarget, resolveSubqueryTarget } from './dml-target.js';
30
30
  import { schemaAuthoredContext } from './schema-authored-context.js';
31
+ import { buildMutationContextAttributes, buildMutationContextValues } from './mutation-context.js';
31
32
  export function buildDeleteStmt(ctx, stmt,
32
33
  /**
33
34
  * Extra row constraints to enforce alongside the table's own — already resolved
@@ -106,30 +107,12 @@ lensRouted = false) {
106
107
  if (isMaintainedTable(deleteResolved)) {
107
108
  return buildViewMutation(contextWithCTEs, maintainedTableViewLike(deleteResolved), { op: 'delete', stmt });
108
109
  }
109
- // Process mutation context assignments if present
110
- const mutationContextValues = new Map();
111
- const contextAttributes = [];
112
- if (stmt.contextValues && tableReference.tableSchema.mutationContext) {
113
- // Create context attributes
114
- tableReference.tableSchema.mutationContext.forEach((contextVar) => {
115
- contextAttributes.push({
116
- id: PlanNode.nextAttrId(),
117
- name: contextVar.name,
118
- type: {
119
- typeClass: 'scalar',
120
- logicalType: contextVar.logicalType,
121
- nullable: !contextVar.notNull,
122
- isReadOnly: true
123
- },
124
- sourceRelation: `context.${tableReference.tableSchema.name}`
125
- });
126
- });
127
- // Build context value expressions (evaluated in the base scope, before table scope)
128
- stmt.contextValues.forEach((assignment) => {
129
- const valueExpr = buildExpression(contextWithCTEs, assignment.value);
130
- mutationContextValues.set(assignment.name, valueExpr);
131
- });
132
- }
110
+ // Mutation context is driven by the TABLE's declaration, not by the statement — see
111
+ // building/mutation-context.ts. Values are evaluated in the base scope, before the
112
+ // table scope; a declared variable the statement omitted gets a NULL literal, and a
113
+ // NOT NULL one fails at reference time from any `check on delete` that reads it.
114
+ const contextAttributes = buildMutationContextAttributes(tableReference.tableSchema, stmt.contextValues);
115
+ const mutationContextValues = buildMutationContextValues(contextWithCTEs, contextAttributes, stmt.contextValues);
133
116
  // Plan the source of rows to delete. This is typically the table itself, potentially filtered.
134
117
  let sourceNode = tableRetrieve; // Use the RetrieveNode as source
135
118
  // Create a new scope with the table columns registered for column resolution.
@@ -200,7 +183,7 @@ lensRouted = false) {
200
183
  // statement-level OR clause, so the effective conflict resolution is the
201
184
  // ABORT default (matching the `undefined` onConflict on the DmlExecutorNode).
202
185
  if (ctx.db.options.getBooleanOption('foreign_keys')
203
- && getBatchableRestrictFks(ctx.schemaManager, tableReference.tableSchema, 'delete', undefined, lensRouted) === undefined) {
186
+ && getBatchableRestrictFks(ctx.db, tableReference.tableSchema, 'delete', undefined, lensRouted) === undefined) {
204
187
  const parentFKChecks = buildParentSideFKChecks(schemaAuthoredCtx, tableReference.tableSchema, RowOpFlag.DELETE, oldAttributes, newAttributes, contextAttributes);
205
188
  constraintChecks.push(...parentFKChecks);
206
189
  }