[planner] Schema information on the information_schema views#11941
[planner] Schema information on the information_schema views#11941systay merged 6 commits intovitessio:mainfrom
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
Signed-off-by: Andres Taylor <andres@planetscale.com>
48dc452 to
027f00e
Compare
There was a problem hiding this comment.
this query didn't make much sense to me, so I removed it. The problem is with in (select * - IN works against a single column. I think we acceptable coverage of star expansion on system tables even without this query
Signed-off-by: Andres Taylor <andres@planetscale.com>
027f00e to
fed492d
Compare
| @@ -208,6 +190,30 @@ | |||
| "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", | |||
There was a problem hiding this comment.
This reminds me that we could look into optimizing UNION queries to not always split them up (e.g. in cases we will end up sending them to the same shard anyway).
There was a problem hiding this comment.
yeah, we need to move all horizon planning over to the operators.
I have to finish this: #11698
Signed-off-by: Andres Taylor <andres@planetscale.com>
| func getInfoSchema() map[string]map[string]query.Type { | ||
| infSchema := map[string]map[string]query.Type{} |
There was a problem hiding this comment.
nit: maybe adding a link to the doc could help to know what each table/column is used for: https://dev.mysql.com/doc/refman/8.0/en/information-schema-table-reference.html
| } | ||
| }, | ||
| { | ||
| "comment": "systable union query in derived table with constraint on outside (star projection)", |
There was a problem hiding this comment.
this query was moved here from unsupported_cases.json
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
| } | ||
| }, | ||
| { | ||
| "comment": "rails_query 6", |
There was a problem hiding this comment.
here we should have rails query 5, but it uses an info_schema view that did not exist in 5.7 information_schema.check_constraints. There were two more queries in this file that I had to delete because they used this view
| directDeps := org.tableSetFor(dt.ASTNode) | ||
| for i, name := range dt.columnNames { | ||
| if name != colName { | ||
| if !strings.EqualFold(name, colName) { |
There was a problem hiding this comment.
Is this fixing a potential bug / does this need to be backported? 🤔
There was a problem hiding this comment.
It fixes #11942
Yeah, we could backport just this change. We already have a test that exposes the problem in the plan tests. That's how I found it
Signed-off-by: Andres Taylor <andres@planetscale.com>
| var err error | ||
| tbl, vindex, _, _, _, err = tc.si.FindTableOrVindex(t) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if tbl == nil && vindex != nil { | ||
| tbl = newVindexTable(t.Name) | ||
| } | ||
|
|
There was a problem hiding this comment.
this looks like a logic change, where we do FindTableOrVindex even if isInfSchema is true
There was a problem hiding this comment.
yeah, this is by design. tc.si now knows about information_schema views, so we want to ask it about these
…o#11941) * add info_schema information Signed-off-by: Andres Taylor <andres@planetscale.com> * add SchemaInformation handling for info_schema tables Signed-off-by: Andres Taylor <andres@planetscale.com> * fix bad test query Signed-off-by: Andres Taylor <andres@planetscale.com> * add support for information_schema on mysql 5.7 Signed-off-by: Andres Taylor <andres@planetscale.com> * columns sorted just like mysql, and tests for 5.7 Signed-off-by: Andres Taylor <andres@planetscale.com> * test: skip test that should not run Signed-off-by: Andres Taylor <andres@planetscale.com> Signed-off-by: Andres Taylor <andres@planetscale.com>
* [planner] Schema information on the information_schema views (#11941) * add info_schema information Signed-off-by: Andres Taylor <andres@planetscale.com> * add SchemaInformation handling for info_schema tables Signed-off-by: Andres Taylor <andres@planetscale.com> * fix bad test query Signed-off-by: Andres Taylor <andres@planetscale.com> * add support for information_schema on mysql 5.7 Signed-off-by: Andres Taylor <andres@planetscale.com> * columns sorted just like mysql, and tests for 5.7 Signed-off-by: Andres Taylor <andres@planetscale.com> * test: skip test that should not run Signed-off-by: Andres Taylor <andres@planetscale.com> Signed-off-by: Andres Taylor <andres@planetscale.com> * Fix for USING when column names not lower cased (#12379) Signed-off-by: Andres Taylor <andres@planetscale.com> --------- Signed-off-by: Andres Taylor <andres@planetscale.com>
Description
This makes it so that Vitess knows the columns and types of all
information_schemaviews, which can then be used during semantic analysis.While working on this I also found and fixed an issue around resolving of derived table columns with different cases.
Related Issue(s)
Fixes #11755
Fixes #11942
Checklist