@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,164 @@
|
|
|
1
|
+
-- determinism-validation.sqllogic - Testing determinism validation for constraints and defaults
|
|
2
|
+
|
|
3
|
+
-- === Test 1: Non-deterministic DEFAULT values should be rejected ===
|
|
4
|
+
|
|
5
|
+
-- Attempt to create table with random() in DEFAULT - should fail
|
|
6
|
+
CREATE TABLE t_random_default (
|
|
7
|
+
id INTEGER PRIMARY KEY,
|
|
8
|
+
value INTEGER DEFAULT random()
|
|
9
|
+
);
|
|
10
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
11
|
+
|
|
12
|
+
-- Attempt to create table with date('now') in DEFAULT - should fail
|
|
13
|
+
CREATE TABLE t_date_now_default (
|
|
14
|
+
id INTEGER PRIMARY KEY,
|
|
15
|
+
created_at TEXT DEFAULT date('now')
|
|
16
|
+
);
|
|
17
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
18
|
+
|
|
19
|
+
-- Attempt to create table with datetime('now') in DEFAULT - should fail
|
|
20
|
+
CREATE TABLE t_datetime_now_default (
|
|
21
|
+
id INTEGER PRIMARY KEY,
|
|
22
|
+
timestamp TEXT DEFAULT datetime('now')
|
|
23
|
+
);
|
|
24
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
25
|
+
|
|
26
|
+
-- Attempt to create table with time('now') in DEFAULT - should fail
|
|
27
|
+
CREATE TABLE t_time_now_default (
|
|
28
|
+
id INTEGER PRIMARY KEY,
|
|
29
|
+
current_time TEXT DEFAULT time('now')
|
|
30
|
+
);
|
|
31
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
32
|
+
|
|
33
|
+
-- Attempt to create table with julianday('now') in DEFAULT - should fail
|
|
34
|
+
CREATE TABLE t_julianday_now_default (
|
|
35
|
+
id INTEGER PRIMARY KEY,
|
|
36
|
+
jd REAL DEFAULT julianday('now')
|
|
37
|
+
);
|
|
38
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
39
|
+
|
|
40
|
+
-- === Test 2: Deterministic DEFAULT values should be accepted ===
|
|
41
|
+
|
|
42
|
+
-- Create table with constant DEFAULT - should succeed
|
|
43
|
+
CREATE TABLE t_const_default (
|
|
44
|
+
id INTEGER PRIMARY KEY,
|
|
45
|
+
name TEXT DEFAULT 'unnamed',
|
|
46
|
+
value INTEGER DEFAULT 42,
|
|
47
|
+
computed INTEGER DEFAULT (10 + 20)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- Insert without specifying defaults
|
|
51
|
+
INSERT INTO t_const_default (id) VALUES (1);
|
|
52
|
+
SELECT * FROM t_const_default WHERE id = 1;
|
|
53
|
+
→ [{"id":1,"name":"unnamed","value":42,"computed":30}]
|
|
54
|
+
|
|
55
|
+
DROP TABLE t_const_default;
|
|
56
|
+
|
|
57
|
+
-- Create table with date literal DEFAULT - should succeed
|
|
58
|
+
CREATE TABLE t_date_literal_default (
|
|
59
|
+
id INTEGER PRIMARY KEY,
|
|
60
|
+
created_date TEXT DEFAULT '2024-01-01'
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
INSERT INTO t_date_literal_default (id) VALUES (1);
|
|
64
|
+
SELECT * FROM t_date_literal_default WHERE id = 1;
|
|
65
|
+
→ [{"id":1,"created_date":"2024-01-01"}]
|
|
66
|
+
|
|
67
|
+
DROP TABLE t_date_literal_default;
|
|
68
|
+
|
|
69
|
+
-- === Test 3: Non-deterministic CHECK constraints should be rejected ===
|
|
70
|
+
|
|
71
|
+
-- Attempt to create table with random() in CHECK - should fail
|
|
72
|
+
CREATE TABLE t_random_check (
|
|
73
|
+
id INTEGER PRIMARY KEY,
|
|
74
|
+
value INTEGER CHECK(value > random())
|
|
75
|
+
);
|
|
76
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
77
|
+
|
|
78
|
+
-- Attempt to create table with date('now') in CHECK - should fail
|
|
79
|
+
CREATE TABLE t_date_now_check (
|
|
80
|
+
id INTEGER PRIMARY KEY,
|
|
81
|
+
created_at TEXT CHECK(created_at < date('now'))
|
|
82
|
+
);
|
|
83
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
84
|
+
|
|
85
|
+
-- === Test 4: Deterministic CHECK constraints should be accepted ===
|
|
86
|
+
|
|
87
|
+
-- Create table with deterministic CHECK - should succeed
|
|
88
|
+
CREATE TABLE t_deterministic_check (
|
|
89
|
+
id INTEGER PRIMARY KEY,
|
|
90
|
+
value INTEGER CHECK(value > 0),
|
|
91
|
+
name TEXT CHECK(length(name) > 2)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
-- Insert valid data
|
|
95
|
+
INSERT INTO t_deterministic_check VALUES (1, 10, 'test');
|
|
96
|
+
SELECT * FROM t_deterministic_check WHERE id = 1;
|
|
97
|
+
→ [{"id":1,"value":10,"name":"test"}]
|
|
98
|
+
|
|
99
|
+
-- Insert invalid data (violates CHECK)
|
|
100
|
+
INSERT INTO t_deterministic_check VALUES (2, -5, 'ok');
|
|
101
|
+
-- error: CHECK constraint failed
|
|
102
|
+
|
|
103
|
+
DROP TABLE t_deterministic_check;
|
|
104
|
+
|
|
105
|
+
-- === Test 5: ALTER TABLE ADD CONSTRAINT with non-deterministic expression ===
|
|
106
|
+
|
|
107
|
+
CREATE TABLE t_alter (
|
|
108
|
+
id INTEGER PRIMARY KEY,
|
|
109
|
+
value INTEGER
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
-- Add non-deterministic constraint - succeeds at ALTER TABLE time
|
|
113
|
+
-- but will fail when first used (at INSERT/UPDATE time)
|
|
114
|
+
ALTER TABLE t_alter ADD CONSTRAINT random_check CHECK (value > random());
|
|
115
|
+
|
|
116
|
+
-- Attempt to insert - should fail due to non-deterministic constraint
|
|
117
|
+
INSERT INTO t_alter VALUES (1, 10);
|
|
118
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
119
|
+
|
|
120
|
+
DROP TABLE t_alter;
|
|
121
|
+
|
|
122
|
+
-- Create table for deterministic constraint test
|
|
123
|
+
CREATE TABLE t_alter2 (
|
|
124
|
+
id INTEGER PRIMARY KEY,
|
|
125
|
+
value INTEGER
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
-- Add deterministic constraint - should succeed
|
|
129
|
+
ALTER TABLE t_alter2 ADD CONSTRAINT positive_check CHECK (value > 0);
|
|
130
|
+
|
|
131
|
+
-- Verify constraint works
|
|
132
|
+
INSERT INTO t_alter2 VALUES (1, 10);
|
|
133
|
+
SELECT * FROM t_alter2 WHERE id = 1;
|
|
134
|
+
→ [{"id":1,"value":10}]
|
|
135
|
+
|
|
136
|
+
INSERT INTO t_alter2 VALUES (2, -5);
|
|
137
|
+
-- error: CHECK constraint failed: positive_check
|
|
138
|
+
|
|
139
|
+
DROP TABLE t_alter2;
|
|
140
|
+
|
|
141
|
+
-- === Test 6: Nested non-deterministic expressions ===
|
|
142
|
+
|
|
143
|
+
-- Non-deterministic function nested in expression - should fail
|
|
144
|
+
CREATE TABLE t_nested_random (
|
|
145
|
+
id INTEGER PRIMARY KEY,
|
|
146
|
+
value INTEGER DEFAULT (random() + 100)
|
|
147
|
+
);
|
|
148
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
149
|
+
|
|
150
|
+
-- Non-deterministic function in complex expression - should fail
|
|
151
|
+
CREATE TABLE t_complex_random (
|
|
152
|
+
id INTEGER PRIMARY KEY,
|
|
153
|
+
value INTEGER CHECK(value > (random() * 10))
|
|
154
|
+
);
|
|
155
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
156
|
+
|
|
157
|
+
-- === Test 7: randomblob() should also be rejected ===
|
|
158
|
+
|
|
159
|
+
CREATE TABLE t_randomblob_default (
|
|
160
|
+
id INTEGER PRIMARY KEY,
|
|
161
|
+
data BLOB DEFAULT randomblob(16)
|
|
162
|
+
);
|
|
163
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
164
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
-- 44-orthogonality.sqllogic - Testing relational orthogonality with mutating subqueries
|
|
2
|
+
|
|
3
|
+
-- Setup test tables
|
|
4
|
+
CREATE TABLE users (
|
|
5
|
+
id INTEGER PRIMARY KEY,
|
|
6
|
+
name TEXT NOT NULL,
|
|
7
|
+
email TEXT UNIQUE
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE TABLE audit_log (
|
|
11
|
+
id INTEGER PRIMARY KEY,
|
|
12
|
+
action TEXT NOT NULL,
|
|
13
|
+
user_id INTEGER,
|
|
14
|
+
timestamp TEXT DEFAULT 'now'
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- Insert initial test data
|
|
18
|
+
INSERT INTO users (id, name, email) VALUES
|
|
19
|
+
(1, 'Alice', 'alice@example.com'),
|
|
20
|
+
(2, 'Bob', 'bob@example.com'),
|
|
21
|
+
(3, 'Charlie', 'charlie@example.com');
|
|
22
|
+
|
|
23
|
+
-- run
|
|
24
|
+
-- Test 0: INSERT from SELECT, TVF, CTE
|
|
25
|
+
insert into audit_log (action, user_id)
|
|
26
|
+
select 'user_created', 0;
|
|
27
|
+
-- error: NOT NULL constraint failed: audit_log.id
|
|
28
|
+
|
|
29
|
+
insert into audit_log (id, action, user_id)
|
|
30
|
+
SELECT key, 'cte_source', value FROM json_each('[0]') where key is not null;
|
|
31
|
+
|
|
32
|
+
insert into audit_log (id, action, user_id)
|
|
33
|
+
select 1, 'test_entry', 0;
|
|
34
|
+
|
|
35
|
+
delete from audit_log;
|
|
36
|
+
|
|
37
|
+
-- Test 1: INSERT ... RETURNING as table source
|
|
38
|
+
SELECT new_user.id, new_user.name, 'created' as status
|
|
39
|
+
FROM (
|
|
40
|
+
INSERT INTO users (id, name, email)
|
|
41
|
+
VALUES (4, 'David', 'david@example.com')
|
|
42
|
+
RETURNING id, name
|
|
43
|
+
) AS new_user;
|
|
44
|
+
→ [{ "id": 4, "name": "David", "status": "created" }]
|
|
45
|
+
|
|
46
|
+
-- Verify the INSERT actually happened
|
|
47
|
+
SELECT name FROM users WHERE id = 4;
|
|
48
|
+
→ [{ "name": "David" }]
|
|
49
|
+
|
|
50
|
+
-- Test 2: UPDATE ... RETURNING as table source
|
|
51
|
+
SELECT updated.id, updated.name, updated.email, 'modified' as status
|
|
52
|
+
FROM (
|
|
53
|
+
UPDATE users
|
|
54
|
+
SET email = 'alice.updated@example.com'
|
|
55
|
+
WHERE name = 'Alice'
|
|
56
|
+
RETURNING id, name, email
|
|
57
|
+
) AS updated;
|
|
58
|
+
→ [{ "id": 1, "name": "Alice", "email": "alice.updated@example.com", "status": "modified" }]
|
|
59
|
+
|
|
60
|
+
-- Verify the UPDATE actually happened
|
|
61
|
+
SELECT email FROM users WHERE name = 'Alice';
|
|
62
|
+
→ [{ "email": "alice.updated@example.com" }]
|
|
63
|
+
|
|
64
|
+
-- Test 3: DELETE ... RETURNING as table source
|
|
65
|
+
SELECT deleted.id, deleted.name, 'removed' as status
|
|
66
|
+
FROM (
|
|
67
|
+
DELETE FROM users
|
|
68
|
+
WHERE name = 'Charlie'
|
|
69
|
+
RETURNING id, name
|
|
70
|
+
) AS deleted;
|
|
71
|
+
→ [{ "id": 3, "name": "Charlie", "status": "removed" }]
|
|
72
|
+
|
|
73
|
+
-- Verify the DELETE actually happened
|
|
74
|
+
SELECT count(*) as remaining FROM users WHERE name = 'Charlie';
|
|
75
|
+
→ [{ "remaining": 0 }]
|
|
76
|
+
|
|
77
|
+
-- Test 4: INSERT from mutating subquery (full orthogonality)
|
|
78
|
+
INSERT INTO audit_log (id, action, user_id)
|
|
79
|
+
SELECT 2, 'user_created', new_user.id
|
|
80
|
+
FROM (
|
|
81
|
+
INSERT INTO users (id, name, email)
|
|
82
|
+
VALUES (5, 'Eve', 'eve@example.com')
|
|
83
|
+
RETURNING id
|
|
84
|
+
) AS new_user;
|
|
85
|
+
|
|
86
|
+
-- Verify both the INSERT and the audit log
|
|
87
|
+
SELECT name FROM users WHERE id = 5;
|
|
88
|
+
→ [{ "name": "Eve" }]
|
|
89
|
+
|
|
90
|
+
SELECT action, user_id FROM audit_log WHERE action = 'user_created';
|
|
91
|
+
→ [{ "action": "user_created", "user_id": 5 }]
|
|
92
|
+
|
|
93
|
+
-- Test 5: JOIN with mutating subquery
|
|
94
|
+
-- TODO: replace this with like operator when that's implemented.
|
|
95
|
+
SELECT u.name, updated.email as new_email
|
|
96
|
+
FROM users u
|
|
97
|
+
JOIN (
|
|
98
|
+
UPDATE users
|
|
99
|
+
SET email = name || '@company.com'
|
|
100
|
+
WHERE like('%@example.com', email)
|
|
101
|
+
RETURNING id, email
|
|
102
|
+
) AS updated ON u.id = updated.id;
|
|
103
|
+
→ [{ "name": "Alice", "new_email": "Alice@company.com" }, { "name": "Bob", "new_email": "Bob@company.com" }, { "name": "David", "new_email": "David@company.com" }, { "name": "Eve", "new_email": "Eve@company.com" }]
|
|
104
|
+
|
|
105
|
+
-- Test 6: Multiple column aliases in mutating subquery
|
|
106
|
+
SELECT u.user_id, u.user_name, u.user_email
|
|
107
|
+
FROM (
|
|
108
|
+
INSERT INTO users (id, name, email)
|
|
109
|
+
VALUES (6, 'Frank', 'frank@example.com')
|
|
110
|
+
RETURNING id, name, email
|
|
111
|
+
) AS u(user_id, user_name, user_email);
|
|
112
|
+
→ [{ "user_id": 6, "user_name": "Frank", "user_email": "frank@example.com" }]
|
|
113
|
+
|
|
114
|
+
-- Test 6b: Mutating subquery with qualified SELECT *
|
|
115
|
+
SELECT r.* FROM (
|
|
116
|
+
INSERT INTO users (id, name, email)
|
|
117
|
+
VALUES (60, 'Qualified', 'qualified@example.com')
|
|
118
|
+
RETURNING id, name
|
|
119
|
+
) AS r;
|
|
120
|
+
→ [{ "id": 60, "name": "Qualified" }]
|
|
121
|
+
|
|
122
|
+
DELETE FROM users WHERE id = 60;
|
|
123
|
+
|
|
124
|
+
-- Test 7: Nested mutating subqueries (complex orthogonality)
|
|
125
|
+
SELECT outer_result.total_created
|
|
126
|
+
FROM (
|
|
127
|
+
SELECT count(*) as total_created
|
|
128
|
+
FROM (
|
|
129
|
+
INSERT INTO users (id, name, email)
|
|
130
|
+
VALUES (7, 'Grace', 'grace@example.com')
|
|
131
|
+
RETURNING id
|
|
132
|
+
) AS inner_insert
|
|
133
|
+
) AS outer_result;
|
|
134
|
+
→ [{ "total_created": 1 }]
|
|
135
|
+
|
|
136
|
+
-- Test 8: Error case - mutating subquery without RETURNING
|
|
137
|
+
-- This should fail at parse/plan time
|
|
138
|
+
SELECT * FROM (
|
|
139
|
+
INSERT INTO users (id, name, email)
|
|
140
|
+
VALUES (8, 'Invalid', 'invalid@example.com')
|
|
141
|
+
) AS invalid_subquery;
|
|
142
|
+
-- error: must have a RETURNING clause
|
|
143
|
+
|
|
144
|
+
-- Cleanup
|
|
145
|
+
DROP TABLE audit_log;
|
|
146
|
+
DROP TABLE users;
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
-- 44.1-nondeterministic-schema.sqllogic
|
|
2
|
+
-- Exercise the `nondeterministic_schema` database option / PRAGMA: it relaxes
|
|
3
|
+
-- the static prohibition on non-deterministic expressions in DEFAULT, CHECK,
|
|
4
|
+
-- and GENERATED ALWAYS AS clauses. Capture is at the resolved-row frontier
|
|
5
|
+
-- in vtab.update(); replay applies primitives at the module-layer boundary.
|
|
6
|
+
|
|
7
|
+
-- ===================================
|
|
8
|
+
-- Pragma roundtrip + default value
|
|
9
|
+
-- ===================================
|
|
10
|
+
|
|
11
|
+
-- Defaults to false (strict rejection — matches 44-determinism-validation).
|
|
12
|
+
PRAGMA nondeterministic_schema;
|
|
13
|
+
→ [{"name":"nondeterministic_schema","value":false}]
|
|
14
|
+
|
|
15
|
+
-- ===================================
|
|
16
|
+
-- Strict mode (default): rejection paths unchanged
|
|
17
|
+
-- ===================================
|
|
18
|
+
|
|
19
|
+
CREATE TABLE strict_default (
|
|
20
|
+
id INTEGER PRIMARY KEY,
|
|
21
|
+
value INTEGER DEFAULT random()
|
|
22
|
+
);
|
|
23
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
24
|
+
|
|
25
|
+
CREATE TABLE strict_check (
|
|
26
|
+
id INTEGER PRIMARY KEY,
|
|
27
|
+
value INTEGER CHECK (random() > 0)
|
|
28
|
+
);
|
|
29
|
+
-- error: Non-deterministic expression not allowed in CHECK
|
|
30
|
+
|
|
31
|
+
-- GENERATED column determinism is validated at CREATE TABLE time, same as
|
|
32
|
+
-- DEFAULT and CHECK — the table is never created.
|
|
33
|
+
CREATE TABLE strict_generated (
|
|
34
|
+
id INTEGER PRIMARY KEY,
|
|
35
|
+
v INTEGER,
|
|
36
|
+
g INTEGER GENERATED ALWAYS AS (random()) STORED
|
|
37
|
+
);
|
|
38
|
+
-- error: Non-deterministic expression not allowed in GENERATED ALWAYS AS
|
|
39
|
+
|
|
40
|
+
DROP TABLE strict_generated;
|
|
41
|
+
-- error: not found in schema
|
|
42
|
+
|
|
43
|
+
-- ===================================
|
|
44
|
+
-- Flip the gate and read it back
|
|
45
|
+
-- ===================================
|
|
46
|
+
|
|
47
|
+
PRAGMA nondeterministic_schema = true;
|
|
48
|
+
|
|
49
|
+
PRAGMA nondeterministic_schema;
|
|
50
|
+
→ [{"name":"nondeterministic_schema","value":true}]
|
|
51
|
+
|
|
52
|
+
-- Alias also resolves to the same underlying value (the pragma echoes the
|
|
53
|
+
-- name as written, but the value reflects the canonical option).
|
|
54
|
+
PRAGMA allow_nondeterministic_schema_expressions;
|
|
55
|
+
→ [{"name":"allow_nondeterministic_schema_expressions","value":true}]
|
|
56
|
+
|
|
57
|
+
-- ===================================
|
|
58
|
+
-- Relaxed mode: DEFAULT random()
|
|
59
|
+
-- ===================================
|
|
60
|
+
|
|
61
|
+
-- CREATE TABLE no longer rejects. Per-row capture resolves the default into a
|
|
62
|
+
-- literal at INSERT time, so the row stored in the table is fully concrete.
|
|
63
|
+
CREATE TABLE relaxed_default (
|
|
64
|
+
id INTEGER PRIMARY KEY,
|
|
65
|
+
rnd INTEGER DEFAULT random()
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
INSERT INTO relaxed_default (id) VALUES (1);
|
|
69
|
+
INSERT INTO relaxed_default (id) VALUES (2);
|
|
70
|
+
INSERT INTO relaxed_default (id) VALUES (3);
|
|
71
|
+
|
|
72
|
+
-- Three rows landed; each row's rnd column is concrete (non-null) because the
|
|
73
|
+
-- default fired per row.
|
|
74
|
+
SELECT COUNT(*) AS n, COUNT(rnd) AS non_null_rnd FROM relaxed_default;
|
|
75
|
+
→ [{"n":3,"non_null_rnd":3}]
|
|
76
|
+
|
|
77
|
+
-- Distinct PKs is independent of the relaxation, but verify the relaxed DEFAULT
|
|
78
|
+
-- doesn't break the regular INSERT path.
|
|
79
|
+
SELECT id FROM relaxed_default ORDER BY id;
|
|
80
|
+
→ [{"id":1},{"id":2},{"id":3}]
|
|
81
|
+
|
|
82
|
+
DROP TABLE relaxed_default;
|
|
83
|
+
|
|
84
|
+
-- ===================================
|
|
85
|
+
-- Relaxed mode: DEFAULT datetime('now')
|
|
86
|
+
-- ===================================
|
|
87
|
+
|
|
88
|
+
CREATE TABLE relaxed_default_now (
|
|
89
|
+
id INTEGER PRIMARY KEY,
|
|
90
|
+
ts TEXT DEFAULT datetime('now')
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
INSERT INTO relaxed_default_now (id) VALUES (1);
|
|
94
|
+
|
|
95
|
+
-- Captured timestamp is a real string (not null, not the literal "datetime").
|
|
96
|
+
SELECT COUNT(*) AS n, COUNT(ts) AS non_null_ts FROM relaxed_default_now;
|
|
97
|
+
→ [{"n":1,"non_null_ts":1}]
|
|
98
|
+
|
|
99
|
+
SELECT id FROM relaxed_default_now WHERE ts >= '2020-01-01';
|
|
100
|
+
→ [{"id":1}]
|
|
101
|
+
|
|
102
|
+
DROP TABLE relaxed_default_now;
|
|
103
|
+
|
|
104
|
+
-- ===================================
|
|
105
|
+
-- Relaxed mode: immediate CHECK using datetime('now') predicate
|
|
106
|
+
-- This avoids probabilistic flakiness while still exercising the relaxed gate
|
|
107
|
+
-- (the strict validator would reject this CREATE TABLE).
|
|
108
|
+
-- ===================================
|
|
109
|
+
|
|
110
|
+
CREATE TABLE relaxed_check (
|
|
111
|
+
id INTEGER PRIMARY KEY,
|
|
112
|
+
note TEXT,
|
|
113
|
+
CONSTRAINT after_epoch CHECK (datetime('now') >= '2020-01-01')
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
INSERT INTO relaxed_check VALUES (1, 'first');
|
|
117
|
+
INSERT INTO relaxed_check VALUES (2, 'second');
|
|
118
|
+
|
|
119
|
+
SELECT COUNT(*) FROM relaxed_check;
|
|
120
|
+
→ [{"count(*)":2}]
|
|
121
|
+
|
|
122
|
+
DROP TABLE relaxed_check;
|
|
123
|
+
|
|
124
|
+
-- ===================================
|
|
125
|
+
-- Relaxed mode: CHECK with random() — pure non-det in a row CHECK
|
|
126
|
+
-- random() returns a BigInt in [MIN_SAFE_INT, MAX_SAFE_INT]; "random() IS NOT NULL"
|
|
127
|
+
-- always passes, so this exercises the relaxed-gate path without probabilistic
|
|
128
|
+
-- flakiness.
|
|
129
|
+
-- ===================================
|
|
130
|
+
|
|
131
|
+
CREATE TABLE relaxed_check_random (
|
|
132
|
+
id INTEGER PRIMARY KEY,
|
|
133
|
+
v INTEGER,
|
|
134
|
+
CONSTRAINT rnd_nonnull CHECK (random() IS NOT NULL)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
INSERT INTO relaxed_check_random VALUES (1, 100);
|
|
138
|
+
INSERT INTO relaxed_check_random VALUES (2, 200);
|
|
139
|
+
|
|
140
|
+
SELECT COUNT(*) FROM relaxed_check_random;
|
|
141
|
+
→ [{"count(*)":2}]
|
|
142
|
+
|
|
143
|
+
DROP TABLE relaxed_check_random;
|
|
144
|
+
|
|
145
|
+
-- ===================================
|
|
146
|
+
-- Relaxed mode: stored GENERATED ALWAYS AS (random())
|
|
147
|
+
-- The expression is evaluated per row before the module write; the resolved
|
|
148
|
+
-- value is captured.
|
|
149
|
+
-- ===================================
|
|
150
|
+
|
|
151
|
+
CREATE TABLE relaxed_generated (
|
|
152
|
+
id INTEGER PRIMARY KEY,
|
|
153
|
+
payload TEXT,
|
|
154
|
+
g INTEGER GENERATED ALWAYS AS (random()) STORED
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
INSERT INTO relaxed_generated (id, payload) VALUES (1, 'a');
|
|
158
|
+
INSERT INTO relaxed_generated (id, payload) VALUES (2, 'b');
|
|
159
|
+
|
|
160
|
+
-- The generated column is materialised with a concrete value per row.
|
|
161
|
+
SELECT COUNT(*) AS n, COUNT(g) AS non_null_g FROM relaxed_generated;
|
|
162
|
+
→ [{"n":2,"non_null_g":2}]
|
|
163
|
+
|
|
164
|
+
DROP TABLE relaxed_generated;
|
|
165
|
+
|
|
166
|
+
-- ===================================
|
|
167
|
+
-- Relaxed mode: deferred CHECK via CREATE ASSERTION with non-det
|
|
168
|
+
-- The assertion evaluates once at COMMIT; non-determinism in the body is
|
|
169
|
+
-- replay-safe by transaction atomicity (commit-or-rollback is decided once,
|
|
170
|
+
-- replay applies the module-layer writes).
|
|
171
|
+
-- ===================================
|
|
172
|
+
|
|
173
|
+
CREATE TABLE assertion_target (id INTEGER PRIMARY KEY, val INTEGER);
|
|
174
|
+
|
|
175
|
+
CREATE ASSERTION rnd_assertion CHECK (random() IS NOT NULL);
|
|
176
|
+
|
|
177
|
+
BEGIN;
|
|
178
|
+
INSERT INTO assertion_target VALUES (1, 10);
|
|
179
|
+
COMMIT;
|
|
180
|
+
|
|
181
|
+
SELECT id, val FROM assertion_target;
|
|
182
|
+
→ [{"id":1,"val":10}]
|
|
183
|
+
|
|
184
|
+
DROP ASSERTION rnd_assertion;
|
|
185
|
+
|
|
186
|
+
DROP TABLE assertion_target;
|
|
187
|
+
|
|
188
|
+
-- ===================================
|
|
189
|
+
-- Pragma scope: turning the gate OFF after creating a relaxed table leaves the
|
|
190
|
+
-- table's schema in place. Validation is re-evaluated at DML build time, so
|
|
191
|
+
-- INSERTs into a table whose stored expressions are non-deterministic require
|
|
192
|
+
-- the gate to be on at the time of compilation; flipping the gate back ON
|
|
193
|
+
-- restores INSERT compilability without re-creating the table.
|
|
194
|
+
-- ===================================
|
|
195
|
+
|
|
196
|
+
CREATE TABLE keeper (
|
|
197
|
+
id INTEGER PRIMARY KEY,
|
|
198
|
+
rnd INTEGER DEFAULT random()
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
INSERT INTO keeper (id) VALUES (10);
|
|
202
|
+
|
|
203
|
+
PRAGMA nondeterministic_schema = false;
|
|
204
|
+
|
|
205
|
+
PRAGMA nondeterministic_schema;
|
|
206
|
+
→ [{"name":"nondeterministic_schema","value":false}]
|
|
207
|
+
|
|
208
|
+
-- New DDL with non-det is rejected again.
|
|
209
|
+
CREATE TABLE strict_after (
|
|
210
|
+
id INTEGER PRIMARY KEY,
|
|
211
|
+
value INTEGER DEFAULT random()
|
|
212
|
+
);
|
|
213
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
214
|
+
|
|
215
|
+
-- Existing table's schema is intact (rows already in the table read back fine —
|
|
216
|
+
-- the read path doesn't re-validate stored expressions).
|
|
217
|
+
SELECT COUNT(*) AS n, COUNT(rnd) AS non_null_rnd FROM keeper;
|
|
218
|
+
→ [{"n":1,"non_null_rnd":1}]
|
|
219
|
+
|
|
220
|
+
-- An INSERT that doesn't fire the non-deterministic DEFAULT (because the
|
|
221
|
+
-- column is supplied explicitly) compiles even under strict mode.
|
|
222
|
+
INSERT INTO keeper (id, rnd) VALUES (11, 99);
|
|
223
|
+
SELECT id, rnd FROM keeper WHERE id = 11;
|
|
224
|
+
→ [{"id":11,"rnd":99}]
|
|
225
|
+
|
|
226
|
+
-- But an INSERT that *would* fire the DEFAULT re-evaluates determinism against
|
|
227
|
+
-- the current pragma value and is rejected.
|
|
228
|
+
INSERT INTO keeper (id) VALUES (12);
|
|
229
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
230
|
+
|
|
231
|
+
-- Flipping the gate back on restores INSERT compilability without touching
|
|
232
|
+
-- the table.
|
|
233
|
+
PRAGMA nondeterministic_schema = true;
|
|
234
|
+
|
|
235
|
+
INSERT INTO keeper (id) VALUES (13);
|
|
236
|
+
SELECT COUNT(*) AS n, COUNT(rnd) AS non_null_rnd FROM keeper;
|
|
237
|
+
→ [{"n":3,"non_null_rnd":3}]
|
|
238
|
+
|
|
239
|
+
DROP TABLE keeper;
|
|
240
|
+
|
|
241
|
+
-- ===================================
|
|
242
|
+
-- Scope-check pre-walks remain active even under relaxed mode. Bind parameters
|
|
243
|
+
-- and bare column references in DEFAULT, and bind parameters in CHECK, are
|
|
244
|
+
-- still rejected at CREATE TABLE time regardless of the pragma — these are
|
|
245
|
+
-- scope checks, not determinism checks.
|
|
246
|
+
-- ===================================
|
|
247
|
+
|
|
248
|
+
PRAGMA nondeterministic_schema = true;
|
|
249
|
+
|
|
250
|
+
CREATE TABLE relaxed_default_bindparam (
|
|
251
|
+
id INTEGER PRIMARY KEY,
|
|
252
|
+
v INTEGER DEFAULT (?)
|
|
253
|
+
);
|
|
254
|
+
-- error: may not reference bind parameters
|
|
255
|
+
|
|
256
|
+
CREATE TABLE relaxed_default_colref (
|
|
257
|
+
id INTEGER PRIMARY KEY,
|
|
258
|
+
a INTEGER,
|
|
259
|
+
b INTEGER DEFAULT (a)
|
|
260
|
+
);
|
|
261
|
+
-- error: may not reference a bare column
|
|
262
|
+
|
|
263
|
+
CREATE TABLE relaxed_check_bindparam (
|
|
264
|
+
id INTEGER PRIMARY KEY,
|
|
265
|
+
v INTEGER,
|
|
266
|
+
CHECK (v > ?)
|
|
267
|
+
);
|
|
268
|
+
-- error: may not reference bind parameters
|
|
269
|
+
|
|
270
|
+
PRAGMA nondeterministic_schema = false;
|
|
271
|
+
|
|
272
|
+
-- ===================================
|
|
273
|
+
-- new.<column> DEFAULT determinism: the DDL build/determinism check is deferred
|
|
274
|
+
-- to INSERT time (the row scope isn't available at CREATE TABLE), so the
|
|
275
|
+
-- determinism gate is re-evaluated when the row is expanded. A pure `new.<col>`
|
|
276
|
+
-- reference is deterministic; wrapping it around a non-deterministic function is
|
|
277
|
+
-- not — and must be rejected under strict mode but allowed under the relaxed gate.
|
|
278
|
+
-- ===================================
|
|
279
|
+
|
|
280
|
+
-- Strict mode: a pure new.<col> default is deterministic and inserts cleanly.
|
|
281
|
+
CREATE TABLE newref_det (
|
|
282
|
+
id INTEGER PRIMARY KEY,
|
|
283
|
+
x INTEGER,
|
|
284
|
+
y INTEGER DEFAULT (new.x + 1)
|
|
285
|
+
);
|
|
286
|
+
INSERT INTO newref_det (id, x) VALUES (1, 5);
|
|
287
|
+
SELECT y FROM newref_det WHERE id = 1;
|
|
288
|
+
→ [{"y":6}]
|
|
289
|
+
DROP TABLE newref_det;
|
|
290
|
+
|
|
291
|
+
-- Strict mode: new.<col> combined with a non-deterministic function is rejected
|
|
292
|
+
-- at INSERT time (the deferred determinism check fires when the default fires).
|
|
293
|
+
CREATE TABLE newref_nondet (
|
|
294
|
+
id INTEGER PRIMARY KEY,
|
|
295
|
+
x INTEGER,
|
|
296
|
+
y INTEGER DEFAULT (new.x + random())
|
|
297
|
+
);
|
|
298
|
+
INSERT INTO newref_nondet (id, x) VALUES (1, 5);
|
|
299
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
300
|
+
DROP TABLE newref_nondet;
|
|
301
|
+
|
|
302
|
+
-- Relaxed mode: the same non-deterministic new.<col> default is permitted; the
|
|
303
|
+
-- value is resolved into a concrete literal per row.
|
|
304
|
+
PRAGMA nondeterministic_schema = true;
|
|
305
|
+
|
|
306
|
+
CREATE TABLE newref_relaxed (
|
|
307
|
+
id INTEGER PRIMARY KEY,
|
|
308
|
+
x INTEGER,
|
|
309
|
+
y INTEGER DEFAULT (new.x + random())
|
|
310
|
+
);
|
|
311
|
+
INSERT INTO newref_relaxed (id, x) VALUES (1, 5);
|
|
312
|
+
SELECT COUNT(*) AS n, COUNT(y) AS non_null_y FROM newref_relaxed;
|
|
313
|
+
→ [{"n":1,"non_null_y":1}]
|
|
314
|
+
DROP TABLE newref_relaxed;
|
|
315
|
+
|
|
316
|
+
PRAGMA nondeterministic_schema = false;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- UDF Determinism Tests
|
|
2
|
+
-- Tests that user-defined functions properly declare and propagate determinism
|
|
3
|
+
|
|
4
|
+
-- Test 1: Non-deterministic UDF in DEFAULT should fail
|
|
5
|
+
-- (This test would require programmatic UDF registration, so we'll skip it for now)
|
|
6
|
+
|
|
7
|
+
-- Test 2: Verify built-in non-deterministic functions are rejected
|
|
8
|
+
CREATE TABLE t1 (
|
|
9
|
+
id INTEGER PRIMARY KEY,
|
|
10
|
+
created_at TEXT DEFAULT datetime('now')
|
|
11
|
+
);
|
|
12
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
13
|
+
|
|
14
|
+
-- Test 3: Verify built-in deterministic functions are allowed
|
|
15
|
+
CREATE TABLE t2 (
|
|
16
|
+
id INTEGER PRIMARY KEY,
|
|
17
|
+
upper_name TEXT DEFAULT upper('test')
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
INSERT INTO t2 (id) VALUES (1);
|
|
21
|
+
SELECT * FROM t2;
|
|
22
|
+
→ [{"id":1,"upper_name":"TEST"}]
|
|
23
|
+
|
|
24
|
+
DROP TABLE t2;
|
|
25
|
+
|
|
26
|
+
-- Test 4: Verify random() is rejected in DEFAULT
|
|
27
|
+
CREATE TABLE t3 (
|
|
28
|
+
id INTEGER PRIMARY KEY,
|
|
29
|
+
random_val REAL DEFAULT random()
|
|
30
|
+
);
|
|
31
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
32
|
+
|
|
33
|
+
-- Test 5: Verify randomblob() is rejected in DEFAULT
|
|
34
|
+
CREATE TABLE t4 (
|
|
35
|
+
id INTEGER PRIMARY KEY,
|
|
36
|
+
random_blob BLOB DEFAULT randomblob(16)
|
|
37
|
+
);
|
|
38
|
+
-- error: Non-deterministic expression not allowed in DEFAULT
|
|
39
|
+
|