MEDIUM: checks: Make post-41 the default mode for mysql checks
MySQL 4.1 is old enough to be the default mode for mysql checks. So now, once a
username is defined, post-41 mode is automatically used. To do mysql checks on
previous MySQL version, the argument "pre-41" must be used.
Note, it is a compatibility breakage for everyone using an antique and
unsupported MySQL version.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index a8ba58a..e434a47 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -7745,14 +7745,15 @@
logging.
-option mysql-check [ user <username> [ post-41 ] ]
+option mysql-check [ user <username> [ { post-41 | pre-41 } ] ]
Use MySQL health checks for server testing
May be used in sections : defaults | frontend | listen | backend
yes | no | yes | yes
Arguments :
<username> This is the username which will be used when connecting to MySQL
server.
- post-41 Send post v4.1 client compatible checks
+ post-41 Send post v4.1 client compatible checks (the default)
+ pre-41 Send pre v4.1 client compatible checks
If you specify a username, the check consists of sending two MySQL packet,
one Client Authentication packet, and one QUIT packet, to correctly close
diff --git a/reg-tests/checks/mysql-check.vtc b/reg-tests/checks/mysql-check.vtc
index 061f2c1..5344d95 100644
--- a/reg-tests/checks/mysql-check.vtc
+++ b/reg-tests/checks/mysql-check.vtc
@@ -89,13 +89,13 @@
backend be2
log ${S2_addr}:${S2_port} daemon
option log-health-checks
- option mysql-check user user
+ option mysql-check user user pre-41
server srv ${h1_mysql1_addr}:${h1_mysql1_port} check inter 1s rise 1 fall 1
backend be3
log ${S3_addr}:${S3_port} daemon
option log-health-checks
- option mysql-check user user post-41
+ option mysql-check user user
server srv ${h1_mysql2_addr}:${h1_mysql2_port} check inter 1s rise 1 fall 1
backend be4
diff --git a/src/checks.c b/src/checks.c
index d22c113..74b0fc8 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -6852,21 +6852,21 @@
goto error;
}
- if (*args[cur_arg+2]) {
- if (strcmp(args[cur_arg+2], "post-41") != 0) {
- ha_alert("parsing [%s:%d] : keyword '%s' only supports option 'post-41' (got '%s').\n",
- file, line, args[cur_arg], args[cur_arg+2]);
- goto error;
- }
+ if (!*args[cur_arg+2] || strcmp(args[cur_arg+2], "post-41") == 0) {
packetlen = userlen + 7 + 27;
mysql_req = mysql41_req;
mysql_rsname = mysql41_rsname;
}
- else {
+ else if (strcmp(args[cur_arg+2], "pre-41") == 0) {
packetlen = userlen + 7;
mysql_req = mysql40_req;
mysql_rsname = mysql40_rsname;
}
+ else {
+ ha_alert("parsing [%s:%d] : keyword '%s' only supports 'post-41' and 'pre-41' (got '%s').\n",
+ file, line, args[cur_arg], args[cur_arg+2]);
+ goto error;
+ }
hdr[0] = (unsigned char)(packetlen & 0xff);
hdr[1] = (unsigned char)((packetlen >> 8) & 0xff);