[FEAT MERGE]Query Interface Enhancement
Co-authored-by: chinaxing <chen.yack@gmail.com>
This commit is contained in:
12
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
12
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
@ -673,6 +673,18 @@ class EventTable
|
||||
EN_FETCH_TABLE_INFO_RPC = 1112,
|
||||
// END OF STORAGE HA - 1101 - 2000
|
||||
|
||||
// sql parameterization 1170-1180
|
||||
EN_SQL_PARAM_FP_NP_NOT_SAME_ERROR = 1170,
|
||||
// END OF sql parameterization 1170-1180
|
||||
|
||||
// session info verification
|
||||
// The types are used for error verification
|
||||
EN_SESS_INFO_VERI_SYS_VAR_ERROR = 1180,
|
||||
EN_SESS_INFO_VERI_APP_INFO_ERROR = 1181,
|
||||
EN_SESS_INFO_VERI_APP_CTX_ERROR = 1182,
|
||||
EN_SESS_INFO_VERI_CLIENT_ID_ERROR = 1183,
|
||||
EN_SESS_INFO_VERI_CONTROL_INFO_ERROR = 1184,
|
||||
EN_SESS_INFO_VERI_TXN_EXTRA_INFO_ERROR = 1185,
|
||||
EN_ENABLE_NEWSORT_FORCE = 1200,
|
||||
|
||||
// Transaction // 2001 - 2100
|
||||
|
||||
@ -261,21 +261,15 @@ int Ob20ProtocolProcessor::decode_extra_info(const Ob20ProtocolHeader &hdr,
|
||||
LOG_WARN("fail to deserialize extra info", K(ret));
|
||||
} else {
|
||||
LOG_TRACE("extra info", K(key), K(value));
|
||||
if (0 == key.get_string().case_compare(ObString("ob_trace_info"))) {
|
||||
extra_info.exist_trace_info_ = true;
|
||||
if (!value.is_varchar()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid extra info value type", K(ret), K(key), K(value));
|
||||
} else {
|
||||
extra_info.trace_info_ = value.get_string();
|
||||
}
|
||||
} else if (0 == key.get_string().case_compare(ObString("sess_inf"))) {
|
||||
|
||||
if (0 == key.get_string().case_compare(ObString("sess_inf"))) {
|
||||
if (!value.is_varchar()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid extra info value type", K(ret), K(key), K(value));
|
||||
} else {
|
||||
extra_info.sync_sess_info_ = value.get_string();
|
||||
LOG_DEBUG("receive extra_info", KPHEX(extra_info.sync_sess_info_.ptr(),extra_info.sync_sess_info_.length()));
|
||||
LOG_DEBUG("receive extra_info", KPHEX(extra_info.sync_sess_info_.ptr(),
|
||||
extra_info.sync_sess_info_.length()));
|
||||
}
|
||||
} else if (0 == key.get_string().case_compare(ObString("full_trc"))) {
|
||||
if (!value.is_varchar()) {
|
||||
@ -284,6 +278,21 @@ int Ob20ProtocolProcessor::decode_extra_info(const Ob20ProtocolHeader &hdr,
|
||||
} else {
|
||||
extra_info.full_link_trace_ = value.get_string();
|
||||
}
|
||||
} else if (0 == key.get_string().case_compare(ObString("ob_trace_info"))) {
|
||||
extra_info.exist_trace_info_ = true;
|
||||
if (!value.is_varchar()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid extra info value type", K(ret), K(key), K(value));
|
||||
} else {
|
||||
extra_info.trace_info_ = value.get_string();
|
||||
}
|
||||
} else if (0 == key.get_string().case_compare(ObString("sess_ver"))) {
|
||||
if (!value.is_varchar()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid extra info value type", K(ret), K(key), K(value));
|
||||
} else {
|
||||
extra_info.sess_info_veri_ = value.get_string();
|
||||
}
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
@ -427,7 +436,8 @@ inline int Ob20ProtocolProcessor::process_ob20_packet(ObProto20PktContext& conte
|
||||
ObMySQLRawPacket *input_packet = reinterpret_cast<ObMySQLRawPacket *>(ipacket);
|
||||
input_packet->set_can_reroute_pkt(pkt20->get_flags().is_proxy_reroute());
|
||||
input_packet->set_is_weak_read(pkt20->get_flags().is_weak_read());
|
||||
|
||||
// need test proxy_switch_route flag.
|
||||
input_packet->set_proxy_switch_route(pkt20->get_flags().proxy_switch_route());
|
||||
const int64_t t_len = context.extra_info_.get_total_len();
|
||||
char *t_buffer = NULL;
|
||||
if (OB_ISNULL(t_buffer = reinterpret_cast<char *>(pool.alloc(t_len)))) {
|
||||
|
||||
@ -54,11 +54,13 @@ private:
|
||||
Obp20Decoder* svr_decoders_[OBP20_SVR_END-OBP20_PROXY_MAX_TYPE] = {
|
||||
&trace_info_dcd_,
|
||||
&sess_info_dcd_,
|
||||
&full_trc_dcd_
|
||||
&full_trc_dcd_,
|
||||
&sess_info_veri_dcd_
|
||||
};
|
||||
Obp20TaceInfoDecoder trace_info_dcd_;
|
||||
Obp20SessInfoDecoder sess_info_dcd_;
|
||||
Obp20FullTrcDecoder full_trc_dcd_;
|
||||
Obp20SessInfoVeriDecoder sess_info_veri_dcd_;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Ob20ProtocolProcessor);
|
||||
|
||||
@ -32,6 +32,7 @@ union Ob20ProtocolFlags
|
||||
bool is_new_extra_info() const { return 1 == st_flags_.OB_IS_NEW_EXTRA_INFO; }
|
||||
bool is_weak_read() const { return 1 == st_flags_.OB_IS_WEAK_READ; }
|
||||
bool txn_free_route() const { return 1 == st_flags_.OB_TXN_FREE_ROUTE; }
|
||||
bool proxy_switch_route() const { return 1 == st_flags_.OB_PROXY_SWITCH_ROUTE; }
|
||||
|
||||
uint32_t flags_;
|
||||
struct Protocol20Flags
|
||||
@ -42,7 +43,8 @@ union Ob20ProtocolFlags
|
||||
uint32_t OB_IS_NEW_EXTRA_INFO: 1;
|
||||
uint32_t OB_IS_WEAK_READ: 1;
|
||||
uint32_t OB_TXN_FREE_ROUTE: 1;
|
||||
uint32_t OB_FLAG_RESERVED_NOT_USE: 26;
|
||||
uint32_t OB_PROXY_SWITCH_ROUTE: 1;
|
||||
uint32_t OB_FLAG_RESERVED_NOT_USE: 25;
|
||||
} st_flags_;
|
||||
};
|
||||
|
||||
|
||||
31
deps/oblib/src/rpc/obmysql/ob_mysql_packet.cpp
vendored
31
deps/oblib/src/rpc/obmysql/ob_mysql_packet.cpp
vendored
@ -186,17 +186,26 @@ int Ob20ExtraInfo::assign(const Ob20ExtraInfo &other, char* buf, int64_t buf_len
|
||||
SERVER_LOG(ERROR, "invalid alloc size", K(total_len), K(ret));
|
||||
} else {
|
||||
uint64_t len = 0;
|
||||
MEMCPY(buf+len, other.trace_info_.ptr(), other.trace_info_.length());
|
||||
trace_info_.assign_ptr(buf+len, other.trace_info_.length());
|
||||
len += other.trace_info_.length();
|
||||
|
||||
MEMCPY(buf+len, other.sync_sess_info_.ptr(), other.sync_sess_info_.length());
|
||||
sync_sess_info_.assign_ptr(buf+len, other.sync_sess_info_.length());
|
||||
len += other.sync_sess_info_.length();
|
||||
|
||||
MEMCPY(buf+len, other.full_link_trace_.ptr(), other.full_link_trace_.length());
|
||||
full_link_trace_.assign_ptr(buf+len, other.full_link_trace_.length());
|
||||
len += other.full_link_trace_.length();
|
||||
if (other.trace_info_.length() > 0) {
|
||||
MEMCPY(buf+len, other.trace_info_.ptr(), other.trace_info_.length());
|
||||
trace_info_.assign_ptr(buf+len, other.trace_info_.length());
|
||||
len += other.trace_info_.length();
|
||||
}
|
||||
if (other.sync_sess_info_.length() > 0) {
|
||||
MEMCPY(buf+len, other.sync_sess_info_.ptr(), other.sync_sess_info_.length());
|
||||
sync_sess_info_.assign_ptr(buf+len, other.sync_sess_info_.length());
|
||||
len += other.sync_sess_info_.length();
|
||||
}
|
||||
if (other.full_link_trace_.length() > 0) {
|
||||
MEMCPY(buf+len, other.full_link_trace_.ptr(), other.full_link_trace_.length());
|
||||
full_link_trace_.assign_ptr(buf+len, other.full_link_trace_.length());
|
||||
len += other.full_link_trace_.length();
|
||||
}
|
||||
if (other.sess_info_veri_.length() > 0) {
|
||||
MEMCPY(buf+len, other.sess_info_veri_.ptr(), other.sess_info_veri_.length());
|
||||
sess_info_veri_.assign_ptr(buf+len, other.sess_info_veri_.length());
|
||||
len += other.sess_info_veri_.length();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
38
deps/oblib/src/rpc/obmysql/ob_mysql_packet.h
vendored
38
deps/oblib/src/rpc/obmysql/ob_mysql_packet.h
vendored
@ -159,6 +159,8 @@ union ObProxyCapabilityFlags
|
||||
bool is_session_var_sync_support() const { return 1 == cap_flags_.OB_CAP_PROXY_SESSION_VAR_SYNC
|
||||
&& is_ob_protocol_v2_support(); }
|
||||
bool is_weak_stale_feedback() const { return 1 == cap_flags_.OB_CAP_PROXY_WEAK_STALE_FEEDBACK; }
|
||||
bool is_flt_show_trace_support() const { return 1 == cap_flags_.OB_CAP_PROXY_FULL_LINK_TRACING_EXT
|
||||
&& is_ob_protocol_v2_support(); }
|
||||
|
||||
uint64_t capability_;
|
||||
struct CapabilityFlags
|
||||
@ -189,7 +191,8 @@ union ObProxyCapabilityFlags
|
||||
uint64_t OB_CAP_PROXY_NEW_EXTRA_INFO: 1;
|
||||
uint64_t OB_CAP_PROXY_SESSION_VAR_SYNC: 1;
|
||||
uint64_t OB_CAP_PROXY_WEAK_STALE_FEEDBACK: 1;
|
||||
uint64_t OB_CAP_RESERVED_NOT_USE: 46;
|
||||
uint64_t OB_CAP_PROXY_FULL_LINK_TRACING_EXT: 1;
|
||||
uint64_t OB_CAP_RESERVED_NOT_USE: 45;
|
||||
} cap_flags_;
|
||||
};
|
||||
|
||||
@ -339,10 +342,13 @@ public:
|
||||
// add key name
|
||||
static constexpr const char SYNC_SESSION_INFO[] = "sess_inf";
|
||||
static constexpr const char FULL_LINK_TRACE[] = "full_trc";
|
||||
static constexpr const char OB_SESSION_INFO_VERI[] = "sess_ver";
|
||||
|
||||
|
||||
// def value
|
||||
ObString sync_sess_info_;
|
||||
ObString full_link_trace_;
|
||||
ObString sess_info_veri_;
|
||||
|
||||
public:
|
||||
Ob20ExtraInfo() : extra_len_(0), exist_trace_info_(false) {}
|
||||
@ -353,22 +359,31 @@ public:
|
||||
trace_info_.reset();
|
||||
sync_sess_info_.reset();
|
||||
full_link_trace_.reset();
|
||||
sess_info_veri_.reset();
|
||||
}
|
||||
bool exist_sync_sess_info() { return !sync_sess_info_.empty(); }
|
||||
bool exist_full_link_trace() { return !full_link_trace_.empty(); }
|
||||
bool exist_sess_info_veri() { return !sess_info_veri_.empty(); }
|
||||
ObString& get_sync_sess_info() { return sync_sess_info_; }
|
||||
ObString& get_full_link_trace() { return full_link_trace_; }
|
||||
ObString& get_sess_info_veri() { return sess_info_veri_; }
|
||||
bool exist_sync_sess_info() const { return !sync_sess_info_.empty(); }
|
||||
bool exist_full_link_trace() const { return !full_link_trace_.empty(); }
|
||||
bool exist_sess_info_veri() const { return !sess_info_veri_.empty(); }
|
||||
const ObString& get_sync_sess_info() const { return sync_sess_info_; }
|
||||
const ObString& get_full_link_trace() const { return full_link_trace_; }
|
||||
bool exist_extra_info() {return !sync_sess_info_.empty() || !full_link_trace_.empty() || exist_trace_info_;}
|
||||
bool exist_extra_info() const {return !sync_sess_info_.empty() || !full_link_trace_.empty() || exist_trace_info_;}
|
||||
const ObString& get_sess_info_veri() const { return sess_info_veri_; }
|
||||
bool exist_extra_info() {return !sync_sess_info_.empty() || !full_link_trace_.empty()
|
||||
|| !sess_info_veri_.empty() || exist_trace_info_;}
|
||||
bool exist_extra_info() const {return !sync_sess_info_.empty() || !full_link_trace_.empty()
|
||||
|| !sess_info_veri_.empty() || exist_trace_info_;}
|
||||
int assign(const Ob20ExtraInfo &other, char* buf, int64_t len);
|
||||
int64_t get_total_len() {return trace_info_.length() + sync_sess_info_.length() + full_link_trace_.length();}
|
||||
int64_t get_total_len() const {return trace_info_.length() + sync_sess_info_.length() + full_link_trace_.length();}
|
||||
int64_t get_total_len() {return trace_info_.length() + sync_sess_info_.length() +
|
||||
full_link_trace_.length() + sess_info_veri_.length();}
|
||||
int64_t get_total_len() const {return trace_info_.length() + sync_sess_info_.length() +
|
||||
full_link_trace_.length() + sess_info_veri_.length();}
|
||||
TO_STRING_KV(K_(extra_len), K_(exist_trace_info), K_(trace_info),
|
||||
K_(sync_sess_info), K_(full_link_trace));
|
||||
K_(sync_sess_info), K_(full_link_trace), K_(sync_sess_info));
|
||||
};
|
||||
|
||||
typedef ObCommonKV<common::ObString, common::ObString> ObStringKV;
|
||||
@ -490,6 +505,7 @@ public:
|
||||
can_reroute_pkt_(false),
|
||||
is_weak_read_(false),
|
||||
txn_free_route_(false),
|
||||
proxy_switch_route_(false),
|
||||
extra_info_()
|
||||
{}
|
||||
|
||||
@ -498,6 +514,7 @@ public:
|
||||
can_reroute_pkt_(false),
|
||||
is_weak_read_(false),
|
||||
txn_free_route_(false),
|
||||
proxy_switch_route_(false),
|
||||
extra_info_()
|
||||
{}
|
||||
|
||||
@ -515,6 +532,9 @@ public:
|
||||
inline void set_is_weak_read(const bool v) { is_weak_read_ = v; }
|
||||
inline bool is_weak_read() const { return is_weak_read_; }
|
||||
|
||||
inline void set_proxy_switch_route(const bool v) { proxy_switch_route_ = v; }
|
||||
inline bool is_proxy_switch_route() const { return proxy_switch_route_; }
|
||||
|
||||
inline void set_txn_free_route(const bool txn_free_route);
|
||||
inline bool txn_free_route() const;
|
||||
|
||||
@ -530,6 +550,7 @@ public:
|
||||
can_reroute_pkt_ = false;
|
||||
is_weak_read_ = false;
|
||||
txn_free_route_ = false;
|
||||
proxy_switch_route_ = false;
|
||||
extra_info_.reset();
|
||||
}
|
||||
|
||||
@ -541,9 +562,11 @@ public:
|
||||
is_weak_read_ = other.is_weak_read_;
|
||||
txn_free_route_ = other.txn_free_route_;
|
||||
extra_info_ = other.extra_info_;
|
||||
proxy_switch_route_ = other.proxy_switch_route_;
|
||||
}
|
||||
|
||||
TO_STRING_KV("header", hdr_, "can_reroute", can_reroute_pkt_, "weak_read", is_weak_read_);
|
||||
TO_STRING_KV("header", hdr_, "can_reroute", can_reroute_pkt_, "weak_read", is_weak_read_,
|
||||
"txn_free_route_", txn_free_route_, "proxy_switch_route", proxy_switch_route_);
|
||||
protected:
|
||||
virtual int serialize(char*, const int64_t, int64_t&) const;
|
||||
|
||||
@ -554,6 +577,7 @@ private:
|
||||
bool can_reroute_pkt_;
|
||||
bool is_weak_read_;
|
||||
bool txn_free_route_;
|
||||
bool proxy_switch_route_;
|
||||
public:
|
||||
Ob20ExtraInfo extra_info_;
|
||||
};
|
||||
|
||||
29
deps/oblib/src/rpc/obmysql/obp20_extra_info.cpp
vendored
29
deps/oblib/src/rpc/obmysql/obp20_extra_info.cpp
vendored
@ -14,6 +14,29 @@
|
||||
#include "rpc/obmysql/obp20_extra_info.h"
|
||||
namespace oceanbase {
|
||||
namespace obmysql {
|
||||
|
||||
// proxy -> server verify sess info required: addr, sess_id, proxy_sess_id.
|
||||
int Obp20SessInfoVeriDecoder::deserialize(const char *buf, int64_t len, int64_t &pos,
|
||||
Ob20ExtraInfo &extra_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
char* ptr = NULL;
|
||||
int32_t v_len = 0;
|
||||
int16_t extra_id = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, len, pos, extra_id, v_len))) {
|
||||
OB_LOG(WARN,"failed to get extra_info", K(ret), KP(buf));
|
||||
} else if (static_cast<ExtraInfoKeyType>(extra_id) != type_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
OB_LOG(WARN, "invalid encoder", K(ret), K(extra_id), K(type_));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve sess info verification required", K(ret));
|
||||
} else {
|
||||
extra_info.sess_info_veri_.assign_ptr(ptr, v_len);
|
||||
OB_LOG(TRACE,"success to deserialize sess info verification required", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Obp20TraceInfoEncoder::serialize(char *buf, int64_t len, int64_t &pos) {
|
||||
int ret = OB_SUCCESS;
|
||||
// resrver for type and len
|
||||
@ -42,7 +65,7 @@ int Obp20TraceInfoEncoder::get_serialize_size() {
|
||||
|
||||
int Obp20TaceInfoDecoder::deserialize(const char *buf, int64_t len, int64_t &pos, Ob20ExtraInfo &extra_info) {
|
||||
int ret = OB_SUCCESS;
|
||||
char* ptr;
|
||||
char* ptr = NULL;
|
||||
int32_t v_len = 0;
|
||||
int16_t extra_id = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, len, pos, extra_id, v_len))) {
|
||||
@ -88,7 +111,7 @@ int Obp20SessInfoEncoder::get_serialize_size() {
|
||||
|
||||
int Obp20SessInfoDecoder::deserialize(const char *buf, int64_t len, int64_t &pos, Ob20ExtraInfo &extra_info) {
|
||||
int ret = OB_SUCCESS;
|
||||
char* ptr;
|
||||
char* ptr = NULL;
|
||||
int32_t v_len = 0;
|
||||
int16_t extra_id = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, len, pos, extra_id, v_len))) {
|
||||
@ -130,7 +153,7 @@ int Obp20FullTrcEncoder::get_serialize_size() {
|
||||
|
||||
int Obp20FullTrcDecoder::deserialize(const char *buf, int64_t len, int64_t &pos, Ob20ExtraInfo &extra_info) {
|
||||
int ret = OB_SUCCESS;
|
||||
char* ptr;
|
||||
char* ptr = NULL;
|
||||
int32_t v_len = 0;
|
||||
int16_t extra_id = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, len, pos, extra_id, v_len))) {
|
||||
|
||||
14
deps/oblib/src/rpc/obmysql/obp20_extra_info.h
vendored
14
deps/oblib/src/rpc/obmysql/obp20_extra_info.h
vendored
@ -23,7 +23,8 @@ OBP20_EXTRA_INFO_DEF(OBP20_PROXY_MAX_TYPE, 2000, EMySQLFieldType::MYSQL_TYPE_NOT
|
||||
OBP20_EXTRA_INFO_DEF(TRACE_INFO, 2001, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
OBP20_EXTRA_INFO_DEF(SESS_INFO, 2002, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
OBP20_EXTRA_INFO_DEF(FULL_TRC, 2003, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
OBP20_EXTRA_INFO_DEF(OBP20_SVR_END, 2004, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
OBP20_EXTRA_INFO_DEF(SESS_INFO_VERI, 2004, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
OBP20_EXTRA_INFO_DEF(OBP20_SVR_END, 2005, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
OBP20_EXTRA_INFO_DEF(OBP20_SVR_MAX_TYPE, 65535, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
#endif /* OBP20_EXTRA_INFO_DEF */
|
||||
|
||||
@ -65,6 +66,17 @@ class Obp20Decoder {
|
||||
TO_STRING_KV(K_(type));
|
||||
};
|
||||
|
||||
|
||||
// proxy -> server verify sess info required: addr, sess_id, proxy_sess_id.
|
||||
// no need encoder.
|
||||
class Obp20SessInfoVeriDecoder : public Obp20Decoder{
|
||||
public:
|
||||
ExtraInfoKeyType type_;
|
||||
Obp20SessInfoVeriDecoder() : type_(SESS_INFO_VERI) {}
|
||||
~Obp20SessInfoVeriDecoder() {}
|
||||
int deserialize(const char *buf, int64_t len, int64_t &pos, Ob20ExtraInfo &extra_info);
|
||||
};
|
||||
|
||||
class Obp20TraceInfoEncoder : public Obp20Encoder {
|
||||
public:
|
||||
ObString trace_info_;
|
||||
|
||||
@ -965,5 +965,8 @@ PCODE_DEF(OB_LOB_QUERY, 0x1561)
|
||||
// PCODE_DEF(OB_ALTER_STORAGE, 0x1574)
|
||||
// PCODE_DEF(OB_GET_SERVER_STORAGE, 0X1575);
|
||||
|
||||
|
||||
// 1581-1590 for workload repository
|
||||
// PCODE_DEF(OB_WR_ASYNC_SNAPSHOT_TASK, 0x1581)
|
||||
// session info verification
|
||||
PCODE_DEF(OB_SESS_INFO_VERIFICATION, 0x1592)
|
||||
|
||||
Reference in New Issue
Block a user