Improve charset selection
The charset sent in the handshake is now done with the following priorities: * First Master server * Last Slave server * First Running server or Down server whose charset is known The change is that server in the Down state to which we've successfully connected to can also be used as the charset source. This, in addition with an "empty" default charset, helps avoid the use of the default latin1 charset unless absolutely necessary.
This commit is contained in:
@ -235,17 +235,18 @@ uint8_t get_charset(SERVER_REF* servers)
|
||||
|
||||
for (SERVER_REF* s = servers; s; s = s->next)
|
||||
{
|
||||
if (server_ref_is_active(s))
|
||||
if (server_ref_is_active(s) && s->server->charset)
|
||||
{
|
||||
// The reference is active and we've queried the charset it uses
|
||||
if (s->server->is_master())
|
||||
{
|
||||
// Master found, stop searching
|
||||
rval = s->server->charset;
|
||||
break;
|
||||
}
|
||||
else if (s->server->is_slave() || (s->server->is_running() && rval == 0))
|
||||
else if (s->server->is_slave() || rval == 0)
|
||||
{
|
||||
// Slaves precede Running servers
|
||||
// Slaves precede Running servers and server that are Down but whose charset is known
|
||||
rval = s->server->charset;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user