@quereus/quereus 3.3.0 → 4.0.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 (900) hide show
  1. package/README.md +7 -0
  2. package/dist/src/common/datatype.d.ts +12 -0
  3. package/dist/src/common/datatype.d.ts.map +1 -1
  4. package/dist/src/common/datatype.js.map +1 -1
  5. package/dist/src/common/types.d.ts +24 -0
  6. package/dist/src/common/types.d.ts.map +1 -1
  7. package/dist/src/common/types.js.map +1 -1
  8. package/dist/src/core/database-assertions.d.ts +37 -9
  9. package/dist/src/core/database-assertions.d.ts.map +1 -1
  10. package/dist/src/core/database-assertions.js +62 -110
  11. package/dist/src/core/database-assertions.js.map +1 -1
  12. package/dist/src/core/database-events.d.ts +163 -0
  13. package/dist/src/core/database-events.d.ts.map +1 -1
  14. package/dist/src/core/database-events.js +235 -21
  15. package/dist/src/core/database-events.js.map +1 -1
  16. package/dist/src/core/database-external-changes.d.ts +28 -0
  17. package/dist/src/core/database-external-changes.d.ts.map +1 -0
  18. package/dist/src/core/database-external-changes.js +242 -0
  19. package/dist/src/core/database-external-changes.js.map +1 -0
  20. package/dist/src/core/database-internal.d.ts +50 -1
  21. package/dist/src/core/database-internal.d.ts.map +1 -1
  22. package/dist/src/core/database-materialized-views.d.ts +1253 -0
  23. package/dist/src/core/database-materialized-views.d.ts.map +1 -0
  24. package/dist/src/core/database-materialized-views.js +3064 -0
  25. package/dist/src/core/database-materialized-views.js.map +1 -0
  26. package/dist/src/core/database-options.d.ts +4 -0
  27. package/dist/src/core/database-options.d.ts.map +1 -1
  28. package/dist/src/core/database-options.js +10 -0
  29. package/dist/src/core/database-options.js.map +1 -1
  30. package/dist/src/core/database-transaction.d.ts +19 -3
  31. package/dist/src/core/database-transaction.d.ts.map +1 -1
  32. package/dist/src/core/database-transaction.js +30 -3
  33. package/dist/src/core/database-transaction.js.map +1 -1
  34. package/dist/src/core/database-watchers.d.ts +19 -0
  35. package/dist/src/core/database-watchers.d.ts.map +1 -1
  36. package/dist/src/core/database-watchers.js +63 -3
  37. package/dist/src/core/database-watchers.js.map +1 -1
  38. package/dist/src/core/database.d.ts +203 -11
  39. package/dist/src/core/database.d.ts.map +1 -1
  40. package/dist/src/core/database.js +493 -29
  41. package/dist/src/core/database.js.map +1 -1
  42. package/dist/src/core/derived-row-validator.d.ts +137 -0
  43. package/dist/src/core/derived-row-validator.d.ts.map +1 -0
  44. package/dist/src/core/derived-row-validator.js +314 -0
  45. package/dist/src/core/derived-row-validator.js.map +1 -0
  46. package/dist/src/core/statement.d.ts.map +1 -1
  47. package/dist/src/core/statement.js +30 -9
  48. package/dist/src/core/statement.js.map +1 -1
  49. package/dist/src/emit/ast-stringify.d.ts +135 -1
  50. package/dist/src/emit/ast-stringify.d.ts.map +1 -1
  51. package/dist/src/emit/ast-stringify.js +793 -118
  52. package/dist/src/emit/ast-stringify.js.map +1 -1
  53. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  54. package/dist/src/func/builtins/aggregate.js +11 -10
  55. package/dist/src/func/builtins/aggregate.js.map +1 -1
  56. package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
  57. package/dist/src/func/builtins/builtin-window-functions.js +32 -0
  58. package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
  59. package/dist/src/func/builtins/explain.d.ts +3 -0
  60. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  61. package/dist/src/func/builtins/explain.js +229 -0
  62. package/dist/src/func/builtins/explain.js.map +1 -1
  63. package/dist/src/func/builtins/index.d.ts.map +1 -1
  64. package/dist/src/func/builtins/index.js +10 -2
  65. package/dist/src/func/builtins/index.js.map +1 -1
  66. package/dist/src/func/builtins/json.d.ts.map +1 -1
  67. package/dist/src/func/builtins/json.js +3 -2
  68. package/dist/src/func/builtins/json.js.map +1 -1
  69. package/dist/src/func/builtins/mutation.d.ts +2 -0
  70. package/dist/src/func/builtins/mutation.d.ts.map +1 -0
  71. package/dist/src/func/builtins/mutation.js +53 -0
  72. package/dist/src/func/builtins/mutation.js.map +1 -0
  73. package/dist/src/func/builtins/schema.d.ts +2 -0
  74. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  75. package/dist/src/func/builtins/schema.js +713 -26
  76. package/dist/src/func/builtins/schema.js.map +1 -1
  77. package/dist/src/func/builtins/string.js +1 -1
  78. package/dist/src/func/builtins/string.js.map +1 -1
  79. package/dist/src/func/registration.d.ts +9 -0
  80. package/dist/src/func/registration.d.ts.map +1 -1
  81. package/dist/src/func/registration.js +4 -0
  82. package/dist/src/func/registration.js.map +1 -1
  83. package/dist/src/index.d.ts +25 -6
  84. package/dist/src/index.d.ts.map +1 -1
  85. package/dist/src/index.js +27 -3
  86. package/dist/src/index.js.map +1 -1
  87. package/dist/src/parser/ast.d.ts +353 -21
  88. package/dist/src/parser/ast.d.ts.map +1 -1
  89. package/dist/src/parser/index.d.ts +14 -1
  90. package/dist/src/parser/index.d.ts.map +1 -1
  91. package/dist/src/parser/index.js +19 -0
  92. package/dist/src/parser/index.js.map +1 -1
  93. package/dist/src/parser/lexer.d.ts +9 -0
  94. package/dist/src/parser/lexer.d.ts.map +1 -1
  95. package/dist/src/parser/lexer.js +9 -0
  96. package/dist/src/parser/lexer.js.map +1 -1
  97. package/dist/src/parser/parser.d.ts +276 -7
  98. package/dist/src/parser/parser.d.ts.map +1 -1
  99. package/dist/src/parser/parser.js +1387 -469
  100. package/dist/src/parser/parser.js.map +1 -1
  101. package/dist/src/parser/visitor.d.ts.map +1 -1
  102. package/dist/src/parser/visitor.js +12 -8
  103. package/dist/src/parser/visitor.js.map +1 -1
  104. package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -1
  105. package/dist/src/planner/analysis/assertion-classifier.js +4 -0
  106. package/dist/src/planner/analysis/assertion-classifier.js.map +1 -1
  107. package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -1
  108. package/dist/src/planner/analysis/assertion-hoist-cache.js +8 -4
  109. package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -1
  110. package/dist/src/planner/analysis/authored-inverse.d.ts +22 -0
  111. package/dist/src/planner/analysis/authored-inverse.d.ts.map +1 -0
  112. package/dist/src/planner/analysis/authored-inverse.js +267 -0
  113. package/dist/src/planner/analysis/authored-inverse.js.map +1 -0
  114. package/dist/src/planner/analysis/change-scope.d.ts +34 -4
  115. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
  116. package/dist/src/planner/analysis/change-scope.js +108 -7
  117. package/dist/src/planner/analysis/change-scope.js.map +1 -1
  118. package/dist/src/planner/analysis/check-extraction.d.ts +36 -2
  119. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
  120. package/dist/src/planner/analysis/check-extraction.js +174 -46
  121. package/dist/src/planner/analysis/check-extraction.js.map +1 -1
  122. package/dist/src/planner/analysis/coarsened-key.d.ts +109 -0
  123. package/dist/src/planner/analysis/coarsened-key.d.ts.map +1 -0
  124. package/dist/src/planner/analysis/coarsened-key.js +228 -0
  125. package/dist/src/planner/analysis/coarsened-key.js.map +1 -0
  126. package/dist/src/planner/analysis/comparison-collation.d.ts +216 -0
  127. package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -0
  128. package/dist/src/planner/analysis/comparison-collation.js +341 -0
  129. package/dist/src/planner/analysis/comparison-collation.js.map +1 -0
  130. package/dist/src/planner/analysis/constraint-extractor.d.ts +3 -1
  131. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  132. package/dist/src/planner/analysis/constraint-extractor.js +192 -9
  133. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  134. package/dist/src/planner/analysis/coverage-prover.d.ts +321 -0
  135. package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -0
  136. package/dist/src/planner/analysis/coverage-prover.js +1038 -0
  137. package/dist/src/planner/analysis/coverage-prover.js.map +1 -0
  138. package/dist/src/planner/analysis/key-filter.d.ts +22 -0
  139. package/dist/src/planner/analysis/key-filter.d.ts.map +1 -0
  140. package/dist/src/planner/analysis/key-filter.js +105 -0
  141. package/dist/src/planner/analysis/key-filter.js.map +1 -0
  142. package/dist/src/planner/analysis/partial-unique-extraction.d.ts +36 -1
  143. package/dist/src/planner/analysis/partial-unique-extraction.d.ts.map +1 -1
  144. package/dist/src/planner/analysis/partial-unique-extraction.js +148 -22
  145. package/dist/src/planner/analysis/partial-unique-extraction.js.map +1 -1
  146. package/dist/src/planner/analysis/predicate-normalizer.d.ts.map +1 -1
  147. package/dist/src/planner/analysis/predicate-normalizer.js +30 -1
  148. package/dist/src/planner/analysis/predicate-normalizer.js.map +1 -1
  149. package/dist/src/planner/analysis/predicate-shape.d.ts +36 -1
  150. package/dist/src/planner/analysis/predicate-shape.d.ts.map +1 -1
  151. package/dist/src/planner/analysis/predicate-shape.js +51 -13
  152. package/dist/src/planner/analysis/predicate-shape.js.map +1 -1
  153. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +314 -0
  154. package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -0
  155. package/dist/src/planner/analysis/query-rewrite-matcher.js +1081 -0
  156. package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -0
  157. package/dist/src/planner/analysis/scalar-invertibility.d.ts +92 -0
  158. package/dist/src/planner/analysis/scalar-invertibility.d.ts.map +1 -0
  159. package/dist/src/planner/analysis/scalar-invertibility.js +129 -0
  160. package/dist/src/planner/analysis/scalar-invertibility.js.map +1 -0
  161. package/dist/src/planner/analysis/update-lineage.d.ts +196 -0
  162. package/dist/src/planner/analysis/update-lineage.d.ts.map +1 -0
  163. package/dist/src/planner/analysis/update-lineage.js +322 -0
  164. package/dist/src/planner/analysis/update-lineage.js.map +1 -0
  165. package/dist/src/planner/analysis/view-complement.d.ts +42 -0
  166. package/dist/src/planner/analysis/view-complement.d.ts.map +1 -0
  167. package/dist/src/planner/analysis/view-complement.js +54 -0
  168. package/dist/src/planner/analysis/view-complement.js.map +1 -0
  169. package/dist/src/planner/building/alter-table.d.ts +1 -1
  170. package/dist/src/planner/building/alter-table.d.ts.map +1 -1
  171. package/dist/src/planner/building/alter-table.js +211 -2
  172. package/dist/src/planner/building/alter-table.js.map +1 -1
  173. package/dist/src/planner/building/block.d.ts.map +1 -1
  174. package/dist/src/planner/building/block.js +18 -1
  175. package/dist/src/planner/building/block.js.map +1 -1
  176. package/dist/src/planner/building/constraint-builder.d.ts +33 -5
  177. package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
  178. package/dist/src/planner/building/constraint-builder.js +63 -28
  179. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  180. package/dist/src/planner/building/create-view.d.ts +9 -0
  181. package/dist/src/planner/building/create-view.d.ts.map +1 -1
  182. package/dist/src/planner/building/create-view.js +41 -12
  183. package/dist/src/planner/building/create-view.js.map +1 -1
  184. package/dist/src/planner/building/ddl.d.ts.map +1 -1
  185. package/dist/src/planner/building/ddl.js +94 -0
  186. package/dist/src/planner/building/ddl.js.map +1 -1
  187. package/dist/src/planner/building/declare-schema.d.ts +1 -0
  188. package/dist/src/planner/building/declare-schema.d.ts.map +1 -1
  189. package/dist/src/planner/building/declare-schema.js +4 -1
  190. package/dist/src/planner/building/declare-schema.js.map +1 -1
  191. package/dist/src/planner/building/default-scope.d.ts +26 -0
  192. package/dist/src/planner/building/default-scope.d.ts.map +1 -0
  193. package/dist/src/planner/building/default-scope.js +41 -0
  194. package/dist/src/planner/building/default-scope.js.map +1 -0
  195. package/dist/src/planner/building/delete.d.ts +19 -1
  196. package/dist/src/planner/building/delete.d.ts.map +1 -1
  197. package/dist/src/planner/building/delete.js +109 -30
  198. package/dist/src/planner/building/delete.js.map +1 -1
  199. package/dist/src/planner/building/dml-target.d.ts +118 -0
  200. package/dist/src/planner/building/dml-target.d.ts.map +1 -0
  201. package/dist/src/planner/building/dml-target.js +282 -0
  202. package/dist/src/planner/building/dml-target.js.map +1 -0
  203. package/dist/src/planner/building/drop-index.d.ts.map +1 -1
  204. package/dist/src/planner/building/drop-index.js +4 -1
  205. package/dist/src/planner/building/drop-index.js.map +1 -1
  206. package/dist/src/planner/building/drop-view.d.ts.map +1 -1
  207. package/dist/src/planner/building/drop-view.js +4 -2
  208. package/dist/src/planner/building/drop-view.js.map +1 -1
  209. package/dist/src/planner/building/expression.d.ts.map +1 -1
  210. package/dist/src/planner/building/expression.js +60 -21
  211. package/dist/src/planner/building/expression.js.map +1 -1
  212. package/dist/src/planner/building/foreign-key-builder.d.ts +30 -0
  213. package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
  214. package/dist/src/planner/building/foreign-key-builder.js +160 -129
  215. package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
  216. package/dist/src/planner/building/insert.d.ts +45 -2
  217. package/dist/src/planner/building/insert.d.ts.map +1 -1
  218. package/dist/src/planner/building/insert.js +257 -88
  219. package/dist/src/planner/building/insert.js.map +1 -1
  220. package/dist/src/planner/building/lens-auxiliary-access.d.ts +22 -0
  221. package/dist/src/planner/building/lens-auxiliary-access.d.ts.map +1 -0
  222. package/dist/src/planner/building/lens-auxiliary-access.js +132 -0
  223. package/dist/src/planner/building/lens-auxiliary-access.js.map +1 -0
  224. package/dist/src/planner/building/materialized-view.d.ts +16 -0
  225. package/dist/src/planner/building/materialized-view.d.ts.map +1 -0
  226. package/dist/src/planner/building/materialized-view.js +57 -0
  227. package/dist/src/planner/building/materialized-view.js.map +1 -0
  228. package/dist/src/planner/building/returning-star.d.ts +32 -0
  229. package/dist/src/planner/building/returning-star.d.ts.map +1 -0
  230. package/dist/src/planner/building/returning-star.js +45 -0
  231. package/dist/src/planner/building/returning-star.js.map +1 -0
  232. package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
  233. package/dist/src/planner/building/select-aggregates.js +47 -0
  234. package/dist/src/planner/building/select-aggregates.js.map +1 -1
  235. package/dist/src/planner/building/select-compound.d.ts.map +1 -1
  236. package/dist/src/planner/building/select-compound.js +84 -11
  237. package/dist/src/planner/building/select-compound.js.map +1 -1
  238. package/dist/src/planner/building/select-context.d.ts +10 -2
  239. package/dist/src/planner/building/select-context.d.ts.map +1 -1
  240. package/dist/src/planner/building/select-context.js +7 -1
  241. package/dist/src/planner/building/select-context.js.map +1 -1
  242. package/dist/src/planner/building/select-modifiers.js +6 -0
  243. package/dist/src/planner/building/select-modifiers.js.map +1 -1
  244. package/dist/src/planner/building/select-ordinal.d.ts +18 -0
  245. package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
  246. package/dist/src/planner/building/select-ordinal.js +30 -0
  247. package/dist/src/planner/building/select-ordinal.js.map +1 -1
  248. package/dist/src/planner/building/select-projections.d.ts +8 -2
  249. package/dist/src/planner/building/select-projections.d.ts.map +1 -1
  250. package/dist/src/planner/building/select-projections.js +26 -4
  251. package/dist/src/planner/building/select-projections.js.map +1 -1
  252. package/dist/src/planner/building/select-window.d.ts.map +1 -1
  253. package/dist/src/planner/building/select-window.js +8 -5
  254. package/dist/src/planner/building/select-window.js.map +1 -1
  255. package/dist/src/planner/building/select.d.ts.map +1 -1
  256. package/dist/src/planner/building/select.js +164 -59
  257. package/dist/src/planner/building/select.js.map +1 -1
  258. package/dist/src/planner/building/set-object-tags.d.ts +7 -0
  259. package/dist/src/planner/building/set-object-tags.d.ts.map +1 -0
  260. package/dist/src/planner/building/set-object-tags.js +38 -0
  261. package/dist/src/planner/building/set-object-tags.js.map +1 -0
  262. package/dist/src/planner/building/tag-diagnostics.d.ts +27 -0
  263. package/dist/src/planner/building/tag-diagnostics.d.ts.map +1 -0
  264. package/dist/src/planner/building/tag-diagnostics.js +37 -0
  265. package/dist/src/planner/building/tag-diagnostics.js.map +1 -0
  266. package/dist/src/planner/building/update.d.ts +18 -1
  267. package/dist/src/planner/building/update.d.ts.map +1 -1
  268. package/dist/src/planner/building/update.js +134 -58
  269. package/dist/src/planner/building/update.js.map +1 -1
  270. package/dist/src/planner/building/view-mutation-builder.d.ts +15 -0
  271. package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -0
  272. package/dist/src/planner/building/view-mutation-builder.js +1158 -0
  273. package/dist/src/planner/building/view-mutation-builder.js.map +1 -0
  274. package/dist/src/planner/building/with.d.ts +11 -0
  275. package/dist/src/planner/building/with.d.ts.map +1 -1
  276. package/dist/src/planner/building/with.js +48 -10
  277. package/dist/src/planner/building/with.js.map +1 -1
  278. package/dist/src/planner/cost/index.d.ts +83 -0
  279. package/dist/src/planner/cost/index.d.ts.map +1 -1
  280. package/dist/src/planner/cost/index.js +114 -0
  281. package/dist/src/planner/cost/index.js.map +1 -1
  282. package/dist/src/planner/framework/characteristics.d.ts +38 -4
  283. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  284. package/dist/src/planner/framework/characteristics.js +50 -6
  285. package/dist/src/planner/framework/characteristics.js.map +1 -1
  286. package/dist/src/planner/framework/pass.d.ts.map +1 -1
  287. package/dist/src/planner/framework/pass.js +2 -1
  288. package/dist/src/planner/framework/pass.js.map +1 -1
  289. package/dist/src/planner/framework/registry.d.ts +39 -1
  290. package/dist/src/planner/framework/registry.d.ts.map +1 -1
  291. package/dist/src/planner/framework/registry.js +18 -2
  292. package/dist/src/planner/framework/registry.js.map +1 -1
  293. package/dist/src/planner/mutation/backward-body.d.ts +131 -0
  294. package/dist/src/planner/mutation/backward-body.d.ts.map +1 -0
  295. package/dist/src/planner/mutation/backward-body.js +135 -0
  296. package/dist/src/planner/mutation/backward-body.js.map +1 -0
  297. package/dist/src/planner/mutation/cte-flatten.d.ts +17 -0
  298. package/dist/src/planner/mutation/cte-flatten.d.ts.map +1 -0
  299. package/dist/src/planner/mutation/cte-flatten.js +364 -0
  300. package/dist/src/planner/mutation/cte-flatten.js.map +1 -0
  301. package/dist/src/planner/mutation/decomposition.d.ts +273 -0
  302. package/dist/src/planner/mutation/decomposition.d.ts.map +1 -0
  303. package/dist/src/planner/mutation/decomposition.js +1719 -0
  304. package/dist/src/planner/mutation/decomposition.js.map +1 -0
  305. package/dist/src/planner/mutation/lens-enforcement.d.ts +165 -0
  306. package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -0
  307. package/dist/src/planner/mutation/lens-enforcement.js +745 -0
  308. package/dist/src/planner/mutation/lens-enforcement.js.map +1 -0
  309. package/dist/src/planner/mutation/multi-source.d.ts +568 -0
  310. package/dist/src/planner/mutation/multi-source.d.ts.map +1 -0
  311. package/dist/src/planner/mutation/multi-source.js +2915 -0
  312. package/dist/src/planner/mutation/multi-source.js.map +1 -0
  313. package/dist/src/planner/mutation/mutation-diagnostic.d.ts +37 -0
  314. package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -0
  315. package/dist/src/planner/mutation/mutation-diagnostic.js +24 -0
  316. package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -0
  317. package/dist/src/planner/mutation/mutation-tags.d.ts +33 -0
  318. package/dist/src/planner/mutation/mutation-tags.d.ts.map +1 -0
  319. package/dist/src/planner/mutation/mutation-tags.js +31 -0
  320. package/dist/src/planner/mutation/mutation-tags.js.map +1 -0
  321. package/dist/src/planner/mutation/propagate.d.ts +97 -0
  322. package/dist/src/planner/mutation/propagate.d.ts.map +1 -0
  323. package/dist/src/planner/mutation/propagate.js +220 -0
  324. package/dist/src/planner/mutation/propagate.js.map +1 -0
  325. package/dist/src/planner/mutation/scope-transform.d.ts +181 -0
  326. package/dist/src/planner/mutation/scope-transform.d.ts.map +1 -0
  327. package/dist/src/planner/mutation/scope-transform.js +574 -0
  328. package/dist/src/planner/mutation/scope-transform.js.map +1 -0
  329. package/dist/src/planner/mutation/set-op.d.ts +242 -0
  330. package/dist/src/planner/mutation/set-op.d.ts.map +1 -0
  331. package/dist/src/planner/mutation/set-op.js +1687 -0
  332. package/dist/src/planner/mutation/set-op.js.map +1 -0
  333. package/dist/src/planner/mutation/single-source.d.ts +261 -0
  334. package/dist/src/planner/mutation/single-source.d.ts.map +1 -0
  335. package/dist/src/planner/mutation/single-source.js +1096 -0
  336. package/dist/src/planner/mutation/single-source.js.map +1 -0
  337. package/dist/src/planner/nodes/aggregate-node.js +3 -3
  338. package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
  339. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  340. package/dist/src/planner/nodes/alias-node.js +5 -1
  341. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  342. package/dist/src/planner/nodes/alter-table-node.d.ts +124 -1
  343. package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
  344. package/dist/src/planner/nodes/alter-table-node.js +27 -0
  345. package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
  346. package/dist/src/planner/nodes/analyze-node.d.ts +2 -1
  347. package/dist/src/planner/nodes/analyze-node.d.ts.map +1 -1
  348. package/dist/src/planner/nodes/analyze-node.js +18 -1
  349. package/dist/src/planner/nodes/analyze-node.js.map +1 -1
  350. package/dist/src/planner/nodes/asserted-keys-node.d.ts +43 -0
  351. package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -0
  352. package/dist/src/planner/nodes/asserted-keys-node.js +99 -0
  353. package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -0
  354. package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
  355. package/dist/src/planner/nodes/async-gather-node.js +33 -8
  356. package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
  357. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  358. package/dist/src/planner/nodes/bloom-join-node.js +2 -1
  359. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  360. package/dist/src/planner/nodes/create-view-node.d.ts +7 -2
  361. package/dist/src/planner/nodes/create-view-node.d.ts.map +1 -1
  362. package/dist/src/planner/nodes/create-view-node.js +4 -1
  363. package/dist/src/planner/nodes/create-view-node.js.map +1 -1
  364. package/dist/src/planner/nodes/declarative-schema.d.ts +13 -1
  365. package/dist/src/planner/nodes/declarative-schema.d.ts.map +1 -1
  366. package/dist/src/planner/nodes/declarative-schema.js +32 -0
  367. package/dist/src/planner/nodes/declarative-schema.js.map +1 -1
  368. package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
  369. package/dist/src/planner/nodes/distinct-node.js +2 -0
  370. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  371. package/dist/src/planner/nodes/dml-executor-node.d.ts +29 -1
  372. package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
  373. package/dist/src/planner/nodes/dml-executor-node.js +27 -3
  374. package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
  375. package/dist/src/planner/nodes/eager-prefetch-node.d.ts.map +1 -1
  376. package/dist/src/planner/nodes/eager-prefetch-node.js +2 -0
  377. package/dist/src/planner/nodes/eager-prefetch-node.js.map +1 -1
  378. package/dist/src/planner/nodes/envelope-scan-node.d.ts +42 -0
  379. package/dist/src/planner/nodes/envelope-scan-node.d.ts.map +1 -0
  380. package/dist/src/planner/nodes/envelope-scan-node.js +62 -0
  381. package/dist/src/planner/nodes/envelope-scan-node.js.map +1 -0
  382. package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
  383. package/dist/src/planner/nodes/fanout-lookup-join-node.js +11 -1
  384. package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
  385. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  386. package/dist/src/planner/nodes/filter.js +63 -13
  387. package/dist/src/planner/nodes/filter.js.map +1 -1
  388. package/dist/src/planner/nodes/join-node.d.ts +41 -1
  389. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  390. package/dist/src/planner/nodes/join-node.js +78 -8
  391. package/dist/src/planner/nodes/join-node.js.map +1 -1
  392. package/dist/src/planner/nodes/join-utils.d.ts +33 -6
  393. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  394. package/dist/src/planner/nodes/join-utils.js +124 -9
  395. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  396. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts +104 -0
  397. package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -0
  398. package/dist/src/planner/nodes/lens-auxiliary-access-node.js +91 -0
  399. package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -0
  400. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  401. package/dist/src/planner/nodes/limit-offset.js +4 -5
  402. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  403. package/dist/src/planner/nodes/materialized-view-nodes.d.ts +69 -0
  404. package/dist/src/planner/nodes/materialized-view-nodes.d.ts.map +1 -0
  405. package/dist/src/planner/nodes/materialized-view-nodes.js +111 -0
  406. package/dist/src/planner/nodes/materialized-view-nodes.js.map +1 -0
  407. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  408. package/dist/src/planner/nodes/merge-join-node.js +2 -1
  409. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  410. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
  411. package/dist/src/planner/nodes/ordinal-slice-node.js +2 -0
  412. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
  413. package/dist/src/planner/nodes/plan-node-type.d.ts +9 -0
  414. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  415. package/dist/src/planner/nodes/plan-node-type.js +9 -0
  416. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  417. package/dist/src/planner/nodes/plan-node.d.ts +265 -5
  418. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  419. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  420. package/dist/src/planner/nodes/pragma.d.ts +2 -1
  421. package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
  422. package/dist/src/planner/nodes/pragma.js +12 -0
  423. package/dist/src/planner/nodes/pragma.js.map +1 -1
  424. package/dist/src/planner/nodes/project-node.d.ts +14 -1
  425. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  426. package/dist/src/planner/nodes/project-node.js +85 -11
  427. package/dist/src/planner/nodes/project-node.js.map +1 -1
  428. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  429. package/dist/src/planner/nodes/reference.js +62 -27
  430. package/dist/src/planner/nodes/reference.js.map +1 -1
  431. package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
  432. package/dist/src/planner/nodes/retrieve-node.js +7 -0
  433. package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
  434. package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
  435. package/dist/src/planner/nodes/returning-node.js +10 -3
  436. package/dist/src/planner/nodes/returning-node.js.map +1 -1
  437. package/dist/src/planner/nodes/scalar.d.ts +20 -0
  438. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  439. package/dist/src/planner/nodes/scalar.js +71 -14
  440. package/dist/src/planner/nodes/scalar.js.map +1 -1
  441. package/dist/src/planner/nodes/set-object-tags-node.d.ts +39 -0
  442. package/dist/src/planner/nodes/set-object-tags-node.d.ts.map +1 -0
  443. package/dist/src/planner/nodes/set-object-tags-node.js +41 -0
  444. package/dist/src/planner/nodes/set-object-tags-node.js.map +1 -0
  445. package/dist/src/planner/nodes/set-operation-node.d.ts +123 -1
  446. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  447. package/dist/src/planner/nodes/set-operation-node.js +291 -18
  448. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  449. package/dist/src/planner/nodes/single-row.d.ts.map +1 -1
  450. package/dist/src/planner/nodes/single-row.js +3 -0
  451. package/dist/src/planner/nodes/single-row.js.map +1 -1
  452. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  453. package/dist/src/planner/nodes/sort.js +7 -6
  454. package/dist/src/planner/nodes/sort.js.map +1 -1
  455. package/dist/src/planner/nodes/subquery.d.ts +2 -0
  456. package/dist/src/planner/nodes/subquery.d.ts.map +1 -1
  457. package/dist/src/planner/nodes/subquery.js +18 -2
  458. package/dist/src/planner/nodes/subquery.js.map +1 -1
  459. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  460. package/dist/src/planner/nodes/table-access-nodes.js +23 -3
  461. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  462. package/dist/src/planner/nodes/table-function-call.js +6 -0
  463. package/dist/src/planner/nodes/table-function-call.js.map +1 -1
  464. package/dist/src/planner/nodes/values-node.d.ts +1 -0
  465. package/dist/src/planner/nodes/values-node.d.ts.map +1 -1
  466. package/dist/src/planner/nodes/values-node.js +16 -6
  467. package/dist/src/planner/nodes/values-node.js.map +1 -1
  468. package/dist/src/planner/nodes/view-mutation-node.d.ts +259 -0
  469. package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -0
  470. package/dist/src/planner/nodes/view-mutation-node.js +273 -0
  471. package/dist/src/planner/nodes/view-mutation-node.js.map +1 -0
  472. package/dist/src/planner/nodes/window-function.d.ts +17 -1
  473. package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
  474. package/dist/src/planner/nodes/window-function.js +15 -1
  475. package/dist/src/planner/nodes/window-function.js.map +1 -1
  476. package/dist/src/planner/nodes/window-node.js +2 -2
  477. package/dist/src/planner/nodes/window-node.js.map +1 -1
  478. package/dist/src/planner/optimizer.d.ts.map +1 -1
  479. package/dist/src/planner/optimizer.js +372 -39
  480. package/dist/src/planner/optimizer.js.map +1 -1
  481. package/dist/src/planner/planning-context.d.ts +1 -1
  482. package/dist/src/planner/planning-context.d.ts.map +1 -1
  483. package/dist/src/planner/rules/access/lens-access-form-matcher.d.ts +70 -0
  484. package/dist/src/planner/rules/access/lens-access-form-matcher.d.ts.map +1 -0
  485. package/dist/src/planner/rules/access/lens-access-form-matcher.js +156 -0
  486. package/dist/src/planner/rules/access/lens-access-form-matcher.js.map +1 -0
  487. package/dist/src/planner/rules/access/rule-lens-auxiliary-access.d.ts +31 -0
  488. package/dist/src/planner/rules/access/rule-lens-auxiliary-access.d.ts.map +1 -0
  489. package/dist/src/planner/rules/access/rule-lens-auxiliary-access.js +176 -0
  490. package/dist/src/planner/rules/access/rule-lens-auxiliary-access.js.map +1 -0
  491. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  492. package/dist/src/planner/rules/access/rule-select-access-path.js +435 -37
  493. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  494. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -1
  495. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +9 -0
  496. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -1
  497. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts +39 -0
  498. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.d.ts.map +1 -0
  499. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +616 -0
  500. package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -0
  501. package/dist/src/planner/rules/cache/rule-scalar-cse.d.ts.map +1 -1
  502. package/dist/src/planner/rules/cache/rule-scalar-cse.js +8 -1
  503. package/dist/src/planner/rules/cache/rule-scalar-cse.js.map +1 -1
  504. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +36 -0
  505. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
  506. package/dist/src/planner/rules/join/equi-pair-extractor.js +38 -1
  507. package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
  508. package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts.map +1 -1
  509. package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +10 -0
  510. package/dist/src/planner/rules/join/rule-fanout-batched-outer.js.map +1 -1
  511. package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
  512. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +19 -1
  513. package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
  514. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.d.ts +130 -0
  515. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.d.ts.map +1 -0
  516. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.js +206 -0
  517. package/dist/src/planner/rules/join/rule-inner-join-existence-recovery.js.map +1 -0
  518. package/dist/src/planner/rules/join/rule-join-elimination.d.ts +67 -14
  519. package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -1
  520. package/dist/src/planner/rules/join/rule-join-elimination.js +81 -25
  521. package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -1
  522. package/dist/src/planner/rules/join/rule-join-existence-pruning.d.ts +84 -0
  523. package/dist/src/planner/rules/join/rule-join-existence-pruning.d.ts.map +1 -0
  524. package/dist/src/planner/rules/join/rule-join-existence-pruning.js +138 -0
  525. package/dist/src/planner/rules/join/rule-join-existence-pruning.js.map +1 -0
  526. package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
  527. package/dist/src/planner/rules/join/rule-join-greedy-commute.js +9 -1
  528. package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -1
  529. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  530. package/dist/src/planner/rules/join/rule-join-physical-selection.js +12 -1
  531. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  532. package/dist/src/planner/rules/join/rule-lateral-top1-asof.d.ts.map +1 -1
  533. package/dist/src/planner/rules/join/rule-lateral-top1-asof.js +4 -0
  534. package/dist/src/planner/rules/join/rule-lateral-top1-asof.js.map +1 -1
  535. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
  536. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +4 -0
  537. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
  538. package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts.map +1 -1
  539. package/dist/src/planner/rules/join/rule-quickpick-enumeration.js +10 -0
  540. package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +1 -1
  541. package/dist/src/planner/rules/join/rule-semijoin-existence-recovery.d.ts +286 -0
  542. package/dist/src/planner/rules/join/rule-semijoin-existence-recovery.d.ts.map +1 -0
  543. package/dist/src/planner/rules/join/rule-semijoin-existence-recovery.js +548 -0
  544. package/dist/src/planner/rules/join/rule-semijoin-existence-recovery.js.map +1 -0
  545. package/dist/src/planner/rules/parallel/rule-async-gather-union-all.d.ts.map +1 -1
  546. package/dist/src/planner/rules/parallel/rule-async-gather-union-all.js +9 -1
  547. package/dist/src/planner/rules/parallel/rule-async-gather-union-all.js.map +1 -1
  548. package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.d.ts.map +1 -1
  549. package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js +7 -0
  550. package/dist/src/planner/rules/parallel/rule-async-gather-zip-by-key.js.map +1 -1
  551. package/dist/src/planner/rules/parallel/rule-eager-prefetch-probe.d.ts.map +1 -1
  552. package/dist/src/planner/rules/parallel/rule-eager-prefetch-probe.js +10 -1
  553. package/dist/src/planner/rules/parallel/rule-eager-prefetch-probe.js.map +1 -1
  554. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -1
  555. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +9 -0
  556. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -1
  557. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts.map +1 -1
  558. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +18 -0
  559. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js.map +1 -1
  560. package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts.map +1 -1
  561. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js +7 -0
  562. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js.map +1 -1
  563. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -1
  564. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +9 -0
  565. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
  566. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +13 -3
  567. package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
  568. package/dist/src/planner/rules/retrieve/rule-projection-pruning.d.ts.map +1 -1
  569. package/dist/src/planner/rules/retrieve/rule-projection-pruning.js +14 -0
  570. package/dist/src/planner/rules/retrieve/rule-projection-pruning.js.map +1 -1
  571. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts +1 -1
  572. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js +4 -4
  573. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js.map +1 -1
  574. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -1
  575. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +8 -0
  576. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -1
  577. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -1
  578. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +7 -0
  579. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
  580. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  581. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +12 -0
  582. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  583. package/dist/src/planner/type-utils.d.ts +14 -0
  584. package/dist/src/planner/type-utils.d.ts.map +1 -1
  585. package/dist/src/planner/type-utils.js +66 -21
  586. package/dist/src/planner/type-utils.js.map +1 -1
  587. package/dist/src/planner/util/fd-utils.d.ts +177 -43
  588. package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
  589. package/dist/src/planner/util/fd-utils.js +396 -101
  590. package/dist/src/planner/util/fd-utils.js.map +1 -1
  591. package/dist/src/planner/util/ind-utils.d.ts +27 -1
  592. package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
  593. package/dist/src/planner/util/ind-utils.js +80 -6
  594. package/dist/src/planner/util/ind-utils.js.map +1 -1
  595. package/dist/src/planner/util/key-utils.d.ts.map +1 -1
  596. package/dist/src/planner/util/key-utils.js +81 -12
  597. package/dist/src/planner/util/key-utils.js.map +1 -1
  598. package/dist/src/planner/util/set-op-wrapper.d.ts +37 -0
  599. package/dist/src/planner/util/set-op-wrapper.d.ts.map +1 -0
  600. package/dist/src/planner/util/set-op-wrapper.js +82 -0
  601. package/dist/src/planner/util/set-op-wrapper.js.map +1 -0
  602. package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
  603. package/dist/src/planner/validation/plan-validator.js +1 -0
  604. package/dist/src/planner/validation/plan-validator.js.map +1 -1
  605. package/dist/src/runtime/context-helpers.d.ts +13 -1
  606. package/dist/src/runtime/context-helpers.d.ts.map +1 -1
  607. package/dist/src/runtime/context-helpers.js +7 -1
  608. package/dist/src/runtime/context-helpers.js.map +1 -1
  609. package/dist/src/runtime/delta-executor.d.ts +30 -1
  610. package/dist/src/runtime/delta-executor.d.ts.map +1 -1
  611. package/dist/src/runtime/delta-executor.js +29 -4
  612. package/dist/src/runtime/delta-executor.js.map +1 -1
  613. package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
  614. package/dist/src/runtime/emit/add-constraint.js +38 -5
  615. package/dist/src/runtime/emit/add-constraint.js.map +1 -1
  616. package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
  617. package/dist/src/runtime/emit/aggregate.js +10 -8
  618. package/dist/src/runtime/emit/aggregate.js.map +1 -1
  619. package/dist/src/runtime/emit/alter-table.d.ts +1 -1
  620. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  621. package/dist/src/runtime/emit/alter-table.js +664 -108
  622. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  623. package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
  624. package/dist/src/runtime/emit/analyze.js +2 -1
  625. package/dist/src/runtime/emit/analyze.js.map +1 -1
  626. package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -1
  627. package/dist/src/runtime/emit/asof-scan.js +18 -5
  628. package/dist/src/runtime/emit/asof-scan.js.map +1 -1
  629. package/dist/src/runtime/emit/asserted-keys.d.ts +13 -0
  630. package/dist/src/runtime/emit/asserted-keys.d.ts.map +1 -0
  631. package/dist/src/runtime/emit/asserted-keys.js +13 -0
  632. package/dist/src/runtime/emit/asserted-keys.js.map +1 -0
  633. package/dist/src/runtime/emit/between.d.ts.map +1 -1
  634. package/dist/src/runtime/emit/between.js +24 -19
  635. package/dist/src/runtime/emit/between.js.map +1 -1
  636. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  637. package/dist/src/runtime/emit/binary.js +5 -9
  638. package/dist/src/runtime/emit/binary.js.map +1 -1
  639. package/dist/src/runtime/emit/block.d.ts.map +1 -1
  640. package/dist/src/runtime/emit/block.js +11 -2
  641. package/dist/src/runtime/emit/block.js.map +1 -1
  642. package/dist/src/runtime/emit/bloom-join.d.ts.map +1 -1
  643. package/dist/src/runtime/emit/bloom-join.js +8 -2
  644. package/dist/src/runtime/emit/bloom-join.js.map +1 -1
  645. package/dist/src/runtime/emit/constraint-check.js +15 -0
  646. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  647. package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
  648. package/dist/src/runtime/emit/create-table.js +8 -0
  649. package/dist/src/runtime/emit/create-table.js.map +1 -1
  650. package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
  651. package/dist/src/runtime/emit/create-view.js +16 -1
  652. package/dist/src/runtime/emit/create-view.js.map +1 -1
  653. package/dist/src/runtime/emit/dml-executor.d.ts +27 -0
  654. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  655. package/dist/src/runtime/emit/dml-executor.js +413 -193
  656. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  657. package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
  658. package/dist/src/runtime/emit/drop-table.js +10 -0
  659. package/dist/src/runtime/emit/drop-table.js.map +1 -1
  660. package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
  661. package/dist/src/runtime/emit/drop-view.js +17 -0
  662. package/dist/src/runtime/emit/drop-view.js.map +1 -1
  663. package/dist/src/runtime/emit/envelope-scan.d.ts +13 -0
  664. package/dist/src/runtime/emit/envelope-scan.d.ts.map +1 -0
  665. package/dist/src/runtime/emit/envelope-scan.js +22 -0
  666. package/dist/src/runtime/emit/envelope-scan.js.map +1 -0
  667. package/dist/src/runtime/emit/join.d.ts +10 -2
  668. package/dist/src/runtime/emit/join.d.ts.map +1 -1
  669. package/dist/src/runtime/emit/join.js +128 -38
  670. package/dist/src/runtime/emit/join.js.map +1 -1
  671. package/dist/src/runtime/emit/lens-auxiliary-access.d.ts +16 -0
  672. package/dist/src/runtime/emit/lens-auxiliary-access.d.ts.map +1 -0
  673. package/dist/src/runtime/emit/lens-auxiliary-access.js +16 -0
  674. package/dist/src/runtime/emit/lens-auxiliary-access.js.map +1 -0
  675. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +640 -0
  676. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -0
  677. package/dist/src/runtime/emit/materialized-view-helpers.js +2576 -0
  678. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -0
  679. package/dist/src/runtime/emit/materialized-view.d.ts +31 -0
  680. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -0
  681. package/dist/src/runtime/emit/materialized-view.js +187 -0
  682. package/dist/src/runtime/emit/materialized-view.js.map +1 -0
  683. package/dist/src/runtime/emit/merge-join.d.ts.map +1 -1
  684. package/dist/src/runtime/emit/merge-join.js +15 -3
  685. package/dist/src/runtime/emit/merge-join.js.map +1 -1
  686. package/dist/src/runtime/emit/project.d.ts.map +1 -1
  687. package/dist/src/runtime/emit/project.js +10 -5
  688. package/dist/src/runtime/emit/project.js.map +1 -1
  689. package/dist/src/runtime/emit/schema-declarative.d.ts +1 -0
  690. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  691. package/dist/src/runtime/emit/schema-declarative.js +101 -5
  692. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  693. package/dist/src/runtime/emit/set-object-tags.d.ts +16 -0
  694. package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -0
  695. package/dist/src/runtime/emit/set-object-tags.js +57 -0
  696. package/dist/src/runtime/emit/set-object-tags.js.map +1 -0
  697. package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
  698. package/dist/src/runtime/emit/set-operation.js +140 -24
  699. package/dist/src/runtime/emit/set-operation.js.map +1 -1
  700. package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
  701. package/dist/src/runtime/emit/subquery.js +110 -5
  702. package/dist/src/runtime/emit/subquery.js.map +1 -1
  703. package/dist/src/runtime/emit/unary.d.ts.map +1 -1
  704. package/dist/src/runtime/emit/unary.js +34 -6
  705. package/dist/src/runtime/emit/unary.js.map +1 -1
  706. package/dist/src/runtime/emit/view-mutation.d.ts +70 -0
  707. package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -0
  708. package/dist/src/runtime/emit/view-mutation.js +299 -0
  709. package/dist/src/runtime/emit/view-mutation.js.map +1 -0
  710. package/dist/src/runtime/emit/window.js +29 -5
  711. package/dist/src/runtime/emit/window.js.map +1 -1
  712. package/dist/src/runtime/foreign-key-actions.d.ts +66 -3
  713. package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
  714. package/dist/src/runtime/foreign-key-actions.js +580 -172
  715. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  716. package/dist/src/runtime/parallel-driver.d.ts +4 -1
  717. package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
  718. package/dist/src/runtime/parallel-driver.js +5 -1
  719. package/dist/src/runtime/parallel-driver.js.map +1 -1
  720. package/dist/src/runtime/register.d.ts.map +1 -1
  721. package/dist/src/runtime/register.js +17 -1
  722. package/dist/src/runtime/register.js.map +1 -1
  723. package/dist/src/runtime/types.d.ts +10 -0
  724. package/dist/src/runtime/types.d.ts.map +1 -1
  725. package/dist/src/runtime/types.js.map +1 -1
  726. package/dist/src/schema/basis-backfill.d.ts +63 -0
  727. package/dist/src/schema/basis-backfill.d.ts.map +1 -0
  728. package/dist/src/schema/basis-backfill.js +161 -0
  729. package/dist/src/schema/basis-backfill.js.map +1 -0
  730. package/dist/src/schema/catalog.d.ts +115 -1
  731. package/dist/src/schema/catalog.d.ts.map +1 -1
  732. package/dist/src/schema/catalog.js +249 -22
  733. package/dist/src/schema/catalog.js.map +1 -1
  734. package/dist/src/schema/change-events.d.ts +42 -1
  735. package/dist/src/schema/change-events.d.ts.map +1 -1
  736. package/dist/src/schema/change-events.js.map +1 -1
  737. package/dist/src/schema/column.d.ts +16 -0
  738. package/dist/src/schema/column.d.ts.map +1 -1
  739. package/dist/src/schema/column.js.map +1 -1
  740. package/dist/src/schema/constraint-builder.d.ts +182 -0
  741. package/dist/src/schema/constraint-builder.d.ts.map +1 -0
  742. package/dist/src/schema/constraint-builder.js +424 -0
  743. package/dist/src/schema/constraint-builder.js.map +1 -0
  744. package/dist/src/schema/ddl-generator.d.ts +86 -1
  745. package/dist/src/schema/ddl-generator.d.ts.map +1 -1
  746. package/dist/src/schema/ddl-generator.js +316 -20
  747. package/dist/src/schema/ddl-generator.js.map +1 -1
  748. package/dist/src/schema/declared-schema-manager.d.ts +51 -0
  749. package/dist/src/schema/declared-schema-manager.d.ts.map +1 -1
  750. package/dist/src/schema/declared-schema-manager.js +61 -0
  751. package/dist/src/schema/declared-schema-manager.js.map +1 -1
  752. package/dist/src/schema/derivation.d.ts +106 -0
  753. package/dist/src/schema/derivation.d.ts.map +1 -0
  754. package/dist/src/schema/derivation.js +25 -0
  755. package/dist/src/schema/derivation.js.map +1 -0
  756. package/dist/src/schema/function.d.ts +13 -0
  757. package/dist/src/schema/function.d.ts.map +1 -1
  758. package/dist/src/schema/function.js.map +1 -1
  759. package/dist/src/schema/lens-ack.d.ts +90 -0
  760. package/dist/src/schema/lens-ack.d.ts.map +1 -0
  761. package/dist/src/schema/lens-ack.js +361 -0
  762. package/dist/src/schema/lens-ack.js.map +1 -0
  763. package/dist/src/schema/lens-compiler.d.ts +62 -0
  764. package/dist/src/schema/lens-compiler.d.ts.map +1 -0
  765. package/dist/src/schema/lens-compiler.js +1594 -0
  766. package/dist/src/schema/lens-compiler.js.map +1 -0
  767. package/dist/src/schema/lens-fk-discovery.d.ts +175 -0
  768. package/dist/src/schema/lens-fk-discovery.d.ts.map +1 -0
  769. package/dist/src/schema/lens-fk-discovery.js +336 -0
  770. package/dist/src/schema/lens-fk-discovery.js.map +1 -0
  771. package/dist/src/schema/lens-prover.d.ts +336 -0
  772. package/dist/src/schema/lens-prover.d.ts.map +1 -0
  773. package/dist/src/schema/lens-prover.js +1988 -0
  774. package/dist/src/schema/lens-prover.js.map +1 -0
  775. package/dist/src/schema/lens.d.ts +254 -0
  776. package/dist/src/schema/lens.d.ts.map +1 -0
  777. package/dist/src/schema/lens.js +21 -0
  778. package/dist/src/schema/lens.js.map +1 -0
  779. package/dist/src/schema/manager.d.ts +676 -18
  780. package/dist/src/schema/manager.d.ts.map +1 -1
  781. package/dist/src/schema/manager.js +1573 -238
  782. package/dist/src/schema/manager.js.map +1 -1
  783. package/dist/src/schema/mapping-advertisement-tags.d.ts +39 -0
  784. package/dist/src/schema/mapping-advertisement-tags.d.ts.map +1 -0
  785. package/dist/src/schema/mapping-advertisement-tags.js +216 -0
  786. package/dist/src/schema/mapping-advertisement-tags.js.map +1 -0
  787. package/dist/src/schema/rename-rewriter.d.ts +45 -4
  788. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  789. package/dist/src/schema/rename-rewriter.js +412 -19
  790. package/dist/src/schema/rename-rewriter.js.map +1 -1
  791. package/dist/src/schema/reserved-tags-policy.d.ts +32 -0
  792. package/dist/src/schema/reserved-tags-policy.d.ts.map +1 -0
  793. package/dist/src/schema/reserved-tags-policy.js +34 -0
  794. package/dist/src/schema/reserved-tags-policy.js.map +1 -0
  795. package/dist/src/schema/reserved-tags.d.ts +170 -0
  796. package/dist/src/schema/reserved-tags.d.ts.map +1 -0
  797. package/dist/src/schema/reserved-tags.js +507 -0
  798. package/dist/src/schema/reserved-tags.js.map +1 -0
  799. package/dist/src/schema/schema-differ.d.ts +158 -2
  800. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  801. package/dist/src/schema/schema-differ.js +1460 -78
  802. package/dist/src/schema/schema-differ.js.map +1 -1
  803. package/dist/src/schema/schema-hasher.d.ts +8 -3
  804. package/dist/src/schema/schema-hasher.d.ts.map +1 -1
  805. package/dist/src/schema/schema-hasher.js +22 -2
  806. package/dist/src/schema/schema-hasher.js.map +1 -1
  807. package/dist/src/schema/schema.d.ts +25 -1
  808. package/dist/src/schema/schema.d.ts.map +1 -1
  809. package/dist/src/schema/schema.js +36 -2
  810. package/dist/src/schema/schema.js.map +1 -1
  811. package/dist/src/schema/table.d.ts +259 -10
  812. package/dist/src/schema/table.d.ts.map +1 -1
  813. package/dist/src/schema/table.js +309 -26
  814. package/dist/src/schema/table.js.map +1 -1
  815. package/dist/src/schema/unique-enforcement.d.ts +78 -0
  816. package/dist/src/schema/unique-enforcement.d.ts.map +1 -0
  817. package/dist/src/schema/unique-enforcement.js +93 -0
  818. package/dist/src/schema/unique-enforcement.js.map +1 -0
  819. package/dist/src/schema/view.d.ts +83 -2
  820. package/dist/src/schema/view.d.ts.map +1 -1
  821. package/dist/src/schema/view.js +67 -1
  822. package/dist/src/schema/view.js.map +1 -1
  823. package/dist/src/schema/window-function.d.ts +9 -1
  824. package/dist/src/schema/window-function.d.ts.map +1 -1
  825. package/dist/src/schema/window-function.js.map +1 -1
  826. package/dist/src/util/comparison.d.ts +24 -0
  827. package/dist/src/util/comparison.d.ts.map +1 -1
  828. package/dist/src/util/comparison.js +34 -0
  829. package/dist/src/util/comparison.js.map +1 -1
  830. package/dist/src/util/mutation-statement.d.ts.map +1 -1
  831. package/dist/src/util/mutation-statement.js +4 -1
  832. package/dist/src/util/mutation-statement.js.map +1 -1
  833. package/dist/src/util/serialization.d.ts +9 -0
  834. package/dist/src/util/serialization.d.ts.map +1 -1
  835. package/dist/src/util/serialization.js +26 -0
  836. package/dist/src/util/serialization.js.map +1 -1
  837. package/dist/src/vtab/backing-host.d.ts +286 -0
  838. package/dist/src/vtab/backing-host.d.ts.map +1 -0
  839. package/dist/src/vtab/backing-host.js +118 -0
  840. package/dist/src/vtab/backing-host.js.map +1 -0
  841. package/dist/src/vtab/best-access-plan.d.ts +21 -0
  842. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  843. package/dist/src/vtab/best-access-plan.js.map +1 -1
  844. package/dist/src/vtab/capabilities.d.ts +5 -5
  845. package/dist/src/vtab/capabilities.d.ts.map +1 -1
  846. package/dist/src/vtab/mapping-advertisement.d.ts +163 -0
  847. package/dist/src/vtab/mapping-advertisement.d.ts.map +1 -0
  848. package/dist/src/vtab/mapping-advertisement.js +2 -0
  849. package/dist/src/vtab/mapping-advertisement.js.map +1 -0
  850. package/dist/src/vtab/memory/index.d.ts +64 -4
  851. package/dist/src/vtab/memory/index.d.ts.map +1 -1
  852. package/dist/src/vtab/memory/index.js +119 -12
  853. package/dist/src/vtab/memory/index.js.map +1 -1
  854. package/dist/src/vtab/memory/layer/base.d.ts +38 -1
  855. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  856. package/dist/src/vtab/memory/layer/base.js +112 -24
  857. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  858. package/dist/src/vtab/memory/layer/manager.d.ts +291 -4
  859. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  860. package/dist/src/vtab/memory/layer/manager.js +1050 -91
  861. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  862. package/dist/src/vtab/memory/layer/plan-filter.d.ts.map +1 -1
  863. package/dist/src/vtab/memory/layer/plan-filter.js +35 -6
  864. package/dist/src/vtab/memory/layer/plan-filter.js.map +1 -1
  865. package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
  866. package/dist/src/vtab/memory/layer/scan-layer.js +66 -14
  867. package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
  868. package/dist/src/vtab/memory/layer/scan-plan.d.ts +14 -0
  869. package/dist/src/vtab/memory/layer/scan-plan.d.ts.map +1 -1
  870. package/dist/src/vtab/memory/layer/scan-plan.js +27 -4
  871. package/dist/src/vtab/memory/layer/scan-plan.js.map +1 -1
  872. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  873. package/dist/src/vtab/memory/layer/transaction.js +5 -1
  874. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  875. package/dist/src/vtab/memory/module.d.ts +17 -0
  876. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  877. package/dist/src/vtab/memory/module.js +82 -3
  878. package/dist/src/vtab/memory/module.js.map +1 -1
  879. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  880. package/dist/src/vtab/memory/table.js +15 -5
  881. package/dist/src/vtab/memory/table.js.map +1 -1
  882. package/dist/src/vtab/memory/types.d.ts +20 -2
  883. package/dist/src/vtab/memory/types.d.ts.map +1 -1
  884. package/dist/src/vtab/memory/utils/predicate.d.ts.map +1 -1
  885. package/dist/src/vtab/memory/utils/predicate.js +46 -24
  886. package/dist/src/vtab/memory/utils/predicate.js.map +1 -1
  887. package/dist/src/vtab/memory/utils/primary-key-encode.d.ts +31 -0
  888. package/dist/src/vtab/memory/utils/primary-key-encode.d.ts.map +1 -0
  889. package/dist/src/vtab/memory/utils/primary-key-encode.js +101 -0
  890. package/dist/src/vtab/memory/utils/primary-key-encode.js.map +1 -0
  891. package/dist/src/vtab/memory/utils/primary-key.d.ts +8 -0
  892. package/dist/src/vtab/memory/utils/primary-key.d.ts.map +1 -1
  893. package/dist/src/vtab/memory/utils/primary-key.js +12 -5
  894. package/dist/src/vtab/memory/utils/primary-key.js.map +1 -1
  895. package/dist/src/vtab/module.d.ts +203 -4
  896. package/dist/src/vtab/module.d.ts.map +1 -1
  897. package/dist/src/vtab/table.d.ts +9 -0
  898. package/dist/src/vtab/table.d.ts.map +1 -1
  899. package/dist/src/vtab/table.js.map +1 -1
  900. package/package.json +6 -5
