mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
MDEV-4088 Replication 10.0 -> 5.5 fails
update 5.1 to replicate from 10.0 and to show the server version (as of 10.0) correctly sql-common/client.c: mdev:4088 sql/slave.cc: use the version number, not just the first character of the version string (we want 10 > 4 not "10" < "4").
This commit is contained in:
parent
e70ce465b7
commit
87a452f6d5
3 changed files with 43 additions and 9 deletions
|
|
@ -27,6 +27,31 @@
|
|||
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
|
||||
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
|
||||
|
||||
/*
|
||||
MDEV-4088
|
||||
|
||||
MySQL (and MariaDB 5.x before the fix) was using the first character of the
|
||||
server version string (as sent in the first handshake protocol packet) to
|
||||
decide on the replication event formats. And for 10.x the first character
|
||||
is "1", which the slave thought comes from some ancient 1.x version
|
||||
(ignoring the fact that the first ever MySQL version was 3.x).
|
||||
|
||||
To support replication to these old clients, we fake the version in the
|
||||
first handshake protocol packet to start from "5.5.5-" (for example,
|
||||
it might be "5.5.5-10.0.1-MariaDB-debug-log".
|
||||
|
||||
On the client side we remove this fake version prefix to restore the
|
||||
correct server version. The version "5.5.5" did not support
|
||||
pluggable authentication, so any version starting from "5.5.5-" and
|
||||
claiming to support pluggable auth, must be using this fake prefix.
|
||||
*/
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define RPL_VERSION_HACK ""
|
||||
#else
|
||||
/* this version must be the one that *does not* support pluggable auth */
|
||||
#define RPL_VERSION_HACK "5.5.5-"
|
||||
#endif
|
||||
|
||||
#define SERVER_VERSION_LENGTH 60
|
||||
#define SQLSTATE_LENGTH 5
|
||||
|
||||
|
|
@ -145,6 +170,8 @@ enum enum_server_command
|
|||
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
|
||||
#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
|
||||
|
||||
#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
|
||||
|
||||
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
|
||||
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
|
||||
|
||||
|
|
|
|||
|
|
@ -2264,6 +2264,12 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
|||
strmov(mysql->server_version,(char*) net->read_pos+1);
|
||||
mysql->port=port;
|
||||
|
||||
/* remove the rpl hack from the version string, see RPL_VERSION_HACK comment */
|
||||
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH &&
|
||||
strncmp(mysql->server_version, RPL_VERSION_HACK,
|
||||
sizeof(RPL_VERSION_HACK) - 1) == 0)
|
||||
mysql->server_version+= sizeof(RPL_VERSION_HACK) - 1;
|
||||
|
||||
/*
|
||||
Part 2: format and send client info to the server for access check
|
||||
*/
|
||||
|
|
|
|||
19
sql/slave.cc
19
sql/slave.cc
|
|
@ -872,6 +872,7 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi)
|
|||
int err_code= 0;
|
||||
MYSQL_RES *master_res= 0;
|
||||
MYSQL_ROW master_row;
|
||||
uint version= mysql_get_server_version(mysql) / 10000;
|
||||
DBUG_ENTER("get_master_version_and_clock");
|
||||
|
||||
/*
|
||||
|
|
@ -892,20 +893,20 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi)
|
|||
/*
|
||||
Note the following switch will bug when we have MySQL branch 30 ;)
|
||||
*/
|
||||
switch (*mysql->server_version)
|
||||
switch (version)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
errmsg = "Master reported unrecognized MySQL version";
|
||||
err_code= ER_SLAVE_FATAL_ERROR;
|
||||
sprintf(err_buff, ER(err_code), errmsg);
|
||||
break;
|
||||
case '3':
|
||||
case 3:
|
||||
mi->rli.relay_log.description_event_for_queue= new
|
||||
Format_description_log_event(1, mysql->server_version);
|
||||
break;
|
||||
case '4':
|
||||
case 4:
|
||||
mi->rli.relay_log.description_event_for_queue= new
|
||||
Format_description_log_event(3, mysql->server_version);
|
||||
break;
|
||||
|
|
@ -1069,10 +1070,10 @@ maybe it is a *VERY OLD MASTER*.");
|
|||
*/
|
||||
|
||||
/* redundant with rest of code but safer against later additions */
|
||||
if (*mysql->server_version == '3')
|
||||
if (version == 3)
|
||||
goto err;
|
||||
|
||||
if (*mysql->server_version == '4')
|
||||
if (version == 4)
|
||||
{
|
||||
master_res= NULL;
|
||||
if (!mysql_real_query(mysql,
|
||||
|
|
@ -1133,7 +1134,7 @@ inconsistency if replicated data deals with collation.");
|
|||
This check is only necessary for 4.x masters (and < 5.0.4 masters but
|
||||
those were alpha).
|
||||
*/
|
||||
if (*mysql->server_version == '4')
|
||||
if (version == 4)
|
||||
{
|
||||
master_res= NULL;
|
||||
if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT @@GLOBAL.TIME_ZONE")) &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue