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:
parent
f94355770f
commit
96a477ec89
@ -202,7 +202,12 @@ bool RWSplitSession::route_single_stmt(GWBUF* querybuf)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1221,3 +1221,11 @@ bool RWSplitSession::supports_hint(HINT_TYPE hint_type) const
|
||||
|
||||
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& 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* add_prefix_wait_gtid(SERVER* server, GWBUF* origin);
|
||||
void correct_packet_sequence(GWBUF* buffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user