@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,409 @@
1
+ -- 53.3-materialized-view-constraint-only-ddl.sqllogic — a body-irrelevant
2
+ -- `table_modified` on a source (constraint/stats/tags-only: old/new columns and
3
+ -- physical PK identical) RECOMPILES each live dependent MV's row-time plan in
4
+ -- place instead of marking it stale: DROP/RENAME/ADD CONSTRAINT and ANALYZE keep
5
+ -- dependents live — writes keep propagating with no REFRESH required. Recompile,
6
+ -- never skip: constraint metadata feeds the COMPILED plan (the join-residual arm
7
+ -- rests on FK referential integrity; CHECKs seed optimizer domain folds), so the
8
+ -- plan is rebuilt against the new catalog. Any recompile failure falls back to
9
+ -- today's mark-stale path; a stale MV serves its frozen snapshot (writes stop
10
+ -- propagating) until REFRESH or drop-and-recreate.
11
+
12
+ -- ===================================
13
+ -- 1. DROP CONSTRAINT (CHECK) keeps the MV live
14
+ -- ===================================
15
+
16
+ create table a (id integer primary key, v integer not null, constraint chk check (v > 0));
17
+ insert into a values (1, 5);
18
+ create materialized view mva as select id, v from a;
19
+
20
+ alter table a drop constraint chk;
21
+
22
+ -- still live: a write the dropped CHECK would have rejected propagates
23
+ insert into a values (2, -1);
24
+ select * from mva order by id;
25
+ → [{"id":1,"v":5},{"id":2,"v":-1}]
26
+
27
+ -- REFRESH still works (never went stale; idempotent re-attach)
28
+ refresh materialized view mva;
29
+ select * from mva order by id;
30
+ → [{"id":1,"v":5},{"id":2,"v":-1}]
31
+
32
+ drop materialized view mva;
33
+ drop table a;
34
+
35
+ -- ===================================
36
+ -- 2. RENAME CONSTRAINT keeps the MV live
37
+ -- ===================================
38
+
39
+ create table b (id integer primary key, v integer not null, constraint chk check (v > 0));
40
+ insert into b values (1, 5);
41
+ create materialized view mvb as select id, v from b;
42
+
43
+ alter table b rename constraint chk to chk2;
44
+
45
+ insert into b values (2, 6);
46
+ select * from mvb order by id;
47
+ → [{"id":1,"v":5},{"id":2,"v":6}]
48
+
49
+ drop materialized view mvb;
50
+ drop table b;
51
+
52
+ -- ===================================
53
+ -- 3. ADD CONSTRAINT CHECK keeps the MV live
54
+ -- ===================================
55
+
56
+ create table c (id integer primary key, v integer not null);
57
+ insert into c values (1, 5);
58
+ create materialized view mvc as select id, v from c;
59
+
60
+ alter table c add constraint chk check (v > 0);
61
+
62
+ insert into c values (2, 6);
63
+ select * from mvc order by id;
64
+ → [{"id":1,"v":5},{"id":2,"v":6}]
65
+
66
+ -- the added CHECK is enforced on the source (the recompiled validator path)
67
+ insert into c values (3, -1);
68
+ -- error: check
69
+
70
+ -- add→drop roundtrip: dropping the just-added CHECK is another
71
+ -- body-irrelevant event — still live, and the previously-rejected
72
+ -- write now propagates
73
+ alter table c drop constraint chk;
74
+ insert into c values (3, -1);
75
+ select * from mvc order by id;
76
+ → [{"id":1,"v":5},{"id":2,"v":6},{"id":3,"v":-1}]
77
+
78
+ drop materialized view mvc;
79
+ drop table c;
80
+
81
+ -- ===================================
82
+ -- 4. ADD UNIQUE on an UNPROJECTED column keeps the MV live
83
+ -- (cannot move the projected key set — strict-PK gate passes)
84
+ -- ===================================
85
+
86
+ create table d (id integer primary key, v integer not null, u integer not null);
87
+ insert into d values (1, 5, 100);
88
+ create materialized view mvd as select id, v from d;
89
+
90
+ alter table d add constraint uq unique (u);
91
+
92
+ insert into d values (2, 6, 200);
93
+ select * from mvd order by id;
94
+ → [{"id":1,"v":5},{"id":2,"v":6}]
95
+
96
+ drop materialized view mvd;
97
+ drop table d;
98
+
99
+ -- ===================================
100
+ -- 5. FK-drop demotes the join-residual arm (the recompile-not-skip proof).
101
+ -- The 1:1-join maintenance arm rests on NOT-NULL FK→PK referential
102
+ -- integrity (lookup side upsert-only). With the FK dropped, a now-possible
103
+ -- delete of a referenced parent row must remove the joined MV rows — under
104
+ -- a stale (skipped) compiled plan they would linger as phantoms.
105
+ -- ===================================
106
+
107
+ create table p5 (id integer primary key, nm text not null);
108
+ create table t5 (tid integer primary key, fk integer not null, constraint fkp foreign key (fk) references p5 (id));
109
+ insert into p5 values (1, 'one'), (2, 'two');
110
+ insert into t5 values (10, 1), (20, 2);
111
+ create materialized view mv5 as select t5.tid, p5.nm from t5 join p5 on t5.fk = p5.id;
112
+
113
+ select * from mv5 order by tid;
114
+ → [{"tid":10,"nm":"one"},{"tid":20,"nm":"two"}]
115
+
116
+ alter table t5 drop constraint fkp;
117
+
118
+ -- still live, and the recompiled plan handles the FK-less world: deleting a
119
+ -- referenced parent removes the joined rows
120
+ delete from p5 where id = 1;
121
+ select * from mv5 order by tid;
122
+ → [{"tid":20,"nm":"two"}]
123
+
124
+ -- a dangling child row (legal now) joins nothing
125
+ insert into t5 values (11, 99);
126
+ select * from mv5 order by tid;
127
+ → [{"tid":20,"nm":"two"}]
128
+
129
+ drop materialized view mv5;
130
+ drop table t5;
131
+ drop table p5;
132
+
133
+ -- ===================================
134
+ -- 6. Dropped UNIQUE that backed the recorded backing PK forces staleness:
135
+ -- `keysOf` no longer proves the recorded key (id is unprojected, so the
136
+ -- derived key falls back and shifts) → strict-PK mismatch → stale fallback.
137
+ -- Stale = frozen snapshot: writes stop propagating; REFRESH errors with the
138
+ -- shape diagnostic; drop-and-recreate recovers.
139
+ -- ===================================
140
+
141
+ create table f (id integer primary key, u text not null, v text, constraint uq unique (u));
142
+ insert into f values (1, 'x', 'one');
143
+ create materialized view mvf as select u, v from f;
144
+
145
+ select * from mvf order by u;
146
+ → [{"u":"x","v":"one"}]
147
+
148
+ alter table f drop constraint uq;
149
+
150
+ -- frozen: the write does not propagate
151
+ insert into f values (2, 'y', 'two');
152
+ select * from mvf order by u;
153
+ → [{"u":"x","v":"one"}]
154
+
155
+ -- refresh cannot rebuild it (derived key shifted past the backing PK)
156
+ refresh materialized view mvf;
157
+ -- error: output shape changed incompatibly
158
+
159
+ -- drop and recreate (with a body whose key is still provable) is the recovery
160
+ drop materialized view mvf;
161
+ drop table f;
162
+
163
+ -- ===================================
164
+ -- 7. ANALYZE keeps MVs live (statistics-only table_modified)
165
+ -- ===================================
166
+
167
+ create table g (id integer primary key, v integer not null);
168
+ insert into g values (1, 1);
169
+ create materialized view mvg as select id, v from g;
170
+
171
+ analyze g;
172
+
173
+ -- no staleness: read succeeds and writes keep propagating
174
+ insert into g values (2, 2);
175
+ select * from mvg order by id;
176
+ → [{"id":1,"v":1},{"id":2,"v":2}]
177
+
178
+ drop materialized view mvg;
179
+ drop table g;
180
+
181
+ -- ===================================
182
+ -- 7b. A tag-only ALTER is body-irrelevant: it fires table_modified on the source
183
+ -- but does not stale the MV
184
+ -- ===================================
185
+ -- (the CREATE/DROP INDEX instance of the same classification lives in
186
+ -- 53.3.1-materialized-view-index-ddl-irrelevance — it needs standalone index DDL)
187
+
188
+ create table g2 (id integer primary key, v integer not null);
189
+ insert into g2 values (1, 1);
190
+ create materialized view mvg2 as select id, v from g2;
191
+
192
+ insert into g2 values (2, 2);
193
+ select * from mvg2 order by id;
194
+ → [{"id":1,"v":1},{"id":2,"v":2}]
195
+
196
+ insert into g2 values (3, 3);
197
+ select * from mvg2 order by id;
198
+ → [{"id":1,"v":1},{"id":2,"v":2},{"id":3,"v":3}]
199
+
200
+ alter table g2 set tags (note = 'x');
201
+ insert into g2 values (4, 4);
202
+ select * from mvg2 order by id;
203
+ → [{"id":1,"v":1},{"id":2,"v":2},{"id":3,"v":3},{"id":4,"v":4}]
204
+
205
+ drop materialized view mvg2;
206
+ drop table g2;
207
+
208
+ -- ===================================
209
+ -- 8. Pre-existing staleness is never cleared by a constraint-only DDL:
210
+ -- a body-RELEVANT change (column retype) marks the MV stale; a later
211
+ -- constraint-only DDL on the same source skips it (no recompile, no
212
+ -- flag-clear) — only REFRESH recovers.
213
+ -- ===================================
214
+
215
+ create table h (id integer primary key, v integer not null, constraint chk check (v > 0));
216
+ insert into h values (1, 5);
217
+ create materialized view mvh as select id, v from h;
218
+
219
+ alter table h alter column v set data type real;
220
+
221
+ -- stale (frozen): the write does not propagate
222
+ insert into h values (2, 6);
223
+ select id from mvh order by id;
224
+ → [{"id":1}]
225
+
226
+ alter table h drop constraint chk;
227
+
228
+ -- STILL stale — the constraint-only DDL must not revive it
229
+ insert into h values (3, 7);
230
+ select id from mvh order by id;
231
+ → [{"id":1}]
232
+
233
+ -- REFRESH recovers (reshapes the backing to the retyped column)
234
+ refresh materialized view mvh;
235
+ select id from mvh order by id;
236
+ → [{"id":1},{"id":2},{"id":3}]
237
+
238
+ drop materialized view mvh;
239
+ drop table h;
240
+
241
+ -- ===================================
242
+ -- 9. Mid-statement failure independence: one DDL, two dependents — the
243
+ -- PK-shifted one stales, the sibling recompiles and stays live.
244
+ -- ===================================
245
+
246
+ create table i (id integer primary key, u text not null, v integer not null, constraint uq unique (u));
247
+ insert into i values (1, 'x', 5);
248
+ create materialized view mvi_keyed_u as select u, v from i;
249
+ create materialized view mvi_keyed_id as select id, v from i;
250
+
251
+ alter table i drop constraint uq;
252
+
253
+ insert into i values (2, 'y', 6);
254
+
255
+ -- the u-keyed MV froze (its backing key lost its proof)
256
+ select * from mvi_keyed_u order by u;
257
+ → [{"u":"x","v":5}]
258
+
259
+ -- the id-keyed sibling stayed live
260
+ select * from mvi_keyed_id order by id;
261
+ → [{"id":1,"v":5},{"id":2,"v":6}]
262
+
263
+ drop materialized view mvi_keyed_u;
264
+ drop materialized view mvi_keyed_id;
265
+ drop table i;
266
+
267
+ -- ===================================
268
+ -- 10. MV-over-MV: a constraint-only DDL on the base keeps BOTH levels live
269
+ -- (the recompile path emits no backing invalidation, so the consumer
270
+ -- never sees a staleness cascade)
271
+ -- ===================================
272
+
273
+ create table j (id integer primary key, v integer not null, constraint chk check (v >= 0));
274
+ insert into j values (1, 1);
275
+ create materialized view mvj1 as select id, v from j;
276
+ create materialized view mvj2 as select id, v from mvj1;
277
+
278
+ alter table j drop constraint chk;
279
+
280
+ -- a write the dropped CHECK would have rejected cascades through the chain
281
+ insert into j values (2, -5);
282
+ select * from mvj1 order by id;
283
+ → [{"id":1,"v":1},{"id":2,"v":-5}]
284
+ select * from mvj2 order by id;
285
+ → [{"id":1,"v":1},{"id":2,"v":-5}]
286
+
287
+ drop materialized view mvj2;
288
+ drop materialized view mvj1;
289
+ drop table j;
290
+
291
+ -- ===================================
292
+ -- 11. Forced recompile failure still cascades staleness to consumers: the
293
+ -- producer's stale fallback emits its backing invalidation, whose
294
+ -- same-object table_modified classifies body-RELEVANT (the reference-
295
+ -- equality guard) and stales the consumer. Both freeze.
296
+ -- ===================================
297
+
298
+ create table k (id integer primary key, u text not null, v text, constraint uq unique (u));
299
+ insert into k values (1, 'x', 'one');
300
+ create materialized view mvk1 as select u, v from k;
301
+ create materialized view mvk2 as select u from mvk1;
302
+
303
+ alter table k drop constraint uq;
304
+
305
+ -- both frozen: the write reaches neither level
306
+ insert into k values (2, 'y', 'two');
307
+ select * from mvk1 order by u;
308
+ → [{"u":"x","v":"one"}]
309
+ select * from mvk2 order by u;
310
+ → [{"u":"x"}]
311
+
312
+ drop materialized view mvk2;
313
+ drop materialized view mvk1;
314
+ drop table k;
315
+
316
+ -- ===================================
317
+ -- 12. RENAME TO of an FK target with an MV reading BOTH tables: the cascade's
318
+ -- constraint-rewrite table_modified on the child is body-irrelevant, but
319
+ -- at that instant the MV body may still name the old table (shape
320
+ -- derivation throws → stale fallback); the rename propagation's own MV
321
+ -- loop then rewrites the body and restores it live. End state: live.
322
+ -- ===================================
323
+
324
+ create table lp (id integer primary key);
325
+ create table lc (id integer primary key, pid integer not null references lp (id));
326
+ insert into lp values (1);
327
+ insert into lc values (10, 1);
328
+ create materialized view mvl as select lc.id, lp.id as pid from lc join lp on lc.pid = lp.id;
329
+
330
+ alter table lp rename to lp2;
331
+
332
+ insert into lp2 values (2);
333
+ insert into lc values (20, 2);
334
+ select * from mvl order by id;
335
+ → [{"id":10,"pid":1},{"id":20,"pid":2}]
336
+
337
+ refresh materialized view mvl;
338
+ select * from mvl order by id;
339
+ → [{"id":10,"pid":1},{"id":20,"pid":2}]
340
+
341
+ drop materialized view mvl;
342
+ drop table lc;
343
+ drop table lp2;
344
+
345
+ -- ===================================
346
+ -- 13. CHECK-contradiction folds (CHECK seeds optimizer domain facts that fold
347
+ -- the body's WHERE to empty). The conservative discipline:
348
+ -- (a) at create, a fully-folded body is rejected outright (it reads no
349
+ -- source table — its dependencies could never be recorded);
350
+ -- (b) adding a contradicting CHECK to a live MV's source folds the
351
+ -- re-planned body, shrinking its source set → the sourceTables guard
352
+ -- forces the stale fallback rather than leaving a live-but-frozen
353
+ -- plan in place. Frozen until the contradiction is resolved.
354
+ -- ===================================
355
+
356
+ create table m (id integer primary key, v integer not null, constraint chk check (v > 10));
357
+ create materialized view mvm as select id, v from m where v < 5;
358
+ -- error: reads no source table
359
+ drop table m;
360
+
361
+ create table n (id integer primary key, v integer not null);
362
+ create materialized view mvn as select id, v from n where v < 5;
363
+ insert into n values (1, 3), (2, 20);
364
+ select * from mvn order by id;
365
+ → [{"id":1,"v":3}]
366
+
367
+ delete from n where id = 1;
368
+ alter table n add constraint chk check (v > 10);
369
+
370
+ -- stale (frozen): the re-planned body folded to empty, so the source set
371
+ -- shrank and the recompile fell back to stale — never a silently-wrong plan
372
+ select * from mvn order by id;
373
+ → []
374
+
375
+ -- refresh cannot re-derive a folded body either
376
+ refresh materialized view mvn;
377
+ -- error: reads no source table
378
+
379
+ drop materialized view mvn;
380
+ drop table n;
381
+
382
+ -- ===================================
383
+ -- 14. ADD UNIQUE that subsumes the existing compound backing key:
384
+ -- keysOf's first key shrinks (compound {a,b} → single {a}) but the old
385
+ -- backing PK {a,b} is still a superkey → MV stays live.
386
+ -- ===================================
387
+
388
+ create table t14 (id integer primary key, a text not null, b text not null,
389
+ constraint uq_ab unique (a, b));
390
+ -- id is not projected; only compound key {a,b} is the backing PK
391
+ insert into t14 values (1, 'x', 'p');
392
+ create materialized view mv14 as select a, b from t14;
393
+
394
+ alter table t14 add constraint uq_a unique (a);
395
+ -- keysOf now returns {0} (a alone) as the first key — {a,b} is subsumed
396
+ -- superkey check: {0} ⊆ {0,1} → backing PK still valid → stay live
397
+
398
+ insert into t14 values (2, 'y', 'q');
399
+ select * from mv14 order by a;
400
+ → [{"a":"x","b":"p"},{"a":"y","b":"q"}]
401
+
402
+ -- live maintenance keeps working under the unchanged (wider) backing PK {a,b}:
403
+ -- a delete propagates too, not just inserts
404
+ delete from t14 where a = 'x';
405
+ select * from mv14 order by a;
406
+ → [{"a":"y","b":"q"}]
407
+
408
+ drop materialized view mv14;
409
+ drop table t14;
@@ -0,0 +1,29 @@
1
+ -- 53.3.1-materialized-view-index-ddl-irrelevance.sqllogic
2
+ --
3
+ -- requires-capability: standalone-index-ddl
4
+ --
5
+ -- Carved out of 53.3-materialized-view-constraint-only-ddl: that file classifies which
6
+ -- source DDL events force a materialized view to recompile, and it makes the same point
7
+ -- with DROP / RENAME / ADD CONSTRAINT, ANALYZE and tag-only ALTER — none of which need
8
+ -- index DDL. CREATE/DROP INDEX is one more example event in that list, so it lives here.
9
+ --
10
+ -- Subject: CREATE INDEX and DROP INDEX on the source are body-irrelevant — each fires
11
+ -- table_modified, neither stales the MV, and the MV keeps tracking source rows across
12
+ -- both.
13
+
14
+ create table g2 (id integer primary key, v integer not null);
15
+ insert into g2 values (1, 1);
16
+ create materialized view mvg2 as select id, v from g2;
17
+
18
+ create index ig2 on g2 (v);
19
+ insert into g2 values (2, 2);
20
+ select * from mvg2 order by id;
21
+ → [{"id":1,"v":1},{"id":2,"v":2}]
22
+
23
+ drop index ig2;
24
+ insert into g2 values (3, 3);
25
+ select * from mvg2 order by id;
26
+ → [{"id":1,"v":1},{"id":2,"v":2},{"id":3,"v":3}]
27
+
28
+ drop materialized view mvg2;
29
+ drop table g2;