Skip to content

Commit

Permalink
[parser] Revert "parser,ast: fix the TiDB issue #8153 (#20)" (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbjoa authored and ti-chi-bot committed Oct 9, 2021
1 parent 53c43f7 commit 9cf3037
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
9 changes: 1 addition & 8 deletions parser/ast/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func (n *ParenthesesExpr) Accept(v Visitor) (Node, bool) {
type PositionExpr struct {
exprNode
// N is the position, started from 1 now.
N ExprNode
N int
// Refer is the result field the position refers to.
Refer *ResultField
}
Expand All @@ -716,13 +716,6 @@ func (n *PositionExpr) Accept(v Visitor) (Node, bool) {
return v.Leave(newNode)
}
n = newNode.(*PositionExpr)
if n.N != nil {
node, ok := n.N.Accept(v)
if !ok {
return n, false
}
n.N = node.(ExprNode)
}
return v.Leave(n)
}

Expand Down
10 changes: 6 additions & 4 deletions parser/parser.go

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

12 changes: 7 additions & 5 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -3188,11 +3188,13 @@ ByItem:
Expression Order
{
expr := $1
if valueExpr, ok := expr.(ast.ValueExpr); ok {
expr = &ast.PositionExpr{N: valueExpr}
} else if paramExpr, ok := expr.(ast.ParamMarkerExpr); ok {
expr = &ast.PositionExpr{N: paramExpr}
}
valueExpr, ok := expr.(ast.ValueExpr)
if ok {
position, isPosition := valueExpr.GetValue().(int64)
if isPosition {
expr = &ast.PositionExpr{N: int(position)}
}
}
$$ = &ast.ByItem{Expr: expr, Desc: $2.(bool)}
}

Expand Down

0 comments on commit 9cf3037

Please sign in to comment.