Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support partial UniqueWithoutIndex referencing types #96678

Closed
Xiang-Gu opened this issue Feb 6, 2023 · 1 comment · Fixed by #96681
Closed

Support partial UniqueWithoutIndex referencing types #96678

Xiang-Gu opened this issue Feb 6, 2023 · 1 comment · Fixed by #96681
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@Xiang-Gu
Copy link
Contributor

Xiang-Gu commented Feb 6, 2023

Today, we didn't correctly support UniqueWithoutIndex constraint that references another user-defined
type, both in the legacy and declarative schema changer.

Namely, if we add the unique_without_index constraint as follows:

CREATE TYPE typ AS ENUM ('a', 'b');
CREATE TABLE t (i INT PRIMARY KEY, j STRING);
SET experimental_enable_unique_without_index_constraints = true;
ALTER TABLE t ADD UNIQUE WITHOUT INDEX (j) WHERE (j::typ != 'a');

Then we inspect the type descriptor

SELECT jsonb_pretty(crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) ) FROM system.descriptor WHERE id = 112;

we will see there is no back-reference from this type descriptor typ back to table t.

This happens both in the legacy and declarative schema changer.

Jira issue: CRDB-24273

@Xiang-Gu Xiang-Gu added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Feb 6, 2023
@Xiang-Gu Xiang-Gu self-assigned this Feb 6, 2023
@blathers-crl blathers-crl bot added the T-sql-schema-deprecated Use T-sql-foundations instead label Feb 6, 2023
@Xiang-Gu
Copy link
Contributor Author

Xiang-Gu commented Feb 6, 2023

Note: I didn't mention "UWI referencing sequences" because that's not implemented/allowed (and probably will never be supported/allowed). See here. We will thus only address the issue of a UWI referencing types.

@craig craig bot closed this as completed in f640acb Feb 7, 2023
@exalate-issue-sync exalate-issue-sync bot reopened this May 10, 2023
@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
@rafiss rafiss closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants