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

planbuilder: Fix infinite recursion for subqueries #13783

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions go/vt/vtgate/planbuilder/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (r *rewriter) rewriteDown(cursor *sqlparser.Cursor) bool {
// replace the table name with the original table
tableName.Name = vindexTable.Name
node.Expr = tableName
case *sqlparser.ExtractedSubquery:
return false
case *sqlparser.Subquery:
err := rewriteSubquery(cursor, r, node)
if err != nil {
Expand Down
19 changes: 19 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/info_schema80_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1693,5 +1693,24 @@
"Table": "information_schema.apa"
}
}
},
{
"comment": "mysqldump query",
"query": "SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE ENGINE = 'ndbcluster' AND FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILES WHERE ENGINE = 'ndbcluster' AND FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('commerce'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE ORDER BY LOGFILE_GROUP_NAME",
"plan": {
"QueryType": "SELECT",
"Original": "SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE ENGINE = 'ndbcluster' AND FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILES WHERE ENGINE = 'ndbcluster' AND FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('commerce'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE ORDER BY LOGFILE_GROUP_NAME",
"Instructions": {
"OperatorType": "Route",
"Variant": "DBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, `ENGINE`, EXTRA from INFORMATION_SCHEMA.FILES where 1 != 1 group by LOGFILE_GROUP_NAME, FILE_NAME, `ENGINE`, TOTAL_EXTENTS, INITIAL_SIZE",
"Query": "select LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, `ENGINE`, EXTRA from INFORMATION_SCHEMA.FILES where `ENGINE` = 'ndbcluster' and FILE_TYPE = 'UNDO LOG' and FILE_NAME is not null and LOGFILE_GROUP_NAME is not null and LOGFILE_GROUP_NAME in (select distinct LOGFILE_GROUP_NAME from INFORMATION_SCHEMA.FILES where `ENGINE` = 'ndbcluster' and FILE_TYPE = 'DATAFILE' and TABLESPACE_NAME in (select distinct TABLESPACE_NAME from INFORMATION_SCHEMA.`PARTITIONS` where TABLE_SCHEMA in ('commerce'))) group by LOGFILE_GROUP_NAME, FILE_NAME, `ENGINE`, TOTAL_EXTENTS, INITIAL_SIZE order by LOGFILE_GROUP_NAME asc",
"Table": "INFORMATION_SCHEMA.FILES"
}
}
}
]