From 24fc82e160b0d9ce7143a92afca70a7c3f086d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Apr 2019 13:14:45 +0300 Subject: [PATCH] Move large query processing inside RWBackend The knowledge of which function to call can be internal to RWBackend. This make the use of the class easier as one can simply write to the backend. --- include/maxscale/protocol/rwbackend.hh | 16 +--------------- server/modules/protocol/MySQL/rwbackend.cc | 9 +++++++++ .../routing/readwritesplit/rwsplit_route_stmt.cc | 4 +--- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/include/maxscale/protocol/rwbackend.hh b/include/maxscale/protocol/rwbackend.hh index fd57f9538..6bf3ae6ea 100644 --- a/include/maxscale/protocol/rwbackend.hh +++ b/include/maxscale/protocol/rwbackend.hh @@ -115,21 +115,6 @@ public: */ bool write(GWBUF* buffer, response_type type = EXPECT_RESPONSE); - /** - * Continue a previously started write - * - * This should only be used when RWBackend::write has been called to start - * a new query. - * - * @param buffer Buffer to write - * - * @return True if writing was successful - */ - bool continue_write(GWBUF* buffer) - { - return mxs::Backend::write(buffer, Backend::NO_RESPONSE); - } - void close(close_type type = CLOSE_NORMAL); // For COM_STMT_FETCH processing @@ -181,6 +166,7 @@ private: bool m_local_infile_requested; /**< Whether a LOCAL INFILE was requested */ ResponseStat m_response_stat; uint64_t m_num_coldefs = 0; + bool m_large_query = false; inline bool is_opening_cursor() const { diff --git a/server/modules/protocol/MySQL/rwbackend.cc b/server/modules/protocol/MySQL/rwbackend.cc index 0fcff826a..738b5a93b 100644 --- a/server/modules/protocol/MySQL/rwbackend.cc +++ b/server/modules/protocol/MySQL/rwbackend.cc @@ -75,6 +75,15 @@ uint32_t RWBackend::get_ps_handle(uint32_t id) const bool RWBackend::write(GWBUF* buffer, response_type type) { + uint32_t len = mxs_mysql_get_packet_len(buffer); + bool was_large_query = m_large_query; + m_large_query = len == MYSQL_PACKET_LENGTH_MAX; + + if (was_large_query) + { + return mxs::Backend::write(buffer, Backend::NO_RESPONSE); + } + if (type == mxs::Backend::EXPECT_RESPONSE) { /** The server will reply to this command */ diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 217f85b9e..7bd1dbd32 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -1176,9 +1176,7 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, RWBackend* target, bool * will do the replacement of PS IDs which must not be done if we are * continuing an ongoing query. */ - bool success = !m_qc.large_query() ? - target->write(send_buf, response) : - target->continue_write(send_buf); + bool success = target->write(send_buf, response); if (success) {