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

Improve logic to include originalUniqueKey in sharedUniqueKeys #1453

Merged
merged 4 commits into from
Jan 5, 2025

Conversation

htmsousa
Copy link
Contributor

Until now, when building the list of SharedUniqueKeys, the code was selecting only the originalUniqueKeys that existed in ghostUniqueKeys list.

However, as part of the alter table, it is possible to add more unique keys or even composed primary keys with multiple columns.

The new logic keeps the old behaviour (it matches originalUniqueKey with exactly the same ghostUniqueKey) but also supports the cases where the originalUniqueKey is now a subset of one of the new ghostUniqueKeys.

If such a case happens, we can still use the originalUniqueKey as normal because a new ghostUniqueKey with the columns of originalUniqueKey plus some new columns is inherently unique just by the columns in the originalUniqueKey, no matter the value in the new columns of the new unique key.

A Pull Request should be associated with an Issue.

We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
and potentially we'll be able to point development in a particular direction.

Related issue: #1452

Further notes in https://github.com/github/gh-ost/blob/master/.github/CONTRIBUTING.md
Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR

Description

This PR [briefly explain what it does]

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

Until now, when building the list of SharedUniqueKeys, the code was selecting only the originalUniqueKeys that existed in ghostUniqueKeys list.

However, as part of the alter table, it is possible to add more unique keys or even composed primary keys with multiple columns.

The new logic keeps the old behaviour (it matches originalUniqueKey with exactly the same ghostUniqueKey) but also supports the cases where the originalUniqueKey is now a subset of one of the new ghostUniqueKeys.

If such a case happens, we can still use the originalUniqueKey as normal because a new ghostUniqueKey with the columns of originalUniqueKey plus some new columns is inherently unique just by the columns in the originalUniqueKey, no matter the value in the new columns of the new unique key.
@meiji163
Copy link
Contributor

👋 Thanks for the PR! Can we add a test in localtests/ to verify this case?

@htmsousa
Copy link
Contributor Author

htmsousa commented Dec 31, 2024

👋 Thanks for the PR! Can we add a test in localtests/ to verify this case?

Thanks @meiji163 for the feedback. I was reading the documentation, but it is not clear how to run the localtests locally. Can you provide some info on how to run it locally?
image

@htmsousa
Copy link
Contributor Author

htmsousa commented Jan 4, 2025

@meiji163 I manage to make the localtests to run locally. Existing test was update and new one added.

@htmsousa
Copy link
Contributor Author

htmsousa commented Jan 4, 2025

@meiji163 apologies but I made a mistake when I merged the master branch to my branch. it should be fixed now.

@meiji163 meiji163 merged commit ad5d3ea into github:master Jan 5, 2025
7 checks passed
@htmsousa htmsousa deleted the ImprovementsToGetSharedUniqueKeys branch January 5, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants