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

ddl: rename a non exist table report right error message(issue:#29893) #32144

Closed
wants to merge 4 commits into from

Conversation

fanrenhoo
Copy link
Contributor

@fanrenhoo fanrenhoo commented Feb 8, 2022

Signed-off-by: fanrenhoo [email protected]

What problem does this PR solve?

Issue Number: close #29893

Problem Summary:

What is changed and how it works?

in executor/ddl.go, in "func (e *DDLExec) executeRenameTable"
add new line:243 "isAlterTable := true"
in this "if branch" should be a altertable case, so set this value to "true"

I tested in my local branch, it worked, like:

use dbtest;
Database changed
rename table db1 to db2;
ERROR 1146 (42S02): Table 'dbtest.db1' doesn't exist

Check List

executor/ddl.go

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    I tested in my local branch, before fix its like what the issue described, now it worked:
    the steps is as:

create database dbtest;
use dbtest;
Database changed
rename table db1 to db2;
ERROR 1146 (42S02): Table 'dbtest.db1' doesn't exist

  • No code

Side effects

should no side effect

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

nothing change to Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release-note

fix the issue "Rename a non exist table report wrong error message"(issue:#29893) 
while rename noexist table, before fix the error message like: "ERROR 1017 (HY000): Can't find file: 'db_optimistic' (errno: {%!d(string=tb1) %!d(string=tb1)} - %!s(MISSING))"
after fix give the correct message "ERROR 1146 (42S02): Table 'dbtest.db1' doesn't exist"

/cc @xiongjiwei

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 8, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Feb 8, 2022

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@fanrenhoo
Copy link
Contributor Author

/cc @xiongjiwei

@ti-chi-bot ti-chi-bot requested a review from xiongjiwei February 8, 2022 04:10
@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 8, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Feb 8, 2022

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@sre-bot
Copy link
Contributor

sre-bot commented Feb 8, 2022

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@xiongjiwei
Copy link
Contributor

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

please follow the comment, the PR title should be like ddl: xxx in this case.

@fanrenhoo fanrenhoo changed the title fix issue:#29893 Rename a non exist table report wrong error message Rename table: rename a non exist table report right error message(issue:#29893) Feb 8, 2022
@fanrenhoo fanrenhoo changed the title Rename table: rename a non exist table report right error message(issue:#29893) Executor: rename a non exist table report right error message(issue:#29893) Feb 8, 2022
@fanrenhoo fanrenhoo changed the title Executor: rename a non exist table report right error message(issue:#29893) ddl: rename a non exist table report right error message(issue:#29893) Feb 8, 2022
@@ -240,6 +240,7 @@ func (e *DDLExec) executeRenameTable(s *ast.RenameTableStmt) error {
return ddl.ErrUnsupportedLocalTempTableDDL.GenWithStackByArgs("RENAME TABLE")
}
newIdent := ast.Ident{Schema: s.TableToTables[0].NewTable.Schema, Name: s.TableToTables[0].NewTable.Name}
isAlterTable := true
Copy link
Contributor

@xiongjiwei xiongjiwei Feb 8, 2022

Choose a reason for hiding this comment

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

the point is the error message is not the same with MySQL. We'd better change the error message.

BTW, in the previous code, isAlterTable is always false. I think it can be removed. you can see the commit which introduced this variable.

@xiongjiwei
Copy link
Contributor

please also add a test for this case

@fanrenhoo fanrenhoo closed this Feb 8, 2022
@fanrenhoo fanrenhoo deleted the renametablebug branch February 8, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename a non exist table report wrong error message
4 participants