-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
OnlineDDL to use schemadiff version capabilities; refactor some flavor
code.
#14883
OnlineDDL to use schemadiff version capabilities; refactor some flavor
code.
#14883
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
…ff is capable of INSTANT algorithm Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…ntDDL instead Signed-off-by: Shlomi Noach <[email protected]>
…it. Introduce mysql.ServerVersionCapableOf() helper function Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
flavor
code.
flavor
code.flavor
code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I just had the minor questions/comments/suggestions. I'll leave it to you to resolve as you feel is best.
@@ -136,7 +136,7 @@ type flavor interface { | |||
baseShowTables() string | |||
baseShowTablesWithSizes() string | |||
|
|||
supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) | |||
supportsCapability(capability capabilities.FlavorCapability) (bool, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now assumes that the serverVersion was specified otherwise. That's fine, I think, but we should probably add some error handling / unit test code covering the case where it's not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit test as suggested. In actual connections, serverVersion
is always non-empty; the existing logic for setting a connection's flavor is to return nil
flavor when there is no known flavor for the given server version (whether server version is empty, or something ridiculous as "1792.3343.3"
). Just pointing out that on this respect there's nothing new this PR adds.
go/mysql/flavor_mysql.go
Outdated
@@ -400,7 +402,8 @@ func (mysqlFlavor80) baseShowTablesWithSizes() string { | |||
} | |||
|
|||
// supportsCapability is part of the Flavor interface. | |||
func (mysqlFlavor80) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { | |||
func (f mysqlFlavor80) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { | |||
serverVersion := f.serverVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing that if f.serverVersion
is the zeroval, then this will just always return false, nil.
, which seems fine to me. We should add a unit test case for that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
@@ -187,25 +194,29 @@ func GetFlavor(serverVersion string, flavorFunc func() flavor) (f flavor, capabl | |||
f = flavorFunc() | |||
case strings.HasPrefix(serverVersion, mariaDBReplicationHackPrefix): | |||
canonicalVersion = serverVersion[len(mariaDBReplicationHackPrefix):] | |||
f = mariadbFlavor101{} | |||
f = mariadbFlavor101{mariadbFlavor{serverVersion: canonicalVersion}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have test coverage for what the expected behavior is if there's a future use of the flavor as we did before, i.e. with no serverVersion
specified like it was here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
version: "8.0.20-log", | ||
capability: capabilities.CheckConstraintsCapability, | ||
isCapable: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I think we could just add:
{
version: "",
capability: capabilities.CheckConstraintsCapability,
isCapable: false,
},
No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
There will actually be a followup PR, I just don't want to overload this PR. I'm unhappy with the amount of information returned by |
Followup PR in #14900, will only be taken out of |
Description
Followup to #14878, which introduced
schemadiff
logic for detectingINSTANT
-able changes. In this PR:onlineddl/analysis.go
uses saidschemadiff
analysis, removing its own overlapping logic.CapableOf
function.mysql.ServerVersionCapableOf(version)
convenience function. I've switched all code that gets aCapableOf
to use this new accessor function.flavor
such that all flavors contain aversionString
field. It is then used by theirsupportsCapability(...)
implementations, rather than having a version string supplied externally as a function argument.Note: none of the Online DDL tests changed in essence - the point of this refactor is to preserve behavior through new implementation. The existing tests have good coverage and if they pass that means the refactor is good.
Related Issue(s)
Closes #14877
Checklist
Deployment Notes