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

fix parsing of MySQL Server Version flag #8791

Merged
merged 2 commits into from
Sep 10, 2021
Merged
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
15 changes: 8 additions & 7 deletions go/vt/sqlparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var parserPool = sync.Pool{
var zeroParser yyParserImpl

// MySQLVersion is the version of MySQL that the parser would emulate
var MySQLVersion string
var MySQLVersion = "50709" // default version if nothing else is stated

// yyParsePooled is a wrapper around yyParse that pools the parser objects. There isn't a
// particularly good reason to use yyParse directly, since it immediately discards its parser.
Expand Down Expand Up @@ -110,12 +110,13 @@ func Parse2(sql string) (Statement, BindVars, error) {
func checkParserVersionFlag() {
if flag.Parsed() {
versionFlagSync.Do(func() {
convVersion, err := convertMySQLVersionToCommentVersion(*MySQLServerVersion)
if err != nil {
log.Error(err)
MySQLVersion = "50709" // default version if nothing else is stated
} else {
MySQLVersion = convVersion
if *MySQLServerVersion != "" {
convVersion, err := convertMySQLVersionToCommentVersion(*MySQLServerVersion)
if err != nil {
log.Error(err)
} else {
MySQLVersion = convVersion
}
}
})
}
Expand Down