func (e *GrantExec) grantColumnPriv(priv *ast.PrivElem, user *ast.UserSpec) error {
	db, tbl, err := e.getTargetSchemaAndTable()
	if err != nil {
		return errors.Trace(err)
	}
	userName, host := parseUser(user.User)
	for _, c := range priv.Cols {
		col := table.FindCol(tbl.Cols(), c.Name.L)
		if col == nil {
			return errors.Errorf("Unknown column: %s", c)
		}
		asgns, err := composeColumnPrivUpdate(e.ctx, priv.Priv, userName, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
		sql := fmt.Sprintf(`UPDATE %s.%s SET %s WHERE User="%s" AND Host="%s" AND DB="%s" AND Table_name="%s" AND Column_name="%s";`, mysql.SystemDB, mysql.ColumnPrivTable, asgns, userName, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		_, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql)
		if err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
// Manipulate mysql.tables_priv table.
Manipulate mysql.tables_priv table.
// Manipulate mysql . tables_priv table .
func (e *GrantExec) grantColumnPriv(priv *ast.PrivElem, user *ast.UserSpec) error {
	db, tbl, err := e.getTargetSchemaAndTable()
	if err != nil {
		return errors.Trace(err)
	}
	userName, host := parseUser(user.User)
	for _, c := range priv.Cols {
		col := table.FindCol(tbl.Cols(), c.Name.L)
		if col == nil {
			return errors.Errorf("Unknown column: %s", c)
		}
		asgns, err := composeColumnPrivUpdate(e.ctx, priv.Priv, userName, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
		sql := fmt.Sprintf(`UPDATE %s.%s SET %s WHERE User="%s" AND Host="%s" AND DB="%s" AND Table_name="%s" AND Column_name="%s";`, mysql.SystemDB, mysql.ColumnPrivTable, asgns, userName, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		_, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql)
		if err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
func ( e * GrantExec ) grantColumnPriv ( priv * ast . PrivElem , user * ast . UserSpec ) error { db , tbl , err := e . getTargetSchemaAndTable ( ) if err != nil { return errors . Trace ( err ) } userName , host := parseUser ( user . User ) for _ , c := range priv . Cols { col := table . FindCol ( tbl . Cols ( ) , c . Name . L ) if col == nil { return errors . Errorf ( " " , c ) } asgns , err := composeColumnPrivUpdate ( e . ctx , priv . Priv , userName , host , db . Name . O , tbl . Meta ( ) . Name . O , col . Name . O ) if err != nil { return errors . Trace ( err ) } sql := fmt . Sprintf ( `UPDATE %s.%s SET %s WHERE User="%s" AND Host="%s" AND DB="%s" AND Table_name="%s" AND Column_name="%s";` , mysql . SystemDB , mysql . ColumnPrivTable , asgns , userName , host , db . Name . O , tbl . Meta ( ) . Name . O , col . Name . O ) _ , err = e . ctx . ( sqlexec . RestrictedSQLExecutor ) . ExecRestrictedSQL ( e . ctx , sql ) if err != nil { return errors . Trace ( err ) } } return nil }
Manipulate mysql.tables_priv table.
Manipulate mysql . tables_priv table .