modutil.c:modutil_reply_routing_error: Removed GWBUF type flag setting and added flags argument to function prototype so that the caller can set necessary flags and they are then copied to GWBUF which is first created in modutil_reply_rounting_error.

This commit is contained in:
VilhoRaatikka 2015-01-17 23:07:06 +02:00
parent bbbdc28440
commit f5d8e2366a
3 changed files with 23 additions and 19 deletions

View File

@ -39,10 +39,11 @@ extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
static void modutil_reply_routing_error(
DCB* backend_dcb,
int error,
char* state,
char* errstr);
DCB* backend_dcb,
int error,
char* state,
char* errstr,
uint32_t flags);
/**
@ -604,13 +605,15 @@ modutil_count_signal_packets(GWBUF *reply, int use_ok, int n_found)
*
* @param backend_dcb DCB where event is added
* @param errstr Plain-text string error
* @param flags GWBUF type flags
*/
void modutil_reply_parse_error(
DCB* backend_dcb,
char* errstr)
DCB* backend_dcb,
char* errstr,
uint32_t flags)
{
CHK_DCB(backend_dcb);
modutil_reply_routing_error(backend_dcb, 1064, "42000", errstr);
modutil_reply_routing_error(backend_dcb, 1064, "42000", errstr, flags);
}
/**
@ -622,12 +625,14 @@ void modutil_reply_parse_error(
* @param error SQL error number
* @param state SQL state
* @param errstr Plain-text string error
* @param flags GWBUF type flags
*/
static void modutil_reply_routing_error(
DCB* backend_dcb,
int error,
char* state,
char* errstr)
DCB* backend_dcb,
int error,
char* state,
char* errstr,
uint32_t flags)
{
GWBUF* buf;
CHK_DCB(backend_dcb);
@ -642,10 +647,8 @@ static void modutil_reply_routing_error(
"Error : Creating buffer for error message failed.")));
return;
}
/** Set flags that help router to identify session commands reply */
gwbuf_set_type(buf, GWBUF_TYPE_MYSQL);
gwbuf_set_type(buf, GWBUF_TYPE_SESCMD_RESPONSE);
gwbuf_set_type(buf, GWBUF_TYPE_RESPONSE_END);
/** Set flags that help router to process reply correctly */
gwbuf_set_type(buf, flags);
/** Create an incoming event for backend DCB */
poll_add_epollin_event_to_dcb(backend_dcb, buf);
return;

View File

@ -50,7 +50,7 @@ extern int modutil_send_mysql_err_packet(DCB *, int, int, int, const char *, con
GWBUF* modutil_get_next_MySQL_packet(GWBUF** p_readbuf);
GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf);
int modutil_MySQL_query_len(GWBUF* buf, int* nbytes_missing);
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr);
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr, uint32_t flags);
GWBUF *modutil_create_mysql_err_msg(
int packet_number,

View File

@ -2178,7 +2178,7 @@ static bool route_single_stmt(
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Can't route %s:%s:\"%s\". SELECT with "
"Error : Can't route %s:%s:\"%s\". SELECT with "
"session data modification is not supported "
"if configuration parameter "
"use_sql_variables_in=all .",
@ -2198,12 +2198,13 @@ static bool route_single_stmt(
}
if (bref != NULL && BREF_IS_IN_USE(bref))
{
{
modutil_reply_parse_error(
bref->bref_dcb,
strdup("Routing query to backend failed. "
"See the error log for further "
"details."));
"details."),
0);
}
if (query_str) free (query_str);
if (qtype_str) free(qtype_str);