Skip to content

Commit

Permalink
fix: Check if the SQL is valid when creating a MySQL account.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuriwuyun committed Dec 9, 2024
1 parent 94e8031 commit 3d12856
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/lorry/engines/mysql/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ func (mgr *Manager) DescribeUser(ctx context.Context, userName string) (*models.
return user, nil
}

func (mgr *Manager) CreateUser(ctx context.Context, userName, password, _ string) error {
func (mgr *Manager) CreateUser(ctx context.Context, userName, password, statement string) error {
if !strings.HasPrefix(statement, "CREATE ") {
return fmt.Errorf("the user %s is created with invalid sql %s, wait and try again", userName, statement)
}

sql := fmt.Sprintf(createUserSQL, userName, password)

_, err := mgr.Exec(ctx, sql)
Expand Down

0 comments on commit 3d12856

Please sign in to comment.