@@ -18,7 +18,6 @@ import (
1818 "fmt"
1919 "strings"
2020
21- "github.com/dolthub/go-mysql-server/sql/mysql_db"
2221 "github.com/dolthub/go-mysql-server/sql/types"
2322
2423 "github.com/dolthub/go-mysql-server/sql"
@@ -101,40 +100,3 @@ func (n *DropUser) WithChildren(children ...sql.Node) (sql.Node, error) {
101100func (* DropUser ) CollationCoercibility (ctx * sql.Context ) (collation sql.CollationID , coercibility byte ) {
102101 return sql .Collation_binary , 7
103102}
104-
105- // RowIter implements the interface sql.Node.
106- func (n * DropUser ) RowIter (ctx * sql.Context , row sql.Row ) (sql.RowIter , error ) {
107- mysqlDb , ok := n .MySQLDb .(* mysql_db.MySQLDb )
108- if ! ok {
109- return nil , sql .ErrDatabaseNotFound .New ("mysql" )
110- }
111- editor := mysqlDb .Editor ()
112- defer editor .Close ()
113- for _ , user := range n .Users {
114- existingUser := mysqlDb .GetUser (editor , user .Name , user .Host , false )
115- if existingUser == nil {
116- if n .IfExists {
117- continue
118- }
119- return nil , sql .ErrUserDeletionFailure .New (user .String ("'" ))
120- }
121-
122- //TODO: if a user is mentioned in the "mandatory_roles" (users and roles are interchangeable) system variable then they cannot be dropped
123- editor .RemoveUser (mysql_db.UserPrimaryKey {
124- Host : existingUser .Host ,
125- User : existingUser .User ,
126- })
127- editor .RemoveRoleEdgesFromKey (mysql_db.RoleEdgesFromKey {
128- FromHost : existingUser .Host ,
129- FromUser : existingUser .User ,
130- })
131- editor .RemoveRoleEdgesToKey (mysql_db.RoleEdgesToKey {
132- ToHost : existingUser .Host ,
133- ToUser : existingUser .User ,
134- })
135- }
136- if err := mysqlDb .Persist (ctx , editor ); err != nil {
137- return nil , err
138- }
139- return sql .RowsToRowIter (sql.Row {types .NewOkResult (0 )}), nil
140- }
0 commit comments