Skip to content

remove semver #1028

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

Merged
merged 4 commits into from
May 2, 2025
Merged

remove semver #1028

merged 4 commits into from
May 2, 2025

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Apr 28, 2025

https://github.com/Masterminds/semver we are using v1 which is unmaintained

v3 fails tests since it does not accept tags (x.y.z-tag)

mysql versions aren't semantic. replace comparison logic to not use semver package

@dveeden
Copy link
Collaborator

dveeden commented Apr 29, 2025

Why is TestCompareServerVersions failing?

@dveeden
Copy link
Collaborator

dveeden commented Apr 29, 2025

Looks like it won't parse 8.0.32-0ubuntu0.20.04.2. Maybe we should truncate the part after the -?

Side note: MySQL versions are not really semantic: 8.0.11 has 8.0 as major version and not 8 for example. However that shouldn't really matter much.

MySQL versions for MariaDB, TiDB, Vitess, etc can be a bit weird: e.g. 8.0.11-TiDB-v9.0.0-alpha-658-gc619031356 which means it is TiDB v9.0.0 with git hash gc619031356 that claims to be MySQL 8.0.11.

And Percona versions and MySQL Enterprise and Cloud versions can also have all kinds of suffixes. (e.g. 8.0.36-u5-cloud)

@dveeden
Copy link
Collaborator

dveeden commented Apr 29, 2025

Maybe we could/should do version parsing in a way that would be useful to users of the library as well. For example to extract the implementation (MariaDB, TiDB, etc) and the version

@serprex
Copy link
Contributor Author

serprex commented Apr 29, 2025

Offering convention checks is unfortunately inconsistent. Noticed semver package being unsupported while investigating what eventually resulted in PeerDB-io/peerdb#2897 since RDS MariaDB returns something like 10.2.0-MariaDB from version(), but serverVersion from handshake is more like 5.5.0-10.2.0-MariaDB

I think keeping scope to the small existing scope is good. Users who want tag info can use _, tag, hasTag := strings.Cut(version, "-")

Updated PR to remove semver dependency, since we don't really want more than basic triplex comparison

@serprex serprex changed the title update semver to semver/v3 remove semver Apr 29, 2025
@serprex
Copy link
Contributor Author

serprex commented Apr 29, 2025

This change can be an issue if consumers specify only 8.0 instead of 8.0.0 to compare function

But hard to define behavior. Likely it should behave as 8.0.x not 8.0.0, skipping patch check. Would only require checking third return value of Cut (or whether numeric string is empty) & returning 0 whenever number missing

If that's desirable I can implement with a few test cases

Copy link
Collaborator

@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.

rest lgtm

@lance6716 lance6716 merged commit 8c60af8 into go-mysql-org:master May 2, 2025
17 checks passed
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.

3 participants