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: implement CREATE SCHEMA ... AUTHORIZATION #53583

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Aug 28, 2020

Fixes #53559.

This commit adds the CREATE SCHEMA ... AUTHORIZATION command. When
authorization is provided, the target user is given ownership of the
schema. If the schema name is not provided, then the schema is named the
same name as the target role.

Release justification: low risk updates to new functionality
Release note (sql change): Support the CREATE SCHEMA ... AUTHORIZATION
command.

@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:

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @lucy-zhang, @rohany, and @solongordon)


pkg/sql/create_schema.go, line 73 at r1 (raw file):

Quoted 4 lines of code…
	// Check validity of the schema name.
	if err := schemadesc.IsSchemaNameValid(schemaName); err != nil {
		return err
	}

Should we do this check before the existence check?


pkg/sql/parser/sql.y, line 5297 at r1 (raw file):

// %Category: DDL
// %Text:
// CREATE SCHEMA [IF NOT EXISTS] <schemaname> [AUTHORIZATION <rolename>]

nit: should this be CREATE SCHEMA [IF NOT EXISTS] { <schemaname> | [ [<schemaname>] AUTHORIZATION <rolename>] }

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

Done, addressed both comments

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 31, 2020

Build failed (retrying...):

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner, @lucy-zhang, @rohany, and @solongordon)


pkg/sql/create_schema.go, line 59 at r2 (raw file):

	// Check validity of the schema name.
	if err := schemadesc.IsSchemaNameValid(schemaName); err != nil {

seems like re-arranging this broke some tests 😬

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner, @lucy-zhang, @rohany, and @solongordon)


pkg/sql/parser/sql.y, line 5297 at r2 (raw file):

// %Category: DDL
// %Text:
// CREATE SCHEMA [IF NOT EXISTS] { <schemaname> | [<schemaname>] [AUTHORIZATION <rolename>] }

also, I don't think this means the same thing as what I wrote. This seems to imply that you could omit both elements of the RHS. I think you could do:

CREATE SCHEMA [IF NOT EXISTS] { <schemaname> | [<schemaname>] AUTHORIZATION <rolename> }

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

Ah yeah you're right, can't have brackets around the AUTHORIZATION ...

@knz
Copy link
Contributor

knz commented Aug 31, 2020

this is failing ci - removing from the bors queue

bors r-

@craig
Copy link
Contributor

craig bot commented Aug 31, 2020

Canceled.

Fixes cockroachdb#53559.

This commit adds the `CREATE SCHEMA ... AUTHORIZATION` command. When
authorization is provided, the target user is given ownership of the
schema. If the schema name is not provided, then the schema is named the
same name as the target role.

Release justification: low risk updates to new functionality
Release note (sql change): Support the `CREATE SCHEMA ... AUTHORIZATION`
command.
@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

Updated the help message.

Seems like we need to keep the name check after the existence check.

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

bors r+

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

bors r-

@craig
Copy link
Contributor

craig bot commented Aug 31, 2020

Canceled.

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

@ajwerner can you stamp this?

Copy link
Contributor

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 6 files at r1, 2 of 2 files at r3.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rohany and @solongordon)

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:

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

@rohany
Copy link
Contributor Author

rohany commented Aug 31, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 31, 2020

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented Sep 1, 2020

Build succeeded:

@craig craig bot merged commit f2056ba into cockroachdb:master Sep 1, 2020
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.

CREATE SCHEMA... AUTHORIZATION is unsupported
5 participants