Skip to content

Commit

Permalink
*: pass user's resource group name to sessionVars.ResourceGroupName (p…
Browse files Browse the repository at this point in the history
…ingcap#27)

Signed-off-by: BornChanger <[email protected]>
  • Loading branch information
BornChanger committed Dec 6, 2022
1 parent 3304176 commit ad41e83
Show file tree
Hide file tree
Showing 9 changed files with 785 additions and 520 deletions.
8 changes: 4 additions & 4 deletions executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,18 +949,18 @@ func (e *SimpleExec) executeCreateUser(ctx context.Context, s *ast.CreateUserStm
var userAttributes = ""
if s.CommentOrAttributeOption != nil {
if s.CommentOrAttributeOption.Type != ast.UserResourceGroupName {
userAttributes = `{"metadata": {"resource group": "default"`
userAttributes = `{"metadata": {"resource_group": "default"`
if s.CommentOrAttributeOption.Type == ast.UserCommentType {
userAttributes += fmt.Sprintf(`, "comment": "%s"`, s.CommentOrAttributeOption.Value)
} else if s.CommentOrAttributeOption.Type == ast.UserAttributeType {
userAttributes = fmt.Sprintf(`, %s`, s.CommentOrAttributeOption.Value)
}
userAttributes += `}}`
} else {
userAttributes = fmt.Sprintf(`{"metadata": {"resource group": "%s"}}`, s.CommentOrAttributeOption.Value)
userAttributes = fmt.Sprintf(`{"metadata": {"resource_group": "%s"}}`, s.CommentOrAttributeOption.Value)
}
} else {
userAttributes = `{"metadata": {"resource group": "default"}}`
userAttributes = `{"metadata": {"resource_group": "default"}}`
}

tokenIssuer := ""
Expand Down Expand Up @@ -1598,7 +1598,7 @@ func (e *SimpleExec) executeAlterUser(ctx context.Context, s *ast.AlterUserStmt)
} else if s.CommentOrAttributeOption.Type == ast.UserAttributeType {
newAttributesStr = fmt.Sprintf(`{"metadata": %s}`, s.CommentOrAttributeOption.Value)
} else {
newAttributesStr = fmt.Sprintf(`{"metadata": {"resource group": "%s"}}`, s.CommentOrAttributeOption.Value)
newAttributesStr = fmt.Sprintf(`{"metadata": {"resource_group": "%s"}}`, s.CommentOrAttributeOption.Value)
}
fields = append(fields, alterField{"user_attributes=json_merge_patch(coalesce(user_attributes, '{}'), %?)", newAttributesStr})
}
Expand Down
Loading

0 comments on commit ad41e83

Please sign in to comment.