@quereus/quereus 4.20.1 → 4.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- 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 +173 -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,683 @@
|
|
|
1
|
+
-- adapted from SQLite test/check.test
|
|
2
|
+
-- CHECK constraint scenarios beyond 40-constraints.sqllogic and
|
|
3
|
+
-- 29-constraint-edge-cases.sqllogic.
|
|
4
|
+
|
|
5
|
+
-- ===================================
|
|
6
|
+
-- 1. CHECK with typeof() / function-driven type integrity
|
|
7
|
+
-- ===================================
|
|
8
|
+
|
|
9
|
+
create table t_typ (
|
|
10
|
+
id integer primary key,
|
|
11
|
+
x any,
|
|
12
|
+
check (typeof(x) in ('integer', 'real'))
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
insert into t_typ values (1, 10);
|
|
16
|
+
|
|
17
|
+
select typeof(x) from t_typ where id = 1;
|
|
18
|
+
→ [{"typeof(x)":"integer"}]
|
|
19
|
+
|
|
20
|
+
-- text fails typeof check
|
|
21
|
+
insert into t_typ values (2, 'abc');
|
|
22
|
+
-- error: CHECK
|
|
23
|
+
|
|
24
|
+
-- real passes
|
|
25
|
+
insert into t_typ values (3, 1.5);
|
|
26
|
+
|
|
27
|
+
select typeof(x) from t_typ where id = 3;
|
|
28
|
+
→ [{"typeof(x)":"real"}]
|
|
29
|
+
|
|
30
|
+
drop table t_typ;
|
|
31
|
+
|
|
32
|
+
-- ===================================
|
|
33
|
+
-- 2. CHECK using CASE / BETWEEN
|
|
34
|
+
-- ===================================
|
|
35
|
+
|
|
36
|
+
create table t_cb (
|
|
37
|
+
id integer primary key,
|
|
38
|
+
kind text,
|
|
39
|
+
amt integer,
|
|
40
|
+
constraint range_by_kind check (
|
|
41
|
+
case kind
|
|
42
|
+
when 'small' then amt between 0 and 9
|
|
43
|
+
when 'big' then amt between 100 and 999
|
|
44
|
+
else amt >= 0
|
|
45
|
+
end
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
insert into t_cb values (1, 'small', 5);
|
|
50
|
+
insert into t_cb values (2, 'big', 500);
|
|
51
|
+
insert into t_cb values (3, 'other', 0);
|
|
52
|
+
|
|
53
|
+
select count(*) as cnt from t_cb;
|
|
54
|
+
→ [{"cnt":3}]
|
|
55
|
+
|
|
56
|
+
insert into t_cb values (4, 'small', 50);
|
|
57
|
+
-- error: range_by_kind
|
|
58
|
+
|
|
59
|
+
insert into t_cb values (5, 'big', 10);
|
|
60
|
+
-- error: range_by_kind
|
|
61
|
+
|
|
62
|
+
drop table t_cb;
|
|
63
|
+
|
|
64
|
+
-- ===================================
|
|
65
|
+
-- 3. CHECK with COLLATE inside the predicate
|
|
66
|
+
-- ===================================
|
|
67
|
+
|
|
68
|
+
create table t_col (
|
|
69
|
+
id integer primary key,
|
|
70
|
+
code text,
|
|
71
|
+
constraint upper_only check (code = code collate nocase and code = upper(code))
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
insert into t_col values (1, 'ABC');
|
|
75
|
+
|
|
76
|
+
select code from t_col;
|
|
77
|
+
→ [{"code":"ABC"}]
|
|
78
|
+
|
|
79
|
+
insert into t_col values (2, 'abc');
|
|
80
|
+
-- error: upper_only
|
|
81
|
+
|
|
82
|
+
drop table t_col;
|
|
83
|
+
|
|
84
|
+
-- ===================================
|
|
85
|
+
-- 4. CHECK enforced on INSERT...SELECT (statement-level rollback)
|
|
86
|
+
-- ===================================
|
|
87
|
+
|
|
88
|
+
create table src (id integer primary key, n integer null);
|
|
89
|
+
insert into src values (1, 1), (2, 2), (3, -1), (4, 4);
|
|
90
|
+
|
|
91
|
+
create table dst (id integer primary key, n integer not null check (n > 0));
|
|
92
|
+
|
|
93
|
+
insert into dst select id, n from src;
|
|
94
|
+
-- error: CHECK
|
|
95
|
+
|
|
96
|
+
-- whole INSERT aborted
|
|
97
|
+
select count(*) as cnt from dst;
|
|
98
|
+
→ [{"cnt":0}]
|
|
99
|
+
|
|
100
|
+
-- after removing the violating source row, full insert succeeds
|
|
101
|
+
delete from src where id = 3;
|
|
102
|
+
|
|
103
|
+
insert into dst select id, n from src;
|
|
104
|
+
|
|
105
|
+
select count(*) as cnt from dst;
|
|
106
|
+
→ [{"cnt":3}]
|
|
107
|
+
|
|
108
|
+
drop table dst;
|
|
109
|
+
drop table src;
|
|
110
|
+
|
|
111
|
+
-- ===================================
|
|
112
|
+
-- 5. Bind parameter inside CHECK rejected at DDL
|
|
113
|
+
-- ===================================
|
|
114
|
+
|
|
115
|
+
create table t_p (a integer not null, check (a = ?));
|
|
116
|
+
-- error: bind parameters
|
|
117
|
+
drop table if exists t_p;
|
|
118
|
+
|
|
119
|
+
create table t_p2 (a integer not null, check (a = :foo));
|
|
120
|
+
-- error: bind parameters
|
|
121
|
+
drop table if exists t_p2;
|
|
122
|
+
|
|
123
|
+
-- ===================================
|
|
124
|
+
-- 6. Prefix NOT against a subquery predicate inside CHECK (direct DDL path).
|
|
125
|
+
-- Regression for github.com/gotchoices/quereus/issues/22 — proves the parser
|
|
126
|
+
-- fix lands independent of the declare/apply round-trip.
|
|
127
|
+
-- ===================================
|
|
128
|
+
|
|
129
|
+
create table Block (Code text primary key) using memory;
|
|
130
|
+
insert into Block values ('r'), ('y');
|
|
131
|
+
create table T (Id int, Color text, primary key (Id),
|
|
132
|
+
constraint NB check (not Color in (select Code from Block))) using memory;
|
|
133
|
+
insert into T (Id, Color) values (1, 'g');
|
|
134
|
+
insert into T (Id, Color) values (2, 'r');
|
|
135
|
+
-- error: CHECK constraint failed: NB
|
|
136
|
+
drop table T;
|
|
137
|
+
drop table Block;
|
|
138
|
+
|
|
139
|
+
-- ===================================
|
|
140
|
+
-- 7. Bind parameters / non-determinism hidden in later legs of a compound
|
|
141
|
+
-- subquery inside a CHECK must still be detected at DDL.
|
|
142
|
+
-- Regression for ast-visitor-compound-select-traversal.
|
|
143
|
+
-- ===================================
|
|
144
|
+
|
|
145
|
+
create table t_compound_param (x integer not null, check (x in (select 1 union all select :p)));
|
|
146
|
+
-- error: bind parameters
|
|
147
|
+
drop table if exists t_compound_param;
|
|
148
|
+
|
|
149
|
+
create table t_compound_nd (x integer not null, check (x in (select 1 union all select random())));
|
|
150
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
151
|
+
drop table if exists t_compound_nd;
|
|
152
|
+
|
|
153
|
+
-- DEFAULT-side: bind parameter hidden in the second leg of a compound subquery.
|
|
154
|
+
create table t_compound_default (
|
|
155
|
+
id integer primary key,
|
|
156
|
+
v integer default (coalesce((select 1 union all select :p limit 1), 0))
|
|
157
|
+
);
|
|
158
|
+
-- error: bind parameters
|
|
159
|
+
drop table if exists t_compound_default;
|
|
160
|
+
|
|
161
|
+
-- Generated-column dependency: column ref hidden in the second leg of a compound
|
|
162
|
+
-- subquery must still register as a dependency for the topo sort. Here `g`
|
|
163
|
+
-- depends on `b` only via the later leg; the engine must not silently miss it.
|
|
164
|
+
create table t_compound_gen (
|
|
165
|
+
a integer not null,
|
|
166
|
+
b integer not null,
|
|
167
|
+
g integer generated always as ((select a union all select b limit 1)) virtual
|
|
168
|
+
);
|
|
169
|
+
insert into t_compound_gen (a, b) values (1, 2);
|
|
170
|
+
select g from t_compound_gen;
|
|
171
|
+
→ [{"g":1}]
|
|
172
|
+
drop table t_compound_gen;
|
|
173
|
+
|
|
174
|
+
-- ===================================
|
|
175
|
+
-- 8. Deferred subquery CHECK reads the transaction's OWN writes, not a
|
|
176
|
+
-- snapshot frozen at row-write time. Regression for
|
|
177
|
+
-- bug-deferred-subquery-check-reads-stale-state: `x in (select …)` builds as
|
|
178
|
+
-- an InNode, which the old subquery test (a list of specific scalar node
|
|
179
|
+
-- types, since replaced by the structural hasRelationalDescendant) did not
|
|
180
|
+
-- recognize as subquery-bearing, so the check ran immediately like an
|
|
181
|
+
-- ordinary CHECK instead of deferring to COMMIT.
|
|
182
|
+
-- ===================================
|
|
183
|
+
|
|
184
|
+
-- read-your-own-writes: the value the check needs arrives LATER in the same
|
|
185
|
+
-- transaction. Immediate (buggy) evaluation would reject this at the INSERT
|
|
186
|
+
-- into zt, before zl has the row.
|
|
187
|
+
create table zl (code text primary key);
|
|
188
|
+
create table zt (id integer primary key, code text,
|
|
189
|
+
constraint zt_ck check (code in (select code from zl)));
|
|
190
|
+
|
|
191
|
+
begin;
|
|
192
|
+
insert into zt values (1, 'a');
|
|
193
|
+
insert into zl values ('a');
|
|
194
|
+
commit;
|
|
195
|
+
|
|
196
|
+
select id, code from zt;
|
|
197
|
+
→ [{"id":1,"code":"a"}]
|
|
198
|
+
|
|
199
|
+
drop table zt;
|
|
200
|
+
drop table zl;
|
|
201
|
+
|
|
202
|
+
-- the reverse: the value the check needs is REMOVED later in the same
|
|
203
|
+
-- transaction. Immediate (buggy) evaluation would pass at the INSERT and
|
|
204
|
+
-- never re-check after the delete; a genuinely deferred check catches it at
|
|
205
|
+
-- COMMIT.
|
|
206
|
+
create table zl2 (code text primary key);
|
|
207
|
+
insert into zl2 values ('a');
|
|
208
|
+
create table zt2 (id integer primary key, code text,
|
|
209
|
+
constraint zt2_ck check (code in (select code from zl2)));
|
|
210
|
+
|
|
211
|
+
begin;
|
|
212
|
+
insert into zt2 values (1, 'a');
|
|
213
|
+
delete from zl2 where code = 'a';
|
|
214
|
+
commit;
|
|
215
|
+
-- the full message is asserted, not merely "CHECK": a deferred violation must be
|
|
216
|
+
-- attributed exactly like an immediate one (name + expression hint), which is only
|
|
217
|
+
-- true because the queued evaluator throws its own message rather than falling
|
|
218
|
+
-- through to DeferredConstraintQueue's generic name-only fallback.
|
|
219
|
+
-- error: CHECK constraint failed: zt2_ck (code in (select code from zl2))
|
|
220
|
+
|
|
221
|
+
select count(*) as cnt from zt2;
|
|
222
|
+
→ [{"cnt":0}]
|
|
223
|
+
|
|
224
|
+
drop table zt2;
|
|
225
|
+
drop table zl2;
|
|
226
|
+
|
|
227
|
+
-- negative control: a plain value-list `in (...)` has no relational child and
|
|
228
|
+
-- must stay immediate — it still fails INSIDE the open transaction, at the
|
|
229
|
+
-- INSERT itself, not deferred to COMMIT.
|
|
230
|
+
create table zt3 (id integer primary key, code text,
|
|
231
|
+
constraint zt3_ck check (code in ('a', 'b')));
|
|
232
|
+
|
|
233
|
+
begin;
|
|
234
|
+
insert into zt3 values (1, 'z');
|
|
235
|
+
-- the immediate half of the parity assertion above: same message shape, produced
|
|
236
|
+
-- by the row-time path.
|
|
237
|
+
-- error: CHECK constraint failed: zt3_ck (code in ('a', 'b'))
|
|
238
|
+
rollback;
|
|
239
|
+
|
|
240
|
+
select count(*) as cnt from zt3;
|
|
241
|
+
→ [{"cnt":0}]
|
|
242
|
+
|
|
243
|
+
drop table zt3;
|
|
244
|
+
|
|
245
|
+
-- ===================================
|
|
246
|
+
-- Table-qualified self-references in CHECK expressions
|
|
247
|
+
-- `t.col` (or `schema.t.col`) on the owning table resolves like the
|
|
248
|
+
-- unqualified column: NEW for INSERT/UPDATE, OLD for DELETE. Regression for
|
|
249
|
+
-- the qualified form being accepted at DDL time but failing to resolve at
|
|
250
|
+
-- the first write ("t.qty isn't a column").
|
|
251
|
+
-- ===================================
|
|
252
|
+
|
|
253
|
+
create table t_selfq (
|
|
254
|
+
id integer primary key,
|
|
255
|
+
qty integer,
|
|
256
|
+
constraint chk_qty check (t_selfq.qty > 0)
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
insert into t_selfq values (1, 5);
|
|
260
|
+
|
|
261
|
+
select qty from t_selfq where id = 1;
|
|
262
|
+
→ [{"qty":5}]
|
|
263
|
+
|
|
264
|
+
insert into t_selfq values (2, -1);
|
|
265
|
+
-- error: chk_qty
|
|
266
|
+
|
|
267
|
+
update t_selfq set qty = 7 where id = 1;
|
|
268
|
+
|
|
269
|
+
select qty from t_selfq where id = 1;
|
|
270
|
+
→ [{"qty":7}]
|
|
271
|
+
|
|
272
|
+
update t_selfq set qty = -3 where id = 1;
|
|
273
|
+
-- error: chk_qty
|
|
274
|
+
|
|
275
|
+
drop table t_selfq;
|
|
276
|
+
|
|
277
|
+
-- schema-qualified self-reference
|
|
278
|
+
create table t_selfq_s (
|
|
279
|
+
id integer primary key,
|
|
280
|
+
qty integer,
|
|
281
|
+
check (main.t_selfq_s.qty < 100)
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
insert into t_selfq_s values (1, 50);
|
|
285
|
+
|
|
286
|
+
insert into t_selfq_s values (2, 200);
|
|
287
|
+
-- error: CHECK
|
|
288
|
+
|
|
289
|
+
drop table t_selfq_s;
|
|
290
|
+
|
|
291
|
+
-- DELETE-op check: the qualified self-reference names the OLD row
|
|
292
|
+
create table t_selfq_d (
|
|
293
|
+
id integer primary key,
|
|
294
|
+
qty integer,
|
|
295
|
+
constraint no_del_stock check on delete (t_selfq_d.qty = 0)
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
insert into t_selfq_d values (1, 0);
|
|
299
|
+
insert into t_selfq_d values (2, 9);
|
|
300
|
+
|
|
301
|
+
delete from t_selfq_d where id = 1;
|
|
302
|
+
|
|
303
|
+
delete from t_selfq_d where id = 2;
|
|
304
|
+
-- error: no_del_stock
|
|
305
|
+
|
|
306
|
+
drop table t_selfq_d;
|
|
307
|
+
|
|
308
|
+
-- correlated: the qualified self-reference reaches into a subquery over
|
|
309
|
+
-- ANOTHER table (auto-deferred; the other table has no same-named column,
|
|
310
|
+
-- so the reference still binds to the constraint row)
|
|
311
|
+
create table caps (k integer primary key, cap integer);
|
|
312
|
+
insert into caps values (1, 50);
|
|
313
|
+
|
|
314
|
+
create table t_selfq_c (
|
|
315
|
+
id integer primary key,
|
|
316
|
+
qty integer,
|
|
317
|
+
constraint under_cap check (exists (select 1 from caps where t_selfq_c.qty <= caps.cap))
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
insert into t_selfq_c values (1, 10);
|
|
321
|
+
|
|
322
|
+
select qty from t_selfq_c;
|
|
323
|
+
→ [{"qty":10}]
|
|
324
|
+
|
|
325
|
+
insert into t_selfq_c values (2, 99);
|
|
326
|
+
-- error: under_cap
|
|
327
|
+
|
|
328
|
+
drop table t_selfq_c;
|
|
329
|
+
drop table caps;
|
|
330
|
+
|
|
331
|
+
-- a subquery that REBINDS the owning table's name shadows the qualified
|
|
332
|
+
-- self-reference (normal scoping): the inner `t_selfq_r.qty` is the
|
|
333
|
+
-- subquery's row, so the max-row check accepts equal-to-max and rejects above
|
|
334
|
+
create table t_selfq_r (
|
|
335
|
+
id integer primary key,
|
|
336
|
+
qty integer,
|
|
337
|
+
constraint within_max check (qty <= (select coalesce(max(t_selfq_r.qty), 10) from t_selfq_r))
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
insert into t_selfq_r values (1, 10);
|
|
341
|
+
|
|
342
|
+
select qty from t_selfq_r;
|
|
343
|
+
→ [{"qty":10}]
|
|
344
|
+
|
|
345
|
+
drop table t_selfq_r;
|
|
346
|
+
|
|
347
|
+
-- a subquery over a VIEW that exposes the same name blocks the strip, exactly as a
|
|
348
|
+
-- real table exposing it would: the column-source resolver reads a view's published
|
|
349
|
+
-- columns (explicit list, or the body's projection / star), so the qualified
|
|
350
|
+
-- self-reference is NOT rewritten to a bare name the view would capture. The ref then
|
|
351
|
+
-- stays qualified and fails to resolve at write time — loud, instead of silently
|
|
352
|
+
-- comparing the view's column to itself (what the view-blind resolver used to produce).
|
|
353
|
+
create table t_selfq_vsrc (k integer primary key, n integer);
|
|
354
|
+
create view t_selfq_vw as select n from t_selfq_vsrc;
|
|
355
|
+
insert into t_selfq_vsrc values (1, 10);
|
|
356
|
+
|
|
357
|
+
create table t_selfq_v (
|
|
358
|
+
id integer primary key,
|
|
359
|
+
n integer,
|
|
360
|
+
constraint over_view check ((select count(*) from t_selfq_vw where t_selfq_vw.n > t_selfq_v.n) = 0)
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
insert into t_selfq_v values (1, 50);
|
|
364
|
+
-- error: t_selfq_v.n isn't a column
|
|
365
|
+
|
|
366
|
+
drop table t_selfq_v;
|
|
367
|
+
|
|
368
|
+
-- ...and when the view does NOT expose the name, the strip proceeds and the
|
|
369
|
+
-- self-reference correlates to the constraint row, same as the real-table case above.
|
|
370
|
+
create view t_selfq_vk as select k from t_selfq_vsrc;
|
|
371
|
+
|
|
372
|
+
create table t_selfq_v2 (
|
|
373
|
+
id integer primary key,
|
|
374
|
+
m integer,
|
|
375
|
+
constraint under_view check ((select count(*) from t_selfq_vk where k > t_selfq_v2.m) = 0)
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
insert into t_selfq_v2 values (1, 50);
|
|
379
|
+
|
|
380
|
+
select m from t_selfq_v2;
|
|
381
|
+
→ [{"m":50}]
|
|
382
|
+
|
|
383
|
+
insert into t_selfq_v2 values (2, 0);
|
|
384
|
+
-- error: under_view
|
|
385
|
+
|
|
386
|
+
drop table t_selfq_v2;
|
|
387
|
+
drop view t_selfq_vk;
|
|
388
|
+
drop view t_selfq_vw;
|
|
389
|
+
drop table t_selfq_vsrc;
|
|
390
|
+
|
|
391
|
+
-- ===================================
|
|
392
|
+
-- CHECK comparisons resolve declared column collations, exactly like read-path
|
|
393
|
+
-- queries (and ALTER backfill validation / assertion enforcement, which compile
|
|
394
|
+
-- plain SQL). Ticket check-extraction-collation-blind-fds. Collation resolution
|
|
395
|
+
-- is the symmetric provenance lattice (explicit COLLATE > explicitly-declared
|
|
396
|
+
-- column collation > defaulted collation > BINARY; ticket
|
|
397
|
+
-- comparison-collation-provenance-and-precedence) — so `b = c` and `c = b`
|
|
398
|
+
-- resolve identically: the declared NOCASE outranks b's defaulted BINARY from
|
|
399
|
+
-- either side, matching `select ... where` of the same spelling.
|
|
400
|
+
-- ===================================
|
|
401
|
+
|
|
402
|
+
-- bare col = col, NOCASE declared on one operand: comparison is NOCASE.
|
|
403
|
+
create table chk_coll (id integer primary key, b text, c text collate nocase, check (b = c));
|
|
404
|
+
insert into chk_coll values (1, 'X', 'x');
|
|
405
|
+
insert into chk_coll values (2, 'abc', 'ABC');
|
|
406
|
+
select count(*) as cnt from chk_coll;
|
|
407
|
+
→ [{"cnt":2}]
|
|
408
|
+
-- read path agrees: the same comparison matches both rows.
|
|
409
|
+
select count(*) as cnt from chk_coll where b = c;
|
|
410
|
+
→ [{"cnt":2}]
|
|
411
|
+
insert into chk_coll values (3, 'X', 'y');
|
|
412
|
+
-- error: CHECK
|
|
413
|
+
drop table chk_coll;
|
|
414
|
+
|
|
415
|
+
-- flipped spelling resolves the SAME collation: the declared NOCASE wins over
|
|
416
|
+
-- the plain column's defaulted BINARY regardless of operand order, so the
|
|
417
|
+
-- case-variant pair is accepted, again matching the read path.
|
|
418
|
+
create table chk_coll_flip (id integer primary key, b text, c text collate nocase, check (c = b));
|
|
419
|
+
insert into chk_coll_flip values (1, 'x', 'x');
|
|
420
|
+
insert into chk_coll_flip values (2, 'X', 'x');
|
|
421
|
+
select count(*) as cnt from chk_coll_flip where c = b;
|
|
422
|
+
→ [{"cnt":2}]
|
|
423
|
+
insert into chk_coll_flip values (3, 'X', 'y');
|
|
424
|
+
-- error: CHECK
|
|
425
|
+
drop table chk_coll_flip;
|
|
426
|
+
|
|
427
|
+
-- col = literal: a literal contributes no collation, so the declared NOCASE
|
|
428
|
+
-- drives the comparison from either side.
|
|
429
|
+
create table chk_coll_lit (id integer primary key, c text collate nocase, check (c = 'abc'));
|
|
430
|
+
insert into chk_coll_lit values (1, 'ABC');
|
|
431
|
+
insert into chk_coll_lit values (2, 'aBc');
|
|
432
|
+
select count(*) as cnt from chk_coll_lit;
|
|
433
|
+
→ [{"cnt":2}]
|
|
434
|
+
insert into chk_coll_lit values (3, 'abd');
|
|
435
|
+
-- error: CHECK
|
|
436
|
+
drop table chk_coll_lit;
|
|
437
|
+
|
|
438
|
+
-- an explicit COLLATE BINARY wrapper still overrides the declared collation.
|
|
439
|
+
create table chk_coll_bin (id integer primary key, b text, c text collate nocase, check (b = c collate binary));
|
|
440
|
+
insert into chk_coll_bin values (1, 'x', 'x');
|
|
441
|
+
insert into chk_coll_bin values (2, 'X', 'x');
|
|
442
|
+
-- error: CHECK
|
|
443
|
+
drop table chk_coll_bin;
|
|
444
|
+
|
|
445
|
+
-- wrapper-honored control: an explicit NOCASE wrapper over plain BINARY
|
|
446
|
+
-- columns keeps accepting case-variants (unchanged behavior).
|
|
447
|
+
create table chk_coll_wrap (id integer primary key, b text, c text, check (b = c collate nocase));
|
|
448
|
+
insert into chk_coll_wrap values (1, 'x', 'X');
|
|
449
|
+
insert into chk_coll_wrap values (2, 'x', 'y');
|
|
450
|
+
-- error: CHECK
|
|
451
|
+
drop table chk_coll_wrap;
|
|
452
|
+
|
|
453
|
+
-- UPDATE-path: an OLD reference resolves the same declared collation.
|
|
454
|
+
create table chk_coll_upd (id integer primary key, c text collate nocase, constraint same_code check on update (old.c = c));
|
|
455
|
+
insert into chk_coll_upd values (1, 'ABC');
|
|
456
|
+
update chk_coll_upd set c = 'abc' where id = 1;
|
|
457
|
+
select c from chk_coll_upd;
|
|
458
|
+
→ [{"c":"abc"}]
|
|
459
|
+
update chk_coll_upd set c = 'xyz' where id = 1;
|
|
460
|
+
-- error: same_code
|
|
461
|
+
drop table chk_coll_upd;
|
|
462
|
+
|
|
463
|
+
-- deferred CHECK (auto-deferred by the subquery) resolves the same declared
|
|
464
|
+
-- collation as the immediate path.
|
|
465
|
+
create table chk_coll_def (id integer primary key, c text collate nocase, check (c = (select 'abc')));
|
|
466
|
+
insert into chk_coll_def values (1, 'ABC');
|
|
467
|
+
select c from chk_coll_def;
|
|
468
|
+
→ [{"c":"ABC"}]
|
|
469
|
+
insert into chk_coll_def values (2, 'xyz');
|
|
470
|
+
-- error: CHECK
|
|
471
|
+
drop table chk_coll_def;
|
|
472
|
+
|
|
473
|
+
-- ===================================
|
|
474
|
+
-- Row-invariant gate on CHECK-derived planner facts. Ticket
|
|
475
|
+
-- check-extraction-rowop-mask-transition-checks. A CHECK contributes
|
|
476
|
+
-- FDs/bindings/domains to the optimizer only when its operation mask covers
|
|
477
|
+
-- insert+update and it has no `old.` row-image reference — otherwise rows the
|
|
478
|
+
-- check never enforced can legally violate it, and folding a matching WHERE
|
|
479
|
+
-- to empty returns wrong results.
|
|
480
|
+
-- ===================================
|
|
481
|
+
|
|
482
|
+
-- insert-only check never sees an UPDATE: the stored row may violate it, so
|
|
483
|
+
-- no fact may be minted from it.
|
|
484
|
+
create table t_riv_ins (id integer primary key, status text, check on insert (status = 'a')) using memory;
|
|
485
|
+
insert into t_riv_ins values (1, 'a');
|
|
486
|
+
update t_riv_ins set status = 'b' where id = 1;
|
|
487
|
+
select * from t_riv_ins where status = 'b';
|
|
488
|
+
→ [{"id":1,"status":"b"}]
|
|
489
|
+
drop table t_riv_ins;
|
|
490
|
+
|
|
491
|
+
-- update-only transition check `old.a = b` must not extract as the same-row
|
|
492
|
+
-- equality a = b (it never ran on these inserts at all).
|
|
493
|
+
create table t_riv_upd (id integer primary key, a text, b text unique, check on update (old.a = b)) using memory;
|
|
494
|
+
insert into t_riv_upd values (1, 'x', 'y1'), (2, 'x', 'y2');
|
|
495
|
+
select * from t_riv_upd where a = 'x' order by id;
|
|
496
|
+
→ [{"id":1,"a":"x","b":"y1"},{"id":2,"a":"x","b":"y2"}]
|
|
497
|
+
drop table t_riv_upd;
|
|
498
|
+
|
|
499
|
+
-- old. under the DEFAULT mask: the check runs on insert but passes because
|
|
500
|
+
-- OLD is NULL there — a transition constraint, not a row invariant, so the
|
|
501
|
+
-- mask gate alone is insufficient and the old.-screen must catch it.
|
|
502
|
+
create table t_riv_old (id integer primary key, a text, b text, check (old.a = b)) using memory;
|
|
503
|
+
insert into t_riv_old values (1, 'x', 'y1');
|
|
504
|
+
select * from t_riv_old where a = 'x';
|
|
505
|
+
→ [{"id":1,"a":"x","b":"y1"}]
|
|
506
|
+
drop table t_riv_old;
|
|
507
|
+
|
|
508
|
+
-- delete-only check constrains no stored row at all.
|
|
509
|
+
create table t_riv_del (id integer primary key, v integer, check on delete (v > 0)) using memory;
|
|
510
|
+
insert into t_riv_del values (1, -5);
|
|
511
|
+
select * from t_riv_del where v <= 0;
|
|
512
|
+
→ [{"id":1,"v":-5}]
|
|
513
|
+
drop table t_riv_del;
|
|
514
|
+
|
|
515
|
+
-- control: default-mask check keeps folding contradictions to empty.
|
|
516
|
+
create table t_riv_def (id integer primary key, v integer, check (v > 0)) using memory;
|
|
517
|
+
insert into t_riv_def values (1, 5);
|
|
518
|
+
select * from t_riv_def where v <= 0;
|
|
519
|
+
→ []
|
|
520
|
+
drop table t_riv_def;
|
|
521
|
+
|
|
522
|
+
-- control: explicit insert,update mask qualifies exactly like the default.
|
|
523
|
+
create table t_riv_iu (id integer primary key, v integer, check on insert, update (v > 0)) using memory;
|
|
524
|
+
insert into t_riv_iu values (1, 5);
|
|
525
|
+
select * from t_riv_iu where v <= 0;
|
|
526
|
+
→ []
|
|
527
|
+
drop table t_riv_iu;
|
|
528
|
+
|
|
529
|
+
-- control: new.-qualified check is same-row (NEW is the stored image); its
|
|
530
|
+
-- facts are sound and matching rows are returned correctly.
|
|
531
|
+
create table t_riv_new (id integer primary key, a text, b text, check (new.a = b)) using memory;
|
|
532
|
+
insert into t_riv_new values (1, 'x', 'x');
|
|
533
|
+
select * from t_riv_new where a = 'x';
|
|
534
|
+
→ [{"id":1,"a":"x","b":"x"}]
|
|
535
|
+
drop table t_riv_new;
|
|
536
|
+
|
|
537
|
+
-- control: new.-qualified facts still fold contradictions end-to-end, same as
|
|
538
|
+
-- the bare spelling.
|
|
539
|
+
create table t_riv_newfold (id integer primary key, v integer, check (new.v > 0)) using memory;
|
|
540
|
+
insert into t_riv_newfold values (1, 5);
|
|
541
|
+
select * from t_riv_newfold where v <= 0;
|
|
542
|
+
→ []
|
|
543
|
+
drop table t_riv_newfold;
|
|
544
|
+
|
|
545
|
+
-- ===================================
|
|
546
|
+
-- CHECK truthiness must match the engine-wide isTruthy rule, not a narrower
|
|
547
|
+
-- `result === false || result === 0` test. Integer literals evaluate to
|
|
548
|
+
-- bigint at runtime, and CHECK must reject bigint-zero and the string '0'
|
|
549
|
+
-- exactly like FilterNode / WHERE does.
|
|
550
|
+
-- ===================================
|
|
551
|
+
|
|
552
|
+
create table t_truthy (id integer primary key, v any, check (v));
|
|
553
|
+
|
|
554
|
+
insert into t_truthy values (1, 5);
|
|
555
|
+
insert into t_truthy values (2, true);
|
|
556
|
+
|
|
557
|
+
select count(*) as cnt from t_truthy;
|
|
558
|
+
→ [{"cnt":2}]
|
|
559
|
+
|
|
560
|
+
-- bare integer literal is bigint 0n at runtime — must fail like SQLite's 0.
|
|
561
|
+
insert into t_truthy values (3, 0);
|
|
562
|
+
-- error: CHECK
|
|
563
|
+
|
|
564
|
+
-- string '0' is falsy under isTruthy's numeric conversion — must fail too.
|
|
565
|
+
insert into t_truthy values (4, '0');
|
|
566
|
+
-- error: CHECK
|
|
567
|
+
|
|
568
|
+
-- boolean false still fails (control, unchanged).
|
|
569
|
+
insert into t_truthy values (5, false);
|
|
570
|
+
-- error: CHECK
|
|
571
|
+
|
|
572
|
+
select count(*) as cnt from t_truthy;
|
|
573
|
+
→ [{"cnt":2}]
|
|
574
|
+
|
|
575
|
+
drop table t_truthy;
|
|
576
|
+
|
|
577
|
+
-- A subquery-bearing CHECK auto-defers to the DeferredConstraintQueue path,
|
|
578
|
+
-- which shares the same isTruthy fix. `check ((select v))` yields the row's own
|
|
579
|
+
-- v (bigint 0n for v=0) through the deferred evaluator — must reject like the
|
|
580
|
+
-- immediate path, not slip past a narrow `value === false || value === 0`.
|
|
581
|
+
create table t_defer (id integer primary key, v any, check ((select v)));
|
|
582
|
+
|
|
583
|
+
insert into t_defer values (1, 5);
|
|
584
|
+
select count(*) as cnt from t_defer;
|
|
585
|
+
→ [{"cnt":1}]
|
|
586
|
+
|
|
587
|
+
-- deferred CHECK result is bigint 0n → must fail.
|
|
588
|
+
insert into t_defer values (2, 0);
|
|
589
|
+
-- error: CHECK
|
|
590
|
+
|
|
591
|
+
-- deferred CHECK result is string '0' → falsy under isTruthy → must fail.
|
|
592
|
+
insert into t_defer values (3, '0');
|
|
593
|
+
-- error: CHECK
|
|
594
|
+
|
|
595
|
+
select count(*) as cnt from t_defer;
|
|
596
|
+
→ [{"cnt":1}]
|
|
597
|
+
|
|
598
|
+
drop table t_defer;
|
|
599
|
+
|
|
600
|
+
-- === OR REPLACE default substitution is subject to CHECK ===
|
|
601
|
+
-- A NOT NULL violation under OR REPLACE substitutes the column's DEFAULT. The
|
|
602
|
+
-- CHECK verdict must be computed against the SUBSTITUTED row, not the original
|
|
603
|
+
-- NULL — `null > 100` is NULL, which CHECK treats as a pass, so evaluating
|
|
604
|
+
-- pre-substitution let a stored value of 5 slip past `check (v > 100)`.
|
|
605
|
+
-- Regression for bug-replace-default-skips-check.
|
|
606
|
+
|
|
607
|
+
create table rd_bad (id integer primary key, v integer not null default 5 check (v > 100));
|
|
608
|
+
|
|
609
|
+
-- Control: the CHECK is live on a supplied value.
|
|
610
|
+
insert into rd_bad values (2, 7);
|
|
611
|
+
-- error: CHECK
|
|
612
|
+
|
|
613
|
+
-- The substituted DEFAULT (5) is not > 100, so the row must be rejected too.
|
|
614
|
+
insert or replace into rd_bad values (1, null);
|
|
615
|
+
-- error: CHECK
|
|
616
|
+
|
|
617
|
+
select count(*) as cnt from rd_bad;
|
|
618
|
+
→ [{"cnt":0}]
|
|
619
|
+
|
|
620
|
+
drop table rd_bad;
|
|
621
|
+
|
|
622
|
+
-- A substituted DEFAULT that satisfies the CHECK is still stored.
|
|
623
|
+
create table rd_ok (id integer primary key, v integer not null default 500 check (v > 100));
|
|
624
|
+
|
|
625
|
+
insert or replace into rd_ok values (1, null);
|
|
626
|
+
|
|
627
|
+
select id, v from rd_ok;
|
|
628
|
+
→ [{"id":1,"v":500}]
|
|
629
|
+
|
|
630
|
+
drop table rd_ok;
|
|
631
|
+
|
|
632
|
+
-- UPDATE has no statement-level OR clause, so its substitution arrives through a
|
|
633
|
+
-- column-level `on conflict replace`. Same rule: the CHECK sees the substituted row.
|
|
634
|
+
create table rd_upd (id integer primary key, v integer not null on conflict replace default 500 check (v > 100));
|
|
635
|
+
|
|
636
|
+
insert into rd_upd values (1, 700);
|
|
637
|
+
|
|
638
|
+
update rd_upd set v = null where id = 1;
|
|
639
|
+
|
|
640
|
+
select id, v from rd_upd;
|
|
641
|
+
→ [{"id":1,"v":500}]
|
|
642
|
+
|
|
643
|
+
drop table rd_upd;
|
|
644
|
+
|
|
645
|
+
create table rd_upd_bad (id integer primary key, v integer not null on conflict replace default 5 check (v > 100));
|
|
646
|
+
|
|
647
|
+
insert into rd_upd_bad values (1, 700);
|
|
648
|
+
|
|
649
|
+
update rd_upd_bad set v = null where id = 1;
|
|
650
|
+
-- error: CHECK
|
|
651
|
+
|
|
652
|
+
select id, v from rd_upd_bad;
|
|
653
|
+
→ [{"id":1,"v":700}]
|
|
654
|
+
|
|
655
|
+
drop table rd_upd_bad;
|
|
656
|
+
|
|
657
|
+
-- The deferred CHECK path reaches the same verdict.
|
|
658
|
+
create table rd_defer (id integer primary key, v integer not null default 5 check ((select v > 100)));
|
|
659
|
+
|
|
660
|
+
insert or replace into rd_defer values (1, null);
|
|
661
|
+
-- error: CHECK
|
|
662
|
+
|
|
663
|
+
select count(*) as cnt from rd_defer;
|
|
664
|
+
→ [{"cnt":0}]
|
|
665
|
+
|
|
666
|
+
drop table rd_defer;
|
|
667
|
+
|
|
668
|
+
-- A DEFAULT that reads a sibling column of the same row still resolves: the
|
|
669
|
+
-- substitution runs against the raw NEW row, and the CHECK then sees the result.
|
|
670
|
+
create table rd_sib (id integer primary key, a integer, b integer not null default (new.a * 2) check (b > 10));
|
|
671
|
+
|
|
672
|
+
insert or replace into rd_sib values (1, 9, null);
|
|
673
|
+
|
|
674
|
+
select id, a, b from rd_sib;
|
|
675
|
+
→ [{"id":1,"a":9,"b":18}]
|
|
676
|
+
|
|
677
|
+
insert or replace into rd_sib values (2, 3, null);
|
|
678
|
+
-- error: CHECK
|
|
679
|
+
|
|
680
|
+
select count(*) as cnt from rd_sib;
|
|
681
|
+
→ [{"cnt":1}]
|
|
682
|
+
|
|
683
|
+
drop table rd_sib;
|