blr_send_custom_error with errno and state
blr_send_custom_error with errno and state
This commit is contained in:
@ -552,7 +552,7 @@ extern void blr_close_binlog(ROUTER_INSTANCE *, BLFILE *);
|
|||||||
extern unsigned long blr_file_size(BLFILE *);
|
extern unsigned long blr_file_size(BLFILE *);
|
||||||
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
||||||
extern int blr_ping(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 *);
|
extern int blr_file_next_exists(ROUTER_INSTANCE *, ROUTER_SLAVE *);
|
||||||
uint32_t extract_field(uint8_t *src, int bits);
|
uint32_t extract_field(uint8_t *src, int bits);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1604,17 +1604,18 @@ GWBUF *ret;
|
|||||||
* mysql_send_custom_error
|
* mysql_send_custom_error
|
||||||
*
|
*
|
||||||
* Send a MySQL protocol Generic ERR message, to the dcb
|
* 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 packet_number
|
||||||
* @param in_affected_rows
|
* @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
|
* @return 1 Non-zero if data was sent
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
uint8_t *outbuf = NULL;
|
||||||
uint32_t mysql_payload_size = 0;
|
uint32_t mysql_payload_size = 0;
|
||||||
@ -1627,10 +1628,17 @@ unsigned int mysql_errno = 0;
|
|||||||
const char *mysql_error_msg = NULL;
|
const char *mysql_error_msg = NULL;
|
||||||
const char *mysql_state = NULL;
|
const char *mysql_state = NULL;
|
||||||
GWBUF *errbuf = NULL;
|
GWBUF *errbuf = NULL;
|
||||||
|
|
||||||
mysql_errno = 1064;
|
if (errcode == 0)
|
||||||
mysql_error_msg = "An errorr occurred ...";
|
mysql_errno = 1064;
|
||||||
mysql_state = "42000";
|
else
|
||||||
|
mysql_errno = errcode;
|
||||||
|
|
||||||
|
mysql_error_msg = "An errorr occurred ...";
|
||||||
|
if (statemsg == NULL)
|
||||||
|
mysql_state = "42000";
|
||||||
|
else
|
||||||
|
mysql_state = statemsg;
|
||||||
|
|
||||||
field_count = 0xff;
|
field_count = 0xff;
|
||||||
gw_mysql_set_byte2(mysql_err, mysql_errno);
|
gw_mysql_set_byte2(mysql_err, mysql_errno);
|
||||||
|
@ -215,7 +215,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
if (router->mariadb10_compat && !slave->mariadb10_compat) {
|
if (router->mariadb10_compat && !slave->mariadb10_compat) {
|
||||||
slave->state = BLRS_ERRORED;
|
slave->state = BLRS_ERRORED;
|
||||||
blr_send_custom_error(slave->dcb, 1, 0,
|
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(
|
LOGIF(LE, (skygw_log_write(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
@ -260,7 +260,8 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blr_send_custom_error(slave->dcb, 1, 0,
|
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(
|
LOGIF(LE, (skygw_log_write(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Unexpected MySQL Command (%d) received from slave",
|
"Unexpected MySQL Command (%d) received from slave",
|
||||||
|
Reference in New Issue
Block a user