@quereus/quereus 4.3.1 → 4.4.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 (788) hide show
  1. package/README.md +25 -7
  2. package/dist/src/common/types.d.ts +9 -59
  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-assertions.d.ts +2 -2
  6. package/dist/src/core/database-assertions.d.ts.map +1 -1
  7. package/dist/src/core/database-assertions.js +4 -3
  8. package/dist/src/core/database-assertions.js.map +1 -1
  9. package/dist/src/core/database-external-changes.d.ts +3 -3
  10. package/dist/src/core/database-external-changes.d.ts.map +1 -1
  11. package/dist/src/core/database-external-changes.js +13 -10
  12. package/dist/src/core/database-external-changes.js.map +1 -1
  13. package/dist/src/core/database-internal.d.ts.map +1 -1
  14. package/dist/src/core/database-materialized-views-analysis.d.ts +199 -0
  15. package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -0
  16. package/dist/src/core/database-materialized-views-analysis.js +502 -0
  17. package/dist/src/core/database-materialized-views-analysis.js.map +1 -0
  18. package/dist/src/core/database-materialized-views-apply.d.ts +422 -0
  19. package/dist/src/core/database-materialized-views-apply.d.ts.map +1 -0
  20. package/dist/src/core/database-materialized-views-apply.js +929 -0
  21. package/dist/src/core/database-materialized-views-apply.js.map +1 -0
  22. package/dist/src/core/database-materialized-views-plan-builders.d.ts +267 -0
  23. package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -0
  24. package/dist/src/core/database-materialized-views-plan-builders.js +1423 -0
  25. package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -0
  26. package/dist/src/core/database-materialized-views-plans.d.ts +641 -0
  27. package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -0
  28. package/dist/src/core/database-materialized-views-plans.js +13 -0
  29. package/dist/src/core/database-materialized-views-plans.js.map +1 -0
  30. package/dist/src/core/database-materialized-views.d.ts +108 -860
  31. package/dist/src/core/database-materialized-views.d.ts.map +1 -1
  32. package/dist/src/core/database-materialized-views.js +212 -2165
  33. package/dist/src/core/database-materialized-views.js.map +1 -1
  34. package/dist/src/core/database-transaction.d.ts +10 -1
  35. package/dist/src/core/database-transaction.d.ts.map +1 -1
  36. package/dist/src/core/database-transaction.js +16 -4
  37. package/dist/src/core/database-transaction.js.map +1 -1
  38. package/dist/src/core/database-watchers.d.ts.map +1 -1
  39. package/dist/src/core/database-watchers.js +2 -1
  40. package/dist/src/core/database-watchers.js.map +1 -1
  41. package/dist/src/core/database.d.ts +99 -13
  42. package/dist/src/core/database.d.ts.map +1 -1
  43. package/dist/src/core/database.js +270 -50
  44. package/dist/src/core/database.js.map +1 -1
  45. package/dist/src/core/derived-row-validator.d.ts +1 -1
  46. package/dist/src/core/derived-row-validator.d.ts.map +1 -1
  47. package/dist/src/core/derived-row-validator.js +5 -3
  48. package/dist/src/core/derived-row-validator.js.map +1 -1
  49. package/dist/src/core/statement.d.ts +8 -0
  50. package/dist/src/core/statement.d.ts.map +1 -1
  51. package/dist/src/core/statement.js +98 -18
  52. package/dist/src/core/statement.js.map +1 -1
  53. package/dist/src/emit/ast-stringify.d.ts.map +1 -1
  54. package/dist/src/emit/ast-stringify.js +24 -13
  55. package/dist/src/emit/ast-stringify.js.map +1 -1
  56. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  57. package/dist/src/func/builtins/aggregate.js +127 -21
  58. package/dist/src/func/builtins/aggregate.js.map +1 -1
  59. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  60. package/dist/src/func/builtins/explain.js +2 -1
  61. package/dist/src/func/builtins/explain.js.map +1 -1
  62. package/dist/src/func/builtins/json.d.ts.map +1 -1
  63. package/dist/src/func/builtins/json.js +2 -1
  64. package/dist/src/func/builtins/json.js.map +1 -1
  65. package/dist/src/func/builtins/mutation.d.ts.map +1 -1
  66. package/dist/src/func/builtins/mutation.js +3 -2
  67. package/dist/src/func/builtins/mutation.js.map +1 -1
  68. package/dist/src/func/registration.d.ts +6 -1
  69. package/dist/src/func/registration.d.ts.map +1 -1
  70. package/dist/src/func/registration.js +16 -0
  71. package/dist/src/func/registration.js.map +1 -1
  72. package/dist/src/index.d.ts +16 -6
  73. package/dist/src/index.d.ts.map +1 -1
  74. package/dist/src/index.js +33 -7
  75. package/dist/src/index.js.map +1 -1
  76. package/dist/src/parser/ast.d.ts +2 -2
  77. package/dist/src/parser/lexer.d.ts +11 -1
  78. package/dist/src/parser/lexer.d.ts.map +1 -1
  79. package/dist/src/parser/lexer.js +40 -34
  80. package/dist/src/parser/lexer.js.map +1 -1
  81. package/dist/src/parser/parser.d.ts.map +1 -1
  82. package/dist/src/parser/parser.js +16 -9
  83. package/dist/src/parser/parser.js.map +1 -1
  84. package/dist/src/planner/analysis/authored-inverse.js +1 -1
  85. package/dist/src/planner/analysis/comparison-collation.d.ts +52 -0
  86. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
  87. package/dist/src/planner/analysis/comparison-collation.js +84 -7
  88. package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
  89. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  90. package/dist/src/planner/analysis/constraint-extractor.js +64 -17
  91. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  92. package/dist/src/planner/analysis/coverage-prover.d.ts +1 -1
  93. package/dist/src/planner/analysis/coverage-prover.js +1 -1
  94. package/dist/src/planner/analysis/equi-correlation.d.ts +26 -0
  95. package/dist/src/planner/analysis/equi-correlation.d.ts.map +1 -0
  96. package/dist/src/planner/analysis/equi-correlation.js +62 -0
  97. package/dist/src/planner/analysis/equi-correlation.js.map +1 -0
  98. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +54 -18
  99. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
  100. package/dist/src/planner/analysis/query-rewrite-matcher.js +86 -42
  101. package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
  102. package/dist/src/planner/analysis/sat-checker.d.ts +8 -1
  103. package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -1
  104. package/dist/src/planner/analysis/sat-checker.js +117 -22
  105. package/dist/src/planner/analysis/sat-checker.js.map +1 -1
  106. package/dist/src/planner/analysis/scalar-invertibility.d.ts +13 -4
  107. package/dist/src/planner/analysis/scalar-invertibility.d.ts.map +1 -1
  108. package/dist/src/planner/analysis/scalar-invertibility.js +12 -3
  109. package/dist/src/planner/analysis/scalar-invertibility.js.map +1 -1
  110. package/dist/src/planner/analysis/scalar-subqueries.d.ts +28 -0
  111. package/dist/src/planner/analysis/scalar-subqueries.d.ts.map +1 -0
  112. package/dist/src/planner/analysis/scalar-subqueries.js +60 -0
  113. package/dist/src/planner/analysis/scalar-subqueries.js.map +1 -0
  114. package/dist/src/planner/analysis/update-lineage.d.ts +1 -1
  115. package/dist/src/planner/analysis/update-lineage.js +1 -1
  116. package/dist/src/planner/analysis/update-lineage.js.map +1 -1
  117. package/dist/src/planner/analysis/view-complement.d.ts +2 -2
  118. package/dist/src/planner/building/delete.js +2 -2
  119. package/dist/src/planner/building/delete.js.map +1 -1
  120. package/dist/src/planner/building/dml-target.d.ts +2 -2
  121. package/dist/src/planner/building/dml-target.js +2 -2
  122. package/dist/src/planner/building/insert.d.ts.map +1 -1
  123. package/dist/src/planner/building/insert.js +53 -2
  124. package/dist/src/planner/building/insert.js.map +1 -1
  125. package/dist/src/planner/building/schema-resolution.d.ts +3 -0
  126. package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
  127. package/dist/src/planner/building/schema-resolution.js +4 -5
  128. package/dist/src/planner/building/schema-resolution.js.map +1 -1
  129. package/dist/src/planner/building/select.d.ts.map +1 -1
  130. package/dist/src/planner/building/select.js +18 -4
  131. package/dist/src/planner/building/select.js.map +1 -1
  132. package/dist/src/planner/building/update.js +2 -2
  133. package/dist/src/planner/building/update.js.map +1 -1
  134. package/dist/src/planner/building/view-mutation-builder.js +7 -7
  135. package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
  136. package/dist/src/planner/building/with.d.ts.map +1 -1
  137. package/dist/src/planner/building/with.js +5 -8
  138. package/dist/src/planner/building/with.js.map +1 -1
  139. package/dist/src/planner/cache/materialization-advisory.d.ts +34 -2
  140. package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
  141. package/dist/src/planner/cache/materialization-advisory.js +185 -42
  142. package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
  143. package/dist/src/planner/cache/reference-graph.d.ts +14 -5
  144. package/dist/src/planner/cache/reference-graph.d.ts.map +1 -1
  145. package/dist/src/planner/cache/reference-graph.js +31 -39
  146. package/dist/src/planner/cache/reference-graph.js.map +1 -1
  147. package/dist/src/planner/cost/index.d.ts +30 -5
  148. package/dist/src/planner/cost/index.d.ts.map +1 -1
  149. package/dist/src/planner/cost/index.js +26 -0
  150. package/dist/src/planner/cost/index.js.map +1 -1
  151. package/dist/src/planner/debug.d.ts +3 -2
  152. package/dist/src/planner/debug.d.ts.map +1 -1
  153. package/dist/src/planner/debug.js +9 -3
  154. package/dist/src/planner/debug.js.map +1 -1
  155. package/dist/src/planner/framework/characteristics.d.ts +46 -19
  156. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  157. package/dist/src/planner/framework/characteristics.js +50 -134
  158. package/dist/src/planner/framework/characteristics.js.map +1 -1
  159. package/dist/src/planner/framework/context.d.ts +8 -44
  160. package/dist/src/planner/framework/context.d.ts.map +1 -1
  161. package/dist/src/planner/framework/context.js +0 -91
  162. package/dist/src/planner/framework/context.js.map +1 -1
  163. package/dist/src/planner/framework/pass.d.ts +7 -0
  164. package/dist/src/planner/framework/pass.d.ts.map +1 -1
  165. package/dist/src/planner/framework/pass.js +84 -0
  166. package/dist/src/planner/framework/pass.js.map +1 -1
  167. package/dist/src/planner/framework/registry.d.ts +13 -42
  168. package/dist/src/planner/framework/registry.d.ts.map +1 -1
  169. package/dist/src/planner/framework/registry.js +14 -182
  170. package/dist/src/planner/framework/registry.js.map +1 -1
  171. package/dist/src/planner/mutation/backward-body.d.ts +2 -2
  172. package/dist/src/planner/mutation/cte-flatten.js +1 -1
  173. package/dist/src/planner/mutation/decomposition.d.ts +2 -2
  174. package/dist/src/planner/mutation/decomposition.js +1 -1
  175. package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
  176. package/dist/src/planner/mutation/lens-enforcement.js +2 -1
  177. package/dist/src/planner/mutation/lens-enforcement.js.map +1 -1
  178. package/dist/src/planner/mutation/multi-source.d.ts +8 -8
  179. package/dist/src/planner/mutation/multi-source.js +11 -11
  180. package/dist/src/planner/mutation/multi-source.js.map +1 -1
  181. package/dist/src/planner/mutation/propagate.d.ts +1 -1
  182. package/dist/src/planner/mutation/propagate.js +1 -1
  183. package/dist/src/planner/mutation/scope-transform.d.ts +2 -2
  184. package/dist/src/planner/mutation/scope-transform.js +3 -3
  185. package/dist/src/planner/mutation/scope-transform.js.map +1 -1
  186. package/dist/src/planner/mutation/set-op.d.ts +1 -1
  187. package/dist/src/planner/mutation/set-op.d.ts.map +1 -1
  188. package/dist/src/planner/mutation/set-op.js +3 -2
  189. package/dist/src/planner/mutation/set-op.js.map +1 -1
  190. package/dist/src/planner/mutation/single-source.d.ts +3 -3
  191. package/dist/src/planner/mutation/single-source.js +9 -9
  192. package/dist/src/planner/mutation/single-source.js.map +1 -1
  193. package/dist/src/planner/nodes/aggregate-function.d.ts +3 -1
  194. package/dist/src/planner/nodes/aggregate-function.d.ts.map +1 -1
  195. package/dist/src/planner/nodes/aggregate-function.js +1 -0
  196. package/dist/src/planner/nodes/aggregate-function.js.map +1 -1
  197. package/dist/src/planner/nodes/aggregate-node.d.ts +1 -0
  198. package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
  199. package/dist/src/planner/nodes/aggregate-node.js +8 -1
  200. package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
  201. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  202. package/dist/src/planner/nodes/alias-node.js +3 -1
  203. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  204. package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
  205. package/dist/src/planner/nodes/asof-scan-node.js +3 -2
  206. package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
  207. package/dist/src/planner/nodes/asserted-keys-node.d.ts +1 -1
  208. package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
  209. package/dist/src/planner/nodes/asserted-keys-node.js +5 -2
  210. package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
  211. package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
  212. package/dist/src/planner/nodes/async-gather-node.js +3 -1
  213. package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
  214. package/dist/src/planner/nodes/block.js +3 -3
  215. package/dist/src/planner/nodes/block.js.map +1 -1
  216. package/dist/src/planner/nodes/bloom-join-node.d.ts +2 -0
  217. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  218. package/dist/src/planner/nodes/bloom-join-node.js +5 -1
  219. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  220. package/dist/src/planner/nodes/cache-node.d.ts +19 -2
  221. package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
  222. package/dist/src/planner/nodes/cache-node.js +43 -3
  223. package/dist/src/planner/nodes/cache-node.js.map +1 -1
  224. package/dist/src/planner/nodes/cte-node.d.ts +16 -1
  225. package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
  226. package/dist/src/planner/nodes/cte-node.js +16 -3
  227. package/dist/src/planner/nodes/cte-node.js.map +1 -1
  228. package/dist/src/planner/nodes/distinct-node.js +3 -3
  229. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  230. package/dist/src/planner/nodes/dml-executor-node.d.ts +21 -0
  231. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  232. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  233. package/dist/src/planner/nodes/envelope-scan-node.d.ts +1 -1
  234. package/dist/src/planner/nodes/envelope-scan-node.js +1 -1
  235. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
  236. package/dist/src/planner/nodes/fanout-lookup-join-node.js +4 -2
  237. package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
  238. package/dist/src/planner/nodes/filter.d.ts +10 -2
  239. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  240. package/dist/src/planner/nodes/filter.js +81 -14
  241. package/dist/src/planner/nodes/filter.js.map +1 -1
  242. package/dist/src/planner/nodes/hash-aggregate.d.ts +12 -1
  243. package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
  244. package/dist/src/planner/nodes/hash-aggregate.js +28 -1
  245. package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
  246. package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts +3 -1
  247. package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts.map +1 -1
  248. package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js +1 -0
  249. package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +1 -1
  250. package/dist/src/planner/nodes/join-node.d.ts +3 -1
  251. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  252. package/dist/src/planner/nodes/join-node.js +5 -5
  253. package/dist/src/planner/nodes/join-node.js.map +1 -1
  254. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
  255. package/dist/src/planner/nodes/lens-auxiliary-access-node.js +4 -1
  256. package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
  257. package/dist/src/planner/nodes/limit-offset.d.ts +1 -0
  258. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  259. package/dist/src/planner/nodes/limit-offset.js +4 -3
  260. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  261. package/dist/src/planner/nodes/merge-join-node.d.ts +2 -0
  262. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  263. package/dist/src/planner/nodes/merge-join-node.js +6 -1
  264. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  265. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
  266. package/dist/src/planner/nodes/ordinal-slice-node.js +3 -1
  267. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
  268. package/dist/src/planner/nodes/plan-node.d.ts +68 -5
  269. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  270. package/dist/src/planner/nodes/plan-node.js +137 -24
  271. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  272. package/dist/src/planner/nodes/project-node.d.ts +3 -2
  273. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  274. package/dist/src/planner/nodes/project-node.js +1 -0
  275. package/dist/src/planner/nodes/project-node.js.map +1 -1
  276. package/dist/src/planner/nodes/recursive-cte-node.d.ts +30 -1
  277. package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
  278. package/dist/src/planner/nodes/recursive-cte-node.js +38 -5
  279. package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
  280. package/dist/src/planner/nodes/reference.d.ts +5 -1
  281. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  282. package/dist/src/planner/nodes/reference.js +3 -0
  283. package/dist/src/planner/nodes/reference.js.map +1 -1
  284. package/dist/src/planner/nodes/remote-query-node.d.ts.map +1 -1
  285. package/dist/src/planner/nodes/remote-query-node.js +3 -1
  286. package/dist/src/planner/nodes/remote-query-node.js.map +1 -1
  287. package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
  288. package/dist/src/planner/nodes/retrieve-node.js +3 -1
  289. package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
  290. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  291. package/dist/src/planner/nodes/set-operation-node.js +3 -1
  292. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  293. package/dist/src/planner/nodes/sink-node.d.ts.map +1 -1
  294. package/dist/src/planner/nodes/sink-node.js +3 -1
  295. package/dist/src/planner/nodes/sink-node.js.map +1 -1
  296. package/dist/src/planner/nodes/sort.d.ts +2 -1
  297. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  298. package/dist/src/planner/nodes/sort.js +9 -5
  299. package/dist/src/planner/nodes/sort.js.map +1 -1
  300. package/dist/src/planner/nodes/stream-aggregate.d.ts +12 -1
  301. package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
  302. package/dist/src/planner/nodes/stream-aggregate.js +32 -3
  303. package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
  304. package/dist/src/planner/nodes/table-access-nodes.d.ts +2 -1
  305. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  306. package/dist/src/planner/nodes/table-access-nodes.js +2 -0
  307. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  308. package/dist/src/planner/nodes/view-mutation-node.d.ts +2 -2
  309. package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
  310. package/dist/src/planner/nodes/view-mutation-node.js +5 -1
  311. package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
  312. package/dist/src/planner/nodes/window-function.d.ts +3 -1
  313. package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
  314. package/dist/src/planner/nodes/window-function.js +1 -0
  315. package/dist/src/planner/nodes/window-function.js.map +1 -1
  316. package/dist/src/planner/optimizer.d.ts +52 -8
  317. package/dist/src/planner/optimizer.d.ts.map +1 -1
  318. package/dist/src/planner/optimizer.js +1014 -895
  319. package/dist/src/planner/optimizer.js.map +1 -1
  320. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  321. package/dist/src/planner/rules/access/rule-select-access-path.js +235 -202
  322. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  323. package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
  324. package/dist/src/planner/rules/cache/rule-cte-optimization.js +8 -1
  325. package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
  326. package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts +7 -0
  327. package/dist/src/planner/rules/cache/rule-in-subquery-cache.d.ts.map +1 -1
  328. package/dist/src/planner/rules/cache/rule-in-subquery-cache.js +14 -1
  329. package/dist/src/planner/rules/cache/rule-in-subquery-cache.js.map +1 -1
  330. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts +2 -2
  331. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts.map +1 -1
  332. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +55 -56
  333. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
  334. package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.d.ts.map +1 -1
  335. package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js +6 -0
  336. package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +1 -1
  337. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts +25 -0
  338. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -0
  339. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +176 -0
  340. package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -0
  341. package/dist/src/planner/rules/cache/rule-scalar-cse.d.ts +1 -1
  342. package/dist/src/planner/rules/cache/rule-scalar-cse.js +1 -1
  343. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts +29 -0
  344. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.d.ts.map +1 -0
  345. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js +66 -0
  346. package/dist/src/planner/rules/cache/rule-scalar-subquery-cache.js.map +1 -0
  347. package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts +1 -1
  348. package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +1 -1
  349. package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
  350. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +1 -54
  351. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
  352. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.d.ts +1 -1
  353. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.js +1 -1
  354. package/dist/src/planner/rules/join/rule-join-elimination.d.ts +1 -1
  355. package/dist/src/planner/rules/join/rule-join-elimination.js +1 -1
  356. package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js +5 -6
  357. package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js.map +1 -1
  358. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +1 -1
  359. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +1 -1
  360. package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts +2 -2
  361. package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts.map +1 -1
  362. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js +4 -3
  363. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js.map +1 -1
  364. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +19 -0
  365. package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -0
  366. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +48 -0
  367. package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -0
  368. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js +12 -1
  369. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js.map +1 -1
  370. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
  371. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +22 -20
  372. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  373. package/dist/src/planner/rules/shared/index-style-context.d.ts +39 -0
  374. package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -0
  375. package/dist/src/planner/rules/shared/index-style-context.js +26 -0
  376. package/dist/src/planner/rules/shared/index-style-context.js.map +1 -0
  377. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts +1 -1
  378. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js +1 -1
  379. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts +1 -1
  380. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +1 -1
  381. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.d.ts +191 -0
  382. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.d.ts.map +1 -0
  383. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js +623 -0
  384. package/dist/src/planner/rules/subquery/rule-scalar-agg-decorrelation.js.map +1 -0
  385. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts +10 -1
  386. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  387. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +242 -51
  388. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  389. package/dist/src/planner/stats/analyze.d.ts.map +1 -1
  390. package/dist/src/planner/stats/analyze.js +2 -20
  391. package/dist/src/planner/stats/analyze.js.map +1 -1
  392. package/dist/src/planner/stats/histogram.d.ts.map +1 -1
  393. package/dist/src/planner/stats/histogram.js +4 -0
  394. package/dist/src/planner/stats/histogram.js.map +1 -1
  395. package/dist/src/planner/util/fd-utils.d.ts +2 -3
  396. package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
  397. package/dist/src/planner/util/fd-utils.js +2 -3
  398. package/dist/src/planner/util/fd-utils.js.map +1 -1
  399. package/dist/src/planner/validation/plan-validator.d.ts +16 -0
  400. package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
  401. package/dist/src/planner/validation/plan-validator.js +36 -0
  402. package/dist/src/planner/validation/plan-validator.js.map +1 -1
  403. package/dist/src/runtime/async-util.d.ts +26 -0
  404. package/dist/src/runtime/async-util.d.ts.map +1 -1
  405. package/dist/src/runtime/async-util.js +139 -55
  406. package/dist/src/runtime/async-util.js.map +1 -1
  407. package/dist/src/runtime/cache/shared-cache.d.ts +7 -0
  408. package/dist/src/runtime/cache/shared-cache.d.ts.map +1 -1
  409. package/dist/src/runtime/cache/shared-cache.js +34 -1
  410. package/dist/src/runtime/cache/shared-cache.js.map +1 -1
  411. package/dist/src/runtime/context-helpers.d.ts +32 -4
  412. package/dist/src/runtime/context-helpers.d.ts.map +1 -1
  413. package/dist/src/runtime/context-helpers.js +26 -9
  414. package/dist/src/runtime/context-helpers.js.map +1 -1
  415. package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
  416. package/dist/src/runtime/deferred-constraint-queue.js +2 -1
  417. package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
  418. package/dist/src/runtime/emission-context.d.ts +27 -3
  419. package/dist/src/runtime/emission-context.d.ts.map +1 -1
  420. package/dist/src/runtime/emission-context.js +38 -7
  421. package/dist/src/runtime/emission-context.js.map +1 -1
  422. package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
  423. package/dist/src/runtime/emit/add-constraint.js +7 -1
  424. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  425. package/dist/src/runtime/emit/aggregate.d.ts +2 -3
  426. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  427. package/dist/src/runtime/emit/aggregate.js +23 -28
  428. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  429. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  430. package/dist/src/runtime/emit/alter-table.js +98 -9
  431. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  432. package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
  433. package/dist/src/runtime/emit/analyze.js +2 -1
  434. package/dist/src/runtime/emit/analyze.js.map +1 -1
  435. package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
  436. package/dist/src/runtime/emit/asof-scan.js +13 -10
  437. package/dist/src/runtime/emit/asof-scan.js.map +1 -1
  438. package/dist/src/runtime/emit/async-gather.d.ts.map +1 -1
  439. package/dist/src/runtime/emit/async-gather.js +4 -3
  440. package/dist/src/runtime/emit/async-gather.js.map +1 -1
  441. package/dist/src/runtime/emit/between.d.ts.map +1 -1
  442. package/dist/src/runtime/emit/between.js +2 -1
  443. package/dist/src/runtime/emit/between.js.map +1 -1
  444. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  445. package/dist/src/runtime/emit/binary.js +122 -14
  446. package/dist/src/runtime/emit/binary.js.map +1 -1
  447. package/dist/src/runtime/emit/block.d.ts.map +1 -1
  448. package/dist/src/runtime/emit/block.js +2 -1
  449. package/dist/src/runtime/emit/block.js.map +1 -1
  450. package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
  451. package/dist/src/runtime/emit/bloom-join.js +20 -8
  452. package/dist/src/runtime/emit/bloom-join.js.map +1 -1
  453. package/dist/src/runtime/emit/cache.d.ts +7 -3
  454. package/dist/src/runtime/emit/cache.d.ts.map +1 -1
  455. package/dist/src/runtime/emit/cache.js +25 -7
  456. package/dist/src/runtime/emit/cache.js.map +1 -1
  457. package/dist/src/runtime/emit/case.d.ts.map +1 -1
  458. package/dist/src/runtime/emit/case.js +66 -45
  459. package/dist/src/runtime/emit/case.js.map +1 -1
  460. package/dist/src/runtime/emit/cast.d.ts.map +1 -1
  461. package/dist/src/runtime/emit/cast.js +2 -1
  462. package/dist/src/runtime/emit/cast.js.map +1 -1
  463. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  464. package/dist/src/runtime/emit/constraint-check.js +13 -7
  465. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  466. package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
  467. package/dist/src/runtime/emit/create-assertion.js +2 -1
  468. package/dist/src/runtime/emit/create-assertion.js.map +1 -1
  469. package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
  470. package/dist/src/runtime/emit/create-index.js +12 -1
  471. package/dist/src/runtime/emit/create-index.js.map +1 -1
  472. package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
  473. package/dist/src/runtime/emit/create-table.js +12 -1
  474. package/dist/src/runtime/emit/create-table.js.map +1 -1
  475. package/dist/src/runtime/emit/cte-reference.d.ts.map +1 -1
  476. package/dist/src/runtime/emit/cte-reference.js +2 -1
  477. package/dist/src/runtime/emit/cte-reference.js.map +1 -1
  478. package/dist/src/runtime/emit/cte.d.ts.map +1 -1
  479. package/dist/src/runtime/emit/cte.js +45 -21
  480. package/dist/src/runtime/emit/cte.js.map +1 -1
  481. package/dist/src/runtime/emit/ddl-transaction-policy.d.ts +50 -0
  482. package/dist/src/runtime/emit/ddl-transaction-policy.d.ts.map +1 -0
  483. package/dist/src/runtime/emit/ddl-transaction-policy.js +69 -0
  484. package/dist/src/runtime/emit/ddl-transaction-policy.js.map +1 -0
  485. package/dist/src/runtime/emit/delete.d.ts.map +1 -1
  486. package/dist/src/runtime/emit/delete.js +2 -1
  487. package/dist/src/runtime/emit/delete.js.map +1 -1
  488. package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
  489. package/dist/src/runtime/emit/distinct.js +2 -1
  490. package/dist/src/runtime/emit/distinct.js.map +1 -1
  491. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  492. package/dist/src/runtime/emit/dml-executor.js +138 -74
  493. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  494. package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
  495. package/dist/src/runtime/emit/drop-assertion.js +2 -1
  496. package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
  497. package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
  498. package/dist/src/runtime/emit/drop-index.js +17 -1
  499. package/dist/src/runtime/emit/drop-index.js.map +1 -1
  500. package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
  501. package/dist/src/runtime/emit/drop-table.js +11 -1
  502. package/dist/src/runtime/emit/drop-table.js.map +1 -1
  503. package/dist/src/runtime/emit/eager-prefetch.d.ts.map +1 -1
  504. package/dist/src/runtime/emit/eager-prefetch.js +2 -1
  505. package/dist/src/runtime/emit/eager-prefetch.js.map +1 -1
  506. package/dist/src/runtime/emit/envelope-scan.d.ts.map +1 -1
  507. package/dist/src/runtime/emit/envelope-scan.js +2 -1
  508. package/dist/src/runtime/emit/envelope-scan.js.map +1 -1
  509. package/dist/src/runtime/emit/fanout-lookup-join.d.ts.map +1 -1
  510. package/dist/src/runtime/emit/fanout-lookup-join.js +3 -2
  511. package/dist/src/runtime/emit/fanout-lookup-join.js.map +1 -1
  512. package/dist/src/runtime/emit/filter.d.ts.map +1 -1
  513. package/dist/src/runtime/emit/filter.js +8 -3
  514. package/dist/src/runtime/emit/filter.js.map +1 -1
  515. package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
  516. package/dist/src/runtime/emit/hash-aggregate.js +16 -11
  517. package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
  518. package/dist/src/runtime/emit/insert.d.ts.map +1 -1
  519. package/dist/src/runtime/emit/insert.js +2 -1
  520. package/dist/src/runtime/emit/insert.js.map +1 -1
  521. package/dist/src/runtime/emit/join.d.ts.map +1 -1
  522. package/dist/src/runtime/emit/join.js +20 -6
  523. package/dist/src/runtime/emit/join.js.map +1 -1
  524. package/dist/src/runtime/emit/limit-offset.d.ts.map +1 -1
  525. package/dist/src/runtime/emit/limit-offset.js +2 -1
  526. package/dist/src/runtime/emit/limit-offset.js.map +1 -1
  527. package/dist/src/runtime/emit/literal.d.ts.map +1 -1
  528. package/dist/src/runtime/emit/literal.js +2 -1
  529. package/dist/src/runtime/emit/literal.js.map +1 -1
  530. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +22 -0
  531. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  532. package/dist/src/runtime/emit/materialized-view-helpers.js +128 -16
  533. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  534. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
  535. package/dist/src/runtime/emit/materialized-view.js +6 -0
  536. package/dist/src/runtime/emit/materialized-view.js.map +1 -1
  537. package/dist/src/runtime/emit/merge-join.d.ts.map +1 -1
  538. package/dist/src/runtime/emit/merge-join.js +14 -4
  539. package/dist/src/runtime/emit/merge-join.js.map +1 -1
  540. package/dist/src/runtime/emit/ordinal-slice.d.ts.map +1 -1
  541. package/dist/src/runtime/emit/ordinal-slice.js +2 -1
  542. package/dist/src/runtime/emit/ordinal-slice.js.map +1 -1
  543. package/dist/src/runtime/emit/pragma.d.ts.map +1 -1
  544. package/dist/src/runtime/emit/pragma.js +2 -1
  545. package/dist/src/runtime/emit/pragma.js.map +1 -1
  546. package/dist/src/runtime/emit/project.d.ts.map +1 -1
  547. package/dist/src/runtime/emit/project.js +7 -2
  548. package/dist/src/runtime/emit/project.js.map +1 -1
  549. package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
  550. package/dist/src/runtime/emit/recursive-cte.js +61 -2
  551. package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
  552. package/dist/src/runtime/emit/returning.d.ts.map +1 -1
  553. package/dist/src/runtime/emit/returning.js +7 -2
  554. package/dist/src/runtime/emit/returning.js.map +1 -1
  555. package/dist/src/runtime/emit/scalar-function.d.ts.map +1 -1
  556. package/dist/src/runtime/emit/scalar-function.js +2 -1
  557. package/dist/src/runtime/emit/scalar-function.js.map +1 -1
  558. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  559. package/dist/src/runtime/emit/scan.js +55 -17
  560. package/dist/src/runtime/emit/scan.js.map +1 -1
  561. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  562. package/dist/src/runtime/emit/schema-declarative.js +6 -5
  563. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  564. package/dist/src/runtime/emit/sequencing.d.ts.map +1 -1
  565. package/dist/src/runtime/emit/sequencing.js +2 -1
  566. package/dist/src/runtime/emit/sequencing.js.map +1 -1
  567. package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
  568. package/dist/src/runtime/emit/set-operation.js +6 -5
  569. package/dist/src/runtime/emit/set-operation.js.map +1 -1
  570. package/dist/src/runtime/emit/sink.d.ts.map +1 -1
  571. package/dist/src/runtime/emit/sink.js +2 -1
  572. package/dist/src/runtime/emit/sink.js.map +1 -1
  573. package/dist/src/runtime/emit/sort.d.ts.map +1 -1
  574. package/dist/src/runtime/emit/sort.js +2 -1
  575. package/dist/src/runtime/emit/sort.js.map +1 -1
  576. package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
  577. package/dist/src/runtime/emit/subquery.js +42 -23
  578. package/dist/src/runtime/emit/subquery.js.map +1 -1
  579. package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
  580. package/dist/src/runtime/emit/table-valued-function.js +2 -1
  581. package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
  582. package/dist/src/runtime/emit/temporal-arithmetic.d.ts.map +1 -1
  583. package/dist/src/runtime/emit/temporal-arithmetic.js +2 -1
  584. package/dist/src/runtime/emit/temporal-arithmetic.js.map +1 -1
  585. package/dist/src/runtime/emit/transaction.d.ts.map +1 -1
  586. package/dist/src/runtime/emit/transaction.js +2 -1
  587. package/dist/src/runtime/emit/transaction.js.map +1 -1
  588. package/dist/src/runtime/emit/unary.d.ts.map +1 -1
  589. package/dist/src/runtime/emit/unary.js +2 -1
  590. package/dist/src/runtime/emit/unary.js.map +1 -1
  591. package/dist/src/runtime/emit/update.d.ts.map +1 -1
  592. package/dist/src/runtime/emit/update.js +2 -1
  593. package/dist/src/runtime/emit/update.js.map +1 -1
  594. package/dist/src/runtime/emit/values.d.ts.map +1 -1
  595. package/dist/src/runtime/emit/values.js +2 -1
  596. package/dist/src/runtime/emit/values.js.map +1 -1
  597. package/dist/src/runtime/emit/view-mutation.d.ts +1 -1
  598. package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
  599. package/dist/src/runtime/emit/view-mutation.js +6 -3
  600. package/dist/src/runtime/emit/view-mutation.js.map +1 -1
  601. package/dist/src/runtime/emit/window.d.ts.map +1 -1
  602. package/dist/src/runtime/emit/window.js +26 -9
  603. package/dist/src/runtime/emit/window.js.map +1 -1
  604. package/dist/src/runtime/emitters.d.ts +11 -3
  605. package/dist/src/runtime/emitters.d.ts.map +1 -1
  606. package/dist/src/runtime/emitters.js +13 -22
  607. package/dist/src/runtime/emitters.js.map +1 -1
  608. package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
  609. package/dist/src/runtime/foreign-key-actions.js +39 -13
  610. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  611. package/dist/src/runtime/parallel-driver.d.ts +32 -4
  612. package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
  613. package/dist/src/runtime/parallel-driver.js +88 -18
  614. package/dist/src/runtime/parallel-driver.js.map +1 -1
  615. package/dist/src/runtime/scheduler.d.ts +56 -7
  616. package/dist/src/runtime/scheduler.d.ts.map +1 -1
  617. package/dist/src/runtime/scheduler.js +223 -200
  618. package/dist/src/runtime/scheduler.js.map +1 -1
  619. package/dist/src/runtime/strict-flags.d.ts +22 -0
  620. package/dist/src/runtime/strict-flags.d.ts.map +1 -0
  621. package/dist/src/runtime/strict-flags.js +26 -0
  622. package/dist/src/runtime/strict-flags.js.map +1 -0
  623. package/dist/src/runtime/strict-fork.d.ts +4 -4
  624. package/dist/src/runtime/strict-fork.d.ts.map +1 -1
  625. package/dist/src/runtime/strict-fork.js +175 -31
  626. package/dist/src/runtime/strict-fork.js.map +1 -1
  627. package/dist/src/runtime/types.d.ts +102 -4
  628. package/dist/src/runtime/types.d.ts.map +1 -1
  629. package/dist/src/runtime/types.js +37 -0
  630. package/dist/src/runtime/types.js.map +1 -1
  631. package/dist/src/runtime/utils.d.ts.map +1 -1
  632. package/dist/src/runtime/utils.js +8 -17
  633. package/dist/src/runtime/utils.js.map +1 -1
  634. package/dist/src/schema/column.d.ts +8 -0
  635. package/dist/src/schema/column.d.ts.map +1 -1
  636. package/dist/src/schema/column.js.map +1 -1
  637. package/dist/src/schema/ddl-generator.js +5 -0
  638. package/dist/src/schema/ddl-generator.js.map +1 -1
  639. package/dist/src/schema/function.d.ts +79 -0
  640. package/dist/src/schema/function.d.ts.map +1 -1
  641. package/dist/src/schema/function.js.map +1 -1
  642. package/dist/src/schema/lens-compiler.js +2 -2
  643. package/dist/src/schema/lens-compiler.js.map +1 -1
  644. package/dist/src/schema/lens-prover.d.ts.map +1 -1
  645. package/dist/src/schema/lens-prover.js +2 -3
  646. package/dist/src/schema/lens-prover.js.map +1 -1
  647. package/dist/src/schema/lens.d.ts +1 -1
  648. package/dist/src/schema/manager.d.ts.map +1 -1
  649. package/dist/src/schema/manager.js +7 -2
  650. package/dist/src/schema/manager.js.map +1 -1
  651. package/dist/src/schema/rename-rewriter.d.ts +61 -0
  652. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  653. package/dist/src/schema/rename-rewriter.js +77 -0
  654. package/dist/src/schema/rename-rewriter.js.map +1 -1
  655. package/dist/src/schema/table.d.ts +36 -8
  656. package/dist/src/schema/table.d.ts.map +1 -1
  657. package/dist/src/schema/table.js +61 -11
  658. package/dist/src/schema/table.js.map +1 -1
  659. package/dist/src/schema/unique-enforcement.d.ts +28 -5
  660. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  661. package/dist/src/schema/unique-enforcement.js +37 -5
  662. package/dist/src/schema/unique-enforcement.js.map +1 -1
  663. package/dist/src/schema/view.d.ts +1 -1
  664. package/dist/src/schema/view.js +1 -1
  665. package/dist/src/types/json-type.d.ts.map +1 -1
  666. package/dist/src/types/json-type.js +18 -8
  667. package/dist/src/types/json-type.js.map +1 -1
  668. package/dist/src/types/logical-type.d.ts +26 -0
  669. package/dist/src/types/logical-type.d.ts.map +1 -1
  670. package/dist/src/types/logical-type.js.map +1 -1
  671. package/dist/src/util/comparison.d.ts +83 -59
  672. package/dist/src/util/comparison.d.ts.map +1 -1
  673. package/dist/src/util/comparison.js +191 -131
  674. package/dist/src/util/comparison.js.map +1 -1
  675. package/dist/src/util/json-canonical.d.ts +34 -0
  676. package/dist/src/util/json-canonical.d.ts.map +1 -0
  677. package/dist/src/util/json-canonical.js +32 -0
  678. package/dist/src/util/json-canonical.js.map +1 -0
  679. package/dist/src/util/key-serializer.d.ts +10 -3
  680. package/dist/src/util/key-serializer.d.ts.map +1 -1
  681. package/dist/src/util/key-serializer.js +43 -17
  682. package/dist/src/util/key-serializer.js.map +1 -1
  683. package/dist/src/util/key-tuple-codec.d.ts +37 -0
  684. package/dist/src/util/key-tuple-codec.d.ts.map +1 -0
  685. package/dist/src/util/key-tuple-codec.js +65 -0
  686. package/dist/src/util/key-tuple-codec.js.map +1 -0
  687. package/dist/src/util/latches.d.ts +29 -3
  688. package/dist/src/util/latches.d.ts.map +1 -1
  689. package/dist/src/util/latches.js +60 -6
  690. package/dist/src/util/latches.js.map +1 -1
  691. package/dist/src/util/patterns.d.ts +22 -8
  692. package/dist/src/util/patterns.d.ts.map +1 -1
  693. package/dist/src/util/patterns.js +87 -16
  694. package/dist/src/util/patterns.js.map +1 -1
  695. package/dist/src/util/qualified-name.d.ts +10 -0
  696. package/dist/src/util/qualified-name.d.ts.map +1 -0
  697. package/dist/src/util/qualified-name.js +15 -0
  698. package/dist/src/util/qualified-name.js.map +1 -0
  699. package/dist/src/vtab/backing-host.d.ts +8 -1
  700. package/dist/src/vtab/backing-host.d.ts.map +1 -1
  701. package/dist/src/vtab/backing-host.js +7 -0
  702. package/dist/src/vtab/backing-host.js.map +1 -1
  703. package/dist/src/vtab/best-access-plan.d.ts +18 -0
  704. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  705. package/dist/src/vtab/best-access-plan.js +15 -0
  706. package/dist/src/vtab/best-access-plan.js.map +1 -1
  707. package/dist/src/vtab/capabilities.d.ts +44 -0
  708. package/dist/src/vtab/capabilities.d.ts.map +1 -1
  709. package/dist/src/vtab/filter-info.d.ts +42 -0
  710. package/dist/src/vtab/filter-info.d.ts.map +1 -1
  711. package/dist/src/vtab/filter-info.js +137 -1
  712. package/dist/src/vtab/filter-info.js.map +1 -1
  713. package/dist/src/vtab/idx-str.d.ts +62 -0
  714. package/dist/src/vtab/idx-str.d.ts.map +1 -0
  715. package/dist/src/vtab/idx-str.js +130 -0
  716. package/dist/src/vtab/idx-str.js.map +1 -0
  717. package/dist/src/vtab/index-descriptor.d.ts +122 -0
  718. package/dist/src/vtab/index-descriptor.d.ts.map +1 -0
  719. package/dist/src/vtab/index-descriptor.js +104 -0
  720. package/dist/src/vtab/index-descriptor.js.map +1 -0
  721. package/dist/src/vtab/mapping-advertisement.d.ts +1 -1
  722. package/dist/src/vtab/memory/index.d.ts +12 -4
  723. package/dist/src/vtab/memory/index.d.ts.map +1 -1
  724. package/dist/src/vtab/memory/index.js +17 -9
  725. package/dist/src/vtab/memory/index.js.map +1 -1
  726. package/dist/src/vtab/memory/layer/base.d.ts +85 -31
  727. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  728. package/dist/src/vtab/memory/layer/base.js +127 -86
  729. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  730. package/dist/src/vtab/memory/layer/connection.d.ts +27 -0
  731. package/dist/src/vtab/memory/layer/connection.d.ts.map +1 -1
  732. package/dist/src/vtab/memory/layer/connection.js +36 -1
  733. package/dist/src/vtab/memory/layer/connection.js.map +1 -1
  734. package/dist/src/vtab/memory/layer/interface.d.ts +24 -4
  735. package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
  736. package/dist/src/vtab/memory/layer/manager.d.ts +212 -16
  737. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  738. package/dist/src/vtab/memory/layer/manager.js +754 -170
  739. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  740. package/dist/src/vtab/memory/layer/plan-filter.d.ts +26 -1
  741. package/dist/src/vtab/memory/layer/plan-filter.d.ts.map +1 -1
  742. package/dist/src/vtab/memory/layer/plan-filter.js +29 -11
  743. package/dist/src/vtab/memory/layer/plan-filter.js.map +1 -1
  744. package/dist/src/vtab/memory/layer/safe-iterate.d.ts +2 -2
  745. package/dist/src/vtab/memory/layer/safe-iterate.d.ts.map +1 -1
  746. package/dist/src/vtab/memory/layer/safe-iterate.js +2 -2
  747. package/dist/src/vtab/memory/layer/safe-iterate.js.map +1 -1
  748. package/dist/src/vtab/memory/layer/scan-layer.d.ts +5 -1
  749. package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
  750. package/dist/src/vtab/memory/layer/scan-layer.js +59 -24
  751. package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
  752. package/dist/src/vtab/memory/layer/scan-plan.d.ts.map +1 -1
  753. package/dist/src/vtab/memory/layer/scan-plan.js +13 -21
  754. package/dist/src/vtab/memory/layer/scan-plan.js.map +1 -1
  755. package/dist/src/vtab/memory/layer/transaction.d.ts +169 -7
  756. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  757. package/dist/src/vtab/memory/layer/transaction.js +334 -9
  758. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  759. package/dist/src/vtab/memory/module.d.ts +11 -4
  760. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  761. package/dist/src/vtab/memory/module.js +35 -16
  762. package/dist/src/vtab/memory/module.js.map +1 -1
  763. package/dist/src/vtab/memory/table.d.ts +30 -4
  764. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  765. package/dist/src/vtab/memory/table.js +63 -15
  766. package/dist/src/vtab/memory/table.js.map +1 -1
  767. package/dist/src/vtab/memory/utils/predicate.d.ts +9 -1
  768. package/dist/src/vtab/memory/utils/predicate.d.ts.map +1 -1
  769. package/dist/src/vtab/memory/utils/predicate.js +35 -14
  770. package/dist/src/vtab/memory/utils/predicate.js.map +1 -1
  771. package/dist/src/vtab/memory/utils/primary-key-encode.d.ts.map +1 -1
  772. package/dist/src/vtab/memory/utils/primary-key-encode.js +12 -6
  773. package/dist/src/vtab/memory/utils/primary-key-encode.js.map +1 -1
  774. package/dist/src/vtab/memory/utils/primary-key.d.ts +6 -1
  775. package/dist/src/vtab/memory/utils/primary-key.d.ts.map +1 -1
  776. package/dist/src/vtab/memory/utils/primary-key.js +12 -8
  777. package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
  778. package/dist/src/vtab/module.d.ts +38 -14
  779. package/dist/src/vtab/module.d.ts.map +1 -1
  780. package/dist/src/vtab/table.d.ts +41 -2
  781. package/dist/src/vtab/table.d.ts.map +1 -1
  782. package/dist/src/vtab/table.js +19 -0
  783. package/dist/src/vtab/table.js.map +1 -1
  784. package/package.json +5 -4
  785. package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts +0 -18
  786. package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts.map +0 -1
  787. package/dist/src/planner/rules/cache/rule-materialization-advisory.js +0 -65
  788. package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"strict-fork.d.ts","sourceRoot":"","sources":["../../../src/runtime/strict-fork.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,eAAe,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAwBrD,oFAAoF;AACpF,UAAU,SAAS;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAQD,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAUD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,GACpC,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,CAkBnC;AAqBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,aAAa,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAI9D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAMzE;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAGnE"}
