Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao committed Nov 22, 2018
1 parent 4f7ff5f commit 815d2f6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 42 deletions.
11 changes: 0 additions & 11 deletions ast/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ type ExistsSubqueryExpr struct {
exprNode
// Sel is the subquery, may be rewritten to other type of expression.
Sel ExprNode
// Not is true, the expression is "not exists".
Not bool
}

// Format the ExprNode into a Writer.
Expand Down Expand Up @@ -700,8 +698,6 @@ type PositionExpr struct {
exprNode
// N is the position, started from 1 now.
N int
// P is the parameterized position.
P ExprNode
// Refer is the result field the position refers to.
Refer *ResultField
}
Expand All @@ -718,13 +714,6 @@ func (n *PositionExpr) Accept(v Visitor) (Node, bool) {
return v.Leave(newNode)
}
n = newNode.(*PositionExpr)
if n.P != nil {
node, ok := n.P.Accept(v)
if !ok {
return n, false
}
n.P = node.(ExprNode)
}
return v.Leave(n)
}

Expand Down
8 changes: 1 addition & 7 deletions parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -2471,13 +2471,7 @@ Expression:
}
| "NOT" Expression %prec not
{
expr, ok := $2.(*ast.ExistsSubqueryExpr)
if ok {
expr.Not = true
$$ = $2
} else {
$$ = &ast.UnaryOperationExpr{Op: opcode.Not, V: $2}
}
$$ = &ast.UnaryOperationExpr{Op: opcode.Not, V: $2}
}
| BoolPri IsOrNotOp trueKwd %prec is
{
Expand Down
17 changes: 0 additions & 17 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2468,23 +2468,6 @@ func (s *testParserSuite) TestTablePartition(c *C) {
c.Assert(createTable.Partition.Definitions[0].Comment, Equals, "check")
}

func (s *testParserSuite) TestNotExistsSubquery(c *C) {
table := []testCase{
{`select * from t1 where not exists (select * from t2 where t1.a = t2.a)`, true},
}

parser := New()
for _, tt := range table {
stmt, err := parser.Parse(tt.src, "", "")
c.Assert(err, IsNil)

sel := stmt[0].(*ast.SelectStmt)
exists, ok := sel.Where.(*ast.ExistsSubqueryExpr)
c.Assert(ok, IsTrue)
c.Assert(exists.Not, Equals, tt.ok)
}
}

func (s *testParserSuite) TestWindowFunctionIdentifier(c *C) {
var table []testCase
s.enableWindowFunc = true
Expand Down

0 comments on commit 815d2f6

Please sign in to comment.