@quereus/quereus 4.20.0 → 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/dist/src/common/types.d.ts +4 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema/catalog-rendering.js +13 -1
- package/dist/src/schema/catalog-rendering.js.map +1 -1
- package/dist/src/schema/catalog.d.ts +35 -2
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +42 -33
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +1 -1
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +195 -33
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +23 -1
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +43 -1
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +15 -12
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +87 -100
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/package.json +7 -4
- package/test/README.md +173 -0
- package/test/logic/01-basic.sqllogic +39 -0
- package/test/logic/01.1-select-projection-extras.sqllogic +130 -0
- package/test/logic/01.2-strings.sqllogic +43 -0
- package/test/logic/01.5-insert-select.sqllogic +237 -0
- package/test/logic/01.6-update-extras.sqllogic +118 -0
- package/test/logic/01.7-update-from.sqllogic +67 -0
- package/test/logic/01.8-delete-extras.sqllogic +122 -0
- package/test/logic/01.8.1-delete-range-cow.sqllogic +115 -0
- package/test/logic/01.9-query-expr-dml-gates.sqllogic +32 -0
- package/test/logic/01.9-query-expr-dml.sqllogic +171 -0
- package/test/logic/01.9-query-expr-values.sqllogic +111 -0
- package/test/logic/01.9.1-limit-over-dml-subquery.sqllogic +119 -0
- package/test/logic/02-filters.sqllogic +54 -0
- package/test/logic/02-smoke.sqllogic +62 -0
- package/test/logic/02.1-bind-parameters.sqllogic +223 -0
- package/test/logic/03-expressions.sqllogic +190 -0
- package/test/logic/03.1-quoted-identifiers.sqllogic +55 -0
- package/test/logic/03.4-defaults.sqllogic +554 -0
- package/test/logic/03.4.1-default-edge-cases.sqllogic +99 -0
- package/test/logic/03.5-tvf.sqllogic +61 -0
- package/test/logic/03.6-type-system.sqllogic +544 -0
- package/test/logic/03.6.1-numeric-text-comparison-coercion.sqllogic +244 -0
- package/test/logic/03.6.2-value-to-text.sqllogic +224 -0
- package/test/logic/03.7-bigint-mixed-arithmetic.sqllogic +65 -0
- package/test/logic/03.8-not-precedence.sqllogic +255 -0
- package/test/logic/03.9-is-bool-predicate.sqllogic +150 -0
- package/test/logic/03.9.1-is-bool-predicate-partial-index.sqllogic +34 -0
- package/test/logic/04-order-by.sqllogic +38 -0
- package/test/logic/04-transactions.sqllogic +239 -0
- package/test/logic/04a-savepoint-lazy-attach.sqllogic +122 -0
- package/test/logic/05-vtab_memory.sqllogic +50 -0
- package/test/logic/05.0.1-vtab-memory-unique-index-collation.sqllogic +34 -0
- package/test/logic/05.1-composite-pk-range-scan.sqllogic +147 -0
- package/test/logic/05.1.1-secondary-index-range-scan.sqllogic +56 -0
- package/test/logic/05.2-cast-seek-correctness.sqllogic +124 -0
- package/test/logic/06-builtin_functions.sqllogic +149 -0
- package/test/logic/06.1-string-functions.sqllogic +92 -0
- package/test/logic/06.1.3-like-glob-edges.sqllogic +53 -0
- package/test/logic/06.2-math-functions.sqllogic +82 -0
- package/test/logic/06.3-schema.sqllogic +48 -0
- package/test/logic/06.3.1-schema-all-schemas.sqllogic +39 -0
- package/test/logic/06.3.2-schema-foreign-keys.sqllogic +208 -0
- package/test/logic/06.3.3-introspection-tags.sqllogic +202 -0
- package/test/logic/06.3.3.1-introspection-tags-index.sqllogic +74 -0
- package/test/logic/06.3.4-view-info.sqllogic +378 -0
- package/test/logic/06.3.5-column-info.sqllogic +347 -0
- package/test/logic/06.3.6-schema-views.sqllogic +29 -0
- package/test/logic/06.4-schema-search-path.sqllogic +354 -0
- package/test/logic/06.4.1-schema-case-insensitive.sqllogic +83 -0
- package/test/logic/06.4.2-collation-extras.sqllogic +472 -0
- package/test/logic/06.4.2.1-collation-index-access-paths.sqllogic +140 -0
- package/test/logic/06.4.3-write-path-collation.sqllogic +99 -0
- package/test/logic/06.4.4-comparison-collation-precedence.sqllogic +342 -0
- package/test/logic/06.4.5-any-collate-declared-keys.sqllogic +92 -0
- package/test/logic/06.5-polymorphic-types.sqllogic +169 -0
- package/test/logic/06.5.1-conversion-functions.sqllogic +173 -0
- package/test/logic/06.5.2-scalar-minmax.sqllogic +16 -0
- package/test/logic/06.5.3-undeclared-return-type-comparison.sqllogic +244 -0
- package/test/logic/06.5.4-declared-return-type-builtins.sqllogic +288 -0
- package/test/logic/06.6-aggregate-extended.sqllogic +78 -0
- package/test/logic/06.7-json-extended.sqllogic +53 -0
- package/test/logic/06.8-json-path-operators.sqllogic +99 -0
- package/test/logic/06.9-json-canonical-key.sqllogic +65 -0
- package/test/logic/06.9.1-json-coerce-once.sqllogic +417 -0
- package/test/logic/06.9.1.1-json-coerce-once-index.sqllogic +39 -0
- package/test/logic/06.9.2-json-structural-equality.sqllogic +382 -0
- package/test/logic/06.9.2.1-json-structural-equality-index.sqllogic +76 -0
- package/test/logic/06.9.3-json-index-range-seek.sqllogic +205 -0
- package/test/logic/07-aggregates.sqllogic +193 -0
- package/test/logic/07.1-aggregate-filter-clause.sqllogic +12 -0
- package/test/logic/07.2-aggregate-order-by.sqllogic +11 -0
- package/test/logic/07.3-group-by-extras.sqllogic +602 -0
- package/test/logic/07.3.1-group-by-order-by-key.sqllogic +164 -0
- package/test/logic/07.3.2-grouped-select-list-shape.sqllogic +231 -0
- package/test/logic/07.4-group-by-filter-composite-pk.sqllogic +120 -0
- package/test/logic/07.5-sum-mixed-exact-and-float.sqllogic +151 -0
- package/test/logic/07.5-window.sqllogic +1941 -0
- package/test/logic/07.5.1-window-named.sqllogic +13 -0
- package/test/logic/07.5.2-window-nth-value.sqllogic +13 -0
- package/test/logic/07.6-subqueries.sqllogic +78 -0
- package/test/logic/07.6.1-subquery-extras.sqllogic +93 -0
- package/test/logic/07.7-and-or-short-circuit.sqllogic +58 -0
- package/test/logic/07.7-in-subquery-caching.sqllogic +174 -0
- package/test/logic/07.7-scalar-agg-decorrelation.sqllogic +197 -0
- package/test/logic/07.7.1-in-extras.sqllogic +158 -0
- package/test/logic/07.7.1-scalar-agg-decorrelation-filter.sqllogic +105 -0
- package/test/logic/07.7.2-scalar-agg-decorrelation-nested.sqllogic +115 -0
- package/test/logic/07.7.3-exists-in-select-decorrelation.sqllogic +107 -0
- package/test/logic/07.7.4-where-conjunct-ordering.sqllogic +121 -0
- package/test/logic/07.7.5-filter-lost-under-index-order.sqllogic +134 -0
- package/test/logic/07.7.6-correlated-predicate-scope.sqllogic +178 -0
- package/test/logic/07.7.7-join-source-scope-shadowing.sqllogic +137 -0
- package/test/logic/07.7.8-correlated-ref-to-computed-column.sqllogic +165 -0
- package/test/logic/07.7.9-conjunct-monotonicity.sqllogic +200 -0
- package/test/logic/07.8-correlated-subquery-edges.sqllogic +71 -0
- package/test/logic/07.8.1-correlated-in-decorrelation-gates.sqllogic +156 -0
- package/test/logic/07.9-in-value-list.sqllogic +154 -0
- package/test/logic/07.9.1-in-value-list-composite-index.sqllogic +38 -0
- package/test/logic/08-views.sqllogic +64 -0
- package/test/logic/08.1-semi-anti-join.sqllogic +191 -0
- package/test/logic/08.1-view-edge-cases.sqllogic +118 -0
- package/test/logic/08.1.1-uncorrelated-in-semijoin.sqllogic +251 -0
- package/test/logic/08.2-existence-flag-semijoin-recovery.sqllogic +197 -0
- package/test/logic/08.3-existence-flag-inner-recovery.sqllogic +102 -0
- package/test/logic/08.4-key-set-semi-join.sqllogic +447 -0
- package/test/logic/09-set_operations.sqllogic +244 -0
- package/test/logic/09.1-set-op-cross-collation.sqllogic +230 -0
- package/test/logic/10-distinct_datatypes.sqllogic +127 -0
- package/test/logic/10.1-ddl-lifecycle.sqllogic +203 -0
- package/test/logic/10.1.1-create-table-syntax-edges.sqllogic +47 -0
- package/test/logic/10.1.2-ddl-in-transaction.sqllogic +143 -0
- package/test/logic/10.1.2.1-add-constraint-in-transaction.sqllogic +59 -0
- package/test/logic/10.1.3-ddl-drop-in-transaction.sqllogic +187 -0
- package/test/logic/10.1.3.1-drop-constraint-in-transaction.sqllogic +45 -0
- package/test/logic/10.1.4-create-table-duplicate-constraint-names.sqllogic +149 -0
- package/test/logic/10.1.4-ddl-transaction-policy.sqllogic +314 -0
- package/test/logic/10.1.5-alter-add-constraint-minted-name-disambiguation.sqllogic +219 -0
- package/test/logic/10.1.5-create-index-lifecycle.sqllogic +72 -0
- package/test/logic/10.1.6-ddl-transaction-policy-index.sqllogic +143 -0
- package/test/logic/10.1.7-create-table-default-type-check.sqllogic +119 -0
- package/test/logic/10.1.8-alter-add-check-existing-rows.sqllogic +117 -0
- package/test/logic/10.2-column-features.sqllogic +365 -0
- package/test/logic/10.2.1-table-options-rejection.sqllogic +63 -0
- package/test/logic/10.2.2-default-collation-memory.sqllogic +30 -0
- package/test/logic/10.3-function-features.sqllogic +247 -0
- package/test/logic/10.4-schema-scale.sqllogic +168 -0
- package/test/logic/10.4.1-schema-scale-indexes.sqllogic +121 -0
- package/test/logic/10.5-indexes.sqllogic +164 -0
- package/test/logic/10.5.1-partial-indexes.sqllogic +526 -0
- package/test/logic/10.5.2-expression-indexes.sqllogic +34 -0
- package/test/logic/10.5.3-desc-index-ordering.sqllogic +130 -0
- package/test/logic/10.5.4-composite-pk-index-update-phantom.sqllogic +55 -0
- package/test/logic/10.5.5-index-name-uniqueness.sqllogic +76 -0
- package/test/logic/10.5.6-minmax-index-boundary.sqllogic +204 -0
- package/test/logic/10.5.7-implicit-unique-index-lifecycle.sqllogic +1216 -0
- package/test/logic/10.6-distinct-edge-cases.sqllogic +119 -0
- package/test/logic/100-predicate-normalization-edge-cases.sqllogic +238 -0
- package/test/logic/100.1-where-extras.sqllogic +163 -0
- package/test/logic/100.1.1-where-join-on-order-indexed.sqllogic +35 -0
- package/test/logic/101-builtin-mutation-kills.sqllogic +974 -0
- package/test/logic/101-transaction-edge-cases.sqllogic +395 -0
- package/test/logic/102-schema-catalog-edge-cases.sqllogic +252 -0
- package/test/logic/102-unique-constraints.sqllogic +145 -0
- package/test/logic/102.0.1-schema-catalog-indexed-table.sqllogic +32 -0
- package/test/logic/102.1-unique-edge-cases.sqllogic +111 -0
- package/test/logic/102.1.1-unique-index-creation-edge-cases.sqllogic +75 -0
- package/test/logic/102.2-unique-collation.sqllogic +181 -0
- package/test/logic/102.2.1-unique-collation-index-derived.sqllogic +305 -0
- package/test/logic/103-database-options-edge-cases.sqllogic +108 -0
- package/test/logic/103.1-pragma-boolean-values.sqllogic +126 -0
- package/test/logic/104-emit-mutation-kills.sqllogic +236 -0
- package/test/logic/105-vtab-memory-mutation-kills.sqllogic +754 -0
- package/test/logic/105.1-vtab-memory-index-mutation-kills.sqllogic +540 -0
- package/test/logic/106-constraint-extractor-mutation-kills.sqllogic +350 -0
- package/test/logic/107-temporal-arithmetic-mutation-kills.sqllogic +833 -0
- package/test/logic/108-cardinality-estimation.sqllogic +146 -0
- package/test/logic/108.1-analyze-name-resolution.sqllogic +102 -0
- package/test/logic/109-aggregate-physical-selection.sqllogic +103 -0
- package/test/logic/11-joins.sqllogic +86 -0
- package/test/logic/11.1-join-using.sqllogic +267 -0
- package/test/logic/11.2-comma-join.sqllogic +35 -0
- package/test/logic/11.3-index-nested-loop-join.sqllogic +305 -0
- package/test/logic/11.3-mismatched-collation-join.sqllogic +74 -0
- package/test/logic/11.4-hash-join-side-swap.sqllogic +118 -0
- package/test/logic/110-scan-emitter-mutation-kills.sqllogic +121 -0
- package/test/logic/110.1-scan-emitter-index-scan-kills.sqllogic +47 -0
- package/test/logic/12-empty-primary-key.sqllogic +124 -0
- package/test/logic/12-join_padding_order.sqllogic +58 -0
- package/test/logic/12.1-orderby-index-consumption.sqllogic +40 -0
- package/test/logic/13-cte.sqllogic +137 -0
- package/test/logic/13.1-cte-multiple-recursive.sqllogic +104 -0
- package/test/logic/13.10-cte-qualified-name.sqllogic +136 -0
- package/test/logic/13.11-unreferenced-dml-cte.sqllogic +414 -0
- package/test/logic/13.12-nested-dml-cte-rejected.sqllogic +280 -0
- package/test/logic/13.2-cte-bind-params.sqllogic +98 -0
- package/test/logic/13.3-cte-edge-cases.sqllogic +120 -0
- package/test/logic/13.4-cte-extras.sqllogic +98 -0
- package/test/logic/13.5-cte-join-order.sqllogic +166 -0
- package/test/logic/13.6-cte-dml-runs-once.sqllogic +318 -0
- package/test/logic/13.7-cte-sibling-visibility.sqllogic +227 -0
- package/test/logic/13.8-insert-with-clause-visibility.sqllogic +254 -0
- package/test/logic/13.9-schema-authored-cte-isolation.sqllogic +328 -0
- package/test/logic/13.9.1-schema-authored-schema-path-isolation.sqllogic +408 -0
- package/test/logic/14-utilities.sqllogic +168 -0
- package/test/logic/15-timespan.sqllogic +279 -0
- package/test/logic/15.1-semantic-ordering.sqllogic +960 -0
- package/test/logic/15.1.1-json-check-coercion.sqllogic +178 -0
- package/test/logic/15.1.2-semantic-ordering-index.sqllogic +41 -0
- package/test/logic/15.1.3-declared-form-write-contract.sqllogic +519 -0
- package/test/logic/16-epoch.sqllogic +187 -0
- package/test/logic/17-weekday-modifier.sqllogic +78 -0
- package/test/logic/18-json-string-escapes.sqllogic +86 -0
- package/test/logic/18-strftime-extended-formats.sqllogic +68 -0
- package/test/logic/20-empty-single-row.sqllogic +261 -0
- package/test/logic/21-null-edge-cases.sqllogic +227 -0
- package/test/logic/21.1-where-null-comparisons.sqllogic +151 -0
- package/test/logic/21.1.1-where-null-comparisons-secondary-index.sqllogic +35 -0
- package/test/logic/21.2-between-edges.sqllogic +157 -0
- package/test/logic/22-boundary-values.sqllogic +175 -0
- package/test/logic/23-self-joins-duplicates.sqllogic +74 -0
- package/test/logic/24-builtin-branches.sqllogic +611 -0
- package/test/logic/24.1-substr-extras.sqllogic +75 -0
- package/test/logic/24.2-random-extras.sqllogic +39 -0
- package/test/logic/25-aggregate-edge-cases.sqllogic +289 -0
- package/test/logic/25.1-nested-aggregates.sqllogic +74 -0
- package/test/logic/25.2-having-edge-cases.sqllogic +318 -0
- package/test/logic/25.3-aggregate-isnull-empty.sqllogic +16 -0
- package/test/logic/25.4-groupby-fd-constant-empty.sqllogic +55 -0
- package/test/logic/25.5-ungrouped-aggregate-column-free-select-item.sqllogic +196 -0
- package/test/logic/26-join-edge-cases.sqllogic +333 -0
- package/test/logic/26.1-left-join-isnull-on-notnull.sqllogic +26 -0
- package/test/logic/26.2-left-join-on-vs-where.sqllogic +67 -0
- package/test/logic/26.3-join-on-constants.sqllogic +61 -0
- package/test/logic/26.4-join-on-is-null-nullable.sqllogic +44 -0
- package/test/logic/27-window-edge-cases.sqllogic +206 -0
- package/test/logic/27.1-window-groups-frame.sqllogic +13 -0
- package/test/logic/27.2-window-exclude.sqllogic +13 -0
- package/test/logic/27.3-window-json-aggregation.sqllogic +66 -0
- package/test/logic/28-set-ops-sort-edge-cases.sqllogic +444 -0
- package/test/logic/28.1-compound-limit-offset.sqllogic +143 -0
- package/test/logic/28.2-orderby-expression-extras.sqllogic +698 -0
- package/test/logic/28.2-set-op-branch-types.sqllogic +217 -0
- package/test/logic/29-constraint-edge-cases.sqllogic +442 -0
- package/test/logic/29.1-column-level-conflict-clause.sqllogic +171 -0
- package/test/logic/29.2-table-level-pk-conflict-clause.sqllogic +113 -0
- package/test/logic/40-constraints.sqllogic +418 -0
- package/test/logic/40.1-pk-desc-direction.sqllogic +76 -0
- package/test/logic/40.2-check-extras.sqllogic +683 -0
- package/test/logic/41-alter-table.sqllogic +191 -0
- package/test/logic/41-fk-cascade-conflict-and-self-ref.sqllogic +263 -0
- package/test/logic/41-fk-cross-schema.sqllogic +155 -0
- package/test/logic/41-fk-extended-targets.sqllogic +173 -0
- package/test/logic/41-foreign-keys.sqllogic +1001 -0
- package/test/logic/41-generated-column-errors.sqllogic +225 -0
- package/test/logic/41-generated-column-extras.sqllogic +598 -0
- package/test/logic/41-generated-column-scope.sqllogic +329 -0
- package/test/logic/41-generated-columns.sqllogic +361 -0
- package/test/logic/41.1-alter-pk.sqllogic +230 -0
- package/test/logic/41.1-fk-collation-conflict.sqllogic +277 -0
- package/test/logic/41.10-alter-drop-column-foreign-key.sqllogic +274 -0
- package/test/logic/41.10.1-alter-drop-column-unique-index.sqllogic +169 -0
- package/test/logic/41.10.2-alter-drop-column-check-and-assertion.sqllogic +1616 -0
- package/test/logic/41.10.3-alter-drop-column-referencing-fk.sqllogic +292 -0
- package/test/logic/41.10.4-drop-object-expression-dependents.sqllogic +602 -0
- package/test/logic/41.11-deferred-fk-with-rename.sqllogic +232 -0
- package/test/logic/41.12-alter-default-coercion.sqllogic +200 -0
- package/test/logic/41.13-alter-add-column-generated-backfill.sqllogic +566 -0
- package/test/logic/41.14-alter-add-column-subquery-backfill.sqllogic +129 -0
- package/test/logic/41.15-alter-column-default-type-check.sqllogic +178 -0
- package/test/logic/41.16-fk-unenforceable.sqllogic +364 -0
- package/test/logic/41.2-alter-column.sqllogic +382 -0
- package/test/logic/41.2.1-alter-column-retype-deleted-row-memory.sqllogic +32 -0
- package/test/logic/41.2.2-alter-column-retype-index-rebuild.sqllogic +77 -0
- package/test/logic/41.2.3-alter-column-set-not-null-pk-backfill.sqllogic +310 -0
- package/test/logic/41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic +37 -0
- package/test/logic/41.3-alter-add-column-unique.sqllogic +184 -0
- package/test/logic/41.3-alter-rename-propagation.sqllogic +2352 -0
- package/test/logic/41.3.1-alter-rename-index-propagation.sqllogic +94 -0
- package/test/logic/41.4-alter-add-column-constraints.sqllogic +855 -0
- package/test/logic/41.5-alter-misc.sqllogic +48 -0
- package/test/logic/41.5-cross-schema-foreign-keys.sqllogic +253 -0
- package/test/logic/41.6-alter-drop-rename-constraint.sqllogic +354 -0
- package/test/logic/41.6.1-alter-drop-constraint-index-derived.sqllogic +22 -0
- package/test/logic/41.7-alter-column-collate.sqllogic +105 -0
- package/test/logic/41.7.1-alter-column-collate-unique.sqllogic +45 -0
- package/test/logic/41.7.2-alter-column-collate-unique-store.sqllogic +208 -0
- package/test/logic/41.7.2.1-alter-column-collate-unique-index-store.sqllogic +114 -0
- package/test/logic/41.7.3-alter-column-retype-unique.sqllogic +293 -0
- package/test/logic/41.7.3.1-alter-column-retype-staged-rows-memory.sqllogic +41 -0
- package/test/logic/41.7.3.2-alter-column-retype-unique-index.sqllogic +72 -0
- package/test/logic/41.7.4-alter-column-retype-semantic-memory.sqllogic +445 -0
- package/test/logic/41.7.4.1-alter-column-retype-semantic-index-memory.sqllogic +91 -0
- package/test/logic/41.7.5-alter-column-collate-pk-staged-delete-memory.sqllogic +106 -0
- package/test/logic/41.8-alter-add-constraint-unique-fk.sqllogic +275 -0
- package/test/logic/41.8-alter-savepoint-staged-rows.sqllogic +443 -0
- package/test/logic/41.8.1-alter-rename-savepoint-staged-rows.sqllogic +408 -0
- package/test/logic/41.9-alter-constraint-body-change.sqllogic +180 -0
- package/test/logic/41.9-fk-restrict-batched.sqllogic +290 -0
- package/test/logic/42-committed-snapshot.sqllogic +254 -0
- package/test/logic/42-returning.sqllogic +159 -0
- package/test/logic/42.1-returning-extras.sqllogic +232 -0
- package/test/logic/42.2-returning-stored-row.sqllogic +165 -0
- package/test/logic/43-default-nullability.sqllogic +131 -0
- package/test/logic/43-transition-constraints.sqllogic +341 -0
- package/test/logic/43.1-default-collation.sqllogic +140 -0
- package/test/logic/43.1-notnull-or-conflict.sqllogic +79 -0
- package/test/logic/43.2-deferred-check-new-on-delete.sqllogic +95 -0
- package/test/logic/43.3-nullable-primary-key.sqllogic +587 -0
- package/test/logic/44-determinism-validation.sqllogic +164 -0
- package/test/logic/44-orthogonality.sqllogic +146 -0
- package/test/logic/44.1-nondeterministic-schema.sqllogic +316 -0
- package/test/logic/45-udf-determinism.sqllogic +39 -0
- package/test/logic/46-mutation-context.sqllogic +595 -0
- package/test/logic/47-upsert.sqllogic +255 -0
- package/test/logic/47.1-upsert-conflict-targets.sqllogic +169 -0
- package/test/logic/47.2-replace-and-or-clauses.sqllogic +164 -0
- package/test/logic/47.2.1-pk-replace-secondary-unique.sqllogic +374 -0
- package/test/logic/47.3-engine-or-fail.sqllogic +122 -0
- package/test/logic/47.3-upsert-conflict-target-collation.sqllogic +139 -0
- package/test/logic/47.3.1-upsert-conflict-index-derived-collation.sqllogic +25 -0
- package/test/logic/47.4-upsert-conflict-target-affinity.sqllogic +59 -0
- package/test/logic/47.5-upsert-do-update-constraints.sqllogic +440 -0
- package/test/logic/47.6-upsert-do-update-decomposed.sqllogic +100 -0
- package/test/logic/49-reference-graph.sqllogic +84 -0
- package/test/logic/50-declarative-schema.sqllogic +2550 -0
- package/test/logic/50-metadata-tags.sqllogic +1033 -0
- package/test/logic/50.0.1-metadata-tags-index.sqllogic +141 -0
- package/test/logic/50.1-declare-schema-pk.sqllogic +150 -0
- package/test/logic/50.2-declare-schema-renames.sqllogic +949 -0
- package/test/logic/50.2.1-declare-schema-index-renames.sqllogic +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,230 @@
|
|
|
1
|
+
-- Set-operation cross-input collation merge. Ticket
|
|
2
|
+
-- set-operation-cross-input-collation-merge. Each set-op output column resolves
|
|
3
|
+
-- its dedup/compare collation across BOTH inputs through the same provenance-
|
|
4
|
+
-- ranked comparison lattice (explicit > declared > default > BINARY, symmetric,
|
|
5
|
+
-- plan-time error on same-rank explicit/declared conflicts) used by ordinary
|
|
6
|
+
-- comparisons and join keys. The resolved collation is written into the node's
|
|
7
|
+
-- output column/attribute types, so the dedup/membership comparator AND an
|
|
8
|
+
-- enclosing ORDER BY both read it from there — lockstep is structural.
|
|
9
|
+
--
|
|
10
|
+
-- DISTINCT operators (UNION/INTERSECT/EXCEPT/DIFF) dedup, so a same-rank
|
|
11
|
+
-- explicit/declared conflict is a prepare-time error; UNION ALL does no dedup,
|
|
12
|
+
-- so it never errors (it propagates no collation, like `||` / CASE).
|
|
13
|
+
-- See docs/types.md § Comparison collation resolution (set operations).
|
|
14
|
+
|
|
15
|
+
create table cl (id integer primary key, n text collate nocase, p text, r text collate rtrim);
|
|
16
|
+
create table cr (id integer primary key, n text collate nocase, p text, r text collate rtrim);
|
|
17
|
+
insert into cl values (1, 'Apple', 'Apple', 'Apple'), (2, 'Banana', 'Banana', 'Banana');
|
|
18
|
+
insert into cr values (1, 'apple', 'apple', 'apple'), (2, 'cherry', 'cherry', 'cherry');
|
|
19
|
+
|
|
20
|
+
-- =============================================================================
|
|
21
|
+
-- 1. Branch-order symmetry (the headline fix). A declared-NOCASE column on one
|
|
22
|
+
-- side and a plain (defaulted-BINARY) column on the other resolves NOCASE
|
|
23
|
+
-- from EITHER branch order, so the union dedups case-insensitively both ways
|
|
24
|
+
-- ('Apple'/'apple' fold → 3 distinct, not 4). Previously the LEFT input's
|
|
25
|
+
-- collation alone drove dedup, so swapping branches flipped NOCASE↔BINARY.
|
|
26
|
+
-- =============================================================================
|
|
27
|
+
|
|
28
|
+
select count(*) as c from (select n from cl union select p from cr);
|
|
29
|
+
→ [{"c":3}]
|
|
30
|
+
|
|
31
|
+
-- reversed: declared NOCASE now on the right; identical dedup (was BINARY → 4).
|
|
32
|
+
select count(*) as c from (select p from cr union select n from cl);
|
|
33
|
+
→ [{"c":3}]
|
|
34
|
+
|
|
35
|
+
-- =============================================================================
|
|
36
|
+
-- 2. Explicit COLLATE both sides. Same name resolves and dedups under it;
|
|
37
|
+
-- different names are a rank-3 prepare-time conflict (both orders).
|
|
38
|
+
-- =============================================================================
|
|
39
|
+
|
|
40
|
+
select count(*) as c from (select n collate nocase from cl union select p collate nocase from cr);
|
|
41
|
+
→ [{"c":3}]
|
|
42
|
+
|
|
43
|
+
select n collate nocase from cl union select p collate rtrim from cr;
|
|
44
|
+
-- error: conflicting COLLATE clauses
|
|
45
|
+
|
|
46
|
+
select p collate rtrim from cr union select n collate nocase from cl;
|
|
47
|
+
-- error: conflicting COLLATE clauses
|
|
48
|
+
|
|
49
|
+
-- =============================================================================
|
|
50
|
+
-- 3. Declared both sides. Same declared collation resolves; different declared
|
|
51
|
+
-- collations are a rank-2 ambiguous-collation error (both orders). An
|
|
52
|
+
-- explicit COLLATE on one side disambiguates.
|
|
53
|
+
-- =============================================================================
|
|
54
|
+
|
|
55
|
+
select count(*) as c from (select n from cl union select n from cr);
|
|
56
|
+
→ [{"c":3}]
|
|
57
|
+
|
|
58
|
+
select n from cl union select r from cr;
|
|
59
|
+
-- error: ambiguous collation
|
|
60
|
+
|
|
61
|
+
select r from cr union select n from cl;
|
|
62
|
+
-- error: ambiguous collation
|
|
63
|
+
|
|
64
|
+
-- explicit COLLATE outranks the conflicted declared pair (rank 3 > rank 2).
|
|
65
|
+
select count(*) as c from (select n from cl union select r collate nocase from cr);
|
|
66
|
+
→ [{"c":3}]
|
|
67
|
+
|
|
68
|
+
-- =============================================================================
|
|
69
|
+
-- 4. Default-vs-default conflict resolves to BINARY SILENTLY (no error) —
|
|
70
|
+
-- defaults are preferences, not declarations. Tables created under different
|
|
71
|
+
-- session default_collations. 'Bob'/'bob' fold only under NOCASE, 'bob '/'bob'
|
|
72
|
+
-- only under RTRIM; under BINARY all three are distinct, so 3 proves BINARY.
|
|
73
|
+
-- =============================================================================
|
|
74
|
+
|
|
75
|
+
pragma default_collation='nocase';
|
|
76
|
+
create table dn (id integer primary key, v text);
|
|
77
|
+
pragma default_collation='rtrim';
|
|
78
|
+
create table dr (id integer primary key, w text);
|
|
79
|
+
pragma default_collation='binary';
|
|
80
|
+
|
|
81
|
+
insert into dn values (1, 'Bob'), (2, 'bob ');
|
|
82
|
+
insert into dr values (1, 'bob');
|
|
83
|
+
|
|
84
|
+
select count(*) as c from (select v from dn union select w from dr);
|
|
85
|
+
→ [{"c":3}]
|
|
86
|
+
select count(*) as c from (select w from dr union select v from dn);
|
|
87
|
+
→ [{"c":3}]
|
|
88
|
+
|
|
89
|
+
drop table dn;
|
|
90
|
+
drop table dr;
|
|
91
|
+
|
|
92
|
+
-- =============================================================================
|
|
93
|
+
-- 5. UNION ALL never errors. Two divergent EXPLICIT collations would be a hard
|
|
94
|
+
-- conflict for any DISTINCT operator, but UNION ALL does no dedup, so the
|
|
95
|
+
-- output column carries no collation and every input row passes through
|
|
96
|
+
-- unchanged (bag: 2 + 2 = 4). This is the easiest place to wrongly throw.
|
|
97
|
+
-- =============================================================================
|
|
98
|
+
|
|
99
|
+
select count(*) as c from (select n collate nocase from cl union all select p collate rtrim from cr);
|
|
100
|
+
→ [{"c":4}]
|
|
101
|
+
|
|
102
|
+
-- divergent DECLARED collations under UNION ALL: also no error.
|
|
103
|
+
select count(*) as c from (select n from cl union all select r from cr);
|
|
104
|
+
→ [{"c":4}]
|
|
105
|
+
|
|
106
|
+
-- =============================================================================
|
|
107
|
+
-- 6. INTERSECT / EXCEPT membership follows the SAME resolved collation as UNION
|
|
108
|
+
-- over the same inputs. Under NOCASE: 'Apple' ∩ {'apple','cherry'} matches
|
|
109
|
+
-- (1 row); {'Apple','Banana'} − {'apple','cherry'} keeps only 'Banana' (1
|
|
110
|
+
-- row). Under BINARY these would be 0 and 2.
|
|
111
|
+
-- =============================================================================
|
|
112
|
+
|
|
113
|
+
select count(*) as c from (select n from cl intersect select p from cr);
|
|
114
|
+
→ [{"c":1}]
|
|
115
|
+
select count(*) as c from (select n from cl except select p from cr);
|
|
116
|
+
→ [{"c":1}]
|
|
117
|
+
|
|
118
|
+
-- INTERSECT yields the LEFT row; it still reports the resolved collation.
|
|
119
|
+
select n from cl intersect select p from cr;
|
|
120
|
+
→ [{"n":"Apple"}]
|
|
121
|
+
select n from cl except select p from cr;
|
|
122
|
+
→ [{"n":"Banana"}]
|
|
123
|
+
|
|
124
|
+
-- =============================================================================
|
|
125
|
+
-- 7. Nested set operations / forward propagation. The inner union resolves to
|
|
126
|
+
-- NOCASE at rank 2 (declared wins over the plain side), and that rank rides
|
|
127
|
+
-- into the inner node's OUTPUT column collation. The outer union then sees
|
|
128
|
+
-- NOCASE(2) vs declared RTRIM(2) → conflict. Were the inner rank demoted to
|
|
129
|
+
-- 1, RTRIM would silently win — so the error firing pins rank propagation.
|
|
130
|
+
-- =============================================================================
|
|
131
|
+
|
|
132
|
+
(select n from cl union select p from cr) union select r from cr;
|
|
133
|
+
-- error: ambiguous collation
|
|
134
|
+
|
|
135
|
+
-- inner resolves NOCASE, outer NOCASE vs declared NOCASE → resolves (no error).
|
|
136
|
+
-- Deterministic union order (left-first, input order): Apple, Banana, cherry.
|
|
137
|
+
(select n from cl union select p from cr) union select n from cr;
|
|
138
|
+
→ [{"n":"Apple"},{"n":"Banana"},{"n":"cherry"}]
|
|
139
|
+
|
|
140
|
+
-- =============================================================================
|
|
141
|
+
-- 8. Multi-column alignment. Each column resolves independently; a conflict in
|
|
142
|
+
-- ANY column errors the whole statement even when the others resolve. Here
|
|
143
|
+
-- column 1 resolves (NOCASE both) but column 2 conflicts (NOCASE vs RTRIM).
|
|
144
|
+
-- =============================================================================
|
|
145
|
+
|
|
146
|
+
create table m1 (id integer primary key, a text collate nocase, b text collate nocase);
|
|
147
|
+
create table m2 (id integer primary key, a text collate nocase, b text collate rtrim);
|
|
148
|
+
insert into m1 values (1, 'x', 'y');
|
|
149
|
+
insert into m2 values (1, 'x', 'y');
|
|
150
|
+
|
|
151
|
+
select a, b from m1 union select a, b from m2;
|
|
152
|
+
-- error: ambiguous collation
|
|
153
|
+
|
|
154
|
+
drop table m1;
|
|
155
|
+
drop table m2;
|
|
156
|
+
|
|
157
|
+
-- =============================================================================
|
|
158
|
+
-- 9. ORDER BY lockstep (end-to-end). The outer ORDER BY keys off the union's
|
|
159
|
+
-- RESOLVED output-column collation (NOCASE), not the left input's raw type.
|
|
160
|
+
-- 'apple' < 'banana' < 'Cherry' under NOCASE; under BINARY 'Cherry' (C=67)
|
|
161
|
+
-- would sort before the lowercase letters, so the order proves NOCASE.
|
|
162
|
+
-- =============================================================================
|
|
163
|
+
|
|
164
|
+
create table o1 (id integer primary key, n text collate nocase);
|
|
165
|
+
create table o2 (id integer primary key, p text);
|
|
166
|
+
insert into o1 values (1, 'banana');
|
|
167
|
+
insert into o2 values (1, 'Cherry'), (2, 'apple');
|
|
168
|
+
|
|
169
|
+
select n from o1 union select p from o2 order by n;
|
|
170
|
+
→ [{"n":"apple"},{"n":"banana"},{"n":"Cherry"}]
|
|
171
|
+
|
|
172
|
+
-- Ordinal form keys off the SAME resolved NOCASE output column (ticket
|
|
173
|
+
-- compound-order-by-ordinal-reference): `order by 1` resolves to output column 1
|
|
174
|
+
-- and inherits its resolved collation, so it sorts identically to the name form.
|
|
175
|
+
select n from o1 union select p from o2 order by 1;
|
|
176
|
+
→ [{"n":"apple"},{"n":"banana"},{"n":"Cherry"}]
|
|
177
|
+
|
|
178
|
+
drop table o1;
|
|
179
|
+
drop table o2;
|
|
180
|
+
|
|
181
|
+
-- =============================================================================
|
|
182
|
+
-- 10. Membership-flag set operations. Data columns resolve cross-input; the
|
|
183
|
+
-- appended `exists … as` flag columns are never touched. The data column
|
|
184
|
+
-- still dedups under the resolved NOCASE (3 distinct), and a divergent
|
|
185
|
+
-- declared data-column collation still errors on the DATA column only.
|
|
186
|
+
-- =============================================================================
|
|
187
|
+
|
|
188
|
+
select count(*) as c from (select n from cl union exists left as inL select p from cr);
|
|
189
|
+
→ [{"c":3}]
|
|
190
|
+
|
|
191
|
+
select n from cl union exists left as inL select r from cr;
|
|
192
|
+
-- error: ambiguous collation
|
|
193
|
+
|
|
194
|
+
-- =============================================================================
|
|
195
|
+
-- 11. DIFF (symmetric difference) expands to (A except B) union (B except A);
|
|
196
|
+
-- each nested except is a DISTINCT operator, so divergent declared
|
|
197
|
+
-- collations surface the conflict. A resolving DIFF folds under NOCASE:
|
|
198
|
+
-- {'Banana'} ∪ {'cherry'} = 2 (BINARY would give 4).
|
|
199
|
+
-- =============================================================================
|
|
200
|
+
|
|
201
|
+
select n from cl diff select r from cr;
|
|
202
|
+
-- error: ambiguous collation
|
|
203
|
+
|
|
204
|
+
select count(*) as c from (select n from cl diff select p from cr);
|
|
205
|
+
→ [{"c":2}]
|
|
206
|
+
|
|
207
|
+
-- =============================================================================
|
|
208
|
+
-- 12. Materialized view over a cross-collation UNION. The union's resolved
|
|
209
|
+
-- output-column collation flows through `deriveBackingShape` into the
|
|
210
|
+
-- backing column (its provenance — declared here — publishes an explicit
|
|
211
|
+
-- backing collation), so the materialized result dedups under the SAME
|
|
212
|
+
-- resolved NOCASE the plain view would (3, not 4), in BOTH branch orders.
|
|
213
|
+
-- Locks in the implement handoff's highest-value gap (gap #3): an MV body's
|
|
214
|
+
-- union persists the symmetric resolved collation, not the left input's.
|
|
215
|
+
-- =============================================================================
|
|
216
|
+
|
|
217
|
+
create materialized view mv_xc as select n from cl union select p from cr;
|
|
218
|
+
select count(*) as c from mv_xc;
|
|
219
|
+
→ [{"c":3}]
|
|
220
|
+
|
|
221
|
+
-- reversed branch order persists the same NOCASE backing (was BINARY → 4).
|
|
222
|
+
create materialized view mv_xc2 as select p from cr union select n from cl;
|
|
223
|
+
select count(*) as c from mv_xc2;
|
|
224
|
+
→ [{"c":3}]
|
|
225
|
+
|
|
226
|
+
drop materialized view mv_xc;
|
|
227
|
+
drop materialized view mv_xc2;
|
|
228
|
+
|
|
229
|
+
drop table cl;
|
|
230
|
+
drop table cr;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
-- distinct_datatypes.sqllogic - Testing DISTINCT operations and data type behavior
|
|
2
|
+
|
|
3
|
+
-- Test DISTINCT operations
|
|
4
|
+
CREATE TABLE distinct_test (id INTEGER PRIMARY KEY, category TEXT, value INTEGER);
|
|
5
|
+
INSERT INTO distinct_test VALUES
|
|
6
|
+
(1, 'A', 100),
|
|
7
|
+
(2, 'B', 200),
|
|
8
|
+
(3, 'A', 100),
|
|
9
|
+
(4, 'B', 300),
|
|
10
|
+
(5, 'A', 200);
|
|
11
|
+
|
|
12
|
+
-- Basic DISTINCT
|
|
13
|
+
SELECT DISTINCT category FROM distinct_test ORDER BY category;
|
|
14
|
+
→ [{"category":"A"},{"category":"B"}]
|
|
15
|
+
|
|
16
|
+
-- DISTINCT with multiple columns
|
|
17
|
+
SELECT DISTINCT category, value FROM distinct_test ORDER BY category, value;
|
|
18
|
+
→ [{"category":"A","value":100},{"category":"A","value":200},{"category":"B","value":200},{"category":"B","value":300}]
|
|
19
|
+
|
|
20
|
+
-- DISTINCT with expressions
|
|
21
|
+
SELECT DISTINCT category, value * 2 as doubled FROM distinct_test ORDER BY category, doubled;
|
|
22
|
+
→ [{"category":"A","doubled":200},{"category":"A","doubled":400},{"category":"B","doubled":400},{"category":"B","doubled":600}]
|
|
23
|
+
|
|
24
|
+
-- DISTINCT in subqueries
|
|
25
|
+
SELECT category, (SELECT COUNT(DISTINCT value) FROM distinct_test d2 WHERE d2.category = d1.category) as unique_values
|
|
26
|
+
FROM distinct_test d1
|
|
27
|
+
GROUP BY category
|
|
28
|
+
ORDER BY category;
|
|
29
|
+
→ [{"category":"A","unique_values":2},{"category":"B","unique_values":2}]
|
|
30
|
+
|
|
31
|
+
DROP TABLE distinct_test;
|
|
32
|
+
|
|
33
|
+
-- Data type behavior tests
|
|
34
|
+
CREATE TABLE types_test (
|
|
35
|
+
id INTEGER PRIMARY KEY,
|
|
36
|
+
int_val INTEGER,
|
|
37
|
+
real_val REAL,
|
|
38
|
+
text_val TEXT,
|
|
39
|
+
blob_val BLOB,
|
|
40
|
+
null_val NULL
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
INSERT INTO types_test VALUES
|
|
44
|
+
(1, 42, 3.14, 'hello', x'deadbeef', NULL),
|
|
45
|
+
(2, -10, 0.0, '', x'', NULL),
|
|
46
|
+
(3, 0, -1.5, 'world', x'ff', NULL);
|
|
47
|
+
|
|
48
|
+
-- Test type coercion and comparison
|
|
49
|
+
SELECT int_val = '42' FROM types_test WHERE id = 1;
|
|
50
|
+
→ [{"int_val = '42'":true}]
|
|
51
|
+
|
|
52
|
+
-- Test NULL handling
|
|
53
|
+
SELECT null_val IS NULL, null_val = NULL FROM types_test WHERE id = 1;
|
|
54
|
+
→ [{"null_val is null":true,"null_val = null":null}]
|
|
55
|
+
|
|
56
|
+
-- Test type functions
|
|
57
|
+
SELECT typeof(int_val), typeof(real_val), typeof(text_val), typeof(blob_val), typeof(null_val)
|
|
58
|
+
FROM types_test WHERE id = 1;
|
|
59
|
+
→ [{"typeof(int_val)":"integer","typeof(real_val)":"real","typeof(text_val)":"text","typeof(blob_val)":"blob","typeof(null_val)":"null"}]
|
|
60
|
+
|
|
61
|
+
-- Test comparison across types
|
|
62
|
+
SELECT int_val < real_val FROM types_test WHERE id = 1;
|
|
63
|
+
→ [{"int_val < real_val":false}]
|
|
64
|
+
|
|
65
|
+
-- Test text/numeric conversion
|
|
66
|
+
SELECT '123' + 0, 'abc' + 0, '' + 0;
|
|
67
|
+
→ [{"'123' + 0":123,"'abc' + 0":0,"'' + 0":0}]
|
|
68
|
+
|
|
69
|
+
-- Test type affinity in tables
|
|
70
|
+
CREATE TABLE affinity_test (
|
|
71
|
+
int_col INTEGER,
|
|
72
|
+
real_col REAL,
|
|
73
|
+
text_col TEXT,
|
|
74
|
+
blob_col BLOB,
|
|
75
|
+
numeric_col NUMERIC
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
INSERT INTO affinity_test VALUES ('123', '45.6', 789, 'text_as_blob', '999.99');
|
|
79
|
+
SELECT typeof(int_col), typeof(real_col), typeof(text_col), typeof(blob_col), typeof(numeric_col)
|
|
80
|
+
FROM affinity_test;
|
|
81
|
+
→ [{"typeof(int_col)":"integer","typeof(real_col)":"real","typeof(text_col)":"text","typeof(blob_col)":"blob","typeof(numeric_col)":"real"}]
|
|
82
|
+
|
|
83
|
+
DROP TABLE affinity_test;
|
|
84
|
+
DROP TABLE types_test;
|
|
85
|
+
|
|
86
|
+
-- Type coercion consistency tests
|
|
87
|
+
CREATE TABLE coerce_test (id INTEGER PRIMARY KEY, a ANY, b ANY);
|
|
88
|
+
|
|
89
|
+
-- Test numeric coercion consistency
|
|
90
|
+
INSERT INTO coerce_test VALUES (1, 5, '3'), (2, '2.5', 4), (3, true, false);
|
|
91
|
+
|
|
92
|
+
-- Expression should work consistently in different contexts
|
|
93
|
+
SELECT (a + b) FROM coerce_test WHERE id = 1;
|
|
94
|
+
→ [{"a + b":8}]
|
|
95
|
+
|
|
96
|
+
SELECT id FROM coerce_test WHERE (a + b) = 8;
|
|
97
|
+
→ [{"id":1}]
|
|
98
|
+
|
|
99
|
+
SELECT (a + b) FROM coerce_test WHERE id = 2;
|
|
100
|
+
→ [{"a + b":6.5}]
|
|
101
|
+
|
|
102
|
+
SELECT id FROM coerce_test WHERE (a + b) = 6.5;
|
|
103
|
+
→ [{"id":2}]
|
|
104
|
+
|
|
105
|
+
-- Boolean arithmetic
|
|
106
|
+
SELECT (a + b) FROM coerce_test WHERE id = 3;
|
|
107
|
+
→ [{"a + b":1}]
|
|
108
|
+
|
|
109
|
+
SELECT id FROM coerce_test WHERE (a + b) = 1;
|
|
110
|
+
→ [{"id":3}]
|
|
111
|
+
|
|
112
|
+
-- Test string/numeric boundary cases
|
|
113
|
+
DELETE FROM coerce_test;
|
|
114
|
+
INSERT INTO coerce_test VALUES (1, '10', '20'), (2, 'abc', 'def');
|
|
115
|
+
|
|
116
|
+
-- Numeric strings should work
|
|
117
|
+
SELECT (a + b) FROM coerce_test WHERE id = 1;
|
|
118
|
+
→ [{"a + b":30}]
|
|
119
|
+
|
|
120
|
+
-- Non-numeric strings should fail gracefully - test that it errors consistently
|
|
121
|
+
-- error: Invalid operation
|
|
122
|
+
-- SELECT (a + b) FROM coerce_test WHERE id = 2;
|
|
123
|
+
|
|
124
|
+
-- error: Invalid operation
|
|
125
|
+
-- SELECT id FROM coerce_test WHERE (a + b) = 'should_fail';
|
|
126
|
+
|
|
127
|
+
DROP TABLE coerce_test;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
-- DDL lifecycle: CREATE, INSERT, ALTER, DROP, and schema+transaction interaction
|
|
2
|
+
|
|
3
|
+
-- ===================================
|
|
4
|
+
-- 1. Basic DDL Lifecycle
|
|
5
|
+
-- ===================================
|
|
6
|
+
-- CREATE TABLE → INSERT data → verify → DROP TABLE → verify table gone
|
|
7
|
+
|
|
8
|
+
create table lifecycle (id integer primary key, name text);
|
|
9
|
+
|
|
10
|
+
insert into lifecycle values (1, 'Alice'), (2, 'Bob');
|
|
11
|
+
|
|
12
|
+
select * from lifecycle order by id;
|
|
13
|
+
→ [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
|
|
14
|
+
|
|
15
|
+
-- Verify count
|
|
16
|
+
select count(*) as cnt from lifecycle;
|
|
17
|
+
→ [{"cnt": 2}]
|
|
18
|
+
|
|
19
|
+
-- Update a row
|
|
20
|
+
update lifecycle set name = 'Alicia' where id = 1;
|
|
21
|
+
|
|
22
|
+
select name from lifecycle where id = 1;
|
|
23
|
+
→ [{"name": "Alicia"}]
|
|
24
|
+
|
|
25
|
+
-- Delete a row
|
|
26
|
+
delete from lifecycle where id = 2;
|
|
27
|
+
|
|
28
|
+
select count(*) as cnt from lifecycle;
|
|
29
|
+
→ [{"cnt": 1}]
|
|
30
|
+
|
|
31
|
+
-- Drop the table
|
|
32
|
+
drop table lifecycle;
|
|
33
|
+
|
|
34
|
+
-- Verify table is gone
|
|
35
|
+
select * from lifecycle;
|
|
36
|
+
-- error: not found in schema path
|
|
37
|
+
|
|
38
|
+
-- ===================================
|
|
39
|
+
-- 2. IF NOT EXISTS / IF EXISTS
|
|
40
|
+
-- ===================================
|
|
41
|
+
|
|
42
|
+
create table safe_create (id integer primary key, val text);
|
|
43
|
+
insert into safe_create values (1, 'original');
|
|
44
|
+
|
|
45
|
+
-- CREATE TABLE IF NOT EXISTS on existing table is a no-op
|
|
46
|
+
create table if not exists safe_create (id integer primary key, val text);
|
|
47
|
+
|
|
48
|
+
-- Data should be intact (not reset)
|
|
49
|
+
select val from safe_create where id = 1;
|
|
50
|
+
→ [{"val": "original"}]
|
|
51
|
+
|
|
52
|
+
-- Insert still works
|
|
53
|
+
insert into safe_create values (2, 'added');
|
|
54
|
+
|
|
55
|
+
select count(*) as cnt from safe_create;
|
|
56
|
+
→ [{"cnt": 2}]
|
|
57
|
+
|
|
58
|
+
-- DROP TABLE IF EXISTS on existing table removes it
|
|
59
|
+
drop table if exists safe_create;
|
|
60
|
+
|
|
61
|
+
-- DROP TABLE IF EXISTS on missing table is a no-op
|
|
62
|
+
drop table if exists safe_create;
|
|
63
|
+
|
|
64
|
+
-- Verify table is gone
|
|
65
|
+
select * from safe_create;
|
|
66
|
+
-- error: not found in schema path
|
|
67
|
+
|
|
68
|
+
-- ===================================
|
|
69
|
+
-- 3. CREATE INDEX Lifecycle
|
|
70
|
+
-- ===================================
|
|
71
|
+
-- Lives in 10.1.5-create-index-lifecycle (it needs standalone index DDL).
|
|
72
|
+
|
|
73
|
+
-- ===================================
|
|
74
|
+
-- 4. Schema + Transaction Interaction
|
|
75
|
+
-- ===================================
|
|
76
|
+
-- Note: Schema (DDL) changes take effect immediately and are NOT
|
|
77
|
+
-- rolled back by transaction rollback. Only data changes are rolled back.
|
|
78
|
+
|
|
79
|
+
-- 4a. INSERT data, BEGIN, INSERT more, ROLLBACK — new inserts gone, old data intact
|
|
80
|
+
create table tx_schema (id integer primary key, val text);
|
|
81
|
+
insert into tx_schema values (1, 'committed');
|
|
82
|
+
|
|
83
|
+
begin;
|
|
84
|
+
insert into tx_schema values (2, 'will-rollback');
|
|
85
|
+
|
|
86
|
+
select count(*) as cnt from tx_schema;
|
|
87
|
+
→ [{"cnt": 2}]
|
|
88
|
+
|
|
89
|
+
rollback;
|
|
90
|
+
|
|
91
|
+
-- Row 2 should be rolled back, row 1 intact
|
|
92
|
+
select count(*) as cnt from tx_schema;
|
|
93
|
+
→ [{"cnt": 1}]
|
|
94
|
+
|
|
95
|
+
select val from tx_schema where id = 1;
|
|
96
|
+
→ [{"val": "committed"}]
|
|
97
|
+
|
|
98
|
+
-- 4b. Data committed inside explicit transaction persists
|
|
99
|
+
begin;
|
|
100
|
+
insert into tx_schema values (3, 'will-commit');
|
|
101
|
+
commit;
|
|
102
|
+
|
|
103
|
+
select val from tx_schema where id = 3;
|
|
104
|
+
→ [{"val": "will-commit"}]
|
|
105
|
+
|
|
106
|
+
-- 4c. Rollback undoes deletes too
|
|
107
|
+
begin;
|
|
108
|
+
delete from tx_schema where id = 1;
|
|
109
|
+
|
|
110
|
+
select count(*) as cnt from tx_schema;
|
|
111
|
+
→ [{"cnt": 1}]
|
|
112
|
+
|
|
113
|
+
rollback;
|
|
114
|
+
|
|
115
|
+
-- Row 1 should be restored
|
|
116
|
+
select count(*) as cnt from tx_schema;
|
|
117
|
+
→ [{"cnt": 2}]
|
|
118
|
+
|
|
119
|
+
-- 4d. Rollback undoes updates
|
|
120
|
+
begin;
|
|
121
|
+
update tx_schema set val = 'changed' where id = 1;
|
|
122
|
+
|
|
123
|
+
select val from tx_schema where id = 1;
|
|
124
|
+
→ [{"val": "changed"}]
|
|
125
|
+
|
|
126
|
+
rollback;
|
|
127
|
+
|
|
128
|
+
select val from tx_schema where id = 1;
|
|
129
|
+
→ [{"val": "committed"}]
|
|
130
|
+
|
|
131
|
+
drop table tx_schema;
|
|
132
|
+
|
|
133
|
+
-- ===================================
|
|
134
|
+
-- 5. Error Cases
|
|
135
|
+
-- ===================================
|
|
136
|
+
|
|
137
|
+
-- 5a. CREATE TABLE with duplicate name
|
|
138
|
+
create table dup_table (x integer);
|
|
139
|
+
|
|
140
|
+
create table dup_table (y integer);
|
|
141
|
+
-- error: already exists
|
|
142
|
+
|
|
143
|
+
drop table dup_table;
|
|
144
|
+
|
|
145
|
+
-- 5b. DROP TABLE on non-existent table
|
|
146
|
+
drop table no_such_table;
|
|
147
|
+
-- error: not found
|
|
148
|
+
|
|
149
|
+
-- 5c. CREATE TABLE with duplicate column names
|
|
150
|
+
create table dup_cols (a integer, a text);
|
|
151
|
+
-- error: Duplicate column name
|
|
152
|
+
|
|
153
|
+
-- 5d-5f. The CREATE INDEX rejections (unknown table, unknown column, duplicate index
|
|
154
|
+
-- name) live in 10.1.5-create-index-lifecycle § 2.
|
|
155
|
+
|
|
156
|
+
-- ===================================
|
|
157
|
+
-- 6. Multi-table DDL Sequence
|
|
158
|
+
-- ===================================
|
|
159
|
+
-- Verify creating, using, and dropping multiple tables in sequence
|
|
160
|
+
|
|
161
|
+
create table t_first (id integer primary key, label text);
|
|
162
|
+
create table t_second (id integer primary key, ref_id integer, data text);
|
|
163
|
+
|
|
164
|
+
insert into t_first values (10, 'ten'), (20, 'twenty');
|
|
165
|
+
insert into t_second values (1, 10, 'alpha'), (2, 20, 'beta');
|
|
166
|
+
|
|
167
|
+
select f.label, s.data
|
|
168
|
+
from t_first f join t_second s on f.id = s.ref_id
|
|
169
|
+
order by f.id;
|
|
170
|
+
→ [{"label": "ten", "data": "alpha"}, {"label": "twenty", "data": "beta"}]
|
|
171
|
+
|
|
172
|
+
-- Drop in reverse dependency order
|
|
173
|
+
drop table t_second;
|
|
174
|
+
drop table t_first;
|
|
175
|
+
|
|
176
|
+
-- Both tables should be gone
|
|
177
|
+
select * from t_first;
|
|
178
|
+
-- error: not found in schema path
|
|
179
|
+
|
|
180
|
+
select * from t_second;
|
|
181
|
+
-- error: not found in schema path
|
|
182
|
+
|
|
183
|
+
-- ===================================
|
|
184
|
+
-- 7. Re-create Table After Drop
|
|
185
|
+
-- ===================================
|
|
186
|
+
-- Verify a table can be re-created with a different schema after drop
|
|
187
|
+
|
|
188
|
+
create table reuse (x integer primary key);
|
|
189
|
+
insert into reuse values (1), (2);
|
|
190
|
+
|
|
191
|
+
select count(*) as cnt from reuse;
|
|
192
|
+
→ [{"cnt": 2}]
|
|
193
|
+
|
|
194
|
+
drop table reuse;
|
|
195
|
+
|
|
196
|
+
-- Re-create with different columns
|
|
197
|
+
create table reuse (a text, b real);
|
|
198
|
+
insert into reuse values ('hello', 3.14);
|
|
199
|
+
|
|
200
|
+
select a, b from reuse;
|
|
201
|
+
→ [{"a": "hello", "b": 3.14}]
|
|
202
|
+
|
|
203
|
+
drop table reuse;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- adapted from SQLite test/createtab.test
|
|
2
|
+
-- CREATE TABLE syntax edge cases not covered by 10.1-ddl-lifecycle / 10.2-column-features.
|
|
3
|
+
|
|
4
|
+
-- ===================================
|
|
5
|
+
-- 1. Untyped columns: SQLite-specific dynamic typing.
|
|
6
|
+
-- Deleted: Quereus has strict typed columns; untyped declarations don't apply.
|
|
7
|
+
-- ===================================
|
|
8
|
+
|
|
9
|
+
-- ===================================
|
|
10
|
+
-- 2. CREATE TABLE while iterating an existing table
|
|
11
|
+
-- ===================================
|
|
12
|
+
-- Cursor-stability across DDL: a new table must be createable while a cursor
|
|
13
|
+
-- on a different table is open / a prior CTE-like read pipeline is in flight.
|
|
14
|
+
|
|
15
|
+
create table cs1 (id integer primary key, v text);
|
|
16
|
+
insert into cs1 values (1, 'aaa'), (2, 'bbb'), (3, 'ccc'), (4, 'ddd');
|
|
17
|
+
|
|
18
|
+
-- Iterate via CTE, then create another table; both should work
|
|
19
|
+
with iter as (select id from cs1)
|
|
20
|
+
select count(*) as cnt from iter;
|
|
21
|
+
→ [{"cnt":4}]
|
|
22
|
+
|
|
23
|
+
create table cs2 (id integer primary key, v text);
|
|
24
|
+
insert into cs2 values (1, 'one'), (2, 'two');
|
|
25
|
+
|
|
26
|
+
select count(*) as cnt from cs1;
|
|
27
|
+
→ [{"cnt":4}]
|
|
28
|
+
|
|
29
|
+
select count(*) as cnt from cs2;
|
|
30
|
+
→ [{"cnt":2}]
|
|
31
|
+
|
|
32
|
+
-- Several CREATE TABLE in sequence
|
|
33
|
+
create table cs3 (id integer primary key);
|
|
34
|
+
create table cs4 (id integer primary key);
|
|
35
|
+
|
|
36
|
+
select name from schema() where type = 'table' and name like 'cs_' order by name;
|
|
37
|
+
→ [{"name":"cs1"},{"name":"cs2"},{"name":"cs3"},{"name":"cs4"}]
|
|
38
|
+
|
|
39
|
+
drop table cs1;
|
|
40
|
+
drop table cs2;
|
|
41
|
+
drop table cs3;
|
|
42
|
+
drop table cs4;
|
|
43
|
+
|
|
44
|
+
-- ===================================
|
|
45
|
+
-- 3. Duplicate column in UNIQUE: SQLite-specific rejection.
|
|
46
|
+
-- Deleted: Quereus does not specifically reject duplicate columns in UNIQUE.
|
|
47
|
+
-- ===================================
|