func (e *GrantExec) checkAndInitColumnPriv(user string, host string, cols []*ast.ColumnName) error {
	db, tbl, err := e.getTargetSchemaAndTable()
	if err != nil {
		return errors.Trace(err)
	}
	for _, c := range cols {
		col := table.FindCol(tbl.Cols(), c.Name.L)
		if col == nil {
			return errors.Errorf("Unknown column: %s", c.Name.O)
		}
		ok, err := columnPrivEntryExists(e.ctx, user, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
		if ok {
			continue
		}
		// Entry does not exist for user-host-db-tbl-col. Insert a new entry.
		err = initColumnPrivEntry(e.ctx, user, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
// Check if column scope privilege entry exists in mysql.Columns_priv.
// If unexists, insert a new one.
Check if column scope privilege entry exists in mysql.Columns_priv.
If unexists, insert a new one.
// Check if column scope privilege entry exists in mysql . Columns_priv . // If unexists insert a new one .
func (e *GrantExec) checkAndInitColumnPriv(user string, host string, cols []*ast.ColumnName) error {
	db, tbl, err := e.getTargetSchemaAndTable()
	if err != nil {
		return errors.Trace(err)
	}
	for _, c := range cols {
		col := table.FindCol(tbl.Cols(), c.Name.L)
		if col == nil {
			return errors.Errorf("Unknown column: %s", c.Name.O)
		}
		ok, err := columnPrivEntryExists(e.ctx, user, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
		if ok {
			continue
		}
		err = initColumnPrivEntry(e.ctx, user, host, db.Name.O, tbl.Meta().Name.O, col.Name.O)
		if err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
func ( e * GrantExec ) checkAndInitColumnPriv ( user string , host string , cols [ ] * ast . ColumnName ) error { db , tbl , err := e . getTargetSchemaAndTable ( ) if err != nil { return errors . Trace ( err ) } for _ , c := range cols { col := table . FindCol ( tbl . Cols ( ) , c . Name . L ) if col == nil { return errors . Errorf ( " " , c . Name . O ) } ok , err := columnPrivEntryExists ( e . ctx , user , host , db . Name . O , tbl . Meta ( ) . Name . O , col . Name . O ) if err != nil { return errors . Trace ( err ) } if ok { continue } err = initColumnPrivEntry ( e . ctx , user , host , db . Name . O , tbl . Meta ( ) . Name . O , col . Name . O ) if err != nil { return errors . Trace ( err ) } } return nil }
Check if column scope privilege entry exists in mysql.Columns_priv.
Check if column scope privilege entry exists in mysql . Columns_priv .
// Entry does not exist for user-host-db-tbl-col. Insert a new entry.