1
+ {"version":3,"file":"strict-fork.d.ts","sourceRoot":"","sources":["../../../src/runtime/strict-fork.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA4B,eAAe,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,aAAa,EAA4C,MAAM,sBAAsB,CAAC;AAiC/F,oFAAoF;AACpF,UAAU,SAAS;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAQD,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAUD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,GACpC,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,CAkBnC;AAwHD;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,aAAa,CAQzD;AAuCD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAI9D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAMzE;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAGnE"}
@@ -1,26 +1,35 @@
1
1
  import { QuereusError } from '../common/errors.js';
2
2
  import { StatusCode } from '../common/types.js';
3
- import { RowContextMap } from './context-helpers.js';
3
+ import { RowContextMap, descriptorEntries } from './context-helpers.js';
4
+ import { FORK_STRICT, CONTEXT_STRICT } from './strict-flags.js';
4
5
  /**
5
- * Strict-fork test harness.
6
+ * Strict test harnesses for the runtime context.
6
7
  *
7
- * Production behavior is unchanged: when `QUEREUS_FORK_STRICT` is unset, every
8
- * helper here is a no-op pass-through. When set, the helpers wrap each
9
- * RuntimeContext's `tableContexts` and `context` maps so that mutating the
10
- * *parent* while one of its forks is being driven throws a contract violation.
8
+ * Two independent, off-by-default concerns share the one `RowContextMap`
9
+ * subclass and the one `createStrictRowContextMap()` factory (so the ~9
10
+ * RuntimeContext construction sites wire both at once):
11
11
  *
12
- * State is tracked **per parent map** (not globally) so that:
13
- * - concurrent unrelated drivers don't interfere,
14
- * - forks may mutate their own (fresh, fork-local) maps freely,
15
- * - sub-forks (fork of a fork) are independently tracked.
12
+ * 1. **`QUEREUS_FORK_STRICT`** parent-immutability during a fork's lifetime.
13
+ * Wraps `tableContexts` / `context` so mutating the *parent* while one of its
14
+ * forks is being driven throws. State is tracked **per parent map** (not
15
+ * globally) so concurrent unrelated drivers don't interfere, forks may mutate
16
+ * their own fresh maps freely, and sub-forks are independently tracked.
17
+ * See docs/runtime.md § Parallel runtime fork contract.
16
18
  *
17
- * See docs/runtime.md § Parallel runtime fork contract for the rules this
18
- * harness enforces.
19
+ * 2. **`QUEREUS_CONTEXT_STRICT`** stale-shadow detection. Maintains a per-
20
+ * descriptor epoch and a per-attribute index-winner map so `assertNoShadow`
21
+ * (called from `resolveAttribute`) can catch a streaming operator that left a
22
+ * stale source-attr context winning the `attributeIndex` while a child set a
23
+ * newer row for the same IDs. See docs/runtime.md § Invariant: source-attr
24
+ * contexts and child pulls, and § Strict context-shadow test mode.
25
+ *
26
+ * Production behavior is unchanged: when both flags are unset, every helper here
27
+ * is a no-op pass-through and `createStrictRowContextMap()` returns a vanilla
28
+ * `RowContextMap`.
19
29
  */
20
- // Cross-platform guard: `process` is unavailable in browser / RN / edge workers.
21
- // Strict mode is a Node-only test harness, so silently disable elsewhere.
22
- const flag = typeof process !== 'undefined' ? process.env?.QUEREUS_FORK_STRICT : undefined;
23
- const STRICT_MODE = flag === '1' || flag === 'true';
30
+ // `STRICT_MODE` retains the fork-strict meaning it had before context-strict was
31
+ // added, so the fork-contract code below reads unchanged.
32
+ const STRICT_MODE = FORK_STRICT;
24
33
  /** Wrapped map → its state. Used by the proxy/subclass to know when to throw. */
25
34
  const stateByWrappedMap = new WeakMap();
26
35
  /** Forked map → state of the parent map it was forked from. Used by drive() to bump parent. */
@@ -59,37 +68,172 @@ export function wrapTableContextsStrict(map) {
59
68
  stateByWrappedMap.set(proxy, state);
60
69
  return proxy;
61
70
  }
71
+ /**
72
+ * `RowContextMap` subclass carrying the state for both strict harnesses. The
73
+ * fork-strict guard fires only when `forkState` is non-null (fork-strict on); the
74
+ * context-strict bookkeeping runs only when `CONTEXT_STRICT`. Either concern may
75
+ * be active without the other.
76
+ */
62
77
  class StrictRowContextMap extends RowContextMap {
78
+ /** Fork-strict state, or null when only context-strict is active. */
63
79
  forkState;
64
- constructor(state) {
80
+ // --- context-strict (QUEREUS_CONTEXT_STRICT) bookkeeping; touched only when the
81
+ // flag is on. A monotonic clock keeps every epoch unique, so the winner is
82
+ // unambiguously the max-epoch live context for an attr. ---
83
+ clock = 0;
84
+ /** Per-descriptor epoch of its most recent set() or noteRowSet() (slot.set). */
85
+ epoch = new Map();
86
+ /** attrId → descriptor currently winning the attributeIndex, kept in lockstep. */
87
+ winnerByAttr = [];
88
+ /** Best-effort installer label per descriptor, for diagnostics only. */
89
+ installer = new Map();
90
+ constructor(forkState) {
65
91
  super();
66
- this.forkState = state;
92
+ this.forkState = forkState;
67
93
  }
68
- set(descriptor, rowGetter) {
69
- if (this.forkState.activeForks > 0)
94
+ set(descriptor, rowGetter, installer) {
95
+ if (this.forkState && this.forkState.activeForks > 0)
70
96
  violation('context (RowContextMap)', this.forkState.activeForks);
71
- return super.set(descriptor, rowGetter);
97
+ const ret = super.set(descriptor, rowGetter, installer);
98
+ if (CONTEXT_STRICT) {
99
+ // A fresh set() reclaims the index for these attrs (mirrors super.set's
100
+ // attributeIndex rebuild) AND bumps the descriptor's epoch.
101
+ this.epoch.set(descriptor, ++this.clock);
102
+ if (installer !== undefined)
103
+ this.installer.set(descriptor, installer);
104
+ for (const [attrId] of descriptorEntries(descriptor)) {
105
+ this.winnerByAttr[attrId] = descriptor;
106
+ }
107
+ }
108
+ return ret;
72
109
  }
73
110
  delete(descriptor) {
74
- if (this.forkState.activeForks > 0)
111
+ if (this.forkState && this.forkState.activeForks > 0)
75
112
  violation('context (RowContextMap)', this.forkState.activeForks);
76
- return super.delete(descriptor);
113
+ if (!CONTEXT_STRICT)
114
+ return super.delete(descriptor);
115
+ // Capture affected attrs before removal so we can rebuild winnerByAttr in the
116
+ // same forward-iteration (last-wins) order super.delete rebuilds attributeIndex.
117
+ const affected = [];
118
+ for (const [attrId] of descriptorEntries(descriptor))
119
+ affected.push(attrId);
120
+ const result = super.delete(descriptor);
121
+ this.epoch.delete(descriptor);
122
+ this.installer.delete(descriptor);
123
+ for (const attrId of affected)
124
+ this.winnerByAttr[attrId] = undefined;
125
+ for (const [desc] of this.entries()) {
126
+ for (const attrId of affected) {
127
+ if (desc[attrId] !== undefined)
128
+ this.winnerByAttr[attrId] = desc;
129
+ }
130
+ }
131
+ return result;
77
132
  }
133
+ // `noteRowSet` / `assertNoShadow` are arrow-function instance fields (not prototype
134
+ // methods) so they cleanly override the base's `declare`d optional properties under
135
+ // `useDefineForClassFields`.
136
+ /**
137
+ * Per-row `slot.set` notification: bump the descriptor's epoch only. The winner
138
+ * is deliberately **not** touched — `slot.set` does not reclaim the
139
+ * attributeIndex, and that asymmetry is exactly the stale-shadow this harness
140
+ * detects.
141
+ */
142
+ noteRowSet = (descriptor) => {
143
+ this.epoch.set(descriptor, ++this.clock);
144
+ };
145
+ /**
146
+ * Assert the attribute-index winner for `attributeId` is the most-recently-set
147
+ * live context for it. Throws when a *different* live context carries the same
148
+ * attr with a strictly-newer row update **whose value for this attr differs** —
149
+ * the operator-shadows-child silent wrong-row.
150
+ *
151
+ * The value comparison is the load-bearing refinement over pure recency. A wider
152
+ * projection legitimately re-carries a source attribute (e.g. a nested-loop join
153
+ * output `[...left, ...right]` still exposes the left row's `d.id`) in a fresh,
154
+ * newer row object that agrees on the shared column. A read resolves the same
155
+ * value through either context, so it is not observably wrong — only a *differing*
156
+ * value at the resolved column is a silent wrong-row worth failing on.
157
+ */
158
+ assertNoShadow = (attributeId, columnName, rctx) => {
159
+ const winnerDesc = this.winnerByAttr[attributeId];
160
+ if (winnerDesc === undefined)
161
+ return; // no index entry — nothing can shadow
162
+ // Skip when the winner's own row is unpopulated: resolveAttribute falls back
163
+ // to a newest→oldest scan then, so the index winner is not actually read.
164
+ const winnerCol = winnerDesc[attributeId];
165
+ const winnerRow = this.get(winnerDesc)?.();
166
+ if (winnerCol === undefined || !Array.isArray(winnerRow) || winnerCol >= winnerRow.length)
167
+ return;
168
+ const winnerVal = winnerRow[winnerCol];
169
+ const winnerEpoch = this.epoch.get(winnerDesc) ?? -1;
170
+ for (const [desc, getter] of this.entries()) {
171
+ if (desc === winnerDesc)
172
+ continue;
173
+ const col = desc[attributeId];
174
+ if (col === undefined)
175
+ continue; // doesn't carry this attr
176
+ if ((this.epoch.get(desc) ?? -1) <= winnerEpoch)
177
+ continue; // not newer than winner
178
+ const row = getter();
179
+ if (!Array.isArray(row) || col >= row.length)
180
+ continue; // unpopulated candidate — skip
181
+ // `desc` is a strictly-newer live context for this attr. If it resolves the
182
+ // same value the read is not observably wrong regardless of which wins — only
183
+ // a differing value is the silent wrong-row this harness exists to catch.
184
+ // NOTE: `===` is reference equality for blobs (Uint8Array), so two distinct
185
+ // blob objects with identical bytes at a shared column would false-positive
186
+ // here (test-mode only, never observed in the suite). If it ever trips, swap
187
+ // this shared-column check for a value-aware SQL comparison (compareSqlValues).
188
+ if (row[col] === winnerVal)
189
+ continue;
190
+ throw contextShadowError(attributeId, columnName, winnerDesc, desc, this.installer, rctx);
191
+ }
192
+ };
78
193
  }
79
194
  /**
80
- * Construct a `RowContextMap`. In strict mode returns a subclass that throws
81
- * on set/delete while forks of it are being driven; otherwise returns the
82
- * vanilla map. Use at any RuntimeContext construction site instead of
83
- * `new RowContextMap()`.
195
+ * Construct a `RowContextMap`. Returns the strict subclass when either strict flag
196
+ * is on (fork-strict wraps set/delete against parent mutation; context-strict adds
197
+ * shadow bookkeeping); otherwise the vanilla map. Use at any RuntimeContext
198
+ * construction site instead of `new RowContextMap()`.
84
199
  */
85
200
  export function createStrictRowContextMap() {
86
- if (!STRICT_MODE)
201
+ if (!STRICT_MODE && !CONTEXT_STRICT)
87
202
  return new RowContextMap();
88
- const state = { activeForks: 0 };
89
- const map = new StrictRowContextMap(state);
90
- stateByWrappedMap.set(map, state);
203
+ // Fork state exists only under fork-strict; context-strict-only maps pass a null
204
+ // fork state (the guard is inert) and are not registered for fork bookkeeping.
205
+ const forkState = STRICT_MODE ? { activeForks: 0 } : null;
206
+ const map = new StrictRowContextMap(forkState);
207
+ if (forkState)
208
+ stateByWrappedMap.set(map, forkState);
91
209
  return map;
92
210
  }
211
+ /** Render a descriptor for diagnostics: its installer label if threaded, else its attr-ID list. */
212
+ function describeDescriptor(descriptor, installer) {
213
+ const label = installer.get(descriptor);
214
+ if (label !== undefined) {
215
+ return typeof label === 'string' ? label : `${label.nodeType}#${label.id}`;
216
+ }
217
+ const attrs = [];
218
+ for (const [attrId] of descriptorEntries(descriptor))
219
+ attrs.push(attrId);
220
+ return `attrs=[${attrs.join(',')}]`;
221
+ }
222
+ function contextShadowError(attributeId, columnName, winnerDesc, shadowDesc, installer, rctx) {
223
+ const col = columnName ? `${columnName} (attr#${attributeId})` : `attr#${attributeId}`;
224
+ const winner = describeDescriptor(winnerDesc, installer);
225
+ const shadow = describeDescriptor(shadowDesc, installer);
226
+ // Best-effort reading operator: planStack top, populated only when tracing is on.
227
+ const stack = rctx.planStack;
228
+ const reader = stack && stack.length > 0
229
+ ? `${stack[stack.length - 1].nodeType}#${stack[stack.length - 1].id}`
230
+ : 'unknown (planStack empty; enable trace-plan-stack)';
231
+ return new QuereusError(`context-strict: stale-shadow on column ${col}. The attribute index still points at the ` +
232
+ `context installed by ${winner} (stale row), but a strictly-newer row was set on the ` +
233
+ `context installed by ${shadow}. A read here resolves to the stale row — a silent wrong-row. ` +
234
+ `Reading operator: ${reader}. A streaming operator must release its source-attr context before ` +
235
+ `pulling its child; see docs/runtime.md § Invariant: source-attr contexts and child pulls.`, StatusCode.INTERNAL);
236
+ }
93
237
  /**
94
238
  * Record that `child` was forked from `parent`. The child carries a hidden
95
239
  * reference back to the parent's ForkState so drive() can bump it.
@@ -1 +1 @@
1
- {"version":3,"file":"strict-fork.js","sourceRoot":"","sources":["../../../src/runtime/strict-fork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AAEH,iFAAiF;AACjF,0EAA0E;AAC1E,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,MAAM,WAAW,GAAG,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,CAAC;AAOpD,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAE3D,+FAA+F;AAC/F,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAE3D,MAAM,UAAU,iBAAiB;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,KAAa;IAC/C,MAAM,IAAI,YAAY,CACrB,uCAAuC,MAAM,UAAU,KAAK,uBAAuB;QACnF,0FAA0F,EAC1F,UAAU,CAAC,QAAQ,CACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAsC;IAEtC,IAAI,CAAC,WAAW;QAAE,OAAO,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAc,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAC5C,MA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,wDAAwD;QACtF,wBAAwB,MAAM,gEAAgE;QAC9F,qBAAqB,MAAM,qEAAqE;QAChG,2FAA2F,EAC3F,UAAU,CAAC,QAAQ,CACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,MAAc;IACvD,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,MAAM,WAAW,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,WAAW;QAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACtD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,KAAK,CAAC,WAAW,EAAE,CAAC;IACpB,OAAO,KAAK,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,qBAAqB,CAAC,KAAuB;IAC5D,IAAI,CAAC,WAAW,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC3C,KAAK,CAAC,WAAW,EAAE,CAAC;AACrB,CAAC"}
@@ -3,10 +3,11 @@ import type { Database } from "../core/database.js";
3
3
  import type { Statement } from "../core/statement.js";
4
4
  import type { RowDescriptor, TableDescriptor, TableGetter } from "../planner/nodes/plan-node.js";
5
5
  import type { Scheduler } from "./scheduler.js";
6
- import type { EmissionContext } from "./emission-context.js";
7
6
  import type { VirtualTableConnection } from "../vtab/connection.js";
7
+ import type { VirtualTable } from "../vtab/table.js";
8
8
  import type { PlanNode } from '../planner/nodes/plan-node.js';
9
9
  import type { RowContextMap } from './context-helpers.js';
10
+ import type { CacheState } from './cache/shared-cache.js';
10
11
  export type { OutputValue };
11
12
  export type RuntimeContext = {
12
13
  db: Database;
@@ -33,7 +34,7 @@ export type RuntimeContext = {
33
34
  * The 1-based ordinal of the row currently being produced within the active
34
35
  * INSERT / mutation-context evaluation, or undefined outside one. Exposed to
35
36
  * the `mutation_ordinal()` builtin so a column `default` can author a per-row
36
- * surrogate (the shared-key-via-default case — docs/view-updateability.md
37
+ * surrogate (the shared-key-via-default case — docs/vu-mutation-context.md
37
38
  * § Mutation Context). Set per row by the INSERT DML executor and by the
38
39
  * shared-surrogate envelope (`runtime/emit/view-mutation.ts`), and saved/
39
40
  * restored around each scope so it never leaks past the statement.
@@ -43,6 +44,70 @@ export type RuntimeContext = {
43
44
  contextTracker?: ContextTracker;
44
45
  /** Stack of currently executing plan nodes (only when tracing enabled) */
45
46
  planStack?: PlanNode[];
47
+ /**
48
+ * Per-execution memo for instructions that must fire exactly once per statement
49
+ * execution — the impure (DML-bearing) scalar/`IN`/`EXISTS` subquery emitters
50
+ * store their drained result here, keyed by a unique symbol minted at emit time.
51
+ * Because a fresh RuntimeContext is built for each execution while the instruction
52
+ * tree is cached and reused, tying the memo to the context (not the emit-time
53
+ * closure) makes it reset between prepared-statement runs — so a re-executed
54
+ * statement re-drives its inner DML, rather than replaying the first run's result.
55
+ */
56
+ executionMemo?: Map<symbol, {
57
+ value: SqlValue;
58
+ }>;
59
+ /**
60
+ * Per-execution cache of connected inner-scan virtual-table instances, keyed by
61
+ * a stable per-scan-node symbol minted in the {@link emitSeqScan} closure. A
62
+ * nested-loop join re-scans its (un-cached) inner relation once per outer row;
63
+ * without this, each re-scan would `module.connect(...)` + `disconnect(...)` the
64
+ * inner table afresh. The scan connects once per scan-site per execution, reuses
65
+ * the instance across every re-scan, and statement teardown disconnects each
66
+ * cached instance exactly once (see core/statement.ts `_iterateRowsRawInternal`).
67
+ *
68
+ * Keyed by scan-node identity (not table name) so a self-join's two scan sites
69
+ * over one table get distinct instances and never share a cursor — the re-scans
70
+ * of one site are sequential (the NLJ drains each inner cursor before the next
71
+ * outer row), so a single instance is never concurrently self-live. Absent on the
72
+ * transient/analysis RuntimeContexts that don't set it — the scan then falls back
73
+ * to connect-and-disconnect per invocation (correct, just no reuse).
74
+ */
75
+ scanConnections?: Map<symbol, VirtualTable>;
76
+ /**
77
+ * Per-execution materialized-row cache state for {@link emitCache}, keyed by a
78
+ * stable symbol minted in that emitter's closure. A fresh RuntimeContext is
79
+ * built for each execution while the instruction tree (and the emitter closure
80
+ * that mints the key) is cached and reused on the prepared Statement, so tying
81
+ * the cache to the context — not the closure — makes it reset between
82
+ * prepared-statement runs: a re-executed statement re-drives its cached source
83
+ * and observes current data instead of replaying the first run's rows. Within
84
+ * one execution, the same key still resolves to the same {@link CacheState},
85
+ * so the cache materializes once and replays across re-scans (e.g. per-outer-row
86
+ * `IN`-subquery evaluation). Mirrors the {@link executionMemo}/{@link scanConnections}
87
+ * pattern.
88
+ */
89
+ cacheStates?: Map<symbol, CacheState>;
90
+ /**
91
+ * Per-execution CTE materialization buffers, keyed by whatever stable identity
92
+ * the emitter shares across the CTE's references, buffering the CTE's rows
93
+ * exactly once per statement execution: the first reference to run stores the
94
+ * buffer promise synchronously and drives the source; every other reference
95
+ * awaits that same promise and never touches its own (separately-emitted)
96
+ * source subtree. A fresh RuntimeContext per execution resets the map between
97
+ * prepared-statement runs (no stale replay). Mirrors {@link cacheStates}.
98
+ *
99
+ * Two key kinds coexist here (their key spaces never collide — string vs
100
+ * object):
101
+ * - {@link emitCTE} keys by the shared CTENode's plan id (a string); all
102
+ * non-recursive references share one CTENode instance, so their closures
103
+ * agree on the key.
104
+ * - {@link emitRecursiveCTE} keys by the shared `TableDescriptor` object. A
105
+ * multi-referenced recursive CTE is DUPLICATED into distinct RecursiveCTENode
106
+ * instances by earlier optimizer passes (distinct plan ids), but every copy
107
+ * preserves the one `tableDescriptor` identity through `withChildren`, so the
108
+ * descriptor — not the plan id — is what the copies agree on.
109
+ */
110
+ cteMaterializations?: Map<string | TableDescriptor, Promise<Row[]>>;
46
111
  };
47
112
  export type InstructionRun = (ctx: RuntimeContext, ...args: RuntimeValue[]) => OutputValue;
48
113
  export type Instruction = {
@@ -52,11 +117,44 @@ export type Instruction = {
52
117
  note?: string;
53
118
  /** Optional sub-programs used to execute this instruction - this is here for tracing purposes */
54
119
  programs?: Scheduler[];
55
- /** Optional emission context for schema validation */
56
- emissionContext?: EmissionContext;
57
120
  /** Optional runtime statistics collected during execution */
58
121
  runtimeStats?: InstructionRuntimeStats;
59
122
  };
123
+ /**
124
+ * Adapts an emitter's precisely-typed `run` (e.g.
125
+ * `(ctx, v1: SqlValue, v2: SqlValue) => SqlValue`) to the general
126
+ * {@link InstructionRun} that the scheduler drives every instruction through.
127
+ *
128
+ * A specific `run` is *not* structurally assignable to `InstructionRun`. The
129
+ * scheduler holds instructions generically and calls `run(ctx, ...args)` with
130
+ * every arg widened to `RuntimeValue`, so a function that declares narrower
131
+ * params (`SqlValue`, `AsyncIterable<Row>`, a fixed arity) is rejected by
132
+ * parameter contravariance under `strictFunctionTypes` — exactly as it would be
133
+ * if a caller passed more, fewer, or differently-typed args. Each emitter
134
+ * therefore has to assert the conversion. This helper is the single audited home
135
+ * for that assertion: emit sites write `run: asRun(run)` and the only
136
+ * `as`-to-`InstructionRun` in the runtime lives here.
137
+ *
138
+ * `TArgs` is inferred from the `run`'s own parameter tuple, so each emit site is
139
+ * still checked: every declared arg must be a {@link RuntimeValue} and the return
140
+ * must be an {@link OutputValue}. Only the arity/contravariance mismatch is
141
+ * waived. Two consequences for `run` authors:
142
+ * - An **optional** param (`cb?: SubProgram`) types as `SubProgram | undefined`, and
143
+ * `undefined` is not a `RuntimeValue` — a `run` whose trailing params are
144
+ * conditionally emitted must declare them as a rest tuple (`...cb: SubProgram[]`),
145
+ * which is also the truthful description of its call sites.
146
+ * - `Promise<OutputValue>` is a promise-of-a-promise and is *not* an `OutputValue`.
147
+ * An `async` `run` returns `Promise<RuntimeValue>`.
148
+ *
149
+ * NOTE: the per-arg checking is only as strong as `TArgs` inferring a real tuple. A
150
+ * `run` declared `(ctx, ...args: RuntimeValue[])` infers `TArgs = RuntimeValue[]` — the
151
+ * constraint itself — so that emit site is accepted unchecked. That is intentional for
152
+ * the genuinely variadic emitters (`emit/block.ts`, `emit/view-mutation.ts`), but it is
153
+ * also the escape hatch a future author reaches for to silence one of the two errors
154
+ * above. If you widen a `run`'s params to shut up `tsc`, you have opted that emitter
155
+ * out of checking, not fixed it.
156
+ */
157
+ export declare function asRun<TArgs extends RuntimeValue[]>(run: (ctx: RuntimeContext, ...args: TArgs) => OutputValue): InstructionRun;
60
158
  /**
61
159
  * Runtime statistics for instruction execution
62
160
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,MAAM,MAAM,cAAc,GAAG;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,GA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@@
1
+ /**
2
+ * Adapts an emitter's precisely-typed `run` (e.g.
3
+ * `(ctx, v1: SqlValue, v2: SqlValue) => SqlValue`) to the general
4
+ * {@link InstructionRun} that the scheduler drives every instruction through.
5
+ *
6
+ * A specific `run` is *not* structurally assignable to `InstructionRun`. The
7
+ * scheduler holds instructions generically and calls `run(ctx, ...args)` with
8
+ * every arg widened to `RuntimeValue`, so a function that declares narrower
9
+ * params (`SqlValue`, `AsyncIterable<Row>`, a fixed arity) is rejected by
10
+ * parameter contravariance under `strictFunctionTypes` — exactly as it would be
11
+ * if a caller passed more, fewer, or differently-typed args. Each emitter
12
+ * therefore has to assert the conversion. This helper is the single audited home
13
+ * for that assertion: emit sites write `run: asRun(run)` and the only
14
+ * `as`-to-`InstructionRun` in the runtime lives here.
15
+ *
16
+ * `TArgs` is inferred from the `run`'s own parameter tuple, so each emit site is
17
+ * still checked: every declared arg must be a {@link RuntimeValue} and the return
18
+ * must be an {@link OutputValue}. Only the arity/contravariance mismatch is
19
+ * waived. Two consequences for `run` authors:
20
+ * - An **optional** param (`cb?: SubProgram`) types as `SubProgram | undefined`, and
21
+ * `undefined` is not a `RuntimeValue` — a `run` whose trailing params are
22
+ * conditionally emitted must declare them as a rest tuple (`...cb: SubProgram[]`),
23
+ * which is also the truthful description of its call sites.
24
+ * - `Promise<OutputValue>` is a promise-of-a-promise and is *not* an `OutputValue`.
25
+ * An `async` `run` returns `Promise<RuntimeValue>`.
26
+ *
27
+ * NOTE: the per-arg checking is only as strong as `TArgs` inferring a real tuple. A
28
+ * `run` declared `(ctx, ...args: RuntimeValue[])` infers `TArgs = RuntimeValue[]` — the
29
+ * constraint itself — so that emit site is accepted unchecked. That is intentional for
30
+ * the genuinely variadic emitters (`emit/block.ts`, `emit/view-mutation.ts`), but it is
31
+ * also the escape hatch a future author reaches for to silence one of the two errors
32
+ * above. If you widen a `run`'s params to shut up `tsc`, you have opted that emitter
33
+ * out of checking, not fixed it.
34
+ */
35
+ export function asRun(run) {
36
+ return run;
37
+ }
1
38
  /** * Tracer that collects execution events for later analysis. */
2
39
  export class CollectingInstructionTracer {
3
40
  events = [];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":"AAuHA,kEAAkE;AAClE,MAAM,OAAO,2BAA2B;IAC/B,MAAM,GAA4B,EAAE,CAAC;IACrC,WAAW,GAAG,IAAI,GAAG,EAAoE,CAAC;IAC1F,gBAAgB,GAAG,CAAC,CAAC;IAE7B,UAAU,CAAC,gBAAwB,EAAE,WAAwB,EAAE,IAAoB;QAClF,MAAM,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAE9E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAChB,gBAAgB;YAChB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,WAAW;SACX,CAAC,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,gBAAwB,EAAE,WAAwB,EAAE,MAAmB;QAClF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAChB,gBAAgB;YAChB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;SAChC,CAAC,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,gBAAwB,EAAE,WAAwB,EAAE,KAAY;QAC1E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAChB,gBAAgB;YAChB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,KAAK,EAAE,KAA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jD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI9E,eAAO,MAAM,MAAM,0BAAkC,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAe5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAY7E;AAED,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAMtF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAuCxH;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CA8BpG;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAO7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,QAIxG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,QAGpE"}
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { QuereusError } from '../common/errors.js';
3
2
  import { StatusCode } from '../common/types.js';
4
3
  import { createLogger } from '../common/logger.js';
@@ -116,24 +115,16 @@ export async function getVTable(ctx, tableSchema) {
116
115
  const vtabArgs = tableSchema.vtabArgs || {};
117
116
  // Pass the full tableSchema to connect() so modules can use the primaryKeyDefinition
118
117
  const vtabInstance = await module.connect(ctx.db, moduleInfo.auxData, tableSchema.vtabModuleName, tableSchema.schemaName, tableSchema.name, vtabArgs, tableSchema);
119
- // If we have an active connection for this table, inject it into the VirtualTable
120
- // Only inject if the connection's manager matches the new table's manager
121
- // (a stale connection from a dropped-then-recreated table must not be reused)
118
+ // If a connection for this table is already registered, offer it to the fresh instance
119
+ // via the module-neutral adoptConnection hook. The module owns the accept/reject
120
+ // decision (subtype + backing-state match); the runtime knows nothing about any module.
122
121
  const qualifiedName = `${tableSchema.schemaName}.${tableSchema.name}`;
123
122
  const existingConnections = ctx.db.getConnectionsForTable(qualifiedName);
124
- if (existingConnections.length > 0 && tableSchema.vtabModuleName === 'memory') {
125
- const memoryConnection = existingConnections[0];
126
- const memoryTable = vtabInstance;
127
- if (memoryConnection.getMemoryConnection && memoryTable.setConnection) {
128
- const existingMemConn = memoryConnection.getMemoryConnection();
129
- if (existingMemConn.tableManager === memoryTable.manager) {
130
- memoryTable.setConnection(existingMemConn);
131
- log(`Injected existing connection into VirtualTable for table ${qualifiedName}`);
132
- }
133
- else {
134
- log(`Skipped stale connection injection for table ${qualifiedName} (manager mismatch)`);
135
- }
136
- }
123
+ if (existingConnections.length > 0) {
124
+ // NOTE: getVTable adopts existingConnections[0]; if covering-connection semantics ever
125
+ // matter here (cf. isCovering in connection.ts / DeferredConstraintQueue), prefer the
126
+ // covering connection.
127
+ await vtabInstance.adoptConnection?.(existingConnections[0]);
137
128
  }
138
129
  return vtabInstance;
139
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAA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,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACzF,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzG,MAAM,CAAC,wCAAwC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,UAAyB,EAAE,IAAY;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACzF,MAAM,CAAC,4BAA4B,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -52,6 +52,14 @@ export interface ColumnSchema {
52
52
  defaultConflict?: ConflictResolution;
53
53
  /** Arbitrary metadata tags (informational only, does not affect behavior or hashing) */
54
54
  tags?: Readonly<Record<string, SqlValue>>;
55
+ /**
56
+ * Raw declared type token verbatim from the DDL (e.g. 'BIGINT', 'TIMESTAMP'), before
57
+ * {@link logicalType} flattening collapses it onto a shared logical type (e.g. both
58
+ * map to INTEGER). Informational only — not hashed, not compared, not read anywhere in
59
+ * Quereus; exists so an external host can recover the distinction the flattened
60
+ * `logicalType` erases. Absent when the column def had no declared type.
61
+ */
62
+ declaredType?: string;
55
63
  }
56
64
  /**
57
65
  * Creates a default ColumnSchema with basic properties
@@ -1 +1 @@
1
- {"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../../src/schema/column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,YAAY,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4DAA4D;IAC5D,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sDAAsD;IACtD,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC7B;;;;OAIG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC,wFAAwF;IACxF,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,GAAE,OAA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IAAI,EAAE,MAAM,EAAE,cAAc,GAAE,OAAc,GAAG,YAAY,CAWpG"}
@@ -1 +1 @@
1
- {"version":3,"file":"column.js","sourceRoot":"","sources":["../../../src/schema/column.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAsDtD;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,iBAA0B,IAAI;IACrF,OAAO;QACN,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE,cAAc,EAAE,uCAAuC;QAChE,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,QAAQ,EAAE,mBAAmB;QACxC,SAAS,EAAE,KAAK;KAChB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"column.js","sourceRoot":"","sources":["../../../src/schema/column.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AA8DtD;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,iBAA0B,IAAI;IACrF,OAAO;QACN,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE,cAAc,EAAE,uCAAuC;QAChE,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,QAAQ,EAAE,mBAAmB;QACxC,SAAS,EAAE,KAAK;KAChB,CAAC;AACH,CAAC"}
@@ -391,6 +391,11 @@ function qualifiedName(schemaName, name, currentSchemaName) {
391
391
  }
392
392
  function formatColumnDef(col, tableSchema, defaultNotNull, synthesizedKey) {
393
393
  let colDef = quoteName(col.name);
394
+ // NOTE: emits the flattened col.logicalType.name (e.g. 'INTEGER'), not col.declaredType
395
+ // (e.g. 'BIGINT'). That's intentional today — declaredType is informational-only, read
396
+ // by an external host, not by Quereus's own DDL round-trip — but if this ever needs to
397
+ // regenerate a byte-faithful CREATE TABLE, prefer col.declaredType here so the raw token
398
+ // isn't silently dropped again.
394
399
  if (col.logicalType)
395
400
  colDef += ` ${col.logicalType.name}`;
396
401
  const nullAnnotation = nullabilityAnnotation(col.notNull, defaultNotNull);