@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,275 @@
|
|
|
1
|
+
-- 41.8-alter-add-constraint-unique-fk.sqllogic
|
|
2
|
+
-- ALTER TABLE ADD CONSTRAINT for table-level UNIQUE / FOREIGN KEY. The module
|
|
3
|
+
-- re-validates the existing rows and fails atomically with CONSTRAINT when the
|
|
4
|
+
-- current data violates the new constraint; otherwise it installs forward
|
|
5
|
+
-- enforcement. Behavioral assertions only (enforcement + introspection via the
|
|
6
|
+
-- *_constraint_info / *_info TVFs), so this runs identically under `yarn test`
|
|
7
|
+
-- (memory) and `yarn test:store`.
|
|
8
|
+
|
|
9
|
+
pragma foreign_keys = true;
|
|
10
|
+
-- run
|
|
11
|
+
|
|
12
|
+
-- ============================================================
|
|
13
|
+
-- 1. ADD UNIQUE over conforming data — enforces going forward
|
|
14
|
+
-- ============================================================
|
|
15
|
+
create table u_ok (id integer primary key, email text);
|
|
16
|
+
insert into u_ok values (1, 'a@x'), (2, 'b@x');
|
|
17
|
+
-- run
|
|
18
|
+
|
|
19
|
+
alter table u_ok add constraint uq_email unique (email);
|
|
20
|
+
-- run
|
|
21
|
+
|
|
22
|
+
-- introspection lists the named UNIQUE
|
|
23
|
+
select name from unique_constraint_info('u_ok') where name = 'uq_email';
|
|
24
|
+
→ [{"name":"uq_email"}]
|
|
25
|
+
|
|
26
|
+
-- forward enforcement: a duplicate is rejected
|
|
27
|
+
insert into u_ok values (3, 'a@x');
|
|
28
|
+
-- error: unique
|
|
29
|
+
|
|
30
|
+
-- a fresh value still inserts
|
|
31
|
+
insert into u_ok values (3, 'c@x');
|
|
32
|
+
select count(*) as c from u_ok;
|
|
33
|
+
→ [{"c":3}]
|
|
34
|
+
|
|
35
|
+
drop table u_ok;
|
|
36
|
+
-- run
|
|
37
|
+
|
|
38
|
+
-- ============================================================
|
|
39
|
+
-- 2. ADD UNIQUE over duplicated existing data — rejected atomically
|
|
40
|
+
-- ============================================================
|
|
41
|
+
create table u_dup (id integer primary key, email text);
|
|
42
|
+
insert into u_dup values (1, 'a@x'), (2, 'a@x');
|
|
43
|
+
-- run
|
|
44
|
+
|
|
45
|
+
-- the add fails because existing rows already violate uniqueness
|
|
46
|
+
alter table u_dup add constraint uq_email unique (email);
|
|
47
|
+
-- error: unique
|
|
48
|
+
|
|
49
|
+
-- constraint NOT installed: it is absent from introspection
|
|
50
|
+
select count(*) as c from unique_constraint_info('u_dup') where name = 'uq_email';
|
|
51
|
+
→ [{"c":0}]
|
|
52
|
+
|
|
53
|
+
-- ...and enforcement is not active: another duplicate inserts freely
|
|
54
|
+
insert into u_dup values (3, 'a@x');
|
|
55
|
+
select count(*) as c from u_dup;
|
|
56
|
+
→ [{"c":3}]
|
|
57
|
+
|
|
58
|
+
-- retry after removing the offending rows ⇒ the same ADD now converges. (Exercises the
|
|
59
|
+
-- DELETE-after-schema-change consolidation path: the base primary tree is replaced, not unioned,
|
|
60
|
+
-- so the deleted duplicates do not resurface in the UNIQUE index build.)
|
|
61
|
+
delete from u_dup where id in (2, 3);
|
|
62
|
+
alter table u_dup add constraint uq_email unique (email);
|
|
63
|
+
-- run
|
|
64
|
+
|
|
65
|
+
select count(*) as c from unique_constraint_info('u_dup') where name = 'uq_email';
|
|
66
|
+
→ [{"c":1}]
|
|
67
|
+
|
|
68
|
+
-- forward enforcement is now active under the retried constraint
|
|
69
|
+
insert into u_dup values (4, 'a@x');
|
|
70
|
+
-- error: unique
|
|
71
|
+
|
|
72
|
+
drop table u_dup;
|
|
73
|
+
-- run
|
|
74
|
+
|
|
75
|
+
-- ============================================================
|
|
76
|
+
-- 3. ADD UNIQUE with existing NULLs — multiple NULLs allowed
|
|
77
|
+
-- ============================================================
|
|
78
|
+
create table u_null (id integer primary key, email text null);
|
|
79
|
+
insert into u_null values (1, null), (2, null);
|
|
80
|
+
-- run
|
|
81
|
+
|
|
82
|
+
-- two existing NULLs are distinct under SQL UNIQUE — the add succeeds
|
|
83
|
+
alter table u_null add constraint uq_email unique (email);
|
|
84
|
+
-- run
|
|
85
|
+
|
|
86
|
+
-- further NULLs remain allowed
|
|
87
|
+
insert into u_null values (3, null);
|
|
88
|
+
select count(*) as c from u_null where email is null;
|
|
89
|
+
→ [{"c":3}]
|
|
90
|
+
|
|
91
|
+
drop table u_null;
|
|
92
|
+
-- run
|
|
93
|
+
|
|
94
|
+
-- ============================================================
|
|
95
|
+
-- 4. Unnamed ADD UNIQUE (...) form (auto-named)
|
|
96
|
+
-- ============================================================
|
|
97
|
+
create table u_anon (id integer primary key, email text);
|
|
98
|
+
insert into u_anon values (1, 'a@x');
|
|
99
|
+
-- run
|
|
100
|
+
|
|
101
|
+
alter table u_anon add unique (email);
|
|
102
|
+
-- run
|
|
103
|
+
|
|
104
|
+
insert into u_anon values (2, 'a@x');
|
|
105
|
+
-- error: unique
|
|
106
|
+
|
|
107
|
+
drop table u_anon;
|
|
108
|
+
-- run
|
|
109
|
+
|
|
110
|
+
-- ============================================================
|
|
111
|
+
-- 5. ADD FOREIGN KEY over satisfied data — enforces going forward
|
|
112
|
+
-- ============================================================
|
|
113
|
+
create table fk_parent (pid integer primary key);
|
|
114
|
+
insert into fk_parent values (1), (2);
|
|
115
|
+
create table fk_child (id integer primary key, pa integer);
|
|
116
|
+
insert into fk_child values (1, 1), (2, 2);
|
|
117
|
+
-- run
|
|
118
|
+
|
|
119
|
+
alter table fk_child add constraint fk_pa foreign key (pa) references fk_parent(pid);
|
|
120
|
+
-- run
|
|
121
|
+
|
|
122
|
+
select name from foreign_key_info('fk_child') where name = 'fk_pa';
|
|
123
|
+
→ [{"name":"fk_pa"}]
|
|
124
|
+
|
|
125
|
+
-- forward enforcement: an orphan child is rejected
|
|
126
|
+
insert into fk_child values (3, 99);
|
|
127
|
+
-- error:
|
|
128
|
+
|
|
129
|
+
-- a satisfied child still inserts
|
|
130
|
+
insert into fk_child values (3, 2);
|
|
131
|
+
select count(*) as c from fk_child;
|
|
132
|
+
→ [{"c":3}]
|
|
133
|
+
|
|
134
|
+
drop table fk_child;
|
|
135
|
+
drop table fk_parent;
|
|
136
|
+
-- run
|
|
137
|
+
|
|
138
|
+
-- ============================================================
|
|
139
|
+
-- 6. ADD FOREIGN KEY over an orphaned row — rejected atomically
|
|
140
|
+
-- ============================================================
|
|
141
|
+
create table fk_parent (pid integer primary key);
|
|
142
|
+
insert into fk_parent values (1);
|
|
143
|
+
create table fk_child (id integer primary key, pa integer);
|
|
144
|
+
insert into fk_child values (1, 1), (2, 99);
|
|
145
|
+
-- run
|
|
146
|
+
|
|
147
|
+
-- existing row (2, 99) has no parent → the add fails
|
|
148
|
+
alter table fk_child add constraint fk_pa foreign key (pa) references fk_parent(pid);
|
|
149
|
+
-- error:
|
|
150
|
+
|
|
151
|
+
-- constraint NOT installed: absent from introspection
|
|
152
|
+
select count(*) as c from foreign_key_info('fk_child') where name = 'fk_pa';
|
|
153
|
+
→ [{"c":0}]
|
|
154
|
+
|
|
155
|
+
-- ...and not enforced: another orphan inserts freely
|
|
156
|
+
insert into fk_child values (3, 77);
|
|
157
|
+
select count(*) as c from fk_child;
|
|
158
|
+
→ [{"c":3}]
|
|
159
|
+
|
|
160
|
+
drop table fk_child;
|
|
161
|
+
drop table fk_parent;
|
|
162
|
+
-- run
|
|
163
|
+
|
|
164
|
+
-- ============================================================
|
|
165
|
+
-- 7. ADD FOREIGN KEY with a NULL FK child (MATCH SIMPLE)
|
|
166
|
+
-- ============================================================
|
|
167
|
+
create table fk_parent (pid integer primary key);
|
|
168
|
+
insert into fk_parent values (1);
|
|
169
|
+
create table fk_child (id integer primary key, pa integer null);
|
|
170
|
+
insert into fk_child values (1, null), (2, 1);
|
|
171
|
+
-- run
|
|
172
|
+
|
|
173
|
+
-- a NULL FK row is exempt (MATCH SIMPLE) — the add succeeds
|
|
174
|
+
alter table fk_child add constraint fk_pa foreign key (pa) references fk_parent(pid);
|
|
175
|
+
-- run
|
|
176
|
+
|
|
177
|
+
-- further NULL FK rows remain allowed
|
|
178
|
+
insert into fk_child values (3, null);
|
|
179
|
+
-- run
|
|
180
|
+
|
|
181
|
+
-- but a non-NULL orphan is rejected
|
|
182
|
+
insert into fk_child values (4, 99);
|
|
183
|
+
-- error:
|
|
184
|
+
|
|
185
|
+
drop table fk_child;
|
|
186
|
+
drop table fk_parent;
|
|
187
|
+
-- run
|
|
188
|
+
|
|
189
|
+
-- ============================================================
|
|
190
|
+
-- 8. ADD FOREIGN KEY with pragma foreign_keys = false — no validation
|
|
191
|
+
-- ============================================================
|
|
192
|
+
pragma foreign_keys = false;
|
|
193
|
+
create table fk_parent (pid integer primary key);
|
|
194
|
+
insert into fk_parent values (1);
|
|
195
|
+
create table fk_child (id integer primary key, pa integer);
|
|
196
|
+
insert into fk_child values (1, 99);
|
|
197
|
+
-- run
|
|
198
|
+
|
|
199
|
+
-- pragma off: the orphan is NOT validated, so the add succeeds
|
|
200
|
+
alter table fk_child add constraint fk_pa foreign key (pa) references fk_parent(pid);
|
|
201
|
+
-- run
|
|
202
|
+
|
|
203
|
+
select count(*) as c from foreign_key_info('fk_child') where name = 'fk_pa';
|
|
204
|
+
→ [{"c":1}]
|
|
205
|
+
|
|
206
|
+
drop table fk_child;
|
|
207
|
+
drop table fk_parent;
|
|
208
|
+
pragma foreign_keys = true;
|
|
209
|
+
-- run
|
|
210
|
+
|
|
211
|
+
-- ============================================================
|
|
212
|
+
-- 9. Unnamed ADD FOREIGN KEY (...) form (auto-named)
|
|
213
|
+
-- ============================================================
|
|
214
|
+
create table fk_parent (pid integer primary key);
|
|
215
|
+
insert into fk_parent values (1);
|
|
216
|
+
create table fk_child (id integer primary key, pa integer);
|
|
217
|
+
insert into fk_child values (1, 1);
|
|
218
|
+
-- run
|
|
219
|
+
|
|
220
|
+
alter table fk_child add foreign key (pa) references fk_parent(pid);
|
|
221
|
+
-- run
|
|
222
|
+
|
|
223
|
+
-- forward enforcement is active under the auto-name
|
|
224
|
+
insert into fk_child values (2, 99);
|
|
225
|
+
-- error:
|
|
226
|
+
|
|
227
|
+
drop table fk_child;
|
|
228
|
+
drop table fk_parent;
|
|
229
|
+
-- run
|
|
230
|
+
|
|
231
|
+
-- ============================================================
|
|
232
|
+
-- 10. Composite ADD FOREIGN KEY over existing rows — exercises the shared
|
|
233
|
+
-- existing-row validator's `not exists` orphan test across MORE THAN ONE
|
|
234
|
+
-- referenced column (the multi-column match chain in the correlated subquery;
|
|
235
|
+
-- single-column cases above only argue the composite path in comments).
|
|
236
|
+
-- ============================================================
|
|
237
|
+
create table fk_cparent (a integer, b integer, primary key (a, b));
|
|
238
|
+
insert into fk_cparent values (1, 10), (2, 20);
|
|
239
|
+
|
|
240
|
+
-- 10a. Composite SATISFIED — every existing (ref_a, ref_b) pair has a parent row.
|
|
241
|
+
create table fk_cchild (id integer primary key, ref_a integer, ref_b integer);
|
|
242
|
+
insert into fk_cchild values (1, 1, 10), (2, 2, 20);
|
|
243
|
+
-- run
|
|
244
|
+
|
|
245
|
+
alter table fk_cchild add constraint fk_ab foreign key (ref_a, ref_b) references fk_cparent(a, b);
|
|
246
|
+
-- run
|
|
247
|
+
|
|
248
|
+
-- installed and enforced going forward; a matching prefix on only ONE column is still an orphan
|
|
249
|
+
insert into fk_cchild values (3, 1, 20);
|
|
250
|
+
-- error:
|
|
251
|
+
|
|
252
|
+
insert into fk_cchild values (4, 2, 20);
|
|
253
|
+
select count(*) as c from fk_cchild;
|
|
254
|
+
→ [{"c":3}]
|
|
255
|
+
|
|
256
|
+
drop table fk_cchild;
|
|
257
|
+
-- run
|
|
258
|
+
|
|
259
|
+
-- 10b. Composite ORPHAN — (2, 99) matches the parent on `a` only ⇒ no full
|
|
260
|
+
-- match ⇒ the add is rejected (the first-parent-col null test must not be
|
|
261
|
+
-- fooled by the partial `a` match).
|
|
262
|
+
create table fk_cchild (id integer primary key, ref_a integer, ref_b integer);
|
|
263
|
+
insert into fk_cchild values (1, 1, 10), (2, 2, 99);
|
|
264
|
+
-- run
|
|
265
|
+
|
|
266
|
+
alter table fk_cchild add constraint fk_ab foreign key (ref_a, ref_b) references fk_cparent(a, b);
|
|
267
|
+
-- error:
|
|
268
|
+
|
|
269
|
+
-- not installed, not enforced
|
|
270
|
+
select count(*) as c from foreign_key_info('fk_cchild') where name = 'fk_ab';
|
|
271
|
+
→ [{"c":0}]
|
|
272
|
+
|
|
273
|
+
drop table fk_cchild;
|
|
274
|
+
drop table fk_cparent;
|
|
275
|
+
-- run
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
-- ALTER TABLE column-shape changes (ADD / DROP / RENAME COLUMN) inside a transaction
|
|
2
|
+
-- must not disturb the savepoint ledger of rows the transaction has already staged:
|
|
3
|
+
-- rows staged BEFORE a savepoint survive `rollback to savepoint`, rows staged AFTER it
|
|
4
|
+
-- are discarded. (DDL itself is not transactional — the rollback keeps the column
|
|
5
|
+
-- change and only unwinds row writes.)
|
|
6
|
+
--
|
|
7
|
+
-- Cross-backend on purpose: under the memory module the pending rows live in its own
|
|
8
|
+
-- transaction layers; under --store they live in the isolation wrapper's per-connection
|
|
9
|
+
-- overlay, which every ALTER used to REBUILD (copy staged rows into a fresh staging
|
|
10
|
+
-- table). The copy's first write lazily registered a fresh connection whose replayed
|
|
11
|
+
-- savepoint stack sat ABOVE the copied rows, so the next `rollback to savepoint`
|
|
12
|
+
-- discarded rows staged long before the savepoint (isolation-alter-forward-column-shape).
|
|
13
|
+
|
|
14
|
+
-- ADD COLUMN: pre-savepoint row survives (backfilled), post-savepoint rows discarded.
|
|
15
|
+
create table t1 (id integer primary key, v text);
|
|
16
|
+
-- run
|
|
17
|
+
|
|
18
|
+
begin;
|
|
19
|
+
-- run
|
|
20
|
+
insert into t1 values (1, 'a');
|
|
21
|
+
-- run
|
|
22
|
+
savepoint s;
|
|
23
|
+
-- run
|
|
24
|
+
insert into t1 values (2, 'b');
|
|
25
|
+
-- run
|
|
26
|
+
alter table t1 add column w text default 'z';
|
|
27
|
+
-- run
|
|
28
|
+
insert into t1 values (3, 'c', 'x');
|
|
29
|
+
-- run
|
|
30
|
+
rollback to savepoint s;
|
|
31
|
+
-- run
|
|
32
|
+
|
|
33
|
+
select id, v, w from t1 order by id;
|
|
34
|
+
→ [{"id":1,"v":"a","w":"z"}]
|
|
35
|
+
|
|
36
|
+
commit;
|
|
37
|
+
-- run
|
|
38
|
+
|
|
39
|
+
select id, v, w from t1 order by id;
|
|
40
|
+
→ [{"id":1,"v":"a","w":"z"}]
|
|
41
|
+
|
|
42
|
+
drop table t1;
|
|
43
|
+
-- run
|
|
44
|
+
|
|
45
|
+
-- DROP COLUMN (middle) with a committed row present: staged values realign under the
|
|
46
|
+
-- narrower layout, and the savepoint ledger still splits pre/post rows correctly.
|
|
47
|
+
create table t2 (id integer primary key, v text, x integer);
|
|
48
|
+
-- run
|
|
49
|
+
insert into t2 values (0, 'base', 100);
|
|
50
|
+
-- run
|
|
51
|
+
|
|
52
|
+
begin;
|
|
53
|
+
-- run
|
|
54
|
+
insert into t2 values (1, 'a', 10);
|
|
55
|
+
-- run
|
|
56
|
+
savepoint s;
|
|
57
|
+
-- run
|
|
58
|
+
insert into t2 values (2, 'b', 20);
|
|
59
|
+
-- run
|
|
60
|
+
alter table t2 drop column v;
|
|
61
|
+
-- run
|
|
62
|
+
rollback to savepoint s;
|
|
63
|
+
-- run
|
|
64
|
+
commit;
|
|
65
|
+
-- run
|
|
66
|
+
|
|
67
|
+
select id, x from t2 order by id;
|
|
68
|
+
→ [{"id":0,"x":100},{"id":1,"x":10}]
|
|
69
|
+
|
|
70
|
+
drop table t2;
|
|
71
|
+
-- run
|
|
72
|
+
|
|
73
|
+
-- RENAME COLUMN: the rename does not change the column set, but the open layers still
|
|
74
|
+
-- have to ADOPT the renamed schema — an eager savepoint snapshot left holding its frozen
|
|
75
|
+
-- pre-rename schema fails `commitTransaction`'s snapshot-wrap identity check and the
|
|
76
|
+
-- transaction's staged rows are dropped at COMMIT.
|
|
77
|
+
create table t3 (id integer primary key, v text);
|
|
78
|
+
-- run
|
|
79
|
+
|
|
80
|
+
begin;
|
|
81
|
+
-- run
|
|
82
|
+
insert into t3 values (1, 'a');
|
|
83
|
+
-- run
|
|
84
|
+
savepoint s;
|
|
85
|
+
-- run
|
|
86
|
+
insert into t3 values (2, 'b');
|
|
87
|
+
-- run
|
|
88
|
+
alter table t3 rename column v to vv;
|
|
89
|
+
-- run
|
|
90
|
+
insert into t3 values (3, 'c');
|
|
91
|
+
-- run
|
|
92
|
+
rollback to savepoint s;
|
|
93
|
+
-- run
|
|
94
|
+
|
|
95
|
+
select id, vv from t3 order by id;
|
|
96
|
+
→ [{"id":1,"vv":"a"}]
|
|
97
|
+
|
|
98
|
+
commit;
|
|
99
|
+
-- run
|
|
100
|
+
|
|
101
|
+
select id, vv from t3 order by id;
|
|
102
|
+
→ [{"id":1,"vv":"a"}]
|
|
103
|
+
|
|
104
|
+
drop table t3;
|
|
105
|
+
-- run
|
|
106
|
+
|
|
107
|
+
-- ...and the same rename with no rollback: every staged row survives COMMIT.
|
|
108
|
+
create table t3b (id integer primary key, v text);
|
|
109
|
+
-- run
|
|
110
|
+
|
|
111
|
+
begin;
|
|
112
|
+
-- run
|
|
113
|
+
insert into t3b values (1, 'a');
|
|
114
|
+
-- run
|
|
115
|
+
savepoint s;
|
|
116
|
+
-- run
|
|
117
|
+
alter table t3b rename column v to vv;
|
|
118
|
+
-- run
|
|
119
|
+
commit;
|
|
120
|
+
-- run
|
|
121
|
+
|
|
122
|
+
select id, vv from t3b order by id;
|
|
123
|
+
→ [{"id":1,"vv":"a"}]
|
|
124
|
+
|
|
125
|
+
drop table t3b;
|
|
126
|
+
-- run
|
|
127
|
+
|
|
128
|
+
-- A staged tombstone (an in-transaction DELETE of a committed row) survives the ALTER
|
|
129
|
+
-- under a savepoint and still applies at COMMIT.
|
|
130
|
+
create table t4 (id integer primary key, v text);
|
|
131
|
+
-- run
|
|
132
|
+
insert into t4 values (1, 'a'), (2, 'b');
|
|
133
|
+
-- run
|
|
134
|
+
|
|
135
|
+
begin;
|
|
136
|
+
-- run
|
|
137
|
+
delete from t4 where id = 1;
|
|
138
|
+
-- run
|
|
139
|
+
savepoint s;
|
|
140
|
+
-- run
|
|
141
|
+
alter table t4 add column w text default 'z';
|
|
142
|
+
-- run
|
|
143
|
+
rollback to savepoint s;
|
|
144
|
+
-- run
|
|
145
|
+
commit;
|
|
146
|
+
-- run
|
|
147
|
+
|
|
148
|
+
select id, v, w from t4 order by id;
|
|
149
|
+
→ [{"id":2,"v":"b","w":"z"}]
|
|
150
|
+
|
|
151
|
+
drop table t4;
|
|
152
|
+
-- run
|
|
153
|
+
|
|
154
|
+
-- ALTER COLUMN SET NOT NULL that needs NO backfill: metadata-only, so it moves nothing an
|
|
155
|
+
-- open layer derives — but the layers still have to ADOPT the new schema OBJECT, or the
|
|
156
|
+
-- savepoint snapshot a `rollback to savepoint` swaps in keeps its frozen pre-ALTER schema,
|
|
157
|
+
-- fails `commitTransaction`'s snapshot-wrap identity check, and the staged rows are dropped
|
|
158
|
+
-- at COMMIT.
|
|
159
|
+
create table t5 (id integer primary key, v text null);
|
|
160
|
+
-- run
|
|
161
|
+
|
|
162
|
+
begin;
|
|
163
|
+
-- run
|
|
164
|
+
insert into t5 values (1, 'a');
|
|
165
|
+
-- run
|
|
166
|
+
savepoint s;
|
|
167
|
+
-- run
|
|
168
|
+
insert into t5 values (2, 'b');
|
|
169
|
+
-- run
|
|
170
|
+
alter table t5 alter column v set not null;
|
|
171
|
+
-- run
|
|
172
|
+
insert into t5 values (3, 'c');
|
|
173
|
+
-- run
|
|
174
|
+
rollback to savepoint s;
|
|
175
|
+
-- run
|
|
176
|
+
|
|
177
|
+
select id, v from t5 order by id;
|
|
178
|
+
→ [{"id":1,"v":"a"}]
|
|
179
|
+
|
|
180
|
+
commit;
|
|
181
|
+
-- run
|
|
182
|
+
|
|
183
|
+
select id, v from t5 order by id;
|
|
184
|
+
→ [{"id":1,"v":"a"}]
|
|
185
|
+
|
|
186
|
+
drop table t5;
|
|
187
|
+
-- run
|
|
188
|
+
|
|
189
|
+
-- ALTER COLUMN SET NOT NULL, the DEFAULT-backfill flavor: a staged NULL is filled at the ALTER, and the
|
|
190
|
+
-- filled row (staged before the later savepoint) survives that savepoint's rollback.
|
|
191
|
+
create table t5b (id integer primary key, v text null default 'filled');
|
|
192
|
+
-- run
|
|
193
|
+
|
|
194
|
+
begin;
|
|
195
|
+
-- run
|
|
196
|
+
insert into t5b values (1, null);
|
|
197
|
+
-- run
|
|
198
|
+
alter table t5b alter column v set not null;
|
|
199
|
+
-- run
|
|
200
|
+
savepoint s;
|
|
201
|
+
-- run
|
|
202
|
+
insert into t5b values (2, 'b');
|
|
203
|
+
-- run
|
|
204
|
+
rollback to savepoint s;
|
|
205
|
+
-- run
|
|
206
|
+
commit;
|
|
207
|
+
-- run
|
|
208
|
+
|
|
209
|
+
select id, v from t5b order by id;
|
|
210
|
+
→ [{"id":1,"v":"filled"}]
|
|
211
|
+
|
|
212
|
+
drop table t5b;
|
|
213
|
+
-- run
|
|
214
|
+
|
|
215
|
+
-- ALTER COLUMN SET DATA TYPE: the pre-savepoint staged row survives the rollback with
|
|
216
|
+
-- its value CONVERTED; the post-savepoint row is discarded.
|
|
217
|
+
create table t6 (id integer primary key, v text);
|
|
218
|
+
-- run
|
|
219
|
+
|
|
220
|
+
begin;
|
|
221
|
+
-- run
|
|
222
|
+
insert into t6 values (1, '10');
|
|
223
|
+
-- run
|
|
224
|
+
savepoint s;
|
|
225
|
+
-- run
|
|
226
|
+
insert into t6 values (2, '20');
|
|
227
|
+
-- run
|
|
228
|
+
alter table t6 alter column v set data type integer;
|
|
229
|
+
-- run
|
|
230
|
+
insert into t6 values (3, 30);
|
|
231
|
+
-- run
|
|
232
|
+
rollback to savepoint s;
|
|
233
|
+
-- run
|
|
234
|
+
|
|
235
|
+
select id, v from t6 order by id;
|
|
236
|
+
→ [{"id":1,"v":10}]
|
|
237
|
+
|
|
238
|
+
commit;
|
|
239
|
+
-- run
|
|
240
|
+
|
|
241
|
+
select id, v from t6 order by id;
|
|
242
|
+
→ [{"id":1,"v":10}]
|
|
243
|
+
|
|
244
|
+
drop table t6;
|
|
245
|
+
-- run
|
|
246
|
+
|
|
247
|
+
-- ALTER COLUMN SET DEFAULT: metadata-only, but the staged rows and the savepoint
|
|
248
|
+
-- ledger must still come through, and the new DEFAULT applies after the rollback.
|
|
249
|
+
create table t7 (id integer primary key, v integer null);
|
|
250
|
+
-- run
|
|
251
|
+
|
|
252
|
+
begin;
|
|
253
|
+
-- run
|
|
254
|
+
insert into t7 values (1, 5);
|
|
255
|
+
-- run
|
|
256
|
+
savepoint s;
|
|
257
|
+
-- run
|
|
258
|
+
insert into t7 values (2, 6);
|
|
259
|
+
-- run
|
|
260
|
+
alter table t7 alter column v set default 99;
|
|
261
|
+
-- run
|
|
262
|
+
rollback to savepoint s;
|
|
263
|
+
-- run
|
|
264
|
+
insert into t7 (id) values (3);
|
|
265
|
+
-- run
|
|
266
|
+
commit;
|
|
267
|
+
-- run
|
|
268
|
+
|
|
269
|
+
select id, v from t7 order by id;
|
|
270
|
+
→ [{"id":1,"v":5},{"id":3,"v":99}]
|
|
271
|
+
|
|
272
|
+
drop table t7;
|
|
273
|
+
-- run
|
|
274
|
+
|
|
275
|
+
-- ADD CONSTRAINT UNIQUE: pre-savepoint staged row survives, post-savepoint rows are
|
|
276
|
+
-- discarded, and the constraint (DDL) survives the rollback and enforces after COMMIT.
|
|
277
|
+
create table t8 (id integer primary key, v text);
|
|
278
|
+
-- run
|
|
279
|
+
|
|
280
|
+
begin;
|
|
281
|
+
-- run
|
|
282
|
+
insert into t8 values (1, 'a');
|
|
283
|
+
-- run
|
|
284
|
+
savepoint s;
|
|
285
|
+
-- run
|
|
286
|
+
insert into t8 values (2, 'b');
|
|
287
|
+
-- run
|
|
288
|
+
alter table t8 add constraint u_v unique (v);
|
|
289
|
+
-- run
|
|
290
|
+
insert into t8 values (3, 'c');
|
|
291
|
+
-- run
|
|
292
|
+
rollback to savepoint s;
|
|
293
|
+
-- run
|
|
294
|
+
|
|
295
|
+
select id, v from t8 order by id;
|
|
296
|
+
→ [{"id":1,"v":"a"}]
|
|
297
|
+
|
|
298
|
+
commit;
|
|
299
|
+
-- run
|
|
300
|
+
|
|
301
|
+
select id, v from t8 order by id;
|
|
302
|
+
→ [{"id":1,"v":"a"}]
|
|
303
|
+
|
|
304
|
+
insert into t8 values (4, 'a');
|
|
305
|
+
-- error: UNIQUE
|
|
306
|
+
|
|
307
|
+
drop table t8;
|
|
308
|
+
-- run
|
|
309
|
+
|
|
310
|
+
-- DROP CONSTRAINT: the drop survives the rollback (DDL is not transactional), the
|
|
311
|
+
-- pre-savepoint staged row survives, and a once-duplicate insert is accepted after COMMIT.
|
|
312
|
+
create table t9 (id integer primary key, v text, constraint u_v unique (v));
|
|
313
|
+
-- run
|
|
314
|
+
insert into t9 values (0, 'dup');
|
|
315
|
+
-- run
|
|
316
|
+
|
|
317
|
+
begin;
|
|
318
|
+
-- run
|
|
319
|
+
insert into t9 values (1, 'a');
|
|
320
|
+
-- run
|
|
321
|
+
savepoint s;
|
|
322
|
+
-- run
|
|
323
|
+
alter table t9 drop constraint u_v;
|
|
324
|
+
-- run
|
|
325
|
+
insert into t9 values (2, 'dup');
|
|
326
|
+
-- run
|
|
327
|
+
rollback to savepoint s;
|
|
328
|
+
-- run
|
|
329
|
+
commit;
|
|
330
|
+
-- run
|
|
331
|
+
|
|
332
|
+
select id, v from t9 order by id;
|
|
333
|
+
→ [{"id":0,"v":"dup"},{"id":1,"v":"a"}]
|
|
334
|
+
|
|
335
|
+
insert into t9 values (3, 'dup');
|
|
336
|
+
-- run
|
|
337
|
+
|
|
338
|
+
select count(*) as c from t9 where v = 'dup';
|
|
339
|
+
→ [{"c":2}]
|
|
340
|
+
|
|
341
|
+
drop table t9;
|
|
342
|
+
-- run
|
|
343
|
+
|
|
344
|
+
-- RENAME CONSTRAINT: schema-only, but the renamed UNIQUE's implicit covering index moves
|
|
345
|
+
-- under a new key in every open layer's index map, and the layers must re-freeze the new
|
|
346
|
+
-- schema so a savepoint snapshot restored across the rename still commits its staged rows.
|
|
347
|
+
create table t10s (id integer primary key, v text, constraint u_old unique (v));
|
|
348
|
+
-- run
|
|
349
|
+
|
|
350
|
+
begin;
|
|
351
|
+
-- run
|
|
352
|
+
insert into t10s values (1, 'a');
|
|
353
|
+
-- run
|
|
354
|
+
savepoint s;
|
|
355
|
+
-- run
|
|
356
|
+
insert into t10s values (2, 'b');
|
|
357
|
+
-- run
|
|
358
|
+
alter table t10s rename constraint u_old to u_new;
|
|
359
|
+
-- run
|
|
360
|
+
rollback to savepoint s;
|
|
361
|
+
-- run
|
|
362
|
+
commit;
|
|
363
|
+
-- run
|
|
364
|
+
|
|
365
|
+
select id, v from t10s order by id;
|
|
366
|
+
→ [{"id":1,"v":"a"}]
|
|
367
|
+
|
|
368
|
+
insert into t10s values (3, 'a');
|
|
369
|
+
-- error: UNIQUE
|
|
370
|
+
|
|
371
|
+
drop table t10s;
|
|
372
|
+
-- run
|
|
373
|
+
|
|
374
|
+
-- ...and the same rename with no savepoint across it:
|
|
375
|
+
create table t10 (id integer primary key, v text, constraint u_old unique (v));
|
|
376
|
+
-- run
|
|
377
|
+
|
|
378
|
+
begin;
|
|
379
|
+
-- run
|
|
380
|
+
insert into t10 values (1, 'a');
|
|
381
|
+
-- run
|
|
382
|
+
alter table t10 rename constraint u_old to u_new;
|
|
383
|
+
-- run
|
|
384
|
+
commit;
|
|
385
|
+
-- run
|
|
386
|
+
|
|
387
|
+
select id, v from t10 order by id;
|
|
388
|
+
→ [{"id":1,"v":"a"}]
|
|
389
|
+
|
|
390
|
+
insert into t10 values (3, 'a');
|
|
391
|
+
-- error: UNIQUE
|
|
392
|
+
|
|
393
|
+
drop table t10;
|
|
394
|
+
-- run
|
|
395
|
+
|
|
396
|
+
-- ADD CONSTRAINT UNIQUE over a primary-key member with two in-transaction deletions:
|
|
397
|
+
-- the two deletion markers share a = 1, and a naive uniqueness check over them would
|
|
398
|
+
-- report a phantom duplicate. Deleted rows are not rows — the ALTER must succeed.
|
|
399
|
+
create table t11 (a integer, b integer, primary key (a, b));
|
|
400
|
+
-- run
|
|
401
|
+
insert into t11 values (1, 1), (1, 2), (2, 1);
|
|
402
|
+
-- run
|
|
403
|
+
|
|
404
|
+
begin;
|
|
405
|
+
-- run
|
|
406
|
+
delete from t11 where a = 1;
|
|
407
|
+
-- run
|
|
408
|
+
alter table t11 add constraint u_a unique (a);
|
|
409
|
+
-- run
|
|
410
|
+
commit;
|
|
411
|
+
-- run
|
|
412
|
+
|
|
413
|
+
select a, b from t11 order by a, b;
|
|
414
|
+
→ [{"a":2,"b":1}]
|
|
415
|
+
|
|
416
|
+
insert into t11 values (3, 1);
|
|
417
|
+
-- run
|
|
418
|
+
insert into t11 values (3, 2);
|
|
419
|
+
-- error: UNIQUE
|
|
420
|
+
|
|
421
|
+
drop table t11;
|
|
422
|
+
-- run
|
|
423
|
+
|
|
424
|
+
-- A backfilling SET NOT NULL must not disturb an in-transaction deletion: the deleted
|
|
425
|
+
-- row stays deleted (never resurrected carrying the DEFAULT) and the survivor is intact.
|
|
426
|
+
create table t12 (id integer primary key, v text null default 'filled');
|
|
427
|
+
-- run
|
|
428
|
+
insert into t12 values (1, null), (2, 'b');
|
|
429
|
+
-- run
|
|
430
|
+
|
|
431
|
+
begin;
|
|
432
|
+
-- run
|
|
433
|
+
delete from t12 where id = 1;
|
|
434
|
+
-- run
|
|
435
|
+
alter table t12 alter column v set not null;
|
|
436
|
+
-- run
|
|
437
|
+
commit;
|
|
438
|
+
-- run
|
|
439
|
+
|
|
440
|
+
select id, v from t12 order by id;
|
|
441
|
+
→ [{"id":2,"v":"b"}]
|
|
442
|
+
|
|
443
|
+
drop table t12;
|