Skip to content

Commit

Permalink
sql: miscellaneous fixes to the CONVERT TO SCHEMA command
Browse files Browse the repository at this point in the history
Release justification: low risk updates to new functionality
Release note (sql change): Disallow the `CONVERT TO SCHEMA` command on
the current database.
  • Loading branch information
rohany committed Aug 31, 2020
1 parent 42e73f7 commit 61eb6af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/sql/reparent_database.go
Expand Up @@ -52,6 +52,10 @@ func (p *planner) ReparentDatabase(
clusterversion.VersionByKey(clusterversion.VersionUserDefinedSchemas))
}

if string(n.Name) == p.CurrentDatabase() {
return nil, pgerror.DangerousStatementf("CONVERT TO SCHEMA on current database")
}

db, err := p.ResolveMutableDatabaseDescriptor(ctx, string(n.Name), true /* required */)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/sem/tree/stmt.go
Expand Up @@ -596,7 +596,7 @@ func (*RenameDatabase) StatementTag() string { return "RENAME DATABASE" }
func (*ReparentDatabase) StatementType() StatementType { return DDL }

// StatementTag returns a short string identifying the type of statement.
func (*ReparentDatabase) StatementTag() string { return "TODO (rohany): Implement" }
func (*ReparentDatabase) StatementTag() string { return "CONVERT TO SCHEMA" }

// StatementType implements the Statement interface.
func (*RenameIndex) StatementType() StatementType { return DDL }
Expand Down

0 comments on commit 61eb6af

Please sign in to comment.