@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,147 @@
|
|
|
1
|
+
-- Lens foundation + default name-based aligner (docs/lens.md).
|
|
2
|
+
-- A logical schema deploys against a name-equivalent basis with no explicit
|
|
3
|
+
-- lens; the query processor then sees an ordinary view.
|
|
4
|
+
|
|
5
|
+
-- ===================================
|
|
6
|
+
-- 1. Logical schema over a name-equivalent basis reads basis rows
|
|
7
|
+
-- ===================================
|
|
8
|
+
|
|
9
|
+
declare schema ybasis {
|
|
10
|
+
table t {
|
|
11
|
+
id integer primary key,
|
|
12
|
+
name text
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
-- run
|
|
17
|
+
|
|
18
|
+
apply schema ybasis;
|
|
19
|
+
|
|
20
|
+
-- run
|
|
21
|
+
|
|
22
|
+
insert into ybasis.t values (1, 'alpha'), (2, 'beta');
|
|
23
|
+
|
|
24
|
+
-- run
|
|
25
|
+
|
|
26
|
+
declare logical schema appx {
|
|
27
|
+
table t {
|
|
28
|
+
id integer primary key,
|
|
29
|
+
name text
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
-- run
|
|
34
|
+
|
|
35
|
+
apply schema appx;
|
|
36
|
+
|
|
37
|
+
-- run
|
|
38
|
+
|
|
39
|
+
-- The default mapper compiled `select id, name from ybasis.t`; reads ride the
|
|
40
|
+
-- ordinary view-resolution path.
|
|
41
|
+
select * from appx.t order by id;
|
|
42
|
+
→ [{"id": 1, "name": "alpha"}, {"id": 2, "name": "beta"}]
|
|
43
|
+
|
|
44
|
+
select name from appx.t where id = 2;
|
|
45
|
+
→ [{"name": "beta"}]
|
|
46
|
+
|
|
47
|
+
-- ===================================
|
|
48
|
+
-- 2. Physical constructs are rejected under a logical schema
|
|
49
|
+
-- ===================================
|
|
50
|
+
|
|
51
|
+
declare logical schema badidx {
|
|
52
|
+
table t {
|
|
53
|
+
id integer primary key,
|
|
54
|
+
name text
|
|
55
|
+
}
|
|
56
|
+
index ix on t (name)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
-- run
|
|
60
|
+
|
|
61
|
+
apply schema badidx;
|
|
62
|
+
-- error: index 'ix' is not allowed in logical schema
|
|
63
|
+
|
|
64
|
+
-- ===================================
|
|
65
|
+
-- 3. A logical column with no basis backing errors at apply (name alignment)
|
|
66
|
+
-- ===================================
|
|
67
|
+
|
|
68
|
+
declare logical schema badcol {
|
|
69
|
+
table t {
|
|
70
|
+
id integer primary key,
|
|
71
|
+
name text,
|
|
72
|
+
missing text
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
-- run
|
|
77
|
+
|
|
78
|
+
apply schema badcol;
|
|
79
|
+
-- error: has no basis backing
|
|
80
|
+
|
|
81
|
+
-- ===================================
|
|
82
|
+
-- 4. n-way decomposition synthesis: a columnar split advertised via decomp tags
|
|
83
|
+
-- reads correctly through the synthesized join (optional member outer-joined)
|
|
84
|
+
-- ===================================
|
|
85
|
+
|
|
86
|
+
-- Basis members in main, carrying quereus.lens.decomp.* tags the generic memory
|
|
87
|
+
-- module turns into a primary-storage advertisement (anchor Car_core, optional
|
|
88
|
+
-- Car_perf sharing logical key id).
|
|
89
|
+
create table Car_core (id integer primary key, make text) with tags (
|
|
90
|
+
"quereus.lens.decomp.logical.d1" = 'Car',
|
|
91
|
+
"quereus.lens.decomp.role.d1" = 'primary-storage',
|
|
92
|
+
"quereus.lens.decomp.anchor.d1" = 'Car_core',
|
|
93
|
+
"quereus.lens.decomp.presence.d1" = 'mandatory',
|
|
94
|
+
"quereus.lens.decomp.keykind.d1" = 'logical-tuple',
|
|
95
|
+
"quereus.lens.decomp.key.d1" = 'id',
|
|
96
|
+
"quereus.lens.decomp.col.d1.id" = 'id',
|
|
97
|
+
"quereus.lens.decomp.col.d1.make" = 'make'
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
create table Car_perf (id integer primary key, speed integer) with tags (
|
|
101
|
+
"quereus.lens.decomp.logical.d1" = 'Car',
|
|
102
|
+
"quereus.lens.decomp.role.d1" = 'primary-storage',
|
|
103
|
+
"quereus.lens.decomp.anchor.d1" = 'Car_core',
|
|
104
|
+
"quereus.lens.decomp.presence.d1" = 'optional',
|
|
105
|
+
"quereus.lens.decomp.keykind.d1" = 'logical-tuple',
|
|
106
|
+
"quereus.lens.decomp.key.d1" = 'id',
|
|
107
|
+
"quereus.lens.decomp.col.d1.maxSpeed" = 'speed'
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
-- run
|
|
111
|
+
|
|
112
|
+
insert into Car_core values (1, 'Honda'), (2, 'Mazda');
|
|
113
|
+
insert into Car_perf values (1, 180);
|
|
114
|
+
|
|
115
|
+
-- run
|
|
116
|
+
|
|
117
|
+
declare logical schema appcar {
|
|
118
|
+
table Car {
|
|
119
|
+
id integer primary key,
|
|
120
|
+
make text,
|
|
121
|
+
-- Backed by the OPTIONAL Car_perf member: an unmatched row null-extends maxSpeed
|
|
122
|
+
-- (outer-joined), so the logical column must be nullable. (default_column_nullability
|
|
123
|
+
-- is `not_null`, so this needs the explicit `null`.)
|
|
124
|
+
maxSpeed integer null
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
-- run
|
|
129
|
+
|
|
130
|
+
-- Pin the basis to main explicitly (ybasis also carries tables, so the default
|
|
131
|
+
-- basis is ambiguous without the `over` binding).
|
|
132
|
+
declare lens for appcar over main { }
|
|
133
|
+
|
|
134
|
+
-- run
|
|
135
|
+
|
|
136
|
+
apply schema appcar;
|
|
137
|
+
|
|
138
|
+
-- run
|
|
139
|
+
|
|
140
|
+
-- The default mapper synthesized `Car_core left join Car_perf on id`; car 2 has
|
|
141
|
+
-- no perf row but survives with maxSpeed null (optional member outer-joined).
|
|
142
|
+
select * from appcar.Car order by id;
|
|
143
|
+
→ [{"id": 1, "make": "Honda", "maxSpeed": 180}, {"id": 2, "make": "Mazda", "maxSpeed": null}]
|
|
144
|
+
|
|
145
|
+
-- The maxSpeed column attributes to the Car_perf member in the effective lens.
|
|
146
|
+
select logical_column, advertised_member from quereus_effective_lens('appcar', 'Car') order by logical_column;
|
|
147
|
+
→ [{"logical_column": "id", "advertised_member": "Car_core"}, {"logical_column": "make", "advertised_member": "Car_core"}, {"logical_column": "maxSpeed", "advertised_member": "Car_perf"}]
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
-- 51-materialized-views.sqllogic — materialized view core. Every MV is row-time
|
|
2
|
+
-- maintained: source writes are reflected immediately (within the writing
|
|
3
|
+
-- transaction), and `refresh materialized view` is an explicit full-rebuild verb
|
|
4
|
+
-- (no longer required for currency).
|
|
5
|
+
|
|
6
|
+
-- ===================================
|
|
7
|
+
-- 1. Initial materialization
|
|
8
|
+
-- ===================================
|
|
9
|
+
|
|
10
|
+
create table t (x integer primary key, y text);
|
|
11
|
+
insert into t values (1, 'a'), (2, 'b'), (3, 'c');
|
|
12
|
+
create materialized view mv as select x, y from t;
|
|
13
|
+
|
|
14
|
+
-- MV equals the body at create time
|
|
15
|
+
select * from mv order by x;
|
|
16
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"}]
|
|
17
|
+
|
|
18
|
+
select x, y from t order by x;
|
|
19
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"}]
|
|
20
|
+
|
|
21
|
+
-- ===================================
|
|
22
|
+
-- 2. Source mutation is reflected immediately (row-time); refresh is idempotent
|
|
23
|
+
-- ===================================
|
|
24
|
+
|
|
25
|
+
insert into t values (4, 'd');
|
|
26
|
+
|
|
27
|
+
-- MV reflects the new source row without any refresh
|
|
28
|
+
select * from mv order by x;
|
|
29
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"}]
|
|
30
|
+
|
|
31
|
+
-- refresh is an explicit full rebuild — a no-op for an already-current MV
|
|
32
|
+
refresh materialized view mv;
|
|
33
|
+
select * from mv order by x;
|
|
34
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"}]
|
|
35
|
+
|
|
36
|
+
-- ===================================
|
|
37
|
+
-- 3. Write boundary — DML on the MV name routes through to the source table
|
|
38
|
+
-- (write-through via view updateability), and the backing reflects it within
|
|
39
|
+
-- the statement. Full write-through coverage is in 53.1; this just locks the
|
|
40
|
+
-- core boundary having flipped from "read-only" to "write-through".
|
|
41
|
+
-- ===================================
|
|
42
|
+
|
|
43
|
+
-- insert through the MV lands in the source and is reflected in the MV
|
|
44
|
+
insert into mv values (9, 'z');
|
|
45
|
+
select * from mv order by x;
|
|
46
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"},{"x":9,"y":"z"}]
|
|
47
|
+
select x, y from t order by x;
|
|
48
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"},{"x":9,"y":"z"}]
|
|
49
|
+
|
|
50
|
+
-- update through the MV
|
|
51
|
+
update mv set y = 'Z' where x = 9;
|
|
52
|
+
select y from mv where x = 9;
|
|
53
|
+
→ [{"y":"Z"}]
|
|
54
|
+
|
|
55
|
+
-- delete through the MV (restores the pre-write state for the next section)
|
|
56
|
+
delete from mv where x = 9;
|
|
57
|
+
select * from mv order by x;
|
|
58
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"}]
|
|
59
|
+
|
|
60
|
+
-- Source remains writable; reflected immediately
|
|
61
|
+
insert into t values (5, 'e');
|
|
62
|
+
select * from mv order by x;
|
|
63
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"},{"x":4,"y":"d"},{"x":5,"y":"e"}]
|
|
64
|
+
|
|
65
|
+
-- ===================================
|
|
66
|
+
-- 4. Drop cascades — backing table goes away, name no longer resolves
|
|
67
|
+
-- ===================================
|
|
68
|
+
|
|
69
|
+
drop materialized view mv;
|
|
70
|
+
|
|
71
|
+
select * from mv;
|
|
72
|
+
-- error: not found
|
|
73
|
+
|
|
74
|
+
drop table t;
|
|
75
|
+
|
|
76
|
+
-- ===================================
|
|
77
|
+
-- 5. order by in the body seeds the backing-table scan order
|
|
78
|
+
-- ===================================
|
|
79
|
+
|
|
80
|
+
create table ot (x integer primary key, y integer);
|
|
81
|
+
insert into ot values (1, 30), (2, 10), (3, 20);
|
|
82
|
+
create materialized view omv as select x, y from ot order by y;
|
|
83
|
+
|
|
84
|
+
-- No explicit ORDER BY: scan follows the body's order by y
|
|
85
|
+
select * from omv;
|
|
86
|
+
→ [{"x":2,"y":10},{"x":3,"y":20},{"x":1,"y":30}]
|
|
87
|
+
|
|
88
|
+
drop materialized view omv;
|
|
89
|
+
drop table ot;
|
|
90
|
+
|
|
91
|
+
-- ===================================
|
|
92
|
+
-- 6. Mandatory gate — a body that drops the source primary key is rejected at
|
|
93
|
+
-- create (a materialized view must project its source key so each source row
|
|
94
|
+
-- maps to exactly one backing row). The diagnostic steers to a plain view /
|
|
95
|
+
-- `create table … as`, never a refresh policy.
|
|
96
|
+
-- ===================================
|
|
97
|
+
|
|
98
|
+
create table pt (x integer primary key, y text);
|
|
99
|
+
insert into pt values (1, 'a'), (2, 'b'), (3, 'c');
|
|
100
|
+
create materialized view pmv as select y from pt;
|
|
101
|
+
-- error: cannot be materialized
|
|
102
|
+
-- the failed create rolled the backing table back, so the name is free
|
|
103
|
+
create materialized view pmv as select x, y from pt;
|
|
104
|
+
select * from pmv order by x;
|
|
105
|
+
→ [{"x":1,"y":"a"},{"x":2,"y":"b"},{"x":3,"y":"c"}]
|
|
106
|
+
drop materialized view pmv;
|
|
107
|
+
drop table pt;
|
|
108
|
+
|
|
109
|
+
-- ===================================
|
|
110
|
+
-- 7. Error paths
|
|
111
|
+
-- ===================================
|
|
112
|
+
|
|
113
|
+
refresh materialized view missing_mv;
|
|
114
|
+
-- error: no such materialized view
|
|
115
|
+
|
|
116
|
+
drop materialized view missing_mv;
|
|
117
|
+
-- error: no such materialized view
|
|
118
|
+
|
|
119
|
+
create table plain (id integer primary key);
|
|
120
|
+
drop materialized view plain;
|
|
121
|
+
-- error: not a materialized view
|
|
122
|
+
|
|
123
|
+
-- Unified model: DROP TABLE on a maintained table drops table + derivation
|
|
124
|
+
-- (one record); DROP VIEW still redirects.
|
|
125
|
+
create materialized view plain_mv as select id from plain;
|
|
126
|
+
drop view plain_mv;
|
|
127
|
+
-- error: use DROP MATERIALIZED VIEW
|
|
128
|
+
drop table plain_mv;
|
|
129
|
+
refresh materialized view plain_mv;
|
|
130
|
+
-- error: no such materialized view
|
|
131
|
+
-- the name is free again after the unified drop
|
|
132
|
+
create table plain_mv (z integer primary key);
|
|
133
|
+
drop table plain_mv;
|
|
134
|
+
drop table plain;
|
|
135
|
+
|
|
136
|
+
-- ===================================
|
|
137
|
+
-- 8. Schema-change staleness
|
|
138
|
+
-- ===================================
|
|
139
|
+
|
|
140
|
+
create table s (x integer primary key, y text);
|
|
141
|
+
insert into s values (1, 'a');
|
|
142
|
+
create materialized view smv as select x, y from s;
|
|
143
|
+
|
|
144
|
+
-- Dropping a source makes the body unplannable → staleness diagnostic on next read
|
|
145
|
+
drop table s;
|
|
146
|
+
select * from smv;
|
|
147
|
+
-- error: stale
|
|
148
|
+
drop materialized view smv;
|
|
149
|
+
|
|
150
|
+
-- An incompatible ALTER (dropping a referenced column) → staleness diagnostic
|
|
151
|
+
create table s2 (x integer primary key, y text);
|
|
152
|
+
insert into s2 values (1, 'a');
|
|
153
|
+
create materialized view smv2 as select x, y from s2;
|
|
154
|
+
alter table s2 drop column y;
|
|
155
|
+
select * from smv2;
|
|
156
|
+
-- error: stale
|
|
157
|
+
drop materialized view smv2;
|
|
158
|
+
drop table s2;
|
|
159
|
+
|
|
160
|
+
-- ===================================
|
|
161
|
+
-- 9. refresh reconciles the backing SHAPE to the re-planned body IDENTITY-
|
|
162
|
+
-- PRESERVINGLY when a source ALTER shifts it. A trailing source-column add
|
|
163
|
+
-- reaching a single-source `select *` body is expressible in place (same table
|
|
164
|
+
-- incarnation, via the module's alterTable + a data reconcile). An interleaving
|
|
165
|
+
-- join `select *` — the new orders column lands BEFORE the customers columns —
|
|
166
|
+
-- is inexpressible by append-only adds and is a sited error, leaving the table
|
|
167
|
+
-- and its rows untouched (recoverable by detach→alter→attach or drop+recreate).
|
|
168
|
+
-- ===================================
|
|
169
|
+
|
|
170
|
+
-- (a) in-place reshape: single-source select*, trailing add
|
|
171
|
+
create table rs_src (id integer primary key, a integer);
|
|
172
|
+
insert into rs_src values (1, 10);
|
|
173
|
+
create materialized view rsv as select * from rs_src;
|
|
174
|
+
|
|
175
|
+
-- before the alter: 2 columns
|
|
176
|
+
select * from rsv;
|
|
177
|
+
→ [{"id":1,"a":10}]
|
|
178
|
+
|
|
179
|
+
alter table rs_src add column b integer default 5;
|
|
180
|
+
refresh materialized view rsv;
|
|
181
|
+
|
|
182
|
+
-- after: the appended column reached the backing in place — value under the right label
|
|
183
|
+
select * from rsv;
|
|
184
|
+
→ [{"id":1,"a":10,"b":5}]
|
|
185
|
+
|
|
186
|
+
-- row-time maintenance binds to the reshaped backing — a later source row carries the new column
|
|
187
|
+
insert into rs_src values (2, 20, 7);
|
|
188
|
+
select * from rsv where id = 2;
|
|
189
|
+
→ [{"id":2,"a":20,"b":7}]
|
|
190
|
+
|
|
191
|
+
drop materialized view rsv;
|
|
192
|
+
drop table rs_src;
|
|
193
|
+
|
|
194
|
+
-- (b) inexpressible interleave: a join select* whose new column lands mid-output → sited error
|
|
195
|
+
create table rs_cust (id integer primary key, name text not null);
|
|
196
|
+
create table rs_ord (id integer primary key, customer_id integer not null references rs_cust(id), amt integer not null);
|
|
197
|
+
create materialized view rsj as select * from rs_ord o join rs_cust c on o.customer_id = c.id;
|
|
198
|
+
insert into rs_cust values (1, 'alice');
|
|
199
|
+
insert into rs_ord values (10, 1, 100);
|
|
200
|
+
|
|
201
|
+
-- before the alter: 5 columns (the colliding c.id surfaces as id:1)
|
|
202
|
+
select * from rsj;
|
|
203
|
+
→ [{"id":10,"customer_id":1,"amt":100,"id:1":1,"name":"alice"}]
|
|
204
|
+
|
|
205
|
+
alter table rs_ord add column extra text default 'x';
|
|
206
|
+
refresh materialized view rsj;
|
|
207
|
+
-- error: changed incompatibly
|
|
208
|
+
|
|
209
|
+
-- the table is untouched: the stored snapshot still reads at the old 5-column shape
|
|
210
|
+
select * from rsj;
|
|
211
|
+
→ [{"id":10,"customer_id":1,"amt":100,"id:1":1,"name":"alice"}]
|
|
212
|
+
|
|
213
|
+
drop materialized view rsj;
|
|
214
|
+
drop table rs_ord;
|
|
215
|
+
drop table rs_cust;
|
|
216
|
+
|
|
217
|
+
-- ===================================
|
|
218
|
+
-- 10. An explicit column list is a declared interface: a refresh whose body output
|
|
219
|
+
-- count shifted under it errors (rather than silently widening the list).
|
|
220
|
+
-- ===================================
|
|
221
|
+
|
|
222
|
+
create table rs_t (x integer primary key, y text);
|
|
223
|
+
insert into rs_t values (1, 'a');
|
|
224
|
+
create materialized view rs_decl(a, b) as select * from rs_t;
|
|
225
|
+
alter table rs_t add column z integer null;
|
|
226
|
+
refresh materialized view rs_decl;
|
|
227
|
+
-- error: drop and recreate
|
|
228
|
+
drop materialized view rs_decl;
|
|
229
|
+
drop table rs_t;
|
|
230
|
+
|
|
231
|
+
-- ===================================
|
|
232
|
+
-- 11. In-transaction source ALTER + REFRESH (mv-refresh-intxn-altered-source-stale-read).
|
|
233
|
+
-- §9 is the autocommit analog; here the alter+refresh run inside one explicit
|
|
234
|
+
-- transaction over a single-source `select *` MV (a trailing add → in-place
|
|
235
|
+
-- reshape). With an MV over the source, an autocommit-collapsed source
|
|
236
|
+
-- connection is detached from its manager's map but stays in the Database
|
|
237
|
+
-- registry; `MemoryTable.ensureConnection` reuses it for the in-transaction read.
|
|
238
|
+
-- ensureSchemaChangeSafety formerly re-pointed only connections still in the map,
|
|
239
|
+
-- so the detached one kept a stale pre-alter readLayer (2-column shape) — the
|
|
240
|
+
-- same-transaction source read missed `extra`, and refresh reshaped+refilled the
|
|
241
|
+
-- backing with misaligned data. The fix re-points every registered source
|
|
242
|
+
-- connection at the new base, so both the direct source read and the refresh
|
|
243
|
+
-- observe the post-alter 3-column shape.
|
|
244
|
+
-- ===================================
|
|
245
|
+
|
|
246
|
+
create table itx_src (id integer primary key, a integer);
|
|
247
|
+
create materialized view itxv as select * from itx_src;
|
|
248
|
+
insert into itx_src values (10, 100);
|
|
249
|
+
|
|
250
|
+
-- a direct autocommit source scan leaves a detached-but-registered source connection
|
|
251
|
+
select * from itx_src order by id;
|
|
252
|
+
→ [{"id":10,"a":100}]
|
|
253
|
+
|
|
254
|
+
select * from itxv;
|
|
255
|
+
→ [{"id":10,"a":100}]
|
|
256
|
+
|
|
257
|
+
begin;
|
|
258
|
+
alter table itx_src add column extra text default 'x';
|
|
259
|
+
-- (b) the same-transaction direct source read returns the new column + backfilled default
|
|
260
|
+
select * from itx_src order by id;
|
|
261
|
+
→ [{"id":10,"a":100,"extra":"x"}]
|
|
262
|
+
-- (a) refresh reshapes the backing in place from the post-alter source — values under right labels
|
|
263
|
+
refresh materialized view itxv;
|
|
264
|
+
commit;
|
|
265
|
+
|
|
266
|
+
select * from itxv;
|
|
267
|
+
→ [{"id":10,"a":100,"extra":"x"}]
|
|
268
|
+
|
|
269
|
+
-- row-time maintenance still binds to the reshaped backing post-commit
|
|
270
|
+
insert into itx_src values (20, 200, 'custom');
|
|
271
|
+
select * from itxv where id = 20;
|
|
272
|
+
→ [{"id":20,"a":200,"extra":"custom"}]
|
|
273
|
+
|
|
274
|
+
drop materialized view itxv;
|
|
275
|
+
drop table itx_src;
|
|
276
|
+
|
|
277
|
+
-- ===================================
|
|
278
|
+
-- 11. Unified maintained-table model: one catalog entry, one namespace,
|
|
279
|
+
-- write-through dispatch order
|
|
280
|
+
-- ===================================
|
|
281
|
+
|
|
282
|
+
create table um_src (id integer primary key, v text not null);
|
|
283
|
+
insert into um_src values (1, 'a');
|
|
284
|
+
create materialized view um_mv as select id, v from um_src;
|
|
285
|
+
|
|
286
|
+
-- exactly ONE catalog entry for the maintained table, surfaced as a
|
|
287
|
+
-- materialized view with its canonical create-materialized-view DDL
|
|
288
|
+
select type, name from schema() where name like 'um_%' order by name;
|
|
289
|
+
→ [{"type":"materialized_view","name":"um_mv"},{"type":"table","name":"um_src"}]
|
|
290
|
+
|
|
291
|
+
-- one namespace: a table cannot squat the MV's name, an MV cannot squat a table's
|
|
292
|
+
create table um_mv (z integer primary key);
|
|
293
|
+
-- error: already exists
|
|
294
|
+
create materialized view um_src as select id from um_src;
|
|
295
|
+
-- error: already exists
|
|
296
|
+
|
|
297
|
+
-- DML naming the maintained table routes write-through to the SOURCE (never the
|
|
298
|
+
-- direct table write), even though the name now plain-resolves as a table
|
|
299
|
+
insert into um_mv values (2, 'b');
|
|
300
|
+
select * from um_src order by id;
|
|
301
|
+
→ [{"id":1,"v":"a"},{"id":2,"v":"b"}]
|
|
302
|
+
update um_mv set v = 'B' where id = 2;
|
|
303
|
+
select v from um_src where id = 2;
|
|
304
|
+
→ [{"v":"B"}]
|
|
305
|
+
delete from um_mv where id = 2;
|
|
306
|
+
select count(*) n from um_src;
|
|
307
|
+
→ [{"n":1}]
|
|
308
|
+
|
|
309
|
+
-- ALTER TABLE on the maintained table: structural changes are rejected (the
|
|
310
|
+
-- shape is defined by the body), tag actions steer to ALTER MATERIALIZED VIEW
|
|
311
|
+
alter table um_mv add column extra integer;
|
|
312
|
+
-- error: materialized view
|
|
313
|
+
alter table um_mv rename column v to w;
|
|
314
|
+
-- error: materialized view
|
|
315
|
+
alter table um_mv set tags (purpose = 'x');
|
|
316
|
+
-- error: ALTER MATERIALIZED VIEW
|
|
317
|
+
|
|
318
|
+
-- ...but RENAME is an ordinary rename plus a maintenance re-key: write-through
|
|
319
|
+
-- and row-time maintenance stay live under the new name
|
|
320
|
+
alter table um_mv rename to um_mv2;
|
|
321
|
+
insert into um_src values (3, 'c');
|
|
322
|
+
select * from um_mv2 order by id;
|
|
323
|
+
→ [{"id":1,"v":"a"},{"id":3,"v":"c"}]
|
|
324
|
+
insert into um_mv2 values (4, 'd');
|
|
325
|
+
select v from um_src where id = 4;
|
|
326
|
+
→ [{"v":"d"}]
|
|
327
|
+
select type, name from schema() where name like 'um_%' order by name;
|
|
328
|
+
→ [{"type":"materialized_view","name":"um_mv2"},{"type":"table","name":"um_src"}]
|
|
329
|
+
delete from um_mv2 where id > 1;
|
|
330
|
+
alter table um_mv2 rename to um_mv;
|
|
331
|
+
|
|
332
|
+
-- create-time tags live on the unified record and survive a refresh
|
|
333
|
+
drop materialized view um_mv;
|
|
334
|
+
create materialized view um_mv as select id, v from um_src with tags (purpose = 'demo');
|
|
335
|
+
refresh materialized view um_mv;
|
|
336
|
+
select tags from schema() where name = 'um_mv';
|
|
337
|
+
→ [{"tags":"{\"purpose\":\"demo\"}"}]
|
|
338
|
+
|
|
339
|
+
drop materialized view um_mv;
|
|
340
|
+
drop table um_src;
|
|
341
|
+
|
|
342
|
+
-- ===================================
|
|
343
|
+
-- BLOB backing primary key under the full-rebuild floor
|
|
344
|
+
-- ===================================
|
|
345
|
+
-- A `select distinct` body is maintained by the full-rebuild floor, which applies
|
|
346
|
+
-- a single keyed 'replace-all' diff against the backing. That diff builds an
|
|
347
|
+
-- in-memory set of the new rows' primary keys; a single-column BLOB PK is stored
|
|
348
|
+
-- in it as a bare Uint8Array, which inheritree's default freeze-on-insert cannot
|
|
349
|
+
-- hold (bug-in-subquery-blob-values-crash — Object.freeze rejects a non-empty
|
|
350
|
+
-- array buffer view). Any source write to such an MV crashed.
|
|
351
|
+
|
|
352
|
+
create table bpk_src (id integer primary key, b blob);
|
|
353
|
+
insert into bpk_src values (1, x'6162'), (2, x'6164');
|
|
354
|
+
create materialized view bpk_mv as select distinct b from bpk_src;
|
|
355
|
+
|
|
356
|
+
select count(*) as n from bpk_mv;
|
|
357
|
+
→ [{"n":2}]
|
|
358
|
+
|
|
359
|
+
-- a source insert drives the rebuild diff: new key, and a duplicate that must not
|
|
360
|
+
-- add a row
|
|
361
|
+
insert into bpk_src values (3, x'6169'), (4, x'6162');
|
|
362
|
+
select count(*) as n from bpk_mv;
|
|
363
|
+
→ [{"n":3}]
|
|
364
|
+
|
|
365
|
+
-- a delete that removes the last occurrence of a value drops it from the backing
|
|
366
|
+
delete from bpk_src where b = x'6169';
|
|
367
|
+
select count(*) as n from bpk_mv;
|
|
368
|
+
→ [{"n":2}]
|
|
369
|
+
|
|
370
|
+
-- explicit full rebuild over the same BLOB-keyed backing
|
|
371
|
+
refresh materialized view bpk_mv;
|
|
372
|
+
select count(*) as n from bpk_mv;
|
|
373
|
+
→ [{"n":2}]
|
|
374
|
+
|
|
375
|
+
drop materialized view bpk_mv;
|
|
376
|
+
drop table bpk_src;
|