Skip to content
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

parser: fix bug empty string in "ESCAPED BY" subclause of "FIELDS" cause panic (#7880) #8005

Merged
merged 2 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -7013,10 +7013,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