@quereus/quereus 4.20.0 → 4.20.2

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 (400) hide show
  1. package/README.md +2 -0
  2. package/dist/src/common/types.d.ts +4 -4
  3. package/dist/src/index.d.ts +1 -1
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +3 -2
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/schema/catalog-rendering.js +13 -1
  8. package/dist/src/schema/catalog-rendering.js.map +1 -1
  9. package/dist/src/schema/catalog.d.ts +35 -2
  10. package/dist/src/schema/catalog.d.ts.map +1 -1
  11. package/dist/src/schema/catalog.js +42 -33
  12. package/dist/src/schema/catalog.js.map +1 -1
  13. package/dist/src/schema/schema-differ.d.ts +1 -1
  14. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  15. package/dist/src/schema/schema-differ.js +195 -33
  16. package/dist/src/schema/schema-differ.js.map +1 -1
  17. package/dist/src/schema/unique-enforcement.d.ts +23 -1
  18. package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
  19. package/dist/src/schema/unique-enforcement.js +43 -1
  20. package/dist/src/schema/unique-enforcement.js.map +1 -1
  21. package/dist/src/vtab/memory/layer/manager.d.ts +15 -12
  22. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  23. package/dist/src/vtab/memory/layer/manager.js +87 -100
  24. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  25. package/package.json +7 -4
  26. package/test/README.md +173 -0
  27. package/test/logic/01-basic.sqllogic +39 -0
  28. package/test/logic/01.1-select-projection-extras.sqllogic +130 -0
  29. package/test/logic/01.2-strings.sqllogic +43 -0
  30. package/test/logic/01.5-insert-select.sqllogic +237 -0
  31. package/test/logic/01.6-update-extras.sqllogic +118 -0
  32. package/test/logic/01.7-update-from.sqllogic +67 -0
  33. package/test/logic/01.8-delete-extras.sqllogic +122 -0
  34. package/test/logic/01.8.1-delete-range-cow.sqllogic +115 -0
  35. package/test/logic/01.9-query-expr-dml-gates.sqllogic +32 -0
  36. package/test/logic/01.9-query-expr-dml.sqllogic +171 -0
  37. package/test/logic/01.9-query-expr-values.sqllogic +111 -0
  38. package/test/logic/01.9.1-limit-over-dml-subquery.sqllogic +119 -0
  39. package/test/logic/02-filters.sqllogic +54 -0
  40. package/test/logic/02-smoke.sqllogic +62 -0
  41. package/test/logic/02.1-bind-parameters.sqllogic +223 -0
  42. package/test/logic/03-expressions.sqllogic +190 -0
  43. package/test/logic/03.1-quoted-identifiers.sqllogic +55 -0
  44. package/test/logic/03.4-defaults.sqllogic +554 -0
  45. package/test/logic/03.4.1-default-edge-cases.sqllogic +99 -0
  46. package/test/logic/03.5-tvf.sqllogic +61 -0
  47. package/test/logic/03.6-type-system.sqllogic +544 -0
  48. package/test/logic/03.6.1-numeric-text-comparison-coercion.sqllogic +244 -0
  49. package/test/logic/03.6.2-value-to-text.sqllogic +224 -0
  50. package/test/logic/03.7-bigint-mixed-arithmetic.sqllogic +65 -0
  51. package/test/logic/03.8-not-precedence.sqllogic +255 -0
  52. package/test/logic/03.9-is-bool-predicate.sqllogic +150 -0
  53. package/test/logic/03.9.1-is-bool-predicate-partial-index.sqllogic +34 -0
  54. package/test/logic/04-order-by.sqllogic +38 -0
  55. package/test/logic/04-transactions.sqllogic +239 -0
  56. package/test/logic/04a-savepoint-lazy-attach.sqllogic +122 -0
  57. package/test/logic/05-vtab_memory.sqllogic +50 -0
  58. package/test/logic/05.0.1-vtab-memory-unique-index-collation.sqllogic +34 -0
  59. package/test/logic/05.1-composite-pk-range-scan.sqllogic +147 -0
  60. package/test/logic/05.1.1-secondary-index-range-scan.sqllogic +56 -0
  61. package/test/logic/05.2-cast-seek-correctness.sqllogic +124 -0
  62. package/test/logic/06-builtin_functions.sqllogic +149 -0
  63. package/test/logic/06.1-string-functions.sqllogic +92 -0
  64. package/test/logic/06.1.3-like-glob-edges.sqllogic +53 -0
  65. package/test/logic/06.2-math-functions.sqllogic +82 -0
  66. package/test/logic/06.3-schema.sqllogic +48 -0
  67. package/test/logic/06.3.1-schema-all-schemas.sqllogic +39 -0
  68. package/test/logic/06.3.2-schema-foreign-keys.sqllogic +208 -0
  69. package/test/logic/06.3.3-introspection-tags.sqllogic +202 -0
  70. package/test/logic/06.3.3.1-introspection-tags-index.sqllogic +74 -0
  71. package/test/logic/06.3.4-view-info.sqllogic +378 -0
  72. package/test/logic/06.3.5-column-info.sqllogic +347 -0
  73. package/test/logic/06.3.6-schema-views.sqllogic +29 -0
  74. package/test/logic/06.4-schema-search-path.sqllogic +354 -0
  75. package/test/logic/06.4.1-schema-case-insensitive.sqllogic +83 -0
  76. package/test/logic/06.4.2-collation-extras.sqllogic +472 -0
  77. package/test/logic/06.4.2.1-collation-index-access-paths.sqllogic +140 -0
  78. package/test/logic/06.4.3-write-path-collation.sqllogic +99 -0
  79. package/test/logic/06.4.4-comparison-collation-precedence.sqllogic +342 -0
  80. package/test/logic/06.4.5-any-collate-declared-keys.sqllogic +92 -0
  81. package/test/logic/06.5-polymorphic-types.sqllogic +169 -0
  82. package/test/logic/06.5.1-conversion-functions.sqllogic +173 -0
  83. package/test/logic/06.5.2-scalar-minmax.sqllogic +16 -0
  84. package/test/logic/06.5.3-undeclared-return-type-comparison.sqllogic +244 -0
  85. package/test/logic/06.5.4-declared-return-type-builtins.sqllogic +288 -0
  86. package/test/logic/06.6-aggregate-extended.sqllogic +78 -0
  87. package/test/logic/06.7-json-extended.sqllogic +53 -0
  88. package/test/logic/06.8-json-path-operators.sqllogic +99 -0
  89. package/test/logic/06.9-json-canonical-key.sqllogic +65 -0
  90. package/test/logic/06.9.1-json-coerce-once.sqllogic +417 -0
  91. package/test/logic/06.9.1.1-json-coerce-once-index.sqllogic +39 -0
  92. package/test/logic/06.9.2-json-structural-equality.sqllogic +382 -0
  93. package/test/logic/06.9.2.1-json-structural-equality-index.sqllogic +76 -0
  94. package/test/logic/06.9.3-json-index-range-seek.sqllogic +205 -0
  95. package/test/logic/07-aggregates.sqllogic +193 -0
  96. package/test/logic/07.1-aggregate-filter-clause.sqllogic +12 -0
  97. package/test/logic/07.2-aggregate-order-by.sqllogic +11 -0
  98. package/test/logic/07.3-group-by-extras.sqllogic +602 -0
  99. package/test/logic/07.3.1-group-by-order-by-key.sqllogic +164 -0
  100. package/test/logic/07.3.2-grouped-select-list-shape.sqllogic +231 -0
  101. package/test/logic/07.4-group-by-filter-composite-pk.sqllogic +120 -0
  102. package/test/logic/07.5-sum-mixed-exact-and-float.sqllogic +151 -0
  103. package/test/logic/07.5-window.sqllogic +1941 -0
  104. package/test/logic/07.5.1-window-named.sqllogic +13 -0
  105. package/test/logic/07.5.2-window-nth-value.sqllogic +13 -0
  106. package/test/logic/07.6-subqueries.sqllogic +78 -0
  107. package/test/logic/07.6.1-subquery-extras.sqllogic +93 -0
  108. package/test/logic/07.7-and-or-short-circuit.sqllogic +58 -0
  109. package/test/logic/07.7-in-subquery-caching.sqllogic +174 -0
  110. package/test/logic/07.7-scalar-agg-decorrelation.sqllogic +197 -0
  111. package/test/logic/07.7.1-in-extras.sqllogic +158 -0
  112. package/test/logic/07.7.1-scalar-agg-decorrelation-filter.sqllogic +105 -0
  113. package/test/logic/07.7.2-scalar-agg-decorrelation-nested.sqllogic +115 -0
  114. package/test/logic/07.7.3-exists-in-select-decorrelation.sqllogic +107 -0
  115. package/test/logic/07.7.4-where-conjunct-ordering.sqllogic +121 -0
  116. package/test/logic/07.7.5-filter-lost-under-index-order.sqllogic +134 -0
  117. package/test/logic/07.7.6-correlated-predicate-scope.sqllogic +178 -0
  118. package/test/logic/07.7.7-join-source-scope-shadowing.sqllogic +137 -0
  119. package/test/logic/07.7.8-correlated-ref-to-computed-column.sqllogic +165 -0
  120. package/test/logic/07.7.9-conjunct-monotonicity.sqllogic +200 -0
  121. package/test/logic/07.8-correlated-subquery-edges.sqllogic +71 -0
  122. package/test/logic/07.8.1-correlated-in-decorrelation-gates.sqllogic +156 -0
  123. package/test/logic/07.9-in-value-list.sqllogic +154 -0
  124. package/test/logic/07.9.1-in-value-list-composite-index.sqllogic +38 -0
  125. package/test/logic/08-views.sqllogic +64 -0
  126. package/test/logic/08.1-semi-anti-join.sqllogic +191 -0
  127. package/test/logic/08.1-view-edge-cases.sqllogic +118 -0
  128. package/test/logic/08.1.1-uncorrelated-in-semijoin.sqllogic +251 -0
  129. package/test/logic/08.2-existence-flag-semijoin-recovery.sqllogic +197 -0
  130. package/test/logic/08.3-existence-flag-inner-recovery.sqllogic +102 -0
  131. package/test/logic/08.4-key-set-semi-join.sqllogic +447 -0
  132. package/test/logic/09-set_operations.sqllogic +244 -0
  133. package/test/logic/09.1-set-op-cross-collation.sqllogic +230 -0
  134. package/test/logic/10-distinct_datatypes.sqllogic +127 -0
  135. package/test/logic/10.1-ddl-lifecycle.sqllogic +203 -0
  136. package/test/logic/10.1.1-create-table-syntax-edges.sqllogic +47 -0
  137. package/test/logic/10.1.2-ddl-in-transaction.sqllogic +143 -0
  138. package/test/logic/10.1.2.1-add-constraint-in-transaction.sqllogic +59 -0
  139. package/test/logic/10.1.3-ddl-drop-in-transaction.sqllogic +187 -0
  140. package/test/logic/10.1.3.1-drop-constraint-in-transaction.sqllogic +45 -0
  141. package/test/logic/10.1.4-create-table-duplicate-constraint-names.sqllogic +149 -0
  142. package/test/logic/10.1.4-ddl-transaction-policy.sqllogic +314 -0
  143. package/test/logic/10.1.5-alter-add-constraint-minted-name-disambiguation.sqllogic +219 -0
  144. package/test/logic/10.1.5-create-index-lifecycle.sqllogic +72 -0
  145. package/test/logic/10.1.6-ddl-transaction-policy-index.sqllogic +143 -0
  146. package/test/logic/10.1.7-create-table-default-type-check.sqllogic +119 -0
  147. package/test/logic/10.1.8-alter-add-check-existing-rows.sqllogic +117 -0
  148. package/test/logic/10.2-column-features.sqllogic +365 -0
  149. package/test/logic/10.2.1-table-options-rejection.sqllogic +63 -0
  150. package/test/logic/10.2.2-default-collation-memory.sqllogic +30 -0
  151. package/test/logic/10.3-function-features.sqllogic +247 -0
  152. package/test/logic/10.4-schema-scale.sqllogic +168 -0
  153. package/test/logic/10.4.1-schema-scale-indexes.sqllogic +121 -0
  154. package/test/logic/10.5-indexes.sqllogic +164 -0
  155. package/test/logic/10.5.1-partial-indexes.sqllogic +526 -0
  156. package/test/logic/10.5.2-expression-indexes.sqllogic +34 -0
  157. package/test/logic/10.5.3-desc-index-ordering.sqllogic +130 -0
  158. package/test/logic/10.5.4-composite-pk-index-update-phantom.sqllogic +55 -0
  159. package/test/logic/10.5.5-index-name-uniqueness.sqllogic +76 -0
  160. package/test/logic/10.5.6-minmax-index-boundary.sqllogic +204 -0
  161. package/test/logic/10.5.7-implicit-unique-index-lifecycle.sqllogic +1216 -0
  162. package/test/logic/10.6-distinct-edge-cases.sqllogic +119 -0
  163. package/test/logic/100-predicate-normalization-edge-cases.sqllogic +238 -0
  164. package/test/logic/100.1-where-extras.sqllogic +163 -0
  165. package/test/logic/100.1.1-where-join-on-order-indexed.sqllogic +35 -0
  166. package/test/logic/101-builtin-mutation-kills.sqllogic +974 -0
  167. package/test/logic/101-transaction-edge-cases.sqllogic +395 -0
  168. package/test/logic/102-schema-catalog-edge-cases.sqllogic +252 -0
  169. package/test/logic/102-unique-constraints.sqllogic +145 -0
  170. package/test/logic/102.0.1-schema-catalog-indexed-table.sqllogic +32 -0
  171. package/test/logic/102.1-unique-edge-cases.sqllogic +111 -0
  172. package/test/logic/102.1.1-unique-index-creation-edge-cases.sqllogic +75 -0
  173. package/test/logic/102.2-unique-collation.sqllogic +181 -0
  174. package/test/logic/102.2.1-unique-collation-index-derived.sqllogic +305 -0
  175. package/test/logic/103-database-options-edge-cases.sqllogic +108 -0
  176. package/test/logic/103.1-pragma-boolean-values.sqllogic +126 -0
  177. package/test/logic/104-emit-mutation-kills.sqllogic +236 -0
  178. package/test/logic/105-vtab-memory-mutation-kills.sqllogic +754 -0
  179. package/test/logic/105.1-vtab-memory-index-mutation-kills.sqllogic +540 -0
  180. package/test/logic/106-constraint-extractor-mutation-kills.sqllogic +350 -0
  181. package/test/logic/107-temporal-arithmetic-mutation-kills.sqllogic +833 -0
  182. package/test/logic/108-cardinality-estimation.sqllogic +146 -0
  183. package/test/logic/108.1-analyze-name-resolution.sqllogic +102 -0
  184. package/test/logic/109-aggregate-physical-selection.sqllogic +103 -0
  185. package/test/logic/11-joins.sqllogic +86 -0
  186. package/test/logic/11.1-join-using.sqllogic +267 -0
  187. package/test/logic/11.2-comma-join.sqllogic +35 -0
  188. package/test/logic/11.3-index-nested-loop-join.sqllogic +305 -0
  189. package/test/logic/11.3-mismatched-collation-join.sqllogic +74 -0
  190. package/test/logic/11.4-hash-join-side-swap.sqllogic +118 -0
  191. package/test/logic/110-scan-emitter-mutation-kills.sqllogic +121 -0
  192. package/test/logic/110.1-scan-emitter-index-scan-kills.sqllogic +47 -0
  193. package/test/logic/12-empty-primary-key.sqllogic +124 -0
  194. package/test/logic/12-join_padding_order.sqllogic +58 -0
  195. package/test/logic/12.1-orderby-index-consumption.sqllogic +40 -0
  196. package/test/logic/13-cte.sqllogic +137 -0
  197. package/test/logic/13.1-cte-multiple-recursive.sqllogic +104 -0
  198. package/test/logic/13.10-cte-qualified-name.sqllogic +136 -0
  199. package/test/logic/13.11-unreferenced-dml-cte.sqllogic +414 -0
  200. package/test/logic/13.12-nested-dml-cte-rejected.sqllogic +280 -0
  201. package/test/logic/13.2-cte-bind-params.sqllogic +98 -0
  202. package/test/logic/13.3-cte-edge-cases.sqllogic +120 -0
  203. package/test/logic/13.4-cte-extras.sqllogic +98 -0
  204. package/test/logic/13.5-cte-join-order.sqllogic +166 -0
  205. package/test/logic/13.6-cte-dml-runs-once.sqllogic +318 -0
  206. package/test/logic/13.7-cte-sibling-visibility.sqllogic +227 -0
  207. package/test/logic/13.8-insert-with-clause-visibility.sqllogic +254 -0
  208. package/test/logic/13.9-schema-authored-cte-isolation.sqllogic +328 -0
  209. package/test/logic/13.9.1-schema-authored-schema-path-isolation.sqllogic +408 -0
  210. package/test/logic/14-utilities.sqllogic +168 -0
  211. package/test/logic/15-timespan.sqllogic +279 -0
  212. package/test/logic/15.1-semantic-ordering.sqllogic +960 -0
  213. package/test/logic/15.1.1-json-check-coercion.sqllogic +178 -0
  214. package/test/logic/15.1.2-semantic-ordering-index.sqllogic +41 -0
  215. package/test/logic/15.1.3-declared-form-write-contract.sqllogic +519 -0
  216. package/test/logic/16-epoch.sqllogic +187 -0
  217. package/test/logic/17-weekday-modifier.sqllogic +78 -0
  218. package/test/logic/18-json-string-escapes.sqllogic +86 -0
  219. package/test/logic/18-strftime-extended-formats.sqllogic +68 -0
  220. package/test/logic/20-empty-single-row.sqllogic +261 -0
  221. package/test/logic/21-null-edge-cases.sqllogic +227 -0
  222. package/test/logic/21.1-where-null-comparisons.sqllogic +151 -0
  223. package/test/logic/21.1.1-where-null-comparisons-secondary-index.sqllogic +35 -0
  224. package/test/logic/21.2-between-edges.sqllogic +157 -0
  225. package/test/logic/22-boundary-values.sqllogic +175 -0
  226. package/test/logic/23-self-joins-duplicates.sqllogic +74 -0
  227. package/test/logic/24-builtin-branches.sqllogic +611 -0
  228. package/test/logic/24.1-substr-extras.sqllogic +75 -0
  229. package/test/logic/24.2-random-extras.sqllogic +39 -0
  230. package/test/logic/25-aggregate-edge-cases.sqllogic +289 -0
  231. package/test/logic/25.1-nested-aggregates.sqllogic +74 -0
  232. package/test/logic/25.2-having-edge-cases.sqllogic +318 -0
  233. package/test/logic/25.3-aggregate-isnull-empty.sqllogic +16 -0
  234. package/test/logic/25.4-groupby-fd-constant-empty.sqllogic +55 -0
  235. package/test/logic/25.5-ungrouped-aggregate-column-free-select-item.sqllogic +196 -0
  236. package/test/logic/26-join-edge-cases.sqllogic +333 -0
  237. package/test/logic/26.1-left-join-isnull-on-notnull.sqllogic +26 -0
  238. package/test/logic/26.2-left-join-on-vs-where.sqllogic +67 -0
  239. package/test/logic/26.3-join-on-constants.sqllogic +61 -0
  240. package/test/logic/26.4-join-on-is-null-nullable.sqllogic +44 -0
  241. package/test/logic/27-window-edge-cases.sqllogic +206 -0
  242. package/test/logic/27.1-window-groups-frame.sqllogic +13 -0
  243. package/test/logic/27.2-window-exclude.sqllogic +13 -0
  244. package/test/logic/27.3-window-json-aggregation.sqllogic +66 -0
  245. package/test/logic/28-set-ops-sort-edge-cases.sqllogic +444 -0
  246. package/test/logic/28.1-compound-limit-offset.sqllogic +143 -0
  247. package/test/logic/28.2-orderby-expression-extras.sqllogic +698 -0
  248. package/test/logic/28.2-set-op-branch-types.sqllogic +217 -0
  249. package/test/logic/29-constraint-edge-cases.sqllogic +442 -0
  250. package/test/logic/29.1-column-level-conflict-clause.sqllogic +171 -0
  251. package/test/logic/29.2-table-level-pk-conflict-clause.sqllogic +113 -0
  252. package/test/logic/40-constraints.sqllogic +418 -0
  253. package/test/logic/40.1-pk-desc-direction.sqllogic +76 -0
  254. package/test/logic/40.2-check-extras.sqllogic +683 -0
  255. package/test/logic/41-alter-table.sqllogic +191 -0
  256. package/test/logic/41-fk-cascade-conflict-and-self-ref.sqllogic +263 -0
  257. package/test/logic/41-fk-cross-schema.sqllogic +155 -0
  258. package/test/logic/41-fk-extended-targets.sqllogic +173 -0
  259. package/test/logic/41-foreign-keys.sqllogic +1001 -0
  260. package/test/logic/41-generated-column-errors.sqllogic +225 -0
  261. package/test/logic/41-generated-column-extras.sqllogic +598 -0
  262. package/test/logic/41-generated-column-scope.sqllogic +329 -0
  263. package/test/logic/41-generated-columns.sqllogic +361 -0
  264. package/test/logic/41.1-alter-pk.sqllogic +230 -0
  265. package/test/logic/41.1-fk-collation-conflict.sqllogic +277 -0
  266. package/test/logic/41.10-alter-drop-column-foreign-key.sqllogic +274 -0
  267. package/test/logic/41.10.1-alter-drop-column-unique-index.sqllogic +169 -0
  268. package/test/logic/41.10.2-alter-drop-column-check-and-assertion.sqllogic +1616 -0
  269. package/test/logic/41.10.3-alter-drop-column-referencing-fk.sqllogic +292 -0
  270. package/test/logic/41.10.4-drop-object-expression-dependents.sqllogic +602 -0
  271. package/test/logic/41.11-deferred-fk-with-rename.sqllogic +232 -0
  272. package/test/logic/41.12-alter-default-coercion.sqllogic +200 -0
  273. package/test/logic/41.13-alter-add-column-generated-backfill.sqllogic +566 -0
  274. package/test/logic/41.14-alter-add-column-subquery-backfill.sqllogic +129 -0
  275. package/test/logic/41.15-alter-column-default-type-check.sqllogic +178 -0
  276. package/test/logic/41.16-fk-unenforceable.sqllogic +364 -0
  277. package/test/logic/41.2-alter-column.sqllogic +382 -0
  278. package/test/logic/41.2.1-alter-column-retype-deleted-row-memory.sqllogic +32 -0
  279. package/test/logic/41.2.2-alter-column-retype-index-rebuild.sqllogic +77 -0
  280. package/test/logic/41.2.3-alter-column-set-not-null-pk-backfill.sqllogic +310 -0
  281. package/test/logic/41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic +37 -0
  282. package/test/logic/41.3-alter-add-column-unique.sqllogic +184 -0
  283. package/test/logic/41.3-alter-rename-propagation.sqllogic +2352 -0
  284. package/test/logic/41.3.1-alter-rename-index-propagation.sqllogic +94 -0
  285. package/test/logic/41.4-alter-add-column-constraints.sqllogic +855 -0
  286. package/test/logic/41.5-alter-misc.sqllogic +48 -0
  287. package/test/logic/41.5-cross-schema-foreign-keys.sqllogic +253 -0
  288. package/test/logic/41.6-alter-drop-rename-constraint.sqllogic +354 -0
  289. package/test/logic/41.6.1-alter-drop-constraint-index-derived.sqllogic +22 -0
  290. package/test/logic/41.7-alter-column-collate.sqllogic +105 -0
  291. package/test/logic/41.7.1-alter-column-collate-unique.sqllogic +45 -0
  292. package/test/logic/41.7.2-alter-column-collate-unique-store.sqllogic +208 -0
  293. package/test/logic/41.7.2.1-alter-column-collate-unique-index-store.sqllogic +114 -0
  294. package/test/logic/41.7.3-alter-column-retype-unique.sqllogic +293 -0
  295. package/test/logic/41.7.3.1-alter-column-retype-staged-rows-memory.sqllogic +41 -0
  296. package/test/logic/41.7.3.2-alter-column-retype-unique-index.sqllogic +72 -0
  297. package/test/logic/41.7.4-alter-column-retype-semantic-memory.sqllogic +445 -0
  298. package/test/logic/41.7.4.1-alter-column-retype-semantic-index-memory.sqllogic +91 -0
  299. package/test/logic/41.7.5-alter-column-collate-pk-staged-delete-memory.sqllogic +106 -0
  300. package/test/logic/41.8-alter-add-constraint-unique-fk.sqllogic +275 -0
  301. package/test/logic/41.8-alter-savepoint-staged-rows.sqllogic +443 -0
  302. package/test/logic/41.8.1-alter-rename-savepoint-staged-rows.sqllogic +408 -0
  303. package/test/logic/41.9-alter-constraint-body-change.sqllogic +180 -0
  304. package/test/logic/41.9-fk-restrict-batched.sqllogic +290 -0
  305. package/test/logic/42-committed-snapshot.sqllogic +254 -0
  306. package/test/logic/42-returning.sqllogic +159 -0
  307. package/test/logic/42.1-returning-extras.sqllogic +232 -0
  308. package/test/logic/42.2-returning-stored-row.sqllogic +165 -0
  309. package/test/logic/43-default-nullability.sqllogic +131 -0
  310. package/test/logic/43-transition-constraints.sqllogic +341 -0
  311. package/test/logic/43.1-default-collation.sqllogic +140 -0
  312. package/test/logic/43.1-notnull-or-conflict.sqllogic +79 -0
  313. package/test/logic/43.2-deferred-check-new-on-delete.sqllogic +95 -0
  314. package/test/logic/43.3-nullable-primary-key.sqllogic +587 -0
  315. package/test/logic/44-determinism-validation.sqllogic +164 -0
  316. package/test/logic/44-orthogonality.sqllogic +146 -0
  317. package/test/logic/44.1-nondeterministic-schema.sqllogic +316 -0
  318. package/test/logic/45-udf-determinism.sqllogic +39 -0
  319. package/test/logic/46-mutation-context.sqllogic +595 -0
  320. package/test/logic/47-upsert.sqllogic +255 -0
  321. package/test/logic/47.1-upsert-conflict-targets.sqllogic +169 -0
  322. package/test/logic/47.2-replace-and-or-clauses.sqllogic +164 -0
  323. package/test/logic/47.2.1-pk-replace-secondary-unique.sqllogic +374 -0
  324. package/test/logic/47.3-engine-or-fail.sqllogic +122 -0
  325. package/test/logic/47.3-upsert-conflict-target-collation.sqllogic +139 -0
  326. package/test/logic/47.3.1-upsert-conflict-index-derived-collation.sqllogic +25 -0
  327. package/test/logic/47.4-upsert-conflict-target-affinity.sqllogic +59 -0
  328. package/test/logic/47.5-upsert-do-update-constraints.sqllogic +440 -0
  329. package/test/logic/47.6-upsert-do-update-decomposed.sqllogic +100 -0
  330. package/test/logic/49-reference-graph.sqllogic +84 -0
  331. package/test/logic/50-declarative-schema.sqllogic +2550 -0
  332. package/test/logic/50-metadata-tags.sqllogic +1033 -0
  333. package/test/logic/50.0.1-metadata-tags-index.sqllogic +141 -0
  334. package/test/logic/50.1-declare-schema-pk.sqllogic +150 -0
  335. package/test/logic/50.2-declare-schema-renames.sqllogic +949 -0
  336. package/test/logic/50.2.1-declare-schema-index-renames.sqllogic +173 -0
  337. package/test/logic/50.3-declare-schema-duplicate-names.sqllogic +280 -0
  338. package/test/logic/50.4-declare-schema-apply-restore.sqllogic +192 -0
  339. package/test/logic/51-lens-foundation.sqllogic +147 -0
  340. package/test/logic/51-materialized-views.sqllogic +376 -0
  341. package/test/logic/51.5-materialized-views-coarsened-key.sqllogic +198 -0
  342. package/test/logic/51.7-maintained-table-attach-detach.sqllogic +468 -0
  343. package/test/logic/51.8-maintained-table-declared-constraints.sqllogic +440 -0
  344. package/test/logic/51.85-maintained-table-parent-fk.sqllogic +103 -0
  345. package/test/logic/51.9-maintained-table-secondary-unique.sqllogic +237 -0
  346. package/test/logic/51.9.1-maintained-table-partial-unique.sqllogic +36 -0
  347. package/test/logic/52-lens-overrides.sqllogic +566 -0
  348. package/test/logic/53-materialized-views-rowtime.sqllogic +1601 -0
  349. package/test/logic/53-reserved-tags.sqllogic +252 -0
  350. package/test/logic/53.1-materialized-view-write-through.sqllogic +329 -0
  351. package/test/logic/53.2-materialized-view-rename-propagation.sqllogic +483 -0
  352. package/test/logic/53.3-materialized-view-constraint-only-ddl.sqllogic +409 -0
  353. package/test/logic/53.3.1-materialized-view-index-ddl-irrelevance.sqllogic +29 -0
  354. package/test/logic/53.4-materialized-view-structural-alter-restore.sqllogic +436 -0
  355. package/test/logic/54-covering-mv-enforcement.sqllogic +314 -0
  356. package/test/logic/54.1-covering-mv-partial-enforcement.sqllogic +34 -0
  357. package/test/logic/55-internal-eviction-reporting.sqllogic +89 -0
  358. package/test/logic/55-lens-prover.sqllogic +202 -0
  359. package/test/logic/55.1-eviction-restrict-fk.sqllogic +148 -0
  360. package/test/logic/55.5-lens-authored-inverse.sqllogic +1468 -0
  361. package/test/logic/80-grow-retrieve-pass.sqllogic +79 -0
  362. package/test/logic/81-quickpick.sqllogic +24 -0
  363. package/test/logic/82-bloom-join.sqllogic +185 -0
  364. package/test/logic/83-merge-join.sqllogic +280 -0
  365. package/test/logic/84-asof-scan.sqllogic +238 -0
  366. package/test/logic/84-key-cardinality.sqllogic +50 -0
  367. package/test/logic/85-relational-const-folding.sqllogic +51 -0
  368. package/test/logic/86-scalar-cse.sqllogic +42 -0
  369. package/test/logic/90-error_paths.sqllogic +114 -0
  370. package/test/logic/90.1-parse-errors.sqllogic +77 -0
  371. package/test/logic/90.2-alter-table-errors.sqllogic +53 -0
  372. package/test/logic/90.2.1-alter-extra-errors.sqllogic +51 -0
  373. package/test/logic/90.3-expression-errors.sqllogic +43 -0
  374. package/test/logic/90.4-dml-errors.sqllogic +47 -0
  375. package/test/logic/90.5-unsupported-join-types.sqllogic +37 -0
  376. package/test/logic/90.5.1-right-full-join-read.sqllogic +157 -0
  377. package/test/logic/90.6-select-error-paths.sqllogic +57 -0
  378. package/test/logic/91-merge-join-edge-cases.sqllogic +159 -0
  379. package/test/logic/92-hash-aggregate-edge-cases.sqllogic +139 -0
  380. package/test/logic/93-ddl-view-edge-cases.sqllogic +104 -0
  381. package/test/logic/93.1-view-error-paths.sqllogic +74 -0
  382. package/test/logic/93.2-view-mutation-pending.sqllogic +108 -0
  383. package/test/logic/93.3-view-mutation-or-clause.sqllogic +60 -0
  384. package/test/logic/93.4-view-mutation.sqllogic +4881 -0
  385. package/test/logic/93.4.1-view-mutation-partial-unique-cardinality.sqllogic +31 -0
  386. package/test/logic/93.5-authored-inverse.sqllogic +415 -0
  387. package/test/logic/93.6-set-op-flagless-write.sqllogic +862 -0
  388. package/test/logic/94-tvf-edge-cases.sqllogic +58 -0
  389. package/test/logic/94.1-limit-offset-edge-cases.sqllogic +109 -0
  390. package/test/logic/94.2-limit-offset-extras.sqllogic +98 -0
  391. package/test/logic/95-assertions.sqllogic +1417 -0
  392. package/test/logic/96-subquery-edge-cases.sqllogic +276 -0
  393. package/test/logic/97-json-function-edge-cases.sqllogic +633 -0
  394. package/test/logic/97.1-json-blob-and-special-values.sqllogic +92 -0
  395. package/test/logic/98-temporal-edge-cases.sqllogic +515 -0
  396. package/test/logic/99-conversion-edge-cases.sqllogic +325 -0
  397. package/test/logic/99.0.1-schema-index-listing.sqllogic +21 -0
  398. package/test/logic/99.1-cast-syntax-extras.sqllogic +167 -0
  399. package/test/logic/drop-unique-index.sqllogic +88 -0
  400. package/test/logic/pushdown-test.sqllogic +36 -0
