@quereus/quereus 4.20.1 → 4.20.3
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.
- package/README.md +2 -0
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +17 -69
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/package.json +7 -4
- package/test/README.md +173 -0
- package/test/logic/01-basic.sqllogic +39 -0
- package/test/logic/01.1-select-projection-extras.sqllogic +130 -0
- package/test/logic/01.2-strings.sqllogic +43 -0
- package/test/logic/01.5-insert-select.sqllogic +237 -0
- package/test/logic/01.6-update-extras.sqllogic +118 -0
- package/test/logic/01.7-update-from.sqllogic +67 -0
- package/test/logic/01.8-delete-extras.sqllogic +122 -0
- package/test/logic/01.8.1-delete-range-cow.sqllogic +115 -0
- package/test/logic/01.9-query-expr-dml-gates.sqllogic +32 -0
- package/test/logic/01.9-query-expr-dml.sqllogic +171 -0
- package/test/logic/01.9-query-expr-values.sqllogic +111 -0
- package/test/logic/01.9.1-limit-over-dml-subquery.sqllogic +119 -0
- package/test/logic/02-filters.sqllogic +54 -0
- package/test/logic/02-smoke.sqllogic +62 -0
- package/test/logic/02.1-bind-parameters.sqllogic +223 -0
- package/test/logic/03-expressions.sqllogic +190 -0
- package/test/logic/03.1-quoted-identifiers.sqllogic +55 -0
- package/test/logic/03.4-defaults.sqllogic +554 -0
- package/test/logic/03.4.1-default-edge-cases.sqllogic +99 -0
- package/test/logic/03.5-tvf.sqllogic +61 -0
- package/test/logic/03.6-type-system.sqllogic +544 -0
- package/test/logic/03.6.1-numeric-text-comparison-coercion.sqllogic +244 -0
- package/test/logic/03.6.2-value-to-text.sqllogic +224 -0
- package/test/logic/03.7-bigint-mixed-arithmetic.sqllogic +65 -0
- package/test/logic/03.8-not-precedence.sqllogic +255 -0
- package/test/logic/03.9-is-bool-predicate.sqllogic +150 -0
- package/test/logic/03.9.1-is-bool-predicate-partial-index.sqllogic +34 -0
- package/test/logic/04-order-by.sqllogic +38 -0
- package/test/logic/04-transactions.sqllogic +239 -0
- package/test/logic/04a-savepoint-lazy-attach.sqllogic +122 -0
- package/test/logic/05-vtab_memory.sqllogic +50 -0
- package/test/logic/05.0.1-vtab-memory-unique-index-collation.sqllogic +34 -0
- package/test/logic/05.1-composite-pk-range-scan.sqllogic +147 -0
- package/test/logic/05.1.1-secondary-index-range-scan.sqllogic +56 -0
- package/test/logic/05.2-cast-seek-correctness.sqllogic +124 -0
- package/test/logic/06-builtin_functions.sqllogic +149 -0
- package/test/logic/06.1-string-functions.sqllogic +92 -0
- package/test/logic/06.1.3-like-glob-edges.sqllogic +53 -0
- package/test/logic/06.2-math-functions.sqllogic +82 -0
- package/test/logic/06.3-schema.sqllogic +48 -0
- package/test/logic/06.3.1-schema-all-schemas.sqllogic +39 -0
- package/test/logic/06.3.2-schema-foreign-keys.sqllogic +208 -0
- package/test/logic/06.3.3-introspection-tags.sqllogic +202 -0
- package/test/logic/06.3.3.1-introspection-tags-index.sqllogic +74 -0
- package/test/logic/06.3.4-view-info.sqllogic +378 -0
- package/test/logic/06.3.5-column-info.sqllogic +347 -0
- package/test/logic/06.3.6-schema-views.sqllogic +29 -0
- package/test/logic/06.4-schema-search-path.sqllogic +354 -0
- package/test/logic/06.4.1-schema-case-insensitive.sqllogic +83 -0
- package/test/logic/06.4.2-collation-extras.sqllogic +472 -0
- package/test/logic/06.4.2.1-collation-index-access-paths.sqllogic +140 -0
- package/test/logic/06.4.3-write-path-collation.sqllogic +99 -0
- package/test/logic/06.4.4-comparison-collation-precedence.sqllogic +342 -0
- package/test/logic/06.4.5-any-collate-declared-keys.sqllogic +92 -0
- package/test/logic/06.5-polymorphic-types.sqllogic +169 -0
- package/test/logic/06.5.1-conversion-functions.sqllogic +173 -0
- package/test/logic/06.5.2-scalar-minmax.sqllogic +16 -0
- package/test/logic/06.5.3-undeclared-return-type-comparison.sqllogic +244 -0
- package/test/logic/06.5.4-declared-return-type-builtins.sqllogic +288 -0
- package/test/logic/06.6-aggregate-extended.sqllogic +78 -0
- package/test/logic/06.7-json-extended.sqllogic +53 -0
- package/test/logic/06.8-json-path-operators.sqllogic +99 -0
- package/test/logic/06.9-json-canonical-key.sqllogic +65 -0
- package/test/logic/06.9.1-json-coerce-once.sqllogic +417 -0
- package/test/logic/06.9.1.1-json-coerce-once-index.sqllogic +39 -0
- package/test/logic/06.9.2-json-structural-equality.sqllogic +382 -0
- package/test/logic/06.9.2.1-json-structural-equality-index.sqllogic +76 -0
- package/test/logic/06.9.3-json-index-range-seek.sqllogic +205 -0
- package/test/logic/07-aggregates.sqllogic +193 -0
- package/test/logic/07.1-aggregate-filter-clause.sqllogic +12 -0
- package/test/logic/07.2-aggregate-order-by.sqllogic +11 -0
- package/test/logic/07.3-group-by-extras.sqllogic +602 -0
- package/test/logic/07.3.1-group-by-order-by-key.sqllogic +164 -0
- package/test/logic/07.3.2-grouped-select-list-shape.sqllogic +231 -0
- package/test/logic/07.4-group-by-filter-composite-pk.sqllogic +120 -0
- package/test/logic/07.5-sum-mixed-exact-and-float.sqllogic +151 -0
- package/test/logic/07.5-window.sqllogic +1941 -0
- package/test/logic/07.5.1-window-named.sqllogic +13 -0
- package/test/logic/07.5.2-window-nth-value.sqllogic +13 -0
- package/test/logic/07.6-subqueries.sqllogic +78 -0
- package/test/logic/07.6.1-subquery-extras.sqllogic +93 -0
- package/test/logic/07.7-and-or-short-circuit.sqllogic +58 -0
- package/test/logic/07.7-in-subquery-caching.sqllogic +174 -0
- package/test/logic/07.7-scalar-agg-decorrelation.sqllogic +197 -0
- package/test/logic/07.7.1-in-extras.sqllogic +158 -0
- package/test/logic/07.7.1-scalar-agg-decorrelation-filter.sqllogic +105 -0
- package/test/logic/07.7.2-scalar-agg-decorrelation-nested.sqllogic +115 -0
- package/test/logic/07.7.3-exists-in-select-decorrelation.sqllogic +107 -0
- package/test/logic/07.7.4-where-conjunct-ordering.sqllogic +121 -0
- package/test/logic/07.7.5-filter-lost-under-index-order.sqllogic +134 -0
- package/test/logic/07.7.6-correlated-predicate-scope.sqllogic +178 -0
- package/test/logic/07.7.7-join-source-scope-shadowing.sqllogic +137 -0
- package/test/logic/07.7.8-correlated-ref-to-computed-column.sqllogic +165 -0
- package/test/logic/07.7.9-conjunct-monotonicity.sqllogic +200 -0
- package/test/logic/07.8-correlated-subquery-edges.sqllogic +71 -0
- package/test/logic/07.8.1-correlated-in-decorrelation-gates.sqllogic +156 -0
- package/test/logic/07.9-in-value-list.sqllogic +154 -0
- package/test/logic/07.9.1-in-value-list-composite-index.sqllogic +38 -0
- package/test/logic/08-views.sqllogic +64 -0
- package/test/logic/08.1-semi-anti-join.sqllogic +191 -0
- package/test/logic/08.1-view-edge-cases.sqllogic +118 -0
- package/test/logic/08.1.1-uncorrelated-in-semijoin.sqllogic +251 -0
- package/test/logic/08.2-existence-flag-semijoin-recovery.sqllogic +197 -0
- package/test/logic/08.3-existence-flag-inner-recovery.sqllogic +102 -0
- package/test/logic/08.4-key-set-semi-join.sqllogic +447 -0
- package/test/logic/09-set_operations.sqllogic +244 -0
- package/test/logic/09.1-set-op-cross-collation.sqllogic +230 -0
- package/test/logic/10-distinct_datatypes.sqllogic +127 -0
- package/test/logic/10.1-ddl-lifecycle.sqllogic +203 -0
- package/test/logic/10.1.1-create-table-syntax-edges.sqllogic +47 -0
- package/test/logic/10.1.2-ddl-in-transaction.sqllogic +143 -0
- package/test/logic/10.1.2.1-add-constraint-in-transaction.sqllogic +59 -0
- package/test/logic/10.1.3-ddl-drop-in-transaction.sqllogic +187 -0
- package/test/logic/10.1.3.1-drop-constraint-in-transaction.sqllogic +45 -0
- package/test/logic/10.1.4-create-table-duplicate-constraint-names.sqllogic +149 -0
- package/test/logic/10.1.4-ddl-transaction-policy.sqllogic +314 -0
- package/test/logic/10.1.5-alter-add-constraint-minted-name-disambiguation.sqllogic +219 -0
- package/test/logic/10.1.5-create-index-lifecycle.sqllogic +72 -0
- package/test/logic/10.1.6-ddl-transaction-policy-index.sqllogic +143 -0
- package/test/logic/10.1.7-create-table-default-type-check.sqllogic +119 -0
- package/test/logic/10.1.8-alter-add-check-existing-rows.sqllogic +117 -0
- package/test/logic/10.2-column-features.sqllogic +365 -0
- package/test/logic/10.2.1-table-options-rejection.sqllogic +63 -0
- package/test/logic/10.2.2-default-collation-memory.sqllogic +30 -0
- package/test/logic/10.3-function-features.sqllogic +247 -0
- package/test/logic/10.4-schema-scale.sqllogic +168 -0
- package/test/logic/10.4.1-schema-scale-indexes.sqllogic +121 -0
- package/test/logic/10.5-indexes.sqllogic +164 -0
- package/test/logic/10.5.1-partial-indexes.sqllogic +526 -0
- package/test/logic/10.5.2-expression-indexes.sqllogic +34 -0
- package/test/logic/10.5.3-desc-index-ordering.sqllogic +130 -0
- package/test/logic/10.5.4-composite-pk-index-update-phantom.sqllogic +55 -0
- package/test/logic/10.5.5-index-name-uniqueness.sqllogic +76 -0
- package/test/logic/10.5.6-minmax-index-boundary.sqllogic +204 -0
- package/test/logic/10.5.7-implicit-unique-index-lifecycle.sqllogic +1216 -0
- package/test/logic/10.6-distinct-edge-cases.sqllogic +119 -0
- package/test/logic/100-predicate-normalization-edge-cases.sqllogic +238 -0
- package/test/logic/100.1-where-extras.sqllogic +163 -0
- package/test/logic/100.1.1-where-join-on-order-indexed.sqllogic +35 -0
- package/test/logic/101-builtin-mutation-kills.sqllogic +974 -0
- package/test/logic/101-transaction-edge-cases.sqllogic +395 -0
- package/test/logic/102-schema-catalog-edge-cases.sqllogic +252 -0
- package/test/logic/102-unique-constraints.sqllogic +145 -0
- package/test/logic/102.0.1-schema-catalog-indexed-table.sqllogic +32 -0
- package/test/logic/102.1-unique-edge-cases.sqllogic +111 -0
- package/test/logic/102.1.1-unique-index-creation-edge-cases.sqllogic +75 -0
- package/test/logic/102.2-unique-collation.sqllogic +181 -0
- package/test/logic/102.2.1-unique-collation-index-derived.sqllogic +305 -0
- package/test/logic/103-database-options-edge-cases.sqllogic +108 -0
- package/test/logic/103.1-pragma-boolean-values.sqllogic +126 -0
- package/test/logic/104-emit-mutation-kills.sqllogic +236 -0
- package/test/logic/105-vtab-memory-mutation-kills.sqllogic +754 -0
- package/test/logic/105.1-vtab-memory-index-mutation-kills.sqllogic +540 -0
- package/test/logic/106-constraint-extractor-mutation-kills.sqllogic +350 -0
- package/test/logic/107-temporal-arithmetic-mutation-kills.sqllogic +833 -0
- package/test/logic/108-cardinality-estimation.sqllogic +146 -0
- package/test/logic/108.1-analyze-name-resolution.sqllogic +102 -0
- package/test/logic/109-aggregate-physical-selection.sqllogic +103 -0
- package/test/logic/11-joins.sqllogic +86 -0
- package/test/logic/11.1-join-using.sqllogic +267 -0
- package/test/logic/11.2-comma-join.sqllogic +35 -0
- package/test/logic/11.3-index-nested-loop-join.sqllogic +305 -0
- package/test/logic/11.3-mismatched-collation-join.sqllogic +74 -0
- package/test/logic/11.4-hash-join-side-swap.sqllogic +118 -0
- package/test/logic/110-scan-emitter-mutation-kills.sqllogic +121 -0
- package/test/logic/110.1-scan-emitter-index-scan-kills.sqllogic +47 -0
- package/test/logic/12-empty-primary-key.sqllogic +124 -0
- package/test/logic/12-join_padding_order.sqllogic +58 -0
- package/test/logic/12.1-orderby-index-consumption.sqllogic +40 -0
- package/test/logic/13-cte.sqllogic +137 -0
- package/test/logic/13.1-cte-multiple-recursive.sqllogic +104 -0
- package/test/logic/13.10-cte-qualified-name.sqllogic +136 -0
- package/test/logic/13.11-unreferenced-dml-cte.sqllogic +414 -0
- package/test/logic/13.12-nested-dml-cte-rejected.sqllogic +280 -0
- package/test/logic/13.2-cte-bind-params.sqllogic +98 -0
- package/test/logic/13.3-cte-edge-cases.sqllogic +120 -0
- package/test/logic/13.4-cte-extras.sqllogic +98 -0
- package/test/logic/13.5-cte-join-order.sqllogic +166 -0
- package/test/logic/13.6-cte-dml-runs-once.sqllogic +318 -0
- package/test/logic/13.7-cte-sibling-visibility.sqllogic +227 -0
- package/test/logic/13.8-insert-with-clause-visibility.sqllogic +254 -0
- package/test/logic/13.9-schema-authored-cte-isolation.sqllogic +328 -0
- package/test/logic/13.9.1-schema-authored-schema-path-isolation.sqllogic +408 -0
- package/test/logic/14-utilities.sqllogic +168 -0
- package/test/logic/15-timespan.sqllogic +279 -0
- package/test/logic/15.1-semantic-ordering.sqllogic +960 -0
- package/test/logic/15.1.1-json-check-coercion.sqllogic +178 -0
- package/test/logic/15.1.2-semantic-ordering-index.sqllogic +41 -0
- package/test/logic/15.1.3-declared-form-write-contract.sqllogic +519 -0
- package/test/logic/16-epoch.sqllogic +187 -0
- package/test/logic/17-weekday-modifier.sqllogic +78 -0
- package/test/logic/18-json-string-escapes.sqllogic +86 -0
- package/test/logic/18-strftime-extended-formats.sqllogic +68 -0
- package/test/logic/20-empty-single-row.sqllogic +261 -0
- package/test/logic/21-null-edge-cases.sqllogic +227 -0
- package/test/logic/21.1-where-null-comparisons.sqllogic +151 -0
- package/test/logic/21.1.1-where-null-comparisons-secondary-index.sqllogic +35 -0
- package/test/logic/21.2-between-edges.sqllogic +157 -0
- package/test/logic/22-boundary-values.sqllogic +175 -0
- package/test/logic/23-self-joins-duplicates.sqllogic +74 -0
- package/test/logic/24-builtin-branches.sqllogic +611 -0
- package/test/logic/24.1-substr-extras.sqllogic +75 -0
- package/test/logic/24.2-random-extras.sqllogic +39 -0
- package/test/logic/25-aggregate-edge-cases.sqllogic +289 -0
- package/test/logic/25.1-nested-aggregates.sqllogic +74 -0
- package/test/logic/25.2-having-edge-cases.sqllogic +318 -0
- package/test/logic/25.3-aggregate-isnull-empty.sqllogic +16 -0
- package/test/logic/25.4-groupby-fd-constant-empty.sqllogic +55 -0
- package/test/logic/25.5-ungrouped-aggregate-column-free-select-item.sqllogic +196 -0
- package/test/logic/26-join-edge-cases.sqllogic +333 -0
- package/test/logic/26.1-left-join-isnull-on-notnull.sqllogic +26 -0
- package/test/logic/26.2-left-join-on-vs-where.sqllogic +67 -0
- package/test/logic/26.3-join-on-constants.sqllogic +61 -0
- package/test/logic/26.4-join-on-is-null-nullable.sqllogic +44 -0
- package/test/logic/27-window-edge-cases.sqllogic +206 -0
- package/test/logic/27.1-window-groups-frame.sqllogic +13 -0
- package/test/logic/27.2-window-exclude.sqllogic +13 -0
- package/test/logic/27.3-window-json-aggregation.sqllogic +66 -0
- package/test/logic/28-set-ops-sort-edge-cases.sqllogic +444 -0
- package/test/logic/28.1-compound-limit-offset.sqllogic +143 -0
- package/test/logic/28.2-orderby-expression-extras.sqllogic +698 -0
- package/test/logic/28.2-set-op-branch-types.sqllogic +217 -0
- package/test/logic/29-constraint-edge-cases.sqllogic +442 -0
- package/test/logic/29.1-column-level-conflict-clause.sqllogic +171 -0
- package/test/logic/29.2-table-level-pk-conflict-clause.sqllogic +113 -0
- package/test/logic/40-constraints.sqllogic +418 -0
- package/test/logic/40.1-pk-desc-direction.sqllogic +76 -0
- package/test/logic/40.2-check-extras.sqllogic +683 -0
- package/test/logic/41-alter-table.sqllogic +191 -0
- package/test/logic/41-fk-cascade-conflict-and-self-ref.sqllogic +263 -0
- package/test/logic/41-fk-cross-schema.sqllogic +155 -0
- package/test/logic/41-fk-extended-targets.sqllogic +173 -0
- package/test/logic/41-foreign-keys.sqllogic +1001 -0
- package/test/logic/41-generated-column-errors.sqllogic +225 -0
- package/test/logic/41-generated-column-extras.sqllogic +598 -0
- package/test/logic/41-generated-column-scope.sqllogic +329 -0
- package/test/logic/41-generated-columns.sqllogic +361 -0
- package/test/logic/41.1-alter-pk.sqllogic +230 -0
- package/test/logic/41.1-fk-collation-conflict.sqllogic +277 -0
- package/test/logic/41.10-alter-drop-column-foreign-key.sqllogic +274 -0
- package/test/logic/41.10.1-alter-drop-column-unique-index.sqllogic +169 -0
- package/test/logic/41.10.2-alter-drop-column-check-and-assertion.sqllogic +1616 -0
- package/test/logic/41.10.3-alter-drop-column-referencing-fk.sqllogic +292 -0
- package/test/logic/41.10.4-drop-object-expression-dependents.sqllogic +602 -0
- package/test/logic/41.11-deferred-fk-with-rename.sqllogic +232 -0
- package/test/logic/41.12-alter-default-coercion.sqllogic +200 -0
- package/test/logic/41.13-alter-add-column-generated-backfill.sqllogic +566 -0
- package/test/logic/41.14-alter-add-column-subquery-backfill.sqllogic +129 -0
- package/test/logic/41.15-alter-column-default-type-check.sqllogic +178 -0
- package/test/logic/41.16-fk-unenforceable.sqllogic +364 -0
- package/test/logic/41.2-alter-column.sqllogic +382 -0
- package/test/logic/41.2.1-alter-column-retype-deleted-row-memory.sqllogic +32 -0
- package/test/logic/41.2.2-alter-column-retype-index-rebuild.sqllogic +77 -0
- package/test/logic/41.2.3-alter-column-set-not-null-pk-backfill.sqllogic +310 -0
- package/test/logic/41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic +37 -0
- package/test/logic/41.3-alter-add-column-unique.sqllogic +184 -0
- package/test/logic/41.3-alter-rename-propagation.sqllogic +2352 -0
- package/test/logic/41.3.1-alter-rename-index-propagation.sqllogic +94 -0
- package/test/logic/41.4-alter-add-column-constraints.sqllogic +855 -0
- package/test/logic/41.5-alter-misc.sqllogic +48 -0
- package/test/logic/41.5-cross-schema-foreign-keys.sqllogic +253 -0
- package/test/logic/41.6-alter-drop-rename-constraint.sqllogic +354 -0
- package/test/logic/41.6.1-alter-drop-constraint-index-derived.sqllogic +22 -0
- package/test/logic/41.7-alter-column-collate.sqllogic +105 -0
- package/test/logic/41.7.1-alter-column-collate-unique.sqllogic +45 -0
- package/test/logic/41.7.2-alter-column-collate-unique-store.sqllogic +208 -0
- package/test/logic/41.7.2.1-alter-column-collate-unique-index-store.sqllogic +114 -0
- package/test/logic/41.7.3-alter-column-retype-unique.sqllogic +293 -0
- package/test/logic/41.7.3.1-alter-column-retype-staged-rows-memory.sqllogic +41 -0
- package/test/logic/41.7.3.2-alter-column-retype-unique-index.sqllogic +72 -0
- package/test/logic/41.7.4-alter-column-retype-semantic-memory.sqllogic +445 -0
- package/test/logic/41.7.4.1-alter-column-retype-semantic-index-memory.sqllogic +91 -0
- package/test/logic/41.7.5-alter-column-collate-pk-staged-delete-memory.sqllogic +106 -0
- package/test/logic/41.8-alter-add-constraint-unique-fk.sqllogic +275 -0
- package/test/logic/41.8-alter-savepoint-staged-rows.sqllogic +443 -0
- package/test/logic/41.8.1-alter-rename-savepoint-staged-rows.sqllogic +408 -0
- package/test/logic/41.9-alter-constraint-body-change.sqllogic +180 -0
- package/test/logic/41.9-fk-restrict-batched.sqllogic +290 -0
- package/test/logic/42-committed-snapshot.sqllogic +254 -0
- package/test/logic/42-returning.sqllogic +159 -0
- package/test/logic/42.1-returning-extras.sqllogic +232 -0
- package/test/logic/42.2-returning-stored-row.sqllogic +165 -0
- package/test/logic/43-default-nullability.sqllogic +131 -0
- package/test/logic/43-transition-constraints.sqllogic +341 -0
- package/test/logic/43.1-default-collation.sqllogic +140 -0
- package/test/logic/43.1-notnull-or-conflict.sqllogic +79 -0
- package/test/logic/43.2-deferred-check-new-on-delete.sqllogic +95 -0
- package/test/logic/43.3-nullable-primary-key.sqllogic +587 -0
- package/test/logic/44-determinism-validation.sqllogic +164 -0
- package/test/logic/44-orthogonality.sqllogic +146 -0
- package/test/logic/44.1-nondeterministic-schema.sqllogic +316 -0
- package/test/logic/45-udf-determinism.sqllogic +39 -0
- package/test/logic/46-mutation-context.sqllogic +595 -0
- package/test/logic/47-upsert.sqllogic +255 -0
- package/test/logic/47.1-upsert-conflict-targets.sqllogic +169 -0
- package/test/logic/47.2-replace-and-or-clauses.sqllogic +164 -0
- package/test/logic/47.2.1-pk-replace-secondary-unique.sqllogic +374 -0
- package/test/logic/47.3-engine-or-fail.sqllogic +122 -0
- package/test/logic/47.3-upsert-conflict-target-collation.sqllogic +139 -0
- package/test/logic/47.3.1-upsert-conflict-index-derived-collation.sqllogic +25 -0
- package/test/logic/47.4-upsert-conflict-target-affinity.sqllogic +59 -0
- package/test/logic/47.5-upsert-do-update-constraints.sqllogic +440 -0
- package/test/logic/47.6-upsert-do-update-decomposed.sqllogic +100 -0
- package/test/logic/49-reference-graph.sqllogic +84 -0
- package/test/logic/50-declarative-schema.sqllogic +2550 -0
- package/test/logic/50-metadata-tags.sqllogic +1033 -0
- package/test/logic/50.0.1-metadata-tags-index.sqllogic +141 -0
- package/test/logic/50.1-declare-schema-pk.sqllogic +150 -0
- package/test/logic/50.2-declare-schema-renames.sqllogic +949 -0
- package/test/logic/50.2.1-declare-schema-index-renames.sqllogic +210 -0
- package/test/logic/50.3-declare-schema-duplicate-names.sqllogic +280 -0
- package/test/logic/50.4-declare-schema-apply-restore.sqllogic +192 -0
- package/test/logic/51-lens-foundation.sqllogic +147 -0
- package/test/logic/51-materialized-views.sqllogic +376 -0
- package/test/logic/51.5-materialized-views-coarsened-key.sqllogic +198 -0
- package/test/logic/51.7-maintained-table-attach-detach.sqllogic +468 -0
- package/test/logic/51.8-maintained-table-declared-constraints.sqllogic +440 -0
- package/test/logic/51.85-maintained-table-parent-fk.sqllogic +103 -0
- package/test/logic/51.9-maintained-table-secondary-unique.sqllogic +237 -0
- package/test/logic/51.9.1-maintained-table-partial-unique.sqllogic +36 -0
- package/test/logic/52-lens-overrides.sqllogic +566 -0
- package/test/logic/53-materialized-views-rowtime.sqllogic +1601 -0
- package/test/logic/53-reserved-tags.sqllogic +252 -0
- package/test/logic/53.1-materialized-view-write-through.sqllogic +329 -0
- package/test/logic/53.2-materialized-view-rename-propagation.sqllogic +483 -0
- package/test/logic/53.3-materialized-view-constraint-only-ddl.sqllogic +409 -0
- package/test/logic/53.3.1-materialized-view-index-ddl-irrelevance.sqllogic +29 -0
- package/test/logic/53.4-materialized-view-structural-alter-restore.sqllogic +436 -0
- package/test/logic/54-covering-mv-enforcement.sqllogic +314 -0
- package/test/logic/54.1-covering-mv-partial-enforcement.sqllogic +34 -0
- package/test/logic/55-internal-eviction-reporting.sqllogic +89 -0
- package/test/logic/55-lens-prover.sqllogic +202 -0
- package/test/logic/55.1-eviction-restrict-fk.sqllogic +148 -0
- package/test/logic/55.5-lens-authored-inverse.sqllogic +1468 -0
- package/test/logic/80-grow-retrieve-pass.sqllogic +79 -0
- package/test/logic/81-quickpick.sqllogic +24 -0
- package/test/logic/82-bloom-join.sqllogic +185 -0
- package/test/logic/83-merge-join.sqllogic +280 -0
- package/test/logic/84-asof-scan.sqllogic +238 -0
- package/test/logic/84-key-cardinality.sqllogic +50 -0
- package/test/logic/85-relational-const-folding.sqllogic +51 -0
- package/test/logic/86-scalar-cse.sqllogic +42 -0
- package/test/logic/90-error_paths.sqllogic +114 -0
- package/test/logic/90.1-parse-errors.sqllogic +77 -0
- package/test/logic/90.2-alter-table-errors.sqllogic +53 -0
- package/test/logic/90.2.1-alter-extra-errors.sqllogic +51 -0
- package/test/logic/90.3-expression-errors.sqllogic +43 -0
- package/test/logic/90.4-dml-errors.sqllogic +47 -0
- package/test/logic/90.5-unsupported-join-types.sqllogic +37 -0
- package/test/logic/90.5.1-right-full-join-read.sqllogic +157 -0
- package/test/logic/90.6-select-error-paths.sqllogic +57 -0
- package/test/logic/91-merge-join-edge-cases.sqllogic +159 -0
- package/test/logic/92-hash-aggregate-edge-cases.sqllogic +139 -0
- package/test/logic/93-ddl-view-edge-cases.sqllogic +104 -0
- package/test/logic/93.1-view-error-paths.sqllogic +74 -0
- package/test/logic/93.2-view-mutation-pending.sqllogic +108 -0
- package/test/logic/93.3-view-mutation-or-clause.sqllogic +60 -0
- package/test/logic/93.4-view-mutation.sqllogic +4881 -0
- package/test/logic/93.4.1-view-mutation-partial-unique-cardinality.sqllogic +31 -0
- package/test/logic/93.5-authored-inverse.sqllogic +415 -0
- package/test/logic/93.6-set-op-flagless-write.sqllogic +862 -0
- package/test/logic/94-tvf-edge-cases.sqllogic +58 -0
- package/test/logic/94.1-limit-offset-edge-cases.sqllogic +109 -0
- package/test/logic/94.2-limit-offset-extras.sqllogic +98 -0
- package/test/logic/95-assertions.sqllogic +1417 -0
- package/test/logic/96-subquery-edge-cases.sqllogic +276 -0
- package/test/logic/97-json-function-edge-cases.sqllogic +633 -0
- package/test/logic/97.1-json-blob-and-special-values.sqllogic +92 -0
- package/test/logic/98-temporal-edge-cases.sqllogic +515 -0
- package/test/logic/99-conversion-edge-cases.sqllogic +325 -0
- package/test/logic/99.0.1-schema-index-listing.sqllogic +21 -0
- package/test/logic/99.1-cast-syntax-extras.sqllogic +167 -0
- package/test/logic/drop-unique-index.sqllogic +88 -0
- package/test/logic/pushdown-test.sqllogic +36 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
-- ALTER COLUMN ... SET NOT NULL on a PRIMARY KEY member: the null → DEFAULT backfill moves the
|
|
2
|
+
-- key VALUES, so two rows that differed only by NULL-vs-DEFAULT there would merge. Key membership
|
|
3
|
+
-- does not imply NOT NULL (docs/schema.md § "Primary-key nullability"), so any key column can be
|
|
4
|
+
-- nullable and hold NULLs — the cases below reach that state via the all-columns key a table with
|
|
5
|
+
-- no declared PRIMARY KEY gets, and 43.3-nullable-primary-key § 10 reaches it via a declared key.
|
|
6
|
+
--
|
|
7
|
+
-- Cross-module: both backends treat the backfill as a primary-key re-key and ask the same two
|
|
8
|
+
-- questions before mutating anything (memory: MemoryTableManager.validateRekeyedPrimaryKey over
|
|
9
|
+
-- the CONVERTED rows; store: StoreTable.validateRekeyedPrimaryKey with the same per-row mapper) —
|
|
10
|
+
-- a collision the transaction can SEE is CONSTRAINT, a collision confined to rows only a rollback
|
|
11
|
+
-- could restore is BUSY, and either refusal leaves the table and the transaction untouched. An
|
|
12
|
+
-- accepted backfill physically re-keys: memory re-derives each open layer's staged deletion keys
|
|
13
|
+
-- (TransactionLayer.convertColumn), the store re-encodes the data keys after the value rewrite
|
|
14
|
+
-- (StoreModuleAlterColumn.alterColumnChange → rekeyRows), and the isolation overlay the store runs
|
|
15
|
+
-- behind re-keys its staged deletion markers (alter-migration.ts derivePkRekey / backfillStagedNotNull).
|
|
16
|
+
|
|
17
|
+
-- ===================================
|
|
18
|
+
-- 1. Two COMMITTED rows that converge under the backfill: refused (CONSTRAINT), nothing changes.
|
|
19
|
+
-- ===================================
|
|
20
|
+
|
|
21
|
+
create table t_bf1 (x integer null default 0, y integer null);
|
|
22
|
+
insert into t_bf1 (x, y) values (null, 1), (0, 1);
|
|
23
|
+
-- run
|
|
24
|
+
|
|
25
|
+
alter table t_bf1 alter column x set not null;
|
|
26
|
+
-- error: collides under the new key definition
|
|
27
|
+
|
|
28
|
+
select count(*) as n from t_bf1;
|
|
29
|
+
→ [{"n":2}]
|
|
30
|
+
|
|
31
|
+
select count(*) as n from t_bf1 where x is null;
|
|
32
|
+
→ [{"n":1}]
|
|
33
|
+
|
|
34
|
+
select name, "notnull" from table_info('t_bf1') where name = 'x';
|
|
35
|
+
→ [{"name":"x","notnull":0}]
|
|
36
|
+
|
|
37
|
+
drop table t_bf1;
|
|
38
|
+
|
|
39
|
+
-- ===================================
|
|
40
|
+
-- 2. A STAGED insert converging with a committed row is a duplicate this transaction's own
|
|
41
|
+
-- select would return: refused (CONSTRAINT), transaction still usable.
|
|
42
|
+
-- ===================================
|
|
43
|
+
|
|
44
|
+
create table t_bf2 (x integer null default 0, y integer null);
|
|
45
|
+
insert into t_bf2 (x, y) values (null, 1);
|
|
46
|
+
-- run
|
|
47
|
+
|
|
48
|
+
begin;
|
|
49
|
+
insert into t_bf2 (x, y) values (0, 1);
|
|
50
|
+
-- run
|
|
51
|
+
|
|
52
|
+
alter table t_bf2 alter column x set not null;
|
|
53
|
+
-- error: collides under the new key definition
|
|
54
|
+
|
|
55
|
+
select count(*) as n from t_bf2;
|
|
56
|
+
→ [{"n":2}]
|
|
57
|
+
|
|
58
|
+
rollback;
|
|
59
|
+
select x, y from t_bf2;
|
|
60
|
+
→ [{"x":null,"y":1}]
|
|
61
|
+
|
|
62
|
+
drop table t_bf2;
|
|
63
|
+
|
|
64
|
+
-- ===================================
|
|
65
|
+
-- 3. A collision confined to a committed row this transaction has DELETED: invisible to the
|
|
66
|
+
-- transaction's view, but it must survive a rollback and the rebuilt key structure cannot
|
|
67
|
+
-- hold the pair — refused as retryable (BUSY), transaction usable, retry after commit lands.
|
|
68
|
+
-- ===================================
|
|
69
|
+
|
|
70
|
+
create table t_bf3 (x integer null default 0, y integer null);
|
|
71
|
+
insert into t_bf3 (x, y) values (null, 1), (0, 1), (null, 2);
|
|
72
|
+
-- run
|
|
73
|
+
|
|
74
|
+
begin;
|
|
75
|
+
delete from t_bf3 where x is null and y = 1;
|
|
76
|
+
-- run
|
|
77
|
+
|
|
78
|
+
alter table t_bf3 alter column x set not null;
|
|
79
|
+
-- error: still collide under the new key definition
|
|
80
|
+
|
|
81
|
+
select count(*) as n from t_bf3;
|
|
82
|
+
→ [{"n":2}]
|
|
83
|
+
|
|
84
|
+
commit;
|
|
85
|
+
alter table t_bf3 alter column x set not null;
|
|
86
|
+
select x, y from t_bf3 order by y;
|
|
87
|
+
→ [{"x":0,"y":1},{"x":0,"y":2}]
|
|
88
|
+
|
|
89
|
+
drop table t_bf3;
|
|
90
|
+
|
|
91
|
+
-- ===================================
|
|
92
|
+
-- 4. A staged delete that REMOVES the collision (delete the NULL row, re-insert its backfilled
|
|
93
|
+
-- twin) is accepted, and exactly one row per key survives the commit.
|
|
94
|
+
-- ===================================
|
|
95
|
+
|
|
96
|
+
create table t_bf4 (x integer null default 0, y integer null);
|
|
97
|
+
insert into t_bf4 (x, y) values (null, 1), (null, 2);
|
|
98
|
+
-- run
|
|
99
|
+
|
|
100
|
+
begin;
|
|
101
|
+
delete from t_bf4 where x is null and y = 1;
|
|
102
|
+
insert into t_bf4 (x, y) values (0, 1);
|
|
103
|
+
alter table t_bf4 alter column x set not null;
|
|
104
|
+
select x, y from t_bf4 order by y;
|
|
105
|
+
→ [{"x":0,"y":1},{"x":0,"y":2}]
|
|
106
|
+
|
|
107
|
+
commit;
|
|
108
|
+
select x, y from t_bf4 order by y;
|
|
109
|
+
→ [{"x":0,"y":1},{"x":0,"y":2}]
|
|
110
|
+
|
|
111
|
+
select count(*) as n from t_bf4 where x = 0 and y = 1;
|
|
112
|
+
→ [{"n":1}]
|
|
113
|
+
|
|
114
|
+
drop table t_bf4;
|
|
115
|
+
|
|
116
|
+
-- ===================================
|
|
117
|
+
-- 5. RESURRECTION guard: a row DELETED in this transaction whose key the backfill moves must
|
|
118
|
+
-- stay deleted — through the ALTER and through the commit. (The staged deletion was recorded
|
|
119
|
+
-- under the pre-backfill key; a replay under that key would land nowhere and the row would
|
|
120
|
+
-- reappear with the backfilled value.)
|
|
121
|
+
-- ===================================
|
|
122
|
+
|
|
123
|
+
create table t_bf5 (x integer null default 0, y integer null);
|
|
124
|
+
insert into t_bf5 (x, y) values (null, 1), (null, 2);
|
|
125
|
+
-- run
|
|
126
|
+
|
|
127
|
+
begin;
|
|
128
|
+
delete from t_bf5 where x is null and y = 1;
|
|
129
|
+
select count(*) as n from t_bf5;
|
|
130
|
+
→ [{"n":1}]
|
|
131
|
+
|
|
132
|
+
alter table t_bf5 alter column x set not null;
|
|
133
|
+
select x, y from t_bf5;
|
|
134
|
+
→ [{"x":0,"y":2}]
|
|
135
|
+
|
|
136
|
+
commit;
|
|
137
|
+
select x, y from t_bf5;
|
|
138
|
+
→ [{"x":0,"y":2}]
|
|
139
|
+
|
|
140
|
+
drop table t_bf5;
|
|
141
|
+
|
|
142
|
+
-- ===================================
|
|
143
|
+
-- 6. A NON-colliding key-column backfill is accepted, and the backfilled row is still FINDABLE
|
|
144
|
+
-- by an equality lookup on its new key and DELETABLE — i.e. the key bytes followed the value
|
|
145
|
+
-- (the store used to rewrite the row payload under its old NULL-encoding key).
|
|
146
|
+
-- ===================================
|
|
147
|
+
|
|
148
|
+
create table t_bf6 (x integer null default 7, y integer null);
|
|
149
|
+
insert into t_bf6 (x, y) values (null, 1), (3, 1);
|
|
150
|
+
alter table t_bf6 alter column x set not null;
|
|
151
|
+
select x, y from t_bf6 order by x;
|
|
152
|
+
→ [{"x":3,"y":1},{"x":7,"y":1}]
|
|
153
|
+
|
|
154
|
+
select x, y from t_bf6 where x = 7 and y = 1;
|
|
155
|
+
→ [{"x":7,"y":1}]
|
|
156
|
+
|
|
157
|
+
insert into t_bf6 (x, y) values (7, 1);
|
|
158
|
+
-- error: UNIQUE constraint failed
|
|
159
|
+
|
|
160
|
+
delete from t_bf6 where x = 7 and y = 1;
|
|
161
|
+
select x, y from t_bf6;
|
|
162
|
+
→ [{"x":3,"y":1}]
|
|
163
|
+
|
|
164
|
+
insert into t_bf6 (x, y) values (7, 1);
|
|
165
|
+
select count(*) as n from t_bf6 where x = 7;
|
|
166
|
+
→ [{"n":1}]
|
|
167
|
+
|
|
168
|
+
drop table t_bf6;
|
|
169
|
+
|
|
170
|
+
-- ===================================
|
|
171
|
+
-- 7. Single-column key (the whole row IS the key): the scalar key form re-keys too.
|
|
172
|
+
-- ===================================
|
|
173
|
+
|
|
174
|
+
create table t_bf7 (x integer null default 5);
|
|
175
|
+
insert into t_bf7 (x) values (null), (3);
|
|
176
|
+
alter table t_bf7 alter column x set not null;
|
|
177
|
+
select x from t_bf7 order by x;
|
|
178
|
+
→ [{"x":3},{"x":5}]
|
|
179
|
+
|
|
180
|
+
select x from t_bf7 where x = 5;
|
|
181
|
+
→ [{"x":5}]
|
|
182
|
+
|
|
183
|
+
delete from t_bf7 where x = 5;
|
|
184
|
+
select x from t_bf7;
|
|
185
|
+
→ [{"x":3}]
|
|
186
|
+
|
|
187
|
+
drop table t_bf7;
|
|
188
|
+
|
|
189
|
+
-- ===================================
|
|
190
|
+
-- 8. Two STAGED rows converging under the backfill: refused (CONSTRAINT), rollback clean.
|
|
191
|
+
-- (Behind the isolation layer this is the overlay's own pre-flight; on plain memory it is
|
|
192
|
+
-- the manager's effective-row probe — same message.)
|
|
193
|
+
-- ===================================
|
|
194
|
+
|
|
195
|
+
create table t_bf9 (x integer null default 0, y integer null);
|
|
196
|
+
-- run
|
|
197
|
+
|
|
198
|
+
begin;
|
|
199
|
+
insert into t_bf9 (x, y) values (null, 1), (0, 1);
|
|
200
|
+
-- run
|
|
201
|
+
|
|
202
|
+
alter table t_bf9 alter column x set not null;
|
|
203
|
+
-- error: collides under the new key definition
|
|
204
|
+
|
|
205
|
+
rollback;
|
|
206
|
+
select count(*) as n from t_bf9;
|
|
207
|
+
→ [{"n":0}]
|
|
208
|
+
|
|
209
|
+
drop table t_bf9;
|
|
210
|
+
|
|
211
|
+
-- ===================================
|
|
212
|
+
-- 9. A staged NULL row that backfills onto the key of a committed row this transaction has
|
|
213
|
+
-- DELETED: the deletion is that row's before-image, not a duplicate — accepted, and the
|
|
214
|
+
-- staged row is what survives the commit.
|
|
215
|
+
-- ===================================
|
|
216
|
+
|
|
217
|
+
create table t_bf10 (x integer null default 0, y integer null);
|
|
218
|
+
insert into t_bf10 (x, y) values (0, 1);
|
|
219
|
+
-- run
|
|
220
|
+
|
|
221
|
+
begin;
|
|
222
|
+
delete from t_bf10 where x = 0 and y = 1;
|
|
223
|
+
insert into t_bf10 (x, y) values (null, 1);
|
|
224
|
+
alter table t_bf10 alter column x set not null;
|
|
225
|
+
select x, y from t_bf10;
|
|
226
|
+
→ [{"x":0,"y":1}]
|
|
227
|
+
|
|
228
|
+
commit;
|
|
229
|
+
select x, y from t_bf10;
|
|
230
|
+
→ [{"x":0,"y":1}]
|
|
231
|
+
|
|
232
|
+
select count(*) as n from t_bf10 where x = 0 and y = 1;
|
|
233
|
+
→ [{"n":1}]
|
|
234
|
+
|
|
235
|
+
drop table t_bf10;
|
|
236
|
+
|
|
237
|
+
-- ===================================
|
|
238
|
+
-- 10. A tightening the transaction can see NO NULL for is metadata-only: the committed keys do
|
|
239
|
+
-- not move, and a staged deletion of a NULL-keyed committed row still lands at commit.
|
|
240
|
+
-- ===================================
|
|
241
|
+
|
|
242
|
+
create table t_bf11 (x integer null default 0, y integer null);
|
|
243
|
+
insert into t_bf11 (x, y) values (null, 1), (2, 2);
|
|
244
|
+
-- run
|
|
245
|
+
|
|
246
|
+
begin;
|
|
247
|
+
delete from t_bf11 where x is null and y = 1;
|
|
248
|
+
alter table t_bf11 alter column x set not null;
|
|
249
|
+
select x, y from t_bf11;
|
|
250
|
+
→ [{"x":2,"y":2}]
|
|
251
|
+
|
|
252
|
+
commit;
|
|
253
|
+
select x, y from t_bf11;
|
|
254
|
+
→ [{"x":2,"y":2}]
|
|
255
|
+
|
|
256
|
+
insert into t_bf11 (x, y) values (null, 3);
|
|
257
|
+
-- error: NOT NULL
|
|
258
|
+
|
|
259
|
+
drop table t_bf11;
|
|
260
|
+
|
|
261
|
+
-- ===================================
|
|
262
|
+
-- 11. The same backfill on a NON-key column is unchanged: no re-key, values filled, key intact.
|
|
263
|
+
-- ===================================
|
|
264
|
+
|
|
265
|
+
create table t_bf12 (id integer primary key, v integer null default 9);
|
|
266
|
+
insert into t_bf12 values (1, null), (2, null), (3, 4);
|
|
267
|
+
begin;
|
|
268
|
+
delete from t_bf12 where id = 2;
|
|
269
|
+
alter table t_bf12 alter column v set not null;
|
|
270
|
+
select id, v from t_bf12 order by id;
|
|
271
|
+
→ [{"id":1,"v":9},{"id":3,"v":4}]
|
|
272
|
+
|
|
273
|
+
commit;
|
|
274
|
+
select id, v from t_bf12 order by id;
|
|
275
|
+
→ [{"id":1,"v":9},{"id":3,"v":4}]
|
|
276
|
+
|
|
277
|
+
select id, v from t_bf12 where id = 1;
|
|
278
|
+
→ [{"id":1,"v":9}]
|
|
279
|
+
|
|
280
|
+
drop table t_bf12;
|
|
281
|
+
|
|
282
|
+
-- ===================================
|
|
283
|
+
-- 12. A SECONDARY INDEX over an untouched column still resolves after the re-key: its entries
|
|
284
|
+
-- embed the primary key, which the backfill just moved. Both the committed rebuild (base /
|
|
285
|
+
-- store re-key) and the open-layer rebuild (TransactionLayer.convertColumn) are exercised.
|
|
286
|
+
-- ===================================
|
|
287
|
+
|
|
288
|
+
-- Table-level `unique` (not a standalone `create index`) so the file needs no
|
|
289
|
+
-- `-- requires-capability: standalone-index-ddl` and runs on every backend. The same case
|
|
290
|
+
-- built with a standalone `create index` lives in
|
|
291
|
+
-- 41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic, which does declare it.
|
|
292
|
+
create table t_bf13 (x integer null default 7, y integer null unique);
|
|
293
|
+
insert into t_bf13 (x, y) values (3, 2);
|
|
294
|
+
-- run
|
|
295
|
+
|
|
296
|
+
begin;
|
|
297
|
+
insert into t_bf13 (x, y) values (null, 1);
|
|
298
|
+
alter table t_bf13 alter column x set not null;
|
|
299
|
+
select x, y from t_bf13 where y = 1;
|
|
300
|
+
→ [{"x":7,"y":1}]
|
|
301
|
+
|
|
302
|
+
commit;
|
|
303
|
+
select x, y from t_bf13 where y = 1;
|
|
304
|
+
→ [{"x":7,"y":1}]
|
|
305
|
+
|
|
306
|
+
delete from t_bf13 where y = 1;
|
|
307
|
+
select x, y from t_bf13;
|
|
308
|
+
→ [{"x":3,"y":2}]
|
|
309
|
+
|
|
310
|
+
drop table t_bf13;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- 41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic
|
|
2
|
+
--
|
|
3
|
+
-- requires-capability: standalone-index-ddl
|
|
4
|
+
--
|
|
5
|
+
-- Carved out of 41.2.3-alter-column-set-not-null-pk-backfill's former § 12: a standalone
|
|
6
|
+
-- `create index` needs standalone index DDL, which not every backend implements, and the
|
|
7
|
+
-- `-- requires-capability:` directive is whole-file — leaving this case in the parent file
|
|
8
|
+
-- would have made its eleven other primary-key-backfill sections, which need no index DDL,
|
|
9
|
+
-- skippable too. 41.2.3 § 12 now covers the same ground via a table-level `unique` column
|
|
10
|
+
-- instead, so it needs no directive; this file keeps the standalone-index-DDL shape covered.
|
|
11
|
+
--
|
|
12
|
+
-- Subject: a SECONDARY INDEX (built via standalone `create index`, not `unique`) over an
|
|
13
|
+
-- untouched column still resolves after ALTER COLUMN ... SET NOT NULL backfills and re-keys
|
|
14
|
+
-- the primary key. Its entries embed the primary key, which the backfill just moved. Both
|
|
15
|
+
-- the committed rebuild (base / store re-key) and the open-layer rebuild
|
|
16
|
+
-- (TransactionLayer.convertColumn) are exercised.
|
|
17
|
+
|
|
18
|
+
create table t_bf13 (x integer null default 7, y integer null);
|
|
19
|
+
create index ix_bf13 on t_bf13 (y);
|
|
20
|
+
insert into t_bf13 (x, y) values (3, 2);
|
|
21
|
+
-- run
|
|
22
|
+
|
|
23
|
+
begin;
|
|
24
|
+
insert into t_bf13 (x, y) values (null, 1);
|
|
25
|
+
alter table t_bf13 alter column x set not null;
|
|
26
|
+
select x, y from t_bf13 where y = 1;
|
|
27
|
+
→ [{"x":7,"y":1}]
|
|
28
|
+
|
|
29
|
+
commit;
|
|
30
|
+
select x, y from t_bf13 where y = 1;
|
|
31
|
+
→ [{"x":7,"y":1}]
|
|
32
|
+
|
|
33
|
+
delete from t_bf13 where y = 1;
|
|
34
|
+
select x, y from t_bf13;
|
|
35
|
+
→ [{"x":3,"y":2}]
|
|
36
|
+
|
|
37
|
+
drop table t_bf13;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
-- ALTER TABLE ADD COLUMN with an inline column-level UNIQUE.
|
|
2
|
+
--
|
|
3
|
+
-- An inline UNIQUE on the new column is routed through the module's `addConstraint`
|
|
4
|
+
-- UNIQUE path — the same path `ALTER TABLE ADD CONSTRAINT … UNIQUE` uses — so it is
|
|
5
|
+
-- materialized, enforced, and (store) persisted, symmetric with CREATE TABLE. These
|
|
6
|
+
-- cases run under both the memory module (`yarn test`) and the store module
|
|
7
|
+
-- (`yarn test:store`); assertions read engine-catalog introspection (table_info /
|
|
8
|
+
-- unique_constraint_info / index_info), which is module-agnostic.
|
|
9
|
+
|
|
10
|
+
-- ===================================================================
|
|
11
|
+
-- 1. Basic: enforcement + introspection (unnamed inline UNIQUE)
|
|
12
|
+
-- ===================================================================
|
|
13
|
+
|
|
14
|
+
create table AddU (id integer primary key);
|
|
15
|
+
alter table AddU add column u integer unique;
|
|
16
|
+
|
|
17
|
+
-- The constraint is materialized and surfaces in introspection (unnamed → name null,
|
|
18
|
+
-- one row per constrained column).
|
|
19
|
+
select name, column_name from unique_constraint_info('AddU');
|
|
20
|
+
→ [{"name":null,"column_name":"u"}]
|
|
21
|
+
|
|
22
|
+
-- Forward enforcement: a duplicate value is rejected.
|
|
23
|
+
insert into AddU values (1, 5);
|
|
24
|
+
insert into AddU values (2, 5);
|
|
25
|
+
-- error: UNIQUE constraint failed
|
|
26
|
+
|
|
27
|
+
-- A distinct value still inserts.
|
|
28
|
+
insert into AddU values (3, 6);
|
|
29
|
+
select count(*) as c from AddU;
|
|
30
|
+
→ [{"c":2}]
|
|
31
|
+
|
|
32
|
+
-- ===================================================================
|
|
33
|
+
-- 2. A named inline UNIQUE round-trips its name
|
|
34
|
+
-- ===================================================================
|
|
35
|
+
|
|
36
|
+
create table AddNamed (id integer primary key);
|
|
37
|
+
alter table AddNamed add column sku text constraint uq_sku unique;
|
|
38
|
+
select name, column_name from unique_constraint_info('AddNamed');
|
|
39
|
+
→ [{"name":"uq_sku","column_name":"sku"}]
|
|
40
|
+
|
|
41
|
+
-- Enforcement is active under the named constraint.
|
|
42
|
+
insert into AddNamed values (1, 'a');
|
|
43
|
+
insert into AddNamed values (2, 'a');
|
|
44
|
+
-- error: UNIQUE constraint failed
|
|
45
|
+
|
|
46
|
+
-- ===================================================================
|
|
47
|
+
-- 3. Existing NULLs are distinct: the add succeeds over multiple NULLs,
|
|
48
|
+
-- and forward duplicates of a non-NULL value are still rejected.
|
|
49
|
+
-- ===================================================================
|
|
50
|
+
|
|
51
|
+
create table AddNull (id integer primary key);
|
|
52
|
+
insert into AddNull values (1), (2);
|
|
53
|
+
-- Existing rows backfill the new (nullable) column with NULL (no DEFAULT); NULLs are
|
|
54
|
+
-- distinct, so the UNIQUE add succeeds over the two existing NULL rows.
|
|
55
|
+
alter table AddNull add column code integer null unique;
|
|
56
|
+
select count(*) as c from unique_constraint_info('AddNull');
|
|
57
|
+
→ [{"c":1}]
|
|
58
|
+
|
|
59
|
+
-- Two non-NULL duplicates collide going forward.
|
|
60
|
+
insert into AddNull values (3, 7);
|
|
61
|
+
insert into AddNull values (4, 7);
|
|
62
|
+
-- error: UNIQUE constraint failed
|
|
63
|
+
|
|
64
|
+
-- ===================================================================
|
|
65
|
+
-- 4. Literal DEFAULT that duplicates across existing rows: the UNIQUE add
|
|
66
|
+
-- fails and the column is fully reverted (no half-applied column /
|
|
67
|
+
-- constraint / index, original schema intact).
|
|
68
|
+
-- ===================================================================
|
|
69
|
+
|
|
70
|
+
create table AddDefDup (id integer primary key);
|
|
71
|
+
insert into AddDefDup values (1), (2);
|
|
72
|
+
-- DEFAULT 5 backfills the same value to both existing rows → immediate duplicate.
|
|
73
|
+
alter table AddDefDup add column u integer default 5 unique;
|
|
74
|
+
-- error: UNIQUE constraint failed
|
|
75
|
+
|
|
76
|
+
-- Revert: the column is gone, no orphan constraint, no orphan index.
|
|
77
|
+
select count(*) as c from table_info('AddDefDup') where name = 'u';
|
|
78
|
+
→ [{"c":0}]
|
|
79
|
+
select count(*) as c from unique_constraint_info('AddDefDup');
|
|
80
|
+
→ [{"c":0}]
|
|
81
|
+
select count(*) as c from index_info('AddDefDup');
|
|
82
|
+
→ [{"c":0}]
|
|
83
|
+
|
|
84
|
+
-- Original schema is intact and usable (single id column).
|
|
85
|
+
insert into AddDefDup values (3);
|
|
86
|
+
select count(*) as c from AddDefDup;
|
|
87
|
+
→ [{"c":3}]
|
|
88
|
+
|
|
89
|
+
-- ===================================================================
|
|
90
|
+
-- 5. Combined revert: ADD COLUMN carrying BOTH a UNIQUE and a CHECK, where the
|
|
91
|
+
-- UNIQUE materializes successfully (single existing row → no duplicate) but the
|
|
92
|
+
-- CHECK then fails over the backfilled row. The revert must tear down the unique
|
|
93
|
+
-- covering structure too — no orphan in index_info / unique_constraint_info.
|
|
94
|
+
-- ===================================================================
|
|
95
|
+
|
|
96
|
+
create table AddCombo (id integer primary key);
|
|
97
|
+
insert into AddCombo values (1);
|
|
98
|
+
-- DEFAULT 0 over the single row: UNIQUE passes (one row), but CHECK (u > 0) fails.
|
|
99
|
+
alter table AddCombo add column u integer default 0 check (u > 0) unique;
|
|
100
|
+
-- error: CHECK constraint
|
|
101
|
+
|
|
102
|
+
-- Full revert: column gone, and neither the unique constraint nor its covering index
|
|
103
|
+
-- (memory) survives as an orphan.
|
|
104
|
+
select count(*) as c from table_info('AddCombo') where name = 'u';
|
|
105
|
+
→ [{"c":0}]
|
|
106
|
+
select count(*) as c from unique_constraint_info('AddCombo');
|
|
107
|
+
→ [{"c":0}]
|
|
108
|
+
select count(*) as c from index_info('AddCombo');
|
|
109
|
+
→ [{"c":0}]
|
|
110
|
+
|
|
111
|
+
-- The table still works under its original shape, and re-adding the same column with
|
|
112
|
+
-- a CHECK-satisfying DEFAULT now succeeds (proving no stale constraint/index lingers).
|
|
113
|
+
alter table AddCombo add column u integer default 1 check (u > 0) unique;
|
|
114
|
+
select count(*) as c from unique_constraint_info('AddCombo');
|
|
115
|
+
→ [{"c":1}]
|
|
116
|
+
select u from AddCombo;
|
|
117
|
+
→ [{"u":1}]
|
|
118
|
+
|
|
119
|
+
-- ===================================================================
|
|
120
|
+
-- 6. Standalone DROP COLUMN of a single-column-UNIQUE column. The general
|
|
121
|
+
-- dropColumn fix (prune the dangling UNIQUE + tear down its covering index)
|
|
122
|
+
-- is what the ADD COLUMN revert path relies on; exercise it directly here.
|
|
123
|
+
-- ===================================================================
|
|
124
|
+
|
|
125
|
+
create table DropU (id integer primary key, a integer, b integer unique);
|
|
126
|
+
insert into DropU values (1, 10, 100);
|
|
127
|
+
-- b is enforced unique while it exists.
|
|
128
|
+
insert into DropU values (2, 20, 100);
|
|
129
|
+
-- error: UNIQUE constraint failed
|
|
130
|
+
alter table DropU drop column b;
|
|
131
|
+
-- Constraint and its covering index are both gone — no orphan.
|
|
132
|
+
select count(*) as c from unique_constraint_info('DropU');
|
|
133
|
+
→ [{"c":0}]
|
|
134
|
+
select count(*) as c from index_info('DropU');
|
|
135
|
+
→ [{"c":0}]
|
|
136
|
+
-- The table is usable under its narrowed shape (b no longer enforced/present).
|
|
137
|
+
insert into DropU values (3, 30);
|
|
138
|
+
select count(*) as c from DropU;
|
|
139
|
+
→ [{"c":2}]
|
|
140
|
+
|
|
141
|
+
-- ===================================================================
|
|
142
|
+
-- 7. Standalone DROP COLUMN of a column that participates in a MULTI-column
|
|
143
|
+
-- UNIQUE: the whole constraint is removed (a UNIQUE missing a column is a
|
|
144
|
+
-- different constraint), AND its covering index is torn down — not left
|
|
145
|
+
-- orphaned as a narrowed structure over the surviving columns.
|
|
146
|
+
-- ===================================================================
|
|
147
|
+
|
|
148
|
+
create table DropMultiIn (id integer primary key, a integer, b integer, constraint uq_ab unique (a, b));
|
|
149
|
+
insert into DropMultiIn values (1, 1, 2);
|
|
150
|
+
insert into DropMultiIn values (2, 1, 2);
|
|
151
|
+
-- error: UNIQUE constraint failed
|
|
152
|
+
alter table DropMultiIn drop column b;
|
|
153
|
+
-- The entire uq_ab constraint is gone — and so is its covering index (no orphan
|
|
154
|
+
-- narrowed to column a, which a prior narrow-not-remove bug would have left behind).
|
|
155
|
+
select count(*) as c from unique_constraint_info('DropMultiIn');
|
|
156
|
+
→ [{"c":0}]
|
|
157
|
+
select count(*) as c from index_info('DropMultiIn');
|
|
158
|
+
→ [{"c":0}]
|
|
159
|
+
-- a alone is no longer constrained: a duplicate value is now allowed.
|
|
160
|
+
insert into DropMultiIn values (3, 1);
|
|
161
|
+
insert into DropMultiIn values (4, 1);
|
|
162
|
+
select count(*) as c from DropMultiIn;
|
|
163
|
+
→ [{"c":3}]
|
|
164
|
+
|
|
165
|
+
-- ===================================================================
|
|
166
|
+
-- 8. Standalone DROP COLUMN of a column NOT in a multi-column UNIQUE: the
|
|
167
|
+
-- constraint survives with its column indices shifted over the removed slot
|
|
168
|
+
-- and still enforces over the correct (renumbered) columns.
|
|
169
|
+
-- ===================================================================
|
|
170
|
+
|
|
171
|
+
create table DropMultiOut (id integer primary key, x integer, a integer, b integer, constraint uq_ab unique (a, b));
|
|
172
|
+
insert into DropMultiOut values (1, 99, 1, 2);
|
|
173
|
+
-- Drop x (lower index than a and b, not part of uq_ab): the constraint's column
|
|
174
|
+
-- indices shift down by one but it survives intact.
|
|
175
|
+
alter table DropMultiOut drop column x;
|
|
176
|
+
select name, column_name from unique_constraint_info('DropMultiOut') order by column_name;
|
|
177
|
+
→ [{"name":"uq_ab","column_name":"a"},{"name":"uq_ab","column_name":"b"}]
|
|
178
|
+
-- Still enforces (a, b) after the shift: the same (a, b) pair collides…
|
|
179
|
+
insert into DropMultiOut values (2, 1, 2);
|
|
180
|
+
-- error: UNIQUE constraint failed
|
|
181
|
+
-- …but a distinct pair is allowed.
|
|
182
|
+
insert into DropMultiOut values (3, 5, 6);
|
|
183
|
+
select count(*) as c from DropMultiOut;
|
|
184
|
+
→ [{"c":2}]
|