-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
infoschema: add table_id to table and add tidb_indexes table. #9183
Conversation
/run-all-tests |
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.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #9183 +/- ##
==========================================
+ Coverage 67.21% 67.24% +0.03%
==========================================
Files 371 371
Lines 77052 77104 +52
==========================================
+ Hits 51789 51850 +61
+ Misses 20634 20629 -5
+ Partials 4629 4625 -4
Continue to review full report at Codecov.
|
/run-all-tests |
tb.Name.O, // TABLE_NAME | ||
0, // NON_UNIQUE | ||
"PRIMARY", // KEY_NAME | ||
1, // SEQ_IN_INDEX |
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 0 better? Or it may coincide with indices?
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.
it's follow
Line 419 in e6a0eb9
1, // Seq_in_index |
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.
maybe we should better let seq start from 1 https://dev.mysql.com/doc/refman/8.0/en/show-index.html
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.
Ok, so it is better to make the seq_in_index
be len(rows)+1
for index.
{"KEY_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, | ||
{"SEQ_IN_INDEX", mysql.TypeLonglong, 21, 0, nil, nil}, | ||
{"COLUMN_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, | ||
{"SUB_PART", mysql.TypeLonglong, 21, 0, nil, nil}, |
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.
Why not name it as LENGTH
?
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.
because show index
use this name
record := types.MakeDatums( | ||
schema.Name.O, // TABLE_SCHEMA | ||
tb.Name.O, // TABLE_NAME | ||
0, // NON_UNIQUE |
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.
May this 0 confuse others?
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.
just follow show index
Line 417 in e6a0eb9
0, // Non_unique |
{"TABLE_SCHEMA", mysql.TypeVarchar, 64, 0, nil, nil}, | ||
{"TABLE_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, | ||
{"NON_UNIQUE", mysql.TypeLonglong, 21, 0, nil, nil}, | ||
{"KEY_NAME", mysql.TypeVarchar, 64, 0, nil, nil}, |
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.
put this column before NON_UNIQUE
?
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.
it's following show index
@@ -1003,6 +1019,68 @@ func dataForTables(ctx sessionctx.Context, schemas []*model.DBInfo) ([][]types.D | |||
return rows, nil | |||
} | |||
|
|||
func dataForIndexes(ctx sessionctx.Context, schemas []*model.DBInfo) ([][]types.Datum, error) { |
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.
This looks like duplicate code with fetchShowIndex
? can we extract it to a separate function for reuse?
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.
good idea, current show table
and tables
is same to but maybe we can do this in future?
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.
LGTM
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.
LGTM
What problem does this PR solve?
now, we can query
table_id
andindex_id
from http-api, but in some enviorment, it's more convient to use sql.
final usage can be sawed in test case https://github.com/pingcap/tidb/pull/9183/files#diff-9cb2947f24dfdff2e6f6cec84b53aa56R212
What is changed and how it works?
tidb_table_id
column toinformation_schema.tables
tidb_indexes
table that containsindex_id
columnlet use query
table_id
andindex_id
via sql.Check List
Tests
Code changes
Side effects
Related changes
This change is