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

Adds Planning and Parsing Support for Create Index of MySQL 5.7 #7024

Merged
merged 14 commits into from
Nov 18, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ var (
}, {
input: "create unique index a using foo on b (col1 desc)",
}, {
input: "create with gh-ost unique index a using foo on b (col1 desc)",
input: "create with 'gh-ost' unique index a using foo on b (col1 desc)",
output: "create unique index a using foo on b (col1 desc)",
}, {
input: "create fulltext index a using foo on b (col1)",
Expand All @@ -1170,9 +1170,6 @@ var (
input: "create index a on b ((col1 + col2), (col1*col2))",
output: "create index a on b ()",
partialDDL: true,
}, {
input: "create fulltext index a using foo on b",
output: "alter table b",
}, {
input: "create view a",
output: "create table a",
Expand Down
8 changes: 7 additions & 1 deletion go/vt/vttablet/tabletserver/planbuilder/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ func Build(statement sqlparser.Statement, tables map[string]*schema.Table, isRes
// DDLs and some other statements below don't get fully parsed.
// We have to use the original query at the time of execution.
// We are in the process of changing this
plan = &Plan{PlanID: PlanDDL}
var fullQuery *sqlparser.ParsedQuery
fullQuery = nil
GuptaManan100 marked this conversation as resolved.
Show resolved Hide resolved
// If the query is fully parsed, then use the ast and store the fullQuery
if stmt.IsFullyParsed() {
fullQuery = GenerateFullQuery(stmt)
}
plan = &Plan{PlanID: PlanDDL, FullQuery: fullQuery}
case *sqlparser.Show:
plan, err = analyzeShow(stmt, dbName)
case *sqlparser.OtherRead, *sqlparser.Explain:
Expand Down
12 changes: 11 additions & 1 deletion go/vt/vttablet/tabletserver/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,17 @@ func (qre *QueryExecutor) execDDL(conn *StatefulConnection) (*sqltypes.Result, e
}
}()

result, err := qre.execStatefulConn(conn, qre.query, true)
sql := qre.query
GuptaManan100 marked this conversation as resolved.
Show resolved Hide resolved
// If FullQuery is not nil, then the DDL query was fully parsed
// and we should use the ast to generate the query instead.
if qre.plan.FullQuery != nil {
var err error
sql, _, err = qre.generateFinalSQL(qre.plan.FullQuery, qre.bindVars)
if err != nil {
return nil, err
}
}
result, err := qre.execStatefulConn(conn, sql, true)
if err != nil {
return nil, err
}
Expand Down