-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: remove mock.NewContext()
usage when building table meta in production code
#56348
*: remove mock.NewContext()
usage when building table meta in production code
#56348
Conversation
894c162
to
ba456b8
Compare
Hi @lcwangchao. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@@ -62,6 +64,7 @@ func Init() { | |||
c.ID = int64(i) + 1 | |||
} | |||
meta.DBID = dbID | |||
meta.State = model.StatePublic |
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.
I think the master code lost this line to set the table state to public... Though it still works well without this state, I still fix it to make the meta complete.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56348 +/- ##
================================================
+ Coverage 73.3813% 76.1041% +2.7228%
================================================
Files 1623 1645 +22
Lines 447183 455176 +7993
================================================
+ Hits 328149 346408 +18259
+ Misses 98920 87175 -11745
- Partials 20114 21593 +1479
Flags with carried forward coverage won't be shown. Click here to find out more.
|
ba456b8
to
a8c3edd
Compare
) | ||
|
||
// GetTableInfo returns table information. | ||
func GetTableInfo(ctx context.Context, db dbutil.QueryExecutor, schemaName string, tableName string) (*model.TableInfo, 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.
Remove GetTableInfo
because it is not used by any code...
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.
used by tiflow😓
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
createTableStmt, ok := astNode.(*ast.CreateTableStmt) | ||
if !ok { | ||
return nil, errors.New("cannot transfer the parsed SQL as an CREATE TABLE statement") | ||
} | ||
info, err := ddl.MockTableInfo(sctx, createTableStmt, tableID) | ||
info, err := ddl.BuildTableInfoFromAST(metabuild.NewNonStrictContext(), createTableStmt) |
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.
Seems newTableInfo
always use 0
as table it and it is not actually used when importing data:
tidb/lightning/pkg/importer/get_pre_info.go
Line 411 in b427e33
theTableInfo, err := newTableInfo(createTblSQL, 0) |
PTAL @lance6716
@@ -237,7 +237,8 @@ func parseTable(t *table, stmt *ast.CreateTableStmt) error { | |||
t.name = stmt.Table.Name.L | |||
t.columns = make([]*column, 0, len(stmt.Cols)) | |||
|
|||
mockTbl, err := ddl.MockTableInfo(mock.NewContext(), stmt, 1) | |||
mockTbl, err := ddl.BuildTableInfoFromAST(metabuild.NewNonStrictContext(), stmt) | |||
mockTbl.ID = 1 |
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.
what's this for?
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 seems like an old tool to import data to tidb. But I think no one uses it now...
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: D3Hunter, hawkingrei, lance6716, qw4990, tangenta, YangKeao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/retest |
@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What problem does this PR solve?
Issue Number: ref #53388
What changed and how does it work?
This PR removes the
mock.Context
usage in production codes when building table meta, including:cmd/importer
Check List
Tests
Use the below test to output the system table's meta in json format:
And try to diff the output file in master and this PR, there is no diff. So the behavior is the same when building system table meta.
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.