MySQL connect: charset flag is stored
MySQL connect: charset flag is stored and passed to backend
This commit is contained in:
@ -281,6 +281,7 @@ typedef struct {
|
|||||||
* created or received */
|
* created or received */
|
||||||
unsigned long tid; /*< MySQL Thread ID, in
|
unsigned long tid; /*< MySQL Thread ID, in
|
||||||
* handshake */
|
* handshake */
|
||||||
|
unsigned int charset; /*< MySQL character set at connect time */
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
skygw_chk_t protocol_chk_tail;
|
skygw_chk_t protocol_chk_tail;
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
* 12/09/2013 Massimiliano Pinto Added checks in gw_read_backend_event() for gw_read_backend_handshake
|
* 12/09/2013 Massimiliano Pinto Added checks in gw_read_backend_event() for gw_read_backend_handshake
|
||||||
* 27/09/2013 Massimiliano Pinto Changed in gw_read_backend_event the check for dcb_read(), now is if rc < 0
|
* 27/09/2013 Massimiliano Pinto Changed in gw_read_backend_event the check for dcb_read(), now is if rc < 0
|
||||||
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
|
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
|
||||||
|
* 10/11/2014 Massimiliano Pinto Client charset is passed to backend
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <modinfo.h>
|
#include <modinfo.h>
|
||||||
@ -912,6 +913,9 @@ static int gw_create_backend_connection(
|
|||||||
/** Copy client flags to backend protocol */
|
/** Copy client flags to backend protocol */
|
||||||
protocol->client_capabilities =
|
protocol->client_capabilities =
|
||||||
((MySQLProtocol *)(backend_dcb->session->client->protocol))->client_capabilities;
|
((MySQLProtocol *)(backend_dcb->session->client->protocol))->client_capabilities;
|
||||||
|
/** Copy client charset to backend protocol */
|
||||||
|
protocol->charset =
|
||||||
|
((MySQLProtocol *)(backend_dcb->session->client->protocol))->charset;
|
||||||
|
|
||||||
/*< if succeed, fd > 0, -1 otherwise */
|
/*< if succeed, fd > 0, -1 otherwise */
|
||||||
rv = gw_do_connect_to_backend(server->name, server->port, &fd);
|
rv = gw_do_connect_to_backend(server->name, server->port, &fd);
|
||||||
@ -1514,4 +1518,4 @@ static bool sescmd_response_complete(
|
|||||||
succp = false;
|
succp = false;
|
||||||
}
|
}
|
||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
* 07/05/2014 Massimiliano Pinto Added: specific version string in server handshake
|
* 07/05/2014 Massimiliano Pinto Added: specific version string in server handshake
|
||||||
* 09/09/2014 Massimiliano Pinto Added: 777 permission for socket path
|
* 09/09/2014 Massimiliano Pinto Added: 777 permission for socket path
|
||||||
* 13/10/2014 Massimiliano Pinto Added: dbname authentication check
|
* 13/10/2014 Massimiliano Pinto Added: dbname authentication check
|
||||||
|
* 10/11/2014 Massimiliano Pinto Added: client charset added to protocol struct
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <skygw_utils.h>
|
#include <skygw_utils.h>
|
||||||
@ -444,6 +445,9 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get charset */
|
||||||
|
memcpy(&protocol->charset, client_auth_packet + 4 + 4 + 4, sizeof (int));
|
||||||
|
|
||||||
/* get the auth token len */
|
/* get the auth token len */
|
||||||
memcpy(&auth_token_len,
|
memcpy(&auth_token_len,
|
||||||
client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1,
|
client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1,
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
* x.y.z.%, x.y.%.%, x.%.%.%
|
* x.y.z.%, x.y.%.%, x.%.%.%
|
||||||
* 03/10/2014 Massimiliano Pinto Added netmask for wildcard in IPv4 hosts.
|
* 03/10/2014 Massimiliano Pinto Added netmask for wildcard in IPv4 hosts.
|
||||||
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
|
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
|
||||||
|
* 10/11/2014 Massimiliano Pinto Charset at connect is passed to backend during authentication
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -563,6 +564,7 @@ int gw_send_authentication_to_backend(
|
|||||||
|
|
||||||
char *curr_db = NULL;
|
char *curr_db = NULL;
|
||||||
uint8_t *curr_passwd = NULL;
|
uint8_t *curr_passwd = NULL;
|
||||||
|
unsigned int charset;
|
||||||
|
|
||||||
if (strlen(dbname))
|
if (strlen(dbname))
|
||||||
curr_db = dbname;
|
curr_db = dbname;
|
||||||
@ -574,7 +576,10 @@ int gw_send_authentication_to_backend(
|
|||||||
final_capabilities = gw_mysql_get_byte4((uint8_t *)&server_capabilities);
|
final_capabilities = gw_mysql_get_byte4((uint8_t *)&server_capabilities);
|
||||||
|
|
||||||
/** Copy client's flags to backend */
|
/** Copy client's flags to backend */
|
||||||
final_capabilities |= conn->client_capabilities;;
|
final_capabilities |= conn->client_capabilities;
|
||||||
|
|
||||||
|
/* get charset the client sent and use it for connection auth */
|
||||||
|
charset = conn->charset;
|
||||||
|
|
||||||
if (compress) {
|
if (compress) {
|
||||||
final_capabilities |= GW_MYSQL_CAPABILITIES_COMPRESS;
|
final_capabilities |= GW_MYSQL_CAPABILITIES_COMPRESS;
|
||||||
@ -668,7 +673,7 @@ int gw_send_authentication_to_backend(
|
|||||||
|
|
||||||
// set the charset
|
// set the charset
|
||||||
payload += 4;
|
payload += 4;
|
||||||
*payload = '\x08';
|
*payload = charset;
|
||||||
|
|
||||||
payload++;
|
payload++;
|
||||||
|
|
||||||
@ -1084,6 +1089,7 @@ int gw_send_change_user_to_backend(
|
|||||||
|
|
||||||
char *curr_db = NULL;
|
char *curr_db = NULL;
|
||||||
uint8_t *curr_passwd = NULL;
|
uint8_t *curr_passwd = NULL;
|
||||||
|
unsigned int charset;
|
||||||
|
|
||||||
if (strlen(dbname))
|
if (strlen(dbname))
|
||||||
curr_db = dbname;
|
curr_db = dbname;
|
||||||
@ -1096,7 +1102,10 @@ int gw_send_change_user_to_backend(
|
|||||||
final_capabilities = gw_mysql_get_byte4((uint8_t *)&server_capabilities);
|
final_capabilities = gw_mysql_get_byte4((uint8_t *)&server_capabilities);
|
||||||
|
|
||||||
/** Copy client's flags to backend */
|
/** Copy client's flags to backend */
|
||||||
final_capabilities |= conn->client_capabilities;;
|
final_capabilities |= conn->client_capabilities;
|
||||||
|
|
||||||
|
/* get charset the client sent and use it for connection auth */
|
||||||
|
charset = conn->charset;
|
||||||
|
|
||||||
if (compress) {
|
if (compress) {
|
||||||
final_capabilities |= GW_MYSQL_CAPABILITIES_COMPRESS;
|
final_capabilities |= GW_MYSQL_CAPABILITIES_COMPRESS;
|
||||||
@ -1222,7 +1231,7 @@ int gw_send_change_user_to_backend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the charset, 2 bytes!!!!
|
// set the charset, 2 bytes!!!!
|
||||||
*payload = '\x08';
|
*payload = charset;
|
||||||
payload++;
|
payload++;
|
||||||
*payload = '\x00';
|
*payload = '\x00';
|
||||||
payload++;
|
payload++;
|
||||||
|
Reference in New Issue
Block a user