@@ -1,13 +1,24 @@
1
- import { Schema } from './schema.js';
1
+ import { Schema, type SchemaKind } from './schema.js';
2
2
  import type { IntegrityAssertionSchema } from './assertion.js';
3
3
  import type { Database } from '../core/database.js';
4
- import type { TableSchema } from './table.js';
4
+ import type { TableSchema, ForeignKeyConstraintSchema } from './table.js';
5
5
  import type { FunctionSchema } from './function.js';
6
6
  import { type SqlValue } from '../common/types.js';
7
7
  import type { AnyVirtualTableModule, BaseModuleConfig } from '../vtab/module.js';
8
8
  import type { ViewSchema } from './view.js';
9
+ import { type MaintainedTableSchema, type TableDerivation } from './derivation.js';
9
10
  import type * as AST from '../parser/ast.js';
10
11
  import { SchemaChangeNotifier } from './change-events.js';
12
+ /**
13
+ * One FK that references some parent table, paired with its declaring child
14
+ * table. Entries in the reverse FK index ({@link SchemaManager.getReferencingForeignKeys});
15
+ * `fk` is the same object reference held in `childTable.foreignKeys` (identity
16
+ * preserved).
17
+ */
18
+ export interface ReferencingForeignKey {
19
+ readonly childTable: TableSchema;
20
+ readonly fk: ForeignKeyConstraintSchema;
21
+ }
11
22
  /**
12
23
  * Generic options passed to VTab modules during CREATE TABLE.
13
24
  * Modules are responsible for interpreting these.
@@ -16,7 +27,48 @@ export interface GenericModuleCallOptions extends BaseModuleConfig {
16
27
  moduleArgs?: readonly string[];
17
28
  statementColumns?: readonly AST.ColumnDef[];
18
29
  statementConstraints?: readonly AST.TableConstraint[];
19
- isTemporary?: boolean;
30
+ }
31
+ /**
32
+ * Options for {@link SchemaManager.importCatalog}, controlling the
33
+ * materialized-view adopt-without-refill fast path. Both default off: a plain
34
+ * `importCatalog(ddl)` always drops and refills a pre-existing same-module
35
+ * backing — the always-correct posture.
36
+ */
37
+ export interface ImportCatalogOptions {
38
+ /**
39
+ * Caller-attested trust in pre-existing durable backings (adopt gate 5):
40
+ * the caller asserts the store has NOT crashed since those backings were
41
+ * last written — e.g. the store module sets this from its consumed
42
+ * clean-shutdown catalog marker. Without that attestation, a crash between
43
+ * two durable modules' commit acknowledgements could have left source and
44
+ * backing divergent on disk (coordinated commit is not 2PC), and the
45
+ * DDL-level adopt gates cannot see content divergence — so adopt is never
46
+ * taken and any divergence self-heals through the refill.
47
+ */
48
+ trustBackings?: boolean;
49
+ /**
50
+ * Shared adopt ledger for one rehydration session: lowercased qualified
51
+ * names (`schema.<table>`) of every maintained table adopted so far,
52
+ * appended on each successful adopt. A maintained table whose body reads
53
+ * another maintained table may only adopt when that upstream is IN this
54
+ * set — an upstream that was refilled this session may hold new content, so
55
+ * its dependents must refill too; an upstream that adopted is unchanged, so
56
+ * trust composes. Pass one Set across all `importCatalog` calls of the
57
+ * session (the store's MV fixpoint rounds compose through it). Omitting it
58
+ * means no maintained-table-sourced MV can adopt.
59
+ */
60
+ adoptedBackings?: Set<string>;
61
+ /**
62
+ * Lowercased qualified names (`schema.<table>`) of maintained tables whose
63
+ * `create materialized view` catalog entries have NOT yet imported this
64
+ * rehydration session. An entry whose body reads any of these is deferred
65
+ * (throws, to be retried in a later fixpoint round): its source table
66
+ * already exists as a *plain* pre-rehydrated table, so without this gate
67
+ * the dependent would adopt/refill against content its upstream's own
68
+ * import may be about to replace. (Pre-unification this ordering fell out
69
+ * of the body failing to plan until the upstream MV record existed.)
70
+ */
71
+ pendingDerivations?: ReadonlySet<string>;
20
72
  }
