@quereus/quereus 4.4.0 → 4.5.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 (491) hide show
  1. package/README.md +6 -1
  2. package/dist/src/common/types.d.ts +9 -0
  3. package/dist/src/common/types.d.ts.map +1 -1
  4. package/dist/src/common/types.js.map +1 -1
  5. package/dist/src/core/database-events.d.ts +49 -0
  6. package/dist/src/core/database-events.d.ts.map +1 -1
  7. package/dist/src/core/database-events.js +148 -0
  8. package/dist/src/core/database-events.js.map +1 -1
  9. package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
  10. package/dist/src/core/database-materialized-views-analysis.js +1 -0
  11. package/dist/src/core/database-materialized-views-analysis.js.map +1 -1
  12. package/dist/src/core/database-materialized-views-plan-builders.d.ts +2 -1
  13. package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
  14. package/dist/src/core/database-materialized-views-plan-builders.js +26 -5
  15. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
  16. package/dist/src/core/database-materialized-views-plans.d.ts +6 -3
  17. package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -1
  18. package/dist/src/core/database-materialized-views.d.ts +3 -2
  19. package/dist/src/core/database-materialized-views.d.ts.map +1 -1
  20. package/dist/src/core/database-materialized-views.js +26 -5
  21. package/dist/src/core/database-materialized-views.js.map +1 -1
  22. package/dist/src/core/database.d.ts +5 -0
  23. package/dist/src/core/database.d.ts.map +1 -1
  24. package/dist/src/core/database.js +21 -1
  25. package/dist/src/core/database.js.map +1 -1
  26. package/dist/src/core/internal-statement-cache.d.ts +18 -0
  27. package/dist/src/core/internal-statement-cache.d.ts.map +1 -0
  28. package/dist/src/core/internal-statement-cache.js +211 -0
  29. package/dist/src/core/internal-statement-cache.js.map +1 -0
  30. package/dist/src/func/builtins/aggregate.d.ts +13 -12
  31. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  32. package/dist/src/func/builtins/aggregate.js +45 -67
  33. package/dist/src/func/builtins/aggregate.js.map +1 -1
  34. package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
  35. package/dist/src/func/builtins/builtin-window-functions.js +63 -48
  36. package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
  37. package/dist/src/func/builtins/scalar.d.ts.map +1 -1
  38. package/dist/src/func/builtins/scalar.js +92 -3
  39. package/dist/src/func/builtins/scalar.js.map +1 -1
  40. package/dist/src/func/registration.d.ts +18 -1
  41. package/dist/src/func/registration.d.ts.map +1 -1
  42. package/dist/src/func/registration.js +26 -0
  43. package/dist/src/func/registration.js.map +1 -1
  44. package/dist/src/index.d.ts +10 -10
  45. package/dist/src/index.d.ts.map +1 -1
  46. package/dist/src/index.js +13 -12
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/parser/parser.d.ts +6 -0
  49. package/dist/src/parser/parser.d.ts.map +1 -1
  50. package/dist/src/parser/parser.js +45 -34
  51. package/dist/src/parser/parser.js.map +1 -1
  52. package/dist/src/planner/analysis/coarsened-key.d.ts +4 -3
  53. package/dist/src/planner/analysis/coarsened-key.d.ts.map +1 -1
  54. package/dist/src/planner/analysis/coarsened-key.js +37 -3
  55. package/dist/src/planner/analysis/coarsened-key.js.map +1 -1
  56. package/dist/src/planner/analysis/comparison-collation.d.ts +35 -3
  57. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
  58. package/dist/src/planner/analysis/comparison-collation.js +37 -3
  59. package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
  60. package/dist/src/planner/analysis/coverage-prover.d.ts +13 -2
  61. package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
  62. package/dist/src/planner/analysis/coverage-prover.js +10 -14
  63. package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
  64. package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
  65. package/dist/src/planner/analysis/expression-fingerprint.js +29 -0
  66. package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
  67. package/dist/src/planner/analysis/predicate-conjuncts.d.ts +10 -4
  68. package/dist/src/planner/analysis/predicate-conjuncts.d.ts.map +1 -1
  69. package/dist/src/planner/analysis/predicate-conjuncts.js +28 -7
  70. package/dist/src/planner/analysis/predicate-conjuncts.js.map +1 -1
  71. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +6 -0
  72. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
  73. package/dist/src/planner/analysis/query-rewrite-matcher.js +19 -29
  74. package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
  75. package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -1
  76. package/dist/src/planner/analysis/sat-checker.js +43 -4
  77. package/dist/src/planner/analysis/sat-checker.js.map +1 -1
  78. package/dist/src/planner/analysis/scalar-subqueries.d.ts +22 -3
  79. package/dist/src/planner/analysis/scalar-subqueries.d.ts.map +1 -1
  80. package/dist/src/planner/analysis/scalar-subqueries.js +32 -3
  81. package/dist/src/planner/analysis/scalar-subqueries.js.map +1 -1
  82. package/dist/src/planner/analysis/set-op-type-merge.d.ts +64 -0
  83. package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -0
  84. package/dist/src/planner/analysis/set-op-type-merge.js +97 -0
  85. package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -0
  86. package/dist/src/planner/building/coercion.d.ts +78 -0
  87. package/dist/src/planner/building/coercion.d.ts.map +1 -0
  88. package/dist/src/planner/building/coercion.js +137 -0
  89. package/dist/src/planner/building/coercion.js.map +1 -0
  90. package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
  91. package/dist/src/planner/building/constraint-builder.js +5 -18
  92. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  93. package/dist/src/planner/building/delete.d.ts.map +1 -1
  94. package/dist/src/planner/building/delete.js +10 -3
  95. package/dist/src/planner/building/delete.js.map +1 -1
  96. package/dist/src/planner/building/expression.d.ts.map +1 -1
  97. package/dist/src/planner/building/expression.js +13 -35
  98. package/dist/src/planner/building/expression.js.map +1 -1
  99. package/dist/src/planner/building/foreign-key-builder.d.ts +44 -1
  100. package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
  101. package/dist/src/planner/building/foreign-key-builder.js +54 -0
  102. package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
  103. package/dist/src/planner/building/function-call.d.ts.map +1 -1
  104. package/dist/src/planner/building/function-call.js +8 -0
  105. package/dist/src/planner/building/function-call.js.map +1 -1
  106. package/dist/src/planner/building/insert.d.ts.map +1 -1
  107. package/dist/src/planner/building/insert.js +9 -12
  108. package/dist/src/planner/building/insert.js.map +1 -1
  109. package/dist/src/planner/building/select-compound.d.ts.map +1 -1
  110. package/dist/src/planner/building/select-compound.js +10 -6
  111. package/dist/src/planner/building/select-compound.js.map +1 -1
  112. package/dist/src/planner/building/update.d.ts.map +1 -1
  113. package/dist/src/planner/building/update.js +13 -4
  114. package/dist/src/planner/building/update.js.map +1 -1
  115. package/dist/src/planner/cost/conjunct-cost.d.ts +42 -0
  116. package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -0
  117. package/dist/src/planner/cost/conjunct-cost.js +62 -0
  118. package/dist/src/planner/cost/conjunct-cost.js.map +1 -0
  119. package/dist/src/planner/framework/pass.js +3 -3
  120. package/dist/src/planner/mutation/propagate.d.ts.map +1 -1
  121. package/dist/src/planner/mutation/propagate.js +1 -0
  122. package/dist/src/planner/mutation/propagate.js.map +1 -1
  123. package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
  124. package/dist/src/planner/nodes/async-gather-node.js +19 -8
  125. package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
  126. package/dist/src/planner/nodes/bloom-join-node.d.ts +2 -0
  127. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  128. package/dist/src/planner/nodes/bloom-join-node.js +10 -5
  129. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  130. package/dist/src/planner/nodes/dml-executor-node.d.ts +0 -9
  131. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  132. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  133. package/dist/src/planner/nodes/join-node.d.ts +5 -0
  134. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  135. package/dist/src/planner/nodes/join-node.js +8 -1
  136. package/dist/src/planner/nodes/join-node.js.map +1 -1
  137. package/dist/src/planner/nodes/join-utils.d.ts +57 -0
  138. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  139. package/dist/src/planner/nodes/join-utils.js +47 -0
  140. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  141. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +87 -0
  142. package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -0
  143. package/dist/src/planner/nodes/key-set-semi-join-node.js +137 -0
  144. package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -0
  145. package/dist/src/planner/nodes/merge-join-node.d.ts +2 -0
  146. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  147. package/dist/src/planner/nodes/merge-join-node.js +14 -6
  148. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  149. package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
  150. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  151. package/dist/src/planner/nodes/plan-node-type.js +1 -0
  152. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  153. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  154. package/dist/src/planner/nodes/scalar.js +26 -3
  155. package/dist/src/planner/nodes/scalar.js.map +1 -1
  156. package/dist/src/planner/nodes/set-operation-node.d.ts +68 -16
  157. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  158. package/dist/src/planner/nodes/set-operation-node.js +147 -26
  159. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  160. package/dist/src/planner/nodes/table-access-nodes.d.ts +19 -1
  161. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  162. package/dist/src/planner/nodes/table-access-nodes.js +13 -2
  163. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  164. package/dist/src/planner/optimizer.d.ts.map +1 -1
  165. package/dist/src/planner/optimizer.js +54 -12
  166. package/dist/src/planner/optimizer.js.map +1 -1
  167. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +68 -0
  168. package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -0
  169. package/dist/src/planner/rules/access/rule-key-set-seek.js +408 -0
  170. package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -0
  171. package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
  172. package/dist/src/planner/rules/access/rule-monotonic-range-access.js +2 -2
  173. package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
  174. package/dist/src/planner/rules/access/rule-select-access-path.d.ts +27 -0
  175. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  176. package/dist/src/planner/rules/access/rule-select-access-path.js +74 -29
  177. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  178. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts.map +1 -1
  179. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +23 -4
  180. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
  181. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts +10 -8
  182. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts.map +1 -1
  183. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js +10 -8
  184. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js.map +1 -1
  185. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +67 -41
  186. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
  187. package/dist/src/planner/rules/join/equi-pair-extractor.js +72 -36
  188. package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
  189. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  190. package/dist/src/planner/rules/join/rule-join-physical-selection.js +14 -2
  191. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  192. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
  193. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +11 -1
  194. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
  195. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +1 -1
  196. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +1 -1
  197. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts +30 -0
  198. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -0
  199. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +63 -0
  200. package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -0
  201. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +17 -1
  202. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
  203. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +206 -12
  204. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
  205. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +8 -1
  206. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
  207. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +3 -1
  208. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -1
  209. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +13 -1
  210. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
  211. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
  212. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +18 -3
  213. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  214. package/dist/src/planner/rules/shared/index-style-context.d.ts +17 -0
  215. package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -1
  216. package/dist/src/planner/rules/shared/index-style-context.js +7 -0
  217. package/dist/src/planner/rules/shared/index-style-context.js.map +1 -1
  218. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js +4 -0
  219. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js.map +1 -1
  220. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +24 -6
  221. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  222. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +175 -60
  223. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  224. package/dist/src/planner/stats/catalog-stats.d.ts +52 -0
  225. package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
  226. package/dist/src/planner/stats/catalog-stats.js +151 -5
  227. package/dist/src/planner/stats/catalog-stats.js.map +1 -1
  228. package/dist/src/planner/stats/index.d.ts +15 -0
  229. package/dist/src/planner/stats/index.d.ts.map +1 -1
  230. package/dist/src/planner/stats/index.js.map +1 -1
  231. package/dist/src/planner/stats/selectivity-combine.d.ts +53 -0
  232. package/dist/src/planner/stats/selectivity-combine.d.ts.map +1 -0
  233. package/dist/src/planner/stats/selectivity-combine.js +75 -0
  234. package/dist/src/planner/stats/selectivity-combine.js.map +1 -0
  235. package/dist/src/planner/util/column-origins.d.ts +58 -0
  236. package/dist/src/planner/util/column-origins.d.ts.map +1 -0
  237. package/dist/src/planner/util/column-origins.js +90 -0
  238. package/dist/src/planner/util/column-origins.js.map +1 -0
  239. package/dist/src/runtime/deferred-constraint-queue.d.ts +40 -0
  240. package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
  241. package/dist/src/runtime/deferred-constraint-queue.js +91 -0
  242. package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
  243. package/dist/src/runtime/emit/aggregate-setup.d.ts +49 -0
  244. package/dist/src/runtime/emit/aggregate-setup.d.ts.map +1 -0
  245. package/dist/src/runtime/emit/aggregate-setup.js +99 -0
  246. package/dist/src/runtime/emit/aggregate-setup.js.map +1 -0
  247. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  248. package/dist/src/runtime/emit/aggregate.js +4 -69
  249. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  250. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  251. package/dist/src/runtime/emit/alter-table.js +354 -165
  252. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  253. package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
  254. package/dist/src/runtime/emit/asof-scan.js +11 -0
  255. package/dist/src/runtime/emit/asof-scan.js.map +1 -1
  256. package/dist/src/runtime/emit/between.d.ts.map +1 -1
  257. package/dist/src/runtime/emit/between.js +7 -12
  258. package/dist/src/runtime/emit/between.js.map +1 -1
  259. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  260. package/dist/src/runtime/emit/binary.js +24 -25
  261. package/dist/src/runtime/emit/binary.js.map +1 -1
  262. package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
  263. package/dist/src/runtime/emit/bloom-join.js +8 -16
  264. package/dist/src/runtime/emit/bloom-join.js.map +1 -1
  265. package/dist/src/runtime/emit/case.d.ts.map +1 -1
  266. package/dist/src/runtime/emit/case.js +40 -6
  267. package/dist/src/runtime/emit/case.js.map +1 -1
  268. package/dist/src/runtime/emit/cast.d.ts.map +1 -1
  269. package/dist/src/runtime/emit/cast.js +10 -23
  270. package/dist/src/runtime/emit/cast.js.map +1 -1
  271. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  272. package/dist/src/runtime/emit/constraint-check.js +72 -51
  273. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  274. package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
  275. package/dist/src/runtime/emit/create-view.js +6 -0
  276. package/dist/src/runtime/emit/create-view.js.map +1 -1
  277. package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
  278. package/dist/src/runtime/emit/distinct.js +6 -3
  279. package/dist/src/runtime/emit/distinct.js.map +1 -1
  280. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  281. package/dist/src/runtime/emit/dml-executor.js +188 -84
  282. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  283. package/dist/src/runtime/emit/filter.d.ts +18 -0
  284. package/dist/src/runtime/emit/filter.d.ts.map +1 -1
  285. package/dist/src/runtime/emit/filter.js +52 -10
  286. package/dist/src/runtime/emit/filter.js.map +1 -1
  287. package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
  288. package/dist/src/runtime/emit/hash-aggregate.js +16 -65
  289. package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
  290. package/dist/src/runtime/emit/insert.d.ts.map +1 -1
  291. package/dist/src/runtime/emit/insert.js +18 -7
  292. package/dist/src/runtime/emit/insert.js.map +1 -1
  293. package/dist/src/runtime/emit/join-key-extractor.d.ts +46 -0
  294. package/dist/src/runtime/emit/join-key-extractor.d.ts.map +1 -0
  295. package/dist/src/runtime/emit/join-key-extractor.js +60 -0
  296. package/dist/src/runtime/emit/join-key-extractor.js.map +1 -0
  297. package/dist/src/runtime/emit/join.d.ts.map +1 -1
  298. package/dist/src/runtime/emit/join.js +37 -11
  299. package/dist/src/runtime/emit/join.js.map +1 -1
  300. package/dist/src/runtime/emit/key-set-semi-join.d.ts +29 -0
  301. package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -0
  302. package/dist/src/runtime/emit/key-set-semi-join.js +143 -0
  303. package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -0
  304. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +14 -1
  305. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  306. package/dist/src/runtime/emit/materialized-view-helpers.js +33 -3
  307. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  308. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
  309. package/dist/src/runtime/emit/materialized-view.js +47 -6
  310. package/dist/src/runtime/emit/materialized-view.js.map +1 -1
  311. package/dist/src/runtime/emit/merge-join.d.ts.map +1 -1
  312. package/dist/src/runtime/emit/merge-join.js +32 -15
  313. package/dist/src/runtime/emit/merge-join.js.map +1 -1
  314. package/dist/src/runtime/emit/operand-comparator.d.ts +40 -0
  315. package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -0
  316. package/dist/src/runtime/emit/operand-comparator.js +59 -0
  317. package/dist/src/runtime/emit/operand-comparator.js.map +1 -0
  318. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  319. package/dist/src/runtime/emit/scan.js +11 -2
  320. package/dist/src/runtime/emit/scan.js.map +1 -1
  321. package/dist/src/runtime/emit/set-object-tags.d.ts +8 -0
  322. package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
  323. package/dist/src/runtime/emit/set-object-tags.js +8 -0
  324. package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
  325. package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
  326. package/dist/src/runtime/emit/set-operation.js +7 -4
  327. package/dist/src/runtime/emit/set-operation.js.map +1 -1
  328. package/dist/src/runtime/emit/sort.d.ts.map +1 -1
  329. package/dist/src/runtime/emit/sort.js +5 -2
  330. package/dist/src/runtime/emit/sort.js.map +1 -1
  331. package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
  332. package/dist/src/runtime/emit/subquery.js +113 -13
  333. package/dist/src/runtime/emit/subquery.js.map +1 -1
  334. package/dist/src/runtime/emit/temporal-arithmetic.d.ts +7 -0
  335. package/dist/src/runtime/emit/temporal-arithmetic.d.ts.map +1 -1
  336. package/dist/src/runtime/emit/temporal-arithmetic.js +15 -7
  337. package/dist/src/runtime/emit/temporal-arithmetic.js.map +1 -1
  338. package/dist/src/runtime/emit/update.d.ts.map +1 -1
  339. package/dist/src/runtime/emit/update.js +44 -3
  340. package/dist/src/runtime/emit/update.js.map +1 -1
  341. package/dist/src/runtime/emit/window.d.ts.map +1 -1
  342. package/dist/src/runtime/emit/window.js +72 -55
  343. package/dist/src/runtime/emit/window.js.map +1 -1
  344. package/dist/src/runtime/foreign-key-actions.d.ts +36 -1
  345. package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
  346. package/dist/src/runtime/foreign-key-actions.js +238 -116
  347. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  348. package/dist/src/runtime/parallel-driver.d.ts +10 -2
  349. package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
  350. package/dist/src/runtime/parallel-driver.js +12 -2
  351. package/dist/src/runtime/parallel-driver.js.map +1 -1
  352. package/dist/src/runtime/register.d.ts.map +1 -1
  353. package/dist/src/runtime/register.js +2 -0
  354. package/dist/src/runtime/register.js.map +1 -1
  355. package/dist/src/runtime/types.d.ts +25 -0
  356. package/dist/src/runtime/types.d.ts.map +1 -1
  357. package/dist/src/runtime/types.js.map +1 -1
  358. package/dist/src/schema/catalog-persistability.d.ts +58 -0
  359. package/dist/src/schema/catalog-persistability.d.ts.map +1 -0
  360. package/dist/src/schema/catalog-persistability.js +87 -0
  361. package/dist/src/schema/catalog-persistability.js.map +1 -0
  362. package/dist/src/schema/catalog.d.ts +17 -1
  363. package/dist/src/schema/catalog.d.ts.map +1 -1
  364. package/dist/src/schema/catalog.js +25 -3
  365. package/dist/src/schema/catalog.js.map +1 -1
  366. package/dist/src/schema/constraint-builder.d.ts +20 -22
  367. package/dist/src/schema/constraint-builder.d.ts.map +1 -1
  368. package/dist/src/schema/constraint-builder.js +43 -36
  369. package/dist/src/schema/constraint-builder.js.map +1 -1
  370. package/dist/src/schema/ddl-generator.d.ts +23 -0
  371. package/dist/src/schema/ddl-generator.d.ts.map +1 -1
  372. package/dist/src/schema/ddl-generator.js +27 -0
  373. package/dist/src/schema/ddl-generator.js.map +1 -1
  374. package/dist/src/schema/function.d.ts +39 -1
  375. package/dist/src/schema/function.d.ts.map +1 -1
  376. package/dist/src/schema/function.js.map +1 -1
  377. package/dist/src/schema/manager.d.ts +28 -0
  378. package/dist/src/schema/manager.d.ts.map +1 -1
  379. package/dist/src/schema/manager.js +82 -14
  380. package/dist/src/schema/manager.js.map +1 -1
  381. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  382. package/dist/src/schema/schema-differ.js +51 -12
  383. package/dist/src/schema/schema-differ.js.map +1 -1
  384. package/dist/src/schema/unique-enforcement.d.ts +31 -0
  385. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  386. package/dist/src/schema/unique-enforcement.js +37 -1
  387. package/dist/src/schema/unique-enforcement.js.map +1 -1
  388. package/dist/src/schema/window-function.d.ts +30 -10
  389. package/dist/src/schema/window-function.d.ts.map +1 -1
  390. package/dist/src/schema/window-function.js +20 -16
  391. package/dist/src/schema/window-function.js.map +1 -1
  392. package/dist/src/types/builtin-types.d.ts.map +1 -1
  393. package/dist/src/types/builtin-types.js +30 -4
  394. package/dist/src/types/builtin-types.js.map +1 -1
  395. package/dist/src/types/cast-semantics.d.ts +43 -0
  396. package/dist/src/types/cast-semantics.d.ts.map +1 -0
  397. package/dist/src/types/cast-semantics.js +59 -0
  398. package/dist/src/types/cast-semantics.js.map +1 -0
  399. package/dist/src/types/index.d.ts +1 -1
  400. package/dist/src/types/index.d.ts.map +1 -1
  401. package/dist/src/types/index.js +1 -1
  402. package/dist/src/types/index.js.map +1 -1
  403. package/dist/src/types/json-type.d.ts.map +1 -1
  404. package/dist/src/types/json-type.js +31 -10
  405. package/dist/src/types/json-type.js.map +1 -1
  406. package/dist/src/types/logical-type.d.ts +22 -0
  407. package/dist/src/types/logical-type.d.ts.map +1 -1
  408. package/dist/src/types/logical-type.js.map +1 -1
  409. package/dist/src/types/temporal-types.d.ts.map +1 -1
  410. package/dist/src/types/temporal-types.js +33 -11
  411. package/dist/src/types/temporal-types.js.map +1 -1
  412. package/dist/src/types/validation.d.ts +39 -1
  413. package/dist/src/types/validation.d.ts.map +1 -1
  414. package/dist/src/types/validation.js +60 -0
  415. package/dist/src/types/validation.js.map +1 -1
  416. package/dist/src/util/ast-spine-clone.d.ts +23 -0
  417. package/dist/src/util/ast-spine-clone.d.ts.map +1 -0
  418. package/dist/src/util/ast-spine-clone.js +41 -0
  419. package/dist/src/util/ast-spine-clone.js.map +1 -0
  420. package/dist/src/util/coercion.d.ts +13 -0
  421. package/dist/src/util/coercion.d.ts.map +1 -1
  422. package/dist/src/util/coercion.js +10 -1
  423. package/dist/src/util/coercion.js.map +1 -1
  424. package/dist/src/util/comparison.d.ts +114 -0
  425. package/dist/src/util/comparison.d.ts.map +1 -1
  426. package/dist/src/util/comparison.js +187 -27
  427. package/dist/src/util/comparison.js.map +1 -1
  428. package/dist/src/vtab/best-access-plan.d.ts +87 -0
  429. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  430. package/dist/src/vtab/best-access-plan.js +87 -0
  431. package/dist/src/vtab/best-access-plan.js.map +1 -1
  432. package/dist/src/vtab/manifest.d.ts +7 -0
  433. package/dist/src/vtab/manifest.d.ts.map +1 -1
  434. package/dist/src/vtab/memory/connection.d.ts +14 -1
  435. package/dist/src/vtab/memory/connection.d.ts.map +1 -1
  436. package/dist/src/vtab/memory/connection.js +20 -2
  437. package/dist/src/vtab/memory/connection.js.map +1 -1
  438. package/dist/src/vtab/memory/layer/base.d.ts +12 -5
  439. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  440. package/dist/src/vtab/memory/layer/base.js +20 -9
  441. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  442. package/dist/src/vtab/memory/layer/connection.d.ts +17 -0
  443. package/dist/src/vtab/memory/layer/connection.d.ts.map +1 -1
  444. package/dist/src/vtab/memory/layer/connection.js +26 -0
  445. package/dist/src/vtab/memory/layer/connection.js.map +1 -1
  446. package/dist/src/vtab/memory/layer/manager.d.ts +156 -31
  447. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  448. package/dist/src/vtab/memory/layer/manager.js +695 -158
  449. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  450. package/dist/src/vtab/memory/layer/plan-filter.d.ts +41 -20
  451. package/dist/src/vtab/memory/layer/plan-filter.d.ts.map +1 -1
  452. package/dist/src/vtab/memory/layer/plan-filter.js +57 -27
  453. package/dist/src/vtab/memory/layer/plan-filter.js.map +1 -1
  454. package/dist/src/vtab/memory/layer/row-convert.d.ts +21 -0
  455. package/dist/src/vtab/memory/layer/row-convert.d.ts.map +1 -0
  456. package/dist/src/vtab/memory/layer/row-convert.js +30 -0
  457. package/dist/src/vtab/memory/layer/row-convert.js.map +1 -0
  458. package/dist/src/vtab/memory/layer/scan-layer.d.ts +6 -3
  459. package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
  460. package/dist/src/vtab/memory/layer/scan-layer.js +48 -34
  461. package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
  462. package/dist/src/vtab/memory/layer/transaction.d.ts +142 -19
  463. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  464. package/dist/src/vtab/memory/layer/transaction.js +237 -73
  465. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  466. package/dist/src/vtab/memory/module.d.ts +14 -2
  467. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  468. package/dist/src/vtab/memory/module.js +60 -41
  469. package/dist/src/vtab/memory/module.js.map +1 -1
  470. package/dist/src/vtab/memory/table.d.ts +1 -1
  471. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  472. package/dist/src/vtab/memory/table.js +12 -4
  473. package/dist/src/vtab/memory/table.js.map +1 -1
  474. package/dist/src/vtab/memory/types.d.ts +27 -1
  475. package/dist/src/vtab/memory/types.d.ts.map +1 -1
  476. package/dist/src/vtab/memory/types.js +16 -1
  477. package/dist/src/vtab/memory/types.js.map +1 -1
  478. package/dist/src/vtab/memory/utils/primary-key.d.ts +9 -0
  479. package/dist/src/vtab/memory/utils/primary-key.d.ts.map +1 -1
  480. package/dist/src/vtab/memory/utils/primary-key.js +11 -0
  481. package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
  482. package/dist/src/vtab/module.d.ts +63 -0
  483. package/dist/src/vtab/module.d.ts.map +1 -1
  484. package/dist/src/vtab/table.d.ts +33 -7
  485. package/dist/src/vtab/table.d.ts.map +1 -1
  486. package/dist/src/vtab/table.js.map +1 -1
  487. package/package.json +3 -3
  488. package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts +0 -26
  489. package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts.map +0 -1
  490. package/dist/src/planner/rules/cache/rule-in-subquery-cache.js +0 -66
  491. package/dist/src/planner/rules/cache/rule-in-subquery-cache.js.map +0 -1
