blr_send_custom_error with errno and state

blr_send_custom_error with errno and state
This commit is contained in:
MassimilianoPinto
2015-09-30 15:59:48 +02:00
parent 680589ed46
commit e043d204b4
3 changed files with 20 additions and 11 deletions

View File

@ -552,7 +552,7 @@ extern void blr_close_binlog(ROUTER_INSTANCE *, BLFILE *);
extern unsigned long blr_file_size(BLFILE *);
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
extern int blr_ping(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
extern int blr_send_custom_error(DCB *, int, int, char *);
extern int blr_send_custom_error(DCB *, int, int, char *, char *, unsigned int);
extern int blr_file_next_exists(ROUTER_INSTANCE *, ROUTER_SLAVE *);
uint32_t extract_field(uint8_t *src, int bits);
#endif

View File

@ -1604,17 +1604,18 @@ GWBUF *ret;
* mysql_send_custom_error
*
* Send a MySQL protocol Generic ERR message, to the dcb
* Note the errno and state are still fixed now
*
* @param dcb Owner_Dcb Control Block for the connection to which the OK is sent
* @param dcb Owner_Dcb Control Block for the connection to which the error message is sent
* @param packet_number
* @param in_affected_rows
* @param msg
* @param msg Message to send
* @param statemsg MySQL State message
* @param errcode MySQL Error code
* @return 1 Non-zero if data was sent
*
*/
int
blr_send_custom_error(DCB *dcb, int packet_number, int affected_rows, char *msg)
blr_send_custom_error(DCB *dcb, int packet_number, int affected_rows, char *msg, char *statemsg, unsigned int errcode)
{
uint8_t *outbuf = NULL;
uint32_t mysql_payload_size = 0;
@ -1627,10 +1628,17 @@ unsigned int mysql_errno = 0;
const char *mysql_error_msg = NULL;
const char *mysql_state = NULL;
GWBUF *errbuf = NULL;
mysql_errno = 1064;
mysql_error_msg = "An errorr occurred ...";
mysql_state = "42000";
if (errcode == 0)
mysql_errno = 1064;
else
mysql_errno = errcode;
mysql_error_msg = "An errorr occurred ...";
if (statemsg == NULL)
mysql_state = "42000";
else
mysql_state = statemsg;
field_count = 0xff;
gw_mysql_set_byte2(mysql_err, mysql_errno);

View File

@ -215,7 +215,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
if (router->mariadb10_compat && !slave->mariadb10_compat) {
slave->state = BLRS_ERRORED;
blr_send_custom_error(slave->dcb, 1, 0,
"MariaDB 10 Slave is required for Slave registration");
"MariaDB 10 Slave is required for Slave registration", "42000", 1064);
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
@ -260,7 +260,8 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
break;
default:
blr_send_custom_error(slave->dcb, 1, 0,
"You have an error in your SQL syntax; Check the syntax the MaxScale binlog router accepts.");
"You have an error in your SQL syntax; Check the syntax the MaxScale binlog router accepts.",
"42000", 1064);
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
"Unexpected MySQL Command (%d) received from slave",