@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,254 @@
|
|
|
1
|
+
-- 13.8-insert-with-clause-visibility.sqllogic - a leading WITH on INSERT reaches every clause
|
|
2
|
+
--
|
|
3
|
+
-- `buildInsertStmt` used to build its leading `with` clause into a local map handed to
|
|
4
|
+
-- exactly ONE consumer — the `select` source branch — instead of deriving one
|
|
5
|
+
-- statement-level planning context the way `buildUpdateStmt` / `buildDeleteStmt` do. Every
|
|
6
|
+
-- other clause of the same statement therefore lost the statement's CTEs and failed with
|
|
7
|
+
-- `Table 'c' not found in schema path: main`: RETURNING, a scalar subquery inside a VALUES
|
|
8
|
+
-- row, ON CONFLICT, WITH CONTEXT, and the view / materialized-view target dispatch.
|
|
9
|
+
--
|
|
10
|
+
-- The same local map also started EMPTY and was filled from the INSERT's own `with` clause
|
|
11
|
+
-- alone, while `buildWithContext` prefers a non-empty explicit argument over the context's
|
|
12
|
+
-- inherited definitions — so an INSERT that carried its own `with` clause dropped every
|
|
13
|
+
-- definition it had inherited from an enclosing statement. That arm is covered at the end.
|
|
14
|
+
|
|
15
|
+
create table p (id integer primary key, v text);
|
|
16
|
+
insert into p values (1, 'a'), (2, 'b');
|
|
17
|
+
-- run
|
|
18
|
+
|
|
19
|
+
-- ===== RETURNING sees the statement's CTEs =====
|
|
20
|
+
|
|
21
|
+
create table q1 (id integer primary key, w text);
|
|
22
|
+
-- run
|
|
23
|
+
|
|
24
|
+
with c as (select id, v from p) insert into q1 values (5, 'e')
|
|
25
|
+
returning id, (select count(*) from c) as n;
|
|
26
|
+
→ [{"id":5,"n":2}]
|
|
27
|
+
|
|
28
|
+
select id, w from q1 order by id;
|
|
29
|
+
→ [{"id":5,"w":"e"}]
|
|
30
|
+
|
|
31
|
+
-- ===== A scalar subquery inside a VALUES row sees them =====
|
|
32
|
+
|
|
33
|
+
create table q2 (id integer primary key, w integer);
|
|
34
|
+
-- run
|
|
35
|
+
|
|
36
|
+
with c as (select id from p) insert into q2 values (6, (select count(*) from c));
|
|
37
|
+
|
|
38
|
+
select id, w from q2 order by id;
|
|
39
|
+
→ [{"id":6,"w":2}]
|
|
40
|
+
|
|
41
|
+
-- ===== A view target sees them (source AND returning) =====
|
|
42
|
+
|
|
43
|
+
create table q3 (id integer primary key, w text);
|
|
44
|
+
create view vq3 as select id, w from q3;
|
|
45
|
+
-- run
|
|
46
|
+
|
|
47
|
+
with c as (select id, v from p) insert into vq3 select id, v from c;
|
|
48
|
+
|
|
49
|
+
select id, w from q3 order by id;
|
|
50
|
+
→ [{"id":1,"w":"a"},{"id":2,"w":"b"}]
|
|
51
|
+
|
|
52
|
+
with c as (select id from p) insert into vq3 values (7, 'g')
|
|
53
|
+
returning id, (select count(*) from c) as n;
|
|
54
|
+
→ [{"id":7,"n":2}]
|
|
55
|
+
|
|
56
|
+
-- ===== A materialized-view target sees them =====
|
|
57
|
+
|
|
58
|
+
create table q4 (id integer primary key, w text);
|
|
59
|
+
create materialized view mvq4 as select id, w from q4;
|
|
60
|
+
-- run
|
|
61
|
+
|
|
62
|
+
with c as (select id, v from p) insert into mvq4 select id, v from c;
|
|
63
|
+
|
|
64
|
+
select id, w from q4 order by id;
|
|
65
|
+
→ [{"id":1,"w":"a"},{"id":2,"w":"b"}]
|
|
66
|
+
|
|
67
|
+
select id, w from mvq4 order by id;
|
|
68
|
+
→ [{"id":1,"w":"a"},{"id":2,"w":"b"}]
|
|
69
|
+
|
|
70
|
+
-- ===== Nested DML source sees them =====
|
|
71
|
+
-- `insert into … insert into … returning` — the inner DML builds on the same context.
|
|
72
|
+
|
|
73
|
+
create table q5 (id integer primary key, w text);
|
|
74
|
+
create table q5src (id integer primary key, w text);
|
|
75
|
+
-- run
|
|
76
|
+
|
|
77
|
+
with c as (select id from p)
|
|
78
|
+
insert into q5 insert into q5src values (8, 'h') returning id + (select count(*) from c), w;
|
|
79
|
+
|
|
80
|
+
select id, w from q5 order by id;
|
|
81
|
+
→ [{"id":10,"w":"h"}]
|
|
82
|
+
|
|
83
|
+
-- The UPDATE- and DELETE-bodied source branches take the same context.
|
|
84
|
+
|
|
85
|
+
create table q5b (id integer primary key, w integer);
|
|
86
|
+
create table q5c (id integer primary key, w integer);
|
|
87
|
+
create table q5upd (id integer primary key, w text);
|
|
88
|
+
insert into q5upd values (1, 'x'), (2, 'y');
|
|
89
|
+
-- run
|
|
90
|
+
|
|
91
|
+
with c as (select id from p)
|
|
92
|
+
insert into q5b update q5upd set w = 'z' where id = 1 returning id, (select count(*) from c);
|
|
93
|
+
|
|
94
|
+
select id, w from q5b order by id;
|
|
95
|
+
→ [{"id":1,"w":2}]
|
|
96
|
+
|
|
97
|
+
with c as (select id from p)
|
|
98
|
+
insert into q5c delete from q5upd where id = 2 returning id, (select count(*) from c);
|
|
99
|
+
|
|
100
|
+
select id, w from q5c order by id;
|
|
101
|
+
→ [{"id":2,"w":2}]
|
|
102
|
+
|
|
103
|
+
-- ===== A MULTI-SOURCE view target sees them =====
|
|
104
|
+
-- A join-bodied view decomposes into one base insert per member, each re-planned through
|
|
105
|
+
-- this builder with a `preBuiltSource`. Every member must still carry the statement's CTEs
|
|
106
|
+
-- (and the RETURNING built over the decomposition must too).
|
|
107
|
+
|
|
108
|
+
create table q11a (id integer primary key, a text);
|
|
109
|
+
create table q11b (id integer primary key, b text);
|
|
110
|
+
create view vq11 as select q11a.id as id, q11a.a as a, q11b.b as b
|
|
111
|
+
from q11a join q11b on q11a.id = q11b.id;
|
|
112
|
+
-- run
|
|
113
|
+
|
|
114
|
+
with c as (select id, v from p) insert into vq11 select id, v, v from c;
|
|
115
|
+
|
|
116
|
+
select id, a from q11a order by id;
|
|
117
|
+
→ [{"id":1,"a":"a"},{"id":2,"a":"b"}]
|
|
118
|
+
|
|
119
|
+
select id, b from q11b order by id;
|
|
120
|
+
→ [{"id":1,"b":"a"},{"id":2,"b":"b"}]
|
|
121
|
+
|
|
122
|
+
-- ===== An INSERT's own WITH clause does not hide the ones it INHERITED =====
|
|
123
|
+
-- Arm B: the inner `with c as (…)` used to replace, rather than shadow into, the enclosing
|
|
124
|
+
-- statement's definitions, so `a` vanished and the insert failed `Table 'a' not found`.
|
|
125
|
+
|
|
126
|
+
create table q6 (id integer primary key, w integer);
|
|
127
|
+
-- run
|
|
128
|
+
|
|
129
|
+
with a as (select id from p),
|
|
130
|
+
b as (with c as (select 1 as k) insert into q6 select id + 40, (select k from c) from a returning id)
|
|
131
|
+
select count(*) as n from b;
|
|
132
|
+
→ [{"n":2}]
|
|
133
|
+
|
|
134
|
+
select id, w from q6 order by id;
|
|
135
|
+
→ [{"id":41,"w":1},{"id":42,"w":1}]
|
|
136
|
+
|
|
137
|
+
-- ===== An own-clause name still SHADOWS a same-named inherited one =====
|
|
138
|
+
|
|
139
|
+
create table q7 (id integer primary key, w integer);
|
|
140
|
+
-- run
|
|
141
|
+
|
|
142
|
+
with a as (select id from p),
|
|
143
|
+
b as (with a as (select 77 as id) insert into q7 select id, 5 from a returning id)
|
|
144
|
+
select count(*) as n from b;
|
|
145
|
+
→ [{"n":1}]
|
|
146
|
+
|
|
147
|
+
-- 77, not 1 and 2 — the inner `a` won.
|
|
148
|
+
select id, w from q7 order by id;
|
|
149
|
+
→ [{"id":77,"w":5}]
|
|
150
|
+
|
|
151
|
+
-- ===== An INSERT nested in FROM / expression position inherits through the context =====
|
|
152
|
+
-- These two shapes reach `buildInsertStmt` with no WITH clause of their own — the enclosing
|
|
153
|
+
-- statement's definitions arrive only via `ctx.cteNodes`. Both only work because RETURNING
|
|
154
|
+
-- is now built on the CTE-aware context rather than the bare one.
|
|
155
|
+
|
|
156
|
+
create table q12 (id integer primary key, w integer);
|
|
157
|
+
create table q13 (id integer primary key, w integer);
|
|
158
|
+
-- run
|
|
159
|
+
|
|
160
|
+
with c as (select id from p)
|
|
161
|
+
select n from (insert into q12 values (1, 5) returning (select count(*) from c) as n) as d;
|
|
162
|
+
→ [{"n":2}]
|
|
163
|
+
|
|
164
|
+
with c as (select id from p)
|
|
165
|
+
select (select n from (insert into q13 values (2, 6) returning (select count(*) from c) as n)) as k;
|
|
166
|
+
→ [{"k":2}]
|
|
167
|
+
|
|
168
|
+
-- ===== Control: the `select` source branch (the one that always worked) =====
|
|
169
|
+
|
|
170
|
+
create table q8 (id integer primary key, w text);
|
|
171
|
+
-- run
|
|
172
|
+
|
|
173
|
+
with c as (select id, v from p) insert into q8 select id + 300, v from c;
|
|
174
|
+
|
|
175
|
+
select id, w from q8 order by id;
|
|
176
|
+
→ [{"id":301,"w":"a"},{"id":302,"w":"b"}]
|
|
177
|
+
|
|
178
|
+
-- ===== Control: schema-authored DEFAULT expressions do NOT bind a caller's CTE =====
|
|
179
|
+
-- A table's own DDL is not part of the user's statement, so the statement-level CTE
|
|
180
|
+
-- context is deliberately withheld from column defaults / generated columns / CHECKs.
|
|
181
|
+
-- `c` here is a real table, and the default must keep resolving to it even when the
|
|
182
|
+
-- INSERT declares a CTE of the same name.
|
|
183
|
+
|
|
184
|
+
create table c (k integer primary key);
|
|
185
|
+
insert into c values (1), (2), (3);
|
|
186
|
+
create table q9 (id integer primary key, w integer default (select count(*) from c));
|
|
187
|
+
-- run
|
|
188
|
+
|
|
189
|
+
with c as (select id from p) insert into q9 (id) values (9);
|
|
190
|
+
|
|
191
|
+
-- 3 (the real table), not 2 (the CTE).
|
|
192
|
+
select id, w from q9 order by id;
|
|
193
|
+
→ [{"id":9,"w":3}]
|
|
194
|
+
|
|
195
|
+
-- ===== ON CONFLICT and WITH CONTEXT: name resolution AND execution both work =====
|
|
196
|
+
-- These two clauses RESOLVE the statement's CTEs (no more `Table 'c' not found`), and a
|
|
197
|
+
-- subquery in either position now executes correctly — `DmlExecutorNode` exposes its
|
|
198
|
+
-- ON CONFLICT / mutation-context expressions as optimizer-visible children, so their
|
|
199
|
+
-- subquery subtrees get rewritten like any other child. Fixed by
|
|
200
|
+
-- `bug-dml-side-expressions-invisible-to-optimizer`.
|
|
201
|
+
|
|
202
|
+
create table q10 (id integer primary key, w text);
|
|
203
|
+
insert into q10 values (1, 'x');
|
|
204
|
+
create table mc (id integer primary key, v text) with context (who integer);
|
|
205
|
+
-- run
|
|
206
|
+
|
|
207
|
+
with c as (select id from p) insert into q10 values (1, 'x')
|
|
208
|
+
on conflict (id) do update set w = (select count(*) from c) returning w;
|
|
209
|
+
→ [{"w":"2"}]
|
|
210
|
+
|
|
211
|
+
with c as (select id from p) insert into q10 values (1, 'x')
|
|
212
|
+
on conflict (id) do update set w = 'y' where (select count(*) from c) > 0 returning w;
|
|
213
|
+
→ [{"w":"y"}]
|
|
214
|
+
|
|
215
|
+
with c as (select id from p) insert into mc with context who = (select count(*) from c)
|
|
216
|
+
values (1, 'x') returning v;
|
|
217
|
+
→ [{"v":"x"}]
|
|
218
|
+
|
|
219
|
+
-- The same three shapes work identically with NO leading WITH clause — the fix is
|
|
220
|
+
-- not about CTE visibility.
|
|
221
|
+
insert into q10 values (1, 'x') on conflict (id) do update set w = (select count(*) from p) returning w;
|
|
222
|
+
→ [{"w":"2"}]
|
|
223
|
+
|
|
224
|
+
insert into mc with context who = (select count(*) from p) values (2, 'x') returning id, v;
|
|
225
|
+
→ [{"id":2,"v":"x"}]
|
|
226
|
+
|
|
227
|
+
-- Cleanup
|
|
228
|
+
-- q9's DEFAULT reads `c` through a subquery, so it has to go first: dropping a table a
|
|
229
|
+
-- stored expression still names is refused (41.10.4-drop-object-expression-dependents).
|
|
230
|
+
drop materialized view mvq4;
|
|
231
|
+
drop view vq3;
|
|
232
|
+
drop view vq11;
|
|
233
|
+
drop table q9;
|
|
234
|
+
drop table p;
|
|
235
|
+
drop table c;
|
|
236
|
+
drop table q1;
|
|
237
|
+
drop table q2;
|
|
238
|
+
drop table q3;
|
|
239
|
+
drop table q4;
|
|
240
|
+
drop table q5;
|
|
241
|
+
drop table q5src;
|
|
242
|
+
drop table q5b;
|
|
243
|
+
drop table q5c;
|
|
244
|
+
drop table q5upd;
|
|
245
|
+
drop table q11a;
|
|
246
|
+
drop table q11b;
|
|
247
|
+
drop table q12;
|
|
248
|
+
drop table q13;
|
|
249
|
+
drop table q6;
|
|
250
|
+
drop table q7;
|
|
251
|
+
drop table q8;
|
|
252
|
+
drop table q10;
|
|
253
|
+
drop table mc;
|
|
254
|
+
-- run
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
-- 13.9-schema-authored-cte-isolation.sqllogic - a table's own DDL never binds a statement's CTEs
|
|
2
|
+
--
|
|
3
|
+
-- A column DEFAULT, a generated-column expression, a CHECK constraint and a foreign-key
|
|
4
|
+
-- check are written in the TABLE's definition, not in the statement doing the write, so
|
|
5
|
+
-- their unqualified relation names must always mean real schema objects. They used to be
|
|
6
|
+
-- built on a planning context that still carried the statement's common-table-expression
|
|
7
|
+
-- definitions, so a caller naming a CTE after a real table silently changed what someone
|
|
8
|
+
-- else's DDL meant — a wrong stored value, or a spurious constraint failure.
|
|
9
|
+
--
|
|
10
|
+
-- Two flavours leak, and the DML builders differed in which reached them:
|
|
11
|
+
-- * INHERITED — the definitions come from an ENCLOSING statement, arriving through
|
|
12
|
+
-- `ctx.cteNodes` (all three builders);
|
|
13
|
+
-- * OWN — the definitions come from the write statement's own leading `with` clause
|
|
14
|
+
-- (UPDATE / DELETE only; INSERT's own clause was already kept out, pinned by
|
|
15
|
+
-- 13.8-insert-with-clause-visibility.sqllogic § "schema-authored DEFAULT expressions").
|
|
16
|
+
-- `schemaAuthoredContext` (planner/building/schema-authored-context.ts) closes both.
|
|
17
|
+
--
|
|
18
|
+
-- Every arm below is written so the WRONG binding is observable: the caller's CTE and the
|
|
19
|
+
-- real table disagree, and the assertion pins the real table's answer.
|
|
20
|
+
|
|
21
|
+
pragma foreign_keys = true;
|
|
22
|
+
|
|
23
|
+
-- `c` is a real table with 3 rows; `p` has 1 row, so a CTE `c` over `p` has 1 row.
|
|
24
|
+
create table c (k integer primary key);
|
|
25
|
+
insert into c values (1), (2), (3);
|
|
26
|
+
create table p (id integer primary key);
|
|
27
|
+
insert into p values (10);
|
|
28
|
+
-- run
|
|
29
|
+
|
|
30
|
+
-- ===== Column DEFAULT (inherited) =====
|
|
31
|
+
|
|
32
|
+
create table sa_def (id integer primary key, w integer default (select count(*) from c));
|
|
33
|
+
-- run
|
|
34
|
+
|
|
35
|
+
with c as (select id from p),
|
|
36
|
+
b as (insert into sa_def (id) values (1) returning id)
|
|
37
|
+
select count(*) as n from b;
|
|
38
|
+
→ [{"n":1}]
|
|
39
|
+
|
|
40
|
+
-- 3 (the real table), not 1 (the caller's CTE over p).
|
|
41
|
+
select id, w from sa_def order by id;
|
|
42
|
+
→ [{"id":1,"w":3}]
|
|
43
|
+
|
|
44
|
+
-- ===== Generated column (inherited) =====
|
|
45
|
+
|
|
46
|
+
create table sa_gen (id integer primary key, g integer generated always as ((select count(*) from c)));
|
|
47
|
+
-- run
|
|
48
|
+
|
|
49
|
+
with c as (select id from p),
|
|
50
|
+
b as (insert into sa_gen (id) values (1) returning id)
|
|
51
|
+
select count(*) as n from b;
|
|
52
|
+
→ [{"n":1}]
|
|
53
|
+
|
|
54
|
+
select id, g from sa_gen order by id;
|
|
55
|
+
→ [{"id":1,"g":3}]
|
|
56
|
+
|
|
57
|
+
-- ===== CHECK on INSERT (inherited) =====
|
|
58
|
+
-- The check holds against the real `c` (3 rows) and fails against the caller's (1 row),
|
|
59
|
+
-- so a leak shows up as a spurious `CHECK constraint failed`.
|
|
60
|
+
|
|
61
|
+
create table sa_cki (id integer primary key, check ((select count(*) from c) = 3));
|
|
62
|
+
-- run
|
|
63
|
+
|
|
64
|
+
with c as (select id from p),
|
|
65
|
+
b as (insert into sa_cki values (1) returning id)
|
|
66
|
+
select count(*) as n from b;
|
|
67
|
+
→ [{"n":1}]
|
|
68
|
+
|
|
69
|
+
select id from sa_cki order by id;
|
|
70
|
+
→ [{"id":1}]
|
|
71
|
+
|
|
72
|
+
-- The other direction: a check that the REAL table can never satisfy must not be rescued
|
|
73
|
+
-- by a caller CTE that would satisfy it.
|
|
74
|
+
|
|
75
|
+
create table sa_ckx (id integer primary key, check ((select count(*) from c) = 1));
|
|
76
|
+
-- run
|
|
77
|
+
|
|
78
|
+
with c as (select id from p),
|
|
79
|
+
b as (insert into sa_ckx values (1) returning id)
|
|
80
|
+
select count(*) as n from b;
|
|
81
|
+
-- error: CHECK
|
|
82
|
+
|
|
83
|
+
select count(*) as n from sa_ckx;
|
|
84
|
+
→ [{"n":0}]
|
|
85
|
+
|
|
86
|
+
-- ===== CHECK on UPDATE =====
|
|
87
|
+
|
|
88
|
+
create table sa_cku (id integer primary key, v integer, check ((select count(*) from c) = 3));
|
|
89
|
+
insert into sa_cku values (1, 1);
|
|
90
|
+
-- run
|
|
91
|
+
|
|
92
|
+
-- (a) the UPDATE's OWN leading with clause
|
|
93
|
+
with c as (select id from p) update sa_cku set v = 2 where id = 1;
|
|
94
|
+
|
|
95
|
+
select id, v from sa_cku order by id;
|
|
96
|
+
→ [{"id":1,"v":2}]
|
|
97
|
+
|
|
98
|
+
-- (b) definitions INHERITED from an enclosing statement
|
|
99
|
+
with c as (select id from p),
|
|
100
|
+
b as (update sa_cku set v = 3 where id = 1 returning id)
|
|
101
|
+
select count(*) as n from b;
|
|
102
|
+
→ [{"n":1}]
|
|
103
|
+
|
|
104
|
+
select id, v from sa_cku order by id;
|
|
105
|
+
→ [{"id":1,"v":3}]
|
|
106
|
+
|
|
107
|
+
-- ===== CHECK on DELETE =====
|
|
108
|
+
|
|
109
|
+
create table sa_ckd (id integer primary key, v integer, check on delete ((select count(*) from c) = 3));
|
|
110
|
+
insert into sa_ckd values (1, 1), (2, 2);
|
|
111
|
+
-- run
|
|
112
|
+
|
|
113
|
+
-- (a) the DELETE's OWN leading with clause
|
|
114
|
+
with c as (select id from p) delete from sa_ckd where id = 1;
|
|
115
|
+
|
|
116
|
+
select id, v from sa_ckd order by id;
|
|
117
|
+
→ [{"id":2,"v":2}]
|
|
118
|
+
|
|
119
|
+
-- (b) definitions INHERITED from an enclosing statement
|
|
120
|
+
with c as (select id from p),
|
|
121
|
+
b as (delete from sa_ckd where id = 2 returning id)
|
|
122
|
+
select count(*) as n from b;
|
|
123
|
+
→ [{"n":1}]
|
|
124
|
+
|
|
125
|
+
select count(*) as n from sa_ckd;
|
|
126
|
+
→ [{"n":0}]
|
|
127
|
+
|
|
128
|
+
-- ===== NOT NULL column DEFAULT (used by REPLACE substitution) =====
|
|
129
|
+
-- `buildNotNullDefaults` pre-builds the DEFAULT evaluator the constraint runtime
|
|
130
|
+
-- substitutes when REPLACE meets an explicit NULL. Same schema-authored surface.
|
|
131
|
+
|
|
132
|
+
create table sa_nnd (id integer primary key, w integer not null default (select count(*) from c));
|
|
133
|
+
-- run
|
|
134
|
+
|
|
135
|
+
with c as (select id from p),
|
|
136
|
+
b as (insert or replace into sa_nnd (id, w) values (1, null) returning id)
|
|
137
|
+
select count(*) as n from b;
|
|
138
|
+
→ [{"n":1}]
|
|
139
|
+
|
|
140
|
+
select id, w from sa_nnd order by id;
|
|
141
|
+
→ [{"id":1,"w":3}]
|
|
142
|
+
|
|
143
|
+
-- ===== Child-side foreign key (INSERT) =====
|
|
144
|
+
-- The synthesized probe is `exists (select 1 from main.<parent> where …)`. `buildFrom` used
|
|
145
|
+
-- to match a CTE on the BARE table name and ignore the schema qualifier, so a caller
|
|
146
|
+
-- `with fkp as (…)` won even against the schema-qualified synthesized FROM. Two independent
|
|
147
|
+
-- fixes now close that: `schemaAuthoredContext` keeps the caller's CTEs out of this context
|
|
148
|
+
-- at all, and `buildFrom` skips its CTE lookup for a qualified name
|
|
149
|
+
-- (13.10-cte-qualified-name.sqllogic). The arms below still pin the behaviour.
|
|
150
|
+
-- Here the real parent HAS the referenced row and the caller's CTE does not, so a leak
|
|
151
|
+
-- shows up as a spurious `CHECK constraint failed: _fk_…`.
|
|
152
|
+
|
|
153
|
+
create table fkp (id integer primary key);
|
|
154
|
+
insert into fkp values (1);
|
|
155
|
+
create table fkc (id integer primary key, pid integer references fkp(id));
|
|
156
|
+
-- run
|
|
157
|
+
|
|
158
|
+
-- (a) inherited
|
|
159
|
+
with fkp as (select 99 as id),
|
|
160
|
+
b as (insert into fkc values (1, 1) returning id)
|
|
161
|
+
select count(*) as n from b;
|
|
162
|
+
→ [{"n":1}]
|
|
163
|
+
|
|
164
|
+
select id, pid from fkc order by id;
|
|
165
|
+
→ [{"id":1,"pid":1}]
|
|
166
|
+
|
|
167
|
+
-- (b) the INSERT's own leading with clause. This one already behaved before the fix —
|
|
168
|
+
-- `buildInsertStmt` hands the FK builder the bare `ctx`, which never carried the
|
|
169
|
+
-- statement's OWN clause — so it pins the contract rather than the closed leak.
|
|
170
|
+
with fkp as (select 99 as id) insert into fkc values (2, 1);
|
|
171
|
+
|
|
172
|
+
select id, pid from fkc order by id;
|
|
173
|
+
→ [{"id":1,"pid":1},{"id":2,"pid":1}]
|
|
174
|
+
|
|
175
|
+
-- ===== Child-side foreign key (UPDATE) =====
|
|
176
|
+
|
|
177
|
+
create table fkc2 (id integer primary key, pid integer null references fkp(id));
|
|
178
|
+
insert into fkc2 values (1, null);
|
|
179
|
+
-- run
|
|
180
|
+
|
|
181
|
+
with fkp as (select 99 as id),
|
|
182
|
+
b as (update fkc2 set pid = 1 where id = 1 returning id)
|
|
183
|
+
select count(*) as n from b;
|
|
184
|
+
→ [{"n":1}]
|
|
185
|
+
|
|
186
|
+
select id, pid from fkc2 order by id;
|
|
187
|
+
→ [{"id":1,"pid":1}]
|
|
188
|
+
|
|
189
|
+
-- ===== Parent-side RESTRICT foreign key (DELETE) =====
|
|
190
|
+
-- The parent-side `not exists (select 1 from main.<child> where …)` probe is built only
|
|
191
|
+
-- when the batched-RESTRICT gate declines, which a second inbound non-RESTRICT FK forces.
|
|
192
|
+
-- The real child table is EMPTY (the delete is legal); the caller's CTE holds a matching
|
|
193
|
+
-- row, so a leak shows up as a spurious rejection of a legal delete.
|
|
194
|
+
|
|
195
|
+
create table pkp (id integer primary key);
|
|
196
|
+
create table pkc (id integer primary key, pid integer references pkp(id) on delete restrict);
|
|
197
|
+
create table pkc2 (id integer primary key, pid integer references pkp(id) on delete cascade);
|
|
198
|
+
insert into pkp values (1), (2);
|
|
199
|
+
-- run
|
|
200
|
+
|
|
201
|
+
with pkc as (select 1 as pid),
|
|
202
|
+
b as (delete from pkp where id = 1 returning id)
|
|
203
|
+
select count(*) as n from b;
|
|
204
|
+
→ [{"n":1}]
|
|
205
|
+
|
|
206
|
+
select id from pkp order by id;
|
|
207
|
+
→ [{"id":2}]
|
|
208
|
+
|
|
209
|
+
-- The real RESTRICT is still enforced — a caller CTE must not disable it either.
|
|
210
|
+
-- (The rejection comes from the plan-time `not exists` probe, whose diagnostic is the
|
|
211
|
+
-- synthesized constraint's name rather than the runtime RESTRICT wording.)
|
|
212
|
+
insert into pkc values (1, 2);
|
|
213
|
+
-- run
|
|
214
|
+
|
|
215
|
+
with pkc as (select 99 as pid) delete from pkp where id = 2;
|
|
216
|
+
-- error: CHECK constraint failed: _fk_pkc_pid
|
|
217
|
+
|
|
218
|
+
select id from pkp order by id;
|
|
219
|
+
→ [{"id":2}]
|
|
220
|
+
|
|
221
|
+
-- ===== Parent-side RESTRICT foreign key (UPDATE) =====
|
|
222
|
+
|
|
223
|
+
create table qkp (id integer primary key);
|
|
224
|
+
create table qkc (id integer primary key, pid integer references qkp(id) on update restrict);
|
|
225
|
+
create table qkc2 (id integer primary key, pid integer references qkp(id) on update cascade);
|
|
226
|
+
insert into qkp values (1);
|
|
227
|
+
-- run
|
|
228
|
+
|
|
229
|
+
with qkc as (select 1 as pid),
|
|
230
|
+
b as (update qkp set id = 5 where id = 1 returning id)
|
|
231
|
+
select count(*) as n from b;
|
|
232
|
+
→ [{"n":1}]
|
|
233
|
+
|
|
234
|
+
select id from qkp order by id;
|
|
235
|
+
→ [{"id":5}]
|
|
236
|
+
|
|
237
|
+
-- ===== View target: the base op re-planned through the same builders inherits the fix =====
|
|
238
|
+
|
|
239
|
+
create table vsa_t (id integer primary key, w integer default (select count(*) from c));
|
|
240
|
+
create view vsa AS select id, w from vsa_t;
|
|
241
|
+
-- run
|
|
242
|
+
|
|
243
|
+
with c as (select id from p) insert into vsa (id) values (1);
|
|
244
|
+
|
|
245
|
+
select id, w from vsa_t order by id;
|
|
246
|
+
→ [{"id":1,"w":3}]
|
|
247
|
+
|
|
248
|
+
-- ===== Multi-source view INSERT: the anchor key column's declared DEFAULT =====
|
|
249
|
+
-- The shared surrogate is minted ONCE per produced row at the envelope, from the anchor
|
|
250
|
+
-- key column's own `default` — the one schema-authored expression the decomposition
|
|
251
|
+
-- lowering builds itself rather than delegating to `buildInsertStmt`
|
|
252
|
+
-- (`buildKeyDefault` in planner/building/view-mutation-builder.ts). A caller CTE named
|
|
253
|
+
-- after the anchor used to change the high-water mark the allocator observed.
|
|
254
|
+
|
|
255
|
+
create table kd_core (rid integer primary key default (coalesce((select max(rid) from kd_core), 0) + mutation_ordinal()), name text);
|
|
256
|
+
create table kd_contact (rid integer primary key, email text);
|
|
257
|
+
create view kd_v as select c.name as name, k.email as email
|
|
258
|
+
from kd_core c join kd_contact k on k.rid = c.rid;
|
|
259
|
+
insert into kd_core values (100, 'seed');
|
|
260
|
+
-- run
|
|
261
|
+
|
|
262
|
+
with kd_core as (select 0 as rid) insert into kd_v (name, email) values ('Ada', 'ada@x.io');
|
|
263
|
+
|
|
264
|
+
-- 101 (above the real high-water mark 100), not 1 (above the caller's CTE).
|
|
265
|
+
select rid, name from kd_core order by rid;
|
|
266
|
+
→ [{"rid":100,"name":"seed"},{"rid":101,"name":"Ada"}]
|
|
267
|
+
|
|
268
|
+
select rid, email from kd_contact order by rid;
|
|
269
|
+
→ [{"rid":101,"email":"ada@x.io"}]
|
|
270
|
+
|
|
271
|
+
-- ===== Controls: the clearing reaches ONLY the schema-authored expressions =====
|
|
272
|
+
-- (a) The statement that must NOT leak into the default still reads the CTE everywhere
|
|
273
|
+
-- the user wrote it: the insert's source and its scalar subquery see `c` as the 1-row
|
|
274
|
+
-- CTE (`v = 1`), while the column default sees the real 3-row table (`w = 3`).
|
|
275
|
+
|
|
276
|
+
create table sa_both (id integer primary key, v integer, w integer default (select count(*) from c));
|
|
277
|
+
-- run
|
|
278
|
+
|
|
279
|
+
with c as (select id from p),
|
|
280
|
+
b as (insert into sa_both (id, v) select id, (select count(*) from c) from c returning id)
|
|
281
|
+
select count(*) as n from b;
|
|
282
|
+
→ [{"n":1}]
|
|
283
|
+
|
|
284
|
+
select id, v, w from sa_both order by id;
|
|
285
|
+
→ [{"id":10,"v":1,"w":3}]
|
|
286
|
+
|
|
287
|
+
-- (b) A schema-authored expression's OWN `with` clause still binds: the namespace is
|
|
288
|
+
-- cleared on the way IN, not disabled, so a default may declare and read its own CTE —
|
|
289
|
+
-- and a relation that clause reads is still the real table, not the caller's.
|
|
290
|
+
|
|
291
|
+
create table sa_ownwith (id integer primary key, w integer default ((with q as (select count(*) as n from c) select n from q)));
|
|
292
|
+
-- run
|
|
293
|
+
|
|
294
|
+
with c as (select id from p),
|
|
295
|
+
b as (insert into sa_ownwith (id) values (1) returning id)
|
|
296
|
+
select count(*) as n from b;
|
|
297
|
+
→ [{"n":1}]
|
|
298
|
+
|
|
299
|
+
select id, w from sa_ownwith order by id;
|
|
300
|
+
→ [{"id":1,"w":3}]
|
|
301
|
+
|
|
302
|
+
-- Cleanup
|
|
303
|
+
drop table sa_ownwith;
|
|
304
|
+
drop table sa_both;
|
|
305
|
+
drop view kd_v;
|
|
306
|
+
drop view vsa;
|
|
307
|
+
drop table kd_contact;
|
|
308
|
+
drop table kd_core;
|
|
309
|
+
drop table vsa_t;
|
|
310
|
+
drop table qkc2;
|
|
311
|
+
drop table qkc;
|
|
312
|
+
drop table qkp;
|
|
313
|
+
drop table pkc2;
|
|
314
|
+
drop table pkc;
|
|
315
|
+
drop table pkp;
|
|
316
|
+
drop table fkc2;
|
|
317
|
+
drop table fkc;
|
|
318
|
+
drop table fkp;
|
|
319
|
+
drop table sa_nnd;
|
|
320
|
+
drop table sa_ckd;
|
|
321
|
+
drop table sa_cku;
|
|
322
|
+
drop table sa_ckx;
|
|
323
|
+
drop table sa_cki;
|
|
324
|
+
drop table sa_gen;
|
|
325
|
+
drop table sa_def;
|
|
326
|
+
drop table p;
|
|
327
|
+
drop table c;
|
|
328
|
+
-- run
|