@@ -1,9 +1,38 @@
1
1
  /**
2
- * Shared helpers for rules that recognize and rewrite `ScalarSubqueryNode`s
3
- * embedded in projection scalar expression trees (`rule-fanout-lookup-join`,
4
- * `rule-scalar-agg-decorrelation`).
2
+ * Shared helpers for recognizing subqueries embedded in scalar expression trees:
3
+ * the `ScalarSubqueryNode` collect/substitute pair used by the rewrite rules
4
+ * (`rule-fanout-lookup-join`, `rule-scalar-agg-decorrelation`), plus the
5
+ * node-type-agnostic {@link hasRelationalDescendant} test.
5
6
  */
7
+ import { isRelationalNode } from '../nodes/plan-node.js';
6
8
  import { ScalarSubqueryNode } from '../nodes/subquery.js';
9
+ /**
10
+ * True iff `expr`'s subtree contains a relational descendant — i.e. it embeds a
11
+ * subquery of ANY shape (scalar-subquery, `EXISTS`, `IN (select …)`, …), each of
12
+ * which exposes its relational body via `getChildren()`. Pure scalar operands
13
+ * (column refs, literals, arithmetic, `IN (<value list>)`, direct function calls)
14
+ * have no relational descendant.
15
+ *
16
+ * Detecting the relational child structurally, rather than listing the scalar
17
+ * node types that wrap a subquery, is what makes this safe against new subquery
18
+ * shapes: the list form missed `x in (select …)`, whose `InNode` carries its
19
+ * source relation but reports `PlanNodeType.In`
20
+ * (bug-deferred-subquery-check-reads-stale-state).
21
+ *
22
+ * Callers: CHECK auto-deferral (`planner/building/constraint-builder.ts`), the
23
+ * MV-rewrite residual gate (`query-rewrite-matcher.ts`), and AND/OR
24
+ * short-circuit deferral (`runtime/emit/binary.ts`).
25
+ */
26
+ export function hasRelationalDescendant(expr) {
27
+ const stack = [expr];
28
+ while (stack.length) {
29
+ const node = stack.pop();
30
+ if (node !== expr && isRelationalNode(node))
31
+ return true;
32
+ stack.push(...node.getChildren());
33
+ }
34
+ return false;
35
+ }
7
36
  /**
8
37
  * Collect every `ScalarSubqueryNode` reachable in a projection's scalar
9
38
  * expression tree, in deterministic pre-order. A recognized subquery is a leaf
@@ -1 +1 @@
1
- {"version":3,"file":"scalar-subqueries.js","sourceRoot":"","sources":["../../../../src/planner/analysis/scalar-subqueries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAoB,EAAE,GAAyB;IACtF,IAAI,IAAI,YAAY,kBAAkB,EAAE,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,OAAO;IACR,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC5C,uBAAuB,CAAC,KAAuB,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CACnC,IAAoB,EACpB,YAA6D;IAE7D,IAAI,IAAI,YAAY,kBAAkB,EAAE,CAAC;QACxC,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACvC,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC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,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAmB,CAAC;AACzD,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Symmetric per-column LOGICAL-type merge for set operations (UNION / UNION ALL /
3
+ * INTERSECT / EXCEPT / DIFF) — the type half of set-op output-column resolution;
4
+ * the collation half is `resolveSetOpColumnCollation` in `comparison-collation.ts`.
5
+ *
6
+ * A set operation's output column carries rows from BOTH operands, so the type it
7
+ * advertises must describe both — everything downstream trusts it (the DML write
8
+ * pass `buildRowCoercion` skips conversion on an identity match, the set-op dedup
9
+ * comparator keys off it, predicate coercion decides casts from it). The merge is
10
+ * order-independent: swapping the operands can never change the result.
11
+ *
12
+ * Rules, first match wins (see docs/types.md § Where coercion happens):
13
+ * 1. Identical logical types → that type (registry singletons, identity compare).
14
+ * 2. Either side is NULL → the other side's type (a `select null` branch is a
15
+ * valid member of every type and must not poison a well-typed union).
16
+ * 3. Both builtin numeric (and differing) → NUMERIC, whose value space
17
+ * (`number | bigint`) covers both branches as they actually are — no branch
18
+ * conversion needed. NOT the CASE rule ("arms differ ⇒ TEXT") — `1 union all
19
+ * 2.5` must stay numeric; and NOT arithmetic's INTEGER + REAL → REAL, which
20
+ * describes one value, not a stream mixing both forms.
21
+ * 4. Exactly one side object-physical (JSON today) → the object side's type,
22
+ * with the other operand marked `convert` — the same rule and direction
23
+ * `insertCrossTypeCoercion` applies to comparisons (casting the JSON side to
24
+ * text would make identity depend on spelling and diverge from the index's
25
+ * structural compare). The caller is responsible for actually converting the
26
+ * marked operand (a lenient CAST); a caller that cannot must advertise ANY
27
+ * instead ({@link mergeSetOpAdvertisedType}).
28
+ * 5. Otherwise → ANY. The honest answer for a pair with no principled common
29
+ * type (DATE ∪ TEXT, BLOB ∪ TEXT, …): ANY's `parse` is pass-through and its
30
+ * `compare` is storage-class + BINARY ordering, and at a DML it is never
31
+ * identical to a declared column type, so every consumer converts — correct
32
+ * precisely because no branch is guaranteed to already be in target form.
33
+ */
34
+ import type { LogicalType } from '../../types/logical-type.js';
35
+ /** Outcome of merging one set-op output column's two operand logical types. */
36
+ export interface SetOpColumnTypeMerge {
37
+ /** The merged (advertised) logical type, assuming `convert` (if set) is honored. */
38
+ readonly logicalType: LogicalType;
39
+ /**
40
+ * The operand whose values must be CAST (leniently) to `logicalType` for the
41
+ * merge to hold — set only by rule 4 (object-physical vs other). Absent means
42
+ * both operands already produce `logicalType`-compatible values as-is.
43
+ */
44
+ readonly convert?: 'left' | 'right';
45
+ }
46
+ /**
47
+ * Merge two set-op operand column logical types under rules 1–5 above.
48
+ * Symmetric: `merge(a, b).logicalType === merge(b, a).logicalType`, with
49
+ * `convert` flipping sides accordingly.
50
+ */
51
+ export declare function mergeSetOpColumnType(left: LogicalType, right: LogicalType): SetOpColumnTypeMerge;
52
+ /**
53
+ * The logical type a set operation may HONESTLY advertise for a column pair
54
+ * when no operand conversion will be performed: the merge result, except a
55
+ * rule-4 pair collapses to ANY (advertising the object side's type over an
56
+ * unconverted text operand is exactly the defect this module exists to fix).
57
+ *
58
+ * `SetOperationNode` reads its output types through this: its factory aligns
59
+ * rule-4 operands with a lenient CAST up front, so an aligned tree hits rule 1
60
+ * here and the ANY collapse only fires for a pair the factory could not align
61
+ * (a flag-surfacing branch) or a hand-built unaligned tree.
62
+ */
63
+ export declare function mergeSetOpAdvertisedType(left: LogicalType, right: LogicalType): LogicalType;
64
+ //# sourceMappingURL=set-op-type-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-op-type-merge.d.ts","sourceRoot":"","sources":["../../../../src/planner/analysis/set-op-type-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI/D,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACpC,oFAAoF;IACpF,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC;AAOD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,oBAAoB,CAoChG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,WAAW,CAG3F"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Symmetric per-column LOGICAL-type merge for set operations (UNION / UNION ALL /
3
+ * INTERSECT / EXCEPT / DIFF) — the type half of set-op output-column resolution;
4
+ * the collation half is `resolveSetOpColumnCollation` in `comparison-collation.ts`.
5
+ *
6
+ * A set operation's output column carries rows from BOTH operands, so the type it
7
+ * advertises must describe both — everything downstream trusts it (the DML write
8
+ * pass `buildRowCoercion` skips conversion on an identity match, the set-op dedup
9
+ * comparator keys off it, predicate coercion decides casts from it). The merge is
10
+ * order-independent: swapping the operands can never change the result.
11
+ *
12
+ * Rules, first match wins (see docs/types.md § Where coercion happens):
13
+ * 1. Identical logical types → that type (registry singletons, identity compare).
14
+ * 2. Either side is NULL → the other side's type (a `select null` branch is a
15
+ * valid member of every type and must not poison a well-typed union).
16
+ * 3. Both builtin numeric (and differing) → NUMERIC, whose value space
17
+ * (`number | bigint`) covers both branches as they actually are — no branch
18
+ * conversion needed. NOT the CASE rule ("arms differ ⇒ TEXT") — `1 union all
19
+ * 2.5` must stay numeric; and NOT arithmetic's INTEGER + REAL → REAL, which
20
+ * describes one value, not a stream mixing both forms.
21
+ * 4. Exactly one side object-physical (JSON today) → the object side's type,
22
+ * with the other operand marked `convert` — the same rule and direction
23
+ * `insertCrossTypeCoercion` applies to comparisons (casting the JSON side to
24
+ * text would make identity depend on spelling and diverge from the index's
25
+ * structural compare). The caller is responsible for actually converting the
26
+ * marked operand (a lenient CAST); a caller that cannot must advertise ANY
27
+ * instead ({@link mergeSetOpAdvertisedType}).
28
+ * 5. Otherwise → ANY. The honest answer for a pair with no principled common
29
+ * type (DATE ∪ TEXT, BLOB ∪ TEXT, …): ANY's `parse` is pass-through and its
30
+ * `compare` is storage-class + BINARY ordering, and at a DML it is never
31
+ * identical to a declared column type, so every consumer converts — correct
32
+ * precisely because no branch is guaranteed to already be in target form.
33
+ */
34
+ import { PhysicalType } from '../../types/logical-type.js';
35
+ import { NULL_TYPE, INTEGER_TYPE, REAL_TYPE, NUMERIC_TYPE, ANY_TYPE } from '../../types/builtin-types.js';
36
+ /** The three builtin numeric types rule 3 accepts; any other numeric falls to ANY. */
37
+ function isBuiltinNumeric(t) {
38
+ return t === INTEGER_TYPE || t === REAL_TYPE || t === NUMERIC_TYPE;
39
+ }
40
+ /**
41
+ * Merge two set-op operand column logical types under rules 1–5 above.
42
+ * Symmetric: `merge(a, b).logicalType === merge(b, a).logicalType`, with
43
+ * `convert` flipping sides accordingly.
44
+ */
45
+ export function mergeSetOpColumnType(left, right) {
46
+ // 1. Identical (the registry hands out one instance per type).
47
+ if (left === right)
48
+ return { logicalType: left };
49
+ // 2. NULL is a member of every type; the other side's claim stands.
50
+ if (left === NULL_TYPE)
51
+ return { logicalType: right };
52
+ if (right === NULL_TYPE)
53
+ return { logicalType: left };
54
+ // 3. Any DIFFERING pair of builtin numerics → NUMERIC (rule 1 already consumed
55
+ // the identical pairs): `number | bigint` is the only builtin numeric value
56
+ // space the unconverted mixed stream inhabits. A non-builtin numeric type has
57
+ // no principled promotion — fall through to ANY (rule 5) rather than guess.
58
+ //
59
+ // Do NOT "restore consistency" with `BinaryOpNode.generateType` / `findCommonType`,
60
+ // which promote INTEGER + REAL to REAL — correct there (one value in one form),
61
+ // wrong here (a stream mixing both). Advertising REAL makes `buildRowCoercion`
62
+ // skip conversion on the identity match, landing a bigint unconverted in a
63
+ // REAL-declared column (ticket `set-op-numeric-promotion-skips-conversion`).
64
+ if (left.isNumeric && right.isNumeric) {
65
+ if (isBuiltinNumeric(left) && isBuiltinNumeric(right))
66
+ return { logicalType: NUMERIC_TYPE };
67
+ return { logicalType: ANY_TYPE };
68
+ }
69
+ // 4. Object-physical vs anything else: the object side wins and the other
70
+ // side converts. NULL was consumed by rule 2, so `convert` never targets a
71
+ // NULL-typed operand.
72
+ const leftObject = left.physicalType === PhysicalType.OBJECT;
73
+ const rightObject = right.physicalType === PhysicalType.OBJECT;
74
+ if (leftObject !== rightObject) {
75
+ return leftObject
76
+ ? { logicalType: left, convert: 'right' }
77
+ : { logicalType: right, convert: 'left' };
78
+ }
79
+ // 5. No principled common type.
80
+ return { logicalType: ANY_TYPE };
81
+ }
82
+ /**
83
+ * The logical type a set operation may HONESTLY advertise for a column pair
84
+ * when no operand conversion will be performed: the merge result, except a
85
+ * rule-4 pair collapses to ANY (advertising the object side's type over an
86
+ * unconverted text operand is exactly the defect this module exists to fix).
87
+ *
88
+ * `SetOperationNode` reads its output types through this: its factory aligns
89
+ * rule-4 operands with a lenient CAST up front, so an aligned tree hits rule 1
90
+ * here and the ANY collapse only fires for a pair the factory could not align
91
+ * (a flag-surfacing branch) or a hand-built unaligned tree.
92
+ */
93
+ export function mergeSetOpAdvertisedType(left, right) {
94
+ const merged = mergeSetOpColumnType(left, right);
95
+ return merged.convert ? ANY_TYPE : merged.logicalType;
96
+ }
97
+ //# sourceMappingURL=set-op-type-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-op-type-merge.js","sourceRoot":"","sources":["../../../../src/planner/analysis/set-op-type-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAc1G,sFAAsF;AACtF,SAAS,gBAAgB,CAAC,CA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IAC5C,CAAC;IAED,gCAAgC;IAChC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAiB,EAAE,KAAkB;IAC7E,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;AACvD,CAAC"}
@@ -0,0 +1,78 @@
1
+ import type { Scope } from '../scopes/scope.js';
2
+ import { CastNode } from '../nodes/scalar.js';
3
+ import type { ScalarPlanNode } from '../nodes/plan-node.js';
4
+ /**
5
+ * Plan-build cross-type coercion for comparison sites. Every construct that
6
+ * compares operands — `=` and friends, BETWEEN, IN value lists, simple CASE,
7
+ * and scalar builtins that declare a comparison group
8
+ * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}) —
9
+ * reconciles its operands through this one module so none of them can drift
10
+ * from the others.
11
+ */
12
+ /**
13
+ * Reconcile operands of a comparison whose plan-time types cannot be compared
14
+ * meaningfully as-is, by wrapping one side in a synthetic CastNode.
15
+ * Returns `[left, right]` — possibly with one side replaced by a CastNode.
16
+ *
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.
45
+ */
46
+ export declare function insertCrossTypeCoercion(scope: Scope, left: ScalarPlanNode, right: ScalarPlanNode): [ScalarPlanNode, ScalarPlanNode];
47
+ /**
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.
63
+ */
64
+ export declare function coerceObjectPhysicalSet(scope: Scope, probe: ScalarPlanNode, values: ScalarPlanNode[]): [ScalarPlanNode, ScalarPlanNode[]];
65
+ /**
66
+ * Apply {@link coerceObjectPhysicalSet} across the argument positions a scalar
67
+ * function declares as one comparison group
68
+ * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}),
69
+ * so `nullif(json_col, '{"a":1}')` reconciles its operands exactly as
70
+ * `json_col = '{"a":1}'` does. The group's first member plays the probe role and
71
+ * the rest the value-list role; positions outside the argument list are ignored
72
+ * (defensive — a well-formed declaration never names one). Mutates `args` in
73
+ * place, replacing coerced members with their CastNode wrappers.
74
+ */
75
+ export declare function coerceComparisonGroup(scope: Scope, comparesArgs: 'all' | readonly number[], args: ScalarPlanNode[]): void;
76
+ /** Create a synthetic CastNode wrapping `operand` with the given target type name. */
77
+ export declare function wrapInCast(scope: Scope, operand: ScalarPlanNode, targetType: string): CastNode;
78
+ //# sourceMappingURL=coercion.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,137 @@
1
+ import { CastNode } from '../nodes/scalar.js';
2
+ import { PhysicalType } from '../../types/logical-type.js';
3
+ import { NULL_TYPE } from '../../types/builtin-types.js';
4
+ /**
5
+ * Plan-build cross-type coercion for comparison sites. Every construct that
6
+ * compares operands — `=` and friends, BETWEEN, IN value lists, simple CASE,
7
+ * and scalar builtins that declare a comparison group
8
+ * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}) —
9
+ * reconciles its operands through this one module so none of them can drift
10
+ * from the others.
11
+ */
12
+ /**
13
+ * Reconcile operands of a comparison whose plan-time types cannot be compared
14
+ * meaningfully as-is, by wrapping one side in a synthetic CastNode.
15
+ * Returns `[left, right]` — possibly with one side replaced by a CastNode.
16
+ *
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.
45
+ */
46
+ export function insertCrossTypeCoercion(scope, left, right) {
47
+ const leftLogical = left.getType().logicalType;
48
+ const rightLogical = right.getType().logicalType;
49
+ const leftObject = leftLogical.physicalType === PhysicalType.OBJECT;
50
+ const rightObject = rightLogical.physicalType === PhysicalType.OBJECT;
51
+ // NOTE: two object-physical operands of DIFFERENT logical types fall through both
52
+ // arms onto the generic runtime path. Unreachable while JSON is the only
53
+ // PhysicalType.OBJECT type; adding a second one means deciding which side converts.
54
+ // Exactly one side is object-physical. A NULL-typed operand is left alone: the
55
+ // comparison is UNKNOWN regardless, so the cast would only add a runtime hop.
56
+ if (leftObject !== rightObject) {
57
+ if (leftObject && rightLogical !== NULL_TYPE) {
58
+ return [left, wrapInCast(scope, right, leftLogical.name)];
59
+ }
60
+ if (rightObject && leftLogical !== NULL_TYPE) {
61
+ return [wrapInCast(scope, left, rightLogical.name), right];
62
+ }
63
+ return [left, right];
64
+ }
65
+ const leftNumeric = !!leftLogical.isNumeric;
66
+ const rightNumeric = !!rightLogical.isNumeric;
67
+ const leftTextual = !!leftLogical.isTextual;
68
+ const rightTextual = !!rightLogical.isTextual;
69
+ if (leftNumeric && rightTextual) {
70
+ // Wrap right (textual) in a cast to the left's numeric type
71
+ return [left, wrapInCast(scope, right, leftLogical.name)];
72
+ }
73
+ if (rightNumeric && leftTextual) {
74
+ // Wrap left (textual) in a cast to the right's numeric type
75
+ return [wrapInCast(scope, left, rightLogical.name), right];
76
+ }
77
+ return [left, right];
78
+ }
79
+ /**
80
+ * Apply the object-physical arm of {@link insertCrossTypeCoercion} across the
81
+ * one-probe-against-many-values shape shared by an IN value list and a simple
82
+ * CASE, so `json_col in ('{"a":1}')` and `case json_col when '{"a":1}' …` agree
83
+ * with `json_col = '{"a":1}'`.
84
+ *
85
+ * Scoped to the object-physical pairing on purpose. The numeric ↔ textual arm has
86
+ * never been applied to either site (`int_col in ('1')` is false today for the same
87
+ * underlying reason), and turning it on here would change unrelated behavior; that
88
+ * case is tracked by `bug-numeric-text-coercion-skips-in-and-case`. Note `=` and
89
+ * BETWEEN DO apply it, so those two forms currently disagree with IN / simple CASE
90
+ * on a numeric column compared against a numeric-looking string.
91
+ *
92
+ * The probe is shared by every value, so it is wrapped at most once — if any value
93
+ * is object-physical while the probe is not, the probe is cast first and the values
94
+ * are then reconciled against it.
95
+ */
96
+ export function coerceObjectPhysicalSet(scope, probe, values) {
97
+ const isObject = (node) => node.getType().logicalType.physicalType === PhysicalType.OBJECT;
98
+ const objectValue = values.find(isObject);
99
+ if (!isObject(probe) && !objectValue)
100
+ return [probe, values];
101
+ const coercedProbe = isObject(probe)
102
+ ? probe
103
+ : wrapInCast(scope, probe, objectValue.getType().logicalType.name);
104
+ return [coercedProbe, values.map(val => insertCrossTypeCoercion(scope, coercedProbe, val)[1])];
105
+ }
106
+ /**
107
+ * Apply {@link coerceObjectPhysicalSet} across the argument positions a scalar
108
+ * function declares as one comparison group
109
+ * ({@link import('../../schema/function.js').BaseFunctionSchema.comparesArgs}),
110
+ * so `nullif(json_col, '{"a":1}')` reconciles its operands exactly as
111
+ * `json_col = '{"a":1}'` does. The group's first member plays the probe role and
112
+ * the rest the value-list role; positions outside the argument list are ignored
113
+ * (defensive — a well-formed declaration never names one). Mutates `args` in
114
+ * place, replacing coerced members with their CastNode wrappers.
115
+ */
116
+ export function coerceComparisonGroup(scope, comparesArgs, args) {
117
+ const indices = comparesArgs === 'all'
118
+ ? args.map((_, i) => i)
119
+ : comparesArgs.filter(i => i >= 0 && i < args.length);
120
+ if (indices.length < 2)
121
+ return;
122
+ const [probeIdx, ...valueIdx] = indices;
123
+ const [probe, values] = coerceObjectPhysicalSet(scope, args[probeIdx], valueIdx.map(i => args[i]));
124
+ args[probeIdx] = probe;
125
+ valueIdx.forEach((argIdx, j) => { args[argIdx] = values[j]; });
126
+ }
127
+ /** Create a synthetic CastNode wrapping `operand` with the given target type name. */
128
+ export function wrapInCast(scope, operand, targetType) {
129
+ // Synthesise a minimal AST.CastExpr — `targetType` is the only field CastNode reads.
130
+ const syntheticExpr = {
131
+ type: 'cast',
132
+ expr: { type: 'literal', value: null }, // placeholder
133
+ targetType,
134
+ };
135
+ return new CastNode(scope, syntheticExpr, operand);
136
+ }
137
+ //# sourceMappingURL=coercion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coercion.js","sourceRoot":"","sources":["../../../../src/planner/building/coercion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,uBAAuB,CACtC,KAAY,EACZ,IAAoB,EACpB,KAAqB;IAErB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC;IAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC;IAEjD,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,KAAK,YAAY,CAAC,MAAM,CAAC;IACpE,MAAM,WAAW,GAAG,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,MAAM,CAAC;IACtE,kFAAkF;IAClF,yEAAyE;IACzE,oFAAoF;IACpF,+EAA+E;IAC/E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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnG,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,UAAU,CACzB,KAAY,EACZ,OAAuB,EACvB,UAAkB;IAElB,qFAAqF;IACrF,MAAM,aAAa,GAAiB;QACnC,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAqB,EAAE,cAAc;QACzE,UAAU;KACV,CAAC;IACF,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC"}
@@ -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,CAyKnB;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;AAoBhD;;;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,CA0KnB;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,8 +1,8 @@
1
1
  import { RowOpFlag, writeRowRelationCorrelation } from '../../schema/table.js';
