MXS-2490: Send error to client on unknown PS handle
If a client requests an unknown binary protocol prepared statement handle, a custom error shows the actual ID used instead of the "empty" ID of 0 that the backend sends.
This commit is contained in:
@ -202,7 +202,12 @@ bool RWSplitSession::route_single_stmt(GWBUF* querybuf)
|
|||||||
|
|
||||||
SRWBackend target;
|
SRWBackend target;
|
||||||
|
|
||||||
if (TARGET_IS_ALL(route_target))
|
if (command == MXS_COM_STMT_EXECUTE && stmt_id == 0)
|
||||||
|
{
|
||||||
|
// Unknown prepared statement ID
|
||||||
|
succp = send_unknown_ps_error(extract_binary_ps_id(querybuf));
|
||||||
|
}
|
||||||
|
else if (TARGET_IS_ALL(route_target))
|
||||||
{
|
{
|
||||||
succp = handle_target_is_all(route_target, querybuf, command, qtype);
|
succp = handle_target_is_all(route_target, querybuf, command, qtype);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1221,3 +1221,11 @@ bool RWSplitSession::supports_hint(HINT_TYPE hint_type) const
|
|||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RWSplitSession::send_unknown_ps_error(uint32_t stmt_id)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Unknown prepared statement handler (" << stmt_id << ") given to MaxScale";
|
||||||
|
GWBUF* err = modutil_create_mysql_err_msg(1, 0, ER_UNKNOWN_STMT_HANDLER, "HY000", ss.str().c_str());
|
||||||
|
return m_client->func.write(m_client, err);
|
||||||
|
}
|
||||||
|
|||||||
@ -214,6 +214,9 @@ private:
|
|||||||
mxs::SRWBackend& old_master,
|
mxs::SRWBackend& old_master,
|
||||||
mxs::SRWBackend& curr_master);
|
mxs::SRWBackend& curr_master);
|
||||||
|
|
||||||
|
// Send unknown prepared statement ID error to client
|
||||||
|
bool send_unknown_ps_error(uint32_t stmt_id);
|
||||||
|
|
||||||
GWBUF* handle_causal_read_reply(GWBUF* writebuf, mxs::SRWBackend& backend);
|
GWBUF* handle_causal_read_reply(GWBUF* writebuf, mxs::SRWBackend& backend);
|
||||||
GWBUF* add_prefix_wait_gtid(SERVER* server, GWBUF* origin);
|
GWBUF* add_prefix_wait_gtid(SERVER* server, GWBUF* origin);
|
||||||
void correct_packet_sequence(GWBUF* buffer);
|
void correct_packet_sequence(GWBUF* buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user