-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: move ast.NewValueExpr to standalone parser_driver package #7952
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ func (f *flagSetter) Enter(in Node) (Node, bool) { | |
} | ||
|
||
func (f *flagSetter) Leave(in Node) (Node, bool) { | ||
if x, ok := in.(ParamMarkerExpr); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this to the original place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. *ParamMarkerExpr is change from struct to interface, because the old struct definition depends on Go can't type assert on a interface:
|
||
x.SetFlag(FlagHasParamMarker) | ||
} | ||
switch x := in.(type) { | ||
case *AggregateFuncExpr: | ||
f.aggregateFunc(x) | ||
|
@@ -57,8 +60,6 @@ func (f *flagSetter) Leave(in Node) (Node, bool) { | |
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: | ||
|
@@ -75,7 +76,6 @@ func (f *flagSetter) Leave(in Node) (Node, bool) { | |
x.SetFlag(FlagHasSubquery) | ||
case *UnaryOperationExpr: | ||
x.SetFlag(x.V.GetFlag()) | ||
case *ValueExpr: | ||
case *ValuesExpr: | ||
x.SetFlag(FlagHasReference) | ||
case *VariableExpr: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ func (visitor1) Enter(in Node) (Node, bool) { | |
} | ||
|
||
func (ts *testMiscSuite) TestMiscVisitorCover(c *C) { | ||
valueExpr := NewValueExpr(42) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does 42 mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 42 is the "Answer to the Ultimate Question of Life, the Universe, and Everything" . I remember @shenli asked this question before. |
||
stmts := []Node{ | ||
&AdminStmt{}, | ||
&AlterUserStmt{}, | ||
|
@@ -53,15 +54,15 @@ func (ts *testMiscSuite) TestMiscVisitorCover(c *C) { | |
&CreateUserStmt{}, | ||
&DeallocateStmt{}, | ||
&DoStmt{}, | ||
&ExecuteStmt{UsingVars: []ExprNode{&ValueExpr{}}}, | ||
&ExecuteStmt{UsingVars: []ExprNode{valueExpr}}, | ||
&ExplainStmt{Stmt: &ShowStmt{}}, | ||
&GrantStmt{}, | ||
&PrepareStmt{SQLVar: &VariableExpr{Value: &ValueExpr{}}}, | ||
&PrepareStmt{SQLVar: &VariableExpr{Value: valueExpr}}, | ||
&RollbackStmt{}, | ||
&SetPwdStmt{}, | ||
&SetStmt{Variables: []*VariableAssignment{ | ||
{ | ||
Value: &ValueExpr{}, | ||
Value: valueExpr, | ||
}, | ||
}}, | ||
&UseStmt{}, | ||
|
@@ -72,7 +73,7 @@ func (ts *testMiscSuite) TestMiscVisitorCover(c *C) { | |
}, | ||
&FlushStmt{}, | ||
&PrivElem{}, | ||
&VariableAssignment{Value: &ValueExpr{}}, | ||
&VariableAssignment{Value: valueExpr}, | ||
&KillStmt{}, | ||
&DropStatsStmt{Table: &TableName{}}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about s/exprNode/ExprNode/ and exporting it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a ExprNode, rename exprNode will cause conflict.
ExprNode is an interface, and exprNode is the embed struct that implements ExprNode.
Use a type alias here could make changes minimal.