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

Add ordinal to merge schema after merge #2662

Merged
merged 3 commits into from
Jan 25, 2022

Conversation

VinaiRachakonda
Copy link
Contributor

@VinaiRachakonda VinaiRachakonda commented Jan 24, 2022

Still need to add test cases here

@@ -118,6 +118,12 @@ func SchemaMerge(ourSch, theirSch, ancSch schema.Schema, tblName string) (sch sc
if err != nil {
return nil, sc, err
}

err = sch.SetPkOrdinals(ourSch.GetPkOrdinals())
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the three schemas have different pk ordinals? how to tell which one to keep?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we do not support merge between tables with competing ordinals.

@VinaiRachakonda VinaiRachakonda changed the title [WIP] Reset the ordinals of the PK Set [WIP] Add ordinal to merge schema after merge Jan 24, 2022
@VinaiRachakonda VinaiRachakonda changed the title [WIP] Add ordinal to merge schema after merge Add ordinal to merge schema after merge Jan 24, 2022
Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

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

LGTM, a simpler unit test would have been helpful, the script test seems sufficient

Expected: []sql.Row{{1, 1, 1}, {2, 3, 2}, {2, 5, 2}},
},
{
Query: "/* client b */ insert into test values (4,3,2)",
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't strike me as the most direct way to test the change, but if it mimics the original customer issue then it make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah without the change, this becomes an incorrect primary key issue and the ordering of the select changes. This indicates that primary key set has changed.

@@ -118,6 +118,14 @@ func SchemaMerge(ourSch, theirSch, ancSch schema.Schema, tblName string) (sch sc
if err != nil {
return nil, sc, err
}

// TODO: We should enforce the existing primary key set pk ordinals as out of order primary
// key ordinal merge is not supported yet.
Copy link
Contributor

Choose a reason for hiding this comment

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

"merge conflict should have blocked any ordinal change"?

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

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

LGTM, a simpler unit test would have been helpful, the script test seems sufficient

@VinaiRachakonda VinaiRachakonda merged commit 27749d9 into main Jan 25, 2022
@Hydrocharged Hydrocharged deleted the vinai/set-merge-schema-ordingal branch April 10, 2022 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants