Skip to content

Commit

Permalink
parser: fix bug empty string in "ESCAPED BY" subclause of "FIELDS" ca…
Browse files Browse the repository at this point in the history
…use panic (#7880)
  • Loading branch information
lzmhhh123 authored and ngaut committed Oct 14, 2018
1 parent 7229b32 commit 4de8887
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -7058,10 +7058,14 @@ Fields:
}else if len(str) != 0 {
enclosed = str[0]
}
var escaped byte
if len(escape) > 0 {
escaped = escape[0]
}
$$ = &ast.FieldsClause{
Terminated: $2.(string),
Enclosed: enclosed,
Escaped: escape[0],
Escaped: escaped,
}
}

Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ func (s *testParserSuite) TestDMLStmt(c *C) {
{"load data local infile '/tmp/t.csv' into table t fields terminated by 'ab' enclosed by 'b' (a,b) ignore 1 lines", false},
{"load data local infile '/tmp/t.csv' into table t lines starting by 'ab' terminated by 'xy' ignore 1 lines", true},
{"load data local infile '/tmp/t.csv' into table t fields terminated by 'ab' enclosed by 'b' escaped by '*' ignore 1 lines (a,b)", true},
{"load data local infile '/tmp/t.csv' into table t fields terminated by 'ab' enclosed by 'b' escaped by ''", true},

// select for update
{"SELECT * from t for update", true},
Expand Down

0 comments on commit 4de8887

Please sign in to comment.