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

Tidy build error on Debian bookworm #448

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

davel
Copy link
Contributor

@davel davel commented Oct 24, 2024

We fail to build on Debian bookworm, it supplies MariaDB rather than MySQL. Unfortunately we fail to build with an unhelpful error message. MariaDB is now up to version 11.

  • Use version.pm to do the version comparison rather than a regex.
  • Check for MariaDB and generate a warning if we're going to link against it.
  • Correct my email address :-)

@davel davel force-pushed the davel/debian-bookworm-error branch from eafc5c4 to 786b362 Compare October 24, 2024 16:42
@davel davel marked this pull request as ready for review October 24, 2024 16:43
@Grinnz
Copy link
Contributor

Grinnz commented Oct 24, 2024

version.pm is for parsing and comparing Perl versions and is not appropriate to use for general program versions (for example, it would interpret a hypothetical '5.10' incorrectly). You could consider versioncmp from Sort::Versions but it's probably not worth adding a dependency for this.

if ($opt->{libs} =~ /mariadb/) {
print <<"MSG";

The chosen MySQL client library appears to be MariaDB's. Compilation may fail.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The chosen MySQL client library appears to be MariaDB's. Compilation may fail.
The chosen MySQL client library appears to be MariaDB's. DBD::mysql doesn't support building against a MariaDB client library.

I like this method as it doesn't rely on versions to detect MariaDB (>= 10.0 ) or MySQL (< 10.0) which can be very useful if in the future Oracle would release a MySQL 10.x (Not unlikely, see the diagram on this blog post )

Copy link
Collaborator

@dveeden dveeden Oct 25, 2024

Choose a reason for hiding this comment

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

Not sure what the best text/info is here.

  • DBD::mysql requires an Oracle MySQL client library. As the MariaDB client library presents itself as MySQL client library this can be confusing to users. This might get better in the future as mysql_config is in libmariadb-dev-compat and is optional (at least on Ubuntu 20.04).
  • DBD::mysql build with a Oracle MySQL client library can be used to connect to MariaDB.
  • Alternatives are DBD::MariaDB and DBD::mysql v4.x. I think only listing the first one (as you did) is probably best, but I'm not sure.
  • The MySQL client library must be 8.0 or newer
  • Maybe return info on how it was determined to be MariaDB (mysql_config --libs matched mariadb) to make it easier for people to troubleshoot.
  • On bookworm the MySQL APT Repository can be used. Debian sid has Oracle MySQL iirc. (I know this doesn't help with native Debian packages)

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've kept the text descriptive of the behaviour.

Suggesting Oracle's library seems like good advice. Recommending sticking with 4.x might age badly.

It's not unreasonable for someone to want to use this module with MariaDB. DBD::MariaDB has Unicode fixes that might break your application.

@dveeden
Copy link
Collaborator

dveeden commented Oct 25, 2024

version.pm is for parsing and comparing Perl versions and is not appropriate to use for general program versions (for example, it would interpret a hypothetical '5.10' incorrectly). You could consider versioncmp from Sort::Versions but it's probably not worth adding a dependency for this.

Thanks, this is very useful info. If MariaDB is detected based on if mysql_config --libs output matches mariadb then the version matching would be easier as we only need to make sure the first number before the . is 8 or higher, we don't have to restrict the upper bound anymore.

As Oracle stayed on 8.0.x for many years and now suddenly has released many new versions like 8.1, 8.2, 8.3, 8.4, 9.0 and 9.1 and is slowly approaching the version range that is used by MariaDB (10.x and up) version checks are becoming more fragile, especially for determining the flavor (MySQL, MariaDB, etc)

@dveeden
Copy link
Collaborator

dveeden commented Oct 25, 2024

Maybe a simple split instead of a regex?

#!/bin/perl
my @versions = ("3.23.40", "4.1.24", "5.7.40", "8.0.11", "9.1.0", "10.0.0", "11.1.0", "8.0.11-TiDB-v8.4.0");
foreach (@versions) {
	my @verinfo = split(/\./, $_);
	my $verok = @verinfo[0]>=8 ? "ok" : "too old";
	print "$_ has major version @verinfo[0] which is $verok.\n"
}
3.23.40 has major version 3 which is too old.
4.1.24 has major version 4 which is too old.
5.7.40 has major version 5 which is too old.
8.0.11 has major version 8 which is ok.
9.1.0 has major version 9 which is ok.
10.0.0 has major version 10 which is ok.
11.1.0 has major version 11 which is ok.
8.0.11-TiDB-v8.4.0 has major version 8 which is ok.

davel added 2 commits October 27, 2024 11:21
Debian no longer supplies libmysqlclient. It provides symlinks from
mysql_config to mariadb_config. Unfortunately this gives us an unhelpful
compilation error because we are using MySQL exclusive features.
@davel davel force-pushed the davel/debian-bookworm-error branch from 786b362 to c38d218 Compare October 27, 2024 11:27
@dveeden dveeden merged commit 0f3a8ba into perl5-dbi:master Oct 28, 2024
7 of 8 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