21
73
  /**
22
74
  * Manages all schemas associated with a database connection (main, temp, attached).
@@ -39,6 +91,44 @@ export declare class SchemaManager {
39
91
  * See `assertion-hoist-cache.ts` and `core/database-assertions.ts`.
40
92
  */
41
93
  private assertionHoistSuppressed;
94
+ /**
95
+ * Re-entrancy guard: when truthy, the read-side materialized-view query-rewrite
96
+ * rule (`rule-materialized-view-rewrite.ts`) is suppressed. Set while planning a
97
+ * materialized view's own body for the purpose of (re)computing or maintaining
98
+ * its backing table (create / refresh / row-time-maintenance compile). Without
99
+ * it, the rewrite rule would recognize the MV's body as "answered from" the MV
100
+ * itself and rewrite it to scan the backing table being populated — reading a
101
+ * stale/empty snapshot instead of recomputing from the source.
102
+ */
103
+ private mvRewriteSuppressed;
104
+ /**
105
+ * Catalog-level reverse foreign-key index: referenced `schema.table`
106
+ * (lowercased) → the FKs that reference it. `null` ⇒ needs a (re)build from
107
+ * the live catalog on next access — a pure derived cache, nulled on every
108
+ * mutation that can add/drop/retarget an FK or add/remove a schema (see
109
+ * {@link invalidateReverseFkIndex}). See `getReferencingForeignKeys`.
110
+ */
111
+ private reverseFkIndex;
112
+ /**
113
+ * Lens basis-FK gate: the set of basis `schema.table` keys (lowercased) that
114
+ * back ≥1 logical parent slot referenced by ≥1 logical FK — the logical-FK
115
+ * analogue of {@link reverseFkIndex}. `null` ⇒ rebuild from the live catalog on
116
+ * next access. A pure derived cache (built by {@link buildLensBasisFkGate}),
117
+ * nulled on every event that can change the underlying slot scan: lens deploy
118
+ * (no `SchemaChangeEvent` fires — `lens-compiler` calls
119
+ * {@link invalidateLensFkGate} directly), any `table_added`/`_modified`/`_removed`
120
+ * (basis-table catalog change, via the constructor listener), and schema
121
+ * attach/detach/reset (no event — invalidated directly).
122
+ *
123
+ * Soundness invariant (load-bearing): a stale gate that **under-reports** would
124
+ * silently drop logical FK enforcement (cascade not propagated / RESTRICT not
125
+ * enforced / divergent basis action not suppressed) — the fatal direction — so
126
+ * invalidation must be exhaustive. Built from, and reset alongside, the same
127
+ * catalog state the three lens FK paths scan, it never under-reports for the
128
+ * current catalog; over-reporting (a stray key ⇒ an on-hit scan that finds
129
+ * nothing) is harmless. See {@link basisTableBacksLogicalParentFk}.
130
+ */
131
+ private lensFkGate;
42
132
  /**
43
133
  * Creates a new schema manager
44
134
  *
@@ -162,14 +252,38 @@ export declare class SchemaManager {
162
252
  * state, even when `fn` throws.
163
253
  */
