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: prohibit DROP COLUMN on REGIONAL BY ROW column reference #60600

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

otan
Copy link
Contributor

@otan otan commented Feb 16, 2021

The foundation of REGIONAL BY ROW is to use a column which dictates the
location to which the row is stored. As such, we should prevent the
column from being used as a DROP COLUMN reference.

Resolves #59117

Release note: None

@otan otan requested review from ajstorm and a team February 16, 2021 00:27
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@ajstorm ajstorm left a comment

Choose a reason for hiding this comment

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

Ultra nit: In the commit record, it might be more correct to say "the location in which the rows is stored".

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan)


pkg/sql/alter_table.go, line 409 at r1 (raw file):

						pgerror.Newf(
							pgcode.InvalidColumnReference,
							"cannot drop column %s as it is used as the REGIONAL BY ROW column reference",

Nit: "as it is used to store the region in a REGIONAL BY ROW table"?


pkg/sql/alter_table.go, line 412 at r1 (raw file):

							t.Column,
						),
						"You must change the table locality before dropping this table.",

Nit: Or alter the table to choose a different column to use for the region info?


pkg/sql/catalog/tabledesc/structured.go, line 4029 at r1 (raw file):

func (desc *wrapper) GetRegionalByRowTableRegionColumnName() (tree.Name, error) {
	if !desc.IsLocalityRegionalByRow() {
		return "", errors.Newf("%s is not REGIONAL BY ROW", desc.Name)

I'd think that this should be an Assertf.

@otan
Copy link
Contributor Author

otan commented Feb 16, 2021

bors r=ajstorm

@otan
Copy link
Contributor Author

otan commented Feb 16, 2021

bors r-

@craig
Copy link
Contributor

craig bot commented Feb 16, 2021

Canceled.

The foundation of REGIONAL BY ROW is to use a column which dictates the
location in which the row is stored. As such, we should prevent the
column from being used as a DROP COLUMN reference.

Release note: None
@otan
Copy link
Contributor Author

otan commented Feb 16, 2021

bors r=ajstorm

@craig
Copy link
Contributor

craig bot commented Feb 16, 2021

Build succeeded:

@craig craig bot merged commit 3c4aaab into cockroachdb:master Feb 16, 2021
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: Block DROP COLUMN (crdb_region or AS) on REGIONAL BY ROW
3 participants