Skip to content

sql: introduce CREATE TENANT syntax#91595

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
adityamaru:create-tenant
Nov 11, 2022
Merged

sql: introduce CREATE TENANT syntax#91595
craig[bot] merged 2 commits intocockroachdb:masterfrom
adityamaru:create-tenant

Conversation

@adityamaru
Copy link
Copy Markdown
Contributor

@adityamaru adityamaru commented Nov 9, 2022

This change introduces:

CREATE TENANT

The query automatically assigns the tenant the first
available ID. This could be an ID that was previously
used by a tenant that has been dropped and GC'ed.

Fixes: #91235

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@adityamaru adityamaru force-pushed the create-tenant branch 3 times, most recently from 9eafac2 to ba54cca Compare November 9, 2022 19:19
@adityamaru adityamaru marked this pull request as ready for review November 9, 2022 19:21
@adityamaru adityamaru requested a review from a team as a code owner November 9, 2022 19:21
@adityamaru adityamaru requested review from a team, knz and lidorcarmel and removed request for a team November 9, 2022 19:21
@adityamaru
Copy link
Copy Markdown
Contributor Author

First commit is #91518.

@adityamaru
Copy link
Copy Markdown
Contributor Author

actually hold off on the review for this, i want to try something

@adityamaru adityamaru requested a review from a team as a code owner November 10, 2022 15:33
Copy link
Copy Markdown
Collaborator

@rafiss rafiss 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 (waiting on @adityamaru, @knz, and @lidorcarmel)


-- commits line 34 at r3:
i just saw this PR fly by, so i might be missing some context, but i had a question. adding CREATE TENANT to the release notes seems like it would also require a lot of extra background docs to explain what tenants are. so far the docs team has explicitly avoided documenting multitenancy, so i just want to make sure that documentation work already tracked somewhere for that team

@adityamaru adityamaru requested a review from a team November 10, 2022 17:25
@adityamaru
Copy link
Copy Markdown
Contributor Author

it would also require a lot of extra background docs

You're right! I discussed this with the team and we'll default to no release notes for now. We might add some private preview docs closer to the release data but that can be done independently. Thanks for flagging.

@adityamaru
Copy link
Copy Markdown
Contributor Author

@lidorcarmel @knz this is ready for a look. I added a type TenantName string to strongly type the string params we're passing around. Let me know what you think!

@ajstorm
Copy link
Copy Markdown
Collaborator

ajstorm commented Nov 10, 2022

You're right! I discussed this with the team and we'll default to no release notes for now.

Does it makes sense to also skip the documentation on the CREATE TENANT statement until we have confirmation that we want this exposed?

@rafiss
Copy link
Copy Markdown
Collaborator

rafiss commented Nov 10, 2022

Yeah we need to make sure this doesn't show up in the auto-generated docs + diagrams

name roachpb.TenantName
}

func (p *planner) CreateTenantNode(_ context.Context, n *tree.CreateTenant) (planNode, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wondering, is this where we should verify things like name uniqueness and maybe permissions? or should we rely on startExec to fail?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • name uniqueness is ensured via the UNIQUE index on the column.
  • permission is ensured inside the CreateTenant function.

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Nice to see this making progress.

Looks like others have caught the important things. I've just left a few nitpicks.

This change introduces:

CREATE TENANT <tenant-name>

The query  automatically assigns the tenant the first
available ID. This could be an ID that was previously
used by a tenant that has been dropped and GC'ed.

Fixes: cockroachdb#91235

Release note: None
@adityamaru
Copy link
Copy Markdown
Contributor Author

Yeah we need to make sure this doesn't show up in the auto-generated docs + diagrams

So I see that ALTER TENANT has all the generated diagrams but isn't on our public facing docs. I'm working with @kathancox to ensure this follows the same pattern and doesn't show up anywhere.

@katmayb
Copy link
Copy Markdown

katmayb commented Nov 11, 2022

Yeah we need to make sure this doesn't show up in the auto-generated docs + diagrams

So I see that ALTER TENANT has all the generated diagrams but isn't on our public facing docs. I'm working with @kathancox to ensure this follows the same pattern and doesn't show up anywhere.

As long as the release note is marked with None and a writer isn’t tasked with creating docs for any of these sql statements, it will not be documented. Assuming these don’t affect/change any of the existing, documented sql syntax (that are already pulled in via a remote_include) then this will not be pulled through to docs. For sql diagrams, writers have to specifically use a remote_include in a .md file to pull in the sql diagram.

@adityamaru
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r=stevendanna,lidorcarmel

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 11, 2022

Build succeeded:

@craig craig bot merged commit 45abe91 into cockroachdb:master Nov 11, 2022
@adityamaru adityamaru deleted the create-tenant branch November 11, 2022 20:56
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.

sql: introduce CREATE TENANT $1 grammar

8 participants