164
254
  withSuppressedAssertionHoist<T>(fn: () => T): T;
255
+ /**
256
+ * True when the read-side materialized-view query-rewrite rule must be
257
+ * suppressed (the caller is currently planning an MV's own body to recompute or
258
+ * maintain its backing). Read by `rule-materialized-view-rewrite.ts`.
259
+ */
260
+ isMaterializedViewRewriteSuppressed(): boolean;
261
+ /**
262
+ * Run a synchronous `fn` with the materialized-view query-rewrite rule
263
+ * suppressed. Re-entrant via a depth counter; always restores state, even on
264
+ * throw. Wrap every place that plans an MV body to (re)compute its backing.
265
+ */
266
+ withSuppressedMaterializedViewRewrite<T>(fn: () => T): T;
267
+ /** Async counterpart of {@link withSuppressedMaterializedViewRewrite}. */
268
+ withSuppressedMaterializedViewRewriteAsync<T>(fn: () => Promise<T>): Promise<T>;
165
269
  /**
166
270
  * Adds a new schema (e.g., for ATTACH)
167
271
  *
168
272
  * @param name Name of the schema to add
273
+ * @param kind Whether the schema is module-backed (`physical`, default) or
274
+ * design-only (`logical`). See `docs/lens.md` § Schema Kinds.
169
275
  * @returns The newly created schema
170
276
  * @throws QuereusError if the name conflicts with an existing schema
171
277
  */
