Skip to content

Commit

Permalink
wl#10799 integrate MySQL Router into MySQL Server repository
Browse files Browse the repository at this point in the history
    Post-push fix: Replacing usage of protobuf with protobuf-lite
    in the MySQLRouter to avoid issue: protocolbuffers/protobuf#4126
    when WITH_PROTOBUF=system (3.0+) is used

Reviewed-by: Lukasz Kotula <[email protected]>
Reviewed-by: Tor Didriksen <[email protected]>
RB: #20341
  • Loading branch information
Andrzej Religa committed Aug 20, 2018
1 parent 3c2869a commit 2c5ab46
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions router/src/routing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

IF (NOT PROTOBUF_LITE_LIBRARY)
MESSAGE(FATAL_ERROR "Routing plugin requires protobuf-lite library")
ENDIF()

SET(ROUTING_SOURCE_FILES_X_PROTOCOL
${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc
)
Expand Down Expand Up @@ -55,7 +59,7 @@ SET(include_dirs

SET(system_include_dirs
${PROTOBUF_INCLUDE_DIR}
${MYSQLX_GENERATE_DIR}/protobuf
${MYSQLX_GENERATE_DIR}/protobuf_lite
)

# link_directories(${PROJECT_BINARY_DIR}/ext/protobuf/protobuf-3.0.0/cmake/)
Expand All @@ -68,7 +72,7 @@ add_harness_plugin(routing
TARGET_INCLUDE_DIRECTORIES(routing PRIVATE ${include_dirs})
TARGET_INCLUDE_DIRECTORIES(routing SYSTEM PRIVATE ${system_include_dirs})

TARGET_LINK_LIBRARIES(routing PRIVATE mysqlxmessages ${PROTOBUF_LIBRARY})
TARGET_LINK_LIBRARIES(routing PRIVATE mysqlxmessages_lite ${PROTOBUF_LITE_LIBRARY})

IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
TARGET_LINK_LIBRARIES(routing PRIVATE -lnsl PRIVATE -lsocket)
Expand Down
4 changes: 2 additions & 2 deletions router/src/routing/src/protocol/x_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <algorithm>
#include <cassert>

using ProtobufMessage = google::protobuf::Message;
using ProtobufMessage = google::protobuf::MessageLite;
IMPORT_LOG_FUNCTIONS()

constexpr size_t kMessageHeaderSize = 5;
Expand Down Expand Up @@ -75,7 +75,7 @@ static bool send_message(const std::string &log_prefix, int destination,

static bool message_valid(const void *message_buffer, const int8_t message_type,
const uint32_t message_size) {
std::unique_ptr<google::protobuf::Message> msg;
std::unique_ptr<google::protobuf::MessageLite> msg;

assert(message_type == Mysqlx::ClientMessages::SESS_AUTHENTICATE_START ||
message_type == Mysqlx::ClientMessages::CON_CAPABILITIES_GET ||
Expand Down
4 changes: 2 additions & 2 deletions router/src/routing/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ INCLUDE_DIRECTORIES(

INCLUDE_DIRECTORIES(SYSTEM
${PROTOBUF_INCLUDE_DIR}
${MYSQLX_GENERATE_DIR}/protobuf
${MYSQLX_GENERATE_DIR}/protobuf_lite
)

# link_directories(${PROJECT_BINARY_DIR}/ext/protobuf/protobuf-3.0.0/cmake/)
ADD_LIBRARY(routing_tests STATIC ${ROUTING_SOURCE_FILES})
TARGET_LINK_LIBRARIES(routing_tests routertest_helpers router_lib
metadata_cache_static mysql_protocol_static
mysqlxmessages ${PROTOBUF_LIBRARY})
mysqlxmessages_lite ${PROTOBUF_LITE_LIBRARY})
TARGET_COMPILE_DEFINITIONS(routing_tests PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)
TARGET_COMPILE_DEFINITIONS(routing_tests PRIVATE -Dmysql_protocol_DEFINE_STATIC=1)
TARGET_INCLUDE_DIRECTORIES(routing PRIVATE ${include_dirs})
Expand Down
2 changes: 1 addition & 1 deletion router/src/routing/tests/test_x_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class XProtocolTest : public ::testing::Test {

void serialize_protobuf_msg_to_buffer(RoutingProtocolBuffer &buffer,
size_t &buffer_offset,
google::protobuf::Message &msg,
google::protobuf::MessageLite &msg,
unsigned char type) {
size_t msg_size = msg.ByteSize();
google::protobuf::io::CodedOutputStream::WriteLittleEndian32ToArray(
Expand Down

0 comments on commit 2c5ab46

Please sign in to comment.