Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,8 @@ type DDL struct {
OptSelect *OptSelect

// User is set for ALTER USER operations.
User AccountName
User AccountName
AccountLimits *AccountLimits

// Authentication is set for ALTER USER operations.
Authentication *Authentication
Expand Down Expand Up @@ -2539,6 +2540,9 @@ func (node *DDL) Format(buf *TrackedBuffer) {
ifExists = "if exists "
}
buf.Myprintf("%s user %s%s %s", node.Action, ifExists, node.User.String(), node.Authentication.String())
if node.AccountLimits != nil {
buf.Myprintf(" with %s", node.AccountLimits.String())
}
node.alterFormat(buf)
} else {
buf.Myprintf(fmt.Sprintf("unsupported alter command: %v", node))
Expand Down
26 changes: 20 additions & 6 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3095,22 +3095,36 @@ var (
}, {
input: "CREATE USER 'UserName'@'%' IDENTIFIED WITH 'caching_sha2_password' AS 'xyz0123'",
output: "create user `UserName`@`%` identified with caching_sha2_password as 'xyz0123'",
}, {
},
{
input: "ALTER USER IF EXISTS foo@bar IDENTIFIED BY 'password1';",
output: "alter user if exists `foo`@`bar` identified by 'password1'",
}, {
},
{
input: "ALTER USER foo@bar IDENTIFIED BY 'password1';",
output: "alter user `foo`@`bar` identified by 'password1'",
}, {
},
{
input: "ALTER USER foo@bar IDENTIFIED BY RANDOM PASSWORD;",
output: "alter user `foo`@`bar` identified by random password",
}, {
},
{
input: "ALTER USER foo@bar IDENTIFIED WITH some_plugin;",
output: "alter user `foo`@`bar` identified with some_plugin",
}, {
},
{
input: "ALTER USER foo@bar IDENTIFIED WITH some_plugin BY 'auth_string';",
output: "alter user `foo`@`bar` identified with some_plugin by 'auth_string'",
}, {
},
{
input: "ALTER USER foo@bar IDENTIFIED WITH some_plugin BY 'auth_string' with MAX_QUERIES_PER_HOUR 123;",
output: "alter user `foo`@`bar` identified with some_plugin by 'auth_string' with max_queries_per_hour 123",
},
{
input: "ALTER USER foo@bar with max_queries_per_hour 123 max_updates_per_hour 456 max_connections_per_hour 789 max_user_connections 321;",
output: "alter user `foo`@`bar` identified by '' with max_queries_per_hour 123 max_updates_per_hour 456 max_connections_per_hour 789 max_user_connections 321",
},
{
input: "RENAME USER UserName1@localhost TO UserName2@localhost, UserName3 TO UserName4",
output: "rename user `UserName1`@`localhost` to `UserName2`@`localhost`, `UserName3`@`%` to `UserName4`@`%`",
}, {
Expand Down
Loading