2
2
  import { RegisteredScope } from '../scopes/registered.js';
3
3
  import { buildExpression } from './expression.js';
4
- import { PlanNodeType } from '../nodes/plan-node-type.js';
5
4
  import { ColumnReferenceNode } from '../nodes/reference.js';
5
+ 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';
@@ -138,11 +138,12 @@ additionalConstraints = []) {
138
138
  if (!ctx.db.options.getBooleanOption('nondeterministic_schema')) {
139
139
  validateDeterministicConstraint(expression, constraintName, tableSchema.name);
140
140
  }
141
- // Heuristic: auto-defer if the expression contains a subquery
142
- // or references committed.* state (which necessarily implies a subquery, but
141
+ // Auto-defer when the expression reads a relation — a subquery of any shape
142
+ // means the check cannot be decided from the mutating row alone — or when it
143
+ // references committed.* state (which necessarily implies a subquery, but
143
144
  // this defensive check ensures committed-ref constraints are always deferred
144
145
  // even if subquery detection logic changes).
145
- const needsDeferred = containsSubquery(expression) || containsCommittedRef(expression);
146
+ const needsDeferred = hasRelationalDescendant(expression) || containsCommittedRef(expression);
146
147
  return {
147
148
  constraint,
148
149
  expression,
@@ -233,20 +234,6 @@ defaultRowContextScope) {
233
234
  }
234
235
  return result;
235
236
  }
