From 7d0c98e26a7a4206ce78c2f5e7175fdaa2d15aaa Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 9 Sep 2021 19:19:40 +0530 Subject: [PATCH 1/2] only parse the MySQL Server Version flag if it is provided Signed-off-by: Manan Gupta --- go/vt/sqlparser/parser.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/go/vt/sqlparser/parser.go b/go/vt/sqlparser/parser.go index d91d07b3104..7c859ba5682 100644 --- a/go/vt/sqlparser/parser.go +++ b/go/vt/sqlparser/parser.go @@ -110,12 +110,14 @@ 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 + MySQLVersion = "50709" // default version if nothing else is stated + if *MySQLServerVersion != "" { + convVersion, err := convertMySQLVersionToCommentVersion(*MySQLServerVersion) + if err != nil { + log.Error(err) + } else { + MySQLVersion = convVersion + } } }) } From bfc0526fa180d8f3bc9bd823337d8c8f2e4fc113 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 10 Sep 2021 10:56:25 +0530 Subject: [PATCH 2/2] make 50709 the default even before flag are parsed Signed-off-by: Manan Gupta --- go/vt/sqlparser/parser.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go/vt/sqlparser/parser.go b/go/vt/sqlparser/parser.go index 7c859ba5682..b45ffdf44e3 100644 --- a/go/vt/sqlparser/parser.go +++ b/go/vt/sqlparser/parser.go @@ -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. @@ -110,7 +110,6 @@ func Parse2(sql string) (Statement, BindVars, error) { func checkParserVersionFlag() { if flag.Parsed() { versionFlagSync.Do(func() { - MySQLVersion = "50709" // default version if nothing else is stated if *MySQLServerVersion != "" { convVersion, err := convertMySQLVersionToCommentVersion(*MySQLServerVersion) if err != nil {