@@ -0,0 +1,949 @@
1
+ -- Declarative schema: rename detection via quereus.id / quereus.previous_name hints
2
+
3
+ -- ===================================
4
+ -- 1. Table rename via quereus.previous_name
5
+ -- ===================================
6
+
7
+ create table client (client_id integer primary key, name text not null);
8
+ insert into client values (1, 'Alice'), (2, 'Bob');
9
+
10
+ declare schema main {
11
+ table customer {
12
+ client_id integer primary key,
13
+ name text not null
14
+ } with tags ("quereus.previous_name" = 'client')
15
+ }
16
+
17
+ -- run
18
+
19
+ -- Diff should be a single RENAME, no drops or creates
20
+ diff schema main;
21
+ → [{"ddl": "ALTER TABLE client RENAME TO customer"}]
22
+
23
+ apply schema main;
24
+
25
+ -- run
26
+
27
+ -- Data preserved under the new name
28
+ select count(*) as cnt from customer;
29
+ → [{"cnt": 2}]
30
+
31
+ select * from customer order by client_id;
32
+ → [{"client_id": 1, "name": "Alice"}, {"client_id": 2, "name": "Bob"}]
33
+
34
+ -- Round-trip: re-diffing should now be empty
35
+ diff schema main;
36
+ → []
37
+
38
+ drop table customer;
39
+
40
+ -- ===================================
41
+ -- 2. Table rename via quereus.id (id wins over previous_name)
42
+ -- ===================================
43
+
44
+ create table widget (id integer primary key, label text) with tags ("quereus.id" = 'tbl-thing');
45
+ insert into widget values (1, 'A'), (2, 'B');
46
+
47
+ -- Declare with same id but a previous_name pointing nowhere; id should still win.
48
+ declare schema main {
49
+ table thing {
50
+ id integer primary key,
51
+ label text
52
+ } with tags (
53
+ "quereus.id" = 'tbl-thing',
54
+ "quereus.previous_name" = 'does_not_exist'
55
+ )
56
+ }
57
+
58
+ -- run
59
+
60
+ diff schema main;
61
+ → [{"ddl": "ALTER TABLE widget RENAME TO thing"}]
62
+
63
+ apply schema main;
64
+
65
+ -- run
66
+
67
+ select * from thing order by id;
68
+ → [{"id": 1, "label": "A"}, {"id": 2, "label": "B"}]
69
+
70
+ drop table thing;
71
+
72
+ -- ===================================
73
+ -- 3. Column rename inside an otherwise-unchanged table
74
+ -- ===================================
75
+
76
+ create table employees (emp_id integer primary key, fullname text not null);
77
+ insert into employees values (10, 'Carol'), (20, 'Dan');
78
+
79
+ declare schema main {
80
+ table employees {
81
+ emp_id integer primary key,
82
+ full_name text not null with tags ("quereus.previous_name" = 'fullname')
83
+ }
84
+ }
85
+
86
+ -- run
87
+
88
+ diff schema main;
89
+ → [{"ddl": "ALTER TABLE employees RENAME COLUMN fullname TO full_name"}]
90
+
91
+ apply schema main;
92
+
93
+ -- run
94
+
95
+ select * from employees order by emp_id;
96
+ → [{"emp_id": 10, "full_name": "Carol"}, {"emp_id": 20, "full_name": "Dan"}]
97
+
98
+ diff schema main;
99
+ → []
100
+
101
+ drop table employees;
102
+
103
+ -- ===================================
104
+ -- 4. Multi-step history: comma-separated previous_name list
105
+ -- ===================================
106
+
107
+ -- Start from a table named 'a'; declared previous_name is 'a, b'.
108
+ create table a (id integer primary key, val text);
109
+ insert into a values (1, 'one'), (2, 'two');
110
+
111
+ declare schema main {
112
+ table c {
113
+ id integer primary key,
114
+ val text
115
+ } with tags ("quereus.previous_name" = 'a, b')
116
+ }
117
+
118
+ -- run
119
+
120
+ diff schema main;
121
+ → [{"ddl": "ALTER TABLE a RENAME TO c"}]
122
+
123
+ apply schema main;
124
+
125
+ -- run
126
+
127
+ select * from c order by id;
128
+ → [{"id": 1, "val": "one"}, {"id": 2, "val": "two"}]
129
+
130
+ drop table c;
131
+
132
+ -- Now do the same starting from 'b' — same declared schema should match either.
133
+ create table b (id integer primary key, val text);
134
+ insert into b values (3, 'three');
135
+
136
+ declare schema main {
137
+ table c {
138
+ id integer primary key,
139
+ val text
140
+ } with tags ("quereus.previous_name" = 'a, b')
141
+ }
142
+
143
+ -- run
144
+
145
+ diff schema main;
146
+ → [{"ddl": "ALTER TABLE b RENAME TO c"}]
147
+
148
+ apply schema main;
149
+
150
+ -- run
151
+
152
+ select * from c order by id;
153
+ → [{"id": 3, "val": "three"}]
154
+
155
+ drop table c;
156
+
157
+ -- ===================================
158
+ -- 5. Conflict: declared name and previous_name both resolve to existing actuals
159
+ -- ===================================
160
+
161
+ create table foo (id integer primary key, x text);
162
+ create table bar (id integer primary key, x text);
163
+
164
+ declare schema main {
165
+ table foo {
166
+ id integer primary key,
167
+ x text
168
+ } with tags ("quereus.previous_name" = 'bar')
169
+ }
170
+
171
+ -- run
172
+
173
+ -- Both 'foo' and 'bar' exist in actual; the rename hint conflicts with the name match.
174
+ diff schema main;
175
+ -- error: Rename conflict for table 'foo'
176
+
177
+ drop table foo;
178
+ drop table bar;
179
+
180
+ -- ===================================
181
+ -- 6. rename_policy = 'require-hint' rejects unhinted name change
182
+ -- ===================================
183
+
184
+ create table old_table (id integer primary key, x text);
185
+
186
+ declare schema main {
187
+ table new_table {
188
+ id integer primary key,
189
+ x text
190
+ }
191
+ }
192
+
193
+ -- run
194
+
195
+ apply schema main options (rename_policy = 'require-hint');
196
+ -- error: rename_policy = 'require-hint'
197
+
198
+ drop table old_table;
199
+
200
+ -- ===================================
201
+ -- 7. rename_policy = 'deny' produces drop+create even with hints present
202
+ -- ===================================
203
+
204
+ create table src_table (id integer primary key, val text);
205
+ insert into src_table values (1, 'keep');
206
+
207
+ declare schema main {
208
+ table dst_table {
209
+ id integer primary key,
210
+ val text
211
+ } with tags ("quereus.previous_name" = 'src_table')
212
+ }
213
+
214
+ -- run
215
+
216
+ -- Under deny, the hint is ignored. Drop + create wipes data.
217
+ apply schema main options (rename_policy = 'deny');
218
+
219
+ -- run
220
+
221
+ -- src_table is gone, dst_table is fresh and empty.
222
+ select count(*) as cnt from dst_table;
223
+ → [{"cnt": 0}]
224
+
225
+ drop table dst_table;
226
+
227
+ -- (Schema-hash stability with/without rename-hint tags is covered by the unit
228
+ -- tests for stripTagsFromDeclaredSchema in test/schema/catalog.spec.ts. Tags
229
+ -- are stripped before canonical DDL is generated, so this property is verified
230
+ -- without depending on the test runner's ability to capture and compare
231
+ -- explain-schema rows.)
232
+
233
+ -- ===================================
234
+ -- 8. Combined: table rename + column rename + new column add in one apply
235
+ -- ===================================
236
+
237
+ create table orig_t (a_id integer primary key, b text not null);
238
+ insert into orig_t values (1, 'hello'), (2, 'world');
239
+
240
+ -- A child table referencing orig_t to verify the FK survives the rename.
241
+ create table child_t (
242
+ id integer primary key,
243
+ parent_a integer not null,
244
+ constraint fk_parent foreign key (parent_a) references orig_t (a_id)
245
+ );
246
+ insert into child_t values (10, 1), (20, 2);
247
+
248
+ declare schema main {
249
+ table renamed_t {
250
+ a_id integer primary key,
251
+ b_renamed text not null with tags ("quereus.previous_name" = 'b'),
252
+ new_col text null default ''
253
+ } with tags ("quereus.previous_name" = 'orig_t')
254
+
255
+ table child_t {
256
+ id integer primary key,
257
+ parent_a integer not null,
258
+ constraint fk_parent foreign key (parent_a) references renamed_t (a_id)
259
+ }
260
+ }
261
+
262
+ -- run
263
+
264
+ apply schema main;
265
+
266
+ -- run
267
+
268
+ -- Both parent's data and child's FK survive
269
+ select count(*) as cnt from renamed_t;
270
+ → [{"cnt": 2}]
271
+
272
+ select * from renamed_t order by a_id;
273
+ → [{"a_id": 1, "b_renamed": "hello", "new_col": ""}, {"a_id": 2, "b_renamed": "world", "new_col": ""}]
274
+
275
+ select * from child_t order by id;
276
+ → [{"id": 10, "parent_a": 1}, {"id": 20, "parent_a": 2}]
277
+
278
+ -- FK still enforced post-rename (Quereus surfaces FK violations as CHECK constraint failures by name)
279
+ insert into child_t values (30, 999);
280
+ -- error: fk_parent
281
+
282
+ drop table child_t;
283
+ drop table renamed_t;
284
+
285
+ -- ===================================
286
+ -- 9. Typo'd reserved tag on a physical declared object → hard error at apply
287
+ -- ===================================
288
+
289
+ -- The physical declarative differ now validates every declared object's
290
+ -- quereus.* tags through the same typed registry as the lens/mutation paths
291
+ -- (hard-error-on-unknown). A typo that the old soft-warn allow-list silently
292
+ -- swallowed now fails the apply loudly. (`quereus.update.taget` is a typo of
293
+ -- `target`.)
294
+ create table gadget (id integer primary key, name text);
295
+
296
+ declare schema main {
297
+ table gadget {
298
+ id integer primary key,
299
+ name text
300
+ } with tags ("quereus.update.taget" = 'gadget')
301
+ }
302
+
303
+ -- run
304
+
305
+ apply schema main;
306
+ -- error: unknown reserved tag
307
+
308
+ drop table gadget;
309
+
310
+ -- ===================================
311
+ -- 10. Typo'd reserved tag on an INLINE NAMED column constraint → hard error at apply
312
+ -- ===================================
313
+
314
+ -- The differ also validates ColumnDef.constraints[].tags at the physical-constraint
315
+ -- site, symmetric with the direct CREATE path (50-metadata-tags § inline named
316
+ -- column-constraint). A trailing WITH TAGS lands on the constraint only when it is
317
+ -- NAMED; a typo on an inline named CHECK constraint fails the apply just as a
318
+ -- table-level constraint typo does (§ 9).
319
+ create table widget (id integer primary key, qty integer);
320
+
321
+ declare schema main {
322
+ table widget {
323
+ id integer primary key,
324
+ qty integer constraint chk_qty check (qty > 0) with tags ("quereus.bogus" = 1)
325
+ }
326
+ }
327
+
328
+ -- run
329
+
330
+ apply schema main;
331
+ -- error: unknown reserved tag
332
+
333
+ drop table widget;
334
+
335
+ -- ===================================
336
+ -- 11. In-diff COLUMN rename reconciles a dependent view (no spurious recreate)
337
+ -- ===================================
338
+
339
+ -- A name-matched view whose declared body references a column renamed in the
340
+ -- SAME diff must NOT recreate: the differ inverse-applies the in-diff renames
341
+ -- before comparing canonical definitions. This is correctness-critical, not
342
+ -- just churn — generateMigrationDDL emits view creates BEFORE the table-alter
343
+ -- block where RENAME COLUMN lives, and CREATE VIEW plans its body at create
344
+ -- time, so an unreconciled recreate naming the NEW column would fail at apply.
345
+
346
+ create table emp (emp_id integer primary key, fullname text not null, created integer not null);
347
+ create view emp_v as select emp_id, fullname from emp with defaults (created = 7);
348
+ insert into emp values (1, 'Carol', 0);
349
+
350
+ declare schema main {
351
+ table emp {
352
+ emp_id integer primary key,
353
+ full_name text not null with tags ("quereus.previous_name" = 'fullname'),
354
+ created integer not null
355
+ }
356
+
357
+ view emp_v as select emp_id, full_name from emp with defaults (created = 7)
358
+ }
359
+
360
+ -- run
361
+
362
+ -- Only the rename op — no DROP VIEW / CREATE VIEW.
363
+ diff schema main;
364
+ → [{"ddl": "ALTER TABLE emp RENAME COLUMN fullname TO full_name"}]
365
+
366
+ apply schema main;
367
+
368
+ -- run
369
+
370
+ -- The live rename propagation rewrote the view body to the new column name.
371
+ select * from emp_v order by emp_id;
372
+ → [{"emp_id": 1, "full_name": "Carol"}]
373
+
374
+ -- Write-through via the (rename-untouched) insert-defaults clause still works.
375
+ insert into emp_v values (2, 'Dan');
376
+ select created from emp where emp_id = 2;
377
+ → [{"created": 7}]
378
+
379
+ -- Converged.
380
+ diff schema main;
381
+ → []
382
+
383
+ drop view emp_v;
384
+ drop table emp;
385
+
386
+ -- ===================================
387
+ -- 12. In-diff TABLE rename reconciles a dependent view (no spurious recreate)
388
+ -- ===================================
389
+
390
+ create table dept_old (id integer primary key, dname text);
391
+ create view dept_v as select id, dname from dept_old;
392
+ insert into dept_old values (1, 'Eng');
393
+
394
+ declare schema main {
395
+ table dept_new {
396
+ id integer primary key,
397
+ dname text
398
+ } with tags ("quereus.previous_name" = 'dept_old')
399
+
400
+ view dept_v as select id, dname from dept_new
401
+ }
402
+
403
+ -- run
404
+
405
+ diff schema main;
406
+ → [{"ddl": "ALTER TABLE dept_old RENAME TO dept_new"}]
407
+
408
+ apply schema main;
409
+
410
+ -- run
411
+
412
+ select * from dept_v;
413
+ → [{"id": 1, "dname": "Eng"}]
414
+
415
+ diff schema main;
416
+ → []
417
+
418
+ drop view dept_v;
419
+ drop table dept_new;
420
+
421
+ -- ===================================
422
+ -- 13. In-diff TABLE rename reconciles a dependent MATERIALIZED VIEW (no spurious rebuild)
423
+ -- ===================================
424
+
425
+ create table inv_old (id integer primary key, qty integer not null);
426
+ create materialized view inv_mv as select id, qty from inv_old;
427
+ insert into inv_old values (1, 5);
428
+
429
+ declare schema main {
430
+ table inv_new {
431
+ id integer primary key,
432
+ qty integer not null
433
+ } with tags ("quereus.previous_name" = 'inv_old')
434
+
435
+ materialized view inv_mv as select id, qty from inv_new
436
+ }
437
+
438
+ -- run
439
+
440
+ -- Only the table rename — no DROP MATERIALIZED VIEW / re-materialization.
441
+ diff schema main;
442
+ → [{"ddl": "ALTER TABLE inv_old RENAME TO inv_new"}]
443
+
444
+ apply schema main;
445
+
446
+ -- run
447
+
448
+ -- Row-time maintenance still tracks the renamed source.
449
+ insert into inv_new values (2, 7);
450
+ select * from inv_mv order by id;
451
+ → [{"id": 1, "qty": 5}, {"id": 2, "qty": 7}]
452
+
453
+ -- Converged: the rename propagation re-stamped the live bodyHash from the
454
+ -- rewritten body, matching the declared definition's hash.
455
+ diff schema main;
456
+ → []
457
+
458
+ drop materialized view inv_mv;
459
+ drop table inv_new;
460
+
461
+ -- ===================================
462
+ -- 14. require-hint: a view DEFINITION recreate is not an ambiguous rename
463
+ -- ===================================
464
+
465
+ -- A definition-change recreate emits both a view drop and a view create; the
466
+ -- require-hint guard must not mistake that deliberate pair for an unhinted
467
+ -- rename (mirroring the index body-recreate exclusion).
468
+
469
+ create table rh_t (id integer primary key, v integer);
470
+ create view rh_v as select id from rh_t;
471
+
472
+ declare schema main {
473
+ table rh_t {
474
+ id integer primary key,
475
+ v integer
476
+ }
477
+
478
+ view rh_v as select id from rh_t where id > 0
479
+ }
480
+
481
+ -- run
482
+
483
+ apply schema main options (rename_policy = 'require-hint');
484
+
485
+ -- run
486
+
487
+ diff schema main;
488
+ → []
489
+
490
+ drop view rh_v;
491
+ drop table rh_t;
492
+
493
+ -- ===================================
494
+ -- 15. In-diff COLUMN rename reconciles a dependent MATERIALIZED VIEW (no spurious rebuild)
495
+ -- ===================================
496
+
497
+ -- The MV mirror of §11: the differ's hash compare reconciles the in-diff
498
+ -- column rename (no DROP MATERIALIZED VIEW / re-materialization), and the live
499
+ -- column-rename propagation rewrites the MV body and re-stamps bodyHash with
500
+ -- the same canonical-definition formula, so the re-diff converges.
501
+
502
+ create table stock_t (id integer primary key, amount integer not null);
503
+ create materialized view stock_mv as select id, amount from stock_t;
504
+ insert into stock_t values (1, 5);
505
+
506
+ declare schema main {
507
+ table stock_t {
508
+ id integer primary key,
509
+ qty integer not null with tags ("quereus.previous_name" = 'amount')
510
+ }
511
+
512
+ materialized view stock_mv as select id, qty from stock_t
513
+ }
514
+
515
+ -- run
516
+
517
+ -- Only the rename op — no MV drop/create.
518
+ diff schema main;
519
+ → [{"ddl": "ALTER TABLE stock_t RENAME COLUMN amount TO qty"}]
520
+
521
+ apply schema main;
522
+
523
+ -- run
524
+
525
+ -- Row-time maintenance survived; the MV's output column followed the rename.
526
+ insert into stock_t values (2, 7);
527
+ select * from stock_mv order by id;
528
+ → [{"id": 1, "qty": 5}, {"id": 2, "qty": 7}]
529
+
530
+ -- Converged: the propagation re-stamp and the differ formula agree.
531
+ diff schema main;
532
+ → []
533
+
534
+ drop materialized view stock_mv;
535
+ drop table stock_t;
536
+
537
+ -- ===================================
538
+ -- 16. Hinted VIEW rename, definition unchanged → drop + recreate
539
+ -- ===================================
540
+
541
+ -- A view has no ALTER VIEW … RENAME TO primitive, so a hint-matched rename
542
+ -- resolves to drop(old) + recreate(declared) emitted from the view buckets
543
+ -- (previously this pair diffed empty and applied as a silent no-op).
544
+
545
+ create table vr_t (id integer primary key, name text);
546
+ create view v_old as select id, name from vr_t;
547
+ insert into vr_t values (1, 'A');
548
+
549
+ declare schema main {
550
+ table vr_t {
551
+ id integer primary key,
552
+ name text
553
+ }
554
+
555
+ view v_new as select id, name from vr_t with tags ("quereus.previous_name" = 'v_old')
556
+ }
557
+
558
+ -- run
559
+
560
+ diff schema main;
561
+ → [{"ddl": "DROP VIEW IF EXISTS v_old"}, {"ddl": "create view v_new as select id, name from vr_t with tags (\"quereus.previous_name\" = 'v_old')"}]
562
+
563
+ apply schema main;
564
+
565
+ -- run
566
+
567
+ -- Only the new name exists.
568
+ select name from schema() where type = 'view' order by name;
569
+ → [{"name": "v_new"}]
570
+
571
+ select * from v_new order by id;
572
+ → [{"id": 1, "name": "A"}]
573
+
574
+ -- Idempotent: the hint tag stored verbatim is inert (name match wins before
575
+ -- hint resolution; the drift compare strips the hint keys).
576
+ diff schema main;
577
+ → []
578
+
579
+ drop view v_new;
580
+ drop table vr_t;
581
+
582
+ -- ===================================
583
+ -- 17. Hinted INDEX rename, body unchanged → drop + recreate
584
+ -- ===================================
585
+ -- Lives in 50.2.1-declare-schema-index-renames (it needs standalone index DDL);
586
+ -- the VIEW-kind twin of this case is § 16 above.
587
+
588
+ -- ===================================
589
+ -- 18. Hinted VIEW rename + non-hint tag drift → recreate carries the tags
590
+ -- ===================================
591
+
592
+ -- The in-place SET TAGS branch requires a name match, so on a rename the
593
+ -- declared tag set must ride the recreate (no separate ALTER VIEW … SET TAGS,
594
+ -- no double-emit).
595
+
596
+ create table tv_t (id integer primary key, v integer);
597
+ create view tv_old as select id, v from tv_t;
598
+
599
+ declare schema main {
600
+ table tv_t {
601
+ id integer primary key,
602
+ v integer
603
+ }
604
+
605
+ view tv_new as select id, v from tv_t with tags ("quereus.previous_name" = 'tv_old', owner = 'team-x')
606
+ }
607
+
608
+ -- run
609
+
610
+ apply schema main;
611
+
612
+ -- run
613
+
614
+ -- The recreate carried the declared tags, including the non-hint key.
615
+ select json_extract(tags, '$.owner') as owner from schema() where type = 'view' and name = 'tv_new';
616
+ → [{"owner": "team-x"}]
617
+
618
+ diff schema main;
619
+ → []
620
+
621
+ drop view tv_new;
622
+ drop table tv_t;
623
+
624
+ -- ===================================
625
+ -- 19. Hinted VIEW rename + in-diff COLUMN rename of its source
626
+ -- ===================================
627
+
628
+ -- The recreate must name the OLD column: creates precede RENAME COLUMN in
629
+ -- migration order and CREATE VIEW plans its body at create time. After the
630
+ -- create, the live column-rename propagation rewrites the fresh body, so the
631
+ -- re-diff converges.
632
+
633
+ create table cr_t (id integer primary key, fullname text not null);
634
+ create view crv_old as select id, fullname from cr_t;
635
+ insert into cr_t values (1, 'Carol');
636
+
637
+ declare schema main {
638
+ table cr_t {
639
+ id integer primary key,
640
+ full_name text not null with tags ("quereus.previous_name" = 'fullname')
641
+ }
642
+
643
+ view crv_new as select id, full_name from cr_t with tags ("quereus.previous_name" = 'crv_old')
644
+ }
645
+
646
+ -- run
647
+
648
+ diff schema main;
649
+ → [{"ddl": "DROP VIEW IF EXISTS crv_old"}, {"ddl": "create view crv_new as select id, fullname from cr_t with tags (\"quereus.previous_name\" = 'crv_old')"}, {"ddl": "ALTER TABLE cr_t RENAME COLUMN fullname TO full_name"}]
650
+
651
+ apply schema main;
652
+
653
+ -- run
654
+
655
+ -- Selecting through the renamed view sees the renamed column.
656
+ select * from crv_new order by id;
657
+ → [{"id": 1, "full_name": "Carol"}]
658
+
659
+ diff schema main;
660
+ → []
661
+
662
+ drop view crv_new;
663
+ drop table cr_t;
664
+
665
+ -- ===================================
666
+ -- 20. Hinted INDEX rename + in-diff COLUMN rename of its table
667
+ -- ===================================
668
+ -- Lives in 50.2.1-declare-schema-index-renames (it needs standalone index DDL);
669
+ -- § 19 above is the VIEW-kind twin.
670
+
671
+ -- ===================================
672
+ -- 21. require-hint: a hinted VIEW rename applies cleanly
673
+ -- ===================================
674
+
675
+ -- A hinted rename's drop+create pair is deliberate, not an ambiguous unhinted
676
+ -- rename — it must not trip the require-hint guard (excluded from the counts,
677
+ -- like the body-change recreates of § 14). The same case with an index
678
+ -- rename alongside is in 50.2.1-declare-schema-index-renames.
679
+
680
+ create table rh2_t (id integer primary key, v integer);
681
+ create view rh2_vold as select id, v from rh2_t;
682
+
683
+ declare schema main {
684
+ table rh2_t {
685
+ id integer primary key,
686
+ v integer
687
+ }
688
+
689
+ view rh2_vnew as select id, v from rh2_t with tags ("quereus.previous_name" = 'rh2_vold')
690
+ }
691
+
692
+ -- run
693
+
694
+ apply schema main options (rename_policy = 'require-hint');
695
+
696
+ -- run
697
+
698
+ diff schema main;
699
+ → []
700
+
701
+ select name from schema() where type = 'view';
702
+ → [{"name": "rh2_vnew"}]
703
+
704
+ drop view rh2_vnew;
705
+ drop table rh2_t;
706
+
707
+ -- ===================================
708
+ -- 22. Hinted VIEW + INDEX rename + in-diff TABLE rename of their source
709
+ -- ===================================
710
+ -- Lives in 50.2.1-declare-schema-index-renames (it needs standalone index DDL).
711
+
712
+ -- ===================================
713
+ -- 23. Hinted VIEW rename + with defaults + in-diff COLUMN rename
714
+ -- ===================================
715
+
716
+ -- The recreate's `with defaults` clause must also name the OLD column (its
717
+ -- column names a base-table column, often projected away — the body rewrite
718
+ -- cannot catch it); after the create, RENAME COLUMN propagation rewrites it.
719
+
720
+ create table emp2 (emp_id integer primary key, fullname text not null, created integer not null);
721
+ create view ev_old as select emp_id, fullname from emp2 with defaults (created = 7);
722
+ insert into emp2 values (1, 'Carol', 0);
723
+
724
+ declare schema main {
725
+ table emp2 {
726
+ emp_id integer primary key,
727
+ fullname text not null,
728
+ created_at integer not null with tags ("quereus.previous_name" = 'created')
729
+ }
730
+
731
+ view ev_new as select emp_id, fullname from emp2 with defaults (created_at = 7) with tags ("quereus.previous_name" = 'ev_old')
732
+ }
733
+
734
+ -- run
735
+
736
+ diff schema main;
737
+ → [{"ddl": "DROP VIEW IF EXISTS ev_old"}, {"ddl": "create view ev_new as select emp_id, fullname from emp2 with defaults (created = 7) with tags (\"quereus.previous_name\" = 'ev_old')"}, {"ddl": "ALTER TABLE emp2 RENAME COLUMN created TO created_at"}]
738
+
739
+ apply schema main;
740
+
741
+ -- run
742
+
743
+ -- Write-through via the recreated + propagation-rewritten defaults clause.
744
+ insert into ev_new values (2, 'Dan');
745
+ select created_at from emp2 where emp_id = 2;
746
+ → [{"created_at": 7}]
747
+
748
+ diff schema main;
749
+ → []
750
+
751
+ drop view ev_new;
752
+ drop table emp2;
753
+
754
+ -- ===================================
755
+ -- 24. Hinted TABLE rename + another table's DEFAULT that names it
756
+ -- ===================================
757
+
758
+ -- The table-verb twin of the column-rename case pinned by
759
+ -- `test/schema/differ-alter-column.spec.ts` ("a column rename carrying a DEFAULT").
760
+ -- The default compare in `computeColumnAttributeChange` is not inverse-reconciled
761
+ -- against pending TABLE renames either, so the declared default (naming the NEW
762
+ -- table) mismatches the actual one (still naming the OLD) and one redundant
763
+ -- SET DEFAULT rides along. This pins that it is HARMLESS: renames are emitted
764
+ -- first, so by the time the SET DEFAULT runs the live rename propagation has
765
+ -- already produced exactly that expression, and the re-diff is empty.
766
+ --
767
+ -- This route converges even WITHOUT the propagation into `columns[].defaultValue`
768
+ -- (the redundant SET DEFAULT would repair the default on its own), so it is a
769
+ -- differ-behaviour guard, not a second copy of the propagation guard — that one is
770
+ -- `41.3-alter-rename-propagation.sqllogic` §38-41, on the imperative RENAME TO path
771
+ -- where nothing re-states the default.
772
+
773
+ create table dt_u (k integer primary key, v integer null);
774
+ insert into dt_u values (1, 42);
775
+ create table dt_t (id integer primary key, w integer null default ((select min(v) from dt_u)));
776
+
777
+ declare schema main {
778
+ table dt_u2 {
779
+ k integer primary key,
780
+ v integer null
781
+ } with tags ("quereus.previous_name" = 'dt_u')
782
+
783
+ table dt_t {
784
+ id integer primary key,
785
+ w integer null default ((select min(v) from dt_u2))
786
+ }
787
+ }
788
+
789
+ -- run
790
+
791
+ diff schema main;
792
+ → [{"ddl": "ALTER TABLE dt_u RENAME TO dt_u2"}, {"ddl": "ALTER TABLE dt_t ALTER COLUMN w SET DEFAULT (select min(v) from dt_u2)"}]
793
+
794
+ apply schema main;
795
+
796
+ -- run
797
+
798
+ -- The dependent table still accepts rows and its default reads the renamed table.
799
+ insert into dt_t (id) values (1);
800
+ select id, w from dt_t;
801
+ → [{"id": 1, "w": 42}]
802
+
803
+ -- Convergence: the live default now names dt_u2, so the re-diff is empty.
804
+ diff schema main;
805
+ → []
806
+
807
+ drop table dt_t;
808
+ drop table dt_u2;
809
+
810
+ -- ===================================
811
+ -- 25. In-diff COLUMN rename of a table called "new" vs another table's row image
812
+ -- ===================================
813
+
814
+ -- The differ reconciles a declared CHECK against the not-yet-renamed catalog by
815
+ -- running the rename walk INVERSELY, so it inherits the same `new.` / `old.`
816
+ -- ambiguity the forward propagation does (`41.3` §62): `new` is not a reserved
817
+ -- word, so `dnw_t`'s `check (new.w > 0)` names dnw_t's own written row while a
818
+ -- real table called "new" is having its column `v` renamed to `w` in the same
819
+ -- diff. Treating that qualifier as a reference to the table would inverse-rewrite
820
+ -- the declared body to `new.v`, mismatch the actual body, and emit a spurious
821
+ -- constraint drop/recreate alongside the rename.
822
+
823
+ create table "new" (id integer primary key, v integer);
824
+ create table dnw_t (id integer primary key, w integer, constraint ck_dnw check (new.w > 0));
825
+
826
+ declare schema main {
827
+ table "new" {
828
+ id integer primary key,
829
+ w integer with tags ("quereus.previous_name" = 'v')
830
+ }
831
+
832
+ table dnw_t {
833
+ id integer primary key,
834
+ w integer,
835
+ constraint ck_dnw check (new.w > 0)
836
+ }
837
+ }
838
+
839
+ -- run
840
+
841
+ diff schema main;
842
+ → [{"ddl": "ALTER TABLE new RENAME COLUMN v TO w"}]
843
+
844
+ apply schema main;
845
+
846
+ -- run
847
+
848
+ -- dnw_t still writable against its own row image, and its CHECK still enforces.
849
+ insert into dnw_t values (1, 5);
850
+ select w from dnw_t;
851
+ → [{"w": 5}]
852
+
853
+ insert into dnw_t values (2, -1);
854
+ -- error: ck_dnw
855
+
856
+ diff schema main;
857
+ → []
858
+
859
+ drop table dnw_t;
860
+ drop table "new";
861
+
862
+ -- ===================================
863
+ -- 26. A rename that PINS an untouched dependent body must converge in one apply
864
+ -- ===================================
865
+ -- The declared rename creates a temp.k26 where the temp-owned view's bare k26
866
+ -- used to fall through to main.k26. The live propagation pins the view body to
867
+ -- main.k26; the re-diff must read that pin as the rename's own artifact — NOT a
868
+ -- body edit — or the recreate would silently re-bind the view to temp.k26.
869
+
870
+ create table main.k26 (id integer primary key, x integer);
871
+ insert into main.k26 values (1, 10);
872
+ create table temp.o26 (id integer primary key, x integer);
873
+ insert into temp.o26 values (99, 999);
874
+ create view temp.v26 as select id, x from k26;
875
+
876
+ declare schema temp {
877
+ table k26 {
878
+ id integer primary key,
879
+ x integer
880
+ } with tags ("quereus.previous_name" = 'o26')
881
+ view v26 as select id, x from k26
882
+ }
883
+
884
+ -- run
885
+
886
+ diff schema temp;
887
+ → [{"ddl": "ALTER TABLE \"temp\".o26 RENAME TO k26"}]
888
+
889
+ apply schema temp;
890
+
891
+ -- run
892
+
893
+ -- One pass converged: no drop+recreate of the pinned view.
894
+ diff schema temp;
895
+ → []
896
+
897
+ -- And the view still reads main.k26, not the table that took its name.
898
+ select * from temp.v26;
899
+ → [{"id": 1, "x": 10}]
900
+
901
+ drop view temp.v26;
902
+ drop table temp.k26;
903
+ drop table main.k26;
904
+
905
+ -- ===================================
906
+ -- 27. A rename whose propagation ALIASES a colliding FROM source re-diffs clean
907
+ -- ===================================
908
+ -- Single schema: the view reads t27 bare AND aliases u27 as t27's new name, so
909
+ -- the forward rename writes `from t27_2 as t27` to keep both qualifiers bound.
910
+ -- The declared (post-rename) body carries that alias; the diff must recognize a
911
+ -- pure rename, and the re-diff after apply must be empty.
912
+
913
+ create table t27 (id integer primary key, x integer);
914
+ insert into t27 values (1, 10);
915
+ create table u27 (id integer primary key, x integer);
916
+ insert into u27 values (1, 77);
917
+ create view v27 as select t27.x as a, t27_2.x as b from t27 join u27 as t27_2 on t27.id = t27_2.id;
918
+
919
+ declare schema main {
920
+ table t27_2 {
921
+ id integer primary key,
922
+ x integer
923
+ } with tags ("quereus.previous_name" = 't27')
924
+ table u27 {
925
+ id integer primary key,
926
+ x integer
927
+ }
928
+ view v27 as select t27.x as a, t27_2.x as b from t27_2 as t27 inner join u27 as t27_2 on t27.id = t27_2.id
929
+ }
930
+
931
+ -- run
932
+
933
+ diff schema main;
934
+ → [{"ddl": "ALTER TABLE t27 RENAME TO t27_2"}]
935
+
936
+ apply schema main;
937
+
938
+ -- run
939
+
940
+ diff schema main;
941
+ → []
942
+
943
+ -- Both qualifiers still bind what they bound before the rename.
944
+ select * from v27;
945
+ → [{"a": 10, "b": 77}]
946
+
947
+ drop view v27;
948
+ drop table u27;
949
+ drop table t27_2;