236
- function containsSubquery(expr) {
237
- const stack = [expr];
238
- while (stack.length) {
239
- const n = stack.pop();
240
- if (n.nodeType === PlanNodeType.ScalarSubquery || n.nodeType === PlanNodeType.Exists) {
241
- return true;
242
- }
243
- for (const c of n.getChildren()) {
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
- stack.push(c);
246
- }
247
- }
248
- return false;
249
- }
250
237
  /**
251
238
  * Walks the full expression tree (descending into subquery plan children)
252
239
  * to find any TableReferenceNode with readCommitted === true.
@@ -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,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,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,EAA8B,MAAM,iCAAiC,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D;;GAEG;AACH,SAAS,qBAAqB,CAAC,UAA+B,EAAE,SAAoB;IAClF,2EAA2E;IAC3E,OAAO,CAAC,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAoB,EACpB,WAAwB,EACxB,SAAoB,EACpB,aAA0B,EAC1B,aAA0B,EAC1B,kBAAiC,EACjC,oBAAiC,EAAE;AACnC;;;;;GAKG;AACH,wBAA4D,EAAE;IAE9D,sDAAsD;IACtD,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AAW,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAoB;IAC5C,MAAM,KAAK,GAAqB,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QACvB,IAAI,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,cAAc,IAAI,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;YACrF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAChC,8DAA8D;YAC9D,KAAK,CAAC,IAAI,CAAC,CAAQ,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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,EAA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AAW,EAAE,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1 +1 @@
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,EAAoF,MAAM,uBAAuB,CAAC;AASnI,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAiB5E,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,CAgTV"}
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,EAAoF,MAAM,uBAAuB,CAAC;AASnI,OAAO,EAAa,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAiB5E,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,CAuTV"}
@@ -17,7 +17,7 @@ import { buildOldNewRowDescriptors } from '../../util/row-descriptor.js';
17
17
  import { DmlExecutorNode } from '../nodes/dml-executor-node.js';
18
18
  import { buildConstraintChecks } from './constraint-builder.js';
19
19
  import { columnSchemaToScalarType } from '../type-utils.js';
20
- import { buildParentSideFKChecks } from './foreign-key-builder.js';
20
+ import { buildParentSideFKChecks, getBatchableRestrictFks } from './foreign-key-builder.js';
21
21
  import { validateReturningQualifiers } from '../validation/returning-qualifier-validator.js';
22
22
  import { isCommittedSchemaRef } from './schema-resolution.js';
23
23
  import { buildViewMutation } from './view-mutation-builder.js';
@@ -179,8 +179,15 @@ lensRouted = false) {
179
179
  }
180
180
  // Build constraint checks at plan time
181
181
  const constraintChecks = buildConstraintChecks(deleteCtx, tableReference.tableSchema, RowOpFlag.DELETE, oldAttributes, newAttributes, flatRowDescriptor, contextAttributes, additionalConstraints);
182
- // Build parent-side FK constraint checks if foreign_keys pragma is enabled
183
- if (ctx.db.options.getBooleanOption('foreign_keys')) {
182
+ // Build parent-side FK constraint checks if foreign_keys pragma is enabled.
183
+ // Skipped entirely when the batchability gate admits the statement — the
184
+ // runtime DML executor then enforces every inbound RESTRICT FK with ONE
185
+ // chunked probe per FK at the end-of-statement boundary instead of one
186
+ // correlated NOT EXISTS per row (see getBatchableRestrictFks). DELETE has no
187
+ // statement-level OR clause, so the effective conflict resolution is the
188
+ // ABORT default (matching the `undefined` onConflict on the DmlExecutorNode).
189
+ if (ctx.db.options.getBooleanOption('foreign_keys')
190
+ && getBatchableRestrictFks(ctx.schemaManager, tableReference.tableSchema, 'delete', undefined, lensRouted) === undefined) {
184
191
  const parentFKChecks = buildParentSideFKChecks(ctx, tableReference.tableSchema, RowOpFlag.DELETE, oldAttributes, newAttributes, contextAttributes);
185
192
  constraintChecks.push(...parentFKChecks);
186
193
  }