-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
vtexplain: Fix setting up the column information #15275
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,8 +474,8 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options, collatio | |
} | ||
tEnv.addResult(query, tEnv.getResult(likeQuery)) | ||
|
||
likeQuery = fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", sanitizedLikeTable) | ||
query = fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", sanitizedTable) | ||
likeQuery = fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", mysqlctl.EncodeEntityName(sanitizedLikeTable)) | ||
query = fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", mysqlctl.EncodeEntityName(sanitizedTable)) | ||
if tEnv.getResult(likeQuery) == nil { | ||
return nil, fmt.Errorf("check your schema, table[%s] doesn't exist", likeTable) | ||
} | ||
|
@@ -516,7 +516,7 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options, collatio | |
tEnv.addResult("SELECT * FROM "+backtickedTable+" WHERE 1 != 1", &sqltypes.Result{ | ||
Fields: rowTypes, | ||
}) | ||
query := fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", sanitizedTable) | ||
query := fmt.Sprintf(mysqlctl.GetColumnNamesQuery, "database()", mysqlctl.EncodeEntityName(sanitizedTable)) | ||
tEnv.addResult(query, &sqltypes.Result{ | ||
Fields: colTypes, | ||
Rows: colValues, | ||
|
@@ -618,7 +618,7 @@ func (t *explainTablet) handleSelect(query string) (*sqltypes.Result, error) { | |
|
||
// Gen4 supports more complex queries so we now need to | ||
// handle multiple FROM clauses | ||
tables := make([]*sqlparser.AliasedTableExpr, len(selStmt.From)) | ||
tables := make([]*sqlparser.AliasedTableExpr, 0, len(selStmt.From)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found this bug as well while debugging. We create it with the length, which means subsequent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's really a |
||
for _, from := range selStmt.From { | ||
tables = append(tables, getTables(from)...) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to apply the encoding onto the like expression? It's not a table name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this creates a correctly escaped string from the input which is what we want here explicitly.