func composeTablePrivUpdate(ctx context.Context, priv mysql.PrivilegeType, name string, host string, db string, tbl string) (string, error) {
	var newTablePriv, newColumnPriv string
	if priv == mysql.AllPriv {
		for _, p := range mysql.AllTablePrivs {
			v, ok := mysql.Priv2SetStr[p]
			if !ok {
				return "", errors.Errorf("Unknown table privilege %v", p)
			}
			if len(newTablePriv) == 0 {
				newTablePriv = v
			} else {
				newTablePriv = fmt.Sprintf("%s,%s", newTablePriv, v)
			}
		}
		for _, p := range mysql.AllColumnPrivs {
			v, ok := mysql.Priv2SetStr[p]
			if !ok {
				return "", errors.Errorf("Unknown column privilege %v", p)
			}
			if len(newColumnPriv) == 0 {
				newColumnPriv = v
			} else {
				newColumnPriv = fmt.Sprintf("%s,%s", newColumnPriv, v)
			}
		}
	} else {
		currTablePriv, currColumnPriv, err := getTablePriv(ctx, name, host, db, tbl)
		if err != nil {
			return "", errors.Trace(err)
		}
		p, ok := mysql.Priv2SetStr[priv]
		if !ok {
			return "", errors.Errorf("Unknown priv: %v", priv)
		}
		if len(currTablePriv) == 0 {
			newTablePriv = p
		} else {
			newTablePriv = fmt.Sprintf("%s,%s", currTablePriv, p)
		}
		for _, cp := range mysql.AllColumnPrivs {
			if priv == cp {
				if len(currColumnPriv) == 0 {
					newColumnPriv = p
				} else {
					newColumnPriv = fmt.Sprintf("%s,%s", currColumnPriv, p)
				}
				break
			}
		}
	}
	return fmt.Sprintf(`Table_priv="%s", Column_priv="%s", Grantor="%s"`, newTablePriv, newColumnPriv, ctx.GetSessionVars().User), nil
}
// Compose update stmt assignment list for table scope privilege update.
Compose update stmt assignment list for table scope privilege update.
// Compose update stmt assignment list for table scope privilege update .
func composeTablePrivUpdate(ctx context.Context, priv mysql.PrivilegeType, name string, host string, db string, tbl string) (string, error) {
	var newTablePriv, newColumnPriv string
	if priv == mysql.AllPriv {
		for _, p := range mysql.AllTablePrivs {
			v, ok := mysql.Priv2SetStr[p]
			if !ok {
				return "", errors.Errorf("Unknown table privilege %v", p)
			}
			if len(newTablePriv) == 0 {
				newTablePriv = v
			} else {
				newTablePriv = fmt.Sprintf("%s,%s", newTablePriv, v)
			}
		}
		for _, p := range mysql.AllColumnPrivs {
			v, ok := mysql.Priv2SetStr[p]
			if !ok {
				return "", errors.Errorf("Unknown column privilege %v", p)
			}
			if len(newColumnPriv) == 0 {
				newColumnPriv = v
			} else {
				newColumnPriv = fmt.Sprintf("%s,%s", newColumnPriv, v)
			}
		}
	} else {
		currTablePriv, currColumnPriv, err := getTablePriv(ctx, name, host, db, tbl)
		if err != nil {
			return "", errors.Trace(err)
		}
		p, ok := mysql.Priv2SetStr[priv]
		if !ok {
			return "", errors.Errorf("Unknown priv: %v", priv)
		}
		if len(currTablePriv) == 0 {
			newTablePriv = p
		} else {
			newTablePriv = fmt.Sprintf("%s,%s", currTablePriv, p)
		}
		for _, cp := range mysql.AllColumnPrivs {
			if priv == cp {
				if len(currColumnPriv) == 0 {
					newColumnPriv = p
				} else {
					newColumnPriv = fmt.Sprintf("%s,%s", currColumnPriv, p)
				}
				break
			}
		}
	}
	return fmt.Sprintf(`Table_priv="%s", Column_priv="%s", Grantor="%s"`, newTablePriv, newColumnPriv, ctx.GetSessionVars().User), nil
}
func composeTablePrivUpdate ( ctx context . Context , priv mysql . PrivilegeType , name string , host string , db string , tbl string ) ( string , error ) { var newTablePriv , newColumnPriv string if priv == mysql . AllPriv { for _ , p := range mysql . AllTablePrivs { v , ok := mysql . Priv2SetStr [ p ] if ! ok { return " " , errors . Errorf ( " " , p ) } if len ( newTablePriv ) == 0 { newTablePriv = v } else { newTablePriv = fmt . Sprintf ( " " , newTablePriv , v ) } } for _ , p := range mysql . AllColumnPrivs { v , ok := mysql . Priv2SetStr [ p ] if ! ok { return " " , errors . Errorf ( " " , p ) } if len ( newColumnPriv ) == 0 { newColumnPriv = v } else { newColumnPriv = fmt . Sprintf ( " " , newColumnPriv , v ) } } } else { currTablePriv , currColumnPriv , err := getTablePriv ( ctx , name , host , db , tbl ) if err != nil { return " " , errors . Trace ( err ) } p , ok := mysql . Priv2SetStr [ priv ] if ! ok { return " " , errors . Errorf ( " " , priv ) } if len ( currTablePriv ) == 0 { newTablePriv = p } else { newTablePriv = fmt . Sprintf ( " " , currTablePriv , p ) } for _ , cp := range mysql . AllColumnPrivs { if priv == cp { if len ( currColumnPriv ) == 0 { newColumnPriv = p } else { newColumnPriv = fmt . Sprintf ( " " , currColumnPriv , p ) } break } } } return fmt . Sprintf ( `Table_priv="%s", Column_priv="%s", Grantor="%s"` , newTablePriv , newColumnPriv , ctx . GetSessionVars ( ) . User ) , nil }
Compose update stmt assignment list for table scope privilege update.
Compose update stmt assignment list for table scope privilege update .