diff --git a/build.sh b/build.sh index 8e6b51346f..2e64aad78f 100755 --- a/build.sh +++ b/build.sh @@ -164,6 +164,11 @@ function build xdebug_no_unity) do_build "$@" -DCMAKE_BUILD_TYPE=Debug -DOB_USE_LLD=$LLD_OPTION -DOB_ENABLE_UNITY=OFF ;; + xccls) + do_build "$@" -DCMAKE_BUILD_TYPE=Debug -DOB_USE_LLD=$LLD_OPTION -DOB_BUILD_CCLS=ON + # build soft link for ccls + ln -sf ${TOPDIR}/build_ccls/compile_commands.json ${TOPDIR}/compile_commands.json + ;; xdebug_asan) do_build "$@" -DCMAKE_BUILD_TYPE=Debug -DOB_USE_LLD=$LLD_OPTION -DOB_USE_ASAN=$ASAN_OPTION ;; diff --git a/cmake/Env.cmake b/cmake/Env.cmake index b666a32b14..c0bf5d7859 100644 --- a/cmake/Env.cmake +++ b/cmake/Env.cmake @@ -22,6 +22,7 @@ ob_define(ENABLE_COMPILE_DLL_MODE OFF) ob_define(OB_CMAKE_RULES_CHECK ON) ob_define(OB_STATIC_LINK_LGPL_DEPS ON) ob_define(HOTFUNC_PATH "${CMAKE_SOURCE_DIR}/hotfuncs.txt") +ob_define(OB_BUILD_CCLS OFF) # 'ENABLE_PERF_MODE' use for offline system insight performance test # PERF_MODE macro controls many special code path in system @@ -84,6 +85,14 @@ else() # not clang, use gcc message("gcc9 not support currently, please set OB_USE_CLANG ON and we will finish it as soon as possible") endif() +if (OB_BUILD_CCLS) + # ccls场景采用更大的unity的联合编译单元,ccls是非完整编译,掉用clang AST接口,单元的size和耗时成指数衰减 + set(OB_MAX_UNITY_BATCH_SIZE 200) + # -DCCLS_LASY_ENABLE 给全局设置上,将采用ccls懒加载模式,主要针对单测case,当添加上-DCCLS_LASY_OFF,首次将会进行检索 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCCLS_LASY_ENABLE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCCLS_LASY_ENABLE") +endif() + if (OB_CC AND OB_CXX) set(CMAKE_C_COMPILER ${OB_CC}) set(CMAKE_CXX_COMPILER ${OB_CXX}) diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 96012396fe..a1e4e91a0e 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -79,9 +79,16 @@ function(config_target_unity target) endif() endfunction() +function(config_ccls_flag target) + if (OB_BUILD_CCLS) + target_compile_definitions(${target} PRIVATE CCLS_LASY_OFF) + endif() +endfunction() + function(ob_add_object_target target) add_library(${target} OBJECT "${${target}_cache_objects_}") config_target_unity(${target}) + config_ccls_flag(${target}) endfunction() function(ob_lib_add_target target) @@ -90,10 +97,12 @@ function(ob_lib_add_target target) target_link_libraries(${target} PUBLIC oblib_base) list(APPEND oblib_object_libraries ${target}) set(oblib_object_libraries "${oblib_object_libraries}" CACHE INTERNAL "observer library list") + config_ccls_flag(${target}) endfunction() -function(ob_add_new_object_target target_name target_objects_list) - message(STATUS "ob_add_new_object_target ${target_name}") - add_library(${target_name} OBJECT EXCLUDE_FROM_ALL "${${target_objects_list}_cache_objects_}") - config_target_unity(${target_name}) +function(ob_add_new_object_target target target_objects_list) + message(STATUS "ob_add_new_object_target ${target}") + add_library(${target} OBJECT EXCLUDE_FROM_ALL "${${target_objects_list}_cache_objects_}") + config_target_unity(${target}) + config_ccls_flag(${target}) endfunction() diff --git a/deps/oblib/src/lib/charset/ob_dtoa_os.cc b/deps/oblib/src/lib/charset/ob_dtoa_os.cc index 4768551c3e..559a757137 100644 --- a/deps/oblib/src/lib/charset/ob_dtoa_os.cc +++ b/deps/oblib/src/lib/charset/ob_dtoa_os.cc @@ -2485,3 +2485,4 @@ ret1: return s0; } +#undef P diff --git a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_result.cpp b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_result.cpp index cce29da944..e5b4bbbb4a 100644 --- a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_result.cpp +++ b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_result.cpp @@ -132,13 +132,13 @@ int ObMySQLPreparedResult::get_int(const int64_t col_idx, int64_t &int_val) cons int ret = OB_SUCCESS; if (OB_LIKELY(col_idx >= 0) && OB_LIKELY(col_idx < result_column_count_)) { // currently not support auto type convertion - if (MYSQL_TYPE_LONGLONG == bind_[col_idx].buffer_type) { + if (enum_field_types::MYSQL_TYPE_LONGLONG == bind_[col_idx].buffer_type) { int_val = *(reinterpret_cast(bind_[col_idx].buffer)); } else { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid type, forget to call bind_type_and_buf() first", "real type", bind_[col_idx].buffer_type, - "expected type", MYSQL_TYPE_LONGLONG, K(ret)); + "expected type", enum_field_types::MYSQL_TYPE_LONGLONG, K(ret)); } } else { ret = OB_INVALID_ARGUMENT; @@ -152,14 +152,14 @@ int ObMySQLPreparedResult::get_varchar(const int64_t col_idx, ObString &varchar_ int ret = OB_SUCCESS; if (OB_LIKELY(col_idx >= 0) && OB_LIKELY(col_idx < result_column_count_)) { // currently not support auto type convertion - if (MYSQL_TYPE_VAR_STRING == bind_[col_idx].buffer_type) { + if (enum_field_types::MYSQL_TYPE_VAR_STRING == bind_[col_idx].buffer_type) { varchar_val.assign(static_cast(bind_[col_idx].buffer), static_cast(*bind_[col_idx].length)); } else { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid type, forget to call bind_type_and_buf() first", "real type", bind_[col_idx].buffer_type, - "expected type", MYSQL_TYPE_VAR_STRING, K(ret)); + "expected type", enum_field_types::MYSQL_TYPE_VAR_STRING, K(ret)); } } else { ret = OB_INVALID_ARGUMENT; diff --git a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp index da32ce6970..2f8504c940 100644 --- a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp +++ b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp @@ -163,7 +163,7 @@ int ObMySQLPreparedStatement::bind_param_int(const int64_t col_idx, int64_t *in_ { int ret = OB_SUCCESS; unsigned long res_len = 0; - if (OB_FAIL(param_.bind_param(col_idx, MYSQL_TYPE_LONGLONG, + if (OB_FAIL(param_.bind_param(col_idx, enum_field_types::MYSQL_TYPE_LONGLONG, reinterpret_cast(in_int_val), sizeof(int64_t), res_len))) { LOG_WARN("fail to bind int result", K(col_idx), K(ret)); } @@ -174,7 +174,7 @@ int ObMySQLPreparedStatement::bind_param_varchar(const int64_t col_idx, char *in unsigned long &in_str_len) { int ret = OB_SUCCESS; - if (OB_FAIL(param_.bind_param(col_idx, MYSQL_TYPE_VAR_STRING, + if (OB_FAIL(param_.bind_param(col_idx, enum_field_types::MYSQL_TYPE_VAR_STRING, in_str_val, 0, in_str_len))) { LOG_WARN("fail to bind int result", K(col_idx), K(ret)); } @@ -185,7 +185,7 @@ int ObMySQLPreparedStatement::bind_result_int(const int64_t col_idx, int64_t *ou { int ret = OB_SUCCESS; unsigned long res_len = 0; - if (OB_FAIL(result_.bind_result(col_idx, MYSQL_TYPE_LONGLONG, + if (OB_FAIL(result_.bind_result(col_idx, enum_field_types::MYSQL_TYPE_LONGLONG, reinterpret_cast(out_buf), sizeof(int64_t), res_len))) { LOG_WARN("fail to bind int result", K(col_idx), K(ret)); } @@ -196,7 +196,7 @@ int ObMySQLPreparedStatement::bind_result_varchar(const int64_t col_idx, char *o unsigned long &res_len) { int ret = OB_SUCCESS; - if (OB_FAIL(result_.bind_result(col_idx, MYSQL_TYPE_VAR_STRING, + if (OB_FAIL(result_.bind_result(col_idx,enum_field_types::MYSQL_TYPE_VAR_STRING, out_buf, buf_len, res_len))) { LOG_WARN("fail to bind int result", K(col_idx), K(ret)); } diff --git a/deps/oblib/src/lib/profile/ob_profile_type.h b/deps/oblib/src/lib/profile/ob_profile_type.h index 99b8e2b0b5..3264a626be 100644 --- a/deps/oblib/src/lib/profile/ob_profile_type.h +++ b/deps/oblib/src/lib/profile/ob_profile_type.h @@ -17,7 +17,7 @@ namespace oceanbase namespace common { /* common */ -#define PCODE " pcode=[%d]" +//#define PCODE " pcode=[%d]" // Comment SELF since it conflicts with other macro utils. // Maybe should change these names for more identical. // #define SELF " self=[%s]" @@ -63,7 +63,7 @@ namespace common /*The time that the mysql package waits in the ObMySQL queue. Unit: microseconds*/ #define WAIT_TIME_US_IN_SQL_QUEUE " wait_time_us_in_sql_queue=[%ld]" /*The sql request sent by the client*/ -#define SQL " sql=[%.*s]" +//#define SQL " sql=[%.*s]" /*The time spent processing a SQL request, not including the time waiting in the ObMySQL queue*/ #define HANDLE_SQL_TIME_MS " handle_sql_time_ms=[%ld]" /*The time spent by obmysql worker thread interacting with IO thread is only related to SELECT*/ diff --git a/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp b/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp index 6313324b03..02953642c0 100644 --- a/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp +++ b/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp @@ -28,6 +28,7 @@ #include #include #include +#include "rpc/obrpc/ob_listener.h" using namespace oceanbase::common; @@ -454,15 +455,6 @@ static int epoll_regist(int epfd, int fd, uint32_t eflag, void* s) { return err; } -static struct sockaddr_in* make_unix_sockaddr(struct sockaddr_in *sin, in_addr_t ip, int port) { - if (NULL != sin) { - sin->sin_port = (uint16_t)htons((uint16_t)port); - sin->sin_addr.s_addr = ip; - sin->sin_family = AF_INET; - } - return sin; -} - static int socket_set_opt(int fd, int option, int value) { return setsockopt(fd, SOL_SOCKET, option, (void *)&value, sizeof(value)); @@ -481,7 +473,7 @@ static int listen_create(int port) { } else if (socket_set_opt(fd, SO_REUSEADDR, 1) < 0) { LOG_ERROR("sql nio set sock opt SO_REUSEADDR failed", K(errno), K(fd)); err = errno; - } else if (bind(fd, (sockaddr*)make_unix_sockaddr(&sin, 0, port), sizeof(sin))) { + } else if (bind(fd, (sockaddr*)obrpc::make_unix_sockaddr(&sin, 0, port), sizeof(sin))) { LOG_ERROR("sql nio bind listen fd failed", K(errno), K(fd)); err = errno; } else if (listen(fd, 1024) < 0) { diff --git a/deps/oblib/src/rpc/obrpc/ob_listener.cpp b/deps/oblib/src/rpc/obrpc/ob_listener.cpp index 8cf6da5a44..f5aef59f6d 100644 --- a/deps/oblib/src/rpc/obrpc/ob_listener.cpp +++ b/deps/oblib/src/rpc/obrpc/ob_listener.cpp @@ -28,15 +28,6 @@ using namespace oceanbase::common; using namespace oceanbase::obrpc; using namespace oceanbase::common::serialization; -struct sockaddr_in* make_unix_sockaddr(struct sockaddr_in *sin, in_addr_t ip, int port) { - if (NULL != sin) { - sin->sin_port = (uint16_t)htons((uint16_t)port); - sin->sin_addr.s_addr = ip; - sin->sin_family = AF_INET; - } - return sin; -} - ObListener::ObListener() { listen_fd_ = -1; diff --git a/deps/oblib/src/rpc/obrpc/ob_listener.h b/deps/oblib/src/rpc/obrpc/ob_listener.h index 6c253076cb..ea29bfcd99 100644 --- a/deps/oblib/src/rpc/obrpc/ob_listener.h +++ b/deps/oblib/src/rpc/obrpc/ob_listener.h @@ -33,6 +33,15 @@ namespace obrpc #define OB_LISTENER_MAX_THREAD_CNT 64 #endif +inline struct sockaddr_in* make_unix_sockaddr(struct sockaddr_in *sin, in_addr_t ip, int port) { + if (NULL != sin) { + sin->sin_port = (uint16_t)htons((uint16_t)port); + sin->sin_addr.s_addr = ip; + sin->sin_family = AF_INET; + } + return sin; +} + typedef struct io_threads_pipefd_pool_t{ int count; int pipefd[OB_LISTENER_MAX_THREAD_CNT]; diff --git a/src/logservice/leader_coordinator/election_priority_impl/election_priority_v1.cpp b/src/logservice/leader_coordinator/election_priority_impl/election_priority_v1.cpp index 582d2e09d2..3578c5e0ad 100644 --- a/src/logservice/leader_coordinator/election_priority_impl/election_priority_v1.cpp +++ b/src/logservice/leader_coordinator/election_priority_impl/election_priority_v1.cpp @@ -158,7 +158,7 @@ int PriorityV1::refresh_(const share::ObLSID &ls_id) log_ts_ = log_ts; } return ret; - #undef PRINT_WRAPPERd + #undef PRINT_WRAPPER } int PriorityV1::compare_fatal_failures_(int &ret, const PriorityV1&rhs) const diff --git a/src/logservice/leader_coordinator/ob_failure_detector.cpp b/src/logservice/leader_coordinator/ob_failure_detector.cpp index 05c9d8143e..484f45002a 100644 --- a/src/logservice/leader_coordinator/ob_failure_detector.cpp +++ b/src/logservice/leader_coordinator/ob_failure_detector.cpp @@ -210,13 +210,13 @@ int ObFailureDetector::insert_event_to_table_(const FailureEvent &event, const O #define PRINT_WRAPPER KR(ret), K(MTL_ID()), K(event), K(recover_operation) int ret = OB_SUCCESS; if (CLICK_FAIL(SERVER_EVENT_ADD("FAILURE_DETECTOR", - to_cstring(info), + common::to_cstring(info), "FAILURE_MODULE", obj_to_cstring(event.module_), "FAILURE_TYPE", obj_to_cstring(event.type_), "AUTO_RECOVER", - to_cstring(recover_operation.is_valid())))) { + common::to_cstring(recover_operation.is_valid())))) { COORDINATOR_LOG_(WARN, "insert into __all_server_event_history failed"); } else { COORDINATOR_LOG_(INFO, "insert into __all_server_event_history success"); diff --git a/src/objit/include/objit/common/ob_expr_res_type.h b/src/objit/include/objit/common/ob_expr_res_type.h deleted file mode 100644 index 254b6f87ae..0000000000 --- a/src/objit/include/objit/common/ob_expr_res_type.h +++ /dev/null @@ -1,351 +0,0 @@ -/** - * Copyright (c) 2021 OceanBase - * OceanBase CE is licensed under Mulan PubL v2. - * You can use this software according to the terms and conditions of the Mulan PubL v2. - * You may obtain a copy of Mulan PubL v2 at: - * http://license.coscl.org.cn/MulanPubL-2.0 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PubL v2 for more details. - */ - -#ifndef _OB_EXPR_RES_TYPE_H -#define _OB_EXPR_RES_TYPE_H 1 - -#include "common/object/ob_object.h" -#include "common/ob_field.h" -#include "rpc/obmysql/ob_mysql_global.h" -#include "lib/container/ob_iarray.h" -#include "lib/container/ob_se_array.h" -#include "lib/container/ob_fixed_array.h" -#include "lib/charset/ob_charset.h" -#include "lib/utility/utility.h" - -namespace oceanbase -{ -namespace sql -{ - -typedef common::ObObjMeta ObExprCalcType; - -/* 说明:为什么从ObObjMeta继承? - * 这是为了一个特殊的需求新增的:在calc_result_type阶段, - * 推导过程可能跟常量值有关系。 - * 对于一个常量,有可能不光需要知道它的type是什么, - * 还需要知道它的值是什么,才能推出跟MySQL兼容的行为。 - */ -class ObExprResType : public common::ObObjMeta -{ - OB_UNIS_VERSION(1); -public: - ObExprResType() : ObObjMeta(), - accuracy_(), - param_(), - calc_type_(), - res_flags_(0), - inner_alloc_("ExprResType"), - row_calc_cmp_types_(&inner_alloc_, 0) - { - } - - // 注意:OB代码利用到了非explicit特性,用法: - // ObExprResType types[2] = {alloc, alloc} - ObExprResType(common::ObIAllocator &alloc) : ObObjMeta(), - accuracy_(), - param_(), - calc_type_(), - res_flags_(0), - row_calc_cmp_types_(&alloc) - { - // nop - } - OB_INLINE int assign(const ObExprResType &other) - { - int ret = common::OB_SUCCESS; - if (OB_LIKELY(this != &other)) { - // assign func in ObFixedArray is not used for deep copy - if (OB_FAIL(copy_assign(this->row_calc_cmp_types_, other.row_calc_cmp_types_))) { - } else { - common::ObObjMeta::operator=(other);//default assignment operator is enough - this->accuracy_ = other.accuracy_; - this->calc_accuracy_ = other.calc_accuracy_; - this->param_ = other.param_; - this->calc_type_ = other.calc_type_; - this->res_flags_ = other.res_flags_; - } - } - return ret; - } - - void set_allocator(common::ObIAllocator *alloc) - { - row_calc_cmp_types_.set_allocator(alloc); - } - OB_INLINE bool operator ==(const ObExprResType &other) const - { - return (ObObjMeta::operator==(other) && accuracy_ == other.accuracy_); - } - OB_INLINE bool operator !=(const ObExprResType &other) const { return !this->operator ==(other); } -public: - OB_INLINE void reset() - { - accuracy_.reset(); - calc_accuracy_.reset(); - param_.reset(); - calc_type_.reset(); - row_calc_cmp_types_.reset(); - res_flags_ = 0; - } - OB_INLINE void set_accuracy(int64_t accuracy) { accuracy_.set_accuracy(accuracy); } - // accuracy. - OB_INLINE void set_accuracy(const common::ObAccuracy &accuracy) - { - accuracy_.set_accuracy(accuracy); - } - OB_INLINE void set_length(common::ObLength length) { accuracy_.set_length(length); } - OB_INLINE void set_length_within_max_length(common::ObLength length, bool is_from_pl) - { - common::ObLength max_length = length; - if (lib::is_oracle_mode()) { - if (is_varchar() || is_nvarchar2()) { - max_length = common::OB_MAX_ORACLE_VARCHAR_LENGTH; - } else if (is_char() || is_nchar()) { - max_length = is_from_pl ? common::OB_MAX_ORACLE_PL_CHAR_LENGTH_BYTE - : common::OB_MAX_ORACLE_CHAR_LENGTH_BYTE; - } - } else { - if (is_char()) { - max_length = common::OB_MAX_CHAR_LENGTH; - } else if (is_varchar()) { - max_length = common::OB_MAX_VARCHAR_LENGTH; - } - } - set_length(MIN(length, max_length)); - } - //set both length and length_semantics in case of someone forget it - OB_INLINE void set_length_semantics(const common::ObLengthSemantics value) - { - if (lib::is_oracle_mode()) { - accuracy_.set_length_semantics(value); - } - } - OB_INLINE void set_full_length(const common::ObLength length, const common::ObLengthSemantics length_semantics) - { - set_length(length); - set_length_semantics(length_semantics); - } - OB_INLINE void set_udt_id(uint64_t id) - { - accuracy_.set_accuracy(id); - } - OB_INLINE void set_precision(common::ObPrecision precision) { accuracy_.set_precision(precision);} - OB_INLINE void set_scale(common::ObScale scale) { accuracy_.set_scale(scale); } - OB_INLINE const common::ObAccuracy &get_accuracy() const { return accuracy_; } - /* character count*/ - OB_INLINE common::ObLength get_length() const - { - int ret = common::OB_SUCCESS; - common::ObLength length = accuracy_.get_length(); - if (!is_string_type() && !is_enum_or_set() && !is_enumset_inner_type() - && !is_ext() && !is_lob_locator()) { - if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), - get_accuracy(), - common::CS_TYPE_INVALID, - length))) { - SQL_RESV_LOG(WARN, "failed to get length", K(ret), KCSTRING(common::lbt()), N_TYPE, get_type()); - } - } - return length; - } - OB_INLINE common::ObLengthSemantics get_length_semantics() const - { - return accuracy_.get_length_semantics(); - } - OB_INLINE uint64_t get_udt_id() const - { - return accuracy_.get_accuracy(); - } - - /* meta info for client */ - OB_INLINE int get_length_for_meta_in_bytes(common::ObLength &length) const - { - int ret = common::OB_SUCCESS; - length = -1; - if (is_string_or_lob_locator_type() || is_enum_or_set() || is_enumset_inner_type() || is_json()) { - if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), - get_accuracy(), - get_collation_type(), - length))) { - SQL_RESV_LOG(WARN, "failed to get length of varchar", K(ret)); - } - } else { - if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), - get_accuracy(), - common::CS_TYPE_INVALID, - length))) { - SQL_RESV_LOG(WARN, "failed to get length of non-varchar", K(ret), K(common::lbt()), N_TYPE, get_type()); - } - } - return ret; - } - - OB_INLINE common::ObPrecision get_precision() const { return accuracy_.get_precision(); } - OB_INLINE common::ObScale get_scale() const - { - common::ObScale scale = accuracy_.get_scale(); - if (ob_is_integer_type(get_type())) { - scale = common::DEFAULT_SCALE_FOR_INTEGER; - } - return scale; - } - OB_INLINE common::ObScale get_mysql_compatible_scale() const - { return static_cast( - accuracy_.get_scale() == -1 ? NOT_FIXED_DEC : accuracy_.get_scale()); } - OB_INLINE bool is_column() const { return !is_literal(); } - OB_INLINE bool is_literal() const { return get_param().get_type() == get_type(); } - OB_INLINE bool is_null() const { return common::ObNullType == get_type(); } - // calc_accuracy. - OB_INLINE void set_calc_accuracy(const common::ObAccuracy &accuracy) - { - calc_accuracy_.set_accuracy(accuracy); - } - OB_INLINE void set_calc_scale(common::ObScale scale) { calc_accuracy_.set_scale(scale); } - OB_INLINE void set_extend_size(int32_t size) { calc_accuracy_.set_length(size); } - OB_INLINE void set_calc_length_semantics(const common::ObLengthSemantics value) - { - if (lib::is_oracle_mode()) { - calc_accuracy_.set_length_semantics(value); - } - } - OB_INLINE void set_calc_length(common::ObLength length) { calc_accuracy_.set_length(length); } - OB_INLINE const common::ObAccuracy &get_calc_accuracy() const { return calc_accuracy_; } - OB_INLINE common::ObScale get_calc_scale() const { return calc_accuracy_.get_scale(); } - OB_INLINE int32_t get_extend_size() const { return calc_accuracy_.get_length(); } - OB_INLINE common::ObLength get_calc_length() const { return calc_accuracy_.get_length(); } - // obj. - OB_INLINE void set_param(const common::ObObj ¶m) { param_ = param; } - OB_INLINE const common::ObObj &get_param() const { return param_; } - // compare type - OB_INLINE ObExprCalcType &get_calc_meta() { return calc_type_; } - OB_INLINE const ObExprCalcType &get_calc_meta() const { return calc_type_; } - OB_INLINE void set_calc_meta(const ObExprCalcType &meta) { calc_type_ = meta; } - - OB_INLINE common::ObIArray &get_row_calc_cmp_types() - { - return row_calc_cmp_types_; - } - OB_INLINE const common::ObIArray &get_row_calc_cmp_types() const - { - return row_calc_cmp_types_; - } - OB_INLINE bool is_not_null_for_read() const { return has_result_flag(NOT_NULL_FLAG); } - OB_INLINE bool is_not_null_for_write() const { return has_result_flag(NOT_NULL_WRITE_FLAG); } - // calc_type: 表示表达式计算时,表达式将转换成calc_type后再计算 - OB_INLINE void set_calc_type(const common::ObObjType &type) { calc_type_.set_type(type); } - OB_INLINE void set_calc_collation_utf8() - { - set_calc_collation_by_charset(common::CHARSET_UTF8MB4); - } - OB_INLINE void set_calc_type_default_varchar() - { - set_calc_type(common::ObVarcharType); - set_calc_collation_utf8(); - } - OB_INLINE void set_calc_collation_ascii_compatible() - { - if (ObCharset::is_cs_nonascii(get_collation_type())) { - set_calc_type_default_varchar(); - } - } - OB_INLINE void set_calc_collation_by_charset(common::ObCharsetType charset_type) - { - set_calc_collation_type( - common::ObCharset::get_default_collation_by_mode(charset_type, lib::is_oracle_mode())); - } - OB_INLINE common::ObObjType get_calc_type() const { return calc_type_.get_type(); } - OB_INLINE common::ObObjTypeClass get_calc_type_class() const - { - return calc_type_.get_type_class(); - } - - OB_INLINE void set_calc_collation_level(common::ObCollationLevel cs_level) - { - calc_type_.set_collation_level(cs_level); - } - OB_INLINE void set_calc_collation_type(common::ObCollationType cs_type) - { - calc_type_.set_collation_type(cs_type); - } - OB_INLINE void set_calc_collation(const ObExprResType &type) - { - calc_type_.set_collation_type(type.get_calc_collation_type()); - calc_type_.set_collation_level(type.get_calc_collation_level()); - } - OB_INLINE common::ObCollationType get_calc_collation_type() const - { - return calc_type_.get_collation_type(); - } - OB_INLINE common::ObCollationLevel get_calc_collation_level() const - { - return calc_type_.get_collation_level(); - } - OB_INLINE void set_result_flag(uint32_t flag) { res_flags_ |= flag; } - OB_INLINE void unset_result_flag(uint32_t flag) { res_flags_ &= (~flag); } - OB_INLINE bool has_result_flag(uint32_t flag) const { return res_flags_ & flag; } - OB_INLINE uint32_t get_result_flag() const { return res_flags_; } - OB_INLINE bool is_oracle_integer() const { return lib::is_oracle_mode() && is_number() - && -1 == get_accuracy().get_precision() - && 0 == get_accuracy().get_scale(); } - int init_row_dimension(int64_t count) { return row_calc_cmp_types_.init(count); } - uint64_t hash(uint64_t seed) const - { - seed = common::do_hash(type_, seed); - seed = common::do_hash(cs_level_, seed); - seed = common::do_hash(cs_type_, seed); - seed = common::do_hash(scale_, seed); - seed = common::do_hash(accuracy_, seed); - seed = common::do_hash(calc_accuracy_, seed); -// seed = common::do_hash(param_, seed); - seed = common::do_hash(calc_type_, seed); - seed = common::do_hash(res_flags_, seed); -// for (int64_t i = 0 ; i < row_calc_cmp_types_.count() ; i++) { -// seed = common::do_hash(row_calc_cmp_types_.at(i), seed); -// } - return seed; - } - // others. - INHERIT_TO_STRING_KV(N_META, - ObObjMeta, - N_ACCURACY, - accuracy_, - N_FLAG, - res_flags_, - N_CALC_TYPE, - calc_type_); -private: - common::ObAccuracy accuracy_; //当是Extend类型时,用来表示复杂数据类型的id - common::ObAccuracy calc_accuracy_; //当是Extend类型时,length字段用来表示复杂数据类型的size - common::ObObj param_; - ObExprCalcType calc_type_; - uint32_t res_flags_; // BINARY, NUM, NOT_NULL, TIMESTAMP, etc - // reference: src/lib/regex/include/mysql_com.h - //common::ObSEArray row_calc_cmp_types_; // for row compare only - common::ModulePageAllocator inner_alloc_; - common::ObFixedArray row_calc_cmp_types_; // for row compare only -}; - -typedef common::ObSEArray ObExprResTypes; -typedef common::ObIArray ObIExprResTypes; - -enum ObSubQueryKey : int8_t -{ - T_WITH_NONE, - T_WITH_ANY, - T_WITH_ALL -}; - -} -} - -#endif /* _OB_EXPR_RES_TYPE_H */ diff --git a/src/objit/include/objit/expr/ob_iraw_expr.h b/src/objit/include/objit/expr/ob_iraw_expr.h index e90a2f6d6c..ed94b404c4 100644 --- a/src/objit/include/objit/expr/ob_iraw_expr.h +++ b/src/objit/include/objit/expr/ob_iraw_expr.h @@ -17,7 +17,8 @@ #include "lib/ob_errno.h" #include "objit/common/ob_item_type.h" #include "lib/container/ob_se_array.h" -#include "objit/common/ob_expr_res_type.h" +#include "src/sql/engine/expr/ob_expr_res_type.h" + namespace oceanbase { namespace jit { namespace expr { diff --git a/src/observer/ob_uniq_task_queue.h b/src/observer/ob_uniq_task_queue.h index f8801a471c..e0651a9593 100644 --- a/src/observer/ob_uniq_task_queue.h +++ b/src/observer/ob_uniq_task_queue.h @@ -44,7 +44,7 @@ private: common::ObMemAttr attr_; }; template -struct Compare +struct CompareT { public: bool operator()(const T &a, const T &b) const @@ -164,7 +164,7 @@ private: int, common::hash::NoPthreadDefendMode, common::hash::hash_func, - Compare, + CompareT, common::hash::SimpleAllocer::AllocType, common::hash::NodeNumTraits::NODE_NUM, common::hash::NoPthreadDefendMode, ObHighPrioMemAllocator> > processing_task_map_; diff --git a/src/observer/virtual_table/ob_gv_sql_audit.h b/src/observer/virtual_table/ob_gv_sql_audit.h index fcf3f18fb0..5c0ace39e4 100644 --- a/src/observer/virtual_table/ob_gv_sql_audit.h +++ b/src/observer/virtual_table/ob_gv_sql_audit.h @@ -10,6 +10,9 @@ * See the Mulan PubL v2 for more details. */ +#ifndef OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_GV_SQL_AUDIT_ +#define OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_GV_SQL_AUDIT_ + #include "lib/container/ob_se_array.h" #include "share/ob_virtual_table_scanner_iterator.h" #include "common/ob_range.h" @@ -194,3 +197,5 @@ private: }; } } + +#endif \ No newline at end of file diff --git a/src/observer/virtual_table/ob_plan_cache_plan_explain.h b/src/observer/virtual_table/ob_plan_cache_plan_explain.h index 9b710f9c33..14651af1fc 100644 --- a/src/observer/virtual_table/ob_plan_cache_plan_explain.h +++ b/src/observer/virtual_table/ob_plan_cache_plan_explain.h @@ -10,6 +10,10 @@ * See the Mulan PubL v2 for more details. */ +#ifndef OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_PLAN_CACHE_PLAN_EXPLAIN_ +#define OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_PLAN_CACHE_PLAN_EXPLAIN_ + + #include "share/ob_virtual_table_scanner_iterator.h" #include "sql/engine/ob_operator.h" @@ -130,3 +134,5 @@ private: }; } } + +#endif \ No newline at end of file diff --git a/src/pl/ob_pl.h b/src/pl/ob_pl.h index d5fabf9cd2..98e0a02c83 100644 --- a/src/pl/ob_pl.h +++ b/src/pl/ob_pl.h @@ -21,7 +21,7 @@ #include "lib/rc/context.h" #include "lib/utility/ob_macro_utils.h" #include "lib/oblog/ob_log_module.h" -#include "objit/common/ob_expr_res_type.h" +#include "sql/engine/expr/ob_expr_res_type.h" #include "objit/ob_llvm_helper.h" #include "objit/ob_llvm_di_helper.h" #include "share/ob_errno.h" diff --git a/src/pl/parser/pl_parser_base.h b/src/pl/parser/pl_parser_base.h index 196a88d6bf..7a03121403 100644 --- a/src/pl/parser/pl_parser_base.h +++ b/src/pl/parser/pl_parser_base.h @@ -114,7 +114,7 @@ extern ParseNode *new_non_terminal_node(void *malloc_pool, ObItemType node_tag, extern int parse_sql_stmt(ParseResult *parse_result); -extern NonReservedKeyword *mysql_pl_non_reserved_keyword_lookup(const char *word); +extern const NonReservedKeyword *mysql_pl_non_reserved_keyword_lookup(const char *word); #define reset_current_location(__f_col, __l_col) \ do { \ diff --git a/src/rootserver/CMakeLists.txt b/src/rootserver/CMakeLists.txt index 5a41b02bab..e22ceb4fe9 100644 --- a/src/rootserver/CMakeLists.txt +++ b/src/rootserver/CMakeLists.txt @@ -1,18 +1,9 @@ ob_set_subtarget(ob_rootserver ALONE - ob_alter_locality_finish_checker.cpp ob_bootstrap.cpp ob_ddl_service.cpp ob_index_builder.cpp - ob_lob_piece_builder.cpp - ob_lob_meta_builder.cpp ob_root_inspection.cpp ob_root_service.cpp - ob_schema_history_recycler.cpp - ob_server_balancer.cpp - ob_system_admin_util.cpp - ob_unit_manager.cpp - ob_update_rs_list_task.cpp - ob_upgrade_storage_format_version_executor.cpp ) ob_set_subtarget(ob_rootserver backup @@ -78,6 +69,15 @@ ob_set_subtarget(ob_rootserver common ob_primary_ls_service.cpp ob_recovery_ls_service.cpp ob_tenant_role_transition_service.cpp + ob_server_balancer.cpp + ob_system_admin_util.cpp + ob_unit_manager.cpp + ob_update_rs_list_task.cpp + ob_upgrade_storage_format_version_executor.cpp + ob_schema_history_recycler.cpp + ob_alter_locality_finish_checker.cpp + ob_lob_piece_builder.cpp + ob_lob_meta_builder.cpp ) ob_set_subtarget(ob_rootserver ddl_task diff --git a/src/share/CMakeLists.txt b/src/share/CMakeLists.txt index 8f65a94967..2080ca8bde 100644 --- a/src/share/CMakeLists.txt +++ b/src/share/CMakeLists.txt @@ -7,6 +7,7 @@ ob_set_subtarget(ob_share ALONE schema/ob_sequence_sql_service.cpp schema/ob_server_schema_service.cpp schema/ob_table_schema.cpp + parameter/ob_parameter_attr.cpp ) file(GLOB SCHEMA_CPPS "inner_table/ob_inner_table_schema.*.cpp") @@ -204,7 +205,6 @@ ob_set_subtarget(ob_share common_mixed inner_table/ob_inner_table_schema.lob.cpp inner_table/ob_inner_table_schema_misc.ipp object/ob_obj_cast.cpp - parameter/ob_parameter_attr.cpp parameter/ob_parameter_seed.ipp ratelimit/ob_rl_mgr.cpp ratelimit/ob_rl_rpc.cpp diff --git a/src/share/io/ob_io_manager.cpp b/src/share/io/ob_io_manager.cpp index d2ffe60d4c..8e3c2eeb84 100644 --- a/src/share/io/ob_io_manager.cpp +++ b/src/share/io/ob_io_manager.cpp @@ -80,7 +80,7 @@ struct DestroyChannelMapFn { public: DestroyChannelMapFn(ObIAllocator &allocator) : allocator_(allocator) {} - int operator () (hash::HashMapPair &entry) { + int operator () (oceanbase::common::hash::HashMapPair &entry) { if (nullptr != entry.second) { entry.second->~ObDeviceChannel(); allocator_.free(entry.second); @@ -95,7 +95,7 @@ struct DestroyTenantMapFn { public: DestroyTenantMapFn(ObIAllocator &allocator) : allocator_(allocator) {} - int operator () (hash::HashMapPair &entry) { + int operator () (oceanbase::common::hash::HashMapPair &entry) { if (nullptr != entry.second) { entry.second->~ObTenantIOManager(); allocator_.free(entry.second); diff --git a/src/share/io/ob_io_struct.cpp b/src/share/io/ob_io_struct.cpp index 05aa809b45..8c50b8a2c0 100644 --- a/src/share/io/ob_io_struct.cpp +++ b/src/share/io/ob_io_struct.cpp @@ -721,7 +721,7 @@ struct DestroyPhyqueueMapFn { public: DestroyPhyqueueMapFn(ObIAllocator &allocator) : allocator_(allocator) {} - int operator () (hash::HashMapPair &entry) { + int operator () (oceanbase::common::hash::HashMapPair &entry) { if (nullptr != entry.second) { entry.second->~ObIOCategoryQueues(); allocator_.free(entry.second); diff --git a/src/share/ob_ddl_task_executor.cpp b/src/share/ob_ddl_task_executor.cpp index c2f2bd91b6..324c77d8ba 100644 --- a/src/share/ob_ddl_task_executor.cpp +++ b/src/share/ob_ddl_task_executor.cpp @@ -20,6 +20,10 @@ using namespace oceanbase::share; using namespace oceanbase::common; +namespace oceanbase +{ +namespace share +{ ObDDLTaskQueue::ObDDLTaskQueue() : task_list_(), task_set_(), lock_(), is_inited_(false), allocator_() { @@ -335,3 +339,6 @@ int ObDDLReplicaBuilder::push_task(ObAsyncTask &task) } return ret; } + +} // end namespace share +} // end namespace oceanbase \ No newline at end of file diff --git a/src/share/ob_upgrade_utils.cpp b/src/share/ob_upgrade_utils.cpp index 2ea47e83b9..80cc0a5322 100644 --- a/src/share/ob_upgrade_utils.cpp +++ b/src/share/ob_upgrade_utils.cpp @@ -741,6 +741,8 @@ int ObBaseUpgradeProcessor::init( return ret; } +#undef FORMAT_STR + /* =========== special upgrade processor start ============= */ /* =========== special upgrade processor end ============= */ diff --git a/src/sql/CMakeLists.txt b/src/sql/CMakeLists.txt index 2d2b90753b..bb9c66e776 100644 --- a/src/sql/CMakeLists.txt +++ b/src/sql/CMakeLists.txt @@ -1,7 +1,3 @@ -ob_set_subtarget(ob_sql ALONE - resolver/ob_resolver_utils.cpp -) - ob_set_subtarget(ob_sql code_generator code_generator/ob_code_generator.cpp code_generator/ob_column_index_provider.cpp @@ -829,6 +825,7 @@ ob_set_subtarget(ob_sql plan_cache ob_set_subtarget(ob_sql resolver resolver/ob_resolver.cpp + resolver/ob_resolver_utils.cpp resolver/ob_schema_checker.cpp resolver/ob_stmt.cpp resolver/ob_stmt_resolver.cpp diff --git a/src/sql/das/ob_das_rpc_processor.h b/src/sql/das/ob_das_rpc_processor.h index b92cea25a5..21f7db3971 100644 --- a/src/sql/das/ob_das_rpc_processor.h +++ b/src/sql/das/ob_das_rpc_processor.h @@ -20,12 +20,13 @@ #include "sql/das/ob_das_define.h" #include "sql/das/ob_das_factory.h" #include "sql/engine/ob_des_exec_context.h" + +namespace oceanbase +{ namespace observer { struct ObGlobalContext; } -namespace oceanbase -{ namespace sql { typedef obrpc::ObRpcProcessor > ObDASSyncRpcProcessor; diff --git a/src/sql/engine/cmd/ob_context_executor.cpp b/src/sql/engine/cmd/ob_context_executor.cpp index 263670ddee..765c928491 100644 --- a/src/sql/engine/cmd/ob_context_executor.cpp +++ b/src/sql/engine/cmd/ob_context_executor.cpp @@ -53,6 +53,6 @@ int name##Executor::execute(ObExecContext &ctx, name##Stmt &stmt) \ DEF_SIMPLE_EXECUTOR_IMPL(ObCreateContext, do_context_ddl); DEF_SIMPLE_EXECUTOR_IMPL(ObDropContext, do_context_ddl); -#undef DEF_EXECUTOR_IMPL +#undef DEF_SIMPLE_EXECUTOR_IMPL } // namespace sql } // namespace oceanbase diff --git a/src/sql/engine/cmd/ob_sequence_executor.cpp b/src/sql/engine/cmd/ob_sequence_executor.cpp index 6dad01ab99..c44f70a0ee 100644 --- a/src/sql/engine/cmd/ob_sequence_executor.cpp +++ b/src/sql/engine/cmd/ob_sequence_executor.cpp @@ -54,6 +54,6 @@ DEF_SIMPLE_EXECUTOR_IMPL(ObCreateSequence, do_sequence_ddl); DEF_SIMPLE_EXECUTOR_IMPL(ObAlterSequence, do_sequence_ddl); DEF_SIMPLE_EXECUTOR_IMPL(ObDropSequence, do_sequence_ddl); -#undef DEF_EXECUTOR_IMPL +#undef DEF_SIMPLE_EXECUTOR_IMPL } // namespace sql } // namespace oceanbase diff --git a/src/sql/engine/expr/ob_datum_cast.cpp b/src/sql/engine/expr/ob_datum_cast.cpp index 5297052783..631df07d5d 100644 --- a/src/sql/engine/expr/ob_datum_cast.cpp +++ b/src/sql/engine/expr/ob_datum_cast.cpp @@ -9915,6 +9915,7 @@ static_assert(ObMaxTC * 2 == sizeof(OB_DATUM_CAST_MYSQL_ENUMSET_IMPLICIT) / size REG_SER_FUNC_ARRAY(OB_SFA_DATUM_CAST_MYSQL_ENUMSET_IMPLICIT, OB_DATUM_CAST_MYSQL_ENUMSET_IMPLICIT, sizeof(OB_DATUM_CAST_MYSQL_ENUMSET_IMPLICIT) / sizeof(void *)); +#undef CAST_FAIL +#undef EVAL_ARG } // namespace sql } // namespace oceanbase -#undef EVAL_ARG diff --git a/src/sql/engine/expr/ob_expr_interval.h b/src/sql/engine/expr/ob_expr_interval.h index 654e3c2453..5a94c4d1d7 100644 --- a/src/sql/engine/expr/ob_expr_interval.h +++ b/src/sql/engine/expr/ob_expr_interval.h @@ -15,7 +15,6 @@ #include -#include "objit/common/ob_expr_res_type.h" #include "objit/common/ob_item_type.h" #include "ob_expr_operator.h" diff --git a/src/sql/engine/expr/ob_expr_json_value.cpp b/src/sql/engine/expr/ob_expr_json_value.cpp index 6cc0dabcea..4362f03c6e 100644 --- a/src/sql/engine/expr/ob_expr_json_value.cpp +++ b/src/sql/engine/expr/ob_expr_json_value.cpp @@ -1685,5 +1685,7 @@ int ObExprJsonValue::get_cast_inttc_len(ObExprResType &type1, return ret; } +#undef CAST_FAIL + } } diff --git a/src/sql/engine/expr/ob_expr_operator.h b/src/sql/engine/expr/ob_expr_operator.h index a246e2e0b3..60668f8bfd 100644 --- a/src/sql/engine/expr/ob_expr_operator.h +++ b/src/sql/engine/expr/ob_expr_operator.h @@ -30,7 +30,7 @@ #include "common/ob_accuracy.h" #include "rpc/obmysql/ob_mysql_global.h" #include "objit/common/ob_item_type.h" -#include "objit/common/ob_expr_res_type.h" +#include "sql/engine/expr/ob_expr_res_type.h" #include "sql/engine/expr/ob_expr.h" #include "sql/engine/expr/ob_expr_cmp_func.h" #include "sql/engine/expr/ob_expr_extra_info_factory.h" diff --git a/src/sql/engine/expr/ob_expr_oracle_trunc.cpp b/src/sql/engine/expr/ob_expr_oracle_trunc.cpp index 0a475a4396..1b4b79608c 100644 --- a/src/sql/engine/expr/ob_expr_oracle_trunc.cpp +++ b/src/sql/engine/expr/ob_expr_oracle_trunc.cpp @@ -342,5 +342,7 @@ int ObExprOracleTrunc::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_ex return ret; } +#undef GET_SCALE_FOR_CALC + } //namespace sql } //namespace oceanbase diff --git a/src/sql/engine/expr/ob_expr_res_type.h b/src/sql/engine/expr/ob_expr_res_type.h index 67fc0021cc..f3cc7de206 100644 --- a/src/sql/engine/expr/ob_expr_res_type.h +++ b/src/sql/engine/expr/ob_expr_res_type.h @@ -100,12 +100,33 @@ public: row_calc_cmp_types_.reset(); res_flags_ = 0; } + OB_INLINE void set_accuracy(int64_t accuracy) { accuracy_.set_accuracy(accuracy); } // accuracy. OB_INLINE void set_accuracy(const common::ObAccuracy &accuracy) { accuracy_.set_accuracy(accuracy); } OB_INLINE void set_length(const common::ObLength length) { accuracy_.set_length(length); } + OB_INLINE void set_length_within_max_length(common::ObLength length, bool is_from_pl) + { + common::ObLength max_length = length; + if (lib::is_oracle_mode()) { + if (is_varchar() || is_nvarchar2()) { + max_length = common::OB_MAX_ORACLE_VARCHAR_LENGTH; + } else if (is_char() || is_nchar()) { + max_length = is_from_pl ? common::OB_MAX_ORACLE_PL_CHAR_LENGTH_BYTE + : common::OB_MAX_ORACLE_CHAR_LENGTH_BYTE; + } + } else { + if (is_char()) { + max_length = common::OB_MAX_CHAR_LENGTH; + } else if (is_varchar()) { + max_length = common::OB_MAX_VARCHAR_LENGTH; + } + } + set_length(MIN(length, max_length)); + } + //set both length and length_semantics in case of someone forget it OB_INLINE void set_length_semantics(const common::ObLengthSemantics value) { if (lib::is_oracle_mode()) { @@ -117,12 +138,12 @@ public: set_length(length); set_length_semantics(length_semantics); } - OB_INLINE void set_precision(const common::ObPrecision precision) { accuracy_.set_precision(precision);} - OB_INLINE void set_scale(const common::ObScale scale) { accuracy_.set_scale(scale); } OB_INLINE void set_udt_id(uint64_t id) { accuracy_.set_accuracy(id); } + OB_INLINE void set_precision(const common::ObPrecision precision) { accuracy_.set_precision(precision);} + OB_INLINE void set_scale(const common::ObScale scale) { accuracy_.set_scale(scale); } OB_INLINE const common::ObAccuracy &get_accuracy() const { return accuracy_; } /* character count*/ OB_INLINE common::ObLength get_length() const @@ -144,20 +165,30 @@ public: { return accuracy_.get_length_semantics(); } + OB_INLINE uint64_t get_udt_id() const + { + return accuracy_.get_accuracy(); + } /* meta info for client */ OB_INLINE int get_length_for_meta_in_bytes(common::ObLength &length) const { int ret = common::OB_SUCCESS; length = -1; - if (common::ObStringTC == ob_obj_type_class(get_type()) - && common::is_oracle_byte_length(lib::is_oracle_mode(), get_accuracy().get_length_semantics())) { - length = get_accuracy().get_length(); - } else if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), - get_accuracy(), - get_collation_type(), - length))) { - SQL_RESV_LOG(WARN, "failed to get length of varchar", K(ret)); + if (is_string_or_lob_locator_type() || is_enum_or_set() || is_enumset_inner_type() || is_json()) { + if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), + get_accuracy(), + get_collation_type(), + length))) { + SQL_RESV_LOG(WARN, "failed to get length of varchar", K(ret)); + } + } else { + if (OB_FAIL(common::ObField::get_field_mb_length(get_type(), + get_accuracy(), + common::CS_TYPE_INVALID, + length))) { + SQL_RESV_LOG(WARN, "failed to get length of non-varchar", K(ret), K(common::lbt()), N_TYPE, get_type()); + } } return ret; } @@ -177,10 +208,7 @@ public: ? (lib::is_oracle_mode() ? ORACLE_NOT_FIXED_DEC : NOT_FIXED_DEC) : accuracy_.get_scale()); } - OB_INLINE uint64_t get_udt_id() const - { - return accuracy_.get_accuracy(); - } + OB_INLINE bool is_column() const { return !is_literal(); } OB_INLINE bool is_literal() const { return get_param().get_type() == get_type(); } OB_INLINE bool is_null() const { return common::ObNullType == get_type(); } @@ -188,17 +216,24 @@ public: { return is_varbinary() && 0 == get_length(); } OB_INLINE bool is_oracle_question_mark_type() const { return is_char() && common::ObAccuracy::PS_QUESTION_MARK_DEDUCE_LEN == get_length(); } - OB_INLINE bool is_oracle_integer() const { return lib::is_oracle_mode() && is_number() - && -1 == get_accuracy().get_precision() - && 0 == get_accuracy().get_scale(); } // calc_accuracy. OB_INLINE void set_calc_accuracy(const common::ObAccuracy &accuracy) { calc_accuracy_.set_accuracy(accuracy); } OB_INLINE void set_calc_scale(common::ObScale scale) { calc_accuracy_.set_scale(scale); } + OB_INLINE void set_extend_size(int32_t size) { calc_accuracy_.set_length(size); } + OB_INLINE void set_calc_length_semantics(const common::ObLengthSemantics value) + { + if (lib::is_oracle_mode()) { + calc_accuracy_.set_length_semantics(value); + } + } + OB_INLINE void set_calc_length(common::ObLength length) { calc_accuracy_.set_length(length); } OB_INLINE const common::ObAccuracy &get_calc_accuracy() const { return calc_accuracy_; } OB_INLINE common::ObScale get_calc_scale() const { return calc_accuracy_.get_scale(); } + OB_INLINE int32_t get_extend_size() const { return calc_accuracy_.get_length(); } + OB_INLINE common::ObLength get_calc_length() const { return calc_accuracy_.get_length(); } // obj. OB_INLINE void set_param(const common::ObObj ¶m) { param_ = param; } OB_INLINE const common::ObObj &get_param() const { return param_; } @@ -219,6 +254,26 @@ public: OB_INLINE bool is_not_null_for_write() const { return has_result_flag(NOT_NULL_WRITE_FLAG); } // calc_type: 表示表达式计算时,表达式将转换成calc_type后再计算 OB_INLINE void set_calc_type(const common::ObObjType &type) { calc_type_.set_type(type); } + OB_INLINE void set_calc_collation_utf8() + { + set_calc_collation_by_charset(common::CHARSET_UTF8MB4); + } + OB_INLINE void set_calc_type_default_varchar() + { + set_calc_type(common::ObVarcharType); + set_calc_collation_utf8(); + } + OB_INLINE void set_calc_collation_ascii_compatible() + { + if (ObCharset::is_cs_nonascii(get_collation_type())) { + set_calc_type_default_varchar(); + } + } + OB_INLINE void set_calc_collation_by_charset(common::ObCharsetType charset_type) + { + set_calc_collation_type( + common::ObCharset::get_default_collation_by_mode(charset_type, lib::is_oracle_mode())); + } OB_INLINE common::ObObjType get_calc_type() const { return calc_type_.get_type(); } OB_INLINE common::ObObjTypeClass get_calc_type_class() const { @@ -250,6 +305,9 @@ public: OB_INLINE void unset_result_flag(uint32_t flag) { res_flags_ &= (~flag); } OB_INLINE bool has_result_flag(uint32_t flag) const { return res_flags_ & flag; } OB_INLINE uint32_t get_result_flag() const { return res_flags_; } + OB_INLINE bool is_oracle_integer() const { return lib::is_oracle_mode() && is_number() + && -1 == get_accuracy().get_precision() + && 0 == get_accuracy().get_scale(); } int init_row_dimension(int64_t count) { return row_calc_cmp_types_.init(count); } uint64_t hash(uint64_t seed) const { @@ -277,8 +335,8 @@ public: N_CALC_TYPE, calc_type_); private: - common::ObAccuracy accuracy_; - common::ObAccuracy calc_accuracy_; + common::ObAccuracy accuracy_; //当是Extend类型时,用来表示复杂数据类型的id + common::ObAccuracy calc_accuracy_; //当是Extend类型时,length字段用来表示复杂数据类型的size common::ObObj param_; ObExprCalcType calc_type_; uint32_t res_flags_; // BINARY, NUM, NOT_NULL, TIMESTAMP, etc diff --git a/src/sql/engine/expr/ob_expr_result_type_util.cpp b/src/sql/engine/expr/ob_expr_result_type_util.cpp index 9b09bb3a76..d3b9224b4f 100644 --- a/src/sql/engine/expr/ob_expr_result_type_util.cpp +++ b/src/sql/engine/expr/ob_expr_result_type_util.cpp @@ -40,7 +40,7 @@ using namespace share; namespace sql { -const int64_t MAX_NUMBER_BUFFER_SIZE = 40; +const int64_t MAX_NUMBER_BUFFER_SIZE_IN_TYPE_UTIL = 40; using ArithOp = ObArithResultTypeMap::OP; int ObExprResultTypeUtil::get_relational_cmp_type(ObExprResType &res_type, @@ -761,7 +761,7 @@ int ObExprResultTypeUtil::deduce_max_string_length_oracle(const ObDataTypeCastPa if (orig_type.is_null()) { // do nothing } else if (orig_type.is_numeric_type()) { - ascii_bytes = MAX_NUMBER_BUFFER_SIZE; + ascii_bytes = MAX_NUMBER_BUFFER_SIZE_IN_TYPE_UTIL; } else if (orig_type.is_datetime() || orig_type.is_otimestamp_type()) { // deduce by format diff --git a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp index e0cf00c429..c5c24fceb4 100644 --- a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp +++ b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp @@ -292,6 +292,6 @@ int ObExprToOutfileRow::copy_string_to_buf(char *buf, const int64_t buf_len, int { return databuff_memcpy(buf, buf_len, pos, str.length(), str.ptr()); } - -} -} + +} +} diff --git a/src/sql/engine/expr/ob_expr_truncate.cpp b/src/sql/engine/expr/ob_expr_truncate.cpp index ee5cabdbf9..c655d3c1ff 100644 --- a/src/sql/engine/expr/ob_expr_truncate.cpp +++ b/src/sql/engine/expr/ob_expr_truncate.cpp @@ -305,3 +305,8 @@ int ObExprTruncate::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr, } } // namespace sql } // namespace oceanbase + +#undef GET_SCALE_FOR_CALC +#undef GET_SCALE_FOR_CALC_ORACLE +#undef GET_SCALE_FOR_DEDUCE +#undef GET_SCALE_FOR_DEDUCE_ORACLE diff --git a/src/sql/engine/expr/ob_expr_width_bucket.h b/src/sql/engine/expr/ob_expr_width_bucket.h index 52e986dc17..c922d50185 100644 --- a/src/sql/engine/expr/ob_expr_width_bucket.h +++ b/src/sql/engine/expr/ob_expr_width_bucket.h @@ -15,7 +15,7 @@ #include -#include "objit/common/ob_expr_res_type.h" +#include "sql/engine/expr/ob_expr_res_type.h" #include "objit/common/ob_item_type.h" #include "ob_expr_operator.h" diff --git a/src/sql/engine/expr/ob_number_format_models.cpp b/src/sql/engine/expr/ob_number_format_models.cpp index 8524c7b457..9a8c581aeb 100644 --- a/src/sql/engine/expr/ob_number_format_models.cpp +++ b/src/sql/engine/expr/ob_number_format_models.cpp @@ -22,7 +22,7 @@ namespace oceanbase { namespace sql { -const int64_t MAX_TO_CHAR_BUFFER_SIZE = 256; +const int64_t MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS= 256; const ObNFMKeyWord ObNFMElem::NFM_KEYWORDS[MAX_TYPE_NUMBER] = { @@ -1434,7 +1434,7 @@ int ObNFMBase::cast_obj_to_num_str(const ObNFMObj &nfm_obj, int64_t num_str_len = 0; number::ObNumber nmb; char *num_str_buf = NULL; - const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; ObObjType obj_type = nfm_obj.get_obj_type(); if (OB_ISNULL(num_str_buf = static_cast( allocator_.alloc(alloc_size)))) { @@ -1689,7 +1689,7 @@ int ObNFMToChar::process_mul_format(const ObNFMObj &nfm_obj, common::ObString &n int64_t origin_str_len = 0; char *origin_str_buf = NULL; int64_t exponent = fmt_desc_.multi_; - const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; if (OB_ISNULL(origin_str_buf = static_cast( allocator_.alloc(alloc_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -1764,7 +1764,7 @@ int ObNFMToChar::process_tm_format(const ObNFMObj &nfm_obj, char *buf, char *num_str_buf = NULL; ObString num_str; const int32_t scale = -1; - const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; if (OB_ISNULL(num_str_buf = static_cast( allocator_.alloc(alloc_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -1816,7 +1816,7 @@ int ObNFMToChar::process_tme_format(const ObNFMObj &nfm_obj, char *buf, char *num_str_buf = NULL; ObString num_str; const int32_t scale = -1; - const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; if (OB_ISNULL(num_str_buf = static_cast( allocator_.alloc(alloc_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -1860,7 +1860,7 @@ int ObNFMToChar::process_sci_format(const common::ObString &origin_str, const in int ret = OB_SUCCESS; int64_t sci_str_len = 0; char *sci_str_buf = NULL; - const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t alloc_size = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; if (fmt_desc_.pre_num_count_ < 1) { ret = OB_ERR_INVALID_NUMBER_FORMAT_MODEL; LOG_WARN("invalid number fmt model", K_(fmt_str)); @@ -2224,7 +2224,7 @@ int ObNFMToChar::convert_num_to_fmt_str(const ObObj &obj, char *res_buf = NULL; ObNFMObj nfm_obj; ObSQLSessionInfo *session = expr_ctx.my_session_; - const int64_t res_buf_len = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t res_buf_len = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; if (OB_ISNULL(fmt_str) || OB_ISNULL(expr_ctx.calc_buf_) || OB_ISNULL(session)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("Invalid argument", K(ret), K(fmt_str), K(expr_ctx.calc_buf_), @@ -2278,7 +2278,7 @@ int ObNFMToChar::convert_num_to_fmt_str(const common::ObObjMeta &obj_meta, int64_t offset = 0; char *res_buf = NULL; ObNFMObj nfm_obj; - const int64_t res_buf_len = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t res_buf_len = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); if (OB_ISNULL(fmt_str) || OB_ISNULL(session)) { ret = OB_INVALID_ARGUMENT; @@ -2392,7 +2392,7 @@ int ObNFMToNumber::process_output_fmt(const ObString &in_str, int64_t offset = 0; bool is_negative = false; char *buf = NULL; - const int64_t buf_len = MAX_TO_CHAR_BUFFER_SIZE; + const int64_t buf_len = MAX_TO_CHAR_BUFFER_SIZE_IN_FORMAT_MODELS; // skip leading spaces while (str_pos < str_len && ' ' == str[str_pos]) { ++str_pos; diff --git a/src/sql/engine/user_defined_function/ob_udf_util.h b/src/sql/engine/user_defined_function/ob_udf_util.h index f00cae9b00..76652d5b50 100644 --- a/src/sql/engine/user_defined_function/ob_udf_util.h +++ b/src/sql/engine/user_defined_function/ob_udf_util.h @@ -19,8 +19,7 @@ #include "sql/engine/user_defined_function/ob_udf_registration_types.h" #include "sql/engine/expr/ob_expr.h" #include "rpc/obmysql/ob_mysql_global.h" -#include "objit/common/ob_expr_res_type.h" -//#include "common/expression/ob_i_sql_expression.h" +#include "sql/engine/expr/ob_expr_res_type.h" namespace oceanbase { diff --git a/src/sql/engine/user_defined_function/ob_user_defined_function.h b/src/sql/engine/user_defined_function/ob_user_defined_function.h index 32d74d9cf4..f44fdddfd2 100644 --- a/src/sql/engine/user_defined_function/ob_user_defined_function.h +++ b/src/sql/engine/user_defined_function/ob_user_defined_function.h @@ -15,8 +15,7 @@ #include "ob_udf_registration_types.h" #include "share/schema/ob_udf.h" -/* 是不是不应该依赖objit里面的头文件?*/ -#include "objit/common/ob_expr_res_type.h" +#include "sql/engine/expr/ob_expr_res_type.h" #include "sql/engine/expr/ob_expr.h" diff --git a/src/sql/executor/ob_remote_executor_processor.h b/src/sql/executor/ob_remote_executor_processor.h index 8e286a3b78..1b24d00c3e 100644 --- a/src/sql/executor/ob_remote_executor_processor.h +++ b/src/sql/executor/ob_remote_executor_processor.h @@ -14,12 +14,13 @@ #define OBDEV_SRC_SQL_EXECUTOR_OB_REMOTE_EXECUTOR_PROCESSOR_H_ #include "sql/executor/ob_executor_rpc_processor.h" #include "sql/plan_cache/ob_cache_object_factory.h" + +namespace oceanbase +{ namespace observer { struct ObGlobalContext; } -namespace oceanbase -{ namespace sql { template diff --git a/src/sql/executor/ob_task_info.cpp b/src/sql/executor/ob_task_info.cpp index d509633c56..d7f23b3fcf 100644 --- a/src/sql/executor/ob_task_info.cpp +++ b/src/sql/executor/ob_task_info.cpp @@ -19,6 +19,10 @@ using namespace oceanbase::common; using namespace oceanbase::sql; +namespace oceanbase +{ +namespace sql +{ ObTaskInfo::ObTaskInfo(common::ObIAllocator &allocator) : range_location_(allocator), task_split_type_(ObTaskSpliter::INVALID_SPLIT), @@ -88,3 +92,5 @@ int ObTaskInfo::ObRangeLocation::assign(const ObTaskInfo::ObRangeLocation &range return ret; } +} +} diff --git a/src/sql/resolver/expr/ob_raw_expr.h b/src/sql/resolver/expr/ob_raw_expr.h index d7e27d0a61..537f78f1e4 100644 --- a/src/sql/resolver/expr/ob_raw_expr.h +++ b/src/sql/resolver/expr/ob_raw_expr.h @@ -27,7 +27,7 @@ #include "objit/expr/ob_op_expr.h" #include "objit/expr/ob_column_ref_expr.h" #include "objit/expr/ob_case_op_expr.h" -#include "objit/common/ob_expr_res_type.h" +#include "sql/engine/expr/ob_expr_res_type.h" #include "share/schema/ob_schema_utils.h" #include "sql/ob_sql_define.h" #include "sql/resolver/expr/ob_expr_info_flag.h" diff --git a/src/sql/resolver/ob_schema_checker.cpp b/src/sql/resolver/ob_schema_checker.cpp index df531d2e3b..0a5e642786 100644 --- a/src/sql/resolver/ob_schema_checker.cpp +++ b/src/sql/resolver/ob_schema_checker.cpp @@ -1385,7 +1385,7 @@ int ObSchemaChecker::get_routine_infos_in_udt(const uint64_t tenant_id, int ObSchemaChecker::get_package_info(const uint64_t tenant_id, const ObString &database_name, const ObString &package_name, - const ObPackageType type, + const share::schema::ObPackageType type, const int64_t compatible_mode, const ObPackageInfo *&package_info) { diff --git a/src/sql/rewrite/ob_key_part.h b/src/sql/rewrite/ob_key_part.h index f12c9dab16..e43eac5499 100644 --- a/src/sql/rewrite/ob_key_part.h +++ b/src/sql/rewrite/ob_key_part.h @@ -18,7 +18,6 @@ #include "lib/container/ob_array_serialization.h" #include "common/object/ob_object.h" #include "sql/engine/expr/ob_expr_res_type.h" -#include "objit/common/ob_expr_res_type.h" namespace oceanbase { diff --git a/src/storage/ob_dml_running_ctx.h b/src/storage/ob_dml_running_ctx.h index 6e585f69fc..ea378f2875 100644 --- a/src/storage/ob_dml_running_ctx.h +++ b/src/storage/ob_dml_running_ctx.h @@ -22,7 +22,6 @@ namespace oceanbase namespace common { class ObIAllocator; -class ColumnMap; } namespace share diff --git a/src/storage/tablelock/ob_table_lock_iterator.cpp b/src/storage/tablelock/ob_table_lock_iterator.cpp index 7d5949ec59..1532f8a254 100644 --- a/src/storage/tablelock/ob_table_lock_iterator.cpp +++ b/src/storage/tablelock/ob_table_lock_iterator.cpp @@ -51,7 +51,7 @@ int ObTableLockScanIterator::inner_get_next_row(const blocksstable::ObDatumRow * int64_t pos = 0; if (OB_SUCC(ret)) { - ObTableLockOp &store_info = table_lock_store_info_[idx_]; + transaction::tablelock::ObTableLockOp &store_info = table_lock_store_info_[idx_]; int64_t serialize_size = store_info.get_serialize_size(); if (OB_FAIL(buf_.reserve(serialize_size))) { diff --git a/src/storage/tablelock/ob_table_lock_iterator.h b/src/storage/tablelock/ob_table_lock_iterator.h index 7b31079cd1..60a9712875 100644 --- a/src/storage/tablelock/ob_table_lock_iterator.h +++ b/src/storage/tablelock/ob_table_lock_iterator.h @@ -102,7 +102,7 @@ private: blocksstable::ObDatumRow row_; ObTableLockBuffer buf_; int64_t idx_; - ObSEArray table_lock_store_info_; + ObSEArray table_lock_store_info_; bool is_inited_; };