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

Error message of duplicate primary key was not showing as expected, error message has been rectified #38254

Closed
wants to merge 2 commits into from

Conversation

75asu
Copy link

@75asu 75asu commented Sep 29, 2022

What problem does this PR solve?

Issue Number: close #35289

Problem Summary:

What is changed and how it works?

This PR modfies the rune type strings into unicode style strings as it was asked in the relevant issue

Check List

Tests

I have done the unit tests using make gotest

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

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

Documentation

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

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

close #38170

<!--

Thank you for contributing to TiDB!

PR Title Format:
1. pkg [, pkg2, pkg3]: what's changed
2. *: what's changed

-->

### What problem does this PR solve?
<!--

Please create an issue first to describe the problem.

There MUST be one line starting with "Issue Number:  " and 
linking the relevant issues via the "close" or "ref".

For more info, check https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/contribute-code.html#referring-to-an-issue.

-->

Issue Number: close #35289

Problem Summary:

### What is changed and how it works?
This PR modfies the **rune type strings** into **unicode style strings** as it was asked in the relevant issue

### Check List

Tests <!-- At least one of them must be included. -->

I have done the unit tests using `make gotest`
- [ x ] Unit test
- [ ] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No code

Side effects

- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility

Documentation

- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ x ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility

### Release note

<!-- compatibility change, improvement, bugfix, and new feature need a release note -->

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

```release-note
None
```
@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 do-not-merge/invalid-title release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 29, 2022
@ti-chi-bot
Copy link
Member

Welcome @measutosh!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@75asu 75asu changed the title Master Error message of duplicate primary key was not showing as expected, error message has been rectified Sep 29, 2022
@75asu
Copy link
Author

75asu commented Sep 29, 2022

/cc @tangenta, here is a submission from my side to solve the issue - #35289

Here I have made a small demo of simillar code - go playground

Please have a look on it.

thanks

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

Hi, can you add an unit test to illustrate the effects?

@75asu
Copy link
Author

75asu commented Sep 30, 2022

Hi, can you add an unit test to illustrate the effects?

Hi @lance6716 , I am quite new to this, unable to figure out how to write test case for this
that's why I have provided the demo code for your reference
Could you please provide some resource following which I can write the unit tests

@lance6716
Copy link
Contributor

Maybe you can search for the usage of MustGetErrMsg, this is a testing function that assert the SQL must return a specific error message. @measutosh

Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

For the ASCII characters we don't have to cast to "%u" style.

store/driver/txn/error.go Outdated Show resolved Hide resolved
return genKeyExistsError(name, strings.Join(valueStr, "-"), nil)
var nonUnicodeValueStr []string;
for i := 0; i < len(valueStr); i++ {
nonUnicodeValueStr[i] = fmt.Sprintf("\\u%X", valueStr[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

This assignment will panic because of the index-out-of-range error.

Co-authored-by: tangenta <tangenta@126.com>
@ti-chi-bot
Copy link
Member

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/invalid-title label, please follow title format, for example pkg [, pkg2, pkg3]: what is changed or *: what is changed.

📖 For more info, you can check the "Contribute Code" section in the development guide.

@winkyao
Copy link
Contributor

winkyao commented Dec 1, 2022

issue #35289 was fixed by PR #39485 , thanks for your contribution.

@75asu 75asu closed this by deleting the head repository Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/invalid-title release-note-none Denotes a PR that doesn't merit a release note. 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.

Error message of duplicate primary key is not shown properly
5 participants