func (e *GrantExec) Next() (*Row, error) {
	if e.done {
		return nil, nil
	}
	// Grant for each user
	for _, user := range e.Users {
		// Check if user exists.
		userName, host := parseUser(user.User)
		exists, err := userExists(e.ctx, userName, host)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if !exists {
			return nil, errors.Errorf("Unknown user: %s", user.User)
		}

		// If there is no privilege entry in corresponding table, insert a new one.
		// DB scope:		mysql.DB
		// Table scope:		mysql.Tables_priv
		// Column scope:	mysql.Columns_priv
		switch e.Level.Level {
		case ast.GrantLevelDB:
			err := e.checkAndInitDBPriv(userName, host)
			if err != nil {
				return nil, errors.Trace(err)
			}
		case ast.GrantLevelTable:
			err := e.checkAndInitTablePriv(userName, host)
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
		// Grant each priv to the user.
		for _, priv := range e.Privs {
			if len(priv.Cols) > 0 {
				// Check column scope privilege entry.
				// TODO: Check validity before insert new entry.
				err := e.checkAndInitColumnPriv(userName, host, priv.Cols)
				if err != nil {
					return nil, errors.Trace(err)
				}
			}
			err := e.grantPriv(priv, user)
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
	}
	e.done = true
	return nil, nil
}
// Next implements Execution Next interface.
Next implements Execution Next interface.
// Next implements Execution Next interface .
func (e *GrantExec) Next() (*Row, error) {
	if e.done {
		return nil, nil
	}
	for _, user := range e.Users {
		userName, host := parseUser(user.User)
		exists, err := userExists(e.ctx, userName, host)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if !exists {
			return nil, errors.Errorf("Unknown user: %s", user.User)
		}
		switch e.Level.Level {
		case ast.GrantLevelDB:
			err := e.checkAndInitDBPriv(userName, host)
			if err != nil {
				return nil, errors.Trace(err)
			}
		case ast.GrantLevelTable:
			err := e.checkAndInitTablePriv(userName, host)
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
		for _, priv := range e.Privs {
			if len(priv.Cols) > 0 {
				err := e.checkAndInitColumnPriv(userName, host, priv.Cols)
				if err != nil {
					return nil, errors.Trace(err)
				}
			}
			err := e.grantPriv(priv, user)
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
	}
	e.done = true
	return nil, nil
}
func ( e * GrantExec ) Next ( ) ( * Row , error ) { if e . done { return nil , nil } for _ , user := range e . Users { userName , host := parseUser ( user . User ) exists , err := userExists ( e . ctx , userName , host ) if err != nil { return nil , errors . Trace ( err ) } if ! exists { return nil , errors . Errorf ( " " , user . User ) } switch e . Level . Level { case ast . GrantLevelDB : err := e . checkAndInitDBPriv ( userName , host ) if err != nil { return nil , errors . Trace ( err ) } case ast . GrantLevelTable : err := e . checkAndInitTablePriv ( userName , host ) if err != nil { return nil , errors . Trace ( err ) } } for _ , priv := range e . Privs { if len ( priv . Cols ) > 0 { err := e . checkAndInitColumnPriv ( userName , host , priv . Cols ) if err != nil { return nil , errors . Trace ( err ) } } err := e . grantPriv ( priv , user ) if err != nil { return nil , errors . Trace ( err ) } } } e . done = true return nil , nil }
Next implements Execution Next interface.
Next implements Execution Next interface .
// Grant for each user // Check if user exists. // If there is no privilege entry in corresponding table, insert a new one. // DB scope:		mysql.DB // Table scope:		mysql.Tables_priv // Column scope:	mysql.Columns_priv // Grant each priv to the user. // Check column scope privilege entry. // TODO: Check validity before insert new entry.