@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,290 @@
|
|
|
1
|
+
-- Batched parent-side RESTRICT enforcement (fk-restrict-statement-batch).
|
|
2
|
+
-- A DELETE/UPDATE whose inbound FKs are all non-self-referential RESTRICT under
|
|
3
|
+
-- default conflict resolution enforces them with ONE probe per FK at end of
|
|
4
|
+
-- statement instead of per row. Final state + error class must be identical to
|
|
5
|
+
-- per-row enforcement; these cases pin that equivalence plus the shapes the
|
|
6
|
+
-- gate routes back to the per-row path.
|
|
7
|
+
|
|
8
|
+
pragma foreign_keys = true;
|
|
9
|
+
|
|
10
|
+
-- ===================================
|
|
11
|
+
-- 1. Batchable multi-row DELETE with an existing child: error + full rollback
|
|
12
|
+
-- ===================================
|
|
13
|
+
|
|
14
|
+
create table bp (id integer primary key);
|
|
15
|
+
create table bc (cid integer primary key, p_id integer,
|
|
16
|
+
foreign key (p_id) references bp(id) on delete restrict);
|
|
17
|
+
|
|
18
|
+
insert into bp values (1), (2), (3), (4), (5);
|
|
19
|
+
-- Only the LAST-scanned parent is referenced, so every earlier row deletes
|
|
20
|
+
-- before the violation is detected — the statement must still undo them all.
|
|
21
|
+
insert into bc values (10, 5);
|
|
22
|
+
|
|
23
|
+
delete from bp;
|
|
24
|
+
-- error: violates RESTRICT from 'bc'
|
|
25
|
+
|
|
26
|
+
-- Atomic: all five parents survive.
|
|
27
|
+
select count(*) as cnt from bp;
|
|
28
|
+
→ [{"cnt":5}]
|
|
29
|
+
|
|
30
|
+
-- ===================================
|
|
31
|
+
-- 2. Batchable DELETE with zero referencing children succeeds
|
|
32
|
+
-- ===================================
|
|
33
|
+
|
|
34
|
+
delete from bc;
|
|
35
|
+
delete from bp;
|
|
36
|
+
select count(*) as cnt from bp;
|
|
37
|
+
→ [{"cnt":0}]
|
|
38
|
+
|
|
39
|
+
drop table bc;
|
|
40
|
+
drop table bp;
|
|
41
|
+
|
|
42
|
+
-- ===================================
|
|
43
|
+
-- 3. UPDATE re-keying a referenced parent: violation at flush, atomic rollback
|
|
44
|
+
-- ===================================
|
|
45
|
+
|
|
46
|
+
create table up (id integer primary key, label text);
|
|
47
|
+
create table uc (cid integer primary key, p_id integer,
|
|
48
|
+
foreign key (p_id) references up(id) on update restrict);
|
|
49
|
+
|
|
50
|
+
insert into up values (1, 'a'), (2, 'b'), (3, 'c');
|
|
51
|
+
insert into uc values (10, 2);
|
|
52
|
+
|
|
53
|
+
-- Re-keys every parent; parent 2 is referenced -> whole statement rolls back.
|
|
54
|
+
update up set id = id + 100;
|
|
55
|
+
-- error: violates RESTRICT from 'uc'
|
|
56
|
+
|
|
57
|
+
select id from up order by id;
|
|
58
|
+
→ [{"id":1},{"id":2},{"id":3}]
|
|
59
|
+
|
|
60
|
+
-- ===================================
|
|
61
|
+
-- 4. UPDATE touching no referenced column contributes nothing to the batch
|
|
62
|
+
-- ===================================
|
|
63
|
+
|
|
64
|
+
update up set label = label || '!';
|
|
65
|
+
select label from up order by id;
|
|
66
|
+
→ [{"label":"a!"},{"label":"b!"},{"label":"c!"}]
|
|
67
|
+
|
|
68
|
+
-- Re-keying only unreferenced parents succeeds (referenced key 2 unchanged).
|
|
69
|
+
update up set id = id + 100 where id in (1, 3);
|
|
70
|
+
select id from up order by id;
|
|
71
|
+
→ [{"id":2},{"id":101},{"id":103}]
|
|
72
|
+
|
|
73
|
+
drop table uc;
|
|
74
|
+
drop table up;
|
|
75
|
+
|
|
76
|
+
-- ===================================
|
|
77
|
+
-- 5. Self-referential RESTRICT FK keeps per-row semantics (gate fallback)
|
|
78
|
+
-- ===================================
|
|
79
|
+
|
|
80
|
+
create table tree (id integer primary key, parent_id integer null,
|
|
81
|
+
foreign key (parent_id) references tree(id) on delete restrict);
|
|
82
|
+
|
|
83
|
+
insert into tree values (1, null), (2, 1);
|
|
84
|
+
|
|
85
|
+
-- Per-row: the check for row 1 sees row 2 still referencing it -> error.
|
|
86
|
+
-- (A statement-end check over the post-delete state would wrongly pass.)
|
|
87
|
+
delete from tree;
|
|
88
|
+
-- error: constraint
|
|
89
|
+
|
|
90
|
+
select count(*) as cnt from tree;
|
|
91
|
+
→ [{"cnt":2}]
|
|
92
|
+
|
|
93
|
+
-- Child-first order deletes cleanly row by row.
|
|
94
|
+
delete from tree where id = 2;
|
|
95
|
+
delete from tree where id = 1;
|
|
96
|
+
select count(*) as cnt from tree;
|
|
97
|
+
→ [{"cnt":0}]
|
|
98
|
+
|
|
99
|
+
drop table tree;
|
|
100
|
+
|
|
101
|
+
-- ===================================
|
|
102
|
+
-- 6. Mixed inbound actions (restrict + cascade) fall back to per-row
|
|
103
|
+
-- ===================================
|
|
104
|
+
|
|
105
|
+
create table mp (id integer primary key);
|
|
106
|
+
create table mc_r (cid integer primary key, p_id integer,
|
|
107
|
+
foreign key (p_id) references mp(id) on delete restrict);
|
|
108
|
+
create table mc_c (cid integer primary key, p_id integer,
|
|
109
|
+
foreign key (p_id) references mp(id) on delete cascade);
|
|
110
|
+
|
|
111
|
+
insert into mp values (1), (2);
|
|
112
|
+
insert into mc_c values (20, 1);
|
|
113
|
+
|
|
114
|
+
-- Only the cascade child references parent 1 -> delete cascades cleanly.
|
|
115
|
+
delete from mp where id = 1;
|
|
116
|
+
select count(*) as cnt from mc_c;
|
|
117
|
+
→ [{"cnt":0}]
|
|
118
|
+
|
|
119
|
+
insert into mc_r values (30, 2);
|
|
120
|
+
delete from mp where id = 2;
|
|
121
|
+
-- error: constraint
|
|
122
|
+
|
|
123
|
+
select id from mp;
|
|
124
|
+
→ [{"id":2}]
|
|
125
|
+
|
|
126
|
+
drop table mc_c;
|
|
127
|
+
drop table mc_r;
|
|
128
|
+
drop table mp;
|
|
129
|
+
|
|
130
|
+
-- ===================================
|
|
131
|
+
-- 7. Composite (two-column) RESTRICT FK batches with OR-of-conjunctions probe
|
|
132
|
+
-- ===================================
|
|
133
|
+
|
|
134
|
+
create table kp (a integer not null, b integer not null, v text,
|
|
135
|
+
primary key (a, b));
|
|
136
|
+
create table kc (cid integer primary key, ca integer, cb integer,
|
|
137
|
+
foreign key (ca, cb) references kp(a, b) on delete restrict);
|
|
138
|
+
|
|
139
|
+
insert into kp values (1, 1, 'x'), (1, 2, 'y'), (2, 1, 'z');
|
|
140
|
+
insert into kc values (10, 1, 2);
|
|
141
|
+
|
|
142
|
+
delete from kp;
|
|
143
|
+
-- error: violates RESTRICT from 'kc'
|
|
144
|
+
|
|
145
|
+
select count(*) as cnt from kp;
|
|
146
|
+
→ [{"cnt":3}]
|
|
147
|
+
|
|
148
|
+
-- Deleting only unreferenced composite keys succeeds; (1,2) stays guarded.
|
|
149
|
+
delete from kp where not (a = 1 and b = 2);
|
|
150
|
+
select a, b from kp;
|
|
151
|
+
→ [{"a":1,"b":2}]
|
|
152
|
+
|
|
153
|
+
drop table kc;
|
|
154
|
+
drop table kp;
|
|
155
|
+
|
|
156
|
+
-- ===================================
|
|
157
|
+
-- 8. NOCASE collation on the FK column: batched probe compares like per-row
|
|
158
|
+
-- ===================================
|
|
159
|
+
|
|
160
|
+
create table np (code text primary key collate nocase);
|
|
161
|
+
create table nc (cid integer primary key, p_code text collate nocase,
|
|
162
|
+
foreign key (p_code) references np(code) on delete restrict);
|
|
163
|
+
|
|
164
|
+
insert into np values ('ABC'), ('DEF');
|
|
165
|
+
-- Case-variant reference: satisfies the child-side check under NOCASE.
|
|
166
|
+
insert into nc values (10, 'abc');
|
|
167
|
+
|
|
168
|
+
-- The batched IN probe rides the child column's NOCASE collation -> violation.
|
|
169
|
+
delete from np where code = 'ABC';
|
|
170
|
+
-- error: violates RESTRICT from 'nc'
|
|
171
|
+
|
|
172
|
+
select code from np order by code;
|
|
173
|
+
→ [{"code":"ABC"},{"code":"DEF"}]
|
|
174
|
+
|
|
175
|
+
delete from np where code = 'def';
|
|
176
|
+
select code from np;
|
|
177
|
+
→ [{"code":"ABC"}]
|
|
178
|
+
|
|
179
|
+
drop table nc;
|
|
180
|
+
drop table np;
|
|
181
|
+
|
|
182
|
+
-- ===================================
|
|
183
|
+
-- 9. NULL referenced values are excluded (MATCH SIMPLE) — nothing to probe
|
|
184
|
+
-- ===================================
|
|
185
|
+
|
|
186
|
+
create table xp (id integer primary key, alt integer null unique);
|
|
187
|
+
create table xc (cid integer primary key, p_alt integer null,
|
|
188
|
+
foreign key (p_alt) references xp(alt) on delete restrict);
|
|
189
|
+
|
|
190
|
+
insert into xp (id, alt) values (1, null), (2, null), (3, 30);
|
|
191
|
+
insert into xc values (10, 30);
|
|
192
|
+
|
|
193
|
+
-- NULL alt values participate in no FK match: deletes succeed.
|
|
194
|
+
delete from xp where alt is null;
|
|
195
|
+
select id from xp;
|
|
196
|
+
→ [{"id":3}]
|
|
197
|
+
|
|
198
|
+
delete from xp where id = 3;
|
|
199
|
+
-- error: violates RESTRICT from 'xc'
|
|
200
|
+
|
|
201
|
+
drop table xc;
|
|
202
|
+
drop table xp;
|
|
203
|
+
|
|
204
|
+
-- ===================================
|
|
205
|
+
-- 10. Multiple inbound RESTRICT FKs: each gets its own batch + probe
|
|
206
|
+
-- ===================================
|
|
207
|
+
|
|
208
|
+
create table zp (id integer primary key);
|
|
209
|
+
create table zc1 (cid integer primary key, p_id integer,
|
|
210
|
+
foreign key (p_id) references zp(id) on delete restrict);
|
|
211
|
+
create table zc2 (cid integer primary key, p_id integer,
|
|
212
|
+
foreign key (p_id) references zp(id) on delete restrict);
|
|
213
|
+
|
|
214
|
+
insert into zp values (1), (2);
|
|
215
|
+
-- Only the SECOND-declared child holds a reference.
|
|
216
|
+
insert into zc2 values (20, 2);
|
|
217
|
+
|
|
218
|
+
delete from zp where id = 1;
|
|
219
|
+
select id from zp;
|
|
220
|
+
→ [{"id":2}]
|
|
221
|
+
|
|
222
|
+
delete from zp where id = 2;
|
|
223
|
+
-- error: violates RESTRICT from 'zc2'
|
|
224
|
+
|
|
225
|
+
drop table zc2;
|
|
226
|
+
drop table zc1;
|
|
227
|
+
drop table zp;
|
|
228
|
+
|
|
229
|
+
-- ===================================
|
|
230
|
+
-- 11. Referenced-column-change short-circuit coerces before comparing
|
|
231
|
+
-- (regression for bug-fk-restrict-change-detection-uncoerced): a rewrite that
|
|
232
|
+
-- spells the same stored value differently must not contribute a key to the
|
|
233
|
+
-- batch, so accumulateParentRestrictKeys must not flush a spurious probe.
|
|
234
|
+
-- ===================================
|
|
235
|
+
|
|
236
|
+
create table crb_p (id integer primary key);
|
|
237
|
+
create table crb_c (cid integer primary key, p_id integer,
|
|
238
|
+
foreign key (p_id) references crb_p(id) on update restrict);
|
|
239
|
+
|
|
240
|
+
insert into crb_p values (1), (2);
|
|
241
|
+
insert into crb_c values (10, 1);
|
|
242
|
+
|
|
243
|
+
-- Integer key rewritten as text '1': same stored value, no batch entry.
|
|
244
|
+
update crb_p set id = '1' where id = 1;
|
|
245
|
+
select id from crb_p order by id;
|
|
246
|
+
→ [{"id":1},{"id":2}]
|
|
247
|
+
|
|
248
|
+
-- Genuine re-key of the referenced row still flushes a violating probe.
|
|
249
|
+
update crb_p set id = 100 where id = 1;
|
|
250
|
+
-- error: violates RESTRICT from 'crb_c'
|
|
251
|
+
|
|
252
|
+
drop table crb_c;
|
|
253
|
+
drop table crb_p;
|
|
254
|
+
|
|
255
|
+
create table crbj_p (id json primary key, tag integer);
|
|
256
|
+
create table crbj_c (cid integer primary key, p_id json,
|
|
257
|
+
foreign key (p_id) references crbj_p(id) on update restrict);
|
|
258
|
+
|
|
259
|
+
insert into crbj_p values ('{"a":1,"b":2}', 1);
|
|
260
|
+
insert into crbj_c values (10, '{"a":1,"b":2}');
|
|
261
|
+
|
|
262
|
+
-- Reorder-equal JSON key: same stored value, no batch entry.
|
|
263
|
+
update crbj_p set id = '{"b": 2, "a": 1}' where tag = 1;
|
|
264
|
+
select id from crbj_p;
|
|
265
|
+
→ [{"id":{"b":2,"a":1}}]
|
|
266
|
+
|
|
267
|
+
-- Genuine JSON re-key still flushes a violating probe.
|
|
268
|
+
update crbj_p set id = '{"a":9,"b":9}' where tag = 1;
|
|
269
|
+
-- error: violates RESTRICT from 'crbj_c'
|
|
270
|
+
|
|
271
|
+
drop table crbj_c;
|
|
272
|
+
drop table crbj_p;
|
|
273
|
+
|
|
274
|
+
-- The re-coercion compares BINARY on purpose: the column's collation says which
|
|
275
|
+
-- values an equality test calls equal, not which value gets STORED. A case-only
|
|
276
|
+
-- rewrite of a `collate nocase` key does change the stored value, so it must still
|
|
277
|
+
-- count as a change and flush a violating probe.
|
|
278
|
+
|
|
279
|
+
create table crbn_p (id text collate nocase primary key);
|
|
280
|
+
create table crbn_c (cid integer primary key, p_id text,
|
|
281
|
+
foreign key (p_id) references crbn_p(id) on update restrict);
|
|
282
|
+
|
|
283
|
+
insert into crbn_p values ('A');
|
|
284
|
+
insert into crbn_c values (10, 'A');
|
|
285
|
+
|
|
286
|
+
update crbn_p set id = 'a' where id = 'A';
|
|
287
|
+
-- error: violates RESTRICT from 'crbn_c'
|
|
288
|
+
|
|
289
|
+
drop table crbn_c;
|
|
290
|
+
drop table crbn_p;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
-- committed-snapshot.sqllogic - Testing committed.tablename pseudo-schema access
|
|
2
|
+
|
|
3
|
+
-- ===================================
|
|
4
|
+
-- Basic: committed.* returns pre-transaction data
|
|
5
|
+
-- ===================================
|
|
6
|
+
|
|
7
|
+
CREATE TABLE accounts (id INTEGER PRIMARY KEY, balance INTEGER);
|
|
8
|
+
INSERT INTO accounts VALUES (1, 100);
|
|
9
|
+
INSERT INTO accounts VALUES (2, 200);
|
|
10
|
+
COMMIT;
|
|
11
|
+
|
|
12
|
+
-- Within a transaction, committed.accounts should show original data
|
|
13
|
+
BEGIN;
|
|
14
|
+
UPDATE accounts SET balance = 50 WHERE id = 1;
|
|
15
|
+
SELECT balance FROM accounts WHERE id = 1;
|
|
16
|
+
→ [{ "balance": 50 }]
|
|
17
|
+
SELECT balance FROM committed.accounts WHERE id = 1;
|
|
18
|
+
→ [{ "balance": 100 }]
|
|
19
|
+
COMMIT;
|
|
20
|
+
|
|
21
|
+
-- After commit, committed.accounts shows the new committed state
|
|
22
|
+
SELECT balance FROM committed.accounts WHERE id = 1;
|
|
23
|
+
→ [{ "balance": 50 }]
|
|
24
|
+
|
|
25
|
+
DROP TABLE accounts;
|
|
26
|
+
-- run
|
|
27
|
+
|
|
28
|
+
-- ===================================
|
|
29
|
+
-- committed.* outside a transaction returns current data
|
|
30
|
+
-- ===================================
|
|
31
|
+
|
|
32
|
+
CREATE TABLE t1 (id INTEGER PRIMARY KEY, val TEXT);
|
|
33
|
+
INSERT INTO t1 VALUES (1, 'hello');
|
|
34
|
+
COMMIT;
|
|
35
|
+
|
|
36
|
+
-- Outside a transaction (autocommit), committed should match current
|
|
37
|
+
SELECT val FROM committed.t1 WHERE id = 1;
|
|
38
|
+
→ [{ "val": "hello" }]
|
|
39
|
+
|
|
40
|
+
DROP TABLE t1;
|
|
41
|
+
-- run
|
|
42
|
+
|
|
43
|
+
-- ===================================
|
|
44
|
+
-- committed.* is read-only (INSERT error)
|
|
45
|
+
-- ===================================
|
|
46
|
+
|
|
47
|
+
CREATE TABLE ro_test (id INTEGER PRIMARY KEY, val TEXT);
|
|
48
|
+
INSERT INTO ro_test VALUES (1, 'x');
|
|
49
|
+
-- run
|
|
50
|
+
|
|
51
|
+
INSERT INTO committed.ro_test VALUES (2, 'y');
|
|
52
|
+
-- error: Cannot modify committed-state table 'committed.ro_test'
|
|
53
|
+
|
|
54
|
+
DROP TABLE ro_test;
|
|
55
|
+
-- run
|
|
56
|
+
|
|
57
|
+
-- ===================================
|
|
58
|
+
-- committed.* is read-only (UPDATE error)
|
|
59
|
+
-- ===================================
|
|
60
|
+
|
|
61
|
+
CREATE TABLE ro_test2 (id INTEGER PRIMARY KEY, val TEXT);
|
|
62
|
+
INSERT INTO ro_test2 VALUES (1, 'x');
|
|
63
|
+
-- run
|
|
64
|
+
|
|
65
|
+
UPDATE committed.ro_test2 SET val = 'z' WHERE id = 1;
|
|
66
|
+
-- error: Cannot modify committed-state table 'committed.ro_test2'
|
|
67
|
+
|
|
68
|
+
DROP TABLE ro_test2;
|
|
69
|
+
-- run
|
|
70
|
+
|
|
71
|
+
-- ===================================
|
|
72
|
+
-- committed.* is read-only (DELETE error)
|
|
73
|
+
-- ===================================
|
|
74
|
+
|
|
75
|
+
CREATE TABLE ro_test3 (id INTEGER PRIMARY KEY, val TEXT);
|
|
76
|
+
INSERT INTO ro_test3 VALUES (1, 'x');
|
|
77
|
+
-- run
|
|
78
|
+
|
|
79
|
+
DELETE FROM committed.ro_test3 WHERE id = 1;
|
|
80
|
+
-- error: Cannot modify committed-state table 'committed.ro_test3'
|
|
81
|
+
|
|
82
|
+
DROP TABLE ro_test3;
|
|
83
|
+
-- run
|
|
84
|
+
|
|
85
|
+
-- ===================================
|
|
86
|
+
-- JOIN between current and committed state
|
|
87
|
+
-- ===================================
|
|
88
|
+
|
|
89
|
+
CREATE TABLE products (id INTEGER PRIMARY KEY, price INTEGER);
|
|
90
|
+
INSERT INTO products VALUES (1, 10);
|
|
91
|
+
INSERT INTO products VALUES (2, 20);
|
|
92
|
+
COMMIT;
|
|
93
|
+
|
|
94
|
+
BEGIN;
|
|
95
|
+
UPDATE products SET price = 15 WHERE id = 1;
|
|
96
|
+
UPDATE products SET price = 25 WHERE id = 2;
|
|
97
|
+
|
|
98
|
+
-- Join current with committed to see price changes
|
|
99
|
+
SELECT p.id, p.price AS new_price, cp.price AS old_price
|
|
100
|
+
FROM products p
|
|
101
|
+
JOIN committed.products cp ON p.id = cp.id
|
|
102
|
+
ORDER BY p.id;
|
|
103
|
+
→ [{ "id": 1, "new_price": 15, "old_price": 10 }, { "id": 2, "new_price": 25, "old_price": 20 }]
|
|
104
|
+
COMMIT;
|
|
105
|
+
|
|
106
|
+
DROP TABLE products;
|
|
107
|
+
-- run
|
|
108
|
+
|
|
109
|
+
-- ===================================
|
|
110
|
+
-- committed.* with multiple tables
|
|
111
|
+
-- ===================================
|
|
112
|
+
|
|
113
|
+
CREATE TABLE t_a (id INTEGER PRIMARY KEY, val INTEGER);
|
|
114
|
+
CREATE TABLE t_b (id INTEGER PRIMARY KEY, val INTEGER);
|
|
115
|
+
INSERT INTO t_a VALUES (1, 100);
|
|
116
|
+
INSERT INTO t_b VALUES (1, 200);
|
|
117
|
+
COMMIT;
|
|
118
|
+
|
|
119
|
+
BEGIN;
|
|
120
|
+
UPDATE t_a SET val = 111 WHERE id = 1;
|
|
121
|
+
UPDATE t_b SET val = 222 WHERE id = 1;
|
|
122
|
+
|
|
123
|
+
SELECT a.val AS a_new, ca.val AS a_old, b.val AS b_new, cb.val AS b_old
|
|
124
|
+
FROM t_a a
|
|
125
|
+
JOIN committed.t_a ca ON a.id = ca.id
|
|
126
|
+
JOIN t_b b ON a.id = b.id
|
|
127
|
+
JOIN committed.t_b cb ON b.id = cb.id
|
|
128
|
+
WHERE a.id = 1;
|
|
129
|
+
→ [{ "a_new": 111, "a_old": 100, "b_new": 222, "b_old": 200 }]
|
|
130
|
+
COMMIT;
|
|
131
|
+
|
|
132
|
+
DROP TABLE t_b;
|
|
133
|
+
DROP TABLE t_a;
|
|
134
|
+
-- run
|
|
135
|
+
|
|
136
|
+
-- ===================================
|
|
137
|
+
-- Savepoint: committed state doesn't change after savepoints
|
|
138
|
+
-- ===================================
|
|
139
|
+
|
|
140
|
+
CREATE TABLE sp_test (id INTEGER PRIMARY KEY, val INTEGER);
|
|
141
|
+
INSERT INTO sp_test VALUES (1, 10);
|
|
142
|
+
COMMIT;
|
|
143
|
+
|
|
144
|
+
BEGIN;
|
|
145
|
+
UPDATE sp_test SET val = 20 WHERE id = 1;
|
|
146
|
+
SAVEPOINT sp1;
|
|
147
|
+
UPDATE sp_test SET val = 30 WHERE id = 1;
|
|
148
|
+
|
|
149
|
+
-- committed.sp_test should still show the pre-transaction value
|
|
150
|
+
SELECT val FROM committed.sp_test WHERE id = 1;
|
|
151
|
+
→ [{ "val": 10 }]
|
|
152
|
+
|
|
153
|
+
-- Current state shows latest update
|
|
154
|
+
SELECT val FROM sp_test WHERE id = 1;
|
|
155
|
+
→ [{ "val": 30 }]
|
|
156
|
+
|
|
157
|
+
ROLLBACK TO SAVEPOINT sp1;
|
|
158
|
+
|
|
159
|
+
-- committed.sp_test still shows original
|
|
160
|
+
SELECT val FROM committed.sp_test WHERE id = 1;
|
|
161
|
+
→ [{ "val": 10 }]
|
|
162
|
+
|
|
163
|
+
-- Current state shows value before savepoint
|
|
164
|
+
SELECT val FROM sp_test WHERE id = 1;
|
|
165
|
+
→ [{ "val": 20 }]
|
|
166
|
+
|
|
167
|
+
COMMIT;
|
|
168
|
+
|
|
169
|
+
DROP TABLE sp_test;
|
|
170
|
+
-- run
|
|
171
|
+
|
|
172
|
+
-- ===================================
|
|
173
|
+
-- Assertion with committed reference: detect balance decrease
|
|
174
|
+
-- ===================================
|
|
175
|
+
|
|
176
|
+
CREATE TABLE accts (id INTEGER PRIMARY KEY, balance INTEGER);
|
|
177
|
+
INSERT INTO accts VALUES (1, 100);
|
|
178
|
+
INSERT INTO accts VALUES (2, 200);
|
|
179
|
+
COMMIT;
|
|
180
|
+
|
|
181
|
+
-- Assertion: no account's balance may decrease
|
|
182
|
+
CREATE ASSERTION no_balance_decrease CHECK (NOT EXISTS (
|
|
183
|
+
SELECT 1 FROM accts a
|
|
184
|
+
JOIN committed.accts ca ON a.id = ca.id
|
|
185
|
+
WHERE a.balance < ca.balance
|
|
186
|
+
));
|
|
187
|
+
-- run
|
|
188
|
+
|
|
189
|
+
-- Valid: increase balance
|
|
190
|
+
BEGIN;
|
|
191
|
+
UPDATE accts SET balance = 150 WHERE id = 1;
|
|
192
|
+
COMMIT;
|
|
193
|
+
-- run
|
|
194
|
+
|
|
195
|
+
SELECT balance FROM accts WHERE id = 1;
|
|
196
|
+
→ [{ "balance": 150 }]
|
|
197
|
+
|
|
198
|
+
-- Invalid: decrease balance
|
|
199
|
+
BEGIN;
|
|
200
|
+
UPDATE accts SET balance = 50 WHERE id = 1;
|
|
201
|
+
COMMIT;
|
|
202
|
+
-- error: Integrity assertion failed: no_balance_decrease
|
|
203
|
+
|
|
204
|
+
-- State should be unchanged
|
|
205
|
+
SELECT balance FROM accts WHERE id = 1;
|
|
206
|
+
→ [{ "balance": 150 }]
|
|
207
|
+
|
|
208
|
+
DROP ASSERTION no_balance_decrease;
|
|
209
|
+
DROP TABLE accts;
|
|
210
|
+
-- run
|
|
211
|
+
|
|
212
|
+
-- ===================================
|
|
213
|
+
-- Assertion with committed reference: passes when constraint holds
|
|
214
|
+
-- ===================================
|
|
215
|
+
|
|
216
|
+
CREATE TABLE vals (id INTEGER PRIMARY KEY, v INTEGER);
|
|
217
|
+
INSERT INTO vals VALUES (1, 10);
|
|
218
|
+
COMMIT;
|
|
219
|
+
|
|
220
|
+
-- Assertion: values can only increase or stay the same
|
|
221
|
+
CREATE ASSERTION monotonic CHECK (NOT EXISTS (
|
|
222
|
+
SELECT 1 FROM vals curr
|
|
223
|
+
JOIN committed.vals prev ON curr.id = prev.id
|
|
224
|
+
WHERE curr.v < prev.v
|
|
225
|
+
));
|
|
226
|
+
-- run
|
|
227
|
+
|
|
228
|
+
-- Equal value: OK
|
|
229
|
+
BEGIN;
|
|
230
|
+
UPDATE vals SET v = 10 WHERE id = 1;
|
|
231
|
+
COMMIT;
|
|
232
|
+
-- run
|
|
233
|
+
|
|
234
|
+
-- Increase: OK
|
|
235
|
+
BEGIN;
|
|
236
|
+
UPDATE vals SET v = 20 WHERE id = 1;
|
|
237
|
+
COMMIT;
|
|
238
|
+
-- run
|
|
239
|
+
|
|
240
|
+
SELECT v FROM vals WHERE id = 1;
|
|
241
|
+
→ [{ "v": 20 }]
|
|
242
|
+
|
|
243
|
+
-- New row (no committed counterpart): OK
|
|
244
|
+
BEGIN;
|
|
245
|
+
INSERT INTO vals VALUES (2, 5);
|
|
246
|
+
COMMIT;
|
|
247
|
+
-- run
|
|
248
|
+
|
|
249
|
+
SELECT v FROM vals WHERE id = 2;
|
|
250
|
+
→ [{ "v": 5 }]
|
|
251
|
+
|
|
252
|
+
DROP ASSERTION monotonic;
|
|
253
|
+
DROP TABLE vals;
|
|
254
|
+
-- run
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
-- 42-returning.sqllogic - Testing RETURNING clauses
|
|
2
|
+
|
|
3
|
+
-- === Basic RETURNING tests ===
|
|
4
|
+
|
|
5
|
+
DROP TABLE IF EXISTS test_returning;
|
|
6
|
+
CREATE TABLE test_returning (
|
|
7
|
+
id INTEGER PRIMARY KEY,
|
|
8
|
+
name TEXT,
|
|
9
|
+
value INTEGER DEFAULT 100
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
-- INSERT with RETURNING
|
|
13
|
+
INSERT INTO test_returning (id, name) VALUES (101, 'first') RETURNING id, name, value;
|
|
14
|
+
→ [{"id":101,"name":"first","value":100}]
|
|
15
|
+
|
|
16
|
+
INSERT INTO test_returning (id, name, value) VALUES (102, 'second', 200) RETURNING *;
|
|
17
|
+
→ [{"id":102,"name":"second","value":200}]
|
|
18
|
+
|
|
19
|
+
INSERT INTO test_returning (id, name, value) VALUES (103, 'third', 300) RETURNING id, name;
|
|
20
|
+
→ [{"id":103,"name":"third"}]
|
|
21
|
+
|
|
22
|
+
-- Verify data was actually inserted (102 was inserted via RETURNING * above)
|
|
23
|
+
SELECT * FROM test_returning ORDER BY id;
|
|
24
|
+
→ [{"id":101,"name":"first","value":100},{"id":102,"name":"second","value":200},{"id":103,"name":"third","value":300}]
|
|
25
|
+
|
|
26
|
+
-- UPDATE with RETURNING
|
|
27
|
+
UPDATE test_returning SET value = value + 50 WHERE id = 101 RETURNING id, name, value;
|
|
28
|
+
→ [{"id":101,"name":"first","value":150}]
|
|
29
|
+
|
|
30
|
+
-- UPDATE multiple rows with RETURNING
|
|
31
|
+
UPDATE test_returning SET name = name || '_updated' RETURNING id, name;
|
|
32
|
+
→ [{"id":101,"name":"first_updated"},{"id":102,"name":"second_updated"},{"id":103,"name":"third_updated"}]
|
|
33
|
+
|
|
34
|
+
-- Verify updates were applied
|
|
35
|
+
SELECT * FROM test_returning ORDER BY id;
|
|
36
|
+
→ [{"id":101,"name":"first_updated","value":150},{"id":102,"name":"second_updated","value":200},{"id":103,"name":"third_updated","value":300}]
|
|
37
|
+
|
|
38
|
+
-- DELETE with RETURNING
|
|
39
|
+
DELETE FROM test_returning WHERE id = 103 RETURNING id, name, value;
|
|
40
|
+
→ [{"id":103,"name":"third_updated","value":300}]
|
|
41
|
+
|
|
42
|
+
-- Verify deletion (102 remains; only 103 was deleted)
|
|
43
|
+
SELECT * FROM test_returning ORDER BY id;
|
|
44
|
+
→ [{"id":101,"name":"first_updated","value":150},{"id":102,"name":"second_updated","value":200}]
|
|
45
|
+
|
|
46
|
+
-- === RETURNING with expressions ===
|
|
47
|
+
|
|
48
|
+
INSERT INTO test_returning (id, name, value) VALUES (104, 'fourth', 400) RETURNING id, upper(name), value * 2;
|
|
49
|
+
→ [{"id":104,"upper(name)":"FOURTH","value * 2":800}]
|
|
50
|
+
|
|
51
|
+
INSERT INTO test_returning (id, name, value) VALUES (105, 'fifth', 500) RETURNING id, name AS item_name, value + 100 AS adjusted_value;
|
|
52
|
+
→ [{"id":105,"item_name":"fifth","adjusted_value":600}]
|
|
53
|
+
|
|
54
|
+
-- === RETURNING with constraints (should only return if operation succeeds) ===
|
|
55
|
+
|
|
56
|
+
DROP TABLE test_returning;
|
|
57
|
+
|
|
58
|
+
CREATE TABLE test_constrained (
|
|
59
|
+
id INTEGER PRIMARY KEY,
|
|
60
|
+
positive_value INTEGER CHECK(positive_value > 0),
|
|
61
|
+
name TEXT NOT NULL
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
-- Successful INSERT with RETURNING
|
|
65
|
+
INSERT INTO test_constrained (id, positive_value, name) VALUES (201, 10, 'valid') RETURNING id, positive_value;
|
|
66
|
+
→ [{"id":201,"positive_value":10}]
|
|
67
|
+
|
|
68
|
+
-- Failed INSERT due to constraint - should not return anything
|
|
69
|
+
INSERT INTO test_constrained (id, positive_value, name) VALUES (202, -5, 'invalid') RETURNING id, positive_value;
|
|
70
|
+
-- error: CHECK constraint failed: _check_positive_value
|
|
71
|
+
|
|
72
|
+
-- Failed INSERT due to NOT NULL - should not return anything
|
|
73
|
+
INSERT INTO test_constrained (id, positive_value, name) VALUES (203, 15, NULL) RETURNING id, name;
|
|
74
|
+
-- error: NOT NULL constraint failed: test_constrained.name
|
|
75
|
+
|
|
76
|
+
-- Verify only the successful insert was applied
|
|
77
|
+
SELECT * FROM test_constrained;
|
|
78
|
+
→ [{"id":201,"positive_value":10,"name":"valid"}]
|
|
79
|
+
|
|
80
|
+
-- Successful UPDATE with RETURNING
|
|
81
|
+
UPDATE test_constrained SET positive_value = 20 WHERE id = 201 RETURNING id, positive_value;
|
|
82
|
+
→ [{"id":201,"positive_value":20}]
|
|
83
|
+
|
|
84
|
+
-- Failed UPDATE due to constraint - should not return anything
|
|
85
|
+
UPDATE test_constrained SET positive_value = -1 WHERE id = 201 RETURNING id, positive_value;
|
|
86
|
+
-- error: CHECK constraint failed: _check_positive_value
|
|
87
|
+
|
|
88
|
+
-- Verify failed update didn't change anything
|
|
89
|
+
SELECT positive_value FROM test_constrained WHERE id = 201;
|
|
90
|
+
→ [{"positive_value":20}]
|
|
91
|
+
|
|
92
|
+
-- === RETURNING with no matching rows ===
|
|
93
|
+
|
|
94
|
+
-- UPDATE with WHERE that matches nothing
|
|
95
|
+
UPDATE test_constrained SET positive_value = 30 WHERE id = 999 RETURNING id, positive_value;
|
|
96
|
+
→ []
|
|
97
|
+
|
|
98
|
+
-- DELETE with WHERE that matches nothing
|
|
99
|
+
DELETE FROM test_constrained WHERE name = 'nonexistent' RETURNING id, name;
|
|
100
|
+
→ []
|
|
101
|
+
|
|
102
|
+
-- === Multiple row RETURNING ===
|
|
103
|
+
|
|
104
|
+
INSERT INTO test_constrained (id, positive_value, name) VALUES
|
|
105
|
+
(210, 100, 'row1'),
|
|
106
|
+
(211, 110, 'row2'),
|
|
107
|
+
(212, 120, 'row3')
|
|
108
|
+
RETURNING id, name;
|
|
109
|
+
→ [{"id":210,"name":"row1"},{"id":211,"name":"row2"},{"id":212,"name":"row3"}]
|
|
110
|
+
|
|
111
|
+
-- Update multiple rows
|
|
112
|
+
UPDATE test_constrained SET positive_value = positive_value + 5 WHERE id >= 210 RETURNING id, positive_value;
|
|
113
|
+
→ [{"id":210,"positive_value":105},{"id":211,"positive_value":115},{"id":212,"positive_value":125}]
|
|
114
|
+
|
|
115
|
+
-- Delete multiple rows
|
|
116
|
+
DELETE FROM test_constrained WHERE id >= 210 RETURNING name;
|
|
117
|
+
→ [{"name":"row1"},{"name":"row2"},{"name":"row3"}]
|
|
118
|
+
|
|
119
|
+
DROP TABLE test_constrained;
|
|
120
|
+
|
|
121
|
+
-- === OLD/NEW qualifiers in RETURNING ===
|
|
122
|
+
|
|
123
|
+
-- Create test table
|
|
124
|
+
CREATE TABLE test_table (
|
|
125
|
+
id INTEGER PRIMARY KEY,
|
|
126
|
+
value TEXT
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
-- Insert initial data
|
|
130
|
+
INSERT INTO test_table VALUES (1, 'original');
|
|
131
|
+
SELECT * FROM test_table;
|
|
132
|
+
→ [{"id":1,"value":"original"}]
|
|
133
|
+
|
|
134
|
+
-- Test UPDATE RETURNING with OLD qualifier (should show original value)
|
|
135
|
+
UPDATE test_table SET value = 'updated' WHERE id = 1 RETURNING OLD.value;
|
|
136
|
+
→ [{"OLD.value":"original"}]
|
|
137
|
+
|
|
138
|
+
-- Verify the update actually happened
|
|
139
|
+
SELECT * FROM test_table;
|
|
140
|
+
→ [{"id":1,"value":"updated"}]
|
|
141
|
+
|
|
142
|
+
-- RETURNING preserves the user's spelling for output column names
|
|
143
|
+
INSERT INTO test_table VALUES (2, 'second');
|
|
144
|
+
UPDATE test_table SET value = 'modified' WHERE id = 2 RETURNING NEW.value, OLD.value;
|
|
145
|
+
→ [{"NEW.value":"modified","OLD.value":"second"}]
|
|
146
|
+
|
|
147
|
+
-- Aliases are emitted with the case as written
|
|
148
|
+
UPDATE test_table SET value = 'final' WHERE id = 2 RETURNING NEW.value AS NewValue, OLD.value AS OldValue;
|
|
149
|
+
→ [{"NewValue":"final","OldValue":"modified"}]
|
|
150
|
+
|
|
151
|
+
-- INSERT with NEW qualifier — qualifier case preserved
|
|
152
|
+
INSERT INTO test_table VALUES (3, 'third') RETURNING NEW.id, NEW.value;
|
|
153
|
+
→ [{"NEW.id":3,"NEW.value":"third"}]
|
|
154
|
+
|
|
155
|
+
-- DELETE with OLD qualifier — qualifier case preserved
|
|
156
|
+
DELETE FROM test_table WHERE id = 3 RETURNING OLD.id, OLD.value;
|
|
157
|
+
→ [{"OLD.id":3,"OLD.value":"third"}]
|
|
158
|
+
|
|
159
|
+
DROP TABLE test_table;
|