PBS-28 feature: Merge code from the MySQL Protocol Prototype onto the main source tree#156
Merged
percona-ysorokin merged 108 commits intoJun 27, 2026
Conversation
The patch includes dependent WLs: wl#11127 Packaging Router as part of Server Source Tree wl#11666 Unify MySQL Router cmake scripts with MySQL-server's wl#11129 Allow building Router as part of server source-tree Reviewed-by: Tor Didriksen <tor.didriksen@oracle.com> Revieved-by: Terje Rosten <terje.rosten@oracle.com> Reviewed-by: Lars Tangvald <lars.tangvald@oracle.com> Reviewed-by: Piotr Obrzut <piotr.obrzut@oracle.com> Reviewed-by: Jan Kneschke <jan.kneschke@oracle.com>
The patch includes dependent WLs: wl#11127 Packaging Router as part of Server Source Tree wl#11666 Unify MySQL Router cmake scripts with MySQL-server's wl#11129 Allow building Router as part of server source-tree Reviewed-by: Tor Didriksen <tor.didriksen@oracle.com> Revieved-by: Terje Rosten <terje.rosten@oracle.com> Reviewed-by: Lars Tangvald <lars.tangvald@oracle.com> Reviewed-by: Piotr Obrzut <piotr.obrzut@oracle.com> Reviewed-by: Jan Kneschke <jan.kneschke@oracle.com>
Fix all instances of -Wextra-semi warnings (mostly using Clang's Fix-It function), so that we can enable the warning. Change-Id: I0c64be78b276efb545bae259b08d7278fa5e64e4
Fix all instances of -Wmissing-noreturn (for Clang) and -Wsuggest-attribute=noreturn (for GCC), so that we can enable those warnings. Change-Id: I0b26870c5e68587ca9c0ee3c116108abb1c3c2bb
…noclose]" This reverts commit 30c9c892a662129195fe4b7069154592b96880e4.
Enable -Wdeprecated when building with Clang. This compiler option warns about using deprecated C++ features. Fix warnings reported by -Wdeprecated. Change-Id: If1a1c476516d67008cd2b8d883bd754ca60aa303
When Router receives an invalid packet during the handshake phase of the connection, it will throw an exception. However, this exception was not caught anywhere, causing Router process to terminate. This patch fixes this - now the Router will deal with this situation like it deals with all other handshake-phase errors (it will close the client connection and increment the error counter on the user side, and hijack the handshake on the Server side and complete it so the Server does not increment its error counter with respect to Router) RB: 20797 Reviewed by: Andrzej Religa
include <stdexcept> for files using std::runtime_error. Change-Id: I44c7ba0f929a18ee4cc21e7f731010558eb68183
…INDOWS
* fixed case libnames
* fixed compile-error on windows due to wrong type for socket
error: non-constant-expression cannot be narrowed from type 'int' to
'SOCKET' (aka 'unsigned long long') in initializer list
[-Wc++11-narrowing]
{sock, POLLOUT, 0},
* fixed wrong dllexports
* made message-check more resilent to localisation
* error-msg may be localiced
* error-msg may change with different CRT versions
* fixed const char * comparison with ==
* fixed clang-warning for RVO/std::move()
* explicitly define copy-constructor if destructor is declared
* fixes clang-7 warning:
definition of implicit copy assignment operator for
'RandomGeneratorInterface' is deprecated because it has a user-declared
destructor [-Wdeprecated]
* fixed format warning for DWORDs
* fixed error-msg handling on windows
err_code was passed to get_last_error(), but then ignore. Instead
GetLastError() was called all the time which may belong to another
intemediate function-call that set the errno.
* removed unused code
* removed unused lambda captures
warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
* removed unused variable
Problem ======= The 'mysql_protocol' library of the router uses handwritten export-header to export symbols into DLLs on windows. cmake provides a GenerateExportHeader() function which: - generates export header - allows to control the visibility of symbols on non-windows platforms too. Change ====== - use cmake's GenerateExportHeadera - replace MYSQL_PROTOCOL_API with MYSQL_PROTOCOL_EXPORT RB: 24637
Problem ======= The BasePacket class from MySQL Router's 'mysql_protocol' library currently inherits from std::vector<>. As the Packet classes are dll-exported it later leads to linker errors when the std::vector methods are exported into both the mysql_protocol class and the msvcrt. Furthermore, there is no need for using inheritance here. Change ====== - instead inheriting from std::vector, just use the vector as private member. - only include headers that are needed. RB: 24638
Suppress the C4275 warnings at the specific points in the source where they are currently generated when building on Windows. RB: 25043
Change ====== Classic Protocol implementation - POD types - encoding - decoding RB: 25178
Change ====== - accept TLS connections on the client side if requested by config: client_ssl_mode != DISABLE|PASSTHROUGH - open TLS connection to server if requested by config server_ssl_mode != DISABLED Track protocol handshake and the switch to TLS (and possible switch to PLAIN). splice client and server connections. RB: 25178
Problem ======= The router's mysql_protocol/src/base_packet.cc based classes are superseeded by the new classic_protocol encoder/decoder. mysql_server_mock is the last user of the old classes. Change ====== - removed old base_packet.cc based codec and its tests - removed mysql_protocol shared library RB: 25472
Update all copyright headers in 8.0 which were not already updated in 5.7, to 2021 and to the current copyright format. This patch was generated by a script. RB#25757
Issue ===== SessionTracker::State allows the server to announce that the last command changed the sessions state. It contains a boolean value "1". Our Codec<> treated that field as VarString, instead of a fixed-size-one-byte-string. Change ====== - treat SessionTracker::State as single byte RB: 26112
Issue ===== the TransactionCharacteristics message contains a "characteristics" field which is exposed by the "statement()" method. Change ====== - renamed variable names to match the meaning of the data they contain. RB: 26113
Issue ===== The router's protocol codec is missing: - ColumnCount message - ListFields codec Clients like 'mysql' still use the deprecated COM_FIELD_LIST command which is different protocol flow than the COM_QUERY command. Change ====== - add client::ListFields - make ColumnCount its own message RB: 26114
Issue ===== The EOF codec already supports the SessionTracker decoding, but doesn't handle the case where the SessionTracker part is announced, but completely empty. Change ====== - added tests for Eof + Session Tracker RB: 26118
Issue ===== When a 3.23/4.0 client connects to the mock-server without specifying an initial schema, it closes the connection and reports: Error: missing nul-terminator The decoder for client::Greeting wrongly expects a nul-terminator. Issue ===== - use the shared-capabilities instead of the server-capabilities to check if the client is sending a schema-name - added tests to verify more combinations RB: 26119
Issue ===== Codec is missing for session_track::Gtid. Change ====== - added codec for session_track::Gtid - added tests for: - server::Ok with session_track::Gtid - session_track::Field with session_track::Gtid RB: 26123
Issue ===== The Codec's cmd_byte() method uses a hardcoded number which uniquely identifies a command. Currently, it is up to the developer to ensure the number is unique and not shared with other commands. Change ====== - use an 'enum class' to ensure uniqueness of the cmd-bytes RB: 26124
Issue ===== The server may send a SendFileRequest after a server::Query to ask the client to send the payload of a file. The codec lib is current missing server::SendFileRequest. Change ====== - add a server::SendFileRequest POD - add a codec for server::SendFileRequest - add tests for the codec and POD RB: 26125
Issue ===== Codec for the server's response to StmtPrepare is missing. Handle the cases: - full metadata - optional metadata Change ====== - added optional metadata support to pod type server::StmtPrepareOk - added codec for server::StmtPrepareOk RB: 26128
Issue ===== codec is missing a class for the response of the client::Statistics command. Change ====== - added POD type server::Statistics - added codec for server::Statistics - added tests RB: 26129
Issue ===== codec is missing for client::Reload. Change ====== - added POD type for client::Reload - added codec for client::Reload - added tests RB: 26130
Issue ===== codec classes are missing the handling of client::Kill. Change ====== - added POD type for client::Kill - added codec for client::Kill - added tests RB: 26131
Issue ===== codec for the clients response to the server's SendFileRequest is missing. Change ====== - added POD type for client::SendFile - added codec for client::SendFile - added tests RB: 26134
build fails with:
mysql_protocol/include/mysqlrouter/classic_protocol_codec_binary.h:277:11:
error: memcpy was not declared in this scope, and no declarations
were found by argument-dependent lookup at the point of instantiation
[-fpermissive]
277 | memcpy(&val, value_res->value().data(), byte_size);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change
------
- include cstring
Change-Id: I936946770ee38dd4358624902f095e9f6038d502
To determine if a message can be forwarded as is, the forwarder needs to know if the destination would encode the message in the same way as the source. Like, a COM_PING looks the same no matter what the negotiated capabilities look like. But a Eof packet depends on several capabilities. Change ------ Declare which protocol capabilities influence the protocol message's codec. Change-Id: I30b05c544ae45915e9c2c3fb5040d40e17362b73
build fails with:
mysql_protocol/include/mysqlrouter/classic_protocol_codec_binary.h:277:11:
error: memcpy was not declared in this scope, and no declarations
were found by argument-dependent lookup at the point of instantiation
[-fpermissive]
277 | memcpy(&val, value_res->value().data(), byte_size);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change
------
- include cstring
Change-Id: I936946770ee38dd4358624902f095e9f6038d502
Since the code-base is C++20, the "backported to C++17" stdx::endian can be replaced by C++20's std::endian. Change ====== - replace stdx::endian by std::endian Change-Id: Ie65673a1cf643e8da4335879b5ee863e75e1a626
Since the code-base is C++20, the "backported to C++17" stdx::span can be replaced by C++20's std::span. Change ====== - replaced stdx::span by std::span - removed mysql/harness/span.h Change-Id: I3dd1b02138b1243d752c1aa4963c89db9e160e29
stdx::expected's get_unexpected was part of the early proposals, but has been drop from the C++23 spec. Change ====== - replace res.get_unexpected() by stdx::unexpected(res.error()) Change-Id: Idadf1c6aab5f02e1a001c6fc82aa48a0000c435a
make_unexpected() was removed from std::expected in favour of the deduction guides which were introduced in C++17. Change ====== - replace uses of stdx::make_unexpected() by stdx::unexpected() - remove stdx::make_unexpected() Change-Id: Ic56ee31087c0310decfb6cca0c09a5009364fb3a
clang reports "set-but-unused-variables" after make stdx::expected trivially destructible. Change ====== - explicitly ignore the return-values Change-Id: Ia582da097b976db1c612dc78287709dd6e9ff47e
Update all copyright headers in 8.0 to 2024 and to the current copyright format. This patch was generated by a script. Approved-by: erlend.dahl@oracle.com Change-Id: Ibd796c000b48576d390be22874a8efea4dd6ae40
Change-Id: Iee0be9bc960b37fe361e13b0374ae77cb9464bd0
Approved by: Erlend Dahl <erlend.dahl@oracle.com>
Approved by: Erlend Dahl <erlend.dahl@oracle.com>
The router/ sub-directory is contains several 'clang-format on/off' directives that aren't needed anymore with clang-format >= 15 Change ====== - removed clang-format on/off directives that aren't needed anymore Change-Id: Ie2e98329783079324c354372ce66154a40b4c7fe
When connector-j connects without "&trackSessionState=true" to the read-write splitting port, updates may fail with: java.sql.SQLException: Buffer length is less than expected payload length. Background ========== The Ok-message for UPDATEs (or other commands) from the server may contain a human-readable part like "Rows update: 1 ...". When the client connects to the router without the CLIENT_SESSION_TRACK capability, the Ok-message is wrongly encoded if it contains that human-readable part. Change ====== - encoded the human-readable part as "variable length string" instead of "string-to-the-end-of-packet" if CLIENT_SESSION_TRACK is not set. Change-Id: I6160d8e4d6e600c57972b2c95d389c8b97706a9f
Update all copyright headers in 8.0 to 2025 and to the current copyright format. This patch was generated by a script. Approved-by: Marc Alff <marc.alff@oracle.com>
Patch for trunk, remaining community files Updated copyright headers to year 2026. Change-Id: I312cc5361e6269cb8acb6ff46bc33ff70388c7bd
Patch for 8.4 - fixed remaining code Updated copyright headers to year 2026. Change-Id: I5ff665e3cef5eb0a9782b42b8e373fc8ef55b2e7
Change-Id: Idf4439e2a18fc6faf1c250b2063b309eb270e1de
Patch for 8.0 Updated copyright headers to year 2026. Change-Id: Ibcc3475bb4c58d246d239986b668194f9f536aa1
Change-Id: I36cb7471e46288184e3d2ed6136cabd4ec0279f3
Change-Id: I29d5fa1d92da4e66c9a98180c3ba25a477bef0c5
percona-ysorokin
added a commit
to percona-ysorokin/percona-binlog-server
that referenced
this pull request
Jun 27, 2026
… main source tree (Percona-Lab#156) https://perconadev.atlassian.net/browse/PBS-28 Imported code from the MySQL Protocol Prototype server to the main code tree. At this iteration the code is added as a second binary 'minimysql_server' - top-level 'CMakeLists.txt' file updated correspondingly. To integrate headers from the 'extra/mysql_protocol/mysqlrouter' directory (those importer directly from the 'mysql-server' git repository) several auxiliary headers were created: * 'mysql/harness/net_ts/buffer.h' - creates aliases for various 'boost::asio' buffers. * 'mysql/harness/stdx/bit.h' - creates an alias for 'std::byteswap()'. * 'mysql/harness/stdx/expected.h' - creates an alias for 'std::expected'. * 'mysql/harness/stdx/type_traits.h' - creates aliases for 'std::is_scoped_enum' and 'std::type_identity'. * 'mysql/harness/stdx/ranges.h' - imported from 'mysql-server' with clang-format / clang-tidy fixes. This file could be just a set of aliases for 'std::ranges::enumerate_view' but unfortunately 'libstdc++' from 'clang-20' does not have this c++23 library feature implemented. A 'TODO' comment was created to change this when we switch to clang-23. * 'mysql/harness/stdx/flags.h' - imported from 'mysql-server' with clang-format / clang-tidy fixes. Modified '.clang-tidy' directives to ignore warnings coming from the headers located in the 'extra/mysql_protocol/mysqlrouter' as they were directly imported from the Oracle's 'mysql-server' repository and still generate a number of warnings. GitHub Actions script modified to instruct `run-clang-tidy` to use this config file (with the required header filters). GitHib Actions scripts extended with one more step that shows clang-tidy configuration.
ceb3f28 to
a6690b3
Compare
… main source tree (Percona-Lab#156) https://perconadev.atlassian.net/browse/PBS-28 Imported code from the MySQL Protocol Prototype server to the main code tree. At this iteration the code is added as a second binary 'minimysql_server' - top-level 'CMakeLists.txt' file updated correspondingly. To integrate headers from the 'extra/mysql_protocol/mysqlrouter' directory (those importer directly from the 'mysql-server' git repository) several auxiliary headers were created: * 'mysql/harness/net_ts/buffer.h' - creates aliases for various 'boost::asio' buffers. * 'mysql/harness/stdx/bit.h' - creates an alias for 'std::byteswap()'. * 'mysql/harness/stdx/expected.h' - creates an alias for 'std::expected'. * 'mysql/harness/stdx/type_traits.h' - creates aliases for 'std::is_scoped_enum' and 'std::type_identity'. * 'mysql/harness/stdx/ranges.h' - imported from 'mysql-server' with clang-format / clang-tidy fixes. This file could be just a set of aliases for 'std::ranges::enumerate_view' but unfortunately 'libstdc++' from 'clang-20' does not have this c++23 library feature implemented. A 'TODO' comment was created to change this when we switch to clang-23. * 'mysql/harness/stdx/flags.h' - imported from 'mysql-server' with clang-format / clang-tidy fixes. Added '.clang-format-ignore' file to ignore formatting of the headers located in the 'extra/mysql_protocol/mysqlrouter' directory as they were directly imported from the Oracle's 'mysql-server' repository and were formatted differently. Modified '.clang-tidy' directives to ignore warnings coming from the headers located in the 'extra/mysql_protocol/mysqlrouter' as they were directly imported from the Oracle's 'mysql-server' repository and still generate a number of warnings. GitHub Actions script modified to instruct `run-clang-tidy` to use this config file (with the required header filters). GitHib Actions scripts extended with one more step that shows clang-tidy configuration.
a6690b3 to
84bee8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.