Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use the backend server charset
The default character set should be copied from the server so that
MaxScale appears to be the same. This fixes problems where utf8mb4
couldn't be taken into use because MaxScale would always send latin1 as
the server charset.
  • Loading branch information
markus456 committed Oct 19, 2016
1 parent b50e794 commit f1acc1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/core/dbusers.c
Expand Up @@ -2612,6 +2612,11 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
return my_errno != ER_ACCESS_DENIED_ERROR;
}

/** Copy the server charset */
MY_CHARSET_INFO cs_info;
mysql_get_character_set_info(mysql, &cs_info);
server->charset = cs_info.number;

if (server->server_string == NULL)
{
const char *server_string = mysql_get_server_info(mysql);
Expand Down
4 changes: 4 additions & 0 deletions server/core/server.c
Expand Up @@ -44,6 +44,9 @@
#include <log_manager.h>
#include <gw_ssl.h>

/** The latin1 charset */
#define SERVER_DEFAULT_CHARSET 0x08

static SPINLOCK server_spin = SPINLOCK_INIT;
static SERVER *allServers = NULL;

Expand Down Expand Up @@ -89,6 +92,7 @@ server_alloc(char *servname, char *protocol, unsigned short port)
server->persistmaxtime = 0;
server->persistpoolmax = 0;
server->slave_configured = false;
server->charset = SERVER_DEFAULT_CHARSET;
spinlock_init(&server->persistlock);

spinlock_acquire(&server_spin);
Expand Down
1 change: 1 addition & 0 deletions server/include/server.h
Expand Up @@ -109,6 +109,7 @@ typedef struct server
long persistpoolmax; /**< Maximum size of persistent connections pool */
long persistmaxtime; /**< Maximum number of seconds connection can live */
int persistmax; /**< Maximum pool size actually achieved since startup */
uint8_t charset; /**< Default server character set */
#if defined(SS_DEBUG)
skygw_chk_t server_chk_tail;
#endif
Expand Down
5 changes: 5 additions & 0 deletions server/modules/protocol/mysql_client.c
Expand Up @@ -277,6 +277,11 @@ int MySQLSendHandshake(DCB* dcb)
int len_version_string = 0;
int id_num;

if (dcb->service->dbref)
{
mysql_server_language = dcb->service->dbref->server->charset;
}

MySQLProtocol *protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
GWBUF *buf;

Expand Down

0 comments on commit f1acc1f

Please sign in to comment.