172
- addSchema(name: string): Schema;
278
+ addSchema(name: string, kind?: SchemaKind): Schema;
279
+ /**
280
+ * Returns the named schema, lazily creating an empty (physical) one if absent.
281
+ * Used by the catalog-import paths ({@link importTable}/{@link importView}) so an
282
+ * object can rehydrate into a schema that holds no tables yet — making import
283
+ * order-independent. Unlike {@link addSchema} this never throws on an existing
284
+ * schema.
285
+ */
286
+ private getOrCreateSchema;
173
287
  /**
174
288
  * Removes a schema (e.g., for DETACH)
175
289
  *
@@ -211,6 +325,28 @@ export declare class SchemaManager {
211
325
  * @returns The ViewSchema or undefined if not found
212
326
  */
213
327
  getView(schemaName: string | null, viewName: string): ViewSchema | undefined;
328
+ /**
329
+ * Retrieves a maintained table (a table carrying a derivation — what
330
+ * `create materialized view` produces) by name.
331
+ *
332
+ * @param schemaName The schema name ('main', etc.). Defaults to current schema
333
+ * @param name The maintained table's name
334
+ */
335
+ getMaintainedTable(schemaName: string | null | undefined, name: string): MaintainedTableSchema | undefined;
336
+ /**
337
+ * Returns all maintained tables (derivation-bearing tables) across all schemas.
338
+ */
339
+ getAllMaintainedTables(): MaintainedTableSchema[];
340
+ /**
341
+ * Attaches (or replaces) a derivation on an already-registered table,
342
+ * swapping the registered record for `{...table, derivation}`. Fires no
343
+ * event — callers own the event discipline (create fires
344
+ * `materialized_view_added`; import stays silent). Returns the swapped
345
+ * maintained table.
346
+ *
347
+ * @throws QuereusError if the table is not registered.
348
+ */
349
+ attachDerivation(schemaName: string, tableName: string, derivation: TableDerivation): MaintainedTableSchema;
214
350
  /**
215
351
  * Retrieves any schema item (table or view) by name. Checks views first
216
352
  *
@@ -227,6 +363,40 @@ export declare class SchemaManager {
227
363
  * @returns The tags record or undefined if no tags are set
228
364
  */
229
365
  getTableTags(tableName: string, schemaName?: string): Readonly<Record<string, SqlValue>> | undefined;
366
+ /**
367
+ * Freezes a whole-set tag replacement: an empty record stores `undefined`
368
+ * (so `tags IS NULL` and the differ's "no tags" both hold), a non-empty one a
369
+ * frozen copy. Shared by the three catalog-only tag setters.
370
+ */
371
+ private freezeTags;
372
+ /**
373
+ * Computes the next frozen tag record from the current one plus a per-key
374
+ * mutation, reusing {@link freezeTags} for the empty→`undefined` collapse.
375
+ *
376
+ * - `merge`: shallow-overlay the new keys onto the current set (overwrite on
377
+ * collision), keeping the rest. A merge of a non-empty payload can never empty
378
+ * the set; an empty merge of an empty set collapses to `undefined`.
379
+ * - `drop`: every listed key must currently be present (atomic). Any missing key
380
+ * raises `NOTFOUND` naming the offenders and mutates nothing; otherwise the keys
381
+ * are deleted and dropping the last key collapses to `undefined`. Key matching
382
+ * is verbatim (case-sensitive), matching how `parseTags` stores keys.
383
+ */
384
+ private mutateTagRecord;
385
+ /**
386
+ * Re-registers a tag-only schema swap and fires `table_modified` so optimizer
387
+ * caches invalidate. Tags are excluded from the schema hash, so a tag-only swap
388
+ * is a structural no-op except for the metadata itself.
389
+ */
390
+ private commitTagUpdate;
391
+ /**
392
+ * Shared table-tag read-modify-write: fetches the live table (NOTFOUND if
393
+ * absent), computes the next tag record from its current `tags` via `compute`,
394
+ * and commits the swap (firing `table_modified`). `compute` decides
395
+ * replace / merge / drop; it may throw before any mutation (e.g. drop-of-absent
396
+ * NOTFOUND), leaving the catalog untouched. Reads the *live* schema each call so
397
+ * back-to-back ALTERs and prepared-statement reuse see the prior result.
398
+ */
399
+ private updateTableTags;
230
400
  /**
231
401
  * Sets metadata tags on an existing table, replacing any existing tags.
232
402
  *
@@ -235,6 +405,261 @@ export declare class SchemaManager {
235
405
  * @param schemaName Optional schema name (defaults to current schema)
236
406
  */
237
407
  setTableTags(tableName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
408
+ /**
409
+ * Merges `tags` into an existing table's tags — set/overwrite the listed keys,
410
+ * keep the rest (the `ALTER TABLE … ADD TAGS` primitive). An empty `tags` is a
411
+ * no-op (it does NOT clear). Reads the table's live tags at call time.
412
+ */
413
+ mergeTableTags(tableName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
414
+ /**
415
+ * Drops the listed keys from an existing table's tags (the `ALTER TABLE …
416
+ * DROP TAGS` primitive). Atomic: every key must be present, else `NOTFOUND`
417
+ * names the missing key(s) and nothing is dropped. Dropping the last key(s)
418
+ * leaves `tags` undefined. An empty `keys` is a no-op.
419
+ */
420
+ dropTableTags(tableName: string, keys: readonly string[], schemaName?: string): void;
421
+ /**
422
+ * Shared column-tag read-modify-write: resolves the table and column (NOTFOUND
423
+ * on either miss), computes the column's next tag record from its current `tags`
424
+ * via `compute`, and commits the swap. Only the column's `tags` field changes;
425
+ * nullability / type / default / PK membership are untouched. `compute` may throw
426
+ * before any mutation (drop-of-absent NOTFOUND), leaving the catalog untouched.
427
+ */
428
+ private updateColumnTags;
429
+ /**
430
+ * Sets metadata tags on a column of an existing table, replacing any existing
431
+ * tags on that column (empty record clears). Catalog-only — only the column's
432
+ * `tags` field changes; nullability / type / default / PK membership are
433
+ * untouched.
434
+ *
435
+ * @throws QuereusError(NOTFOUND) if the table or column does not exist.
436
+ */
437
+ setColumnTags(tableName: string, columnName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
438
+ /**
439
+ * Merges `tags` into a column's existing tags — set/overwrite the listed keys,
440
+ * keep the rest (`ALTER TABLE … ALTER COLUMN … ADD TAGS`). Empty `tags` is a
441
+ * no-op (does NOT clear).
442
+ *
443
+ * @throws QuereusError(NOTFOUND) if the table or column does not exist.
444
+ */
445
+ mergeColumnTags(tableName: string, columnName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
446
+ /**
447
+ * Drops the listed keys from a column's tags (`ALTER TABLE … ALTER COLUMN …
448
+ * DROP TAGS`). Atomic: every key must be present, else `NOTFOUND` names the
449
+ * missing key(s) and nothing is dropped. Empty `keys` is a no-op.
450
+ *
451
+ * @throws QuereusError(NOTFOUND) if the table or column does not exist, or any
452
+ * listed key is absent.
453
+ */
454
+ dropColumnTags(tableName: string, columnName: string, keys: readonly string[], schemaName?: string): void;
455
+ /**
456
+ * Shared named-constraint-tag read-modify-write: resolves the table (NOTFOUND if
457
+ * absent) and the single matching constraint class (check → unique → fk;
458
+ * NOTFOUND / ambiguous via {@link resolveNamedConstraintClass}), computes the
459
+ * matching constraint's next tag record from its current `tags` via `compute`,
460
+ * and commits. `compute` may throw before any mutation (drop-of-absent NOTFOUND);
461
+ * since it runs inside the array rebuild prior to `commitTagUpdate`, a throw
462
+ * leaves the catalog untouched.
463
+ */
464
+ private updateConstraintTags;
465
+ /**
466
+ * Sets metadata tags on a NAMED table-level constraint (CHECK / UNIQUE /
467
+ * FOREIGN KEY), replacing any existing tags (empty record clears). Lookup order
468
+ * is checks → unique → foreign keys; a name present in more than one class is
469
+ * rejected as ambiguous. Unnamed constraints are not addressable.
470
+ *
471
+ * @throws QuereusError(NOTFOUND) if no named constraint matches.
472
+ * @throws QuereusError(ERROR) if the name is ambiguous across constraint classes.
473
+ */
474
+ setConstraintTags(tableName: string, constraintName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
475
+ /**
476
+ * Merges `tags` into a named constraint's existing tags — set/overwrite the
477
+ * listed keys, keep the rest (`ALTER TABLE … ALTER CONSTRAINT … ADD TAGS`).
478
+ * Empty `tags` is a no-op (does NOT clear).
479
+ *
480
+ * @throws QuereusError(NOTFOUND) if no named constraint matches.
481
+ * @throws QuereusError(ERROR) if the name is ambiguous across constraint classes.
482
+ */
483
+ mergeConstraintTags(tableName: string, constraintName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
484
+ /**
485
+ * Drops the listed keys from a named constraint's tags (`ALTER TABLE … ALTER
486
+ * CONSTRAINT … DROP TAGS`). Atomic: every key must be present, else `NOTFOUND`
487
+ * names the missing key(s) and nothing is dropped. Empty `keys` is a no-op.
488
+ *
489
+ * @throws QuereusError(NOTFOUND) if no named constraint matches, or any listed
490
+ * key is absent.
491
+ * @throws QuereusError(ERROR) if the name is ambiguous across constraint classes.
492
+ */
493
+ dropConstraintTags(tableName: string, constraintName: string, keys: readonly string[], schemaName?: string): void;
494
+ /**
495
+ * Shared view-tag read-modify-write: fetches the live view (NOTFOUND if
496
+ * absent), computes its next tag record from its current `tags` via `compute`,
497
+ * re-registers the swapped {@link ViewSchema}, and fires `view_modified` so a
498
+ * cached write-through plan that recorded a `view` dependency (every
499
+ * view-/MV-mediated write does — see `buildViewMutation`) is invalidated when
500
+ * the view's tags change (tag validation re-runs at plan time, so a
501
+ * newly-invalid tag must surface on the next run). This event is distinct
502
+ * from the (non-existent) plain-view create event, so it triggers no maintenance
503
+ * re-registration. `compute` decides replace / merge / drop and may throw before
504
+ * any mutation (drop-of-absent NOTFOUND), leaving the catalog untouched.
505
+ */
506
+ private updateViewTags;
507
+ /**
508
+ * Sets metadata tags on an existing view, replacing any existing tags (empty
509
+ * record clears).
510
+ *
511
+ * @throws QuereusError(NOTFOUND) if the view does not exist.
512
+ */
513
+ setViewTags(viewName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
514
+ /**
515
+ * Merges `tags` into an existing view's tags — set/overwrite the listed keys,
516
+ * keep the rest (`ALTER VIEW … ADD TAGS`). Empty `tags` is a no-op (does NOT
517
+ * clear). Reads the view's live tags at call time.
518
+ *
519
+ * @throws QuereusError(NOTFOUND) if the view does not exist.
520
+ */
521
+ mergeViewTags(viewName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
522
+ /**
523
+ * Drops the listed keys from an existing view's tags (`ALTER VIEW … DROP TAGS`).
524
+ * Atomic: every key must be present, else `NOTFOUND` names the missing key(s)
525
+ * and nothing is dropped. Dropping the last key(s) leaves `tags` undefined. An
526
+ * empty `keys` is a no-op.
527
+ *
528
+ * @throws QuereusError(NOTFOUND) if the view does not exist, or any listed key
529
+ * is absent.
530
+ */
531
+ dropViewTags(viewName: string, keys: readonly string[], schemaName?: string): void;
532
+ /**
533
+ * Shared materialized-view-tag read-modify-write: fetches the live maintained
534
+ * table (NOTFOUND if absent or derivation-less), computes its next tag record
535
+ * via `compute`, re-registers the swapped table (the shared `derivation`
536
+ * object rides the spread), and fires `materialized_view_modified`. The
537
+ * table's contents and the row-time maintenance plan are untouched (tags do
538
+ * not affect maintenance), so this never re-materializes — `_modified` is
539
+ * deliberately distinct from `materialized_view_added` (what create emits):
540
+ * the MV maintenance manager re-registers on `_added` but ignores
541
+ * `_modified`. The event invalidates a cached write-through plan that
542
+ * recorded a `view` dependency when the MV's tags change (tag validation
543
+ * re-runs at plan time). `compute` may throw before any mutation
544
+ * (drop-of-absent NOTFOUND), leaving the catalog untouched.
545
+ */
546
+ private updateMaterializedViewTags;
547
+ /**
548
+ * Sets metadata tags on an existing materialized view, replacing any existing
549
+ * tags (empty record clears). Catalog-only — never re-materializes.
550
+ *
551
+ * @throws QuereusError(NOTFOUND) if the materialized view does not exist.
552
+ */
553
+ setMaterializedViewTags(name: string, tags: Record<string, SqlValue>, schemaName?: string): void;
554
+ /**
555
+ * Merges `tags` into an existing materialized view's tags — set/overwrite the
556
+ * listed keys, keep the rest (`ALTER MATERIALIZED VIEW … ADD TAGS`). Empty
557
+ * `tags` is a no-op (does NOT clear). Catalog-only — never re-materializes.
558
+ *
559
+ * @throws QuereusError(NOTFOUND) if the materialized view does not exist.
560
+ */
561
+ mergeMaterializedViewTags(name: string, tags: Record<string, SqlValue>, schemaName?: string): void;
562
+ /**
563
+ * Drops the listed keys from an existing materialized view's tags (`ALTER
564
+ * MATERIALIZED VIEW … DROP TAGS`). Atomic: every key must be present, else
565
+ * `NOTFOUND` names the missing key(s) and nothing is dropped. Empty `keys` is a
566
+ * no-op. Catalog-only — never re-materializes.
567
+ *
568
+ * @throws QuereusError(NOTFOUND) if the materialized view does not exist, or any
569
+ * listed key is absent.
570
+ */
571
+ dropMaterializedViewTags(name: string, keys: readonly string[], schemaName?: string): void;
572
+ /**
573
+ * Shared index-tag read-modify-write. Indexes live on their owning
574
+ * {@link TableSchema}, so this resolves the owner by index name, computes the
575
+ * matching {@link IndexSchema}'s next tag record from its current `tags` via
576
+ * `compute`, swaps it, re-registers the table, and fires `table_modified`
577
+ * (mirroring create/drop index) so optimizer caches invalidate.
578
+ *
579
+ * Hidden implicit covering structures (the auto-built BTree backing a UNIQUE
580
+ * constraint, not opted into catalog visibility) are not user-addressable and
581
+ * surface as NOTFOUND — their tags live on the originating constraint. `compute`
582
+ * runs before the index array is rebuilt, so a drop-of-absent NOTFOUND aborts
583
+ * before any swap.
584
+ */
585
+ private updateIndexTags;
586
+ /**
587
+ * Resolve-and-swap core shared by {@link updateIndexTags} (live ALTER — commits
588
+ * via {@link commitTagUpdate}, firing `table_modified`) and the catalog-import
589
+ * path ({@link applyImportedIndexTags} — commits silently). Resolves `indexName`
590
+ * within `targetSchemaName` and returns the owning table plus its swapped
591
+ * replacement with the computed tags applied; mutates nothing itself.
592
+ */
593
+ private resolveIndexTagSwap;
594
+ /**
595
+ * Sets metadata tags on an existing index, replacing any existing tags (empty
596
+ * record clears).
597
+ *
598
+ * @throws QuereusError(NOTFOUND) if no user-visible index matches.
599
+ */
600
+ setIndexTags(indexName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
601
+ /**
602
+ * Merges `tags` into an existing index's tags — set/overwrite the listed keys,
603
+ * keep the rest (`ALTER INDEX … ADD TAGS`). Empty `tags` is a no-op (does NOT
604
+ * clear).
605
+ *
606
+ * @throws QuereusError(NOTFOUND) if no user-visible index matches.
607
+ */
608
+ mergeIndexTags(indexName: string, tags: Record<string, SqlValue>, schemaName?: string): void;
609
+ /**
610
+ * Drops the listed keys from an existing index's tags (`ALTER INDEX … DROP
611
+ * TAGS`). Atomic: every key must be present, else `NOTFOUND` names the missing
612
+ * key(s) and nothing is dropped. Empty `keys` is a no-op.
613
+ *
614
+ * @throws QuereusError(NOTFOUND) if no user-visible index matches, or any listed
615
+ * key is absent.
616
+ */
617
+ dropIndexTags(indexName: string, keys: readonly string[], schemaName?: string): void;
618
+ /**
619
+ * Nulls the reverse FK index so it rebuilds from the live catalog on next
620
+ * access. Pure derived-cache reset — order-independent, called both from the
621
+ * self-subscribed change listener and from the schema attach/detach methods.
622
+ */
623
+ private invalidateReverseFkIndex;
624
+ /**
625
+ * Builds the reverse FK index from the live catalog, bucketing every FK under
626
+ * its resolved referenced `schema.table` key (cross-schema FKs key under their
627
+ * `referencedSchema`). Preserves schema-insertion → table → FK-declaration
628
+ * order within each bucket so the first-surviving-child RESTRICT pre-check and
629
+ * any error-message golden tests keep naming the same child.
630
+ */
631
+ private buildReverseFkIndex;
632
+ /**
633
+ * Returns the FKs that reference `parentSchemaName.parentTableName`
634
+ * (case-insensitive), the shared primitive every parent-side referential scan
635
+ * uses to short-circuit. Returns a shared frozen empty array — the O(1) gate —
636
+ * when nothing references the table; otherwise exactly its referencing FKs.
637
+ * Lazily (re)builds the whole index from the live catalog on the first access
638
+ * after any schema mutation; a pure derived cache (over-reporting a since-dropped
639
+ * FK is harmless — each consumer re-checks arity/target in its per-FK body).
640
+ *
641
+ * The returned `fk` objects are the same references held in
642
+ * `childTable.foreignKeys` (identity preserved).
643
+ */
644
+ getReferencingForeignKeys(parentSchemaName: string, parentTableName: string): readonly ReferencingForeignKey[];
645
+ /**
646
+ * Nulls the lens basis-FK gate so it rebuilds from the live catalog on next
647
+ * access. Pure derived-cache reset — order-independent (rebuild happens on next
648
+ * access, never inside a listener). Public because `lens-compiler` calls it after
649
+ * a lens (re)deploy, which mutates the slot set without firing a `SchemaChangeEvent`.
650
+ */
651
+ invalidateLensFkGate(): void;
652
+ /**
653
+ * O(1) gate for the three basis-keyed lens FK paths: does `schemaName.tableName`
654
+ * (case-insensitive) back ≥1 logical parent slot referenced by ≥1 logical FK?
655
+ * When `false`, `executeLensForeignKeyActions`,
656
+ * `assertLensRestrictsForParentMutation`, and `basisFksOverriddenByDivergentLensFk`
657
+ * early-return — the reverse-map slot scan they would run finds nothing. Lazily
658
+ * (re)builds {@link lensFkGate} on the first access after any invalidation, then
659
+ * does a single `Set.has`. See {@link buildLensBasisFkGate} for the build, and the
660
+ * {@link lensFkGate} doc-comment for the never-under-report soundness invariant.
661
+ */
662
+ basisTableBacksLogicalParentFk(schemaName: string, tableName: string): boolean;
238
663
  /**
239
664
  * Asserts that no other table has FK rows referencing the table being dropped.
240
665
  * Self-referential FKs are skipped — those rows go away with the table.
@@ -270,6 +695,23 @@ export declare class SchemaManager {
270
695
  * @throws QuereusError if the schema does not exist
271
696
  */
272
697
  getSchemaOrFail(name: string): Schema;
698
+ /**
699
+ * Canonical form of a raw (statement-supplied) schema qualifier.
700
+ *
701
+ * The invalidation contract this anchors: stored `schemaName` on
702
+ * tables/views/MVs is canonical, and every schema-change emitter fires the
703
+ * *stored* names of the object it swapped. `Statement.compile()` compares
704
+ * recorded dependencies against events exactly, so a raw-cased name on
705
+ * either side silently misses cached-plan invalidation.
706
+ *
707
+ * `Schema.name` is invariantly lowercase (every construction site
708
+ * lowercases), so an existing schema canonicalizes through its Schema
709
+ * object; an absent one (a plan-time reference that may resolve by run
710
+ * time, a catalog import into a not-yet-created schema) folds the way the
711
+ * Schema constructor would. Existence is NOT validated here — lookup sites
712
+ * keep their own missing-schema handling.
713
+ */
714
+ canonicalSchemaName(raw: string): string;
273
715
  /**
274
716
  * Retrieves a table from the specified schema
275
717
  *
@@ -308,6 +750,18 @@ export declare class SchemaManager {
308
750
  * Shared by both createTable (new storage) and importTable (existing storage).
309
751
  */
310
752
  private buildTableSchemaFromAST;
753
+ /**
754
+ * Builds a **logical** TableSchema spec from a declared CREATE TABLE AST,
755
+ * for use as the `logicalTable` of a lens slot (see `schema/lens.ts`).
756
+ *
757
+ * Reuses the same column / PK / constraint extraction as a physical table
758
+ * (so the spec is a faithful design), but carries **no** `vtabModule`
759
+ * (`vtabModuleName: ''`, `isLogical: true`) — a logical table is never
760
+ * registered or executed; its compiled effective body is registered as a
761
+ * `ViewSchema`. Module association / indexes / storage are rejected upstream
762
+ * by the lens compiler before this is called.
763
+ */
764
+ buildLogicalTableSchema(stmt: AST.CreateTableStmt, schemaName: string): TableSchema;
311
765
  /**
312
766
  * Walks an expression AST and rejects bind-parameter and (optionally)
313
767
  * column-reference nodes. Used by DDL-time DEFAULT/CHECK validators where
@@ -331,7 +785,53 @@ export declare class SchemaManager {
331
785
  * context variable, and the build attempt is permitted to fail —
332
786
  * scope resolution is deferred to row-time).
333
787
  */
788
+ /** True when a DEFAULT expression embeds a subquery (scalar subquery / EXISTS / SELECT). */
789
+ private defaultEmbedsSubquery;
790
+ /** True when a DEFAULT expression reads the row being written via `new.<column>`. */
791
+ private defaultReferencesNewRow;
792
+ /**
793
+ * Build the throwaway planning context (global + parameter scope, no table/row
794
+ * scope) used to compile a DEFAULT expression for DDL-time validation. The table's
795
+ * columns are intentionally absent so a bare-column reference fails to build —
796
+ * which the bare-column pre-walk has already rejected for the strict case, and
797
+ * which the deferral path tolerates for `new.`/subquery/mutation-context defaults.
798
+ */
799
+ private makeDdlValidationContext;
800
+ /**
801
+ * Validate a single DEFAULT expression — the per-default core of
802
+ * {@link validateDefaultDeterminism}, factored out so the ALTER COLUMN SET DEFAULT
803
+ * path ({@link validateAlterColumnDefault}) routes through the identical checks:
804
+ * bind parameters and (absent a mutation context) bare columns rejected up front,
805
+ * non-determinism rejected unless `allowNonDeterministic`, and a `new.<column>` /
806
+ * subquery / mutation-context default deferred to INSERT time (it cannot build
807
+ * here without the row/table scope; determinism is re-checked when the row scope
808
+ * is established).
809
+ */
810
+ private validateOneDefault;
334
811
  private validateDefaultDeterminism;
812
+ /**
813
+ * Validate a DEFAULT expression supplied by an `ALTER COLUMN … SET DEFAULT`,
814
+ * routing it through the same checks CREATE TABLE applies so the stored default is
815
+ * consistent with what INSERT will accept: bind parameters and (absent a mutation
816
+ * context) bare columns are rejected, non-determinism is rejected unless the
817
+ * `nondeterministic_schema` option is set, and a `new.<column>` default is accepted
818
+ * with the build/determinism check deferred to INSERT time. DROP DEFAULT (a null
819
+ * expression) never reaches here. Called from the ALTER TABLE runtime emitter.
820
+ */
821
+ validateAlterColumnDefault(defaultExpr: AST.Expression, columnName: string, tableName: string, hasMutationContext: boolean): void;
822
+ /**
823
+ * Validate a DEFAULT supplied by `ALTER TABLE ADD COLUMN`, routing it through the
824
+ * same checks CREATE TABLE / ALTER COLUMN apply so the stored default is consistent
825
+ * with what INSERT (and the per-row backfill) will accept: bind parameters and
826
+ * (absent a mutation context) bare columns are rejected, non-determinism is rejected
827
+ * unless `nondeterministic_schema` is set, and a `new.<column>` default is accepted
828
+ * with its build deferred — it reads the existing row's sibling during backfill and
829
+ * the INSERT-supplied sibling for future inserts. Called from the ALTER TABLE
830
+ * statement builder (`buildAlterTableStmt`) at plan-build time.
831
+ */
832
+ validateAddColumnDefault(defaultExpr: AST.Expression, columnName: string, tableName: string, hasMutationContext: boolean): void;
833
+ /** Shared body for the ALTER-time DEFAULT validators (ALTER COLUMN SET DEFAULT / ADD COLUMN). */
834
+ private validateDdlDefault;
335
835
  /**
336
836
  * Validates that CHECK constraint expressions don't call non-deterministic
337
837
  * functions and don't reference bind parameters. Walks the AST and looks
@@ -357,12 +857,6 @@ export declare class SchemaManager {
357
857
  * Builds an IndexSchema from AST column definitions, validating against the table schema.
358
858
  */
359
859
  private buildIndexSchema;
360
- /**
361
- * Returns a new TableSchema with the given index appended. If the index is
362
- * unique, also adds a matching uniqueConstraint so the mutation manager
363
- * enforces uniqueness on insert/update through its existing checks.
364
- */
365
- private addIndexToTableSchema;
366
860
  /**
367
861
  * Drops a secondary index from the table that owns it.
368
862
  * Searches all tables in the target schema to find the owning table.
@@ -374,7 +868,8 @@ export declare class SchemaManager {
374
868
  dropIndex(schemaName: string, indexName: string, ifExists?: boolean): Promise<void>;
375
869
  /**
376
870
  * Emits an auto schema event for modules that don't have native event support,
377
- * if any schema listeners are registered.
871
+ * if the engine needs schema events i.e. any `onSchemaChange` or
872
+ * `onTransactionCommit` listener is registered (see `Database._needsSchemaEvents`).
378
873
  */
379
874
  private emitAutoSchemaEventIfNeeded;
380
875
  /**
@@ -385,28 +880,184 @@ export declare class SchemaManager {
385
880
  * @returns A Promise that resolves to the created TableSchema.
386
881
  * @throws QuereusError on errors (e.g., module not found, create fails, table exists).
387
882
  */
388
- createTable(stmt: AST.CreateTableStmt): Promise<TableSchema>;
883
+ /**
884
+ * Builds the {@link TableSchema} a CREATE TABLE statement WOULD register,
885
+ * without touching the module or the catalog. Resolution matches
886
+ * {@link createTable} exactly (same module-info resolution, same live-session
887
+ * default collation), so the result is byte-for-byte what registration would
888
+ * produce. Used by the maintained-table create path
889
+ * (`createMaintainedTable`) to verify the declared shape against the
890
+ * derivation body BEFORE any catalog registration — the all-or-nothing
891
+ * posture of `create table … maintained as`.
892
+ */
893
+ buildDeclaredTableSchema(stmt: AST.CreateTableStmt): TableSchema;
894
+ /**
895
+ * `preferBacking` routes the module instantiation through the durable backing
896
+ * seam — `createBacking?() ?? create()`, the SAME preference
897
+ * {@link createBackingTable} uses — instead of `module.create` directly. It is
898
+ * set ONLY by the maintained-table create path (`createMaintainedTable`), so a
899
+ * durable-backing module (e.g. lamina) builds the basis `RowStore` that
900
+ * `getBackingHost` later resolves for row-time maintenance; without it the table
901
+ * is an ordinary relational collection with no basis store, and the maintained
902
+ * fill throws `backing host not found`. An ordinary user CREATE leaves it false
903
+ * and stays byte-for-byte on `module.create`. A module without `createBacking`
904
+ * (e.g. memory) falls through to `create` regardless, so the flag is a no-op
905
+ * there. Every gate above (determinism, FK-collation) runs identically in both
906
+ * modes — the flag only selects the factory method.
907
+ */
908
+ createTable(stmt: AST.CreateTableStmt, preferBacking?: boolean): Promise<TableSchema>;
909
+ /**
910
+ * Creates a backing table from a pre-built `TableSchema` rather than a
911
+ * CREATE TABLE AST. Used by materialized views, whose backing-table columns
912
+ * and primary key are derived from the optimized body relation (carrying
913
+ * full {@link import('../common/datatype.js').ScalarType} fidelity that a
914
+ * round-trip through SQL type strings would lose).
915
+ *
916
+ * Reuses the same internal sequence as {@link createTable} —
917
+ * `finalizeCreatedTableSchema` → `addTable` → `table_added` notify — so the
918
+ * backing table behaves like any other table, except the instance is built via
919
+ * the module's optional `createBacking` when present (`createBacking?() ??
920
+ * create()`): a durable-backing module routes the backing into its durable
921
+ * store there; modules without it fall through to `create` (today's behavior).
922
+ * The supplied schema must carry `vtabModule`/`vtabModuleName` (typically
923
+ * `memory`).
924
+ */
925
+ createBackingTable(tableSchema: TableSchema): Promise<TableSchema>;
389
926
  /**
390
927
  * Import catalog objects from DDL statements without triggering storage creation.
391
928
  * Used when connecting to existing storage that already contains data.
392
929
  *
930
+ * Options enable the materialized-view **adopt-without-refill fast path**
931
+ * (see {@link importMaterializedView}); omitted, every MV refills — the
932
+ * always-correct default.
933
+ *
393
934
  * This method:
394
935
  * 1. Parses each DDL statement
395
- * 2. Registers the schema objects (tables, indexes)
396
- * 3. Calls module.connect() instead of module.create()
936
+ * 2. Registers the schema objects (tables, indexes, views, materialized views)
937
+ * 3. Calls module.connect() instead of module.create() for tables (a
938
+ * materialized view's memory backing is re-materialized instead — see
939
+ * {@link importMaterializedView})
397
940
  * 4. Skips schema change hooks (since these are existing objects)
398
941
  *
399
- * @param ddlStatements Array of DDL strings (CREATE TABLE, CREATE INDEX, etc.)
942
+ * Each DDL string may hold **one or more** statements: a catalog entry can
943
+ * bundle a `CREATE TABLE` immediately followed by the `CREATE INDEX`es that
944
+ * belong to it. Statements within an entry are imported in document order, so
945
+ * a table always precedes the indexes that reference it. (Because every
946
+ * table's indexes are co-located with it in one entry, no global
947
+ * table-before-index ordering across entries is required.)
948
+ *
949
+ * @param ddlStatements Array of DDL strings (each one or more CREATE TABLE / CREATE INDEX, etc.)
950
+ * @param options Adopt-fast-path options for materialized views — see {@link ImportCatalogOptions}
400
951
  * @returns Array of imported object names
401
952
  */
402
- importCatalog(ddlStatements: string[]): Promise<{
953
+ importCatalog(ddlStatements: string[], options?: ImportCatalogOptions): Promise<{
403
954
  tables: string[];
404
955
  indexes: string[];
956
+ views: string[];
957
+ materializedViews: string[];
405
958
  }>;
406
959
  /**
407
- * Import a single DDL statement without creating storage.
960
+ * Import every statement in a DDL string without creating storage, in document
961
+ * order. A single string may carry several statements (a table bundled with
962
+ * its indexes); single-statement entries remain valid. An `alter index … tags`
963
+ * statement (the store bundle's vehicle for exposed-implicit-index user tags)
964
+ * applies silently against the just-imported table and contributes no result
965
+ * entry — it modifies an existing object rather than importing one. Any other
966
+ * unsupported statement type throws — `rehydrateCatalog` relies on this
967
+ * fail-loud contract to record import errors rather than silently dropping
968
+ * objects.
969
+ */
970
+ private importDDL;
971
+ /**
972
+ * Apply an `alter index … {set|add|drop} tags` statement during catalog import,
973
+ * **silently** — no `notifyChange`, mirroring {@link importTable}/{@link importIndex}
974
+ * (a store rehydrating its own catalog must not re-emit persistence events).
975
+ * Shares {@link resolveIndexTagSwap} with the live {@link updateIndexTags} path,
976
+ * so the bundle's statement resolves exactly as a user-issued ALTER would —
977
+ * materialized `IndexSchema` first, then the exposed-implicit-constraint
978
+ * fallback (the store-bundle case: the `alter index` line follows its
979
+ * `CREATE TABLE` in the same entry, so the constraint is already registered).
980
+ * All three action forms map through the shared `freezeTags`/`mutateTagRecord`
981
+ * helpers, though the bundle generator only emits the whole-set replace form.
982
+ * An unresolvable target throws NOTFOUND — the bundle and its alter line come
983
+ * from one `TableSchema` snapshot, so a miss indicates real corruption, which
984
+ * `rehydrateCatalog` records per-entry.
985
+ */
986
+ private applyImportedIndexTags;
987
+ /**
988
+ * Import a plain view from its parsed DDL **without planning the body**.
989
+ * Registration is silent — no `notifyChange` fires, mirroring
990
+ * {@link importTable}/{@link importIndex} (a store rehydrating its own catalog
991
+ * must not re-emit persistence events). Body validation is deferred to first
992
+ * reference, exactly as {@link importTable} defers create-time work via
993
+ * `connect`: this makes view rehydration order-independent — a view over
994
+ * another view, a materialized view, or a not-yet-imported relation registers
995
+ * regardless of phase order, and a broken body surfaces only when queried.
996
+ *
997
+ * The stored `sql` is the canonical {@link createViewToString} rendering (not
998
+ * the raw entry text, which may bundle several statements). Synchronous: unlike
999
+ * table/index import there is no module storage to bind, so there is nothing to
1000
+ * await.
408
1001
  */
409
- private importSingleDDL;
1002
+ private importView;
1003
+ /**
1004
+ * Import a materialized view from its parsed DDL by re-materializing it
1005
+ * through the shared {@link materializeView} core: the body is re-planned
1006
+ * against the current (already-imported) sources, the memory backing table is
1007
+ * rebuilt and filled, and row-time maintenance is re-registered — the same
1008
+ * work the create emitter does, minus the `materialized_view_added` event (a
1009
+ * store rehydrating its own catalog must not re-emit persistence events;
1010
+ * `table_added` still fires for the backing table, exactly as on create).
1011
+ *
1012
+ * Unlike {@link importView}, the body plans EAGERLY (the backing cannot be
1013
+ * filled without running it), so MV import is order-dependent: the body's
1014
+ * sources — including another MV's backing for MV-over-MV — must already be
1015
+ * registered. The store's `rehydrateCatalog` orders MVs after tables/views
1016
+ * and resolves MV-over-MV chains by fixpoint retry. A body that cannot plan,
1017
+ * fills with duplicate keys, or fails the row-time eligibility gate in
1018
+ * `registerMaterializedView` throws (after {@link materializeView} rolls the
1019
+ * half-built backing back), and the caller records it as a per-entry
1020
+ * rehydration error.
1021
+ *
1022
+ * **Adopt fast path.** A pre-existing table at the backing name in the MV's
1023
+ * own backing module (a durable host's phase-1 rehydration of its backing)
1024
+ * is ADOPTED — registered as-is, no body re-execution — iff ALL gates pass
1025
+ * (see {@link tryAdoptPreExistingBacking}); otherwise it is dropped and the
1026
+ * MV refills through {@link materializeView}. Only import ever adopts —
1027
+ * create and refresh are unchanged.
1028
+ */
1029
+ private importMaterializedView;
1030
+ /**
1031
+ * The adopt-without-refill gate check + adopt for a pre-existing same-module
1032
+ * backing during MV import. Returns true when the backing was adopted; false
1033
+ * means "fall back to drop+refill". `shape` is the caller's pre-derived
1034
+ * backing shape (derived before any drop — see {@link importMaterializedView}).
1035
+ * Gates, of five (the caller already verified gate 1, same-module, and
1036
+ * gate 5, `trustBackings`):
1037
+ *
1038
+ * 2. **Shape** — `backingShapeMatches(preExisting, shape)`: the persisted
1039
+ * backing is column-for-column what the re-planned body would build
1040
+ * (names, logical types, not-null, collation, physical PK).
1041
+ * 3. **bodyHash** — automatic by construction: the catalog persists DDL and
1042
+ * import re-parses it, recomputing `computeBodyHash` from the same
1043
+ * canonical definition — there is no independently persisted hash that
1044
+ * could diverge, so no runtime check is possible or needed.
1045
+ * 4. **Sources** — every table the body reads lives in the SAME module as
1046
+ * the backing (one storage substrate ⇒ the divergence window is the
1047
+ * documented crash window the marker attests against; a cross-module
1048
+ * source — e.g. memory — was itself just recomputed, so persisted backing
1049
+ * rows may be stale relative to it), AND every source that is itself a
1050
+ * maintained table was ADOPTED this session (`adoptedBackings`) — a
1051
+ * refilled upstream may hold new content its dependents must reflect.
1052
+ * (The caller's pending-derivations gate guarantees every maintained
1053
+ * source's own entry has already imported, so derivation presence is
1054
+ * decidable here.)
1055
+ *
1056
+ * A throw from `adoptMaterializedView` itself (the row-time eligibility gate
1057
+ * in registration) propagates — per-entry error, backing left registered as
1058
+ * a plain (derivation-less) table.
1059
+ */
1060
+ private tryAdoptPreExistingBacking;
410
1061
  /**
411
1062
  * Import a table schema without calling module.create().
412
1063
  * Uses module.connect() to bind to existing storage.
@@ -414,6 +1065,13 @@ export declare class SchemaManager {
414
1065
  private importTable;
415
1066
  /**
416
1067
  * Import an index schema without calling module.createIndex().
1068
+ *
1069
+ * Reconstructs the index with full fidelity from the re-parsed DDL so a
1070
+ * `CREATE [UNIQUE] INDEX ... (col [COLLATE x]) [WHERE ...]` survives a
1071
+ * catalog round-trip: per-column collation, the UNIQUE flag, the partial
1072
+ * predicate, and (for a unique index) the synthesized `derivedFromIndex`
1073
+ * UNIQUE constraint — mirroring the live `buildIndexSchema` + the shared
1074
+ * {@link appendIndexToTableSchema} that {@link createIndex} uses.
417
1075
  */
418
1076
  private importIndex;
419
1077
  }