mysql2
gem + mariadb
+ Alpine Linux
tl;dr Use mariadb-dev
. In case of Alpine Linux 3.8, 3.9,
use mysql2 >= 0.4.10
.
Starting with Alpine Linux 3.8 there are basically 2 options to install
the mysql2
gem:
1.sh
:
#!/bin/sh
set -eu
apk add build-base "$1"
gem install mysql2 -v "$2"
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.11 ./1.sh mariadb-dev 0.5.3
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.5.3
1 gem installed
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.11 ./1.sh mariadb-connector-c-dev 0.5.3
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.5.3
1 gem installed
But with mysql2 < 0.4.10
one of them doesn't work:
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.11 ./1.sh mariadb-dev 0.4.9
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.9
1 gem installed
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.11 ./1.sh mariadb-connector-c-dev 0.4.9
...
compiling client.c
In file included from client.c:1:
./mysql2_ext.h:14:10: fatal error: mysql_com.h: No such file or directory
14 | #include <mysql_com.h>
| ^~~~~~~~~~~~~
...
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.11 ./1.sh mariadb-connector-c-dev 0.4.10
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.10
1 gem installed
That happens because mysql2 < 0.4.10
requires mysql_com.h
for some reason (leftover #include
?).
But most of the time mysql_com.h
comes with mariadb-dev
, not with mariadb-connector-c-dev
.
MariaDB Connector/C renamed mysql_com.h
to mariadb_com.h
in 3.0-cc-server-integ-0
.
MariaDB Connector/C 3.0.1-beta
replaced libmysqlclient
in MariaDB 10.2.2.
But MariaDB itself (server) still had the mysql_com.h
file, so nothing changed in this regard.
Before MariaDB 10.2.8
mysql_com.h
was a part of the mariadb
header files, that
were used to build both clients, and server plugins. But in 10.2.8
those
were split, server headers were moved to /usr/include/mysql/server
.
Then, in 10.2.9
there were added some client compatibility header
files (with warnings), particularly mysql_com.h
.
That means mysql_com.h
didn't exist in MariaDB 10.2.8
.
So, either upgrade to mysql2 >= 0.4.10
, or use mariadb-dev
.
But that's not the only issue that mysql2-0.4.10
solves.
MariaDB Connector/C doesn't define MYSQL_SERVER_VERSION
until 3.0.9
.
That affects Alpine Linux 3.8 (3.0.4
), 3.9 (3.0.8
). mysql2 < 0.4.10
doesn't work on these releases.
So again, either upgrade mysql2
to >= 0.4.10
, or use Alpine Linux >= 3.10
.
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.8 ./1.sh mariadb-dev 0.4.9
...
compiling client.c
In file included from /usr/local/include/ruby-2.6.0/ruby/ruby.h:29:0,
from /usr/local/include/ruby-2.6.0/ruby.h:33,
from ./mysql2_ext.h:10,
from client.c:1:
client.c: In function 'rb_mysql_client_info':
client.c:59:30: error: 'MYSQL_SERVER_VERSION' undeclared (first use in this function)
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^
...
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.8 ./1.sh mariadb-dev 0.4.10
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.10
1 gem installed
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.9 ./1.sh mariadb-dev 0.4.9
...
compiling client.c
In file included from /usr/local/include/ruby-2.6.0/ruby/ruby.h:29,
from /usr/local/include/ruby-2.6.0/ruby.h:33,
from ./mysql2_ext.h:10,
from client.c:1:
client.c: In function 'rb_mysql_client_info':
client.c:59:30: error: 'MYSQL_SERVER_VERSION' undeclared (first use in this function); did you mean 'MYSQL_LINK_VERSION'?
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^~~~~~~~~~~~~~~~~~~~
...
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.9 ./1.sh mariadb-dev 0.4.10
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.10
1 gem installed
$ docker run --rm -v $PWD/1.sh:/1.sh ruby:2.6-alpine3.10 ./1.sh mariadb-dev 0.4.9
...
Gem 'mysql2' is not installed
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.9
1 gem installed
MDEV-9055 replace libmysqlclient with Connector/C
MDEV-9293 change clients to use Connector/C
MDEV-9267 pull in Connector/C sources into the server tree on builds
56c4cfe0bea MDEV-9293 - Use MariaDB's Connector/C in server
ed0b84a0270 remove libmysql/
79fa256eb2e really add a submodule
main/mariadb: upgrade to 10.2.13, modernize
main/mariadb: split embedded, embedded-dev, static and server-utils
Judging from the following commit:
main/mariadb-connector-c: move from testing
Connector/C is needed for mariadb-10.2.x
to work (at least for mariadb >= 10.2.2
).