MySQL 9.1.0
Source Code Documentation
x_connection.cc File Reference
#include "x_connection.h"
#include <exception>
#include <mutex>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/message_lite.h>
#include <mysqld_error.h>
#include <mysqlx.pb.h>
#include <mysqlx_connection.pb.h>
#include <mysqlx_datatypes.pb.h>
#include <mysqlx_error.h>
#include "hexify.h"
#include "mysql/harness/logging/logging.h"
#include "mysql/harness/stdx/expected.h"
#include "mysql/harness/tls_error.h"
#include "mysqlrouter/classic_protocol_wire.h"
#include "mysqlrouter/connection_pool_component.h"
#include "mysqlrouter/routing_component.h"
#include "mysqlrouter/ssl_mode.h"
#include "tls_content_type.h"

Functions

static void log_fatal_error_code (const char *msg, std::error_code ec)
 
static size_t message_byte_size (const google::protobuf::MessageLite &msg)
 
static constexpr uint8_t xproto_frame_msg_type (const Mysqlx::Error &)
 
static constexpr uint8_t xproto_frame_msg_type (const Mysqlx::Ok &)
 
static constexpr uint8_t xproto_frame_msg_type (const Mysqlx::Connection::Capabilities &)
 
static constexpr uint8_t xproto_frame_msg_type (const Mysqlx::Connection::CapabilitiesSet &)
 
static constexpr uint8_t xproto_frame_msg_type (const Mysqlx::Connection::CapabilitiesGet &)
 
static bool has_frame_header (XProtocolState &src_protocol)
 
static bool has_msg_type (XProtocolState &src_protocol)
 
static stdx::expected< std::pair< size_t, XProtocolState::FrameInfo >, std::error_code > decode_frame_header (const net::const_buffer &recv_buf)
 
static stdx::expected< size_t, std::error_code > ensure_frame_header (Channel &src_channel, XProtocolState &src_protocol)
 
static stdx::expected< void, std::error_code > ensure_has_msg_prefix (Channel &src_channel, XProtocolState &src_protocol)
 ensure recv-channel contains a frame+msg-header. More...
 
static stdx::expected< void, std::error_code > ensure_has_full_frame (Channel &src_channel, XProtocolState &src_protocol)
 
static void discard_current_msg (Channel &src_channel, XProtocolState &src_protocol)
 
template<class T >
static size_t xproto_frame_encode (const T &msg, std::vector< uint8_t > &out_buf)
 encode a message into a xproto frame. More...
 
static stdx::expected< bool, std::error_code > forward_frame_from_channel (Channel &src_channel, XProtocolState &src_protocol, Channel &dst_channel, XProtocolState &dst_protocol)
 
static stdx::expected< MysqlRoutingXConnection::ForwardResult, std::error_code > forward_frame (Channel &src_channel, XProtocolState &src_protocol, Channel &dst_channel, XProtocolState &dst_protocol)
 
static void set_capability_tls (Mysqlx::Connection::Capability *cap, bool value)
 
static stdx::expected< TlsClientContext *, std::error_code > get_dest_ssl_ctx (MySQLRoutingContext &ctx, const std::string &id)
 

Function Documentation

◆ decode_frame_header()

static stdx::expected< std::pair< size_t, XProtocolState::FrameInfo >, std::error_code > decode_frame_header ( const net::const_buffer recv_buf)
static

◆ discard_current_msg()

static void discard_current_msg ( Channel src_channel,
XProtocolState src_protocol 
)
static

◆ ensure_frame_header()

static stdx::expected< size_t, std::error_code > ensure_frame_header ( Channel src_channel,
XProtocolState src_protocol 
)
static

◆ ensure_has_full_frame()

static stdx::expected< void, std::error_code > ensure_has_full_frame ( Channel src_channel,
XProtocolState src_protocol 
)
static

◆ ensure_has_msg_prefix()

static stdx::expected< void, std::error_code > ensure_has_msg_prefix ( Channel src_channel,
XProtocolState src_protocol 
)
static

ensure recv-channel contains a frame+msg-header.

frame-header is: len msg-header is: msg-type

Return values
trueif src_protocol's msg_type() is valid()
false.error() will contain the reason for error.
  • std::errc::bad_message frame is too small.
  • TlsErrc::kWantRead for more data is needed.

◆ forward_frame()

static stdx::expected< MysqlRoutingXConnection::ForwardResult, std::error_code > forward_frame ( Channel src_channel,
XProtocolState src_protocol,
Channel dst_channel,
XProtocolState dst_protocol 
)
static

◆ forward_frame_from_channel()

static stdx::expected< bool, std::error_code > forward_frame_from_channel ( Channel src_channel,
XProtocolState src_protocol,
Channel dst_channel,
XProtocolState dst_protocol 
)
static
Returns
frame-is-done on success and std::error_code on error.

◆ get_dest_ssl_ctx()

static stdx::expected< TlsClientContext *, std::error_code > get_dest_ssl_ctx ( MySQLRoutingContext ctx,
const std::string &  id 
)
static

◆ has_frame_header()

static bool has_frame_header ( XProtocolState src_protocol)
static

◆ has_msg_type()

static bool has_msg_type ( XProtocolState src_protocol)
static

◆ log_fatal_error_code()

static void log_fatal_error_code ( const char *  msg,
std::error_code  ec 
)
static

◆ message_byte_size()

static size_t message_byte_size ( const google::protobuf::MessageLite &  msg)
static

◆ set_capability_tls()

static void set_capability_tls ( Mysqlx::Connection::Capability cap,
bool  value 
)
static

◆ xproto_frame_encode()

template<class T >
static size_t xproto_frame_encode ( const T &  msg,
std::vector< uint8_t > &  out_buf 
)
static

encode a message into a xproto frame.

  • 4-byte length (msg-type + payload)
  • 1-byte msg-type
  • payload

◆ xproto_frame_msg_type() [1/5]

static constexpr uint8_t xproto_frame_msg_type ( const Mysqlx::Connection::Capabilities )
staticconstexpr

◆ xproto_frame_msg_type() [2/5]

static constexpr uint8_t xproto_frame_msg_type ( const Mysqlx::Connection::CapabilitiesGet )
staticconstexpr

◆ xproto_frame_msg_type() [3/5]

static constexpr uint8_t xproto_frame_msg_type ( const Mysqlx::Connection::CapabilitiesSet )
staticconstexpr

◆ xproto_frame_msg_type() [4/5]

static constexpr uint8_t xproto_frame_msg_type ( const Mysqlx::Error )
staticconstexpr

◆ xproto_frame_msg_type() [5/5]

static constexpr uint8_t xproto_frame_msg_type ( const Mysqlx::Ok )
staticconstexpr