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

parser: XXXDatabaseStmt now use CIStr for DB name #35668

Merged
merged 8 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address comment
Signed-off-by: lance6716 <lance6716@gmail.com>
  • Loading branch information
lance6716 committed Jun 23, 2022
commit 25fa483c0e35843c6a1a2ef26f1c98c388e98cc9
2 changes: 1 addition & 1 deletion br/pkg/lightning/restore/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func createIfNotExistsStmt(p *parser.Parser, createTable, dbName, tblName string
for _, stmt := range stmts {
switch node := stmt.(type) {
case *ast.CreateDatabaseStmt:
node.Name = dbName
node.Name = model.NewCIStr(dbName)
node.IfNotExists = true
case *ast.CreateTableStmt:
node.Table.Schema = model.NewCIStr(dbName)
Expand Down
6 changes: 3 additions & 3 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4168,7 +4168,7 @@ func (b *PlanBuilder) buildDDL(ctx context.Context, node ast.DDLNode) (Plan, err
authErr = ErrDBaccessDenied.GenWithStackByArgs("ALTER", b.ctx.GetSessionVars().User.AuthUsername,
b.ctx.GetSessionVars().User.AuthHostname, v.Name)
}
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.AlterPriv, v.Name.O, "", "", authErr)
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.AlterPriv, v.Name.L, "", "", authErr)
case *ast.AlterTableStmt:
if b.ctx.GetSessionVars().User != nil {
authErr = ErrTableaccessDenied.GenWithStackByArgs("ALTER", b.ctx.GetSessionVars().User.AuthUsername,
Expand Down Expand Up @@ -4246,7 +4246,7 @@ func (b *PlanBuilder) buildDDL(ctx context.Context, node ast.DDLNode) (Plan, err
authErr = ErrDBaccessDenied.GenWithStackByArgs(b.ctx.GetSessionVars().User.AuthUsername,
b.ctx.GetSessionVars().User.AuthHostname, v.Name)
}
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.CreatePriv, v.Name.O,
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.CreatePriv, v.Name.L,
"", "", authErr)
case *ast.CreateIndexStmt:
if b.ctx.GetSessionVars().User != nil {
Expand Down Expand Up @@ -4340,7 +4340,7 @@ func (b *PlanBuilder) buildDDL(ctx context.Context, node ast.DDLNode) (Plan, err
authErr = ErrDBaccessDenied.GenWithStackByArgs(b.ctx.GetSessionVars().User.AuthUsername,
b.ctx.GetSessionVars().User.AuthHostname, v.Name)
}
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.DropPriv, v.Name.O,
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.DropPriv, v.Name.L,
"", "", authErr)
case *ast.DropIndexStmt:
if b.ctx.GetSessionVars().User != nil {
Expand Down
6 changes: 3 additions & 3 deletions planner/core/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,20 +716,20 @@ func (p *preprocessor) checkSetOprSelectList(stmt *ast.SetOprSelectList) {
}

func (p *preprocessor) checkCreateDatabaseGrammar(stmt *ast.CreateDatabaseStmt) {
if isIncorrectName(stmt.Name.O) {
if isIncorrectName(stmt.Name.L) {
p.err = dbterror.ErrWrongDBName.GenWithStackByArgs(stmt.Name)
}
}

func (p *preprocessor) checkAlterDatabaseGrammar(stmt *ast.AlterDatabaseStmt) {
// for 'ALTER DATABASE' statement, database name can be empty to alter default database.
if isIncorrectName(stmt.Name.O) && !stmt.AlterDefaultDatabase {
if isIncorrectName(stmt.Name.L) && !stmt.AlterDefaultDatabase {
p.err = dbterror.ErrWrongDBName.GenWithStackByArgs(stmt.Name)
}
}

func (p *preprocessor) checkDropDatabaseGrammar(stmt *ast.DropDatabaseStmt) {
if isIncorrectName(stmt.Name.O) {
if isIncorrectName(stmt.Name.L) {
p.err = dbterror.ErrWrongDBName.GenWithStackByArgs(stmt.Name)
}
}
Expand Down