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

perf: zero-copy tokenizer #7619

Merged
merged 6 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,7 @@ var (
output: "syntax error at position 66 near 'using'",
}, {
input: "select 'aa",
output: "syntax error at position 11 near 'aa'",
output: "syntax error at position 12 near 'aa'",
excludeMulti: true,
}, {
input: "select 'aa\\",
Expand Down
14 changes: 7 additions & 7 deletions go/vt/sqlparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ func ParseNextStrictDDL(tokenizer *Tokenizer) (Statement, error) {
}

func parseNext(tokenizer *Tokenizer, strict bool) (Statement, error) {
if tokenizer.lastChar == ';' {
tokenizer.next()
if tokenizer.cur() == ';' {
tokenizer.skip(1)
tokenizer.skipBlank()
}
if tokenizer.lastChar == eofChar {
if tokenizer.cur() == eofChar {
return nil, io.EOF
}

Expand Down Expand Up @@ -176,7 +176,7 @@ func SplitStatement(blob string) (string, string, error) {
return "", "", tokenizer.LastError
}
if tkn == ';' {
return blob[:tokenizer.Position-2], blob[tokenizer.Position-1:], nil
return blob[:tokenizer.Pos-1], blob[tokenizer.Pos:], nil
}
return blob, "", nil
}
Expand All @@ -196,14 +196,14 @@ loop:
tkn, _ = tokenizer.Scan()
switch tkn {
case ';':
stmt = blob[stmtBegin : tokenizer.Position-2]
stmt = blob[stmtBegin : tokenizer.Pos-1]
if !emptyStatement {
pieces = append(pieces, stmt)
emptyStatement = true
}
stmtBegin = tokenizer.Position - 1
stmtBegin = tokenizer.Pos
case 0, eofChar:
blobTail := tokenizer.Position - 2
blobTail := tokenizer.Pos - 1
if stmtBegin < blobTail {
stmt = blob[stmtBegin : blobTail+1]
if !emptyStatement {
Expand Down