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

sql/schemachanger: add enum type values as an element #83802

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Jul 5, 2022

Previously, our decomposition of enum types only included
an element for the type itself. This was inadequate because
for multi-region support we need to be able to iterate over
the values for an enum. This patch adds further decomposition
for enums.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: other than the testdata file I don't think you meant to add

This was inadequate because
for multi-region support we need to be able to iterate over
the values for an enum.

We'll need this for adding and dropping enum values too.

Reviewed 24 of 25 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner and @fqazi)


pkg/sql/schemachanger/testdata/drop line 1683 at r1 (raw file):

# end PostCommitPhase

setup

does this need to be split into multiple files / is this adding back a deleted file?

Code quote:

setup
CREATE DATABASE db1;
CREATE SCHEMA db1.sc1;
CREATE SEQUENCE db1.public.sq1;
CREATE SEQUENCE db1.sc1.sq1;
CREATE TABLE db1.sc1.t1 (id INT PRIMARY KEY, name varchar(256), val int DEFAULT nextval('db1.sc1.sq1'));
CREATE TABLE db1.public.t1 (id INT PRIMARY KEY, name varchar(256), val int DEFAULT nextval('db1.public.sq1'));
CREATE TABLE db1.public.ttl (id INT PRIMARY KEY) WITH (ttl_expire_after = '10 minutes');
CREATE VIEW db1.sc1.v1 AS (SELECT name FROM db1.sc1.t1);
CREATE VIEW db1.sc1.v2 AS (SELECT name AS n1, name AS n2 FROM db1.sc1.v1);
CREATE VIEW db1.sc1.v3 AS (SELECT name, n1 FROM db1.sc1.v1, db1.sc1.v2);
CREATE VIEW db1.sc1.v4 AS (SELECT n2, n1 FROM db1.sc1.v2);
CREATE TYPE db1.sc1.typ AS ENUM('a');
CREATE VIEW db1.sc1.v5 AS (SELECT 'a'::db1.sc1.typ::string AS k, n2, n1 from db1.sc1.v4);
----
...
+database {0 0 db1} -> 111
+schema {111 0 public} -> 112
+schema {111 0 sc1} -> 113
+object {111 112 sq1} -> 114
+object {111 113 sq1} -> 115
+object {111 113 t1} -> 116
+object {111 112 t1} -> 117
+object {111 112 ttl} -> 118
+object {111 113 v1} -> 119
+object {111 113 v2} -> 120
+object {111 113 v3} -> 121
+object {111 113 v4} -> 122
+object {111 113 typ} -> 123
+object {111 113 _typ} -> 124
+object {111 113 v5} -> 125

test
DROP DATABASE db1 CASCADE

Copy link
Collaborator Author

@fqazi fqazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner)


pkg/sql/schemachanger/testdata/drop line 1683 at r1 (raw file):

Previously, ajwerner wrote…

does this need to be split into multiple files / is this adding back a deleted file?

This was accidentally re-added. Dropping it from here
Done.

@fqazi fqazi marked this pull request as ready for review July 5, 2022 13:32
@fqazi fqazi requested a review from a team July 5, 2022 13:32
@ajwerner
Copy link
Contributor

ajwerner commented Jul 5, 2022

        -## StatementPhase stage 1 of 1 with 17 MutationType ops
        +## StatementPhase stage 1 of 1 with 14 MutationType ops

Seems you need a rewrite

Previously, our decomposition of enum types only included
an element for the type itself. This was inadequate because
for multi-region support we need to be able to iterate over
the values for an enum. This patch adds further decomposition
for enums.

Release note: None
@fqazi
Copy link
Collaborator Author

fqazi commented Jul 5, 2022

@ajwerner TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 5, 2022

Build succeeded:

@craig craig bot merged commit cff9d8b into cockroachdb:master Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants