Merge pull request #836 from pingcap/qiuyesuifeng/tiny-clean-up
Make better code review.
This commit is contained in:
78
ast/flag.go
78
ast/flag.go
@ -41,67 +41,67 @@ func (f *flagSetter) Enter(in Node) (Node, bool) {
|
||||
|
||||
func (f *flagSetter) Leave(in Node) (Node, bool) {
|
||||
switch x := in.(type) {
|
||||
case *ValueExpr:
|
||||
case *AggregateFuncExpr:
|
||||
f.aggregateFunc(x)
|
||||
case *BetweenExpr:
|
||||
x.SetFlag(x.Expr.GetFlag() | x.Left.GetFlag() | x.Right.GetFlag())
|
||||
case *BinaryOperationExpr:
|
||||
x.SetFlag(x.L.GetFlag() | x.R.GetFlag())
|
||||
case *CaseExpr:
|
||||
f.caseExpr(x)
|
||||
case *SubqueryExpr:
|
||||
x.SetFlag(FlagHasSubquery)
|
||||
case *CompareSubqueryExpr:
|
||||
x.SetFlag(x.L.GetFlag() | x.R.GetFlag())
|
||||
case *ColumnNameExpr:
|
||||
x.SetFlag(FlagHasReference)
|
||||
case *CompareSubqueryExpr:
|
||||
x.SetFlag(x.L.GetFlag() | x.R.GetFlag())
|
||||
case *DefaultExpr:
|
||||
x.SetFlag(FlagHasDefault)
|
||||
case *ExistsSubqueryExpr:
|
||||
x.SetFlag(x.Sel.GetFlag())
|
||||
case *PatternInExpr:
|
||||
f.patternIn(x)
|
||||
case *IsNullExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *IsTruthExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *PatternLikeExpr:
|
||||
f.patternLike(x)
|
||||
case *ParamMarkerExpr:
|
||||
x.SetFlag(FlagHasParamMarker)
|
||||
case *ParenthesesExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *PositionExpr:
|
||||
x.SetFlag(FlagHasReference)
|
||||
case *PatternRegexpExpr:
|
||||
f.patternRegexp(x)
|
||||
case *RowExpr:
|
||||
f.row(x)
|
||||
case *UnaryOperationExpr:
|
||||
x.SetFlag(x.V.GetFlag())
|
||||
case *ValuesExpr:
|
||||
x.SetFlag(FlagHasReference)
|
||||
case *VariableExpr:
|
||||
x.SetFlag(FlagHasVariable)
|
||||
case *FuncCallExpr:
|
||||
f.funcCall(x)
|
||||
case *FuncExtractExpr:
|
||||
x.SetFlag(FlagHasFunc | x.Date.GetFlag())
|
||||
case *FuncConvertExpr:
|
||||
x.SetFlag(FlagHasFunc | x.Expr.GetFlag())
|
||||
case *FuncCastExpr:
|
||||
x.SetFlag(FlagHasFunc | x.Expr.GetFlag())
|
||||
case *FuncConvertExpr:
|
||||
x.SetFlag(FlagHasFunc | x.Expr.GetFlag())
|
||||
case *FuncDateArithExpr:
|
||||
f.funcDateArith(x)
|
||||
case *FuncExtractExpr:
|
||||
x.SetFlag(FlagHasFunc | x.Date.GetFlag())
|
||||
case *FuncLocateExpr:
|
||||
f.funcLocate(x)
|
||||
case *FuncSubstringExpr:
|
||||
f.funcSubstring(x)
|
||||
case *FuncSubstringIndexExpr:
|
||||
f.funcSubstringIndex(x)
|
||||
case *FuncLocateExpr:
|
||||
f.funcLocate(x)
|
||||
case *FuncTrimExpr:
|
||||
f.funcTrim(x)
|
||||
case *FuncDateArithExpr:
|
||||
f.funcDateArith(x)
|
||||
case *AggregateFuncExpr:
|
||||
f.aggregateFunc(x)
|
||||
case *IsNullExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *IsTruthExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *ParamMarkerExpr:
|
||||
x.SetFlag(FlagHasParamMarker)
|
||||
case *ParenthesesExpr:
|
||||
x.SetFlag(x.Expr.GetFlag())
|
||||
case *PatternInExpr:
|
||||
f.patternIn(x)
|
||||
case *PatternLikeExpr:
|
||||
f.patternLike(x)
|
||||
case *PatternRegexpExpr:
|
||||
f.patternRegexp(x)
|
||||
case *PositionExpr:
|
||||
x.SetFlag(FlagHasReference)
|
||||
case *RowExpr:
|
||||
f.row(x)
|
||||
case *SubqueryExpr:
|
||||
x.SetFlag(FlagHasSubquery)
|
||||
case *UnaryOperationExpr:
|
||||
x.SetFlag(x.V.GetFlag())
|
||||
case *ValueExpr:
|
||||
case *ValuesExpr:
|
||||
x.SetFlag(FlagHasReference)
|
||||
case *VariableExpr:
|
||||
x.SetFlag(FlagHasVariable)
|
||||
}
|
||||
|
||||
return in, true
|
||||
|
||||
@ -28,56 +28,56 @@ func (con *Converter) Convert(node ast.Node) (stmt.Statement, error) {
|
||||
c := newExpressionConverter()
|
||||
con.converter = c
|
||||
switch v := node.(type) {
|
||||
case *ast.InsertStmt:
|
||||
return convertInsert(c, v)
|
||||
case *ast.DeleteStmt:
|
||||
return convertDelete(c, v)
|
||||
case *ast.UpdateStmt:
|
||||
return convertUpdate(c, v)
|
||||
case *ast.SelectStmt:
|
||||
return convertSelect(c, v)
|
||||
case *ast.UnionStmt:
|
||||
return convertUnion(c, v)
|
||||
case *ast.CreateDatabaseStmt:
|
||||
return convertCreateDatabase(c, v)
|
||||
case *ast.DropDatabaseStmt:
|
||||
return convertDropDatabase(c, v)
|
||||
case *ast.CreateTableStmt:
|
||||
return convertCreateTable(c, v)
|
||||
case *ast.DropTableStmt:
|
||||
return convertDropTable(c, v)
|
||||
case *ast.CreateIndexStmt:
|
||||
return convertCreateIndex(c, v)
|
||||
case *ast.DropIndexStmt:
|
||||
return convertDropIndex(c, v)
|
||||
case *ast.AlterTableStmt:
|
||||
return convertAlterTable(c, v)
|
||||
case *ast.TruncateTableStmt:
|
||||
return convertTruncateTable(c, v)
|
||||
case *ast.ExplainStmt:
|
||||
return convertExplain(c, v)
|
||||
case *ast.ShowStmt:
|
||||
return convertShow(c, v)
|
||||
case *ast.BeginStmt:
|
||||
return convertBegin(c, v)
|
||||
case *ast.CommitStmt:
|
||||
return convertCommit(c, v)
|
||||
case *ast.CreateDatabaseStmt:
|
||||
return convertCreateDatabase(c, v)
|
||||
case *ast.CreateIndexStmt:
|
||||
return convertCreateIndex(c, v)
|
||||
case *ast.CreateTableStmt:
|
||||
return convertCreateTable(c, v)
|
||||
case *ast.CreateUserStmt:
|
||||
return convertCreateUser(c, v)
|
||||
case *ast.DeleteStmt:
|
||||
return convertDelete(c, v)
|
||||
case *ast.DoStmt:
|
||||
return convertDo(c, v)
|
||||
case *ast.DropDatabaseStmt:
|
||||
return convertDropDatabase(c, v)
|
||||
case *ast.DropIndexStmt:
|
||||
return convertDropIndex(c, v)
|
||||
case *ast.DropTableStmt:
|
||||
return convertDropTable(c, v)
|
||||
case *ast.ExplainStmt:
|
||||
return convertExplain(c, v)
|
||||
case *ast.GrantStmt:
|
||||
return convertGrant(c, v)
|
||||
case *ast.InsertStmt:
|
||||
return convertInsert(c, v)
|
||||
case *ast.RollbackStmt:
|
||||
return convertRollback(c, v)
|
||||
case *ast.UseStmt:
|
||||
return convertUse(c, v)
|
||||
case *ast.SetStmt:
|
||||
return convertSet(c, v)
|
||||
case *ast.SelectStmt:
|
||||
return convertSelect(c, v)
|
||||
case *ast.SetCharsetStmt:
|
||||
return convertSetCharset(c, v)
|
||||
case *ast.SetPwdStmt:
|
||||
return convertSetPwd(c, v)
|
||||
case *ast.CreateUserStmt:
|
||||
return convertCreateUser(c, v)
|
||||
case *ast.DoStmt:
|
||||
return convertDo(c, v)
|
||||
case *ast.GrantStmt:
|
||||
return convertGrant(c, v)
|
||||
case *ast.SetStmt:
|
||||
return convertSet(c, v)
|
||||
case *ast.ShowStmt:
|
||||
return convertShow(c, v)
|
||||
case *ast.TruncateTableStmt:
|
||||
return convertTruncateTable(c, v)
|
||||
case *ast.UnionStmt:
|
||||
return convertUnion(c, v)
|
||||
case *ast.UpdateStmt:
|
||||
return convertUpdate(c, v)
|
||||
case *ast.UseStmt:
|
||||
return convertUse(c, v)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user