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

planner, executor: fix error code #13733

Merged
merged 11 commits into from
Dec 3, 2019
Merged

Conversation

ichn-hu
Copy link
Contributor

@ichn-hu ichn-hu commented Nov 26, 2019

What problem does this PR solve?

Associating internal error code for planner/core/errors.go, expression/errors.go and executor/errors.go to parser/mysql/errcode.go.

What is changed and how it works?

Adding more error code and set up the mapping.

Check List

Tests

  • No code

Code changes

Side effects

Related changes

Release note

@ichn-hu ichn-hu added the type/enhancement The issue or PR belongs to an enhancement. label Nov 26, 2019
@ichn-hu ichn-hu requested a review from a team as a code owner November 26, 2019 05:24
@ghost ghost requested review from wshwsh12 and XuHuaiyu and removed request for a team November 26, 2019 05:24
@ichn-hu ichn-hu requested a review from jackysp November 26, 2019 05:24
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Nov 26, 2019

/run-all-tests

codeWindowRowsIntervalUse = mysql.ErrWindowRowsIntervalUse
codeWindowFunctionIgnoresFrame = mysql.ErrWindowFunctionIgnoresFrame
codeUnsupportedOnGeneratedColumn = mysql.ErrUnsupportedOnGeneratedColumn
codeUnsupportedType terror.ErrCode = mysql.ErrUnsupportedType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't get what you mean? Do you mean we want to totally get ride of codeXXX and just use mysql.ErrXX?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

ErrCartesianProductUnsupported = terror.ClassOptimizer.New(codeUnsupported, mysql.MySQLErrName[mysql.ErrCartesianProductUnsupported])
ErrStmtNotFound = terror.ClassOptimizer.New(codeStmtNotFound, mysql.MySQLErrName[mysql.ErrPreparedStmtNotFound])
ErrWrongParamCount = terror.ClassOptimizer.New(codeWrongParamCount, mysql.MySQLErrName[mysql.ErrWrongParamCount])
ErrSchemaChanged = terror.ClassOptimizer.New(codeSchemaChanged, mysql.MySQLErrName[mysql.ErrSchemaChanged])
ErrTablenameNotAllowedHere = terror.ClassOptimizer.New(codeTablenameNotAllowedHere, "Table '%s' from one of the %ss cannot be used in %s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the predefined error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a little different, it has a predefined error message in mysql/errname.go for ErrTablenameNotAllowedHere, but it is different from the native error message.

	ErrTablenameNotAllowedHere:                  "Table '%-.192s' from one of the SELECTs cannot be used in %-.32s",

One work around is to then create another error code for this error, say ErrTablenameNotAllowedHere2 if we want every error message to be strictly defined in mysql/errname.go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could modify the error message in mysql/errname.go

@@ -147,6 +146,12 @@ var (

func init() {
mysqlErrCodeMap := map[terror.ErrCode]uint16{
codeUnsupportedType: mysql.ErrUnsupportedType,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests for this map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give some hint on how to add tests for this map?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Nov 26, 2019

Codecov Report

Merging #13733 into master will increase coverage by 0.0093%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##             master     #13733        +/-   ##
================================================
+ Coverage   80.3765%   80.3859%   +0.0094%     
================================================
  Files           474        474                
  Lines        118333     117941       -392     
================================================
- Hits          95112      94808       -304     
+ Misses        15804      15706        -98     
- Partials       7417       7427        +10

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Nov 26, 2019

@jackysp PTAL again.

@XuHuaiyu XuHuaiyu changed the title Fix error code *: fix error code Nov 26, 2019
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SunRunAway SunRunAway changed the title *: fix error code planner, executor: fix error code Nov 26, 2019
@SunRunAway SunRunAway added sig/execution SIG execution sig/planner SIG: Planner labels Nov 26, 2019
@SunRunAway SunRunAway requested review from jackysp and removed request for SunRunAway November 26, 2019 12:31
@jackysp
Copy link
Member

jackysp commented Nov 27, 2019

LGTM, please fix the build and test.

@wshwsh12 wshwsh12 removed their request for review November 27, 2019 07:25
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Nov 28, 2019

Will do, pingcap/parser#650 merged.

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Nov 29, 2019

/run-common-test

3 similar comments
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-common-test

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-common-test

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-common-test

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-all-tests

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-all-tests

1 similar comment
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-all-tests

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-all-tests tidb-test=pr/961

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-common-test tidb-test=pr/961

1 similar comment
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-common-test tidb-test=pr/961

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

/run-all-tests tidb-test=pr/961

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Dec 2, 2019

@jackysp PR https://github.com/pingcap/tidb-test/pull/961 fixes common-test, both PR are ready for merge, PTAL.

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 3, 2019
@zz-jason zz-jason added status/all tests passed and removed status/can-merge Indicates a PR has been approved by a committer. labels Dec 3, 2019
@zz-jason zz-jason requested a review from a team as a code owner December 3, 2019 05:03
@ghost ghost requested review from francis0407 and winoros and removed request for a team December 3, 2019 05:04
@zz-jason zz-jason merged commit 744c5c1 into pingcap:master Dec 3, 2019
@ichn-hu ichn-hu deleted the fix-error-code branch December 3, 2019 12:05
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants