Enter implements Visitor interface.
(in ast.Node)
| 6932 | |
| 6933 | // Enter implements Visitor interface. |
| 6934 | func (checker *nodeTextCleaner) Enter(in ast.Node) (out ast.Node, skipChildren bool) { |
| 6935 | in.SetText(nil, "") |
| 6936 | in.SetOriginTextPosition(0) |
| 6937 | if v, ok := in.(ast.ValueExpr); ok && v != nil { |
| 6938 | tpFlag := v.GetType().GetFlag() |
| 6939 | if tpFlag&mysql.UnderScoreCharsetFlag != 0 { |
| 6940 | // ignore underscore charset flag to let `'abc' = _utf8'abc'` pass |
| 6941 | tpFlag ^= mysql.UnderScoreCharsetFlag |
| 6942 | v.GetType().SetFlag(tpFlag) |
| 6943 | } |
| 6944 | } |
| 6945 | |
| 6946 | switch node := in.(type) { |
| 6947 | case *ast.CreateTableStmt: |
| 6948 | for _, opt := range node.Options { |
| 6949 | switch opt.Tp { |
| 6950 | case ast.TableOptionCharset: |
| 6951 | opt.StrValue = strings.ToUpper(opt.StrValue) |
| 6952 | case ast.TableOptionCollate: |
| 6953 | opt.StrValue = strings.ToUpper(opt.StrValue) |
| 6954 | } |
| 6955 | } |
| 6956 | for _, col := range node.Cols { |
| 6957 | col.Tp.SetCharset(strings.ToUpper(col.Tp.GetCharset())) |
| 6958 | col.Tp.SetCollate(strings.ToUpper(col.Tp.GetCollate())) |
| 6959 | |
| 6960 | for i, option := range col.Options { |
| 6961 | if option.Tp == 0 && option.Expr == nil && !option.Stored && option.Refer == nil { |
| 6962 | col.Options = append(col.Options[:i], col.Options[i+1:]...) |
| 6963 | } |
| 6964 | } |
| 6965 | } |
| 6966 | case *ast.DeleteStmt: |
| 6967 | for _, tableHint := range node.TableHints { |
| 6968 | tableHint.HintName.O = "" |
| 6969 | } |
| 6970 | case *ast.UpdateStmt: |
| 6971 | for _, tableHint := range node.TableHints { |
| 6972 | tableHint.HintName.O = "" |
| 6973 | } |
| 6974 | case *ast.Constraint: |
| 6975 | if node.Option != nil { |
| 6976 | if node.Option.KeyBlockSize == 0x0 && node.Option.Tp == 0 && node.Option.Comment == "" { |
| 6977 | node.Option = nil |
| 6978 | } |
| 6979 | } |
| 6980 | case *ast.FuncCallExpr: |
| 6981 | node.FnName.O = strings.ToLower(node.FnName.O) |
| 6982 | node.SetOriginTextPosition(0) |
| 6983 | case *ast.AggregateFuncExpr: |
| 6984 | node.F = strings.ToLower(node.F) |
| 6985 | case *ast.SelectField: |
| 6986 | node.Offset = 0 |
| 6987 | case *test_driver.ValueExpr: |
| 6988 | if node.Kind() == test_driver.KindMysqlDecimal { |
| 6989 | _ = node.GetMysqlDecimal().FromString(node.GetMysqlDecimal().ToString()) |
| 6990 | } |
| 6991 | case *ast.GrantStmt: |
nothing calls this directly
no test coverage detected