@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,314 @@
|
|
|
1
|
+
-- DDL transaction policy: the `ddl_transaction_policy` pragma and its strict gate.
|
|
2
|
+
--
|
|
3
|
+
-- `permissive` (the default) leaves DDL-in-transaction behavior exactly as it was.
|
|
4
|
+
-- `strict` refuses a module-dispatching DDL statement (CREATE/DROP TABLE/INDEX,
|
|
5
|
+
-- ALTER TABLE, CREATE/DROP/REFRESH MATERIALIZED VIEW) while an explicit transaction
|
|
6
|
+
-- is open, because on memory and store
|
|
7
|
+
-- the schema change would escape the transaction (survive rollback). The refusal
|
|
8
|
+
-- fires before any dispatch or catalog mutation, so the open transaction stays
|
|
9
|
+
-- fully usable afterward.
|
|
10
|
+
--
|
|
11
|
+
-- Runs against every backend (memory, store). Neither declares
|
|
12
|
+
-- ddlTransactionality='transactional', so strict refuses on both; the permissive
|
|
13
|
+
-- sections must behave identically on both. Each statement is its own block so an
|
|
14
|
+
-- expected failure is attributed to exactly one statement.
|
|
15
|
+
--
|
|
16
|
+
-- The gate is verb-agnostic, and every case below is asserted with a table,
|
|
17
|
+
-- ALTER TABLE, materialized-view or `apply schema` statement. The CREATE/DROP INDEX
|
|
18
|
+
-- instance of the same cases lives in 10.1.6-ddl-transaction-policy-index, which
|
|
19
|
+
-- needs standalone index DDL.
|
|
20
|
+
|
|
21
|
+
-- ===================================
|
|
22
|
+
-- 1. Permissive default: DDL inside a transaction is allowed (unchanged behavior)
|
|
23
|
+
-- ===================================
|
|
24
|
+
|
|
25
|
+
create table perm_t (id integer primary key, v text);
|
|
26
|
+
-- run
|
|
27
|
+
begin;
|
|
28
|
+
-- run
|
|
29
|
+
insert into perm_t values (1, 'a');
|
|
30
|
+
-- run
|
|
31
|
+
alter table perm_t add column w text null;
|
|
32
|
+
-- run
|
|
33
|
+
insert into perm_t values (2, 'b', null);
|
|
34
|
+
-- run
|
|
35
|
+
commit;
|
|
36
|
+
-- run
|
|
37
|
+
|
|
38
|
+
select count(*) as cnt from perm_t;
|
|
39
|
+
→ [{ "cnt": 2 }]
|
|
40
|
+
|
|
41
|
+
alter table perm_t drop column w;
|
|
42
|
+
-- run
|
|
43
|
+
|
|
44
|
+
-- ===================================
|
|
45
|
+
-- 2. strict: alter table inside begin is refused; the transaction survives
|
|
46
|
+
-- ===================================
|
|
47
|
+
|
|
48
|
+
pragma ddl_transaction_policy = 'strict';
|
|
49
|
+
-- run
|
|
50
|
+
|
|
51
|
+
create table strict_t (id integer primary key, v text);
|
|
52
|
+
-- run
|
|
53
|
+
insert into strict_t values (1, 'a');
|
|
54
|
+
-- run
|
|
55
|
+
begin;
|
|
56
|
+
-- run
|
|
57
|
+
insert into strict_t values (2, 'b');
|
|
58
|
+
-- run
|
|
59
|
+
alter table strict_t add column w text null;
|
|
60
|
+
-- error: ddl_transaction_policy = strict
|
|
61
|
+
|
|
62
|
+
-- The refusal left the transaction open and usable: insert again and commit.
|
|
63
|
+
insert into strict_t values (3, 'c');
|
|
64
|
+
-- run
|
|
65
|
+
commit;
|
|
66
|
+
-- run
|
|
67
|
+
|
|
68
|
+
-- Both buffered rows landed and the column was never added.
|
|
69
|
+
select count(*) as cnt from strict_t;
|
|
70
|
+
→ [{ "cnt": 3 }]
|
|
71
|
+
|
|
72
|
+
-- ===================================
|
|
73
|
+
-- 3. strict: the same statement is allowed OUTSIDE a transaction (autocommit)
|
|
74
|
+
-- ===================================
|
|
75
|
+
|
|
76
|
+
alter table strict_t add column w text null;
|
|
77
|
+
-- run
|
|
78
|
+
alter table strict_t drop column w;
|
|
79
|
+
-- run
|
|
80
|
+
|
|
81
|
+
-- ===================================
|
|
82
|
+
-- 4. strict: alter table ... add constraint is refused inside begin
|
|
83
|
+
-- ===================================
|
|
84
|
+
|
|
85
|
+
begin;
|
|
86
|
+
-- run
|
|
87
|
+
alter table strict_t add constraint strict_u unique (v);
|
|
88
|
+
-- error: ddl_transaction_policy = strict
|
|
89
|
+
rollback;
|
|
90
|
+
-- run
|
|
91
|
+
|
|
92
|
+
-- ===================================
|
|
93
|
+
-- 5. strict: drop table is refused inside begin (table still present after)
|
|
94
|
+
-- ===================================
|
|
95
|
+
|
|
96
|
+
create table strict_t2 (id integer primary key);
|
|
97
|
+
-- run
|
|
98
|
+
begin;
|
|
99
|
+
-- run
|
|
100
|
+
drop table strict_t2;
|
|
101
|
+
-- error: ddl_transaction_policy = strict
|
|
102
|
+
rollback;
|
|
103
|
+
-- run
|
|
104
|
+
drop table strict_t2;
|
|
105
|
+
-- run
|
|
106
|
+
|
|
107
|
+
-- ===================================
|
|
108
|
+
-- 6. strict: create table is refused inside begin
|
|
109
|
+
-- ===================================
|
|
110
|
+
|
|
111
|
+
begin;
|
|
112
|
+
-- run
|
|
113
|
+
create table strict_t2 (id integer primary key);
|
|
114
|
+
-- error: ddl_transaction_policy = strict
|
|
115
|
+
rollback;
|
|
116
|
+
-- run
|
|
117
|
+
|
|
118
|
+
-- The refused create table left nothing behind; base data intact.
|
|
119
|
+
select count(*) as cnt from strict_t;
|
|
120
|
+
→ [{ "cnt": 3 }]
|
|
121
|
+
|
|
122
|
+
-- ===================================
|
|
123
|
+
-- 6b. strict: a refusal inside a savepoint leaves the savepoint usable
|
|
124
|
+
-- ===================================
|
|
125
|
+
|
|
126
|
+
create table sp_t (id integer primary key, v text);
|
|
127
|
+
-- run
|
|
128
|
+
insert into sp_t values (1, 'a');
|
|
129
|
+
-- run
|
|
130
|
+
begin;
|
|
131
|
+
-- run
|
|
132
|
+
savepoint sp1;
|
|
133
|
+
-- run
|
|
134
|
+
insert into sp_t values (2, 'b');
|
|
135
|
+
-- run
|
|
136
|
+
create table sp_t2 (id integer primary key);
|
|
137
|
+
-- error: ddl_transaction_policy = strict
|
|
138
|
+
|
|
139
|
+
-- The savepoint is still usable: roll back to it (undoing row 2), continue, commit.
|
|
140
|
+
rollback to savepoint sp1;
|
|
141
|
+
-- run
|
|
142
|
+
insert into sp_t values (3, 'c');
|
|
143
|
+
-- run
|
|
144
|
+
commit;
|
|
145
|
+
-- run
|
|
146
|
+
|
|
147
|
+
select id from sp_t order by id;
|
|
148
|
+
→ [{ "id": 1 }, { "id": 3 }]
|
|
149
|
+
|
|
150
|
+
drop table sp_t;
|
|
151
|
+
-- run
|
|
152
|
+
|
|
153
|
+
-- ===================================
|
|
154
|
+
-- 6c. strict: create materialized view is refused inside begin
|
|
155
|
+
-- ===================================
|
|
156
|
+
|
|
157
|
+
begin;
|
|
158
|
+
-- run
|
|
159
|
+
create materialized view strict_mv as select id, v from strict_t;
|
|
160
|
+
-- error: ddl_transaction_policy = strict
|
|
161
|
+
|
|
162
|
+
-- The refusal left the transaction open and usable.
|
|
163
|
+
insert into strict_t values (4, 'd');
|
|
164
|
+
-- run
|
|
165
|
+
commit;
|
|
166
|
+
-- run
|
|
167
|
+
|
|
168
|
+
select count(*) as cnt from strict_t;
|
|
169
|
+
→ [{ "cnt": 4 }]
|
|
170
|
+
|
|
171
|
+
-- Nothing was materialized.
|
|
172
|
+
drop materialized view strict_mv;
|
|
173
|
+
-- error: no such materialized view
|
|
174
|
+
|
|
175
|
+
-- A no-op `if exists` drop has no target to resolve, so the gate never fires.
|
|
176
|
+
begin;
|
|
177
|
+
-- run
|
|
178
|
+
drop materialized view if exists strict_mv;
|
|
179
|
+
-- run
|
|
180
|
+
rollback;
|
|
181
|
+
-- run
|
|
182
|
+
|
|
183
|
+
-- ===================================
|
|
184
|
+
-- 6d. strict: the same create is allowed OUTSIDE a transaction (autocommit)
|
|
185
|
+
-- ===================================
|
|
186
|
+
|
|
187
|
+
create materialized view strict_mv as select id, v from strict_t;
|
|
188
|
+
-- run
|
|
189
|
+
|
|
190
|
+
select count(*) as cnt from strict_mv;
|
|
191
|
+
→ [{ "cnt": 4 }]
|
|
192
|
+
|
|
193
|
+
-- `if not exists` does NOT skip the gate: like CREATE TABLE, the gate keys off the
|
|
194
|
+
-- statement, not off whether it would have been a no-op. (DROP differs by design —
|
|
195
|
+
-- it has no target to resolve a module from; see the `if exists` case in 6c.)
|
|
196
|
+
begin;
|
|
197
|
+
-- run
|
|
198
|
+
create materialized view if not exists strict_mv as select id, v from strict_t;
|
|
199
|
+
-- error: ddl_transaction_policy = strict
|
|
200
|
+
rollback;
|
|
201
|
+
-- run
|
|
202
|
+
|
|
203
|
+
-- ===================================
|
|
204
|
+
-- 6e. strict: refresh / drop materialized view are refused inside begin
|
|
205
|
+
-- (REFRESH is gated too — its reshape arm dispatches module alterTable and
|
|
206
|
+
-- both arms commit contents mid-transaction; see materialized-view.ts)
|
|
207
|
+
-- ===================================
|
|
208
|
+
|
|
209
|
+
begin;
|
|
210
|
+
-- run
|
|
211
|
+
refresh materialized view strict_mv;
|
|
212
|
+
-- error: ddl_transaction_policy = strict
|
|
213
|
+
|
|
214
|
+
-- A refusal inside a savepoint leaves the savepoint usable (6b, for the MV verbs).
|
|
215
|
+
savepoint mv_sp;
|
|
216
|
+
-- run
|
|
217
|
+
insert into strict_t values (5, 'e');
|
|
218
|
+
-- run
|
|
219
|
+
drop materialized view strict_mv;
|
|
220
|
+
-- error: ddl_transaction_policy = strict
|
|
221
|
+
rollback to savepoint mv_sp;
|
|
222
|
+
-- run
|
|
223
|
+
rollback;
|
|
224
|
+
-- run
|
|
225
|
+
|
|
226
|
+
-- Both refusals left the MV intact and readable.
|
|
227
|
+
select count(*) as cnt from strict_mv;
|
|
228
|
+
→ [{ "cnt": 4 }]
|
|
229
|
+
|
|
230
|
+
-- Outside a transaction both succeed.
|
|
231
|
+
refresh materialized view strict_mv;
|
|
232
|
+
-- run
|
|
233
|
+
drop materialized view strict_mv;
|
|
234
|
+
-- run
|
|
235
|
+
|
|
236
|
+
-- ===================================
|
|
237
|
+
-- 7. Reset to permissive; DDL inside a transaction works again
|
|
238
|
+
-- ===================================
|
|
239
|
+
|
|
240
|
+
pragma ddl_transaction_policy = 'permissive';
|
|
241
|
+
-- run
|
|
242
|
+
|
|
243
|
+
begin;
|
|
244
|
+
-- run
|
|
245
|
+
create table perm_again (id integer primary key);
|
|
246
|
+
-- run
|
|
247
|
+
commit;
|
|
248
|
+
-- run
|
|
249
|
+
|
|
250
|
+
drop table perm_again;
|
|
251
|
+
-- run
|
|
252
|
+
|
|
253
|
+
-- Materialized-view DDL inside a transaction is likewise allowed again.
|
|
254
|
+
begin;
|
|
255
|
+
-- run
|
|
256
|
+
create materialized view perm_mv as select id, v from strict_t;
|
|
257
|
+
-- run
|
|
258
|
+
refresh materialized view perm_mv;
|
|
259
|
+
-- run
|
|
260
|
+
commit;
|
|
261
|
+
-- run
|
|
262
|
+
|
|
263
|
+
select count(*) as cnt from perm_mv;
|
|
264
|
+
→ [{ "cnt": 4 }]
|
|
265
|
+
|
|
266
|
+
begin;
|
|
267
|
+
-- run
|
|
268
|
+
drop materialized view perm_mv;
|
|
269
|
+
-- run
|
|
270
|
+
commit;
|
|
271
|
+
-- run
|
|
272
|
+
|
|
273
|
+
drop table strict_t;
|
|
274
|
+
-- run
|
|
275
|
+
drop table perm_t;
|
|
276
|
+
-- run
|
|
277
|
+
|
|
278
|
+
-- ===================================
|
|
279
|
+
-- 8. strict + `apply schema`: a migration is NOT gated in autocommit (its generated
|
|
280
|
+
-- DDL runs inside the engine's implicit transaction), but the same migration
|
|
281
|
+
-- wrapped in an explicit begin trips the gate on the first gated statement.
|
|
282
|
+
-- Runs last, against an otherwise-empty main schema, so the declaration below is
|
|
283
|
+
-- the whole of main and the diff generates no drops.
|
|
284
|
+
-- ===================================
|
|
285
|
+
|
|
286
|
+
pragma ddl_transaction_policy = 'strict';
|
|
287
|
+
-- run
|
|
288
|
+
|
|
289
|
+
declare schema main {
|
|
290
|
+
table ap_t (id INTEGER PRIMARY KEY, x INTEGER NOT NULL)
|
|
291
|
+
materialized view ap_mv as select id, x from ap_t
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
-- run
|
|
295
|
+
|
|
296
|
+
apply schema main;
|
|
297
|
+
|
|
298
|
+
-- run
|
|
299
|
+
|
|
300
|
+
insert into ap_t values (1, 10);
|
|
301
|
+
-- run
|
|
302
|
+
|
|
303
|
+
select x from ap_mv;
|
|
304
|
+
→ [{ "x": 10 }]
|
|
305
|
+
|
|
306
|
+
-- Dropping only the MV leaves one statement in the next migration: its re-create.
|
|
307
|
+
drop materialized view ap_mv;
|
|
308
|
+
-- run
|
|
309
|
+
begin;
|
|
310
|
+
-- run
|
|
311
|
+
apply schema main;
|
|
312
|
+
-- error: ddl_transaction_policy = strict
|
|
313
|
+
rollback;
|
|
314
|
+
-- run
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
-- ALTER-path minted constraint-name disambiguation.
|
|
2
|
+
--
|
|
3
|
+
-- The ALTER counterpart of 10.1.4 (which covers the CREATE TABLE mints). A
|
|
4
|
+
-- constraint the user does not name gets an invented name, and that name is the
|
|
5
|
+
-- handle `ALTER TABLE … DROP CONSTRAINT <name>` addresses — so it has to address
|
|
6
|
+
-- exactly ONE constraint. Every ALTER spelling that mints a name therefore
|
|
7
|
+
-- disambiguates against the names already on the table:
|
|
8
|
+
--
|
|
9
|
+
-- * `ADD FOREIGN KEY (...)` → `_fk_<table>_<cols>`, `_<N>` suffix on collision
|
|
10
|
+
-- * `ADD COLUMN … references …` → same mint, same suffix
|
|
11
|
+
-- * `ADD CHECK (...)` → `check_<n>`, n bumped upward until free
|
|
12
|
+
--
|
|
13
|
+
-- `check_<n>` bumps its INDEX rather than taking a `_<N>` suffix (which would read
|
|
14
|
+
-- `check_1_2`); n starts at the number of CHECKs already on the table, which is
|
|
15
|
+
-- the historical spelling, so every non-colliding name is byte-identical to what
|
|
16
|
+
-- the engine minted before (§5 pins that).
|
|
17
|
+
--
|
|
18
|
+
-- A constraint the USER names and that collides keeps being refused (§6) — that is
|
|
19
|
+
-- identity, not a mint.
|
|
20
|
+
--
|
|
21
|
+
-- No `-- requires-capability:` directive, so this runs under both the memory
|
|
22
|
+
-- module and the store module. The store leg matters: disambiguated names are
|
|
23
|
+
-- persisted and must survive a reopen.
|
|
24
|
+
|
|
25
|
+
pragma foreign_keys = true;
|
|
26
|
+
|
|
27
|
+
-- ===================================================================
|
|
28
|
+
-- 1. `ALTER TABLE … ADD FOREIGN KEY` onto a column that already carries an
|
|
29
|
+
-- unnamed FK: minted `_fk_AmC_x_2`, each key addressable and each dropping
|
|
30
|
+
-- only itself. (Before the fix both were `_fk_AmC_x`, so one DROP silently
|
|
31
|
+
-- removed both and the orphan insert below was accepted.)
|
|
32
|
+
-- ===================================================================
|
|
33
|
+
|
|
34
|
+
create table AmP1 (x integer primary key);
|
|
35
|
+
create table AmP2 (y integer primary key);
|
|
36
|
+
create table AmC (id integer primary key, x integer null references AmP1(x));
|
|
37
|
+
|
|
38
|
+
select name from foreign_key_info('AmC') order by name;
|
|
39
|
+
→ [{"name":"_fk_AmC_x"}]
|
|
40
|
+
|
|
41
|
+
alter table AmC add foreign key (x) references AmP2(y);
|
|
42
|
+
select name, "to" from foreign_key_info('AmC') order by name;
|
|
43
|
+
→ [{"name":"_fk_AmC_x","to":"x"},{"name":"_fk_AmC_x_2","to":"y"}]
|
|
44
|
+
|
|
45
|
+
-- Both keys enforce, each under its own name (FK existence checks share the
|
|
46
|
+
-- `CHECK constraint failed:` prefix — see runtime/row-constraints.ts).
|
|
47
|
+
-- A value present in AmP1 but not AmP2 trips only the ALTER-added key…
|
|
48
|
+
insert into AmP1 values (1);
|
|
49
|
+
insert into AmC values (1, 1);
|
|
50
|
+
-- error: CHECK constraint failed: _fk_AmC_x_2
|
|
51
|
+
|
|
52
|
+
-- …a value present in AmP2 but not AmP1 trips only the CREATE-time key…
|
|
53
|
+
insert into AmP2 values (2);
|
|
54
|
+
insert into AmC values (1, 2);
|
|
55
|
+
-- error: CHECK constraint failed: _fk_AmC_x
|
|
56
|
+
|
|
57
|
+
-- …and a value present in both parents is accepted.
|
|
58
|
+
insert into AmP1 values (7);
|
|
59
|
+
insert into AmP2 values (7);
|
|
60
|
+
insert into AmC values (1, 7);
|
|
61
|
+
select count(*) as c from AmC;
|
|
62
|
+
→ [{"c":1}]
|
|
63
|
+
|
|
64
|
+
-- Dropping the CREATE-time key removes ONLY it.
|
|
65
|
+
alter table AmC drop constraint _fk_AmC_x;
|
|
66
|
+
select name from foreign_key_info('AmC');
|
|
67
|
+
→ [{"name":"_fk_AmC_x_2"}]
|
|
68
|
+
|
|
69
|
+
-- The ALTER-added key still enforces (1 ∉ AmP2) — the enforcement half of the
|
|
70
|
+
-- defect, which a name-only assertion would miss.
|
|
71
|
+
insert into AmC values (2, 1);
|
|
72
|
+
-- error: CHECK constraint failed: _fk_AmC_x_2
|
|
73
|
+
|
|
74
|
+
-- …while a value only AmP2 holds is now accepted (the dropped key no longer binds).
|
|
75
|
+
insert into AmP2 values (9);
|
|
76
|
+
insert into AmC values (3, 9);
|
|
77
|
+
select count(*) as c from AmC;
|
|
78
|
+
→ [{"c":2}]
|
|
79
|
+
|
|
80
|
+
-- And the survivor is itself addressable by its disambiguated name.
|
|
81
|
+
alter table AmC drop constraint _fk_AmC_x_2;
|
|
82
|
+
select count(*) as c from foreign_key_info('AmC');
|
|
83
|
+
→ [{"c":0}]
|
|
84
|
+
insert into AmC values (4, 12345);
|
|
85
|
+
select count(*) as c from AmC;
|
|
86
|
+
→ [{"c":3}]
|
|
87
|
+
|
|
88
|
+
-- ===================================================================
|
|
89
|
+
-- 2. `ALTER TABLE … ADD COLUMN … references …`: two inline FKs on ONE new
|
|
90
|
+
-- column mint `_fk_AcC_x` / `_fk_AcC_x_2`, exactly as the CREATE TABLE
|
|
91
|
+
-- spelling of the same declaration does.
|
|
92
|
+
-- ===================================================================
|
|
93
|
+
|
|
94
|
+
create table AcP1 (x integer primary key);
|
|
95
|
+
create table AcP2 (y integer primary key);
|
|
96
|
+
create table AcC (id integer primary key);
|
|
97
|
+
|
|
98
|
+
alter table AcC add column x integer null references AcP1(x) references AcP2(y);
|
|
99
|
+
select name, "to" from foreign_key_info('AcC') order by name;
|
|
100
|
+
→ [{"name":"_fk_AcC_x","to":"x"},{"name":"_fk_AcC_x_2","to":"y"}]
|
|
101
|
+
|
|
102
|
+
insert into AcP1 values (3);
|
|
103
|
+
insert into AcC values (1, 3);
|
|
104
|
+
-- error: CHECK constraint failed: _fk_AcC_x_2
|
|
105
|
+
|
|
106
|
+
alter table AcC drop constraint _fk_AcC_x_2;
|
|
107
|
+
insert into AcC values (1, 3);
|
|
108
|
+
select count(*) as c from AcC;
|
|
109
|
+
→ [{"c":1}]
|
|
110
|
+
|
|
111
|
+
-- ===================================================================
|
|
112
|
+
-- 3. ADD COLUMN revert drops by the name the module actually stored.
|
|
113
|
+
--
|
|
114
|
+
-- The engine pre-builds each inline FK (to reject a collation conflict before
|
|
115
|
+
-- the module call) and remembers that FK's name as the one to hand back if a
|
|
116
|
+
-- LATER inline constraint fails. If the engine's mint and the module's mint
|
|
117
|
+
-- disambiguated against different sets, the revert would drop a name that was
|
|
118
|
+
-- never installed and strand the real constraint on a column that is about to
|
|
119
|
+
-- disappear — under a DISAMBIGUATED name, which is exactly the case this file
|
|
120
|
+
-- creates. Here the first inline FK installs and the second is rejected, so the
|
|
121
|
+
-- whole ALTER must leave the table exactly as it was.
|
|
122
|
+
--
|
|
123
|
+
-- The rejection trigger is a child/parent COLLATION conflict rather than an
|
|
124
|
+
-- existing-row FK orphan, because the collation check is engine-side and
|
|
125
|
+
-- unconditional, so this case runs identically on every backend. (The orphan
|
|
126
|
+
-- trigger does not fire on the Lamina backend, which replays this corpus —
|
|
127
|
+
-- tracked in that repo as `bug-add-constraint-admits-orphan-rows`.) The first
|
|
128
|
+
-- FK's parent column has a DEFAULTED binary collation, which is the engine
|
|
129
|
+
-- floor and resolves against the child's declared NOCASE; the second FK's
|
|
130
|
+
-- parent DECLARES binary, and two declarations at the same rank conflict.
|
|
131
|
+
-- ===================================================================
|
|
132
|
+
|
|
133
|
+
create table RvP1 (id integer primary key, x text unique);
|
|
134
|
+
create table RvP2 (id integer primary key, y text collate binary unique);
|
|
135
|
+
create table RvC (id integer primary key);
|
|
136
|
+
insert into RvC values (1);
|
|
137
|
+
|
|
138
|
+
alter table RvC add column x text null collate nocase references RvP1(x) references RvP2(y);
|
|
139
|
+
-- error: conflicting collations
|
|
140
|
+
|
|
141
|
+
-- Column gone, both keys gone — nothing stranded.
|
|
142
|
+
select count(*) as c from table_info('RvC');
|
|
143
|
+
→ [{"c":1}]
|
|
144
|
+
select count(*) as c from foreign_key_info('RvC');
|
|
145
|
+
→ [{"c":0}]
|
|
146
|
+
|
|
147
|
+
-- ===================================================================
|
|
148
|
+
-- 4. `ALTER TABLE … ADD CHECK (...)`: a drop shrinks the CHECK count, so the
|
|
149
|
+
-- next unnamed add would re-mint a LIVE `check_<n>`. The index is bumped
|
|
150
|
+
-- past it instead. (Before the fix the third add below re-minted `check_1`,
|
|
151
|
+
-- and `alter table Ckm drop constraint check_1` then switched off BOTH the
|
|
152
|
+
-- `a < 100` rule and the `a <> 7` rule.)
|
|
153
|
+
-- ===================================================================
|
|
154
|
+
|
|
155
|
+
create table Ckm (id integer primary key, a integer null);
|
|
156
|
+
|
|
157
|
+
alter table Ckm add check (a > 0);
|
|
158
|
+
alter table Ckm add check (a < 100);
|
|
159
|
+
select name from check_constraint_info('Ckm') order by name;
|
|
160
|
+
→ [{"name":"check_0"},{"name":"check_1"}]
|
|
161
|
+
|
|
162
|
+
alter table Ckm drop constraint check_0;
|
|
163
|
+
alter table Ckm add check (a <> 7);
|
|
164
|
+
select name from check_constraint_info('Ckm') order by name;
|
|
165
|
+
→ [{"name":"check_1"},{"name":"check_2"}]
|
|
166
|
+
|
|
167
|
+
-- Both survivors enforce, each under its own name.
|
|
168
|
+
insert into Ckm values (1, 200);
|
|
169
|
+
-- error: check_1
|
|
170
|
+
|
|
171
|
+
insert into Ckm values (2, 7);
|
|
172
|
+
-- error: check_2
|
|
173
|
+
|
|
174
|
+
-- The dropped lower bound no longer binds.
|
|
175
|
+
insert into Ckm values (3, -1);
|
|
176
|
+
select count(*) as c from Ckm;
|
|
177
|
+
→ [{"c":1}]
|
|
178
|
+
|
|
179
|
+
-- Dropping `check_1` releases ONLY the upper bound; `check_2` still rejects 7.
|
|
180
|
+
alter table Ckm drop constraint check_1;
|
|
181
|
+
insert into Ckm values (4, 200);
|
|
182
|
+
select count(*) as c from Ckm;
|
|
183
|
+
→ [{"c":2}]
|
|
184
|
+
|
|
185
|
+
insert into Ckm values (5, 7);
|
|
186
|
+
-- error: check_2
|
|
187
|
+
|
|
188
|
+
-- ===================================================================
|
|
189
|
+
-- 5. Non-colliding mints are unchanged (pins the compatibility property).
|
|
190
|
+
--
|
|
191
|
+
-- The index is seeded from the CHECK COUNT, not from the lowest free index,
|
|
192
|
+
-- so a table whose existing CHECK is user-named still mints `check_1` for the
|
|
193
|
+
-- first unnamed add — byte-identical to the historical spelling, even though
|
|
194
|
+
-- `check_0` happens to be free.
|
|
195
|
+
-- ===================================================================
|
|
196
|
+
|
|
197
|
+
create table CkU (id integer primary key, a integer null, constraint ck_user check (a > -100));
|
|
198
|
+
alter table CkU add check (a > 0);
|
|
199
|
+
select name from check_constraint_info('CkU') order by name;
|
|
200
|
+
→ [{"name":"check_1"},{"name":"ck_user"}]
|
|
201
|
+
|
|
202
|
+
-- A lone ALTER-added FK onto a table with no constraint of that name keeps the
|
|
203
|
+
-- bare mint.
|
|
204
|
+
create table SoloP (x integer primary key);
|
|
205
|
+
create table SoloC (id integer primary key, x integer null);
|
|
206
|
+
alter table SoloC add foreign key (x) references SoloP(x);
|
|
207
|
+
select name from foreign_key_info('SoloC');
|
|
208
|
+
→ [{"name":"_fk_SoloC_x"}]
|
|
209
|
+
|
|
210
|
+
-- ===================================================================
|
|
211
|
+
-- 6. A name the USER writes is identity, not a mint: a collision is still
|
|
212
|
+
-- refused rather than disambiguated.
|
|
213
|
+
-- ===================================================================
|
|
214
|
+
|
|
215
|
+
alter table CkU add constraint ck_user check (a < 5);
|
|
216
|
+
-- error: already exists
|
|
217
|
+
|
|
218
|
+
select count(*) as c from check_constraint_info('CkU');
|
|
219
|
+
→ [{"c":2}]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
-- 10.1.5-create-index-lifecycle.sqllogic — CREATE INDEX lifecycle and DDL error paths.
|
|
2
|
+
--
|
|
3
|
+
-- requires-capability: standalone-index-ddl
|
|
4
|
+
--
|
|
5
|
+
-- Carved out of 10.1-ddl-lifecycle: that file's subject is the generic DDL lifecycle
|
|
6
|
+
-- (create → insert → verify → drop, IF NOT EXISTS / IF EXISTS, ALTER, schema-vs-
|
|
7
|
+
-- transaction interaction, multi-table sequences) and its remaining error cases are
|
|
8
|
+
-- all table-shaped. Only these sections need standalone index DDL, so they move here.
|
|
9
|
+
--
|
|
10
|
+
-- Subject: creating, re-creating (IF NOT EXISTS), listing and dropping indexes, plus
|
|
11
|
+
-- the DDL rejections — unknown table, unknown column, duplicate index name.
|
|
12
|
+
|
|
13
|
+
-- ===================================
|
|
14
|
+
-- 1. CREATE INDEX Lifecycle
|
|
15
|
+
-- ===================================
|
|
16
|
+
|
|
17
|
+
create table idx_lifecycle (id integer primary key, name text, score integer);
|
|
18
|
+
|
|
19
|
+
insert into idx_lifecycle values
|
|
20
|
+
(1, 'Alice', 90),
|
|
21
|
+
(2, 'Bob', 80),
|
|
22
|
+
(3, 'Charlie', 95);
|
|
23
|
+
|
|
24
|
+
-- Create an index
|
|
25
|
+
create index idx_lc_score on idx_lifecycle (score);
|
|
26
|
+
|
|
27
|
+
-- Queries should still work with the index present
|
|
28
|
+
select name from idx_lifecycle where score > 85 order by name;
|
|
29
|
+
→ [{"name": "Alice"}, {"name": "Charlie"}]
|
|
30
|
+
|
|
31
|
+
-- CREATE INDEX IF NOT EXISTS on existing index is a no-op
|
|
32
|
+
create index if not exists idx_lc_score on idx_lifecycle (score);
|
|
33
|
+
|
|
34
|
+
-- Create a second index on a different column
|
|
35
|
+
create index idx_lc_name on idx_lifecycle (name);
|
|
36
|
+
|
|
37
|
+
select name from idx_lifecycle where name = 'Bob';
|
|
38
|
+
→ [{"name": "Bob"}]
|
|
39
|
+
|
|
40
|
+
-- Verify indexes are visible in schema()
|
|
41
|
+
select name from schema() where type = 'index' and tbl_name = 'idx_lifecycle' order by name;
|
|
42
|
+
→ [{"name": "idx_lc_name"}, {"name": "idx_lc_score"}]
|
|
43
|
+
|
|
44
|
+
-- Clean up
|
|
45
|
+
drop table idx_lifecycle;
|
|
46
|
+
|
|
47
|
+
-- ===================================
|
|
48
|
+
-- 2. CREATE INDEX error cases
|
|
49
|
+
-- ===================================
|
|
50
|
+
-- (the table-shaped rejections — unknown table, duplicate column name, dropping a
|
|
51
|
+
-- missing table — stay in 10.1-ddl-lifecycle § 5)
|
|
52
|
+
|
|
53
|
+
-- 2a. CREATE INDEX on non-existent table
|
|
54
|
+
create index idx_bad on no_such_table (col);
|
|
55
|
+
-- error: no such table
|
|
56
|
+
|
|
57
|
+
-- 2b. CREATE INDEX on non-existent column
|
|
58
|
+
create table idx_err (id integer primary key, name text);
|
|
59
|
+
|
|
60
|
+
create index idx_bad_col on idx_err (missing_col);
|
|
61
|
+
-- error: not found
|
|
62
|
+
|
|
63
|
+
drop table idx_err;
|
|
64
|
+
|
|
65
|
+
-- 2c. Duplicate index name without IF NOT EXISTS
|
|
66
|
+
create table idx_dup_test (id integer primary key, val integer);
|
|
67
|
+
create index idx_dup on idx_dup_test (val);
|
|
68
|
+
|
|
69
|
+
create index idx_dup on idx_dup_test (val);
|
|
70
|
+
-- error: already exists
|
|
71
|
+
|
|
72
|
+
drop table idx_dup_test;
|