From c157309bc6b6db9addbb02cd7663f5a0044231fd Mon Sep 17 00:00:00 2001 From: xuhuleon Date: Tue, 7 Feb 2023 00:40:01 +0800 Subject: [PATCH] add -Wshorten-64-to-32 for share --- deps/oblib/src/common/object/ob_obj_funcs.h | 12 +- deps/oblib/src/common/object/ob_object.h | 2 +- .../src/common/storage/ob_fd_simulator.cpp | 6 +- deps/oblib/src/lib/alloc/abit_set.h | 4 +- deps/oblib/src/lib/alloc/alloc_struct.h | 1 + .../src/lib/allocator/ob_lf_fifo_allocator.h | 7 +- .../src/lib/allocator/ob_small_allocator.h | 5 +- .../oblib/src/lib/allocator/ob_vslice_alloc.h | 4 +- deps/oblib/src/lib/allocator/page_arena.h | 8 +- .../src/lib/ash/ob_active_session_guard.h | 2 +- deps/oblib/src/lib/charset/ob_charset.cpp | 6 +- deps/oblib/src/lib/charset/ob_charset.h | 2 +- .../compress/lz4/ob_lz4_stream_compressor.cpp | 13 +- .../lz4/ob_lz4_stream_compressor_191.cpp | 13 +- .../lib/compress/zlib/ob_zlib_compressor.cpp | 2 +- .../src/lib/geo/ob_geo_to_wkt_visitor.cpp | 4 +- deps/oblib/src/lib/geo/ob_geo_tree.h | 4 +- deps/oblib/src/lib/json_type/ob_json_bin.h | 10 +- deps/oblib/src/lib/json_type/ob_json_tree.h | 8 +- deps/oblib/src/lib/lock/ob_drw_lock.h | 2 +- deps/oblib/src/lib/lock/ob_tc_rwlock.h | 2 +- deps/oblib/src/lib/number/ob_number_v2.cpp | 2 +- deps/oblib/src/lib/number/ob_number_v2.h | 30 ++--- deps/oblib/src/lib/ob_define.h | 4 +- .../lib/objectpool/ob_concurrency_objpool.h | 2 +- .../lib/objectpool/ob_server_object_pool.h | 6 +- deps/oblib/src/lib/oblog/ob_log.cpp | 2 +- deps/oblib/src/lib/oblog/ob_log.h | 2 +- deps/oblib/src/lib/oblog/ob_log_print_kv.h | 2 +- .../src/lib/oblog/ob_syslog_rate_limiter.h | 4 +- deps/oblib/src/lib/queue/ob_dedup_queue.cpp | 2 +- deps/oblib/src/lib/queue/ob_dedup_queue.h | 6 +- deps/oblib/src/lib/string/ob_string.h | 34 +++++ deps/oblib/src/lib/thread/thread_mgr.h | 10 +- .../oblib/src/lib/timezone/ob_timezone_info.h | 2 +- deps/oblib/src/lib/utility/serialization.h | 8 +- deps/oblib/src/lib/utility/utility.h | 25 +--- deps/oblib/src/rpc/frame/ob_net_easy.cpp | 19 +-- deps/oblib/src/rpc/frame/ob_req_transport.h | 2 +- .../src/rpc/obmysql/packet/ompk_error.cpp | 2 +- deps/oblib/src/rpc/obrpc/ob_listener.cpp | 4 +- deps/oblib/src/rpc/obrpc/ob_rpc_proxy.cpp | 2 +- deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h | 2 +- .../oblib/unittest/lib/thread/test_tg_mgr.cpp | 1 + .../storage/blocksstable/test_block_cache.cpp | 2 +- .../test_index_block_row_scanner.cpp | 2 +- .../test_index_block_row_struct.cpp | 2 +- .../test_index_block_tree_cursor.cpp | 2 +- .../storage/blocksstable/test_index_tree.cpp | 2 +- .../blocksstable/test_shared_macro_block.cpp | 4 +- .../blocksstable/test_sstable_row_exister.cpp | 2 +- .../rewrite_function_for_test_big_tx_data.cpp | 4 +- src/logservice/cdcservice/ob_cdc_service.cpp | 2 +- src/logservice/libobcdc/src/ob_log_utils.cpp | 2 +- src/observer/mysql/ob_query_driver.cpp | 2 +- src/observer/ob_srv_network_frame.cpp | 3 +- src/observer/ob_srv_network_frame.h | 2 +- src/observer/omt/ob_tenant_srs.h | 4 +- src/pl/ob_pl.h | 2 +- src/pl/ob_pl_stmt.h | 2 +- src/pl/ob_pl_user_type.h | 2 +- src/pl/sys_package/ob_dbms_sql.h | 2 +- src/rootserver/ob_root_service.cpp | 2 +- src/share/CMakeLists.txt | 1 + src/share/backup/ob_archive_store.cpp | 8 +- src/share/backup/ob_backup_connectivity.cpp | 4 +- .../backup/ob_backup_data_table_operator.cpp | 2 +- src/share/backup/ob_backup_struct.cpp | 32 ++--- src/share/backup/ob_backup_struct.h | 6 +- src/share/cache/ob_kvcache_struct.cpp | 11 +- src/share/config/ob_common_config.cpp | 2 +- src/share/config/ob_config.cpp | 8 +- src/share/datum/ob_datum.h | 25 ++-- .../ob_deadlock_detector_common_define.cpp | 2 +- src/share/deadlock/ob_deadlock_detector_rpc.h | 5 +- .../deadlock/ob_deadlock_key_wrapper.cpp | 2 +- .../ob_lcl_batch_sender_thread.cpp | 2 +- src/share/io/ob_io_define.cpp | 4 +- src/share/io/ob_io_struct.cpp | 6 +- src/share/io/ob_io_struct.h | 2 +- .../location_cache/ob_ls_location_service.cpp | 2 +- src/share/ls/ob_ls_status_operator.cpp | 4 +- src/share/ob_bg_thread_monitor.cpp | 2 +- src/share/ob_cluster_version.cpp | 4 +- src/share/ob_ddl_common.cpp | 2 +- src/share/ob_encryption_struct.h | 4 +- src/share/ob_encryption_util.cpp | 2 +- src/share/ob_lob_access_utils.cpp | 32 ++--- src/share/ob_local_device.cpp | 28 ++--- src/share/ob_occam_thread_pool.h | 2 +- src/share/ob_occam_time_guard.h | 9 +- src/share/ob_order_perserving_encoder.cpp | 2 +- .../ob_tablet_replica_checksum_operator.cpp | 8 +- src/share/ob_task_define.cpp | 4 +- src/share/ob_tenant_mgr.cpp | 2 +- src/share/ob_thread_mgr.h | 2 +- src/share/object/ob_obj_cast.cpp | 28 ++--- src/share/ratelimit/ob_rl_mgr.cpp | 6 +- src/share/ratelimit/ob_rl_mgr.h | 6 +- src/share/rc/ob_tenant_base.h | 4 +- src/share/redolog/ob_log_file_handler.cpp | 6 +- src/share/redolog/ob_log_file_reader.cpp | 2 +- src/share/resource_manager/ob_cgroup_ctrl.cpp | 12 +- .../restore/ob_physical_restore_info.cpp | 4 +- .../restore/ob_restore_persist_helper.cpp | 4 +- src/share/scheduler/ob_dag_scheduler.cpp | 26 ++-- src/share/scheduler/ob_dag_scheduler.h | 30 ++--- src/share/schema/ob_column_schema.h | 1 + .../ob_multi_version_schema_service.cpp | 8 +- src/share/schema/ob_partition_sql_helper.cpp | 4 +- src/share/schema/ob_schema_macro_define.cpp | 9 +- src/share/schema/ob_schema_mgr_cache.cpp | 2 +- src/share/schema/ob_schema_retrieve_utils.ipp | 2 +- src/share/schema/ob_schema_struct.cpp | 22 +--- src/share/schema/ob_schema_struct.h | 6 +- src/share/schema/ob_server_schema_service.cpp | 2 +- src/share/schema/ob_table_dml_param.cpp | 10 +- src/share/schema/ob_table_param.cpp | 8 +- src/share/schema/ob_table_schema.cpp | 16 +-- src/share/schema/ob_table_schema.h | 2 +- .../stat/ob_dbms_stats_export_import.cpp | 2 +- src/share/stat/ob_dbms_stats_lock_unlock.cpp | 4 +- src/share/stat/ob_dbms_stats_preferences.cpp | 4 +- src/share/stat/ob_index_stats_estimator.cpp | 6 +- src/share/stat/ob_opt_stat_sql_service.cpp | 2 +- src/share/stat/ob_stats_estimator.cpp | 4 +- src/share/table/ob_table_load_define.h | 6 +- src/share/tablet/ob_tablet_table_operator.cpp | 1 - .../code_generator/ob_static_engine_expr_cg.h | 4 +- src/sql/dblink/ob_dblink_utils.h | 4 +- src/sql/dtl/ob_dtl_interm_result_manager.h | 2 +- .../aggregate/ob_aggregate_function.cpp | 2 +- .../aggregate/ob_aggregate_processor.cpp | 6 +- .../engine/aggregate/ob_aggregate_processor.h | 6 +- src/sql/engine/basic/ob_chunk_datum_store.h | 15 ++- src/sql/engine/expr/ob_datum_cast.cpp | 8 +- src/sql/engine/expr/ob_expr.h | 2 +- src/sql/engine/expr/ob_expr_inet.cpp | 4 +- .../engine/expr/ob_expr_oracle_to_char.cpp | 8 +- src/sql/engine/expr/ob_expr_sys_context.cpp | 2 +- src/sql/engine/expr/ob_expr_udf.h | 2 +- src/sql/engine/expr/ob_expr_userenv.cpp | 2 +- src/sql/engine/expr/ob_expr_util.cpp | 2 +- .../engine/expr/ob_number_format_models.cpp | 8 +- src/sql/engine/expr/ob_sql_expression.h | 1 - src/sql/engine/ob_operator.h | 6 +- src/sql/engine/ob_tenant_sql_memory_manager.h | 3 +- src/sql/monitor/flt/ob_flt_span_mgr.h | 2 +- src/sql/monitor/flt/ob_flt_utils.cpp | 4 +- src/sql/ob_sql_utils.cpp | 2 +- src/sql/optimizer/ob_join_order.h | 2 +- src/sql/parser/sql_parser_base.c | 5 +- src/sql/plan_cache/ob_plan_cache_struct.h | 16 --- src/sql/resolver/dml/ob_dml_stmt.h | 2 +- src/sql/resolver/dml/ob_stmt_expr_visitor.h | 4 +- src/sql/session/ob_basic_session_info.h | 6 +- .../blocksstable/ob_bloom_filter_cache.h | 2 +- src/storage/blocksstable/ob_datum_row.h | 4 +- .../blocksstable/ob_micro_block_header.h | 4 +- src/storage/blocksstable/ob_tmp_file.h | 1 - .../compaction/ob_compaction_diagnose.h | 2 +- .../ob_partition_parallel_merge_ctx.cpp | 4 +- src/storage/lob/ob_lob_util.h | 2 +- src/storage/ob_i_store.h | 12 +- src/storage/tx/ob_trans_define.h | 119 +----------------- src/storage/tx/ob_trans_define_v4.h | 2 +- src/storage/tx/ob_trans_log.h | 39 ------ src/storage/tx/ob_trans_timer.h | 2 +- 168 files changed, 502 insertions(+), 636 deletions(-) diff --git a/deps/oblib/src/common/object/ob_obj_funcs.h b/deps/oblib/src/common/object/ob_obj_funcs.h index 92539170b6..3a11d0ff53 100644 --- a/deps/oblib/src/common/object/ob_obj_funcs.h +++ b/deps/oblib/src/common/object/ob_obj_funcs.h @@ -384,10 +384,10 @@ template <> UNUSED(params); \ int64_t print_len = 0;\ if (IS_DOUBLE) {\ - print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, length - pos , buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(length - pos) , buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ } else {\ - print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, length - pos, buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(length - pos), buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ }\ if (OB_UNLIKELY(print_len <=0 || print_len + pos > length)) {\ @@ -418,10 +418,10 @@ template <> } else { \ buffer[pos++] = '\''; \ if (IS_DOUBLE) {\ - print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, length - pos , buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(length - pos), buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ } else {\ - print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, length - pos, buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(length - pos), buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ }\ if (OB_UNLIKELY(print_len <= 0 || print_len + pos > length)) {\ @@ -457,10 +457,10 @@ template <> UNUSED(params); \ int64_t print_len = 0;\ if (IS_DOUBLE) {\ - print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, length - pos , buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(length - pos), buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ } else {\ - print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, length - pos, buffer + pos, \ + print_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(length - pos), buffer + pos, \ NULL, lib::is_oracle_mode(), TRUE);\ }\ if (OB_UNLIKELY(print_len <=0 || print_len + pos > length)) {\ diff --git a/deps/oblib/src/common/object/ob_object.h b/deps/oblib/src/common/object/ob_object.h index a1c1ac2984..6d0c9c81ff 100644 --- a/deps/oblib/src/common/object/ob_object.h +++ b/deps/oblib/src/common/object/ob_object.h @@ -747,7 +747,7 @@ struct ObMemLobExternHeader rowkey_size_(rowkey_size), payload_offset_(0), payload_size_(0) {} - ObMemLobExternHeader(uint64_t table_id, uint64_t column_idx, uint16_t rowkey_size, + ObMemLobExternHeader(uint64_t table_id, uint32_t column_idx, uint16_t rowkey_size, uint32_t payload_offset, uint32_t payload_size) : reserved_(0), table_id_(table_id), column_idx_(column_idx), flags_(), rowkey_size_(rowkey_size), diff --git a/deps/oblib/src/common/storage/ob_fd_simulator.cpp b/deps/oblib/src/common/storage/ob_fd_simulator.cpp index 865dc00564..34228ccd39 100644 --- a/deps/oblib/src/common/storage/ob_fd_simulator.cpp +++ b/deps/oblib/src/common/storage/ob_fd_simulator.cpp @@ -132,13 +132,13 @@ int try_get_fd_inner(ObFdSimulator::FirstArray* first_array, int32_t second_arra { int ret = OB_SUCCESS; int i = 0; - int32_t free_id = ObFdSimulator::INVALID_SLOT_ID; + int64_t free_id = ObFdSimulator::INVALID_SLOT_ID; ObFdSimulator::FdSlot *second_array_p = NULL; for (; i < second_array_num; i++) { free_id = first_array[i].second_array_free_hd; second_array_p = first_array[i].second_array_p; if (free_id != ObFdSimulator::INVALID_SLOT_ID) { - int32_t next_free_id = second_array_p[free_id].pointer.index_id; + int64_t next_free_id = second_array_p[free_id].pointer.index_id; ob_sim_fd_id sim_fd; sim_fd.sim_id_.first_pos_ = i; sim_fd.sim_id_.second_pos_ = free_id; @@ -314,4 +314,4 @@ int ObFdSimulator::release_fd(const ObIOFd& fd) } -} \ No newline at end of file +} diff --git a/deps/oblib/src/lib/alloc/abit_set.h b/deps/oblib/src/lib/alloc/abit_set.h index 612bb5812f..599c285c0c 100644 --- a/deps/oblib/src/lib/alloc/abit_set.h +++ b/deps/oblib/src/lib/alloc/abit_set.h @@ -33,12 +33,12 @@ public: static constexpr int32_t n_second_level(int64_t nbits) { - return ((nbits - 1) >> 6) + 1; + return static_cast(((nbits - 1) >> 6) + 1); } static constexpr int32_t n_first_level(int64_t nbits) { - return ((n_second_level(nbits) - 1) >> 6) + 1; + return static_cast(((n_second_level(nbits) - 1) >> 6) + 1); } static constexpr int64_t buf_len(int64_t nbits) diff --git a/deps/oblib/src/lib/alloc/alloc_struct.h b/deps/oblib/src/lib/alloc/alloc_struct.h index fb0f2a585e..9a940dfbc5 100644 --- a/deps/oblib/src/lib/alloc/alloc_struct.h +++ b/deps/oblib/src/lib/alloc/alloc_struct.h @@ -417,6 +417,7 @@ char *AChunk::blk_data(const ABlock *block) const ABlock::ABlock() : MAGIC_CODE_(ABLOCK_MAGIC_CODE), alloc_bytes_(0), + ablock_size_(0), obj_set_(NULL), mem_context_(0), prev_(this), next_(this) {} diff --git a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h index c9d68acd19..08c540d792 100644 --- a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h @@ -37,8 +37,11 @@ public: mattr_.tenant_id_ = tenant_id; block_alloc_.set_limit(total_limit); if (OB_FAIL(ObVSliceAlloc::init(page_size, block_alloc_, mattr_))) { - } else{ - ObVSliceAlloc::set_nway(cache_page_count); + } else if (cache_page_count < 0 || cache_page_count > INT32_MAX) { + ret = OB_INVALID_ARGUMENT; + LIB_ALLOC_LOG(ERROR, "invalid cache_page_count", K(ret), K(cache_page_count)); + } else{ + ObVSliceAlloc::set_nway(static_cast(cache_page_count)); } return ret; } diff --git a/deps/oblib/src/lib/allocator/ob_small_allocator.h b/deps/oblib/src/lib/allocator/ob_small_allocator.h index d84616348d..801f7a6b9f 100644 --- a/deps/oblib/src/lib/allocator/ob_small_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_small_allocator.h @@ -39,7 +39,10 @@ public: if (limit_num < INT64_MAX) { block_alloc_.set_limit(limit_num * obj_size); } - if (OB_FAIL(ObSliceAlloc::init(obj_size, block_size, block_alloc_, attr_))) { + if (obj_size < 0 || obj_size > INT32_MAX || block_size < 0 || block_size > INT32_MAX) { + ret = OB_INVALID_ARGUMENT; + } else if (OB_FAIL(ObSliceAlloc::init(static_cast(obj_size), + static_cast(block_size), block_alloc_, attr_))) { } else { ObSliceAlloc::set_nway(OB_MAX_CPU_NUM * 16); } diff --git a/deps/oblib/src/lib/allocator/ob_vslice_alloc.h b/deps/oblib/src/lib/allocator/ob_vslice_alloc.h index f3875d8ea0..6ee1eb3646 100644 --- a/deps/oblib/src/lib/allocator/ob_vslice_alloc.h +++ b/deps/oblib/src/lib/allocator/ob_vslice_alloc.h @@ -91,10 +91,10 @@ public: } CACHE_ALIGNED; public: ObVSliceAlloc(): nway_(0), bsize_(0), blk_alloc_(default_blk_alloc) {} - ObVSliceAlloc(const ObMemAttr &attr, int block_size = DEFAULT_BLOCK_SIZE, BlockAlloc &blk_alloc = default_blk_alloc) + ObVSliceAlloc(const ObMemAttr &attr, const int64_t block_size = DEFAULT_BLOCK_SIZE, BlockAlloc &blk_alloc = default_blk_alloc) : nway_(1), bsize_(block_size), mattr_(attr), blk_alloc_(blk_alloc) {} virtual ~ObVSliceAlloc() override { destroy(); } - int init(int block_size, BlockAlloc& block_alloc, const ObMemAttr& attr) { + int init(int64_t block_size, BlockAlloc& block_alloc, const ObMemAttr& attr) { int ret = OB_SUCCESS; new(this)ObVSliceAlloc(attr, block_size, block_alloc); return ret; diff --git a/deps/oblib/src/lib/allocator/page_arena.h b/deps/oblib/src/lib/allocator/page_arena.h index d17a7c2637..3c8c0ca833 100644 --- a/deps/oblib/src/lib/allocator/page_arena.h +++ b/deps/oblib/src/lib/allocator/page_arena.h @@ -39,7 +39,8 @@ inline int64_t sys_page_size() // convenient function for memory alignment inline size_t get_align_offset(void *p, const int64_t alignment) { - assert(ob_is_power_of_two(alignment)); + assert(alignment >= 0 && alignment < UINT32_MAX); + assert(ob_is_power_of_two(static_cast(alignment))); return alignment - (((uint64_t)p) & (alignment - 1)); } @@ -748,7 +749,8 @@ public: // API */ CharT *alloc_aligned_bf(const int64_t sz, const int64_t alignment) { - assert(ob_is_power_of_two(alignment)); + assert(alignment >=0 && alignment <= UINT32_MAX); + assert(ob_is_power_of_two(static_cast(alignment))); CharT *ret = nullptr; ensure_cur_page(); // find the best page @@ -792,7 +794,7 @@ public: // API ret = alloc_big(adjusted_sz); } if (nullptr != ret) { - ret = (CharT*)ob_aligned_to2((int64_t)ret, alignment); + ret = (CharT*)ob_aligned_to2((int64_t)ret, static_cast(alignment)); used_ += adjusted_sz; } } diff --git a/deps/oblib/src/lib/ash/ob_active_session_guard.h b/deps/oblib/src/lib/ash/ob_active_session_guard.h index 50a8c097b5..0c163f5573 100644 --- a/deps/oblib/src/lib/ash/ob_active_session_guard.h +++ b/deps/oblib/src/lib/ash/ob_active_session_guard.h @@ -60,7 +60,7 @@ public: stat->p3_ = desc.p3_; #ifndef NDEBUG const char *bt = lbt(); - int size = std::min(sizeof(stat->bt_) - 1, STRLEN(bt)); + int64_t size = std::min(sizeof(stat->bt_) - 1, STRLEN(bt)); MEMCPY(stat->bt_, bt, size); stat->bt_[size] = '\0'; #endif diff --git a/deps/oblib/src/lib/charset/ob_charset.cpp b/deps/oblib/src/lib/charset/ob_charset.cpp index 69494d63d2..e96a2ded32 100644 --- a/deps/oblib/src/lib/charset/ob_charset.cpp +++ b/deps/oblib/src/lib/charset/ob_charset.cpp @@ -2679,7 +2679,7 @@ int ObCharset::charset_convert(const ObCollationType from_type, const uint32_t from_len, const ObCollationType to_type, char *to_str, - uint32_t to_len, + int64_t to_len, uint32_t &result_len, bool trim_incomplete_tail, bool report_error /*true*/, @@ -2692,7 +2692,7 @@ int ObCharset::charset_convert(const ObCollationType from_type, || to_type <= CS_TYPE_INVALID || to_type >= CS_TYPE_MAX || (OB_ISNULL(to_str) - || OB_UNLIKELY(to_len <= 0)))) { + || OB_UNLIKELY(to_len <= 0 || to_len > UINT32_MAX)))) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid convert", K(ret), K(from_type), K(to_type), K(ObString(from_len, from_str)), KP(to_str), K(from_len), K(to_len), KCSTRING(lbt())); @@ -2704,7 +2704,7 @@ int ObCharset::charset_convert(const ObCollationType from_type, LOG_WARN("unexpected collation type", K(ret), K(from_type), K(to_type)); } else { uint errors = 0; - result_len = ob_convert(to_str, to_len, to_cs, from_str, from_len, from_cs, + result_len = ob_convert(to_str, static_cast(to_len), to_cs, from_str, from_len, from_cs, trim_incomplete_tail, replaced_char, &errors); if (OB_UNLIKELY(errors != 0 && report_error)) { ret = OB_ERR_INCORRECT_STRING_VALUE; diff --git a/deps/oblib/src/lib/charset/ob_charset.h b/deps/oblib/src/lib/charset/ob_charset.h index ce270e9609..3c49ddbac5 100644 --- a/deps/oblib/src/lib/charset/ob_charset.h +++ b/deps/oblib/src/lib/charset/ob_charset.h @@ -485,7 +485,7 @@ public: const uint32_t from_len, const ObCollationType to_type, char *to_str, - uint32_t to_len, + int64_t to_len, uint32_t &result_len, bool trim_incomplete_tail = true, bool report_error = true, diff --git a/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor.cpp b/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor.cpp index 299af8016c..f1bf26a469 100644 --- a/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor.cpp +++ b/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor.cpp @@ -79,7 +79,8 @@ int ObLZ4StreamCompressor::stream_compress(void *ctx, const char *src, const int || OB_ISNULL(src) || OB_ISNULL(dest) || OB_UNLIKELY(!is_valid_original_data_length(src_size)) - || OB_UNLIKELY(dest_size <= 0)) { + || OB_UNLIKELY(dest_size <= 0) + || OB_UNLIKELY(dest_size > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid compress argument,", KP(src), K(src_size), KP(dest), K(dest_size), K(ret)); } else if (OB_FAIL(get_compress_bound_size(src_size, bound_size))) { @@ -90,7 +91,7 @@ int ObLZ4StreamCompressor::stream_compress(void *ctx, const char *src, const int } else { LZ4_stream_t *lz4_ctx = static_cast(ctx); - if (OB_UNLIKELY(0 >= (compressed_size = LZ4_compress_fast_continue(lz4_ctx, src, dest, src_size, dest_size, acceleration)))) { + if (OB_UNLIKELY(0 >= (compressed_size = LZ4_compress_fast_continue(lz4_ctx, src, dest, static_cast(src_size), static_cast(dest_size), acceleration)))) { ret = OB_ERR_COMPRESS_DECOMPRESS_DATA; LIB_LOG(WARN, "fail to compress data by LZ4_compress_fast_continue", KP(src), K(src_size), KP(dest), K(dest_size), K(compressed_size), K(ret)); @@ -140,13 +141,15 @@ int ObLZ4StreamCompressor::stream_decompress(void *ctx, const char *src, const i || OB_ISNULL(src) || OB_ISNULL(dest) || OB_UNLIKELY(src_size <= 0) - || OB_UNLIKELY(max_decompressed_size <= 0)) { + || OB_UNLIKELY(src_size > INT32_MAX) + || OB_UNLIKELY(max_decompressed_size <= 0) + || OB_UNLIKELY(max_decompressed_size > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid decompress argument,", KP(src), K(src_size), KP(dest), K(max_decompressed_size), K(ret)); } else { LZ4_streamDecode_t *decompress_ctx = static_cast(ctx); - if (OB_UNLIKELY(0 >= (decompressed_size = LZ4_decompress_safe_continue(decompress_ctx, src, dest, src_size, max_decompressed_size)))) { + if (OB_UNLIKELY(0 >= (decompressed_size = LZ4_decompress_safe_continue(decompress_ctx, src, dest, static_cast(src_size), static_cast(max_decompressed_size))))) { ret = OB_ERR_COMPRESS_DECOMPRESS_DATA; LIB_LOG(WARN, "fail to decompress data by LZ4_decompress_safe_continue", KP(src), KP(dest), K(src_size), K(max_decompressed_size), K(decompressed_size), K(ret)); @@ -162,7 +165,7 @@ int ObLZ4StreamCompressor::get_compress_bound_size(const int64_t src_data_size, ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid argument, ", K(src_data_size), K(ret)); } else { - bound_size = LZ4_compressBound(src_data_size); + bound_size = LZ4_compressBound(static_cast(src_data_size)); } return ret; } diff --git a/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor_191.cpp b/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor_191.cpp index ac2715bb33..cc81d116d8 100644 --- a/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor_191.cpp +++ b/deps/oblib/src/lib/compress/lz4/ob_lz4_stream_compressor_191.cpp @@ -78,7 +78,8 @@ int ObLZ4StreamCompressor191::stream_compress(void *ctx, const char *src, const || OB_ISNULL(src) || OB_ISNULL(dest) || OB_UNLIKELY(!is_valid_original_data_length(src_size)) - || OB_UNLIKELY(dest_size <= 0)) { + || OB_UNLIKELY(dest_size <= 0) + || OB_UNLIKELY(dest_size > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid compress argument,", KP(src), K(src_size), KP(dest), K(dest_size), K(ret)); } else if (OB_FAIL(get_compress_bound_size(src_size, bound_size))) { @@ -89,7 +90,7 @@ int ObLZ4StreamCompressor191::stream_compress(void *ctx, const char *src, const } else { LZ4_stream_t *lz4_ctx = static_cast(ctx); - if (OB_UNLIKELY(0 >= (compressed_size = LZ4_compress_fast_continue(lz4_ctx, src, dest, src_size, dest_size, acceleration)))) { + if (OB_UNLIKELY(0 >= (compressed_size = LZ4_compress_fast_continue(lz4_ctx, src, dest, static_cast(src_size), static_cast(dest_size), acceleration)))) { ret = OB_ERR_COMPRESS_DECOMPRESS_DATA; LIB_LOG(WARN, "fail to compress data by LZ4_compress_fast_continue", KP(src), K(src_size), KP(dest), K(dest_size), K(compressed_size), K(ret)); @@ -139,13 +140,15 @@ int ObLZ4StreamCompressor191::stream_decompress(void *ctx, const char *src, cons || OB_ISNULL(src) || OB_ISNULL(dest) || OB_UNLIKELY(src_size <= 0) - || OB_UNLIKELY(max_decompressed_size <= 0)) { + || OB_UNLIKELY(src_size > INT32_MAX) + || OB_UNLIKELY(max_decompressed_size <= 0) + || OB_UNLIKELY(max_decompressed_size > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid decompress argument,", KP(src), K(src_size), KP(dest), K(max_decompressed_size), K(ret)); } else { LZ4_streamDecode_t *decompress_ctx = static_cast(ctx); - if (OB_UNLIKELY(0 >= (decompressed_size = LZ4_decompress_safe_continue(decompress_ctx, src, dest, src_size, max_decompressed_size)))) { + if (OB_UNLIKELY(0 >= (decompressed_size = LZ4_decompress_safe_continue(decompress_ctx, src, dest, static_cast(src_size), static_cast(max_decompressed_size))))) { ret = OB_ERR_COMPRESS_DECOMPRESS_DATA; LIB_LOG(WARN, "fail to decompress data by LZ4_decompress_safe_continue", KP(src), KP(dest), K(src_size), K(max_decompressed_size), K(decompressed_size), K(ret)); @@ -161,7 +164,7 @@ int ObLZ4StreamCompressor191::get_compress_bound_size(const int64_t src_data_siz ret = OB_INVALID_ARGUMENT; LIB_LOG(WARN, "invalid argument, ", K(src_data_size), K(ret)); } else { - bound_size = LZ4_compressBound(src_data_size); + bound_size = LZ4_compressBound(static_cast(src_data_size)); } return ret; } diff --git a/deps/oblib/src/lib/compress/zlib/ob_zlib_compressor.cpp b/deps/oblib/src/lib/compress/zlib/ob_zlib_compressor.cpp index 3dbc234cea..1bf5dd3ba5 100644 --- a/deps/oblib/src/lib/compress/zlib/ob_zlib_compressor.cpp +++ b/deps/oblib/src/lib/compress/zlib/ob_zlib_compressor.cpp @@ -77,7 +77,7 @@ int ObZlibCompressor::fast_level0_compress(unsigned char *dest, unsigned long *d dest += DEFLATE_HEADER_LEN; MEMCPY(dest, source + idx, step); dest += step; - adler = adler32(adler, source + idx, step); + adler = adler32(adler, source + idx, static_cast(step)); } if (step >= max_dist_size) { //last step is zero diff --git a/deps/oblib/src/lib/geo/ob_geo_to_wkt_visitor.cpp b/deps/oblib/src/lib/geo/ob_geo_to_wkt_visitor.cpp index 1f13ea1320..c7cd758b5a 100644 --- a/deps/oblib/src/lib/geo/ob_geo_to_wkt_visitor.cpp +++ b/deps/oblib/src/lib/geo/ob_geo_to_wkt_visitor.cpp @@ -617,7 +617,7 @@ int ObGeoToWktVisitor::finish(ObIWkbGeogCollection *geo) void ObGeoToWktVisitor::get_wkt(ObString &wkt) { - wkt.assign(buffer_.ptr(), buffer_.length()); + wkt.assign(buffer_.ptr(), static_cast(buffer_.length())); } int ObGeoToWktVisitor::init(uint32_t srid, int64_t maxdecimaldigits) @@ -646,4 +646,4 @@ int ObGeoToWktVisitor::init(uint32_t srid, int64_t maxdecimaldigits) } } // namespace common -} // namespace oceanbase \ No newline at end of file +} // namespace oceanbase diff --git a/deps/oblib/src/lib/geo/ob_geo_tree.h b/deps/oblib/src/lib/geo/ob_geo_tree.h index 8ced71195a..dd97eb69d5 100644 --- a/deps/oblib/src/lib/geo/ob_geo_tree.h +++ b/deps/oblib/src/lib/geo/ob_geo_tree.h @@ -164,8 +164,8 @@ public: const value_type &back() const { return *(vec_.end()-1); }; value_type &front() { return *(vec_.begin()); } const value_type &front() const { return *(vec_.begin()); } - value_type &operator[](int32_t i) { return vec_[i]; } - const value_type &operator[](int32_t i) const { return vec_[i]; } + value_type &operator[](int64_t i) { return vec_[i]; } + const value_type &operator[](int64_t i) const { return vec_[i]; } // iterator iterator begin() { return vec_.begin(); } const_iterator begin() const { return const_iterator(&*(const_cast *>(&vec_))->begin()); } diff --git a/deps/oblib/src/lib/json_type/ob_json_bin.h b/deps/oblib/src/lib/json_type/ob_json_bin.h index c1239ea0a4..d9284af30d 100644 --- a/deps/oblib/src/lib/json_type/ob_json_bin.h +++ b/deps/oblib/src/lib/json_type/ob_json_bin.h @@ -398,10 +398,10 @@ private: uint32_t idx_; // the index of array or object array uint64_t offset_; // cur node offset from uint64_t obj_size_; // cur node total size - ObJBNodeMeta(uint8_t ver_type, uint8_t size_type, uint8_t entry_type, uint64_t idx, uint64_t offset, uint64_t obj_size) : - ver_type_(ver_type), size_type_(size_type), entry_type_(entry_type), idx_(idx), offset_(offset), obj_size_(obj_size) {} - ObJBNodeMeta() : ver_type_(0), size_type_(0), entry_type_(0), idx_(0), offset_(0), obj_size_(0) {} - ObJBNodeMeta(const ObJBNodeMeta& src): ver_type_(src.ver_type_), size_type_(src.size_type_), entry_type_(src.entry_type_), + ObJBNodeMeta(uint8_t ver_type, uint8_t size_type, uint8_t entry_type, uint32_t idx, uint64_t offset, uint64_t obj_size) : + ver_type_(ver_type), size_type_(size_type), entry_type_(entry_type), reserve(0), idx_(idx), offset_(offset), obj_size_(obj_size) {} + ObJBNodeMeta() : ver_type_(0), size_type_(0), entry_type_(0), reserve(0), idx_(0), offset_(0), obj_size_(0) {} + ObJBNodeMeta(const ObJBNodeMeta& src): ver_type_(src.ver_type_), size_type_(src.size_type_), entry_type_(src.entry_type_), reserve(0), idx_(src.idx_), offset_(src.offset_), obj_size_(src.obj_size_) {} }; @@ -554,4 +554,4 @@ public: } // namespace common } // namespace oceanbase -#endif // OCEANBASE_SQL_OB_JSON_BIN \ No newline at end of file +#endif // OCEANBASE_SQL_OB_JSON_BIN diff --git a/deps/oblib/src/lib/json_type/ob_json_tree.h b/deps/oblib/src/lib/json_type/ob_json_tree.h index d63906c7cf..c752280785 100644 --- a/deps/oblib/src/lib/json_type/ob_json_tree.h +++ b/deps/oblib/src/lib/json_type/ob_json_tree.h @@ -194,13 +194,13 @@ public: OB_INLINE void set_serialize_size(uint64_t size) { serialize_size_ = size; } OB_INLINE uint32_t depth() const override { - uint64_t max_child = 0; + uint32_t max_child = 0; uint64_t count = element_count(); ObJsonNode *child_node = NULL; for (uint64_t i = 0; i < count; i++) { child_node = get_value(i); if (OB_NOT_NULL(child_node)) { - max_child = max(max_child, static_cast(child_node->depth())); + max_child = max(max_child, child_node->depth()); } } return max_child + 1; @@ -322,13 +322,13 @@ public: OB_INLINE uint64_t element_count() const override { return node_vector_.size(); } OB_INLINE uint32_t depth() const override { - uint64_t max_child = 0; + uint32_t max_child = 0; uint64_t size = element_count(); ObJsonNode *child_node = NULL; for (uint64_t i = 0; i < size; i++) { child_node = node_vector_[i]; if (OB_NOT_NULL(child_node)) { - max_child = max(max_child, static_cast(child_node->depth())); + max_child = max(max_child, child_node->depth()); } } return max_child + 1; diff --git a/deps/oblib/src/lib/lock/ob_drw_lock.h b/deps/oblib/src/lib/lock/ob_drw_lock.h index 2d6f3ef6c8..552674f6ed 100644 --- a/deps/oblib/src/lib/lock/ob_drw_lock.h +++ b/deps/oblib/src/lib/lock/ob_drw_lock.h @@ -89,7 +89,7 @@ public: if (REACH_TIME_INTERVAL(10 * 1000 * 1000)) { COMMON_LOG_RET(WARN, ret_, "Fail to write lock for 10s, ", K_(ret)); } - ob_usleep(timeout); + ob_usleep(static_cast(timeout)); } } ~WRLockGuardRetryTimeout() diff --git a/deps/oblib/src/lib/lock/ob_tc_rwlock.h b/deps/oblib/src/lib/lock/ob_tc_rwlock.h index 6fc7ce5db9..2a7b527fe5 100644 --- a/deps/oblib/src/lib/lock/ob_tc_rwlock.h +++ b/deps/oblib/src/lib/lock/ob_tc_rwlock.h @@ -117,7 +117,7 @@ public: { [[nodiscard]] explicit WLockGuardWithRetryInterval(TCRWLock &lock, const int64_t try_thresold_us, - const int64_t retry_interval_us) + const uint32_t retry_interval_us) : lock_(lock) { int ret = OB_SUCCESS; diff --git a/deps/oblib/src/lib/number/ob_number_v2.cpp b/deps/oblib/src/lib/number/ob_number_v2.cpp index 8b806dae57..e1799e10af 100644 --- a/deps/oblib/src/lib/number/ob_number_v2.cpp +++ b/deps/oblib/src/lib/number/ob_number_v2.cpp @@ -3597,7 +3597,7 @@ int ObNumber::get_npi_(double n, ObNumber& out, ObIAllocator &alloc, const bool const int64_t MAX_DOUBLE_PRINT_SIZE = 512; char buf[MAX_DOUBLE_PRINT_SIZE] = {0}; - (void)ob_gcvt_opt(n, OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, buf, NULL, lib::is_oracle_mode(), TRUE); + (void)ob_gcvt_opt(n, OB_GCVT_ARG_DOUBLE, static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); ObNumber n_obnum; ObNumber pi = get_pi(); diff --git a/deps/oblib/src/lib/number/ob_number_v2.h b/deps/oblib/src/lib/number/ob_number_v2.h index 129de68075..7f9b91794b 100644 --- a/deps/oblib/src/lib/number/ob_number_v2.h +++ b/deps/oblib/src/lib/number/ob_number_v2.h @@ -511,7 +511,7 @@ public: const uint32_t *multiplier_digits, const uint32_t multiplicand_desc, const uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc); // 2 number multiplication fast path // formular format: a(1 digit number) * b(1 digit number): @@ -521,7 +521,7 @@ public: const uint32_t *multiplier_digits, const uint32_t multiplicand_desc, const uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc); // 2 number multiplication fast path // formular format: a(2 digits number) * b(2 digits number): @@ -531,7 +531,7 @@ public: const uint32_t *multiplier_digits, const uint32_t multiplicand_desc, const uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc); // multiplication fast path entrance @@ -1040,7 +1040,7 @@ public: MEMCPY(out.digits_ + 0, digits_ + l, out.len_ * sizeof(int64_t)); } - inline void set(const int32_t loc, const int32_t value) + inline void set(const int64_t loc, const int64_t value) { digits_[loc] = value; } @@ -1191,7 +1191,7 @@ public: } - void mul(const int32_t b, ObDivArray &c) { + void mul(const int64_t b, ObDivArray &c) { c.len_ = len_; int64_t carry = 0; for (int32_t i = 0; i < c.len_; ++i) { @@ -2276,11 +2276,11 @@ inline uint32_t ObNumber::remove_back_zero(const uint32_t digit, int64_t &count) inline int64_t ObNumber::get_digit_len(const uint32_t d) { - int64_t ret = 0; + int64_t len = 0; if (BASE <= d) { - LIB_LOG(ERROR, "d is out of range"); + LIB_LOG_RET(ERROR, OB_INVALID_ARGUMENT, "d is out of range"); } else { - ret = (d >= 100000000) ? 9 : + len = (d >= 100000000) ? 9 : (d >= 10000000) ? 8 : (d >= 1000000) ? 7 : (d >= 100000) ? 6 : @@ -2291,7 +2291,7 @@ inline int64_t ObNumber::get_digit_len(const uint32_t d) 1; } - return ret; + return len; } inline void ObNumber::exp_shift_(const int64_t shift, Desc &desc) @@ -3237,7 +3237,7 @@ OB_INLINE bool ObNumber::fast_mul_1d_mul_2d(const uint32_t *multiplicand_digits, const uint32_t *multiplier_digits, uint32_t multiplicand_desc, uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc) { @@ -3250,7 +3250,7 @@ OB_INLINE bool ObNumber::fast_mul_1d_mul_2d(const uint32_t *multiplicand_digits, static_cast(*multiplicand_digits); auto low_digit = tmp_multiplicand_di * multiplier_digits[1]; auto high_digit = tmp_multiplicand_di * multiplier_digits[0]; - auto digits_len = 0; + int64_t digits_len = 0; // formalize result digits uint64_t carry = 0; if (low_digit >= ObNumber::BASE) { @@ -3288,7 +3288,7 @@ OB_INLINE bool ObNumber::fast_mul_1d_mul_1d(const uint32_t *multiplicand_digits, const uint32_t *multiplier_digits, uint32_t multiplicand_desc, uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc) { @@ -3300,7 +3300,7 @@ OB_INLINE bool ObNumber::fast_mul_1d_mul_1d(const uint32_t *multiplicand_digits, multiplier_desc == NUM_DESC_1DIGIT_POSITIVE_INTEGER)) { auto res_digit_value = static_cast(*multiplicand_digits) * multiplier_digits[0]; - auto digits_len = 0; + int64_t digits_len = 0; // formalize result digits uint64_t carry = 0; if (res_digit_value >= ObNumber::BASE) { @@ -3331,7 +3331,7 @@ OB_INLINE bool ObNumber::fast_mul_2d_mul_2d(const uint32_t *multiplicand_digits, const uint32_t *multiplier_digits, uint32_t multiplicand_desc, uint32_t multiplier_desc, - uint32_t res_len, uint32_t res_exp, + int64_t res_len, int64_t res_exp, uint32_t *res_digit, Desc &res_desc) { @@ -3347,7 +3347,7 @@ OB_INLINE bool ObNumber::fast_mul_2d_mul_2d(const uint32_t *multiplicand_digits, auto mid_digit = multiplicand_low_di * multiplier_digits[0]; mid_digit += multiplicand_high_di * multiplier_digits[1]; auto high_digit = multiplicand_high_di * multiplier_digits[0]; - auto digits_len = 0; + int64_t digits_len = 0; // formalize result digits uint64_t carry = 0; diff --git a/deps/oblib/src/lib/ob_define.h b/deps/oblib/src/lib/ob_define.h index 125cc2acd4..6b1e3d5d9b 100644 --- a/deps/oblib/src/lib/ob_define.h +++ b/deps/oblib/src/lib/ob_define.h @@ -351,7 +351,7 @@ const int64_t OB_MPI_MAX_PARTITION_NUM = 128; const int64_t OB_MPI_MAX_TASK_NUM = 256; const int64_t OB_MAX_TABLE_NUM_PER_STMT = 256; -const int64_t OB_TMP_BUF_SIZE_256 = 256; +const int32_t OB_TMP_BUF_SIZE_256 = 256; const int64_t OB_SCHEMA_MGR_MAX_USED_TID_MAP_BUCKET_NUM = 64; const int64_t OB_MAX_SLAVE_READ_DELAY_TS = 5 * 1000 * 1000; const int64_t OB_SKIP_RANGE_LIMIT = 256; @@ -513,7 +513,7 @@ const int32_t OB_UPS_LIMIT_RATIO = 2; const int64_t OB_MERGED_VERSION_INIT = 1; -const int64_t OB_TRACE_BUFFER_SIZE = 4 * 1024; //4k +const int32_t OB_TRACE_BUFFER_SIZE = 4 * 1024; //4k const int64_t OB_TRACE_STAT_BUFFER_SIZE= 200; //200 diff --git a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h index a3436518db..8ca0375f39 100644 --- a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h +++ b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h @@ -389,7 +389,7 @@ class ObFixedClassAllocator public: ObFixedClassAllocator(const int obj_size, const ObMemAttr &attr, int blk_size, int64_t nway) : allocator_(obj_size, attr, blk_size) { - allocator_.set_nway(nway); + allocator_.set_nway(static_cast(nway)); } virtual ~ObFixedClassAllocator() {} diff --git a/deps/oblib/src/lib/objectpool/ob_server_object_pool.h b/deps/oblib/src/lib/objectpool/ob_server_object_pool.h index 8b15c63441..8bbd9c6c4c 100644 --- a/deps/oblib/src/lib/objectpool/ob_server_object_pool.h +++ b/deps/oblib/src/lib/objectpool/ob_server_object_pool.h @@ -284,14 +284,14 @@ public: */ ObServerObjectPool(const int64_t tenant_id, const bool regist, const bool is_mini_mode) : tenant_id_(tenant_id), regist_(regist), is_mini_mode_(is_mini_mode), arena_num_(0), - arena_(NULL), is_inited_(false) + arena_(NULL), cnt_per_arena_(0), item_size_(0), buf_(nullptr), is_inited_(false) {} int init() { int ret = OB_SUCCESS; const bool is_mini = (lib::is_mini_mode() || is_mini_mode_); - arena_num_ = is_mini ? get_cpu_count()/2 : get_cpu_count(); + arena_num_ = static_cast(is_mini ? get_cpu_count()/2 : get_cpu_count()); //If the assignment logic of buf_ below is not reached, buf_ will not be initialized buf_ = NULL; cnt_per_arena_ = is_mini ? 16 : 128; @@ -398,7 +398,7 @@ private: const int64_t tenant_id_; const bool regist_; const bool is_mini_mode_; - int arena_num_; + int32_t arena_num_; ObPoolArenaHead *arena_; int64_t cnt_per_arena_; int64_t item_size_; diff --git a/deps/oblib/src/lib/oblog/ob_log.cpp b/deps/oblib/src/lib/oblog/ob_log.cpp index 059d00188f..ca04094f7f 100644 --- a/deps/oblib/src/lib/oblog/ob_log.cpp +++ b/deps/oblib/src/lib/oblog/ob_log.cpp @@ -1668,7 +1668,7 @@ int64_t ObLogger::get_wait_us(const int32_t level) } -int ObLogger::alloc_log_item(const int32_t level, const int32_t size, ObPLogItem *&log_item) +int ObLogger::alloc_log_item(const int32_t level, const int64_t size, ObPLogItem *&log_item) { UNUSED(level); int ret = OB_SUCCESS; diff --git a/deps/oblib/src/lib/oblog/ob_log.h b/deps/oblib/src/lib/oblog/ob_log.h index 5643eda481..5f28254fa4 100644 --- a/deps/oblib/src/lib/oblog/ob_log.h +++ b/deps/oblib/src/lib/oblog/ob_log.h @@ -706,7 +706,7 @@ private: const int64_t log_size, bool &allow); bool need_print_log_limit_msg(); - int alloc_log_item(const int32_t level, const int32_t size, ObPLogItem *&log_item); + int alloc_log_item(const int32_t level, const int64_t size, ObPLogItem *&log_item); void free_log_item(ObPLogItem *log_item); void inc_dropped_log_count(const int32_t level); template diff --git a/deps/oblib/src/lib/oblog/ob_log_print_kv.h b/deps/oblib/src/lib/oblog/ob_log_print_kv.h index 2399ff3f35..2e6247a8a0 100644 --- a/deps/oblib/src/lib/oblog/ob_log_print_kv.h +++ b/deps/oblib/src/lib/oblog/ob_log_print_kv.h @@ -103,7 +103,7 @@ public: { int64_t pos = 0; if (OB_LIKELY(NULL != buf && len > 0)) { - int max_cpy = MIN(len, len_); + int64_t max_cpy = MIN(len, len_); STRNCPY(buf, str_, max_cpy); while (buf[pos] != '\0' && pos < max_cpy) pos++; diff --git a/deps/oblib/src/lib/oblog/ob_syslog_rate_limiter.h b/deps/oblib/src/lib/oblog/ob_syslog_rate_limiter.h index 25f8b15bdd..827a6daac0 100644 --- a/deps/oblib/src/lib/oblog/ob_syslog_rate_limiter.h +++ b/deps/oblib/src/lib/oblog/ob_syslog_rate_limiter.h @@ -48,8 +48,8 @@ public: { RLOCAL_INLINE(bool, in_acquire); int ret = common::OB_SUCCESS; - int log_level = arg0; - int errcode = arg1; + int log_level = static_cast(arg0); + int errcode = static_cast(arg1); if (!in_acquire) { if (0 == rate_) { ret = common::OB_EAGAIN; diff --git a/deps/oblib/src/lib/queue/ob_dedup_queue.cpp b/deps/oblib/src/lib/queue/ob_dedup_queue.cpp index 301b79f997..7e32548141 100644 --- a/deps/oblib/src/lib/queue/ob_dedup_queue.cpp +++ b/deps/oblib/src/lib/queue/ob_dedup_queue.cpp @@ -56,7 +56,7 @@ ObDedupQueue::~ObDedupQueue() destroy(); } -int ObDedupQueue::init(int32_t thread_num /*= DEFAULT_THREAD_NUM*/, +int ObDedupQueue::init(const int64_t thread_num /*= DEFAULT_THREAD_NUM*/, const char* thread_name /*= NULL*/, const int64_t queue_size /*= TASK_QUEUE_SIZE*/, const int64_t task_map_size /*= TASK_MAP_SIZE*/, diff --git a/deps/oblib/src/lib/queue/ob_dedup_queue.h b/deps/oblib/src/lib/queue/ob_dedup_queue.h index 3fe90b4253..254aeaeaca 100644 --- a/deps/oblib/src/lib/queue/ob_dedup_queue.h +++ b/deps/oblib/src/lib/queue/ob_dedup_queue.h @@ -161,7 +161,7 @@ public: ObDedupQueue(); virtual ~ObDedupQueue(); public: - int init(int32_t thread_num = DEFAULT_THREAD_NUM, + int init(const int64_t thread_num = DEFAULT_THREAD_NUM, const char* thread_name = nullptr, const int64_t queue_size = TASK_QUEUE_SIZE, const int64_t task_map_size = TASK_MAP_SIZE, @@ -294,8 +294,8 @@ private: private: bool is_inited_; ThreadMeta thread_metas_[MAX_THREAD_NUM]; - int32_t thread_num_; - int32_t work_thread_num_; + int64_t thread_num_; + int64_t work_thread_num_; int64_t thread_dead_threshold_; ObConcurrentFIFOAllocator allocator_; HashAllocator hash_allocator_; diff --git a/deps/oblib/src/lib/string/ob_string.h b/deps/oblib/src/lib/string/ob_string.h index 5c071dd33b..bbc884c64e 100644 --- a/deps/oblib/src/lib/string/ob_string.h +++ b/deps/oblib/src/lib/string/ob_string.h @@ -166,6 +166,17 @@ public: } return writed; } + /* + * DO NOT USE THIS ANY MORE + */ + + inline void assign(char *bytes, const int64_t length) //TODO(yongle.xh): for -Wshorten-64-to-32, delete it later + { + if (length > INT32_MAX) { + LIB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "invalid length for assign", K(length)); + } + assign(bytes, static_cast(length)); + } /* * DO NOT USE THIS ANY MORE @@ -196,6 +207,29 @@ public: } } + inline void assign_ptr(const char *bytes, const int64_t length) //TODO(yongle.xh): for -Wshorten-64-to-32, delete it later + { + if (length < 0 || length > INT32_MAX) { + LIB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "invalid length for assign ptr", K(length)); + } + assign_ptr(bytes, static_cast(length)); + } + + inline void assign_ptr(const char *bytes, const uint64_t length) //TODO(yongle.xh): for -Wshorten-64-to-32, delete it later + { + if (length < 0 || length > INT32_MAX) { + LIB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "invalid length for assign ptr", K(length)); + } + assign_ptr(bytes, static_cast(length)); + } + + inline void assign_ptr(const char *bytes, const uint32_t length) //TODO(yongle.xh): for -Wshorten-64-to-32, delete it later + { + if (length > INT32_MAX) { + LIB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "invalid length for assign ptr", K(length)); + } + assign_ptr(bytes, static_cast(length)); + } /* * attach myself to a buffer, whoes capacity is size */ diff --git a/deps/oblib/src/lib/thread/thread_mgr.h b/deps/oblib/src/lib/thread/thread_mgr.h index ba01c012c1..fa46f8f993 100644 --- a/deps/oblib/src/lib/thread/thread_mgr.h +++ b/deps/oblib/src/lib/thread/thread_mgr.h @@ -315,7 +315,7 @@ public: private: char buf_[sizeof(MyReentrantThread)]; MyReentrantThread *th_ = nullptr; - int thread_cnt_; + int64_t thread_cnt_; }; class MyThreadPool : public lib::ThreadPool @@ -401,7 +401,7 @@ public: private: char buf_[sizeof(MyThreadPool)]; MyThreadPool *th_ = nullptr; - int thread_cnt_; + int64_t thread_cnt_; }; class MySimpleThreadPool : public common::ObSimpleThreadPool @@ -619,7 +619,7 @@ public: private: char buf_[sizeof(common::ObDedupQueue)]; common::ObDedupQueue *qth_ = nullptr; - int32_t thread_num_; + int64_t thread_num_; const int64_t queue_size_; const int64_t task_map_size_; const int64_t total_mem_limit_; @@ -797,7 +797,7 @@ public: private: char buf_[sizeof(share::ObAsyncTaskQueue)]; share::ObAsyncTaskQueue *qth_ = nullptr; - int thread_cnt_; + int64_t thread_cnt_; int64_t queue_size_; }; @@ -890,7 +890,7 @@ public: private: char buf_[sizeof(TimerType) * MAX_CNT]; TimerType *timers_[MAX_CNT] = {nullptr}; - const int cnt_ = 0; + const int64_t cnt_ = 0; bool is_inited_ = false; }; diff --git a/deps/oblib/src/lib/timezone/ob_timezone_info.h b/deps/oblib/src/lib/timezone/ob_timezone_info.h index 6c97c6e35f..34d8599e4c 100644 --- a/deps/oblib/src/lib/timezone/ob_timezone_info.h +++ b/deps/oblib/src/lib/timezone/ob_timezone_info.h @@ -872,7 +872,7 @@ struct ObIntervalDSValue return validate(); } - static inline int64_t get_store_size() { return sizeof(int64_t) + sizeof(int32_t); } + static inline uint32_t get_store_size() { return static_cast(sizeof(int64_t) + sizeof(int32_t)); } inline int decode(const char *buf) { int ret = OB_SUCCESS; diff --git a/deps/oblib/src/lib/utility/serialization.h b/deps/oblib/src/lib/utility/serialization.h index 775227336d..05c71f617c 100644 --- a/deps/oblib/src/lib/utility/serialization.h +++ b/deps/oblib/src/lib/utility/serialization.h @@ -1340,15 +1340,15 @@ int decode_decimal_type(const char *buf, const int64_t buf_len, int64_t &pos, bo inline int64_t encoded_length_decimal_type(int8_t nwords, const uint32_t *words) { - int64_t ret = 6; + int64_t len = 6; if (OB_UNLIKELY(NULL == words)) { - _OB_LOG(ERROR, "null decimal words"); + _OB_LOG_RET(ERROR, OB_INVALID_ARGUMENT, "null decimal words"); } else { for (int8_t i = 0; i < nwords; ++i) { - ret += static_cast(encoded_length_vi32(words[i])); + len += static_cast(encoded_length_vi32(words[i])); } } - return ret; + return len; } inline int encode_double_type(char *buf, const int64_t buf_len, int64_t &pos, double val, diff --git a/deps/oblib/src/lib/utility/utility.h b/deps/oblib/src/lib/utility/utility.h index 5391beeda4..abc0fe9e0e 100644 --- a/deps/oblib/src/lib/utility/utility.h +++ b/deps/oblib/src/lib/utility/utility.h @@ -175,16 +175,16 @@ inline double max(const double x, const double y) return x < y ? y : x; } +template +void max(T, T) = delete; + template -inline void ob_usleep(useconds_t v) +inline void ob_usleep(const useconds_t v) { oceanbase::common::ObWaitEventGuard wait_guard(event_id, 0, (int64_t)v); ::usleep(v); } -template -void max(T, T) = delete; - int get_double_expand_size(int64_t &new_size, const int64_t limit_size); /** * allocate new memory that twice larger to store %oldp @@ -241,23 +241,6 @@ inline const char *get_peer_ip(char *buffer, size_t n, easy_request_t *req) } } -inline const char *get_peer_ip_str(char *buffer, size_t n, easy_request_t *req) -{ - static char mess[8] = "unknown"; - if (OB_LIKELY(nullptr != req && nullptr != req->ms && nullptr != req->ms->c)) { - if (AF_INET == req->ms->c->addr.family) { - return inet_ntoa_s(buffer, n, req->ms->c->addr.u.addr); - } else if (AF_INET6 == req->ms->c->addr.family) { // ipv6 - in6_addr in6; - MEMCPY(in6.s6_addr, req->ms->c->addr.u.addr6, sizeof(in6_addr)); - if(!inet_ntop(AF_INET6, &in6, buffer, n)) { - return buffer; - } - } - } - return mess; -} - inline const char *get_peer_ip(char *buffer, size_t n, easy_connection_t *c) { static char mess[8] = "unknown"; diff --git a/deps/oblib/src/rpc/frame/ob_net_easy.cpp b/deps/oblib/src/rpc/frame/ob_net_easy.cpp index f7a039e6f1..8a73d266f2 100644 --- a/deps/oblib/src/rpc/frame/ob_net_easy.cpp +++ b/deps/oblib/src/rpc/frame/ob_net_easy.cpp @@ -234,12 +234,13 @@ void ObNetEasy::init_eio_(easy_io_t *eio, const ObNetOptions &opts) } } -void ObNetEasy::update_eio_rpc_tcp_keepalive(easy_io_t* eio, int64_t user_timeout) +void ObNetEasy::update_eio_rpc_tcp_keepalive(easy_io_t* eio, int64_t input_user_timeout) { if (NULL != eio) { + const uint32_t user_timeout = static_cast(input_user_timeout); eio->tcp_keepalive = (user_timeout > 0) ? 1: 0; // tcp keeyalive args - eio->tcp_keepidle = max(user_timeout/5000000, 1); + eio->tcp_keepidle = max(user_timeout/5000000, 1u); eio->tcp_keepintvl = eio->tcp_keepidle; eio->tcp_keepcnt = 5; eio->conn_timeout = user_timeout/1000; @@ -248,16 +249,16 @@ void ObNetEasy::update_eio_rpc_tcp_keepalive(easy_io_t* eio, int64_t user_timeou } void ObNetEasy::update_eio_sql_tcp_keepalive(easy_io_t* eio, int64_t user_timeout, - int enable_tcp_keepalive, int64_t tcp_keepidle, - int64_t tcp_keepintvl, int64_t tcp_keepcnt) + int enable_tcp_keepalive, int64_t tcp_keepidle, + int64_t tcp_keepintvl, int64_t tcp_keepcnt) { if (NULL != eio) { - eio->tcp_keepalive = (enable_tcp_keepalive > 0) ? 1: 0; + eio->tcp_keepalive = (enable_tcp_keepalive > 0) ? 1u: 0u; // tcp keeyalive args - eio->tcp_keepidle = max(tcp_keepidle/1000000, 1); - eio->tcp_keepintvl = max(tcp_keepintvl/1000000, 1); - eio->tcp_keepcnt = tcp_keepcnt; - eio->conn_timeout = user_timeout/1000; + eio->tcp_keepidle = static_cast(max(tcp_keepidle/1000000, 1)); + eio->tcp_keepintvl = static_cast(max(tcp_keepintvl/1000000, 1)); + eio->tcp_keepcnt = static_cast(tcp_keepcnt); + eio->conn_timeout = static_cast(user_timeout/1000); eio->ack_timeout = 0; } } diff --git a/deps/oblib/src/rpc/frame/ob_req_transport.h b/deps/oblib/src/rpc/frame/ob_req_transport.h index 0257982c7c..1a292a3b08 100644 --- a/deps/oblib/src/rpc/frame/ob_req_transport.h +++ b/deps/oblib/src/rpc/frame/ob_req_transport.h @@ -63,7 +63,7 @@ public: virtual ~EasySPAlloc() {} void *alloc(int64_t size) const { - return easy_pool_alloc(pool_, size); + return easy_pool_alloc(pool_, static_cast(size)); } private: easy_pool_t *pool_; diff --git a/deps/oblib/src/rpc/obmysql/packet/ompk_error.cpp b/deps/oblib/src/rpc/obmysql/packet/ompk_error.cpp index 2ce37ced54..0103a61dfb 100644 --- a/deps/oblib/src/rpc/obmysql/packet/ompk_error.cpp +++ b/deps/oblib/src/rpc/obmysql/packet/ompk_error.cpp @@ -79,7 +79,7 @@ int OMPKError::decode() pos += 5; if (end >= pos) { //OB_ASSERT(end >= pos); - message_.assign_ptr(pos, static_cast(end - pos)); + message_.assign_ptr(pos, static_cast(end - pos)); pos += end - pos; //OB_ASSERT(pos == end); if (pos != end) { diff --git a/deps/oblib/src/rpc/obrpc/ob_listener.cpp b/deps/oblib/src/rpc/obrpc/ob_listener.cpp index 8bbbcb9c1f..8d70416c90 100644 --- a/deps/oblib/src/rpc/obrpc/ob_listener.cpp +++ b/deps/oblib/src/rpc/obrpc/ob_listener.cpp @@ -187,7 +187,7 @@ static int read_client_magic(int fd, uint64_t &client_magic, uint8_t &index) { int ret = OB_SUCCESS; const int64_t recv_buf_len = 1 * 1024; - int rcv_byte = 0; + int64_t rcv_byte = 0; uint64_t header_magic = 0; int64_t pos = 0; uint16_t msg_body_len = 0; @@ -235,7 +235,7 @@ static int connection_redispatch(int conn_fd, io_threads_pipefd_pool_t *ths_fd_p int ret = OB_SUCCESS; int wrfd = -1; int count = ths_fd_pool->count; - int write_bytes = 0; + int64_t write_bytes = 0; if (OB_ISNULL(ths_fd_pool)) { RPC_LOG(ERROR, "ths_fd_pool is NULL"); diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.cpp b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.cpp index 37f34971a3..9a6fdd979a 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.cpp +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.cpp @@ -399,4 +399,4 @@ int ObRpcProxy::create_request( { PCodeGuard pcode_guard(pcode); return transport.create_request(req, addr, size, timeout, local_addr, do_ratelimit, is_bg_flow, ob_ssl_invited_nodes, cb); -} \ No newline at end of file +} diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h index 31049290c6..3497dae391 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.h @@ -370,7 +370,7 @@ extern ObRpcProxy::NoneT None; } \ inline CLS& group_id(uint64_t group_id) \ { \ - set_group_id(group_id); \ + set_group_id(static_cast(group_id)); \ return *this; \ } \ inline CLS& as(uint64_t tenant_id) \ diff --git a/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp b/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp index a827b7cc90..74556f38be 100644 --- a/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp +++ b/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp @@ -315,6 +315,7 @@ int main(int argc, char *argv[]) { oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); OB_LOGGER.set_log_level("INFO"); + OB_LOGGER.set_file_name("test_tg_mgr.log", true); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/mittest/mtlenv/storage/blocksstable/test_block_cache.cpp b/mittest/mtlenv/storage/blocksstable/test_block_cache.cpp index f2902a7b04..fe461e2c0d 100644 --- a/mittest/mtlenv/storage/blocksstable/test_block_cache.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_block_cache.cpp @@ -291,7 +291,7 @@ TEST_F(TestObMicroBlockCache, test_block_cache) int main(int argc, char **argv) { system("rm -f test_block_cache.log*"); - OB_LOGGER.set_file_name("test_block_cache.log", true, true); + OB_LOGGER.set_file_name("test_block_cache.log"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/mtlenv/storage/blocksstable/test_index_block_row_scanner.cpp b/mittest/mtlenv/storage/blocksstable/test_index_block_row_scanner.cpp index c858f95923..c4a8be5d35 100644 --- a/mittest/mtlenv/storage/blocksstable/test_index_block_row_scanner.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_index_block_row_scanner.cpp @@ -242,7 +242,7 @@ TEST_F(TestIndexBlockRowScanner, prefetch_and_scan) int main(int argc, char **argv) { system("rm -f test_index_block_row_scanner.log*"); - OB_LOGGER.set_file_name("test_index_block_row_scanner.log", true, true); + OB_LOGGER.set_file_name("test_index_block_row_scanner.log"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/mtlenv/storage/blocksstable/test_index_block_row_struct.cpp b/mittest/mtlenv/storage/blocksstable/test_index_block_row_struct.cpp index 455df4f636..60fb2b0b8a 100644 --- a/mittest/mtlenv/storage/blocksstable/test_index_block_row_struct.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_index_block_row_struct.cpp @@ -218,7 +218,7 @@ TEST_F(TestIndexBlockRowStruct, test_set_rowkey) int main(int argc, char** argv) { system("rm -f test_index_block_row_struct.log*"); - OB_LOGGER.set_file_name("test_index_block_row_struct.log", true, false); + OB_LOGGER.set_file_name("test_index_block_row_struct.log"); OB_LOGGER.set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/mtlenv/storage/blocksstable/test_index_block_tree_cursor.cpp b/mittest/mtlenv/storage/blocksstable/test_index_block_tree_cursor.cpp index ec8e174acb..032e049850 100644 --- a/mittest/mtlenv/storage/blocksstable/test_index_block_tree_cursor.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_index_block_tree_cursor.cpp @@ -328,7 +328,7 @@ TEST_F(TestIndexBlockTreeCursor, test_bare_micro_block_iterator) int main(int argc, char **argv) { system("rm -f test_index_block_tree_cursor.log*"); - OB_LOGGER.set_file_name("test_index_block_tree_cursor.log", true, true); + OB_LOGGER.set_file_name("test_index_block_tree_cursor.log"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/mtlenv/storage/blocksstable/test_index_tree.cpp b/mittest/mtlenv/storage/blocksstable/test_index_tree.cpp index e2287f1336..c32cdd3959 100644 --- a/mittest/mtlenv/storage/blocksstable/test_index_tree.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_index_tree.cpp @@ -1460,7 +1460,7 @@ int main(int argc, char **argv) { system("rm -f test_index_tree.log*"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); - OB_LOGGER.set_file_name("test_index_tree.log", true); + OB_LOGGER.set_file_name("test_index_tree.log"); srand(time(NULL)); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/mtlenv/storage/blocksstable/test_shared_macro_block.cpp b/mittest/mtlenv/storage/blocksstable/test_shared_macro_block.cpp index 4e350fb15a..b0322a0c03 100644 --- a/mittest/mtlenv/storage/blocksstable/test_shared_macro_block.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_shared_macro_block.cpp @@ -168,8 +168,8 @@ TEST_F(TestSharedMacroBlk, test_invalid_write) int main(int argc, char **argv) { system("rm -f test_shared_macro_block.log*"); - OB_LOGGER.set_file_name("test_shared_macro_block.log", true, true); + OB_LOGGER.set_file_name("test_shared_macro_block.log"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/mittest/mtlenv/storage/blocksstable/test_sstable_row_exister.cpp b/mittest/mtlenv/storage/blocksstable/test_sstable_row_exister.cpp index 22717cfcf3..b00c84d002 100644 --- a/mittest/mtlenv/storage/blocksstable/test_sstable_row_exister.cpp +++ b/mittest/mtlenv/storage/blocksstable/test_sstable_row_exister.cpp @@ -116,7 +116,7 @@ TEST_F(TestSSTableRowExister, single_exist) int main(int argc, char **argv) { system("rm -f test_sstable_row_exister.log*"); - OB_LOGGER.set_file_name("test_sstable_row_exister.log", true, true); + OB_LOGGER.set_file_name("test_sstable_row_exister.log", false, true); oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/mittest/simple_server/rewrite_function_for_test_big_tx_data.cpp b/mittest/simple_server/rewrite_function_for_test_big_tx_data.cpp index f4fe56c528..f2b6e50a7e 100644 --- a/mittest/simple_server/rewrite_function_for_test_big_tx_data.cpp +++ b/mittest/simple_server/rewrite_function_for_test_big_tx_data.cpp @@ -222,7 +222,7 @@ int ObParallelMergeCtx::init_parallel_mini_merge(compaction::ObTabletMergeCtx &m } else { int64_t total_bytes = 0; int64_t total_rows = 0; - int32_t mini_merge_thread = 0; + int64_t mini_merge_thread = 0; if (OB_FAIL(memtable->estimate_phy_size(nullptr, nullptr, total_bytes, total_rows))) { STORAGE_LOG(WARN, "Failed to get estimate size from memtable", K(ret)); } else if (MTL(ObTenantDagScheduler *)->get_up_limit(ObDagPrio::DAG_PRIO_COMPACTION_HIGH, mini_merge_thread)) { @@ -317,4 +317,4 @@ int ObParallelMergeCtx::init(compaction::ObTabletMergeCtx &merge_ctx) } } -} \ No newline at end of file +} diff --git a/src/logservice/cdcservice/ob_cdc_service.cpp b/src/logservice/cdcservice/ob_cdc_service.cpp index 6e08c5fe97..27fcd1766d 100644 --- a/src/logservice/cdcservice/ob_cdc_service.cpp +++ b/src/logservice/cdcservice/ob_cdc_service.cpp @@ -130,7 +130,7 @@ void ObCdcService::run1() last_purge_ts = current_ts; } - ob_usleep(BASE_INTERVAL); + ob_usleep(static_cast(BASE_INTERVAL)); } } } diff --git a/src/logservice/libobcdc/src/ob_log_utils.cpp b/src/logservice/libobcdc/src/ob_log_utils.cpp index 16580be93d..0b2f695cf5 100644 --- a/src/logservice/libobcdc/src/ob_log_utils.cpp +++ b/src/logservice/libobcdc/src/ob_log_utils.cpp @@ -1209,7 +1209,7 @@ int get_tenant_compat_mode(const uint64_t tenant_id, // Retry to get it again ret = OB_SUCCESS; // After a failure to acquire the tenant schema, and in order to ensure that the modules can handle the performance, usleep for a short time - ob_usleep(100L); + ob_usleep(100); } int64_t left_time = end_time - ObTimeUtility::current_time(); diff --git a/src/observer/mysql/ob_query_driver.cpp b/src/observer/mysql/ob_query_driver.cpp index 89741c79cf..e76f95bb42 100644 --- a/src/observer/mysql/ob_query_driver.cpp +++ b/src/observer/mysql/ob_query_driver.cpp @@ -267,7 +267,7 @@ int ObQueryDriver::convert_field_charset(ObIAllocator& allocator, result_len))) { LOG_WARN("charset convert failed", K(ret), K(from_collation), K(dest_collation)); } else { - dest_string.assign(buf, result_len); + dest_string.assign(buf, static_cast(result_len)); } return ret; } diff --git a/src/observer/ob_srv_network_frame.cpp b/src/observer/ob_srv_network_frame.cpp index 29c517c49b..bf30cb4f2f 100644 --- a/src/observer/ob_srv_network_frame.cpp +++ b/src/observer/ob_srv_network_frame.cpp @@ -110,6 +110,7 @@ int ObSrvNetworkFrame::init() opts.mysql_io_cnt_ = io_cnt; opts.batch_rpc_io_cnt_ = io_cnt; opts.use_ipv6_ = GCONF.use_ipv6; + //TODO(tony.wzh): fix opts.tcp_keepidle negative opts.tcp_user_timeout_ = static_cast(GCONF.dead_socket_detection_timeout); opts.tcp_keepidle_ = static_cast(GCONF.tcp_keepidle); opts.tcp_keepintvl_ = static_cast(GCONF.tcp_keepintvl); @@ -492,4 +493,4 @@ void ObSrvNetworkFrame::sql_nio_stop() if (NULL != obmysql::global_sql_nio_server) { obmysql::global_sql_nio_server->stop(); } -} \ No newline at end of file +} diff --git a/src/observer/ob_srv_network_frame.h b/src/observer/ob_srv_network_frame.h index 025eb0d66f..ae1ba87056 100644 --- a/src/observer/ob_srv_network_frame.h +++ b/src/observer/ob_srv_network_frame.h @@ -66,7 +66,7 @@ public: rpc::frame::ObNetEasy *get_net_easy(); void set_ratelimit_enable(int ratelimit_enabled); int reload_mysql_login_thread_config() { - int cnt = deliver_.get_mysql_login_thread_count_to_set(GCONF.sql_login_thread_count); + int cnt = deliver_.get_mysql_login_thread_count_to_set(static_cast(GCONF.sql_login_thread_count)); return deliver_.set_mysql_login_thread_count(cnt); } private: diff --git a/src/observer/omt/ob_tenant_srs.h b/src/observer/omt/ob_tenant_srs.h index cbf2262b2b..cd125bd593 100644 --- a/src/observer/omt/ob_tenant_srs.h +++ b/src/observer/omt/ob_tenant_srs.h @@ -58,7 +58,7 @@ public: void dec_ref_count() { ATOMIC_DEC(&ref_count_); } void inc_ref_count() { ATOMIC_INC(&ref_count_); } int64_t get_ref_count() { return ATOMIC_LOAD64(&ref_count_); } - int get_srs_count() { return srs_item_map_.size(); } + int64_t get_srs_count() { return srs_item_map_.size(); } int parse_srs_item(common::sqlclient::ObMySQLResult *result, const common::ObSrsItem *&srs_item, uint64_t &srs_version); int add_pg_reserved_srs_item(const common::ObString &pg_wkt, const uint32_t srs_id); @@ -194,4 +194,4 @@ private: } // namespace omt } // namespace oceanbase -#endif \ No newline at end of file +#endif diff --git a/src/pl/ob_pl.h b/src/pl/ob_pl.h index 26f905251a..6e6fd5c46e 100644 --- a/src/pl/ob_pl.h +++ b/src/pl/ob_pl.h @@ -326,7 +326,7 @@ public: } int add_routine(ObPLFunction *routine); int get_routine(int64_t routine_idx, ObPLFunction *&routine) const; - void init_routine_table(int64_t count) { routine_table_.set_capacity(count); } + void init_routine_table(int64_t count) { routine_table_.set_capacity(static_cast(count)); } inline const ObIArray &get_type_table() const { return type_table_; } inline sql::ObRawExprFactory &get_expr_factory() { return expr_factory_; } diff --git a/src/pl/ob_pl_stmt.h b/src/pl/ob_pl_stmt.h index 45c53273dc..30fc0b6242 100644 --- a/src/pl/ob_pl_stmt.h +++ b/src/pl/ob_pl_stmt.h @@ -219,7 +219,7 @@ public: ObPLSymbolDebugInfoTable(ObIAllocator &allocator) : variable_debuginfos_(allocator) {} inline int reserve(int capcity) { return variable_debuginfos_.reserve(capcity); } - inline int get_count() const { return variable_debuginfos_.count(); } + inline int64_t get_count() const { return variable_debuginfos_.count(); } inline const ObPLVarDebugInfo* get_symbol(int64_t idx) const { return idx < 0 || idx >= variable_debuginfos_.count() ? NULL : &variable_debuginfos_.at(idx); diff --git a/src/pl/ob_pl_user_type.h b/src/pl/ob_pl_user_type.h index 2ee699119f..afe30180ef 100644 --- a/src/pl/ob_pl_user_type.h +++ b/src/pl/ob_pl_user_type.h @@ -703,7 +703,7 @@ public: inline int64_t get_count() const { return count_; } inline void set_count(int64_t count) { count_ = count; } inline int64_t get_column_count() const { return element_.field_cnt_; } - inline void set_column_count(int64_t count) { element_.field_cnt_ = count; } + inline void set_column_count(int64_t count) { element_.field_cnt_ = static_cast(count); } int64_t get_first(); inline void set_first(int64_t first) { first_ = first; } int64_t get_last(); diff --git a/src/pl/sys_package/ob_dbms_sql.h b/src/pl/sys_package/ob_dbms_sql.h index 319ff83827..453b42350b 100644 --- a/src/pl/sys_package/ob_dbms_sql.h +++ b/src/pl/sys_package/ob_dbms_sql.h @@ -76,7 +76,7 @@ public: common::ColumnsFieldArray &dst_fields); int init_params(int64_t param_count); - int get_param_name_count() const { return param_names_.count(); } + int64_t get_param_name_count() const { return param_names_.count(); } ObIArray& get_param_names() { return param_names_; } int add_param_name(ObString &clone_name); diff --git a/src/rootserver/ob_root_service.cpp b/src/rootserver/ob_root_service.cpp index 3b3cba94d7..6e6d520fb8 100644 --- a/src/rootserver/ob_root_service.cpp +++ b/src/rootserver/ob_root_service.cpp @@ -7381,7 +7381,7 @@ int ObRootService::check_can_stop(const ObZone &zone, bool ObRootService::have_other_stop_task(const ObZone &zone) { bool bret = false; - int64_t ret = OB_SUCCESS; + int ret = OB_SUCCESS; ObArray zone_infos; bool stopped = false; //Check if there are other servers in the stopped state on other zones diff --git a/src/share/CMakeLists.txt b/src/share/CMakeLists.txt index 699ebd7584..333d0e355f 100644 --- a/src/share/CMakeLists.txt +++ b/src/share/CMakeLists.txt @@ -462,6 +462,7 @@ ob_set_subtarget(ob_share unit ob_add_new_object_target(ob_share ob_share) +target_compile_options(ob_share PRIVATE -Wshorten-64-to-32) target_link_libraries(ob_share PUBLIC ob_base) add_library(ob_share_static diff --git a/src/share/backup/ob_archive_store.cpp b/src/share/backup/ob_archive_store.cpp index 92dd063f87..6902b4130f 100644 --- a/src/share/backup/ob_archive_store.cpp +++ b/src/share/backup/ob_archive_store.cpp @@ -1576,7 +1576,7 @@ static int is_round_start_file_name_(ObString &file_name, bool &is_round_start) is_round_start = false; } else if (file_name.length() < suffix_len) { is_round_start = false; - } else if (OB_FALSE_IT(tmp.assign(file_name.ptr() + p, strlen(SUFFIX)))) { + } else if (OB_FALSE_IT(tmp.assign(file_name.ptr() + p, static_cast(strlen(SUFFIX))))) { } else if (!tmp.prefix_match(SUFFIX)) { is_round_start = false; } else { @@ -1847,7 +1847,7 @@ int ObArchiveStore::ObPieceFileListFilter::func(const dirent *entry) } else if (OB_ISNULL(entry)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid entry", K(ret)); - } else if (FALSE_IT(len = strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX))) { + } else if (FALSE_IT(len = static_cast(strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX)))) { } else if (len <= 0) { ret = OB_ERR_UNEXPECTED; LOG_WARN("file name without a unified suffix", K(ret), K(entry->d_name), K(OB_ARCHIVE_SUFFIX)); @@ -1893,14 +1893,14 @@ int ObArchiveStore::ObLSFileListOp::func(const dirent *entry) ObString file_name; ObSingleLSInfoDesc::OneFile one_file; char *endptr = NULL; - int64 len = 0; + int32_t len = 0; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("ObLSFileListOp not init", K(ret)); } else if (OB_ISNULL(entry)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid entry", K(ret)); - } else if (FALSE_IT(len = strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX))) { + } else if (FALSE_IT(len = static_cast(strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX)))) { } else if (len <= 0) { ret = OB_ERR_UNEXPECTED; LOG_WARN("file name without a unified suffix", K(ret), K(entry->d_name), K(OB_ARCHIVE_SUFFIX)); diff --git a/src/share/backup/ob_backup_connectivity.cpp b/src/share/backup/ob_backup_connectivity.cpp index 6e7dabb384..cf42fb9d16 100644 --- a/src/share/backup/ob_backup_connectivity.cpp +++ b/src/share/backup/ob_backup_connectivity.cpp @@ -321,7 +321,7 @@ int ObBackupCheckFile::compare_check_file_name_( LOG_WARN("failed to get check file prefix", K(ret), K_(tenant_id)); } else { ObDirPrefixEntryNameFilter prefix_op(d_entrys); - if (OB_FAIL(prefix_op.init(check_file_prefix, strlen(check_file_prefix)))) { + if (OB_FAIL(prefix_op.init(check_file_prefix, static_cast(strlen(check_file_prefix))))) { LOG_WARN("failed to init dir prefix", K(ret), K(check_file_prefix), K_(tenant_id)); } else if (OB_FAIL(util.list_files(path.get_obstr(), backup_dest.get_storage_info(), prefix_op))) { LOG_WARN("failed to list files", K(ret), K_(tenant_id)); @@ -450,7 +450,7 @@ int ObBackupCheckFile::delete_permission_check_file(const ObBackupDest &backup_d LOG_WARN("failed to get check file path", K(ret), K(backup_dest)); } else { ObDirPrefixEntryNameFilter prefix_op(d_entrys); - if (OB_FAIL(prefix_op.init(check_file_prefix, strlen(check_file_prefix)))) { + if (OB_FAIL(prefix_op.init(check_file_prefix, static_cast(strlen(check_file_prefix))))) { LOG_WARN("failed to init dir prefix", K(ret), K(check_file_prefix), K_(tenant_id)); } else if (OB_FAIL(util.list_files(path.get_obstr(), backup_dest.get_storage_info(), prefix_op))) { LOG_WARN("failed to list files", K(ret), K_(tenant_id)); diff --git a/src/share/backup/ob_backup_data_table_operator.cpp b/src/share/backup/ob_backup_data_table_operator.cpp index a1a790a295..f845c55695 100644 --- a/src/share/backup/ob_backup_data_table_operator.cpp +++ b/src/share/backup/ob_backup_data_table_operator.cpp @@ -1876,7 +1876,7 @@ int ObBackupLSTaskOperator::do_parse_ls_result_(ObMySQLResult &result, ObBackupL LOG_WARN("[DATA_BACKUP]failed to parse string to addr", K(ret)); } else if (strcmp(trace_id_str, "") != 0 && OB_FAIL(ls_attr.task_trace_id_.set(trace_id_str))) { LOG_WARN("[DATA_BACKUP]failed to set task trace id", K(ret), K(trace_id_str)); - } else if (!ls_attr.dst_.set_ip_addr(server_str, port)) { + } else if (!ls_attr.dst_.set_ip_addr(server_str, static_cast(port))) { ret = OB_INVALID_ARGUMENT; LOG_WARN("fail to set server ip and port", K(ret), K(server_str), K(port)); } else { diff --git a/src/share/backup/ob_backup_struct.cpp b/src/share/backup/ob_backup_struct.cpp index f7cc72a352..ea7bb67d54 100644 --- a/src/share/backup/ob_backup_struct.cpp +++ b/src/share/backup/ob_backup_struct.cpp @@ -150,7 +150,7 @@ int ObPhysicalRestoreBackupDestList::get_backup_set_list_format_str( ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected format str", KR(ret), K(str_buf), K(str_buf_len)); } else { - str.assign_ptr(str_buf, str_buf_len - 1); + str.assign_ptr(str_buf, static_cast(str_buf_len - 1)); LOG_DEBUG("get format backup set path list str", KR(ret), K(str)); } return ret; @@ -186,7 +186,7 @@ int ObPhysicalRestoreBackupDestList::get_backup_set_desc_list_format_str( ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected format str", KR(ret), K(str_buf), K(str_buf_len)); } else { - str.assign_ptr(str_buf, STRLEN(str_buf)); + str.assign_ptr(str_buf, static_cast(STRLEN(str_buf))); LOG_DEBUG("get format backup set path list str", KR(ret), K(str)); } return ret; @@ -221,7 +221,7 @@ int ObPhysicalRestoreBackupDestList::get_backup_piece_list_format_str( ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected format str", KR(ret), K(str_buf), K(str_buf_len)); } else { - str.assign_ptr(str_buf, str_buf_len - 1); + str.assign_ptr(str_buf, static_cast(str_buf_len - 1)); LOG_DEBUG("get format backup piece path list str", KR(ret), K(str)); } return ret; @@ -256,7 +256,7 @@ int ObPhysicalRestoreBackupDestList::get_log_path_list_format_str( ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected format str", KR(ret), K(str_buf), K(str_buf_len)); } else { - str.assign_ptr(str_buf, str_buf_len - 1); + str.assign_ptr(str_buf, static_cast(str_buf_len - 1)); LOG_DEBUG("get log path list str", KR(ret), K(str)); } return ret; @@ -508,7 +508,7 @@ int ObPhysicalRestoreBackupDestList::get_backup_set_list_hex_str( ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - str.assign_ptr(hex_buf, hex_size); + str.assign_ptr(hex_buf, static_cast(hex_size)); LOG_DEBUG("get hex backup set list str", KR(ret), K(str)); } return ret; @@ -545,7 +545,7 @@ int ObPhysicalRestoreBackupDestList::get_backup_piece_list_hex_str( ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - str.assign_ptr(hex_buf, hex_size); + str.assign_ptr(hex_buf, static_cast(hex_size)); LOG_DEBUG("get hex backup piece list str", KR(ret), K(str)); } return ret; @@ -582,7 +582,7 @@ int ObPhysicalRestoreBackupDestList::get_log_path_list_hex_str( ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - str.assign_ptr(hex_buf, hex_size); + str.assign_ptr(hex_buf, static_cast(hex_size)); LOG_DEBUG("get hex log path list str", KR(ret), K(str)); } return ret; @@ -1398,11 +1398,11 @@ bool ObBackupStorageInfo::operator !=(const ObBackupStorageInfo &storage_info) c int64_t ObBackupStorageInfo::hash() const { int64_t hash_value = 0; - hash_value = murmurhash(&device_type_, sizeof(device_type_), hash_value); - hash_value = murmurhash(endpoint_, strlen(endpoint_), hash_value); - hash_value = murmurhash(access_id_, strlen(access_id_), hash_value); - hash_value = murmurhash(access_key_, strlen(access_key_), hash_value); - hash_value = murmurhash(extension_, strlen(extension_), hash_value); + hash_value = murmurhash(&device_type_, static_cast(sizeof(device_type_)), hash_value); + hash_value = murmurhash(endpoint_, static_cast(strlen(endpoint_)), hash_value); + hash_value = murmurhash(access_id_, static_cast(strlen(access_id_)), hash_value); + hash_value = murmurhash(access_key_, static_cast(strlen(access_key_)), hash_value); + hash_value = murmurhash(extension_, static_cast(strlen(extension_)), hash_value); return hash_value; } @@ -1493,7 +1493,7 @@ int64_t ObBackupDest::hash() const { int64_t hash_val = 0; if (is_valid()) { - hash_val = murmurhash(root_path_, strlen(root_path_), hash_val); + hash_val = murmurhash(root_path_, static_cast(strlen(root_path_)), hash_val); hash_val += storage_info_->hash(); } return hash_val; @@ -1684,7 +1684,7 @@ int ObBackupDest::set(const char *root_path, const ObBackupStorageInfo *storage_ void ObBackupDest::root_path_trim_() { - int len = strlen(root_path_); + int len = static_cast(strlen(root_path_)); for (int i = len - 1; i >=0 ; i--) { if (root_path_[i] == '/') { root_path_[i] = '\0'; @@ -4089,7 +4089,7 @@ int share::backup_time_to_strftime(const int64_t &ts_s, char *buf, int ret = OB_SUCCESS; ObSqlString format; struct tm lt; - int strftime_len = 0; + int64_t strftime_len = 0; time_t t = static_cast(ts_s); (void) localtime_r(&t, <); @@ -4167,4 +4167,4 @@ int ObBackupSkippedType::parse_from_str(const ObString &str) LOG_WARN("invalid backup skipped type str", KR(ret), K(str)); } return ret; -} \ No newline at end of file +} diff --git a/src/share/backup/ob_backup_struct.h b/src/share/backup/ob_backup_struct.h index c532aa1119..7f184293d0 100644 --- a/src/share/backup/ob_backup_struct.h +++ b/src/share/backup/ob_backup_struct.h @@ -1122,13 +1122,13 @@ int ObBackupUtils::parse_backup_format_input( if (format_input.ptr()[i] == split_commma || format_input.ptr()[i] == split_semicolon) { length = i - pos; - if (length <= 0 || length > max_length) { + if (length <= 0 || length > max_length || length > INT32_MAX) { ret = OB_ERR_UNEXPECTED; OB_LOG(WARN, "format input value is unexpcted", K(ret), K(format_input), K(length), K(max_length)); } else { ObString tmp_string; object.reset(); - tmp_string.assign_ptr(format_input.ptr() + pos, length); + tmp_string.assign_ptr(format_input.ptr() + pos, static_cast(length)); if (OB_FAIL(object.set(tmp_string, priority))) { OB_LOG(WARN, "failed to set object", K(ret), K(tmp_string), K(priority)); } else if (OB_FAIL(array.push_back(object))) { @@ -1150,7 +1150,7 @@ int ObBackupUtils::parse_backup_format_input( length = format_input.length() - pos; ObString tmp_string; object.reset(); - tmp_string.assign_ptr(format_input.ptr() + pos, length); + tmp_string.assign_ptr(format_input.ptr() + pos, static_cast(length)); if (OB_FAIL(object.set(tmp_string, priority))) { OB_LOG(WARN, "failed to set object", K(ret), K(tmp_string), K(priority)); } else if (OB_FAIL(array.push_back(object))) { diff --git a/src/share/cache/ob_kvcache_struct.cpp b/src/share/cache/ob_kvcache_struct.cpp index 15a489100c..edd455d1eb 100644 --- a/src/share/cache/ob_kvcache_struct.cpp +++ b/src/share/cache/ob_kvcache_struct.cpp @@ -228,12 +228,9 @@ int ObKVStoreMemBlock::alloc( if (OB_UNLIKELY(NULL == buffer_)) { ret = OB_INVALID_DATA; COMMON_LOG(WARN, "The mem block is invalid, ", KP_(buffer), K(ret)); - } else if (OB_UNLIKELY(key_size <= 0)) { + } else if (OB_UNLIKELY(key_size <= 0 || value_size <= 0 || align_kv_size < 0 || align_kv_size > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(WARN, "The size of key is 0, ", K(ret)); - } else if (OB_UNLIKELY(value_size <= 0)) { - ret = OB_INVALID_ARGUMENT; - COMMON_LOG(WARN, "The size of value is 0, ", K(ret)); + COMMON_LOG(WARN, "invalid args", K(ret), K(key_size), K(value_size), K(align_kv_size)); } //find write position @@ -244,7 +241,7 @@ int ObKVStoreMemBlock::alloc( ret = OB_BUF_NOT_ENOUGH; break; } else { - new_atomic_pos.buffer += align_kv_size; + new_atomic_pos.buffer += static_cast(align_kv_size); new_atomic_pos.pairs += 1; if (ATOMIC_BCAS(&(atomic_pos_.atomic), old_atomic_pos.atomic, new_atomic_pos.atomic)) { break; @@ -255,7 +252,7 @@ int ObKVStoreMemBlock::alloc( //if has found store pos, then store the kv if (OB_SUCC(ret)) { kvpair = reinterpret_cast(&(buffer_[old_atomic_pos.buffer])); - kvpair->size_ = align_kv_size; + kvpair->size_ = static_cast(align_kv_size); kvpair->key_ = reinterpret_cast(&(buffer_[old_atomic_pos.buffer + sizeof(ObKVCachePair)])); kvpair->value_ = reinterpret_cast(&(buffer_[old_atomic_pos.buffer + sizeof(ObKVCachePair) + key_size])); diff --git a/src/share/config/ob_common_config.cpp b/src/share/config/ob_common_config.cpp index ee92c8ae28..3373c07dc5 100644 --- a/src/share/config/ob_common_config.cpp +++ b/src/share/config/ob_common_config.cpp @@ -329,7 +329,7 @@ int ObCommonConfig::add_extra_config(const char *config_str, name = ""; } if (OB_SUCC(ret)) { - const int value_len = strlen(value); + const int value_len = static_cast(strlen(value)); // hex2cstring -> value_len / 2 + 1 // '\0' -> 1 const int external_info_val_len = value_len / 2 + 1 + 1; diff --git a/src/share/config/ob_config.cpp b/src/share/config/ob_config.cpp index 35a9a8f2ca..7961314e35 100644 --- a/src/share/config/ob_config.cpp +++ b/src/share/config/ob_config.cpp @@ -519,11 +519,11 @@ ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer *container, int64_t ObConfigCapacityItem::parse(const char *str, bool &valid) const { - int64_t ret = ObConfigCapacityParser::get(str, valid); + int64_t value = ObConfigCapacityParser::get(str, valid); if (!valid) { - OB_LOG(ERROR, "set capacity error", "name", name(), K(str), K(valid)); + OB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "set capacity error", "name", name(), K(str), K(valid)); } - return ret; + return value; } // ObConfigTimeItem @@ -946,7 +946,7 @@ int ObConfigLogArchiveOptionsItem::format_option_str(const char *src, int64_t sr int64_t pos = 0; while (OB_SUCC(ret) && (source_left_len > 0) && (NULL != (locate_str = STRCHR(source_str, '=')))) { - locate = locate_str - source_str; + locate = static_cast(locate_str - source_str); if (OB_FAIL(databuff_printf(dest, dest_len, pos, "%.*s = ", locate, source_str))) { OB_LOG(WARN, "failed to databuff_print", K(ret), K(dest), K(locate), K(source_str)); } else { diff --git a/src/share/datum/ob_datum.h b/src/share/datum/ob_datum.h index 96772df778..d926d95604 100644 --- a/src/share/datum/ob_datum.h +++ b/src/share/datum/ob_datum.h @@ -294,12 +294,12 @@ public: inline void set_interval_nmonth(const int64_t interval_nmonth) { *no_cv(interval_nmonth_) = interval_nmonth; - pack_ = sizeof(int64_t); + pack_ = static_cast(sizeof(int64_t)); }; inline void set_interval_ym(const int64_t interval_nmonth) { *no_cv(interval_nmonth_) = interval_nmonth; - pack_ = sizeof(int64_t); + pack_ = static_cast(sizeof(int64_t)); }; inline void set_interval_ds(const ObIntervalDSValue &v) { @@ -347,27 +347,28 @@ public: OB_INLINE void set_pack(const int64_t len); inline void set_string(const ObString &v) { ptr_ = v.ptr(); pack_ = v.length(); } - inline void set_string(const char *ptr, const int64_t len) { ptr_ = ptr; pack_ = len; } + inline void set_string(const char *ptr, const uint32_t len) { ptr_ = ptr; pack_ = len; } inline void set_enumset_inner(const ObString &v) { set_string(v); } - inline void set_enumset_inner(const char *ptr, const int64_t len) { set_string(ptr, len); } + inline void set_enumset_inner(const char *ptr, const uint32_t len) { set_string(ptr, len); } inline void set_urowid(const ObURowIDData &urowid_data) { ptr_ = reinterpret_cast(urowid_data.rowid_content_); - pack_ = urowid_data.rowid_len_; + pack_ = static_cast(urowid_data.rowid_len_);//TODO(yongle.xh): need check } inline void set_urowid(const char *ptr, const int64_t size) { - ptr_ = ptr; pack_ = size; + ptr_ = ptr; + pack_ = static_cast(size); } inline void set_lob_locator(const ObLobLocator &value) { lob_locator_ = &value; - pack_ = value.get_total_size(); + pack_ = static_cast(value.get_total_size());//TODO(yuanzhi.zy): need check } inline void set_lob_data(const ObLobCommon &value, int64_t length) { lob_data_ = &value; - pack_ = length; + pack_ = static_cast(length);//TODO(yuanzhi.zy):need check } inline void set_datum(const ObDatum &other) { *this = other; } inline int deep_copy(const ObDatum &src, char *buf, int64_t max_size, int64_t &pos) @@ -502,18 +503,18 @@ OB_INLINE void ObDatum::set_number(const number::ObNumber &num) no_cv(num_)->desc_ = num.d_; const int64_t len = num.d_.len_ * sizeof(*num.get_digits()); memcpy(&no_cv(num_)->digits_[0], num.get_digits(), len); - pack_ = len + sizeof(*num_); + pack_ = static_cast(len + sizeof(*num_)); } OB_INLINE void ObDatum::set_number(const number::ObCompactNumber &cnum) { - pack_ = sizeof(cnum) + cnum.desc_.len_ * sizeof(cnum.digits_[0]); + pack_ = static_cast(sizeof(cnum) + cnum.desc_.len_ * sizeof(cnum.digits_[0])); memcpy(no_cv(num_), &cnum, len_); } OB_INLINE void ObDatum::set_number_shallow(const number::ObCompactNumber &cnum) { - pack_ = sizeof(cnum) + cnum.desc_.len_ * sizeof(cnum.digits_[0]); + pack_ = static_cast(sizeof(cnum) + cnum.desc_.len_ * sizeof(cnum.digits_[0])); num_ = &cnum; } @@ -521,7 +522,7 @@ OB_INLINE void ObDatum::set_number_shallow(const number::ObCompactNumber &cnum) OB_INLINE void ObDatum::set_pack(const int64_t len) { //pack_ = desc.len_ * sizeof(no_cv(num_)->digits_[0]) + sizeof(*num_); - pack_ = len; + pack_ = static_cast(len); } template <> diff --git a/src/share/deadlock/ob_deadlock_detector_common_define.cpp b/src/share/deadlock/ob_deadlock_detector_common_define.cpp index 916d56f07b..040faf3cdc 100644 --- a/src/share/deadlock/ob_deadlock_detector_common_define.cpp +++ b/src/share/deadlock/ob_deadlock_detector_common_define.cpp @@ -54,7 +54,7 @@ static int check_and_assign_ptr_(const char *others_ptr, DETECT_LOG(WARN, "string length is not satisfied length limit", PRINT_WRAPPER, K(STR_LEN_LIMIT)); } else { - self_string->assign_ptr(others_ptr, calculated_len); + self_string->assign_ptr(others_ptr, static_cast(calculated_len)); } } diff --git a/src/share/deadlock/ob_deadlock_detector_rpc.h b/src/share/deadlock/ob_deadlock_detector_rpc.h index 1bdff479ea..5f37456926 100644 --- a/src/share/deadlock/ob_deadlock_detector_rpc.h +++ b/src/share/deadlock/ob_deadlock_detector_rpc.h @@ -105,8 +105,9 @@ public: if (OB_SUCCESS != rcode.rcode_) { DETECT_LOG_RET(WARN, rcode.rcode_, "detector rpc returns error code(rpc level)", K(rcode), K(dst)); } else if (OB_SUCCESS != remote_ret) { - DETECT_LOG_RET(WARN, remote_ret, "detector rpc returns error code(detector level)", - KR(remote_ret), K(rcode.rcode_), K(dst)); + const int32_t tmp_ret = static_cast(remote_ret); + DETECT_LOG_RET(WARN, tmp_ret, "detector rpc returns error code(detector level)", + KR(tmp_ret), K(rcode.rcode_), K(dst)); } else { // do nothing } diff --git a/src/share/deadlock/ob_deadlock_key_wrapper.cpp b/src/share/deadlock/ob_deadlock_key_wrapper.cpp index e712bf7b7f..0a6a758a66 100644 --- a/src/share/deadlock/ob_deadlock_key_wrapper.cpp +++ b/src/share/deadlock/ob_deadlock_key_wrapper.cpp @@ -119,7 +119,7 @@ int64_t UserBinaryKey::to_string(char *buffer, const int64_t length) const #undef USER_REGISTER default: static const char *err_str = "invalid key"; - const int err_str_len = strlen(err_str); + const int64_t err_str_len = strlen(err_str); if (length >= err_str_len) { memcpy(buffer, err_str, err_str_len); used_length = err_str_len; diff --git a/src/share/deadlock/ob_lcl_scheme/ob_lcl_batch_sender_thread.cpp b/src/share/deadlock/ob_lcl_scheme/ob_lcl_batch_sender_thread.cpp index 4869d3fc29..0788690ee2 100644 --- a/src/share/deadlock/ob_lcl_scheme/ob_lcl_batch_sender_thread.cpp +++ b/src/share/deadlock/ob_lcl_scheme/ob_lcl_batch_sender_thread.cpp @@ -210,7 +210,7 @@ void ObLCLBatchSenderThread::run1() record_summary_info_and_logout_when_necessary_(begin_ts, end_ts, diff); if (diff < _lcl_op_interval) { - ob_usleep(_lcl_op_interval - diff); + ob_usleep(static_cast(_lcl_op_interval - diff)); // DETECT_LOG(DEBUG, "scan done", K(diff), K(*this)); } } diff --git a/src/share/io/ob_io_define.cpp b/src/share/io/ob_io_define.cpp index 6f10538f1f..0b63725155 100644 --- a/src/share/io/ob_io_define.cpp +++ b/src/share/io/ob_io_define.cpp @@ -812,7 +812,7 @@ int ObIOHandle::wait(const int64_t timeout_ms) ObWaitEventGuard wait_guard(req_->io_info_.flag_.get_wait_event(), timeout_ms, req_->io_info_.size_); - int real_wait_timeout = min(OB_IO_MANAGER.get_io_config().data_storage_io_timeout_ms_, timeout_ms); + const int64_t real_wait_timeout = min(OB_IO_MANAGER.get_io_config().data_storage_io_timeout_ms_, timeout_ms); if (real_wait_timeout > 0) { ObThreadCondGuard guard(req_->cond_); @@ -1092,7 +1092,7 @@ int ObTenantIOConfig::parse_group_config(const char *config_str) } else { str_trim(copied_str); int pos = 0; - int len = strlen(copied_str); + const int64_t len = strlen(copied_str); for (int64_t i = 0; OB_SUCC(ret) && i < len; ++i) { if (';' == copied_str[i]) { copied_str[i] = '\0'; diff --git a/src/share/io/ob_io_struct.cpp b/src/share/io/ob_io_struct.cpp index 745b58cced..c640b101ae 100644 --- a/src/share/io/ob_io_struct.cpp +++ b/src/share/io/ob_io_struct.cpp @@ -689,7 +689,7 @@ void ObIOTuner::run1() if (REACH_TIME_INTERVAL(1000L * 1000L * 1L)) { print_io_status(); } - ob_usleep(100L * 1000L); // 100ms + ob_usleep(100 * 1000); // 100ms } LOG_INFO("io tuner thread stopped"); } @@ -1240,7 +1240,7 @@ int ObIOSender::notify() return ret; } -int32_t ObIOSender::get_queue_count() const +int64_t ObIOSender::get_queue_count() const { return OB_ISNULL(io_queue_) ? 0 : sender_req_count_; } @@ -1718,7 +1718,7 @@ void ObAsyncIOChannel::destroy() // wait flying request const int64_t max_wait_ts = ObTimeUtility::fast_current_time() + 1000L * 1000L * 30L; // 30s while (submit_count_ > 0 && ObTimeUtility::fast_current_time() < max_wait_ts) { - ob_usleep(1000L * 10L); + ob_usleep(1000 * 10); } if (submit_count_ > 0) { LOG_WARN_RET(OB_ERR_UNEXPECTED, "some request have not returned from file system", K(submit_count_)); diff --git a/src/share/io/ob_io_struct.h b/src/share/io/ob_io_struct.h index be0f2f3c00..402e3fd6cd 100644 --- a/src/share/io/ob_io_struct.h +++ b/src/share/io/ob_io_struct.h @@ -242,7 +242,7 @@ public: int remove_group_queues(const uint64_t tenant_id); int stop_phy_queue(const uint64_t tenant_id, const uint64_t index); int notify(); - int32_t get_queue_count() const; + int64_t get_queue_count() const; int get_sender_status(const uint64_t tenant_id, const uint64_t index, ObSenderInfo &sender_info); TO_STRING_KV(K(is_inited_), K(stop_submit_), KPC(io_queue_), K(tg_id_)); //private: diff --git a/src/share/location_cache/ob_ls_location_service.cpp b/src/share/location_cache/ob_ls_location_service.cpp index 28b3a79f43..4436bda9c8 100644 --- a/src/share/location_cache/ob_ls_location_service.cpp +++ b/src/share/location_cache/ob_ls_location_service.cpp @@ -373,7 +373,7 @@ int ObLSLocationService::get_leader_with_retry_until_timeout( } else if (ObTimeUtil::current_time() + retry_interval > curr_abs_retry_timeout_ts) { break; } else { - ob_usleep(retry_interval); + ob_usleep(static_cast(retry_interval)); } } else { LOG_WARN("fail to nonblock_get_leader", KR(ret), K(cluster_id), K(tenant_id), K(ls_id)); diff --git a/src/share/ls/ob_ls_status_operator.cpp b/src/share/ls/ob_ls_status_operator.cpp index 4a5748511b..b3ba195ce0 100644 --- a/src/share/ls/ob_ls_status_operator.cpp +++ b/src/share/ls/ob_ls_status_operator.cpp @@ -584,7 +584,7 @@ int ObLSStatusOperator::get_visible_member_list_str_(const ObMemberList &member_ ret = OB_SIZE_OVERFLOW; LOG_WARN("size overflow", KR(ret), K(pos), K(length)); } else { - visible_member_list_str.assign(member_list_str, pos); + visible_member_list_str.assign(member_list_str, static_cast(pos)); } return ret; } @@ -623,7 +623,7 @@ int ObLSStatusOperator::get_member_list_hex_(const ObMemberList &member_list, ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - hex_str.assign_ptr(hex_buf, hex_size); + hex_str.assign_ptr(hex_buf, static_cast(hex_size)); } return ret; } diff --git a/src/share/ob_bg_thread_monitor.cpp b/src/share/ob_bg_thread_monitor.cpp index 7c30f38ffa..cecd10272f 100644 --- a/src/share/ob_bg_thread_monitor.cpp +++ b/src/share/ob_bg_thread_monitor.cpp @@ -338,7 +338,7 @@ void ObBGThreadMonitor::run_loop_() if (cost_time > 100*1000) { SHARE_LOG_RET(WARN, OB_ERR_TOO_MUCH_TIME, "ObBGThreadMonitor cost too much time", K(cost_time)); } - int64_t sleep_time = CHECK_INTERVAL - cost_time; + int32_t sleep_time = static_cast(CHECK_INTERVAL - cost_time); if (sleep_time < 0) { sleep_time = 0; } diff --git a/src/share/ob_cluster_version.cpp b/src/share/ob_cluster_version.cpp index b6f8538aaf..72a5d128c0 100644 --- a/src/share/ob_cluster_version.cpp +++ b/src/share/ob_cluster_version.cpp @@ -170,7 +170,7 @@ int64_t ObClusterVersion::print_vsn(char *buf, const int64_t buf_len, uint64_t v const uint8_t minor_patch = OB_VSN_MINOR_PATCH(version); if (OB_UNLIKELY(!check_version_valid_(version))) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(ERROR, "invalid cluster version", KR(ret), KR(version), K(lbt())); + COMMON_LOG(ERROR, "invalid cluster version", KR(ret), K(version), K(lbt())); } else if (major < 3 || (3 == major && minor < 2) || (3 == major && 2 == minor && 0 == major_patch && minor_patch < 3)) { @@ -200,7 +200,7 @@ int64_t ObClusterVersion::print_version_str(char *buf, const int64_t buf_len, ui const uint8_t minor_patch = OB_VSN_MINOR_PATCH(version); if (OB_UNLIKELY(!check_version_valid_(version))) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(ERROR, "invalid cluster version", KR(version), K(lbt())); + COMMON_LOG(ERROR, "invalid cluster version", K(version), K(lbt())); } else if (major < 3 || (3 == major && minor < 2) || (3 == major && 2 == minor && 0 == major_patch && minor_patch < 3)) { diff --git a/src/share/ob_ddl_common.cpp b/src/share/ob_ddl_common.cpp index 2d08e807fe..5eba07fe1b 100644 --- a/src/share/ob_ddl_common.cpp +++ b/src/share/ob_ddl_common.cpp @@ -795,7 +795,7 @@ int ObDDLUtil::find_table_scan_table_id(const ObOpSpec *spec, uint64_t &table_id } else if (spec->is_table_scan()) { table_id = static_cast(spec)->get_ref_table_id(); } else { - for (int64_t i = 0; OB_SUCC(ret) && i < spec->get_child_cnt(); ++i) { + for (uint32_t i = 0; OB_SUCC(ret) && i < spec->get_child_cnt(); ++i) { if (OB_FAIL(SMART_CALL(find_table_scan_table_id(spec->get_child(i), table_id)))) { LOG_WARN("fail to find sample scan", K(ret)); } diff --git a/src/share/ob_encryption_struct.h b/src/share/ob_encryption_struct.h index 40e8375a37..4adbba0880 100644 --- a/src/share/ob_encryption_struct.h +++ b/src/share/ob_encryption_struct.h @@ -72,7 +72,7 @@ int ObEncryptKey::assign(const ObEncryptKey &rhs) { int ret = common::OB_SUCCESS; str_.set_length(0); - int64_t rhs_len = rhs.get_content().length(); + const int32_t rhs_len = rhs.get_content().length(); if (OB_UNLIKELY(rhs_len != str_.write(rhs.get_content().ptr(), rhs_len))) { ret = OB_ERR_UNEXPECTED; SHARE_LOG(WARN, "key content is wrong", K(ret), K(rhs), K(rhs_len)); @@ -104,7 +104,7 @@ int ObEncryptKey::set_content(const char *ptr, const int64_t len) ret = common::OB_INVALID_ARGUMENT; } else { str_.set_length(0); - str_.write(ptr, len); + str_.write(ptr, static_cast(len)); } return ret; } diff --git a/src/share/ob_encryption_util.cpp b/src/share/ob_encryption_util.cpp index dfff0d88a4..5a53cd760b 100644 --- a/src/share/ob_encryption_util.cpp +++ b/src/share/ob_encryption_util.cpp @@ -364,7 +364,7 @@ int ObHashUtil::hash(const enum ObHashAlgorithm algo, const ObString data, } else if (OB_FAIL(hash(algo, data_ptr, data.length(), buf, buf_len, out_len))) { LOG_WARN("fail to calc hash output", K(ret)); } else { - output.assign_ptr(buf, out_len); + output.assign_ptr(buf, static_cast(out_len)); } return ret; } diff --git a/src/share/ob_lob_access_utils.cpp b/src/share/ob_lob_access_utils.cpp index 1fcd0c334e..5ff5645ab6 100644 --- a/src/share/ob_lob_access_utils.cpp +++ b/src/share/ob_lob_access_utils.cpp @@ -204,7 +204,7 @@ int ObTextStringIter::get_outrow_lob_full_data() COMMON_LOG(WARN,"Lob: unable to read full data over 512M lob.", K(ret), K(param)); } else { ctx_->total_byte_len_ = param.byte_size_; - ctx_->buff_byte_len_ = param.byte_size_; + ctx_->buff_byte_len_ = static_cast(param.byte_size_);//TODO(gehao.wh): check convert from 64 to 32 ctx_->buff_ = static_cast(ctx_->alloc_->alloc(ctx_->buff_byte_len_)); ObString output_data; @@ -286,7 +286,7 @@ int ObTextStringIter::get_current_block(ObString &str) ret = OB_INVALID_ARGUMENT; COMMON_LOG(WARN, "Lob: iter not accessed", K(ret)); } else { - str.assign(ctx_->buff_, ctx_->content_byte_len_); + str.assign(ctx_->buff_, static_cast(ctx_->content_byte_len_)); } return ret; } @@ -392,7 +392,7 @@ int ObTextStringIter::get_first_block(ObString &str) COMMON_LOG(INFO,"Lob: buffer size changed due to configurations", K(ctx_->buff_byte_len_), K(ctx_->reserved_byte_len_), K(ctx_->reserved_len_), K(max_reserved_byte)); - ctx_->buff_byte_len_ = max_reserved_byte; + ctx_->buff_byte_len_ = static_cast(max_reserved_byte); } } @@ -422,9 +422,9 @@ int ObTextStringIter::get_first_block(ObString &str) } else { ctx_->content_byte_len_ = output_data.length(); // ToDo: @gehao get char len directly from lob mngr ? - ctx_->content_len_ = ObCharset::strlen_char(cs_type_, + ctx_->content_len_ = static_cast(ObCharset::strlen_char(cs_type_, output_data.ptr(), - static_cast(output_data.length())); + static_cast(output_data.length()))); ctx_->last_accessed_byte_len_ = 0; ctx_->last_accessed_len_ = 0; ctx_->accessed_byte_len_ = ctx_->content_byte_len_; @@ -461,13 +461,13 @@ int ObTextStringIter::reserve_data() } else if (!ctx_->is_backward_) { uint32 reserved_char_start = ctx_->content_len_ - ctx_->reserved_len_; uint32 reserved_char_pos = - ObCharset::charpos(cs_type_, ctx_->buff_, ctx_->content_byte_len_, reserved_char_start); + static_cast(ObCharset::charpos(cs_type_, ctx_->buff_, ctx_->content_byte_len_, reserved_char_start)); ctx_->reserved_byte_len_ = ctx_->content_byte_len_ - reserved_char_pos; MEMMOVE(ctx_->buff_, ctx_->buff_ + reserved_char_pos, ctx_->reserved_byte_len_); } else if (ctx_->is_backward_) { uint32 reserved_char_end = ctx_->reserved_len_ + 1; uint32 reserved_char_end_pos = - ObCharset::charpos(cs_type_, ctx_->buff_, ctx_->content_byte_len_, reserved_char_end); + static_cast(ObCharset::charpos(cs_type_, ctx_->buff_, ctx_->content_byte_len_, reserved_char_end)); ctx_->reserved_byte_len_ = reserved_char_end_pos; MEMMOVE(ctx_->buff_ + ctx_->content_byte_len_ - ctx_->reserved_byte_len_, ctx_->buff_, @@ -535,9 +535,9 @@ int ObTextStringIter::get_next_block_inner(ObString &str) } else { ctx_->content_byte_len_ = ctx_->reserved_byte_len_ + output_data.length(); // ToDo: @gehao get directly from lob mngr ? - uint32 cur_out_len = ObCharset::strlen_char(cs_type_, + uint32 cur_out_len = static_cast(ObCharset::strlen_char(cs_type_, output_data.ptr(), - static_cast(output_data.length())); + static_cast(output_data.length()))); ctx_->content_len_ = ctx_->reserved_len_ + cur_out_len; ctx_->last_accessed_byte_len_ = ctx_->accessed_byte_len_; ctx_->last_accessed_len_ = ctx_->accessed_len_; @@ -652,7 +652,7 @@ void ObTextStringIter::set_forward() uint64_t ObTextStringIter::get_start_offset() { - uint32_t start_offset = 0; + uint64_t start_offset = 0; if (!is_init_ || !is_outrow_ || !has_lob_header_ || state_ <= TEXTSTRING_ITER_INIT || OB_ISNULL(ctx_)) { } else { @@ -892,8 +892,8 @@ int ObTextStringIter::append_outrow_lob_fulldata(ObObj &obj, COMMON_LOG(WARN,"Lob: invalid mem locator", K(*mem_loc), K(pos)); } else { ObMemLobExternHeader *mem_loc_extern = reinterpret_cast(mem_loc->data_); - mem_loc_extern->payload_offset_ = pos - sizeof(ObLobLocator); - mem_loc_extern->payload_size_ = lob_data_byte_len; + mem_loc_extern->payload_offset_ = static_cast(pos - sizeof(ObLobLocator)); + mem_loc_extern->payload_size_ = static_cast(lob_data_byte_len); // copy inrow data ObTextStringIterState state; @@ -909,7 +909,7 @@ int ObTextStringIter::append_outrow_lob_fulldata(ObObj &obj, pos += src_block_data.length(); } OB_ASSERT(pos == res_byte_len); - obj.set_lob_value(obj.get_type(), buff, res_byte_len); + obj.set_lob_value(obj.get_type(), buff, static_cast(res_byte_len)); obj.set_has_lob_header(); // must has lob header } } @@ -1002,7 +1002,7 @@ void ObTextStringResult::calc_buffer_len(int64_t res_len) bool has_extern = lib::is_oracle_mode(); // even oracle may not need extern for temp data ObMemLobExternFlags extern_flags(has_extern); res_len += sizeof(ObLobCommon); - buff_len_ = ObLobLocatorV2::calc_locator_full_len(extern_flags, 0, res_len, false); + buff_len_ = ObLobLocatorV2::calc_locator_full_len(extern_flags, 0, static_cast(res_len), false); } else { LOG_WARN_RET(OB_NOT_IMPLEMENT, "Lob: out row temp lob not implemented", K(OB_NOT_IMPLEMENT), K(this), K(pos_), K(buff_len_)); @@ -1019,7 +1019,7 @@ int ObTextStringResult::fill_temp_lob_header(const int64_t res_len) LOG_WARN("Lob: allocate memory for lob result failed", K(type_), K(buff_len_), K(ret)); } else if (!(is_lob_storage(type_))) { // do nothing } else if (res_len <= OB_MAX_LONGTEXT_LENGTH - MAX_TMP_LOB_HEADER_LEN) { - ObLobLocatorV2 locator(buffer_, buff_len_, has_lob_header_); + ObLobLocatorV2 locator(buffer_, static_cast(buff_len_), has_lob_header_); // temp lob in oracle mode not need extern neither, for it does not have rowkey // However we mock extern failed in case of return it to old client ObMemLobExternFlags extern_flags(lib::is_oracle_mode()); @@ -1030,7 +1030,7 @@ int ObTextStringResult::fill_temp_lob_header(const int64_t res_len) extern_flags, rowkey_str, &lob_common, - res_len + sizeof(ObLobCommon), + static_cast(res_len + sizeof(ObLobCommon)), false))) { LOG_WARN("Lob: fill temp lob locator failed", K(type_), K(ret)); } else if (OB_FAIL((locator.set_payload_data(&lob_common, empty_str)))) { diff --git a/src/share/ob_local_device.cpp b/src/share/ob_local_device.cpp index 5f5428bc18..23374dcb3a 100644 --- a/src/share/ob_local_device.cpp +++ b/src/share/ob_local_device.cpp @@ -53,7 +53,7 @@ int ObLocalIOEvents::get_ith_ret_code(const int64_t i) const if (res >= 0) { ret_code = 0; } else { - ret_code = -res; + ret_code = static_cast(-res); } } else { SHARE_LOG_RET(WARN, ret_code, "invalid member", KP(io_events_), K(i), K(complete_io_cnt_)); @@ -64,7 +64,7 @@ int ObLocalIOEvents::get_ith_ret_code(const int64_t i) const int ObLocalIOEvents::get_ith_ret_bytes(const int64_t i) const { const int64_t res = static_cast(io_events_[i].res); - return (nullptr != io_events_ && i < complete_io_cnt_ && res >= 0) ? res : 0; + return (nullptr != io_events_ && i < complete_io_cnt_ && res >= 0) ? static_cast(res) : 0; } void *ObLocalIOEvents::get_ith_data(const int64_t i) const @@ -307,7 +307,7 @@ int ObLocalDevice::close(const ObIOFd &fd) if (OB_UNLIKELY(fd.is_block_file())) { ret = OB_INVALID_ARGUMENT; SHARE_LOG(WARN, "The block file does not need close, ", K(ret), K(fd)); - } else if (0 != ::close(fd.second_id_)) { + } else if (0 != ::close(static_cast(fd.second_id_))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "Fail to close file, ", K(ret), K(fd)); } @@ -488,7 +488,7 @@ int ObLocalDevice::fsync(const ObIOFd &fd) SHARE_LOG(WARN, "invalid fd, not normal file, ", K(ret), K(fd)); } else { int sys_ret = 0; - if (0 != (sys_ret = ::fsync(fd.second_id_))) { + if (0 != (sys_ret = ::fsync(static_cast(fd.second_id_)))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "Fail to fsync, ", K(ret), K(sys_ret), K(fd), KERRMSG); } @@ -504,7 +504,7 @@ int ObLocalDevice::fdatasync(const ObIOFd &fd) SHARE_LOG(WARN, "invalid fd, not normal file, ", K(ret), K(fd)); } else { int sys_ret = 0; - if (0 != (sys_ret = ::fdatasync(fd.second_id_))) { + if (0 != (sys_ret = ::fdatasync(static_cast(fd.second_id_)))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "Fail to fdatasync, ", K(ret), K(sys_ret), K(fd), KERRMSG); } @@ -520,7 +520,7 @@ int ObLocalDevice::fallocate(const ObIOFd &fd, mode_t mode, const int64_t offset SHARE_LOG(WARN, "invalid args, not normal file", K(ret), K(fd)); } else { int sys_ret = 0; - if (0 != (sys_ret = ::fallocate(fd.second_id_, mode, offset, len))) { + if (0 != (sys_ret = ::fallocate(static_cast(fd.second_id_), mode, offset, len))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "fail to fallocate", K(ret), K(sys_ret), K(fd), K(offset), K(len), KERRMSG); } @@ -534,7 +534,7 @@ int ObLocalDevice::lseek(const ObIOFd &fd, const int64_t offset, const int whenc if (OB_UNLIKELY(!fd.is_normal_file())) { ret = OB_INVALID_ARGUMENT; SHARE_LOG(WARN, "invalid args, not normal file", K(ret), K(fd)); - } else if (-1 == (result_offset = ::lseek(fd.second_id_, offset, whence))) { + } else if (-1 == (result_offset = ::lseek(static_cast(fd.second_id_), offset, whence))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "fail to lseek", K(ret), K(fd), K(offset), K(errno), KERRMSG); } @@ -619,7 +619,7 @@ int ObLocalDevice::fstat(const ObIOFd &fd, ObIODFileStat &statbuf) SHARE_LOG(WARN, "invalid args, not normal file", K(ret), K(fd)); } else { struct stat buf; - if (0 != ::fstat(fd.second_id_, &buf)) { + if (0 != ::fstat(static_cast(fd.second_id_), &buf)) { ret = convert_sys_errno(); SHARE_LOG(WARN, "Fail to stat file, ", K(ret), K(fd), K(errno), KERRMSG); } else { @@ -975,7 +975,7 @@ int ObLocalDevice::read( } else if (OB_UNLIKELY(!fd.is_normal_file())) { ret = OB_ERR_UNEXPECTED; SHARE_LOG(WARN, "fd is not normal file", K(ret), K(fd)); - } else if (-1 == (read_size = ::read(fd.second_id_, buf, size))) { + } else if (-1 == (read_size = ::read(static_cast(fd.second_id_), buf, size))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "fail to read", K(ret), K(fd), K(size), K(errno), KERRMSG); } @@ -995,7 +995,7 @@ int ObLocalDevice::write( } else if (OB_UNLIKELY(!fd.is_normal_file())) { ret = OB_ERR_UNEXPECTED; SHARE_LOG(WARN, "fd is not normal file", K(ret), K(fd)); - } else if (-1 == (write_size = ::write(fd.second_id_, buf, size))) { + } else if (-1 == (write_size = ::write(static_cast(fd.second_id_), buf, size))) { ret = convert_sys_errno(); SHARE_LOG(WARN, "fail to read", K(ret), K(fd), K(size), K(errno), KERRMSG); } @@ -1087,7 +1087,7 @@ int ObLocalDevice::io_prepare_pwrite( if (fd.is_block_file()) { ::io_prep_pwrite(&(local_iocb->iocb_), block_fd_, buf, count, get_block_file_offset(fd, offset)); } else { - ::io_prep_pwrite(&(local_iocb->iocb_), fd.second_id_, buf, count, offset); + ::io_prep_pwrite(&(local_iocb->iocb_), static_cast(fd.second_id_), buf, count, offset); } local_iocb->iocb_.data = callback; } @@ -1121,7 +1121,7 @@ int ObLocalDevice::io_prepare_pread( if (fd.is_block_file()) { ::io_prep_pread(&(local_iocb->iocb_), block_fd_, buf, count, get_block_file_offset(fd, offset)); } else { - ::io_prep_pread(&(local_iocb->iocb_), fd.second_id_, buf, count, offset); + ::io_prep_pread(&(local_iocb->iocb_), static_cast(fd.second_id_), buf, count, offset); } local_iocb->iocb_.data = callback; } @@ -1521,7 +1521,7 @@ int ObLocalDevice::pread_impl(const int64_t fd, void *buf, const int64_t size, c int64_t read_offset = offset; ssize_t sz = 0; while (OB_SUCC(ret) && read_sz > 0) { - sz = ::pread(fd, buffer, read_sz, read_offset); + sz = ::pread(static_cast(fd), buffer, read_sz, read_offset); if (sz < 0) { if (EINTR == errno) { SHARE_LOG(INFO, "pread is interrupted before any data is read, just retry", K(errno), KERRMSG); @@ -1552,7 +1552,7 @@ int ObLocalDevice::pwrite_impl(const int64_t fd, const void *buf, const int64_t int64_t write_offset = offset; ssize_t sz = 0; while (OB_SUCC(ret) && write_sz > 0) { - sz = ::pwrite(fd, buffer, write_sz, write_offset); + sz = ::pwrite(static_cast(fd), buffer, write_sz, write_offset); if (sz <= 0) { // if physical end of medium is reached and there's no space for any byte, EFBIG is set // and we think pwrite will never return 0 diff --git a/src/share/ob_occam_thread_pool.h b/src/share/ob_occam_thread_pool.h index 5db6e053ba..2f1a17bc94 100644 --- a/src/share/ob_occam_thread_pool.h +++ b/src/share/ob_occam_thread_pool.h @@ -200,7 +200,7 @@ public: is_inited_(false), is_stopped_(false) {} ~ObOccamThreadPool() { destroy(); } - int init(int64_t thread_num, int queue_size_square_of_2 = 14) + int init(int64_t thread_num, int64_t queue_size_square_of_2 = 14) { int ret = OB_SUCCESS; if (is_inited_) { diff --git a/src/share/ob_occam_time_guard.h b/src/share/ob_occam_time_guard.h index 30697f8778..5005f2df44 100644 --- a/src/share/ob_occam_time_guard.h +++ b/src/share/ob_occam_time_guard.h @@ -97,7 +97,7 @@ private: } } } - ob_usleep(500_ms); + ob_usleep(static_cast(500_ms)); } else { OCCAM_LOG(INFO, "thread hung detect thread is stopped"); break; @@ -263,7 +263,7 @@ public: if (OB_LIKELY(idx_ < CAPACITY)) { int64_t now = common::ObTimeUtility::fast_current_time(); line_array_[idx_] = static_cast(line); - click_poinsts_[idx_] = now - last_click_ts_; + click_poinsts_[idx_] = static_cast(now - last_click_ts_); last_click_ts_ = now; ++idx_; } @@ -435,7 +435,7 @@ struct TimeGuardFactory const int64_t line, const char *mod) { UNUSED(line); - return ObOccamTimeGuard(threshold1, file, func, mod); + return ObOccamTimeGuard(static_cast(threshold1), file, func, mod); } static ObOccamTimeGuardDetectHung make_guard(const int64_t threshold1, const int64_t threshold2, @@ -443,7 +443,8 @@ struct TimeGuardFactory const char *func, const int64_t line, const char *mod) { - return ObOccamTimeGuardDetectHung(threshold1, threshold2, file, func, mod, line); + return ObOccamTimeGuardDetectHung(static_cast(threshold1), + static_cast(threshold2), file, func, mod, line); } }; diff --git a/src/share/ob_order_perserving_encoder.cpp b/src/share/ob_order_perserving_encoder.cpp index e7a54f10fb..8beabf8788 100644 --- a/src/share/ob_order_perserving_encoder.cpp +++ b/src/share/ob_order_perserving_encoder.cpp @@ -690,7 +690,7 @@ int ObOrderPerservingEncoder::encode_from_number(ObNumber val, to++; // digits encoding - int32_t digits_mask = (int64_t)((~se) ^ 0x80) >> 8; + int32_t digits_mask = static_cast((int64_t)((~se) ^ 0x80) >> 8); uint32_t *digits_ptr = val.get_digits(); for (int64_t i = 0; i < desc.len_; i++) { uint32_t dig = bswap_32((digits_ptr[i] + 1) ^ digits_mask); diff --git a/src/share/ob_tablet_replica_checksum_operator.cpp b/src/share/ob_tablet_replica_checksum_operator.cpp index 8ac1207de8..24005af601 100644 --- a/src/share/ob_tablet_replica_checksum_operator.cpp +++ b/src/share/ob_tablet_replica_checksum_operator.cpp @@ -169,7 +169,7 @@ int64_t ObTabletReplicaReportColumnMeta::get_string_length() const int64_t ObTabletReplicaReportColumnMeta::get_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; - int32_t column_cnt = column_checksums_.count(); + int32_t column_cnt = static_cast(column_checksums_.count()); common::databuff_printf(buf, buf_len, pos, "magic:%lX,", MAGIC_NUMBER); common::databuff_printf(buf, buf_len, pos, "compat:%d,", compat_version_); common::databuff_printf(buf, buf_len, pos, "method:%d,", checksum_method_); @@ -796,7 +796,7 @@ int ObTabletReplicaChecksumOperator::construct_tablet_replica_checksum_item_( item.tenant_id_ = (uint64_t)int_tenant_id; item.tablet_id_ = (uint64_t)int_tablet_id; item.ls_id_ = ls_id; - if (OB_UNLIKELY(!item.server_.set_ip_addr(ip, port))) { + if (OB_UNLIKELY(!item.server_.set_ip_addr(ip, static_cast(port)))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("fail to set ip_addr", KR(ret), K(item), K(ip), K(port)); } else if (OB_FAIL(set_column_meta_with_hex_str(column_meta_hex_str, item.column_meta_))) { @@ -1614,7 +1614,7 @@ int ObTabletReplicaChecksumOperator::get_visible_column_meta( ret = OB_SIZE_OVERFLOW; LOG_WARN("size overflow", KR(ret), K(pos), K(length)); } else { - column_meta_visible_str.assign(column_meta_str, pos); + column_meta_visible_str.assign(column_meta_str, static_cast(pos)); } return ret; } @@ -1654,7 +1654,7 @@ int ObTabletReplicaChecksumOperator::get_hex_column_meta( ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - column_meta_hex_str.assign_ptr(hex_buf, hex_size); + column_meta_hex_str.assign_ptr(hex_buf, static_cast(hex_size)); } return ret; } diff --git a/src/share/ob_task_define.cpp b/src/share/ob_task_define.cpp index d1659fc81f..adab2c67be 100644 --- a/src/share/ob_task_define.cpp +++ b/src/share/ob_task_define.cpp @@ -66,7 +66,7 @@ public: private: void per_err_logs(int &first_thread_cnt, int &left_cnt) { - int total_cnt = std::min(rate_, (int64_t)INT32_MAX); + int total_cnt = std::min(static_cast(rate_), INT32_MAX); first_thread_cnt = std::min(std::max(total_cnt / 2, 24), 48); left_cnt = std::max(0, total_cnt - first_thread_cnt); } @@ -310,7 +310,7 @@ int ObSyslogPerErrLimiter::do_acquire(int64_t permits, int log_level, int errcod int ret = OB_SUCCESS; if (log_level == OB_LOG_LEVEL_WARN && inited_ && rate_ > 0) { PerErrorItem &perr = locate_perr(errcode); - int mytid = GETTID(); + int mytid = static_cast(GETTID()); int tid = ATOMIC_LOAD(&perr.first_tid_); int tidcnt = -1; if (0 == tid) { diff --git a/src/share/ob_tenant_mgr.cpp b/src/share/ob_tenant_mgr.cpp index 52699a12de..4931196f90 100644 --- a/src/share/ob_tenant_mgr.cpp +++ b/src/share/ob_tenant_mgr.cpp @@ -37,7 +37,7 @@ namespace oceanbase namespace lib { int get_max_thread_num() { - return 0 == GCONF._ob_max_thread_num ? INT32_MAX : GCONF._ob_max_thread_num; + return 0 == GCONF._ob_max_thread_num ? INT32_MAX : static_cast(GCONF._ob_max_thread_num); } } diff --git a/src/share/ob_thread_mgr.h b/src/share/ob_thread_mgr.h index 7402d75cc6..ede342ca34 100644 --- a/src/share/ob_thread_mgr.h +++ b/src/share/ob_thread_mgr.h @@ -120,7 +120,7 @@ public: private: char buf_[sizeof(MyObThreadPool)]; MyObThreadPool *th_ = nullptr; - int thread_cnt_; + int64_t thread_cnt_; }; } // end of namespace share diff --git a/src/share/object/ob_obj_cast.cpp b/src/share/object/ob_obj_cast.cpp index 5c7561ef9c..b8655f0596 100644 --- a/src/share/object/ob_obj_cast.cpp +++ b/src/share/object/ob_obj_cast.cpp @@ -381,7 +381,7 @@ OB_INLINE int get_cast_ret(const ObCastMode cast_mode, if (params.res_accuracy_ != NULL && OB_SUCCESS == ret) {\ params.res_accuracy_->set_scale(res_scale);\ params.res_accuracy_->set_precision(res_precision);\ - params.res_accuracy_->set_length(res_length);\ + params.res_accuracy_->set_length(static_cast(res_length));\ } #define SET_RES_ACCURACY_STRING(type, res_precision, res_length) \ @@ -750,7 +750,7 @@ int ObHexUtils::rawtohex(const ObObj &text, ObCastCtx &cast_ctx, ObObj &result) ObScale res_scale = -1; char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); - int64_t length = ob_gcvt_opt(float_value, OB_GCVT_ARG_FLOAT, sizeof(buf) - 1, + int64_t length = ob_gcvt_opt(float_value, OB_GCVT_ARG_FLOAT, static_cast(sizeof(buf) - 1), buf, NULL, TRUE, TRUE); ObString float_str(sizeof(buf), static_cast(length), buf); if (OB_FAIL(nmb.from_sci_opt(float_str.ptr(), float_str.length(), @@ -781,7 +781,7 @@ int ObHexUtils::rawtohex(const ObObj &text, ObCastCtx &cast_ctx, ObObj &result) ObScale res_scale = -1; char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); - int64_t length = ob_gcvt_opt(double_value, OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, + int64_t length = ob_gcvt_opt(double_value, OB_GCVT_ARG_DOUBLE, static_cast(sizeof(buf) - 1), buf, NULL, TRUE, TRUE); ObString double_str(sizeof(buf), static_cast(length), buf); if (OB_FAIL(nmb.from_sci_opt(double_str.ptr(), double_str.length(), @@ -2124,7 +2124,7 @@ static int float_number(const ObObjType expect_type, ObObjCastParams ¶ms, MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); int64_t length = 0; if (lib::is_oracle_mode()) { - length = ob_gcvt_opt(in.get_float(), OB_GCVT_ARG_FLOAT, sizeof(buf) - 1, + length = ob_gcvt_opt(in.get_float(), OB_GCVT_ARG_FLOAT, static_cast(sizeof(buf) - 1), buf, NULL, TRUE, TRUE); } else { length = ob_gcvt(in.get_float(), OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, buf, NULL); @@ -2245,7 +2245,7 @@ static int float_string(const ObObjType expect_type, ObObjCastParams ¶ms, if (0 <= scale) { length = ob_fcvt(in.get_float(), scale, sizeof(buf) - 1, buf, NULL); } else { - length = ob_gcvt_opt(in.get_float(), OB_GCVT_ARG_FLOAT, sizeof(buf) - 1, + length = ob_gcvt_opt(in.get_float(), OB_GCVT_ARG_FLOAT, static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); } } @@ -2557,7 +2557,7 @@ static int double_number(const ObObjType expect_type, ObObjCastParams ¶ms, } else { char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); - int64_t length = ob_gcvt_opt(in.get_double(), OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, + int64_t length = ob_gcvt_opt(in.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); ObString str(sizeof(buf), static_cast(length), buf); number::ObNumber nmb; @@ -2721,7 +2721,7 @@ static int double_string(const ObObjType expect_type, ObObjCastParams ¶ms, length = ob_fcvt(in.get_double(), scale, sizeof(buf) - 1, buf, NULL); } else { length = ob_gcvt_opt(in.get_double(), OB_GCVT_ARG_DOUBLE, - sizeof(buf) - 1, buf, NULL, lib::is_oracle_mode(), TRUE); + static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); } } ObString str(sizeof(buf), static_cast(length), buf); @@ -5316,7 +5316,7 @@ static int string_string(const ObObjType expect_type, ObObjCastParams ¶ms, break; } ret = ObCharset::charset_convert(in.get_collation_type(), str.ptr() + str_offset, - offset, params.dest_collation_, buf + buf_offset, buf_len - buf_offset, result_len); + static_cast(offset), params.dest_collation_, buf + buf_offset, buf_len - buf_offset, result_len); str_offset += offset; if (OB_SUCCESS == ret) { buf_offset += result_len; @@ -5329,7 +5329,7 @@ static int string_string(const ObObjType expect_type, ObObjCastParams ¶ms, ret = OB_SIZE_OVERFLOW; LOG_WARN("size overflow", K(ret), K(str), KPHEX(str.ptr(), str.length())); } else { - result_len = buf_offset; + result_len = static_cast(buf_offset); ret = OB_SUCCESS; LOG_WARN("charset convert failed", K(ret), K(in.get_collation_type()), K(params.dest_collation_)); @@ -5575,7 +5575,7 @@ static int string_set(const ObExpectType &expect_type, ObObjCastParams ¶ms, value = ObCharset::strntoull(in_str.ptr(), in_str.length(), 10, &err); if(err == 0) { ret = OB_SUCCESS; - uint32_t val_cnt = type_infos->count(); + uint32_t val_cnt = static_cast(type_infos->count()); if (OB_UNLIKELY(val_cnt <= 0)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpect val_cnt", K(in), K(out), K(expect_type), K(ret)); @@ -5869,7 +5869,7 @@ static int string_json(const ObObjType expect_type, ObObjCastParams ¶ms, { int ret = OB_SUCCESS; ObObj tmp_val; - int64_t res_length = -1; + int32_t res_length = -1; bool need_charset_convert = ((CS_TYPE_BINARY != in.get_collation_type()) && (ObCharset::charset_type_by_coll(in.get_collation_type()) != ObCharset::charset_type_by_coll(params.dest_collation_))); @@ -8347,7 +8347,7 @@ static int json_raw(const ObObjType expect_type, ObObjCastParams ¶ms, } if (!need_charset_convert) { if (accuracy_max_len > 0 && accuracy_max_len < j_buf.length()) { - temp_str_val.assign_ptr(j_buf.ptr(), accuracy_max_len); + temp_str_val.assign_ptr(j_buf.ptr(), static_cast(accuracy_max_len)); } ret = copy_string(params, ObLongTextType, temp_str_val, t_out); t_out.set_collation_type(params.dest_collation_); @@ -8359,7 +8359,7 @@ static int json_raw(const ObObjType expect_type, ObObjCastParams ¶ms, ret = string_string(ObLongTextType, params, tmp_obj, t_out, cast_mode); if (accuracy_max_len && accuracy_max_len < t_out.get_string().length()) { ObString tmp_str = t_out.get_string(); - t_out.set_string(ObLongTextType, tmp_str.ptr(), accuracy_max_len); + t_out.set_string(ObLongTextType, tmp_str.ptr(), static_cast(accuracy_max_len)); } } if (OB_SUCC(ret)) { @@ -8432,7 +8432,7 @@ static int json_string(const ObObjType expect_type, ObObjCastParams ¶ms, ret = string_string(expect_type, params, tmp_obj, out, cast_mode); if (accuracy_max_len && accuracy_max_len < out.get_string().length()) { ObString tmp_str = out.get_string(); - out.set_string(expect_type, tmp_str.ptr(), accuracy_max_len); + out.set_string(expect_type, tmp_str.ptr(), static_cast(accuracy_max_len)); } if (ObTextTC == ob_obj_type_class(expect_type)) { out.set_inrow(); diff --git a/src/share/ratelimit/ob_rl_mgr.cpp b/src/share/ratelimit/ob_rl_mgr.cpp index 86f377f9e3..8ef2c2cfe2 100644 --- a/src/share/ratelimit/ob_rl_mgr.cpp +++ b/src/share/ratelimit/ob_rl_mgr.cpp @@ -253,7 +253,7 @@ int ObRatelimitMgr::update_local_s2r_map() if (line < s2r_map_list_.count()) { s2r_changed = 1; - for (int i = (s2r_map_list_.count() - 1); i >= line; i--) { + for (int64_t i = (s2r_map_list_.count() - 1); i >= line; i--) { s2r_map_list_.remove(i); } } @@ -345,7 +345,7 @@ int ObRatelimitMgr::update_region_max_bw() if (line < peer_region_bw_list_.count()) { region_list_changed = 1; - for (int i = (peer_region_bw_list_.count() - 1); i >= line; i--) { + for (int64_t i = (peer_region_bw_list_.count() - 1); i >= line; i--) { peer_region_bw_list_.remove(i); } } @@ -355,7 +355,7 @@ int ObRatelimitMgr::update_region_max_bw() } OB_LOG(DEBUG, "Got peer_region_bw_list_", K(peer_region_bw_list_.count()), K(local_server_list_.count()), K(region_list_changed)); if (region_list_changed) { - int max_bw = 0; + int64_t max_bw = 0; for (int i = 0; i < peer_region_bw_list_.count(); i++) { region_bw_stat = &peer_region_bw_list_[i]; region_bw_stat->server_bw_list_.destroy(); diff --git a/src/share/ratelimit/ob_rl_mgr.h b/src/share/ratelimit/ob_rl_mgr.h index e0b7928b48..06a7e5e578 100644 --- a/src/share/ratelimit/ob_rl_mgr.h +++ b/src/share/ratelimit/ob_rl_mgr.h @@ -34,7 +34,7 @@ public: REGION_BW_MARGIN = 2 * 1000 * 1000, // 2MB }; ObRatelimitMgr(); - ~ObRatelimitMgr(); + virtual ~ObRatelimitMgr(); int init(common::ObAddr& self_addr, observer::ObSrvNetworkFrame *net_frame_, observer::ObGlobalContext *gctx); void destroy(); int start(); @@ -63,7 +63,7 @@ private: int64_t pending_rpc_count_; SingleWaitCond swc_; int64_t stat_period_; - int self_server_idx_; + int64_t self_server_idx_; common::ObAddr self_addr_; common::ObRegion self_region_; ObServerSEArray local_server_list_; @@ -78,4 +78,4 @@ private: } // namespace share } // namespace oceanbase -#endif \ No newline at end of file +#endif diff --git a/src/share/rc/ob_tenant_base.h b/src/share/rc/ob_tenant_base.h index fae3dd0672..9acd98f64a 100644 --- a/src/share/rc/ob_tenant_base.h +++ b/src/share/rc/ob_tenant_base.h @@ -369,9 +369,9 @@ public: int update_thread_cnt(double tenant_unit_cpu); int64_t update_memory_size(int64_t memory_size) { - int orig_size_ = memory_size_; + int64_t orig_size = memory_size_; memory_size_ = memory_size; - return orig_size_; + return orig_size; } int64_t get_memory_size() { return memory_size_; } bool update_mini_mode(bool mini_mode) diff --git a/src/share/redolog/ob_log_file_handler.cpp b/src/share/redolog/ob_log_file_handler.cpp index e36e28bd49..258c1e7df2 100644 --- a/src/share/redolog/ob_log_file_handler.cpp +++ b/src/share/redolog/ob_log_file_handler.cpp @@ -366,7 +366,7 @@ int ObLogFileHandler::unlink(const char* file_path) while (OB_SUCC(ret)) { if (OB_FAIL(THE_IO_DEVICE->unlink(file_path)) && OB_NO_SUCH_FILE_OR_DIRECTORY != ret) { LOG_WARN("unlink failed", K(ret), K(file_path)); - ob_usleep(UNLINK_RETRY_INTERVAL_US); + ob_usleep(static_cast(UNLINK_RETRY_INTERVAL_US)); ret = OB_SUCCESS; } else if (OB_NO_SUCH_FILE_OR_DIRECTORY == ret) { ret = OB_SUCCESS; @@ -401,7 +401,7 @@ int ObLogFileHandler::normal_retry_write(void *buf, int64_t size, int64_t offset if (REACH_TIME_INTERVAL(LOG_INTERVAL_US)) { LOG_WARN("fail to write", K(ret), KP(buf), K(size), K(offset), K(retry_cnt), K(write_size)); } else { - ob_usleep(SLEEP_TIME_US); + ob_usleep(static_cast(SLEEP_TIME_US)); } } } while (OB_FAIL(ret)); @@ -425,7 +425,7 @@ int ObLogFileHandler::open(const char *file_path, const int flags, const mode_t LOG_WARN("failed to open file", K(ret), K(file_path), K(errno), KERRMSG); if (OB_TIMEOUT == ret || OB_EAGAIN == ret) { ret = OB_SUCCESS; - ob_usleep(ObLogDefinition::RETRY_SLEEP_TIME_IN_US); + ob_usleep(static_cast(ObLogDefinition::RETRY_SLEEP_TIME_IN_US)); } } else { break; diff --git a/src/share/redolog/ob_log_file_reader.cpp b/src/share/redolog/ob_log_file_reader.cpp index f03efe6cf4..44969c6731 100644 --- a/src/share/redolog/ob_log_file_reader.cpp +++ b/src/share/redolog/ob_log_file_reader.cpp @@ -46,7 +46,7 @@ uint64_t ObLogReadFdKey::hash() const { uint64_t hash_val = 0; if (is_valid()) { - hash_val = common::murmurhash(&path_, STRLEN(path_), hash_val); + hash_val = common::murmurhash(&path_, static_cast(STRLEN(path_)), hash_val); } return hash_val; } diff --git a/src/share/resource_manager/ob_cgroup_ctrl.cpp b/src/share/resource_manager/ob_cgroup_ctrl.cpp index e342ff76c5..a08dd760f3 100644 --- a/src/share/resource_manager/ob_cgroup_ctrl.cpp +++ b/src/share/resource_manager/ob_cgroup_ctrl.cpp @@ -566,7 +566,7 @@ int ObCgroupCtrl::get_cpu_usage(const uint64_t tenant_id, int32_t &cpu_usage) if (0 == last_usage_check_time_) { last_cpu_usage_ = cur_usage; } else if (cur_time - last_usage_check_time_ > 1000000) { - cpu_usage = (cur_usage - last_cpu_usage_) / (cur_time - last_usage_check_time_); + cpu_usage = static_cast(cur_usage - last_cpu_usage_) / (cur_time - last_usage_check_time_); } return ret; @@ -772,14 +772,14 @@ int ObCgroupCtrl::write_string_to_file_(const char *filename, const char *conten { int ret = OB_SUCCESS; int fd = -1; - int tmp_ret = -1; + int64_t write_size = -1; if ((fd = ::open(filename, O_WRONLY)) < 0) { ret = OB_IO_ERROR; LOG_WARN("open file error", K(filename), K(errno), KERRMSG, K(ret)); - } else if ((tmp_ret = write(fd, content, strlen(content))) < 0) { + } else if ((write_size = write(fd, content, static_cast(strlen(content)))) < 0) { ret = OB_IO_ERROR; LOG_WARN("write file error", - K(filename), K(content), K(ret), K(errno), KERRMSG, K(tmp_ret)); + K(filename), K(content), K(ret), K(errno), KERRMSG); } else { // do nothing } @@ -795,11 +795,11 @@ int ObCgroupCtrl::get_string_from_file_(const char *filename, char content[VALUE { int ret = OB_SUCCESS; int fd = -1; - int tmp_ret = -1; + int64_t read_size = -1; if ((fd = ::open(filename, O_RDONLY)) < 0) { ret = OB_IO_ERROR; LOG_WARN("open file error", K(filename), K(errno), KERRMSG, K(ret)); - } else if ((tmp_ret = read(fd, content, VALUE_BUFSIZE)) < 0) { + } else if ((read_size = read(fd, content, VALUE_BUFSIZE)) < 0) { ret = OB_IO_ERROR; LOG_WARN("read file error", K(filename), K(content), K(ret), K(errno), KERRMSG, K(ret)); diff --git a/src/share/restore/ob_physical_restore_info.cpp b/src/share/restore/ob_physical_restore_info.cpp index f045180078..11920da02e 100644 --- a/src/share/restore/ob_physical_restore_info.cpp +++ b/src/share/restore/ob_physical_restore_info.cpp @@ -114,7 +114,7 @@ int ObPhysicalRestoreWhiteList::get_format_str( ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected format str", KR(ret), K(format_str_buf), K(format_str_length)); } else { - str.assign_ptr(format_str_buf, format_str_length - 1); + str.assign_ptr(format_str_buf, static_cast(format_str_length - 1)); LOG_DEBUG("get format white_list str", KR(ret), K(str)); } return ret; @@ -152,7 +152,7 @@ int ObPhysicalRestoreWhiteList::get_hex_str( ret = OB_SIZE_OVERFLOW; LOG_WARN("encode error", KR(ret), K(hex_pos), K(hex_size)); } else { - str.assign_ptr(hex_buf, hex_size); + str.assign_ptr(hex_buf, static_cast(hex_size)); LOG_DEBUG("get hex white_list str", KR(ret), K(str)); } return ret; diff --git a/src/share/restore/ob_restore_persist_helper.cpp b/src/share/restore/ob_restore_persist_helper.cpp index 06eeebe22d..e250a6e403 100644 --- a/src/share/restore/ob_restore_persist_helper.cpp +++ b/src/share/restore/ob_restore_persist_helper.cpp @@ -314,7 +314,7 @@ int ObLSRestoreProgressPersistInfo::parse_from(common::sqlclient::ObMySQLResult EXTRACT_INT_FIELD_MYSQL(result, OB_STR_FINISH_TABLET_COUNT, finish_tablet_count_, int64_t); EXTRACT_INT_FIELD_MYSQL(result, OB_STR_TOTAL_BYTES, total_bytes_, int64_t); EXTRACT_INT_FIELD_MYSQL(result, OB_STR_FINISH_BYTES, finish_bytes_, int64_t); - EXTRACT_INT_FIELD_MYSQL(result, OB_STR_RESULT, result_, int64_t); + EXTRACT_INT_FIELD_MYSQL(result, OB_STR_RESULT, result_, int32_t); EXTRACT_STRBUF_FIELD_MYSQL(result, OB_STR_TRACE_ID, trace_id, OB_MAX_TRACE_ID_BUFFER_SIZE, real_length); EXTRACT_STRBUF_FIELD_MYSQL(result, OB_STR_COMMENT, comment, MAX_TABLE_COMMENT_LENGTH, real_length); @@ -395,7 +395,7 @@ const char *ObHisRestoreJobPersistInfo::get_status_str() const int ObHisRestoreJobPersistInfo::get_status(const ObString &str_str) const { int status = -1; - for (int64_t i = 0; i < ARRAYSIZEOF(STATUS_STR); ++i) { + for (int32_t i = 0; i < ARRAYSIZEOF(STATUS_STR); ++i) { if (0 == str_str.case_compare(STATUS_STR[i])) { status = i; break; diff --git a/src/share/scheduler/ob_dag_scheduler.cpp b/src/share/scheduler/ob_dag_scheduler.cpp index f5a2b1d047..e519ca93b1 100644 --- a/src/share/scheduler/ob_dag_scheduler.cpp +++ b/src/share/scheduler/ob_dag_scheduler.cpp @@ -1062,7 +1062,7 @@ void ObIDagNet::gene_dag_info(ObDagInfo &info, const char *list_info) info.running_task_cnt_ = dag_record_map_.size(); info.add_time_ = add_time_; info.start_time_ = start_time_; - int64_t tmp_ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; if (OB_TMP_FAIL(fill_dag_net_key(info.dag_net_key_, OB_DAG_KEY_LENGTH))) { COMMON_LOG_RET(WARN, tmp_ret, "failed to fill dag key", K(tmp_ret)); } @@ -1096,7 +1096,7 @@ void ObIDag::gene_dag_info(ObDagInfo &info, const char *list_info) info.running_task_cnt_ = running_task_cnt_; info.add_time_ = add_time_; info.start_time_ = start_time_; - int64_t tmp_ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; if (OB_TMP_FAIL(fill_dag_key(info.dag_key_, OB_DAG_KEY_LENGTH))) { COMMON_LOG_RET(WARN, tmp_ret, "failed to fill dag key", K(tmp_ret)); } @@ -1384,7 +1384,7 @@ int ObTenantDagWorker::set_dag_resource() LOG_WARN("bind back thread to group failed", K(ret), K(GETTID()), K(MTL_ID()), K(group_id)); } else { ATOMIC_SET(&group_id_, group_id); - THIS_WORKER.set_group_id(group_id); + THIS_WORKER.set_group_id(static_cast(group_id)); } return ret; } @@ -1849,9 +1849,9 @@ int ObTenantDagScheduler::add_dag( void ObTenantDagScheduler::dump_dag_status() { if (REACH_TENANT_TIME_INTERVAL(DUMP_DAG_STATUS_INTERVAL)) { - int32_t running_task[ObDagPrio::DAG_PRIO_MAX]; - int32_t low_limits[ObDagPrio::DAG_PRIO_MAX]; - int32_t up_limits[ObDagPrio::DAG_PRIO_MAX]; + int64_t running_task[ObDagPrio::DAG_PRIO_MAX]; + int64_t low_limits[ObDagPrio::DAG_PRIO_MAX]; + int64_t up_limits[ObDagPrio::DAG_PRIO_MAX]; int64_t dag_count[ObDagType::DAG_TYPE_MAX]; int64_t dag_net_count[ObDagNetType::DAG_NET_TYPE_MAX]; int64_t ready_dag_count[ObDagPrio::DAG_PRIO_MAX]; @@ -2914,7 +2914,7 @@ int ObTenantDagScheduler::schedule() void ObTenantDagScheduler::loop_dag_net() { - int64_t tmp_ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; if (OB_TMP_FAIL(loop_blocking_dag_net_list())) { COMMON_LOG_RET(WARN, tmp_ret, "failed to loop blocking dag net list", K(tmp_ret)); } @@ -3071,18 +3071,18 @@ void ObTenantDagScheduler::update_work_thread_num() work_thread_num_ = threads_sum; } -int ObTenantDagScheduler::set_thread_score(const int64_t priority, const int32_t score) +int ObTenantDagScheduler::set_thread_score(const int64_t priority, const int64_t score) { int ret = OB_SUCCESS; if (IS_NOT_INIT) { ret = OB_NOT_INIT; COMMON_LOG(WARN, "ObTenantDagScheduler is not inited", K(ret)); - } else if (OB_UNLIKELY(priority < 0 || priority >= ObDagPrio::DAG_PRIO_MAX || score < 0)) { + } else if (OB_UNLIKELY(priority < 0 || priority >= ObDagPrio::DAG_PRIO_MAX || score < 0 || score > INT32_MAX)) { ret = OB_INVALID_ARGUMENT; COMMON_LOG(WARN, "invalid argument", K(ret), K(priority), K(score)); } else { ObThreadCondGuard guard(scheduler_sync_); - const int32_t old_val = up_limits_[priority]; + const int64_t old_val = up_limits_[priority]; up_limits_[priority] = 0 == score ? OB_DAG_PRIOS[priority].score_ : score; low_limits_[priority] = up_limits_[priority]; if (old_val != up_limits_[priority]) { @@ -3096,9 +3096,9 @@ int ObTenantDagScheduler::set_thread_score(const int64_t priority, const int32_t return ret; } -int32_t ObTenantDagScheduler::get_running_task_cnt(const ObDagPrio::ObDagPrioEnum priority) +int64_t ObTenantDagScheduler::get_running_task_cnt(const ObDagPrio::ObDagPrioEnum priority) { - int32_t count = -1; + int64_t count = -1; if (priority >= 0 && priority < ObDagPrio::DAG_PRIO_MAX) { ObThreadCondGuard guard(scheduler_sync_); count = running_task_cnts_[priority]; @@ -3108,7 +3108,7 @@ int32_t ObTenantDagScheduler::get_running_task_cnt(const ObDagPrio::ObDagPrioEnu return count; } -int ObTenantDagScheduler::get_up_limit(const int64_t prio, int32_t &up_limit) +int ObTenantDagScheduler::get_up_limit(const int64_t prio, int64_t &up_limit) { int ret = OB_SUCCESS; up_limit = 0; diff --git a/src/share/scheduler/ob_dag_scheduler.h b/src/share/scheduler/ob_dag_scheduler.h index 536a1ffa11..7408933a40 100644 --- a/src/share/scheduler/ob_dag_scheduler.h +++ b/src/share/scheduler/ob_dag_scheduler.h @@ -668,13 +668,13 @@ public: int64_t size(const int64_t prio) { - int64_t ret = 0; + int64_t len = 0; if (prio >= 0 && prio < PRIO_CNT) { - ret = dlists_[prio].get_size(); + len = dlists_[prio].get_size(); } else { - COMMON_LOG(ERROR, "invalid priority", K(prio), K(PRIO_CNT)); + COMMON_LOG_RET(ERROR, OB_INVALID_ARGUMENT, "invalid priority", K(prio), K(PRIO_CNT)); } - return ret; + return len; } private: common::ObDList dlists_[PRIOS]; @@ -780,7 +780,7 @@ public: void notify(); void destroy(); void get_default_config(); - int32_t get_work_thread_num() const { return work_thread_num_; } + int64_t get_work_thread_num() const { return work_thread_num_; } bool is_empty() const { return dag_list_[READY_DAG_LIST].is_empty() && dag_list_[WAITING_DAG_LIST].is_empty() @@ -789,8 +789,8 @@ public: int64_t get_cur_dag_cnt() const { return dag_cnt_; } int sys_task_start(ObIDag *dag); int64_t get_dag_count(const ObDagType::ObDagTypeEnum type); - int32_t get_running_task_cnt(const ObDagPrio::ObDagPrioEnum priority); - int32_t get_up_limit(const int64_t prio, int32_t &up_limit); + int64_t get_running_task_cnt(const ObDagPrio::ObDagPrioEnum priority); + int32_t get_up_limit(const int64_t prio, int64_t &up_limit); int check_dag_exist(const ObIDag *dag, bool &exist); int cancel_dag(const ObIDag *dag, ObIDag *parent_dag = nullptr); int get_all_dag_info( @@ -881,7 +881,7 @@ private: int schedule_one(const int64_t priority); int dispatch_task(ObITask &task, ObTenantDagWorker *&ret_worker, const int64_t priority); void destroy_all_workers(); - int set_thread_score(const int64_t priority, const int32_t concurrency); + int set_thread_score(const int64_t priority, const int64_t concurrency); bool try_switch(ObTenantDagWorker &worker); int try_switch(ObTenantDagWorker &worker, const int64_t src_prio, const int64_t dest_prio, bool &need_pause); void pause_worker(ObTenantDagWorker &worker, const int64_t priority); @@ -925,13 +925,13 @@ private: int64_t dag_limit_; int64_t check_period_; int64_t loop_waiting_dag_list_period_; - int32_t total_worker_cnt_; - int32_t work_thread_num_; - int32_t default_work_thread_num_; - int32_t total_running_task_cnt_; - int32_t running_task_cnts_[ObDagPrio::DAG_PRIO_MAX]; - int32_t low_limits_[ObDagPrio::DAG_PRIO_MAX]; // wait to delete - int32_t up_limits_[ObDagPrio::DAG_PRIO_MAX]; // wait to delete + int64_t total_worker_cnt_; + int64_t work_thread_num_; + int64_t default_work_thread_num_; + int64_t total_running_task_cnt_; + int64_t running_task_cnts_[ObDagPrio::DAG_PRIO_MAX]; + int64_t low_limits_[ObDagPrio::DAG_PRIO_MAX]; // wait to delete + int64_t up_limits_[ObDagPrio::DAG_PRIO_MAX]; // wait to delete int64_t dag_cnts_[ObDagType::DAG_TYPE_MAX]; int64_t dag_net_cnts_[ObDagNetType::DAG_NET_TYPE_MAX]; common::ObFIFOAllocator allocator_; diff --git a/src/share/schema/ob_column_schema.h b/src/share/schema/ob_column_schema.h index 0792bffa97..ecd8323c5a 100644 --- a/src/share/schema/ob_column_schema.h +++ b/src/share/schema/ob_column_schema.h @@ -102,6 +102,7 @@ public: inline void set_data_type(const common::ColumnType type) { meta_type_.set_type(type); } inline void set_meta_type(const common::ObObjMeta type) { meta_type_ = type; } inline void set_accuracy(const common::ObAccuracy &accuracy) { accuracy_ = accuracy; } + inline void set_data_length(const int64_t length) { set_data_length(static_cast(length)); } //TODO(xiaofeng.lby): fix it later inline void set_data_length(const int32_t length) { accuracy_.set_length(length); } inline void set_data_precision(const int16_t precision) { accuracy_.set_precision(precision); } inline void set_length_semantics(const int16_t value) { accuracy_.set_length_semantics(value); } diff --git a/src/share/schema/ob_multi_version_schema_service.cpp b/src/share/schema/ob_multi_version_schema_service.cpp index 6c57156725..2dc9beb5e8 100644 --- a/src/share/schema/ob_multi_version_schema_service.cpp +++ b/src/share/schema/ob_multi_version_schema_service.cpp @@ -2181,7 +2181,7 @@ int ObMultiVersionSchemaService::async_refresh_schema( } else { int64_t retry_cnt = 0; int64_t MAX_RETRY_CNT = 1000; - int64_t RETRY_IDLE_TIME = 100 * 1000L; // 100ms + const __useconds_t RETRY_IDLE_TIME = 100 * 1000L; // 100ms while (OB_SUCC(ret)) { if (THIS_WORKER.is_timeout() || (INT64_MAX == THIS_WORKER.get_timeout_ts() && retry_cnt >= MAX_RETRY_CNT)) { @@ -2651,7 +2651,7 @@ int ObMultiVersionSchemaService::refresh_tenant_schema( LOG_WARN("fail to refresh schema by tenant", KR(ret), K(refresh_schema_status)); } } - int64_t tmp_ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; if (OB_INVALID_SCHEMA_VERSION != new_received_schema_version) { if (OB_SUCCESS != (tmp_ret = set_tenant_received_broadcast_version(tenant_id, new_received_schema_version))) { LOG_WARN("fail to set tenant received schema version", KR(tmp_ret), K(tenant_id), K(new_received_schema_version)); @@ -4033,7 +4033,7 @@ int ObMultiVersionSchemaService::get_tablet_to_table_history( } else if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id || tablet_ids_cnt <= 0)) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid arg", KR(ret), KR(tenant_id), K(tablet_ids_cnt)); + LOG_WARN("invalid arg", KR(ret), K(tenant_id), K(tablet_ids_cnt)); } else if (OB_FAIL(table_ids.reserve(tablet_ids_cnt))) { LOG_WARN("fail to reserve array", KR(ret), K(tablet_ids_cnt)); } else { @@ -4083,7 +4083,7 @@ int ObMultiVersionSchemaService::get_tablet_to_table_history( if (OB_UNLIKELY(schema_version <= 0 || !ObSchemaService::is_formal_version(schema_version))) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid arg", KR(ret), KR(tenant_id), K(tablet_ids_cnt), K(schema_version)); + LOG_WARN("invalid arg", KR(ret), K(tenant_id), K(tablet_ids_cnt), K(schema_version)); } else if (OB_FAIL(tablet_map.create(BUCKET_NUM, "TbtTbPair", "TbtTbPair"))) { LOG_WARN("fail to create hashmap", KR(ret), K(tenant_id)); } diff --git a/src/share/schema/ob_partition_sql_helper.cpp b/src/share/schema/ob_partition_sql_helper.cpp index 2f0df5b7ec..77d22e79c9 100644 --- a/src/share/schema/ob_partition_sql_helper.cpp +++ b/src/share/schema/ob_partition_sql_helper.cpp @@ -119,7 +119,7 @@ int ObPartDMLGenerator::gen_interval_part_name(int64_t part_id, ObString &part_n { int ret = OB_SUCCESS; int64_t str_size = common::OB_MAX_PARTITION_NAME_LENGTH; - int64_t str_len = 0; + int32_t str_len = 0; memset(&interval_part_name_, 0, str_size); str_len += snprintf(interval_part_name_, str_size, "SYS_P%ld", part_id); part_name.assign_ptr(interval_part_name_, str_len); @@ -260,7 +260,7 @@ int ObPartSqlHelper::iterate_all_sub_part(const bool only_history) } for (int64_t j = 0; OB_SUCC(ret) && j < sub_part_num; j++) { dml.reset(); - int sub_part_id = -1; + int64_t sub_part_id = -1; if (OB_ISNULL(subpart_array) || OB_ISNULL(subpart_array[j])) { ret = OB_ERR_UNEXPECTED; LOG_WARN("subpart_array is invalid", KR(ret)); diff --git a/src/share/schema/ob_schema_macro_define.cpp b/src/share/schema/ob_schema_macro_define.cpp index b62679c8b4..aa50c7c387 100644 --- a/src/share/schema/ob_schema_macro_define.cpp +++ b/src/share/schema/ob_schema_macro_define.cpp @@ -44,6 +44,13 @@ int ADD_COLUMN_SCHEMA_FULL(share::schema::ObTableSchema &table_schema, ret = OB_SIZE_OVERFLOW; SHARE_SCHEMA_LOG(WARN, "col name is too long, ", K(col_name_len)); } + + if (OB_SUCC(ret)) { + if (data_len < INT32_MIN || data_len > INT32_MAX) { + ret = OB_INVALID_ARGUMENT; + SHARE_SCHEMA_LOG(ERROR, "invalid data_len", K(ret), K(data_len)); + } + } if(OB_SUCC(ret)) { ObObj orig_default_value; @@ -56,7 +63,7 @@ int ADD_COLUMN_SCHEMA_FULL(share::schema::ObTableSchema &table_schema, column.set_data_type(data_type); const ObAccuracy &default_accuracy = ObAccuracy::DDL_DEFAULT_ACCURACY[data_type]; if (ob_is_string_tc(data_type)) { - column.set_data_length(data_len); + column.set_data_length(static_cast(data_len)); column.set_data_precision(data_precision); } else if (ob_is_text_tc(data_type) || ob_is_json_tc(data_type) || ob_is_geometry_tc(data_type)) { column.set_data_length(default_accuracy.get_length()); diff --git a/src/share/schema/ob_schema_mgr_cache.cpp b/src/share/schema/ob_schema_mgr_cache.cpp index c57922107d..86c3f890d3 100644 --- a/src/share/schema/ob_schema_mgr_cache.cpp +++ b/src/share/schema/ob_schema_mgr_cache.cpp @@ -414,7 +414,7 @@ int ObSchemaMgrCache::build_ref_mod_infos_(const int64_t *mod_ref, } } if (OB_SUCC(ret)) { - int str_len = pos; + const int32_t str_len = static_cast(pos); if (0 != str_len) { str.assign(buff, str_len); } diff --git a/src/share/schema/ob_schema_retrieve_utils.ipp b/src/share/schema/ob_schema_retrieve_utils.ipp index 73b9fb3097..25b9fb1c04 100644 --- a/src/share/schema/ob_schema_retrieve_utils.ipp +++ b/src/share/schema/ob_schema_retrieve_utils.ipp @@ -1582,7 +1582,7 @@ int ObSchemaRetrieveUtils::fill_user_schema( EXTRACT_VARCHAR_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE( result, x509_subject, user_info, false, ObSchemaService::g_ignore_column_retrieve_error_, default_ssl_specified); EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, - type, user_info, uint64_t, true, ObSchemaService::g_ignore_column_retrieve_error_, 0); + type, user_info, int32_t, true, ObSchemaService::g_ignore_column_retrieve_error_, 0); EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_TENANT_ID_AND_DEFAULT_VALUE(result, profile_id, user_info, tenant_id, false, ObSchemaService::g_ignore_column_retrieve_error_, common::OB_INVALID_ID); int64_t default_last_changed = -1; diff --git a/src/share/schema/ob_schema_struct.cpp b/src/share/schema/ob_schema_struct.cpp index 2258870c98..dc3097f357 100644 --- a/src/share/schema/ob_schema_struct.cpp +++ b/src/share/schema/ob_schema_struct.cpp @@ -3227,7 +3227,7 @@ int ObPartitionSchema::try_generate_hash_part() if (OB_FAIL(ObPartitionSchema::gen_hash_part_name( i, FIRST_PART, is_oracle_mode, buf, BUF_SIZE, NULL, NULL))) { LOG_WARN("fail to get part name", KR(ret), K(i)); - } else if (FALSE_IT(part_name.assign_ptr(buf, strlen(buf)))) { + } else if (FALSE_IT(part_name.assign_ptr(buf, static_cast(strlen(buf))))) { } else if (OB_FAIL(part.set_part_name(part_name))) { LOG_WARN("fail to set part name", KR(ret), K(part_name)); } else if (OB_FAIL(add_partition(part))) { @@ -3282,7 +3282,7 @@ int ObPartitionSchema::try_generate_hash_subpart(bool &generated) if (OB_FAIL(gen_hash_part_name(j, TEMPLATE_SUB_PART, is_oracle_mode, buf, BUF_SIZE, NULL, NULL))) { LOG_WARN("fail to get def subpart name", KR(ret), K(j)); - } else if (FALSE_IT(sub_part_name.assign_ptr(buf, strlen(buf)))) { + } else if (FALSE_IT(sub_part_name.assign_ptr(buf, static_cast(strlen(buf))))) { } else if (OB_FAIL(subpart.set_part_name(sub_part_name))) { LOG_WARN("set subpart name failed", KR(ret), K(sub_part_name), KPC(this)); } else if (OB_FAIL(add_def_subpartition(subpart))) { @@ -3354,7 +3354,7 @@ int ObPartitionSchema::try_generate_subpart_by_template(bool &generated) part->get_part_name().ptr(), is_oracle_mode ? "S" : "s", def_subpart_array[j]->get_part_name().ptr()))) { LOG_WARN("part name is too long", KR(ret), KPC(part), K(subpart)); - } else if (FALSE_IT(sub_part_name.assign_ptr(buf, strlen(buf)))) { + } else if (FALSE_IT(sub_part_name.assign_ptr(buf, static_cast(strlen(buf))))) { } else if (OB_FAIL(subpart.set_part_name(sub_part_name))) { LOG_WARN("set subpart name failed", KR(ret), K(sub_part_name), KPC(this)); } else if (OB_FAIL(part->add_partition(subpart))) { @@ -3744,16 +3744,6 @@ int ObPartitionSchema::serialize_partitions(char *buf, return ret; } -int ObPartitionSchema::get_def_subpartitions_serialize_len() { - int64_t length = serialization::encoded_length_vi64(def_subpartition_num_); - for (int64_t i = 0; i < def_subpartition_num_; i++) { - if (NULL != def_subpartition_array_[i]) { - length += def_subpartition_array_[i]->get_serialize_size(); - } - } - return length; -} - int ObPartitionSchema::serialize_def_subpartitions(char *buf, const int64_t data_len, int64_t &pos) const { @@ -3889,7 +3879,7 @@ int ObPartitionSchema::set_transition_point_with_hex_str( LOG_WARN("allocate memory for default value buffer failed", K(ret), K(serialize_len)); } else if (OB_UNLIKELY(hex_length != str_to_hex( transition_point_hex.ptr(), static_cast(hex_length), - serialize_buf, serialize_len))) { + serialize_buf, static_cast(serialize_len)))) { ret = OB_BUF_NOT_ENOUGH; LOG_WARN("Failed to get hex_str buf", K(ret)); } else if (OB_FAIL(transition_point_.deserialize(*allocator, serialize_buf, serialize_len, pos))) { @@ -3963,7 +3953,7 @@ int ObPartitionSchema::set_interval_range_with_hex_str( LOG_WARN("allocate memory for default value buffer failed", K(ret), K(serialize_len)); } else if (OB_UNLIKELY(hex_length != str_to_hex( interval_range_hex.ptr(), static_cast(hex_length), - serialize_buf, serialize_len))) { + serialize_buf, static_cast(serialize_len)))) { ret = OB_BUF_NOT_ENOUGH; LOG_WARN("Failed to get hex_str buf", K(ret)); } else if (OB_FAIL(interval_range_.deserialize(*allocator, serialize_buf, serialize_len, pos))) { @@ -5400,7 +5390,7 @@ int ObBasePartition::set_high_bound_val_with_hex_str( LOG_WARN("fail to alloc buf", KR(ret), K(seri_length)); } else if (OB_UNLIKELY(hex_length != str_to_hex( high_bound_val_hex.ptr(), static_cast(hex_length), - serialize_buf, seri_length))) { + serialize_buf, static_cast(seri_length)))) { ret = OB_BUF_NOT_ENOUGH; LOG_WARN("Failed to get hex_str buf", K(ret)); } else if (OB_FAIL(high_bound_val_.deserialize(*allocator, serialize_buf, seri_length, pos))) { diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 511bfecb80..144b235d54 100644 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -2278,7 +2278,6 @@ public: int try_init_partition_idx(); int serialize_partitions(char *buf, const int64_t data_len, int64_t &pos) const; - int get_def_subpartitions_serialize_len(); int serialize_def_subpartitions(char *buf, const int64_t data_len, int64_t &pos) const; int deserialize_partitions(const char *buf, const int64_t data_len, int64_t &pos); int deserialize_def_subpartitions(const char *buf, const int64_t data_len, int64_t &pos); @@ -3877,7 +3876,7 @@ public: inline int set_x509_issuer(const common::ObString &x509_issuer) { return deep_copy_str(x509_issuer, x509_issuer_); } inline int set_x509_subject(const char *x509_subject) { return deep_copy_str(x509_subject, x509_subject_); } inline int set_x509_subject(const common::ObString &x509_subject) { return deep_copy_str(x509_subject, x509_subject_); } - inline void set_type(const uint64_t type) { type_ = type; } + inline void set_type(const int32_t type) { type_ = type; } inline void set_profile_id(const uint64_t profile_id) { profile_id_ = profile_id; } inline void set_password_last_changed(int64_t ts) { password_last_changed_timestamp_ = ts; } inline void set_max_connections(uint64_t max_connections) { max_connections_ = max_connections; } @@ -3906,8 +3905,7 @@ public: inline uint64_t get_max_user_connections() const { return max_user_connections_; } // role inline bool is_role() const { return OB_ROLE == type_; } - inline int get_grantee_count() const { return grantee_id_array_.count(); } - inline int get_role_count() const { return role_id_array_.count(); } + inline int64_t get_role_count() const { return role_id_array_.count(); } const common::ObSEArray& get_grantee_id_array() const { return grantee_id_array_; } const common::ObSEArray& get_role_id_array() const { return role_id_array_; } const common::ObSEArray& get_role_id_option_array() const { return role_id_option_array_; } diff --git a/src/share/schema/ob_server_schema_service.cpp b/src/share/schema/ob_server_schema_service.cpp index 0170d1f122..71f0263f2f 100644 --- a/src/share/schema/ob_server_schema_service.cpp +++ b/src/share/schema/ob_server_schema_service.cpp @@ -4948,7 +4948,7 @@ int ObServerSchemaService::fetch_increment_tenant_schemas_for_data_dict_( } // end FOREACH_X FOREACH_X(key, schema_keys.alter_tenant_keys_, OB_SUCC(ret)) { const uint64_t tenant_id = key->first.get_tenant_key(); - int64_t hash_ret = schema_keys.new_tenant_keys_.exist_refactored(key->first); + int hash_ret = schema_keys.new_tenant_keys_.exist_refactored(key->first); if (OB_HASH_NOT_EXIST == hash_ret) { if (OB_FAIL(tenant_ids.push_back(tenant_id))) { LOG_WARN("fail to push back tenant keys", KR(ret), K(tenant_id)); diff --git a/src/share/schema/ob_table_dml_param.cpp b/src/share/schema/ob_table_dml_param.cpp index 5ba06c8ca7..9628887fc8 100644 --- a/src/share/schema/ob_table_dml_param.cpp +++ b/src/share/schema/ob_table_dml_param.cpp @@ -124,7 +124,7 @@ int ObTableSchemaParam::convert(const ObTableSchema *schema) if (OB_SUCC(ret) && OB_FAIL(schema->get_column_ids(all_column_ids, false))) { LOG_WARN("fail to get column ids", K(ret)); } - int64_t virtual_cols_cnt = 0; + int32_t virtual_cols_cnt = 0; int64_t schema_rowkey_cnt = schema->get_rowkey_column_num(); for (int32_t i = 0; OB_SUCC(ret) && i < all_column_ids.count(); ++i) { int32_t col_index = OB_INVALID_INDEX; @@ -258,7 +258,7 @@ int ObTableSchemaParam::get_rowkey_column_ids(ObIArray &column_ids) c ret = OB_ERR_UNEXPECTED; LOG_WARN("column param is NULL", K(ret), K(i)); } else { - col_desc.col_id_ = param->get_column_id(); + col_desc.col_id_ = static_cast(param->get_column_id()); col_desc.col_order_ = param->get_column_order(); col_desc.col_type_ = param->get_meta_type(); col_desc.col_type_.set_scale(param->get_accuracy().get_scale()); @@ -575,21 +575,21 @@ int ObTableDMLParam::prepare_storage_param(const ObIArray &column_ids) { int ret = OB_SUCCESS; const int64_t col_cnt = column_ids.count(); - if (col_cnt <= 0) { + if (col_cnt <= 0 || col_cnt > UINT32_MAX) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid column_ids", K(ret), K(col_cnt)); } else { const ObColumnParam *col_param = nullptr; uint64_t column_id = OB_INVALID_ID; ObColDesc col_desc; - col_descs_.set_capacity(col_cnt); + col_descs_.set_capacity(static_cast(col_cnt)); for (int64_t i = 0; OB_SUCC(ret) && i < col_cnt; ++i) { column_id = column_ids.at(i); if (nullptr == (col_param = data_table_.get_column(column_id))) { ret = OB_INVALID_ARGUMENT; LOG_WARN("get column param fail", K(ret), K(column_id), KP(col_param)); } else { - col_desc.col_id_ = column_id; + col_desc.col_id_ = static_cast(column_id); col_desc.col_type_ = col_param->get_meta_type(); col_desc.col_type_.set_scale(col_param->get_accuracy().get_scale()); col_desc.col_order_ = col_param->get_column_order(); diff --git a/src/share/schema/ob_table_param.cpp b/src/share/schema/ob_table_param.cpp index ecc13b71a2..d7ef60311f 100644 --- a/src/share/schema/ob_table_param.cpp +++ b/src/share/schema/ob_table_param.cpp @@ -772,7 +772,7 @@ int ObTableParam::construct_columns_and_projector( // column array const ObRowkeyInfo &rowkey_info = table_schema.get_rowkey_info(); - int32_t rowkey_count = rowkey_info.get_size(); + int64_t rowkey_count = rowkey_info.get_size(); if (OB_SUCC(ret)) { //add rowkey columns for (int32_t i = 0; OB_SUCC(ret) && i < rowkey_count; ++i) { @@ -794,7 +794,7 @@ int ObTableParam::construct_columns_and_projector( } else if (OB_FAIL(tmp_access_cols_index.push_back(i))) { LOG_WARN("fail to push_back tmp_access_cols_index", K(ret)); } else { - tmp_col_desc.col_id_ = column->get_column_id(); + tmp_col_desc.col_id_ = static_cast(column->get_column_id()); tmp_col_desc.col_type_ = column->get_meta_type(); tmp_col_desc.col_order_ = column->get_column_order(); if (tmp_col_desc.col_type_.is_lob_storage() && (!IS_CLUSTER_VERSION_BEFORE_4_1_0_0)) { @@ -854,7 +854,7 @@ int ObTableParam::construct_columns_and_projector( if (OB_SUCC(ret)) { has_virtual_column_ = column_ids_no_virtual.count() != column_ids.count(); - tmp_col_desc.col_id_ = column->get_column_id(); + tmp_col_desc.col_id_ = static_cast(column->get_column_id()); tmp_col_desc.col_type_ = column->get_meta_type(); tmp_col_desc.col_order_ = column->get_column_order(); if (tmp_col_desc.col_type_.is_lob_storage() && (!IS_CLUSTER_VERSION_BEFORE_4_1_0_0)) { @@ -1146,7 +1146,7 @@ int ObTableParam::construct_lob_locator_param(const ObTableSchema &table_schema, ret = OB_ERR_UNEXPECTED; LOG_WARN("Unexpected null col param", K(ret), K(j), K(storage_project_columns)); } else if (rowid_col_ids.at(i) == col_param->get_column_id()) { - if (OB_FAIL(rowid_projector.push_back(j))) { + if (OB_FAIL(rowid_projector.push_back(static_cast(j)))) { LOG_WARN("Failed to push back rowid project", K(ret)); } else { exist = true; diff --git a/src/share/schema/ob_table_schema.cpp b/src/share/schema/ob_table_schema.cpp index b95a93c145..69bad19a1f 100644 --- a/src/share/schema/ob_table_schema.cpp +++ b/src/share/schema/ob_table_schema.cpp @@ -3736,7 +3736,7 @@ int ObTableSchema::convert_char_to_byte_semantics(const ObColumnSchemaV2 *col_sc LOG_WARN("mbmaxlen is less than 0", K(ret), K(mbmaxlen)); } else { if (!is_oracle_byte_length(is_oracle_mode, col_schema->get_length_semantics())) { - col_byte_len = col_byte_len * mbmaxlen; + col_byte_len = static_cast(col_byte_len * mbmaxlen); } } } @@ -4524,9 +4524,9 @@ int ObTableSchema::check_column_can_be_altered_online( int32_t src_col_byte_len = src_schema->get_data_length(); int32_t dst_col_byte_len = dst_schema->get_data_length(); if (!is_oracle_byte_length(is_oracle_mode, src_schema->get_length_semantics())) { - src_col_byte_len = src_col_byte_len * mbmaxlen; + src_col_byte_len = static_cast(src_col_byte_len * mbmaxlen); } else { - dst_col_byte_len = dst_col_byte_len * mbmaxlen; + dst_col_byte_len = static_cast(dst_col_byte_len * mbmaxlen); } if (src_col_byte_len > dst_col_byte_len) { ret = OB_ERR_DECREASE_COLUMN_LENGTH; @@ -4863,7 +4863,7 @@ int ObTableSchema::get_vp_column_ids(common::ObIArray &column_ids) co } else if (it->is_primary_vp_column() || it->is_aux_vp_column()) { // The same VP table will not have a primary VP column and a secondary VP column at the same time // Therefore, the type of VP table is not judged here. - col_desc.col_id_ = it->get_column_id(); + col_desc.col_id_ = static_cast(it->get_column_id()); col_desc.col_type_ = it->get_meta_type(); //for non-rowkey, col_desc.col_order_ is not meaningful if (OB_FAIL(column_ids.push_back(col_desc))) { @@ -4899,7 +4899,7 @@ int ObTableSchema::get_vp_column_ids_with_rowkey(common::ObIArray &co ret = OB_ERR_UNEXPECTED; LOG_WARN("The rowkey column is NULL, ", K(i)); } else { - col_desc.col_id_ = rowkey_column->column_id_; + col_desc.col_id_ = static_cast(rowkey_column->column_id_); col_desc.col_type_ = rowkey_column->type_; col_desc.col_order_ = rowkey_column->order_; if (OB_FAIL(column_ids.push_back(col_desc))) { @@ -4917,7 +4917,7 @@ int ObTableSchema::get_vp_column_ids_with_rowkey(common::ObIArray &co && (!no_virtual || !(it->is_virtual_generated_column()))) { // This column is a VP column, if it is also a primary key column, skip it, // because the first step has been added - col_desc.col_id_ = it->get_column_id(); + col_desc.col_id_ = static_cast(it->get_column_id()); col_desc.col_type_ = it->get_meta_type(); //for non-rowkey, col_desc.col_order_ is not meaningful if (OB_FAIL(column_ids.push_back(col_desc))) { @@ -5107,7 +5107,7 @@ int ObTableSchema::get_rowkey_column_ids(common::ObIArray &column_ids ret = OB_ERR_UNEXPECTED; LOG_WARN("The rowkey column is NULL, ", K(i)); } else { - col_desc.col_id_ = rowkey_column->column_id_; + col_desc.col_id_ = static_cast(rowkey_column->column_id_); col_desc.col_type_ = rowkey_column->type_; col_desc.col_order_ = rowkey_column->order_; if (OB_FAIL(column_ids.push_back(col_desc))) { @@ -5184,7 +5184,7 @@ int ObTableSchema::get_column_ids_without_rowkey( LOG_WARN("The column is NULL, ", K(i)); } else if (!column_array_[i]->is_rowkey_column() && !(no_virtual && column_array_[i]->is_virtual_generated_column())) { - col_desc.col_id_ = column_array_[i]->get_column_id(); + col_desc.col_id_ = static_cast(column_array_[i]->get_column_id()); col_desc.col_type_ = column_array_[i]->get_meta_type(); //for non-rowkey, col_desc.col_order_ is not meaningful if (OB_FAIL(column_ids.push_back(col_desc))) { diff --git a/src/share/schema/ob_table_schema.h b/src/share/schema/ob_table_schema.h index fccb11205c..a1294ad952 100644 --- a/src/share/schema/ob_table_schema.h +++ b/src/share/schema/ob_table_schema.h @@ -326,7 +326,7 @@ struct ObBackUpTableModeOp flag = strtok_r(table_mode_str, delim, &save_ptr); while (OB_SUCC(ret) && OB_NOT_NULL(flag)) { - common::ObString flag_str(0, strlen(flag), flag); + common::ObString flag_str(0, static_cast(strlen(flag)), flag); if (0 == flag_str.case_compare("normal")) { // do nothing } else if (0 == flag_str.case_compare("queuing")) { diff --git a/src/share/stat/ob_dbms_stats_export_import.cpp b/src/share/stat/ob_dbms_stats_export_import.cpp index 668cbc03c7..9389d19503 100644 --- a/src/share/stat/ob_dbms_stats_export_import.cpp +++ b/src/share/stat/ob_dbms_stats_export_import.cpp @@ -199,7 +199,7 @@ int ObDbmsStatsExportImport::export_table_stats(ObExecContext &ctx, const char *from_table_name = lib::is_oracle_mode() ? "sys.ALL_VIRTUAL_TABLE_STAT_REAL_AGENT" : "oceanbase.__all_table_stat"; const char *null_str = "NULL"; - int32_t null_str_len = strlen(null_str); + int32_t null_str_len = static_cast(strlen(null_str)); if (OB_FAIL(table_name_str.append_fmt(lib::is_oracle_mode() ? "\"%.*s\".\"%.*s\"" : "`%.*s`.`%.*s`", param.stat_own_.length(), param.stat_own_.ptr(), diff --git a/src/share/stat/ob_dbms_stats_lock_unlock.cpp b/src/share/stat/ob_dbms_stats_lock_unlock.cpp index b65eaa61ba..887a7b16a0 100644 --- a/src/share/stat/ob_dbms_stats_lock_unlock.cpp +++ b/src/share/stat/ob_dbms_stats_lock_unlock.cpp @@ -202,7 +202,7 @@ int ObDbmsStatsLockUnlock::get_stats_history_sql(ObExecContext &ctx, int ObDbmsStatsLockUnlock::check_stat_locked(ObExecContext &ctx, ObTableStatParam ¶m) { - int64_t ret = OB_SUCCESS; + int ret = OB_SUCCESS; ObSqlString raw_sql; ObSEArray locked_partition_ids; ObSEArray dummy_array; @@ -247,7 +247,7 @@ int ObDbmsStatsLockUnlock::check_stat_locked(ObExecContext &ctx, int ObDbmsStatsLockUnlock::fill_stat_locked(ObExecContext &ctx, ObTableStatParam ¶m) { - int64_t ret = OB_SUCCESS; + int ret = OB_SUCCESS; ObSqlString raw_sql; ObSEArray locked_partition_ids; ObSEArray stattype_locked_array; diff --git a/src/share/stat/ob_dbms_stats_preferences.cpp b/src/share/stat/ob_dbms_stats_preferences.cpp index aac69be0ea..015d0ef1a4 100644 --- a/src/share/stat/ob_dbms_stats_preferences.cpp +++ b/src/share/stat/ob_dbms_stats_preferences.cpp @@ -1082,11 +1082,11 @@ int ObMethodOptPrefs::check_global_method_opt_prefs_value_validity(ObString &met bool is_valid = false; while (i < val_len && ISSPACE(val_ptr[i])) { ++i; } if (i < val_len && 0 == strncasecmp(val_ptr + i, str1, strlen(str1))) { - i = i + strlen(str1); + i = i + static_cast(strlen(str1)); if (i < val_len && ISSPACE(val_ptr[i++])) { while (i < val_len && ISSPACE(val_ptr[i])) { ++i; } if (i < val_len && 0 == strncasecmp(val_ptr + i, str2, strlen(str2))) { - i = i + strlen(str2); + i = i + static_cast(strlen(str2)); if (i < val_len && ISSPACE(val_ptr[i])) { is_valid = true; } diff --git a/src/share/stat/ob_index_stats_estimator.cpp b/src/share/stat/ob_index_stats_estimator.cpp index 94922a90ae..8fe0fa2703 100644 --- a/src/share/stat/ob_index_stats_estimator.cpp +++ b/src/share/stat/ob_index_stats_estimator.cpp @@ -121,7 +121,7 @@ int ObIndexStatsEstimator::fill_index_info(common::ObIAllocator &alloc, } else { const char *fmt_str = "INDEX(%.*s %.*s)"; char *buf = NULL; - int32_t buf_len = table_name.length() + index_name.length() + strlen(fmt_str); + int64_t buf_len = table_name.length() + index_name.length() + strlen(fmt_str); if (OB_ISNULL(buf = static_cast(alloc.alloc(buf_len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc memory", K(ret), K(buf), K(buf_len)); @@ -165,7 +165,7 @@ int ObIndexStatsEstimator::fill_index_group_by_info(ObIAllocator &allocator, LOG_WARN("get unexpected type", K(extra.type_), K(ret)); } if (OB_SUCC(ret)) { - const int32_t len = strlen(fmt_str) + + const int64_t len = strlen(fmt_str) + param.data_table_name_.length() + param.tab_name_.length() + type_str.length() ; @@ -210,7 +210,7 @@ int ObIndexStatsEstimator::fill_partition_condition(ObIAllocator &allocator, } else if (extra.type_ == SUBPARTITION_LEVEL) { type_str = ObString(7, "SUBPART"); } - const int32_t len = strlen(fmt_str) + + const int64_t len = strlen(fmt_str) + param.data_table_name_.length() + param.tab_name_.length() + type_str.length() + 30; diff --git a/src/share/stat/ob_opt_stat_sql_service.cpp b/src/share/stat/ob_opt_stat_sql_service.cpp index 52cf98c66f..b331445838 100644 --- a/src/share/stat/ob_opt_stat_sql_service.cpp +++ b/src/share/stat/ob_opt_stat_sql_service.cpp @@ -1658,7 +1658,7 @@ int ObOptStatSqlService::get_valid_obj_str(const ObObj &src_obj, ret = OB_SUCCESS; const char *incorrect_string = "-4258: Incorrect string value, can't show."; ObObj incorrect_str_obj; - incorrect_str_obj.set_string(new_obj.get_type(), incorrect_string, strlen(incorrect_string)); + incorrect_str_obj.set_string(new_obj.get_type(), incorrect_string, static_cast(strlen(incorrect_string))); if (OB_FAIL(get_obj_str(incorrect_str_obj, allocator, dest_str))) { LOG_WARN("failed to get obj str", K(ret)); } else {/*do nothing*/} diff --git a/src/share/stat/ob_stats_estimator.cpp b/src/share/stat/ob_stats_estimator.cpp index 0c37f98f9f..1bf424c085 100644 --- a/src/share/stat/ob_stats_estimator.cpp +++ b/src/share/stat/ob_stats_estimator.cpp @@ -253,7 +253,7 @@ int ObStatsEstimator::fill_partition_info(ObIAllocator &allocator, const ObString &part_name = part_info.part_name_; const char *fmt_str = lib::is_oracle_mode() ? "PARTITION (\"%.*s\")" : "PARTITION (`%.*s`)"; char *buf = NULL; - const int32_t len = strlen(fmt_str) + part_name.length(); + const int64_t len = strlen(fmt_str) + part_name.length(); int32_t real_len = -1; if (OB_ISNULL(buf = static_cast(allocator.alloc(len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -291,7 +291,7 @@ int ObStatsEstimator::fill_group_by_info(ObIAllocator &allocator, LOG_WARN("get unexpected type", K(extra.type_), K(ret)); } if (OB_SUCC(ret)) { - const int32_t len = strlen(fmt_str) + + const int64_t len = strlen(fmt_str) + (param.is_index_stat_ ? param.data_table_name_.length() : param.tab_name_.length()) + type_str.length(); int32_t real_len = -1; diff --git a/src/share/table/ob_table_load_define.h b/src/share/table/ob_table_load_define.h index 2d5d442561..52a6474e03 100644 --- a/src/share/table/ob_table_load_define.h +++ b/src/share/table/ob_table_load_define.h @@ -110,7 +110,7 @@ public: } int compare(const ObTableLoadPartitionId &other) const { - return (partition_id_ != other.partition_id_ ? partition_id_ - other.partition_id_ + return (partition_id_ != other.partition_id_ ? static_cast(partition_id_ - other.partition_id_)//TODO(suzhi.yt): fix convert int64 to int32 : tablet_id_.compare(other.tablet_id_)); } TO_STRING_KV(K_(partition_id), K_(tablet_id)); @@ -230,7 +230,7 @@ public: } int compare(const ObTableLoadSegmentID &other) const { - return id_ - other.id_; + return static_cast(id_ - other.id_);//TODO(suzhi.yt): fix convert int64 to int32 } TO_STRING_KV(K_(id)); public: @@ -290,7 +290,7 @@ public: int compare(const ObTableLoadTransId &other) const { return (segment_id_ != other.segment_id_ ? segment_id_.compare(other.segment_id_) - : trans_gid_ - other.trans_gid_); + : static_cast(trans_gid_ - other.trans_gid_));//TODO(suzhi.yt): fix convert int64 to int32 } TO_STRING_KV(K_(segment_id), K_(trans_gid)); public: diff --git a/src/share/tablet/ob_tablet_table_operator.cpp b/src/share/tablet/ob_tablet_table_operator.cpp index 9262fe6adf..6cdcb5f716 100644 --- a/src/share/tablet/ob_tablet_table_operator.cpp +++ b/src/share/tablet/ob_tablet_table_operator.cpp @@ -22,7 +22,6 @@ #include "lib/mysqlclient/ob_mysql_proxy.h" // ObMySqlProxy #include "share/ob_ls_id.h" // ObLSID #include "observer/omt/ob_tenant_timezone_mgr.h" // for OTTZ_MGR.get_tenant_tz -#include "observer/ob_server_struct.h" // GCTX namespace oceanbase { diff --git a/src/sql/code_generator/ob_static_engine_expr_cg.h b/src/sql/code_generator/ob_static_engine_expr_cg.h index 7a1e927a42..05f0457262 100644 --- a/src/sql/code_generator/ob_static_engine_expr_cg.h +++ b/src/sql/code_generator/ob_static_engine_expr_cg.h @@ -354,7 +354,7 @@ private: ObPreCalcExprFrameInfo &expr_info); // total datums size: header + reserved data - int get_expr_datums_size(const ObExpr &expr) { + int64_t get_expr_datums_size(const ObExpr &expr) { return get_expr_datums_header_size(expr) + reserve_datums_buf_len(expr); } @@ -364,7 +364,7 @@ private: // - EvalInfo instance // - EvalFlag(BitVector) instance + BitVector data // - SkipBitmap(BitVector) + BitVector data - int get_expr_datums_header_size(const ObExpr &expr) { + int64_t get_expr_datums_header_size(const ObExpr &expr) { return get_datums_header_size(expr) + sizeof(ObEvalInfo) + 2 * get_expr_skip_vector_size(expr); } diff --git a/src/sql/dblink/ob_dblink_utils.h b/src/sql/dblink/ob_dblink_utils.h index 905b374cca..887c061b21 100644 --- a/src/sql/dblink/ob_dblink_utils.h +++ b/src/sql/dblink/ob_dblink_utils.h @@ -53,7 +53,7 @@ public: inline void set_addr(common::ObAddr addr) { addr_ = addr; } inline void set_self_addr(common::ObAddr addr) { self_addr_ = addr; } inline void set_tx_id(int64_t tx_id) { tx_id_ = tx_id; } - inline void set_tm_sessid(int64_t tm_sessid) { tm_sessid_ = tm_sessid; } + inline void set_tm_sessid(uint32_t tm_sessid) { tm_sessid_ = tm_sessid; } const ObString &get_user() { return user_; } const ObString &get_tenant() { return tenant_; } const ObString &get_cluster() { return cluster_; } @@ -143,4 +143,4 @@ private: } // end of namespace sql } // end of namespace oceanbase -#endif // OCEANBASE_SQL_OB_DBLINK_UTILS_H \ No newline at end of file +#endif // OCEANBASE_SQL_OB_DBLINK_UTILS_H diff --git a/src/sql/dtl/ob_dtl_interm_result_manager.h b/src/sql/dtl/ob_dtl_interm_result_manager.h index 337862b3bf..9eae88e686 100644 --- a/src/sql/dtl/ob_dtl_interm_result_manager.h +++ b/src/sql/dtl/ob_dtl_interm_result_manager.h @@ -40,7 +40,7 @@ struct ObDTLIntermResultMonitorInfo qc_id_(qc_id), dfo_id_(dfo_id), sqc_id_(sqc_id) { } TO_STRING_KV(K_(qc_id), K_(dfo_id), K_(sqc_id)); - int32_t qc_id_; + int64_t qc_id_; int64_t dfo_id_; int64_t sqc_id_; }; diff --git a/src/sql/engine/aggregate/ob_aggregate_function.cpp b/src/sql/engine/aggregate/ob_aggregate_function.cpp index 1002f149c3..e887e66d21 100644 --- a/src/sql/engine/aggregate/ob_aggregate_function.cpp +++ b/src/sql/engine/aggregate/ob_aggregate_function.cpp @@ -288,7 +288,7 @@ int ObAggregateFunction::init_first_rollup_cols(common::ObIAllocator *alloc, const ObIArray& group_idxs, const ObIArray& rollup_idxs) { - int64_t ret = OB_SUCCESS; + int ret = OB_SUCCESS; common::ObSEArray no_dup_group_col_idxs; common::ObSEArray no_dup_rollup_col_idxs; first_rollup_cols_.set_allocator(alloc); diff --git a/src/sql/engine/aggregate/ob_aggregate_processor.cpp b/src/sql/engine/aggregate/ob_aggregate_processor.cpp index e4ea592757..3303cd4243 100644 --- a/src/sql/engine/aggregate/ob_aggregate_processor.cpp +++ b/src/sql/engine/aggregate/ob_aggregate_processor.cpp @@ -5852,7 +5852,8 @@ int ObAggregateProcessor::get_ora_json_arrayagg_result(const ObAggrInfo &aggr_in ObString origin_str; if (ob_is_lob_locator(val_type)) { const ObLobLocator &lob_locator = converted_datum.get_lob_locator(); - origin_str.assign(const_cast(lob_locator.get_payload_ptr()), lob_locator.payload_size_); + origin_str.assign(const_cast(lob_locator.get_payload_ptr()), + static_cast(lob_locator.payload_size_)); val_type = ObVarcharType; } else if (tmp_obj->is_lob_storage()) { origin_str = converted_datum.get_string(); @@ -6244,7 +6245,8 @@ int ObAggregateProcessor::get_ora_json_objectagg_result(const ObAggrInfo &aggr_i ObString origin_str; if (ob_is_lob_locator(val_type1)) { const ObLobLocator &lob_locator = converted_datum.get_lob_locator(); - origin_str.assign(const_cast(lob_locator.get_payload_ptr()), lob_locator.payload_size_); + origin_str.assign(const_cast(lob_locator.get_payload_ptr()), + static_cast(lob_locator.payload_size_)); val_type1 = ObVarcharType; } else if (tmp_obj->is_lob_storage()) { origin_str = converted_datum.get_string(); diff --git a/src/sql/engine/aggregate/ob_aggregate_processor.h b/src/sql/engine/aggregate/ob_aggregate_processor.h index 84c03c7a64..e84bb95875 100644 --- a/src/sql/engine/aggregate/ob_aggregate_processor.h +++ b/src/sql/engine/aggregate/ob_aggregate_processor.h @@ -356,10 +356,10 @@ public: int rewind(); bool empty() const { return 0 == row_count_; } bool is_iterated() const { return iter_idx_ > 0; } - int get_row_count() const { return row_count_; } + int64_t get_row_count() const { return row_count_; }//TODO(jiangxiu.wt): fix it in previous versions ObDatum *&get_separator_datum() { return separator_datum_; } int reserve_bool_mark_count(int64_t count) { return bool_mark_.reserve(count); } - int get_bool_mark_size() { return bool_mark_.count(); } + int64_t get_bool_mark_size() { return bool_mark_.count(); }//TODO(jiangxiu.wt): fix it in previous versions int get_bool_mark(int64_t col_index, bool &is_bool); int set_bool_mark(int64_t col_index, bool is_bool); DECLARE_VIRTUAL_TO_STRING; @@ -621,7 +621,7 @@ public: const bool release_mem = true); inline int get_group_row(const int64_t group_id, GroupRow *&group_row) { return group_rows_.at(group_id, group_row); } - inline int get_group_rows_count() const + inline int64_t get_group_rows_count() const//TODO(jiangxiu.wt): fix it in previous versions { return group_rows_.count(); } inline int swap_group_row(const int a, const int b) // dangerous { diff --git a/src/sql/engine/basic/ob_chunk_datum_store.h b/src/sql/engine/basic/ob_chunk_datum_store.h index 47c737c4cf..d24e94c220 100644 --- a/src/sql/engine/basic/ob_chunk_datum_store.h +++ b/src/sql/engine/basic/ob_chunk_datum_store.h @@ -156,6 +156,9 @@ public: if (OB_UNLIKELY(0 == exprs.count())) { // 没有任何列 // 场景:如distinct 1,对于常量,不会有任何处理 + } else if (OB_UNLIKELY(extra_size < 0 || extra_size > INT32_MAX)) { + ret = OB_INVALID_ARGUMENT; + SQL_ENG_LOG(ERROR, "invalid extra size", K(ret), K(extra_size)); } else if (OB_FAIL(ObChunkDatumStore::row_copy_size(exprs, ctx, row_size))) { SQL_ENG_LOG(WARN, "failed to calc copy size", K(ret)); } else { @@ -198,7 +201,7 @@ public: } if (OB_SUCC(ret)) { int64_t pos = head_size; - if (OB_FAIL(StoredRow::build(store_row_, exprs, ctx, buf, buffer_len, extra_size))) { + if (OB_FAIL(StoredRow::build(store_row_, exprs, ctx, buf, buffer_len, static_cast(extra_size)))) { SQL_ENG_LOG(WARN, "failed to build stored row", K(ret), K(buffer_len), K(row_size)); } else { max_size_ = buffer_len; @@ -291,6 +294,7 @@ public: { int ret = common::OB_SUCCESS; int64_t buffer_len = datum_cnt * sizeof(ObDatum) + sizeof(StoredRow); + const int64_t row_size = datum_cnt * sizeof(ObDatum) + sizeof(StoredRow); char *buf = nullptr; if (nullptr != store_row_) { // inited @@ -298,14 +302,17 @@ public: } else if (NULL != alloc_) { ret = common::OB_INIT_TWICE; SQL_ENG_LOG(WARN, "init twice", K(ret)); + } else if (row_size < 0 || row_size > INT32_MAX) { + ret = OB_INVALID_ARGUMENT; + SQL_ENG_LOG(WARN, "invalid row_size", K(ret), K(datum_cnt), K(row_size)); } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buffer_len)))) { ret = common::OB_ALLOCATE_MEMORY_FAILED; SQL_ENG_LOG(WARN, "alloc buf failed", K(ret)); } else { alloc_ = &allocator; store_row_ = new (buf) StoredRow(); - store_row_->cnt_ = datum_cnt; - store_row_->row_size_ = datum_cnt * sizeof(ObDatum) + sizeof(StoredRow); + store_row_->cnt_ = static_cast(datum_cnt); + store_row_->row_size_ = static_cast(row_size); saved_ = false; } return ret; @@ -361,7 +368,7 @@ public: virtual void reuse() { if (nullptr != store_row_) { - int64_t payload_len = store_row_->cnt_ * sizeof(ObDatum); + uint32_t payload_len = store_row_->cnt_ * sizeof(ObDatum); //reserve the memory of datum.ptr_ to assign ObObj bzero(store_row_->payload_, payload_len); store_row_->row_size_ = payload_len + sizeof(StoredRow); diff --git a/src/sql/engine/expr/ob_datum_cast.cpp b/src/sql/engine/expr/ob_datum_cast.cpp index afe36ec1a6..5b83c6c54c 100644 --- a/src/sql/engine/expr/ob_datum_cast.cpp +++ b/src/sql/engine/expr/ob_datum_cast.cpp @@ -366,7 +366,7 @@ int ObDatumHexUtils::rawtohex(const ObExpr &expr, const ObString &in_str, ObScale res_scale = -1; char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); - int64_t length = ob_gcvt_opt(in_val, OB_GCVT_ARG_FLOAT, sizeof(buf) - 1, + int64_t length = ob_gcvt_opt(in_val, OB_GCVT_ARG_FLOAT, static_cast(sizeof(buf) - 1), buf, NULL, TRUE, TRUE); ObString float_str(sizeof(buf), static_cast(length), buf); number::ObNumber nmb; @@ -384,7 +384,7 @@ int ObDatumHexUtils::rawtohex(const ObExpr &expr, const ObString &in_str, ObScale res_scale = -1; char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); - int64_t length = ob_gcvt_opt(in_val, OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, + int64_t length = ob_gcvt_opt(in_val, OB_GCVT_ARG_DOUBLE, static_cast(sizeof(buf) - 1), buf, NULL, TRUE, TRUE); ObString double_str(sizeof(buf), static_cast(length), buf); number::ObNumber nmb; @@ -1880,7 +1880,7 @@ static int common_floating_number(const IN_TYPE in_val, MEMSET(buf, 0, MAX_DOUBLE_STRICT_PRINT_SIZE); int64_t length = 0; if (lib::is_oracle_mode() || OB_GCVT_ARG_DOUBLE == arg_type) { - length = ob_gcvt_opt(in_val, arg_type, sizeof(buf) - 1, + length = ob_gcvt_opt(in_val, arg_type, static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); } else { length = ob_gcvt(in_val, OB_GCVT_ARG_DOUBLE, sizeof(buf) - 1, buf, NULL); @@ -1939,7 +1939,7 @@ static int common_floating_string(const ObExpr &expr, if (0 <= scale) { length = ob_fcvt(in_val, scale, sizeof(buf) - 1, buf, NULL); } else { - length = ob_gcvt_opt(in_val, arg_type, sizeof(buf) - 1, + length = ob_gcvt_opt(in_val, arg_type, static_cast(sizeof(buf) - 1), buf, NULL, lib::is_oracle_mode(), TRUE); } } diff --git a/src/sql/engine/expr/ob_expr.h b/src/sql/engine/expr/ob_expr.h index 98947b7afe..0e0dc5f49c 100644 --- a/src/sql/engine/expr/ob_expr.h +++ b/src/sql/engine/expr/ob_expr.h @@ -1146,7 +1146,7 @@ inline int encode(char *buf, const int64_t buf_len, int64_t &pos, sql::ObExpr *e if (NULL != expr) { sql::ObExpr::ObExprIArray *array = sql::ObExpr::get_serialize_array(); if (OB_UNLIKELY(NULL == array || array->empty() || expr < &array->at(0) - || (idx = expr - &array->at(0) + 1) > array->count())) { + || (idx = static_cast(expr - &array->at(0) + 1)) > array->count())) { ret = OB_ERR_UNEXPECTED; SQL_LOG(WARN, "expr not in array", K(ret), KP(array), KP(idx), KP(expr)); } diff --git a/src/sql/engine/expr/ob_expr_inet.cpp b/src/sql/engine/expr/ob_expr_inet.cpp index ffd8372651..c2b74d42fa 100644 --- a/src/sql/engine/expr/ob_expr_inet.cpp +++ b/src/sql/engine/expr/ob_expr_inet.cpp @@ -591,10 +591,10 @@ int ObExprInet6Aton::inet6_aton(const ObString& ip, bool& is_ip_format_invalid, } else if (is_ip_format_invalid) { LOG_WARN("ip format invalid", K(ip)); } else { - str_result.assign(result_buf, sizeof(in6_addr)); + str_result.assign(result_buf, static_cast(sizeof(in6_addr))); } } else { - str_result.assign(result_buf, sizeof(in_addr)); + str_result.assign(result_buf, static_cast(sizeof(in_addr))); } } } diff --git a/src/sql/engine/expr/ob_expr_oracle_to_char.cpp b/src/sql/engine/expr/ob_expr_oracle_to_char.cpp index d670c20c91..030c573c10 100644 --- a/src/sql/engine/expr/ob_expr_oracle_to_char.cpp +++ b/src/sql/engine/expr/ob_expr_oracle_to_char.cpp @@ -692,10 +692,10 @@ int ObExprToCharCommon::process_number_sci_value(ObExprCtx &expr_ctx, LOG_WARN("allocate memory for number string failed", K(ret)); } else { if (obj.is_double()) { - str_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, alloc_size, + str_len = ob_gcvt_opt(obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(alloc_size), buf, NULL, lib::is_oracle_mode(), TRUE); } else if (obj.is_float()) { - str_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, alloc_size, + str_len = ob_gcvt_opt(obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(alloc_size), buf, NULL, lib::is_oracle_mode(), TRUE); } else { EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE); @@ -1355,10 +1355,10 @@ int ObExprToCharCommon::process_number_sci_value( } else { if (is_double) { str_len = ob_gcvt_opt(input.get_double(), OB_GCVT_ARG_DOUBLE, - alloc_size, buf, NULL, lib::is_oracle_mode(), TRUE); + static_cast(alloc_size), buf, NULL, lib::is_oracle_mode(), TRUE); } else if (is_float) { str_len = ob_gcvt_opt(input.get_float(), OB_GCVT_ARG_FLOAT, - alloc_size, buf, NULL, lib::is_oracle_mode(), TRUE); + static_cast(alloc_size), buf, NULL, lib::is_oracle_mode(), TRUE); } else { number::ObNumber number_value; if (expr.args_[0]->obj_meta_.is_integer_type()) { diff --git a/src/sql/engine/expr/ob_expr_sys_context.cpp b/src/sql/engine/expr/ob_expr_sys_context.cpp index ebfd624226..1cafd5f391 100644 --- a/src/sql/engine/expr/ob_expr_sys_context.cpp +++ b/src/sql/engine/expr/ob_expr_sys_context.cpp @@ -570,7 +570,7 @@ int ObExprSysContext::eval_lang(const ObExpr &expr, common::ObDatum &res, for (int64_t i = 0; !found && i < ARRAYSIZEOF(lang_map_); ++i) { if (0 == language.get_string().case_compare(lang_map_[i].language)) { found = true; - abbreviated.assign(lang_map_[i].abbreviated, strlen(lang_map_[i].abbreviated)); + abbreviated.assign(lang_map_[i].abbreviated, static_cast(strlen(lang_map_[i].abbreviated))); } } if (!found) { diff --git a/src/sql/engine/expr/ob_expr_udf.h b/src/sql/engine/expr/ob_expr_udf.h index 502659cda3..5acfb4ba74 100644 --- a/src/sql/engine/expr/ob_expr_udf.h +++ b/src/sql/engine/expr/ob_expr_udf.h @@ -87,7 +87,7 @@ class ObExprUDF : public ObFuncExprOperator } ParamStore* get_param_store() { return params_; } - int get_param_count() { return OB_ISNULL(params_) ? 0 : params_->count(); } + int64_t get_param_count() { return OB_ISNULL(params_) ? 0 : params_->count(); } private: void* param_store_buf_; diff --git a/src/sql/engine/expr/ob_expr_userenv.cpp b/src/sql/engine/expr/ob_expr_userenv.cpp index eeb4b76c91..5a8b0f9332 100644 --- a/src/sql/engine/expr/ob_expr_userenv.cpp +++ b/src/sql/engine/expr/ob_expr_userenv.cpp @@ -334,7 +334,7 @@ int ObExprUserEnv::eval_lang(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res) if (0 == language.get_string().case_compare(lang_map_[i].language)) { found = true; abbreviated.assign(lang_map_[i].abbreviated, - strlen(lang_map_[i].abbreviated)); + static_cast(strlen(lang_map_[i].abbreviated))); } } if (!found) { diff --git a/src/sql/engine/expr/ob_expr_util.cpp b/src/sql/engine/expr/ob_expr_util.cpp index 79c1045e75..0627d4b104 100644 --- a/src/sql/engine/expr/ob_expr_util.cpp +++ b/src/sql/engine/expr/ob_expr_util.cpp @@ -652,7 +652,7 @@ int ObExprUtil::convert_utf8_charset(ObIAllocator& allocator, result_len))) { LOG_WARN("charset convert failed", K(ret), K(from_collation), K(CS_TYPE_UTF8MB4_BIN)); } else { - to_string.assign(buf, result_len); + to_string.assign(buf, static_cast(result_len)); } return ret; } diff --git a/src/sql/engine/expr/ob_number_format_models.cpp b/src/sql/engine/expr/ob_number_format_models.cpp index 9a8c581aeb..431ca1b99d 100644 --- a/src/sql/engine/expr/ob_number_format_models.cpp +++ b/src/sql/engine/expr/ob_number_format_models.cpp @@ -1772,10 +1772,10 @@ int ObNFMToChar::process_tm_format(const ObNFMObj &nfm_obj, char *buf, } else { ObObjType obj_type = nfm_obj.get_obj_type(); if (ObFloatType == obj_type) { - num_str_len = ob_gcvt_opt(nfm_obj.get_float(), OB_GCVT_ARG_FLOAT, alloc_size, + num_str_len = ob_gcvt_opt(nfm_obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(alloc_size), num_str_buf, NULL, lib::is_oracle_mode(), TRUE); } else if (ObDoubleType == obj_type) { - num_str_len = ob_gcvt_opt(nfm_obj.get_double(), OB_GCVT_ARG_DOUBLE, alloc_size, + num_str_len = ob_gcvt_opt(nfm_obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(alloc_size), num_str_buf, NULL, lib::is_oracle_mode(), TRUE); } else if (ObNumberType == obj_type) { number::ObNumber num = nfm_obj.get_number(); @@ -1824,10 +1824,10 @@ int ObNFMToChar::process_tme_format(const ObNFMObj &nfm_obj, char *buf, } else { ObObjType obj_type = nfm_obj.get_obj_type(); if (ObFloatType == obj_type) { - num_str_len = ob_gcvt_opt(nfm_obj.get_float(), OB_GCVT_ARG_FLOAT, alloc_size, + num_str_len = ob_gcvt_opt(nfm_obj.get_float(), OB_GCVT_ARG_FLOAT, static_cast(alloc_size), num_str_buf, NULL, lib::is_oracle_mode(), TRUE); } else if (ObDoubleType == obj_type) { - num_str_len = ob_gcvt_opt(nfm_obj.get_double(), OB_GCVT_ARG_DOUBLE, alloc_size, + num_str_len = ob_gcvt_opt(nfm_obj.get_double(), OB_GCVT_ARG_DOUBLE, static_cast(alloc_size), num_str_buf, NULL, lib::is_oracle_mode(), TRUE); } else if (ObNumberType == obj_type) { number::ObNumber num = nfm_obj.get_number(); diff --git a/src/sql/engine/expr/ob_sql_expression.h b/src/sql/engine/expr/ob_sql_expression.h index 0f851f7526..9f93491b83 100644 --- a/src/sql/engine/expr/ob_sql_expression.h +++ b/src/sql/engine/expr/ob_sql_expression.h @@ -76,7 +76,6 @@ public: int set_item_count(int64_t count); inline void set_need_construct_binding_array(bool need_construct) { need_construct_binding_array_ = need_construct; } inline bool need_construct_binding_array() const { return need_construct_binding_array_; } - inline void set_array_param_index(int64_t array_param_index) { array_param_index_ = array_param_index; } inline int64_t get_array_param_index() const { return array_param_index_; } /** common::ObIAllocator &alloc, * 设置表达式 diff --git a/src/sql/engine/ob_operator.h b/src/sql/engine/ob_operator.h index 969b919cd4..1eeb775c27 100644 --- a/src/sql/engine/ob_operator.h +++ b/src/sql/engine/ob_operator.h @@ -103,7 +103,7 @@ public: common::ObIArray& get_one_batch_params(int64_t idx) { return params_.at(idx); } - int get_param_idx(int64_t idx) { + int64_t get_param_idx(int64_t idx) { return param_idxs_.at(idx); } int append_batch_rescan_param(const common::ObIArray ¶m_idxs, @@ -613,7 +613,7 @@ protected: inline void begin_ash_line_id_reg() { // begin with current operator - ObActiveSessionGuard::get_stat().plan_line_id_ = spec_.id_; + ObActiveSessionGuard::get_stat().plan_line_id_ = static_cast(spec_.id_);//TODO(xiaochu.yh): fix uint64 to int32 } inline void end_ash_line_id_reg() { @@ -621,7 +621,7 @@ protected: // known issue: when switch from batch to row in same op, // we shift line id to parent op un-intently. but we tolerate this inaccuracy if (OB_LIKELY(spec_.get_parent())) { - common::ObActiveSessionGuard::get_stat().plan_line_id_ = spec_.get_parent()->id_; + common::ObActiveSessionGuard::get_stat().plan_line_id_ = static_cast(spec_.get_parent()->id_);//TODO(xiaochu.yh): fix uint64 to int32 } else { common::ObActiveSessionGuard::get_stat().plan_line_id_ = -1; } diff --git a/src/sql/engine/ob_tenant_sql_memory_manager.h b/src/sql/engine/ob_tenant_sql_memory_manager.h index 28400235b9..fbd5d333af 100644 --- a/src/sql/engine/ob_tenant_sql_memory_manager.h +++ b/src/sql/engine/ob_tenant_sql_memory_manager.h @@ -118,7 +118,7 @@ public: number_pass_ = num_pass; } } - OB_INLINE int32_t get_number_pass() const { return number_pass_; } + OB_INLINE int64_t get_number_pass() const { return number_pass_; } static bool auto_sql_memory_manager(ObSqlWorkAreaProfile &profile) { @@ -264,7 +264,6 @@ public: OB_INLINE void set_seqno(int64_t seqno) { seqno_ = seqno; } OB_INLINE int64_t get_seqno() { return seqno_; } OB_INLINE WorkareaKey get_workarea_key() const { return workarea_key_; } - OB_INLINE int32_t get_sql_id_len() const { return strlen(workarea_key_.sql_id_); } OB_INLINE const char* get_sql_id() const { return workarea_key_.sql_id_; } OB_INLINE uint64_t get_plan_id() const { return workarea_key_.plan_id_; } OB_INLINE uint64_t get_operator_id() const { return workarea_key_.operator_id_; } diff --git a/src/sql/monitor/flt/ob_flt_span_mgr.h b/src/sql/monitor/flt/ob_flt_span_mgr.h index a5af8eac95..97d4e2be61 100644 --- a/src/sql/monitor/flt/ob_flt_span_mgr.h +++ b/src/sql/monitor/flt/ob_flt_span_mgr.h @@ -181,7 +181,7 @@ namespace sql int64_t get_start_idx() const { return (int64_t)queue_.get_pop_idx(); } int64_t get_end_idx() const { return (int64_t)queue_.get_push_idx(); } - int get_tenant_id() { return tenant_id_; } + uint64_t get_tenant_id() { return tenant_id_; } int init(uint64_t tenant_id, const int64_t max_mem_size, const int64_t queue_size); int record_span(ObFLTSpanData &span_data); int release_old(int64_t limit = BATCH_RELEASE_COUNT); // evict old span and release memory diff --git a/src/sql/monitor/flt/ob_flt_utils.cpp b/src/sql/monitor/flt/ob_flt_utils.cpp index 6447c5d53f..1db157fdb8 100644 --- a/src/sql/monitor/flt/ob_flt_utils.cpp +++ b/src/sql/monitor/flt/ob_flt_utils.cpp @@ -534,7 +534,7 @@ namespace sql // span name data.span_name_.assign(const_cast(trace::__span_type_mapper[span->span_type_]), - strlen(trace::__span_type_mapper[span->span_type_])); + static_cast(strlen(trace::__span_type_mapper[span->span_type_]))); //parent_span_id_ org_pos = pos; @@ -552,7 +552,7 @@ namespace sql if (OB_NOT_NULL(tag_buf) && tag_len != 0) { //skip "tags":[ and trim ] - data.tags_.assign(tag_buf+sizeof("\"tags\":["), tag_len-sizeof("\"tags\":[")-2); + data.tags_.assign(tag_buf+sizeof("\"tags\":["), static_cast(tag_len-sizeof("\"tags\":[")-2)); //data.tags_.assign(tag_buf, tag_len); } diff --git a/src/sql/ob_sql_utils.cpp b/src/sql/ob_sql_utils.cpp index 8f21e2a75c..0393696438 100644 --- a/src/sql/ob_sql_utils.cpp +++ b/src/sql/ob_sql_utils.cpp @@ -2976,7 +2976,7 @@ int ObSQLUtils::ConvertFiledNameAttribute(ObIAllocator& allocator, } if (OB_SUCC(ret)) { - dst.assign(buf, result_len); + dst.assign(buf, static_cast(result_len)); } } } diff --git a/src/sql/optimizer/ob_join_order.h b/src/sql/optimizer/ob_join_order.h index 526500489f..738e5e35da 100644 --- a/src/sql/optimizer/ob_join_order.h +++ b/src/sql/optimizer/ob_join_order.h @@ -366,7 +366,7 @@ struct EstimateCostInfo { inline common::ObIArray &get_ordering() { return ordering_; } inline const common::ObIArray &get_server_list() const { return server_list_; } inline common::ObIArray &get_server_list() { return server_list_; } - inline int get_interesting_order_info() const { return interesting_order_info_; } + inline int64_t get_interesting_order_info() const { return interesting_order_info_; } inline void set_interesting_order_info(int64_t info) { interesting_order_info_ = info; } inline void add_interesting_order_flag(OrderingFlag flag) { interesting_order_info_ |= flag; } inline void add_interesting_order_flag(int64_t flags) { interesting_order_info_ |= flags; } diff --git a/src/sql/parser/sql_parser_base.c b/src/sql/parser/sql_parser_base.c index 1458d1fe66..098bb85b1a 100644 --- a/src/sql/parser/sql_parser_base.c +++ b/src/sql/parser/sql_parser_base.c @@ -52,14 +52,15 @@ int parse_terminate(ParseResult *p) return ret; } -int parse_sql(ParseResult *p, const char *buf, size_t len) +int parse_sql(ParseResult *p, const char *buf, size_t input_len) { int ret = OB_PARSER_ERR_PARSE_SQL; if (OB_UNLIKELY(NULL == p)) { - } else if (OB_UNLIKELY(NULL == buf || len <= 0)) { + } else if (OB_UNLIKELY(NULL == buf || input_len <= 0 || input_len > INT32_MAX)) { snprintf(p->error_msg_, MAX_ERROR_MSG, "Input SQL can not be empty"); ret = OB_PARSER_ERR_EMPTY_QUERY; } else { + const int32_t len = (int32_t)input_len; p->input_sql_ = buf; p->input_sql_len_ = len; p->start_col_ = 1; diff --git a/src/sql/plan_cache/ob_plan_cache_struct.h b/src/sql/plan_cache/ob_plan_cache_struct.h index 5d33dc0ac0..0c4f2f054d 100644 --- a/src/sql/plan_cache/ob_plan_cache_struct.h +++ b/src/sql/plan_cache/ob_plan_cache_struct.h @@ -56,22 +56,6 @@ struct ObPlanCacheKey : public ObILibCacheKey db_id_(common::OB_INVALID_ID), sessid_(0), mode_(PC_TEXT_MODE) {} - ObPlanCacheKey(const ObString &name, - uint64_t key_id, - uint64_t db_id, - uint64_t sessid, - PlanCacheMode mode, - const ObString &sys_vars_str, - const ObString &config_str, - ObLibCacheNameSpace namespace_arg) - : ObILibCacheKey(namespace_arg), - name_(name), - key_id_(key_id), - db_id_(db_id), - sessid_(sessid), - mode_(mode), - sys_vars_str_(sys_vars_str), - config_str_(config_str) {} inline void reset() { diff --git a/src/sql/resolver/dml/ob_dml_stmt.h b/src/sql/resolver/dml/ob_dml_stmt.h index 268fde1567..acecb66b09 100644 --- a/src/sql/resolver/dml/ob_dml_stmt.h +++ b/src/sql/resolver/dml/ob_dml_stmt.h @@ -1126,7 +1126,7 @@ public: int check_and_get_same_rowid_expr(const ObRawExpr *expr, ObRawExpr *&same_rowid_expr); int add_cte_definition(TableItem * table_item) { return cte_definitions_.push_back(table_item); } - int get_cte_definition_size() const { return cte_definitions_.count(); } + int64_t get_cte_definition_size() const { return cte_definitions_.count(); } common::ObIArray& get_cte_definitions() { return cte_definitions_; } const common::ObIArray& get_cte_definitions() const { return cte_definitions_; } diff --git a/src/sql/resolver/dml/ob_stmt_expr_visitor.h b/src/sql/resolver/dml/ob_stmt_expr_visitor.h index 6bd1a1f592..df00376587 100644 --- a/src/sql/resolver/dml/ob_stmt_expr_visitor.h +++ b/src/sql/resolver/dml/ob_stmt_expr_visitor.h @@ -79,7 +79,7 @@ public: void add_scope(DmlStmtScope scope) { - flags_ = (flags_ | (1L << scope)); + flags_ = static_cast((flags_ | (1L << scope))); } void add_scope(const ObIArray &scopes); @@ -218,4 +218,4 @@ private: } } -#endif // OB_STMT_EXPR_VISITOR_H \ No newline at end of file +#endif // OB_STMT_EXPR_VISITOR_H diff --git a/src/sql/session/ob_basic_session_info.h b/src/sql/session/ob_basic_session_info.h index c15d7d8462..9365f470ef 100644 --- a/src/sql/session/ob_basic_session_info.h +++ b/src/sql/session/ob_basic_session_info.h @@ -1588,7 +1588,7 @@ private: if (trace_info.empty()) { ob_trace_info_.reset(); } else { - int64_t trace_len = std::min(static_cast(trace_info.length()), OB_TRACE_BUFFER_SIZE); + const int32_t trace_len = std::min(trace_info.length(), OB_TRACE_BUFFER_SIZE); MEMCPY(trace_info_buf_, trace_info.ptr(), trace_len); ob_trace_info_.assign_ptr(trace_info_buf_, trace_len); } @@ -1606,8 +1606,8 @@ private: if (plsql_ccflags.empty()) { ob_plsql_ccflags_.reset(); } else { - int64_t ccflags_len - = std::min(static_cast(plsql_ccflags.length()), OB_TMP_BUF_SIZE_256); + const int32_t ccflags_len + = std::min(plsql_ccflags.length(), OB_TMP_BUF_SIZE_256); MEMCPY(plsql_ccflags_, plsql_ccflags.ptr(), ccflags_len); ob_plsql_ccflags_.assign_ptr(plsql_ccflags_, ccflags_len); } diff --git a/src/storage/blocksstable/ob_bloom_filter_cache.h b/src/storage/blocksstable/ob_bloom_filter_cache.h index 858b0fbf74..462845dcc0 100644 --- a/src/storage/blocksstable/ob_bloom_filter_cache.h +++ b/src/storage/blocksstable/ob_bloom_filter_cache.h @@ -311,7 +311,7 @@ public: OB_INLINE bool is_need_build() const { return is_inited_ && need_build_; } OB_INLINE bool is_valid() const { return is_inited_ && bf_cache_value_.is_valid(); } OB_INLINE int32_t get_row_count() const { return bf_cache_value_.get_row_count(); } - OB_INLINE int32_t get_rowkey_column_count() const { return bf_cache_value_.get_prefix_len(); } + OB_INLINE int64_t get_rowkey_column_count() const { return bf_cache_value_.get_prefix_len(); } TO_STRING_KV(K_(is_inited), K_(need_build), K_(max_row_count), K_(bf_cache_value)); private: ObBloomFilterCacheValue bf_cache_value_; diff --git a/src/storage/blocksstable/ob_datum_row.h b/src/storage/blocksstable/ob_datum_row.h index 6865f13a95..f5fdd4e2cf 100644 --- a/src/storage/blocksstable/ob_datum_row.h +++ b/src/storage/blocksstable/ob_datum_row.h @@ -545,12 +545,12 @@ OB_INLINE int ObStorageDatum::from_buf_enhance(const char *buf, const int64_t bu { int ret = common::OB_SUCCESS; - if (OB_UNLIKELY(nullptr == buf || buf_len < 0)) { + if (OB_UNLIKELY(nullptr == buf || buf_len < 0 || buf_len > UINT32_MAX)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "Invalid argument to transfer from buf", K(ret), KP(buf), K(buf_len)); } else { reuse(); - len_ = buf_len; + len_ = static_cast(buf_len); if (buf_len > 0) { ptr_ = buf; } diff --git a/src/storage/blocksstable/ob_micro_block_header.h b/src/storage/blocksstable/ob_micro_block_header.h index e44ff5c03c..b80f4c8563 100644 --- a/src/storage/blocksstable/ob_micro_block_header.h +++ b/src/storage/blocksstable/ob_micro_block_header.h @@ -85,8 +85,8 @@ public: int deserialize(const char *buf, const int64_t data_len, int64_t& pos); uint32_t get_serialize_size() { return get_serialize_size(column_count_, has_column_checksum_); } static uint32_t get_serialize_size(const int64_t column_count, const bool need_calc_column_chksum) { - return ObMicroBlockHeader::COLUMN_CHECKSUM_PTR_OFFSET + - (need_calc_column_chksum ? column_count * sizeof(int64_t) : 0); + return static_cast(ObMicroBlockHeader::COLUMN_CHECKSUM_PTR_OFFSET + + (need_calc_column_chksum ? column_count * sizeof(int64_t) : 0)); } TO_STRING_KV(K_(magic), K_(version), K_(header_size), K_(header_checksum), K_(column_count), K_(rowkey_column_count), K_(has_column_checksum), K_(row_count), K_(row_store_type), diff --git a/src/storage/blocksstable/ob_tmp_file.h b/src/storage/blocksstable/ob_tmp_file.h index b47dc1c4d8..5ce6e781d6 100644 --- a/src/storage/blocksstable/ob_tmp_file.h +++ b/src/storage/blocksstable/ob_tmp_file.h @@ -173,7 +173,6 @@ public: OB_INLINE uint8_t get_page_nums() const { return page_nums_; } OB_INLINE void set_block_id(const int64_t block_id) { block_id_ = block_id; } OB_INLINE int64_t get_block_id() const { return block_id_; } - OB_INLINE void set_offset(const int64_t offset) { offset_ = offset; } OB_INLINE int32_t get_offset() const { return offset_; } OB_INLINE ObTmpFile &get_owner() { return *owner_; } TO_STRING_KV(K_(is_alloced), K_(fd), K_(g_offset_start), K_(g_offset_end), KP_(owner), diff --git a/src/storage/compaction/ob_compaction_diagnose.h b/src/storage/compaction/ob_compaction_diagnose.h index 6de1453033..2802be9ec1 100644 --- a/src/storage/compaction/ob_compaction_diagnose.h +++ b/src/storage/compaction/ob_compaction_diagnose.h @@ -113,7 +113,7 @@ public: int init(ObCompactionDiagnoseInfo *info_array, const int64_t max_cnt); int diagnose_all_tablets(const int64_t tenant_id); int diagnose_tenant_tablet(); - int get_cnt() { return idx_; } + int64_t get_cnt() { return idx_; } static int diagnose_dag( const storage::ObMergeType merge_type, const ObLSID ls_id, diff --git a/src/storage/compaction/ob_partition_parallel_merge_ctx.cpp b/src/storage/compaction/ob_partition_parallel_merge_ctx.cpp index e397acfec1..a9c30d2fa4 100644 --- a/src/storage/compaction/ob_partition_parallel_merge_ctx.cpp +++ b/src/storage/compaction/ob_partition_parallel_merge_ctx.cpp @@ -300,7 +300,7 @@ int ObParallelMergeCtx::init_parallel_mini_merge(compaction::ObTabletMergeCtx &m } else { int64_t total_bytes = 0; int64_t total_rows = 0; - int32_t mini_merge_thread = 0; + int64_t mini_merge_thread = 0; if (OB_FAIL(memtable->estimate_phy_size(nullptr, nullptr, total_bytes, total_rows))) { STORAGE_LOG(WARN, "Failed to get estimate size from memtable", K(ret)); } else if (MTL(ObTenantDagScheduler *)->get_up_limit(ObDagPrio::DAG_PRIO_COMPACTION_HIGH, mini_merge_thread)) { @@ -411,7 +411,7 @@ int ObParallelMergeCtx::calc_mini_minor_parallel_degree(const int64_t tablet_siz int64_t ¶llel_degree) { int ret = OB_SUCCESS; - int32_t minor_merge_thread = 0; + int64_t minor_merge_thread = 0; if (OB_UNLIKELY(tablet_size == 0 || total_size < 0 || sstable_count <= 1)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "Invalid argument to calc mini minor parallel degree", K(ret), K(tablet_size), diff --git a/src/storage/lob/ob_lob_util.h b/src/storage/lob/ob_lob_util.h index 4f575ad2de..4f8ca98abf 100644 --- a/src/storage/lob/ob_lob_util.h +++ b/src/storage/lob/ob_lob_util.h @@ -129,7 +129,7 @@ struct ObLobMetaInfo { ObString tmp_seq = seq_id_; size_t len = tmp_seq.length(); const uint32_t* ori_dig = reinterpret_cast(tmp_seq.ptr()); - const uint32_t ori_len = len / sizeof(uint32_t); + const uint32_t ori_len = static_cast(len / sizeof(uint32_t)); //TODO(yuanzhi.zy): check is len int32 enough uint32_t cur_pos = 0; common::databuff_printf(buf, buf_len, pos, ", seq_id:["); while (cur_pos < ori_len) { diff --git a/src/storage/ob_i_store.h b/src/storage/ob_i_store.h index 4d54331e41..0fa2fe1414 100644 --- a/src/storage/ob_i_store.h +++ b/src/storage/ob_i_store.h @@ -170,21 +170,21 @@ public: const int64_t schema_rowkey_col_cnt, const bool is_multi_version) { - int ret = -1; + int64_t index = -1; if (is_multi_version) { - ret = schema_rowkey_col_cnt + ObMultiVersionExtraRowkeyIds::TRANS_VERSION_COL; + index = schema_rowkey_col_cnt + ObMultiVersionExtraRowkeyIds::TRANS_VERSION_COL; } - return ret; + return index; } static int64_t get_sql_sequence_col_store_index( const int64_t schema_rowkey_col_cnt, const bool is_multi_version) { - int ret = -1; + int64_t index = -1; if (is_multi_version) { - ret = schema_rowkey_col_cnt + ObMultiVersionExtraRowkeyIds::SQL_SEQUENCE_COL; + index = schema_rowkey_col_cnt + ObMultiVersionExtraRowkeyIds::SQL_SEQUENCE_COL; } - return ret; + return index; } static int add_extra_rowkey_cols(ObColDescIArray &store_out_cols); diff --git a/src/storage/tx/ob_trans_define.h b/src/storage/tx/ob_trans_define.h index a6e2428db8..78f17b2a9d 100644 --- a/src/storage/tx/ob_trans_define.h +++ b/src/storage/tx/ob_trans_define.h @@ -737,123 +737,6 @@ public: int64_t seq_no_; }; -class ObTransTaskInfo //unreferenced, need remove -{ - OB_UNIS_VERSION(1); -public: - int start_stmt(const int32_t sql_no); - int start_stmt_v2(const int64_t seq_no); - int start_task(const int32_t sql_no, const int64_t snapshot_version); - int start_task_v2(const int32_t sql_no, const int64_t seq_no, const int64_t snapshot_version); - void end_task(); - bool is_task_match(const int32_t sql_no) const; - bool is_task_match_v2(const int64_t seq_no) const; - void remove_task_after(const int32_t sql_no); - void remove_task_after_v2(const int64_t seq_no); - bool is_stmt_ended() const { return tasks_.empty(); } - int64_t get_top_snapshot_version() const; - void reset() { tasks_.reset(); } - TO_STRING_KV(K(tasks_)); -private: - common::ObSEArray tasks_; -}; - -class ObTransStmtInfo //unused, to be removed -{ - OB_UNIS_VERSION(1); -public: - ObTransStmtInfo() { reset(); } - ~ObTransStmtInfo() {} - void reset(); - int start_stmt(const int64_t sql_no) - { - return task_info_.start_stmt(sql_no); - } - int start_stmt_v2(const int64_t seq_no) - { - return task_info_.start_stmt_v2(seq_no); - } - void end_stmt(const int64_t sql_no) - { - update_sql_no(sql_no); - need_rollback_ = true; - task_info_.remove_task_after(0); - } - void end_stmt_v2() - { - need_rollback_ = true; - task_info_.remove_task_after_v2(0); - } - void rollback_to(const int64_t from, const int64_t to) - { - update_sql_no(from); - need_rollback_ = true; - task_info_.remove_task_after(to); - } - void rollback_to_v2(const int64_t to) - { - // [to, from) - need_rollback_ = true; - task_info_.remove_task_after_v2(to); - } - int start_task(const int64_t sql_no, const int64_t snapshot_version) - { - update_sql_no(sql_no); - return task_info_.start_task(sql_no, snapshot_version); - } - int start_task_v2(const int64_t sql_no, const int64_t seq_no, const int64_t snapshot_version) - { - update_sql_no(sql_no); - // update_seq_no(seq_no); - return task_info_.start_task_v2(sql_no, seq_no, snapshot_version); - } - void end_task() { return task_info_.end_task(); } - - int64_t get_top_snapshot_version() const { return task_info_.get_top_snapshot_version(); } - bool is_stmt_ended() const { return task_info_.is_stmt_ended(); } - bool is_task_match(const int64_t sql_no = 0) const { return task_info_.is_task_match(sql_no); } - bool is_task_match_v2(const int64_t seq_no = 0) const { return task_info_.is_task_match_v2(seq_no); } - bool stmt_expired(const int64_t sql_no, const bool is_rollback = false) const - { - return sql_no < sql_no_ || (!is_rollback && (need_rollback_ && sql_no == sql_no_)); - } - bool stmt_expired_v2(const int64_t msg_seq, const bool is_rollback = false) const - { - return msg_seq < msg_seq_ || (!is_rollback && (need_rollback_ && msg_seq == msg_seq_)); - } - bool stmt_matched(const int64_t sql_no) const { return sql_no == sql_no_ && !need_rollback_; } - bool stmt_matched_v2(const int64_t msg_seq) const { return msg_seq == msg_seq_ && !need_rollback_; } - - bool main_stmt_change(const int64_t sql_no) const { return (sql_no >> 32) > main_sql_no_; } - bool main_stmt_change_compat(const int64_t sql_no) const { return sql_no > sql_no_; } - int64_t get_sql_no() const { return sql_no_; } - // int64_t get_seq_no() const { return seq_no_; } - void update_msg_seq(const int64_t msg_seq) - { - if (msg_seq > msg_seq_) { msg_seq_ = msg_seq; need_rollback_ = false; } - } - - TO_STRING_KV(K_(sql_no), K_(msg_seq), K_(start_task_cnt), K_(end_task_cnt), K_(need_rollback), K_(task_info)); -private: - void update_sql_no(const int64_t sql_no) - { - if (sql_no > sql_no_) { sql_no_ = sql_no; need_rollback_ = false; } - } - - union { - struct { - int32_t sub_sql_no_; - int32_t main_sql_no_; - }; - int64_t sql_no_; - }; - int64_t start_task_cnt_; // compat only - int64_t end_task_cnt_; // compat only - bool need_rollback_; - ObTransTaskInfo task_info_; - int64_t msg_seq_; -}; - class ObTransVersion { public: @@ -1703,7 +1586,7 @@ public: int range_submitted(ObTxMDSCache &cache); void range_sync_failed(); - int count() const { return count_; }; + int64_t count() const { return count_; }; TO_STRING_KV(K(count_)); diff --git a/src/storage/tx/ob_trans_define_v4.h b/src/storage/tx/ob_trans_define_v4.h index f19b68d3b6..1612b04182 100644 --- a/src/storage/tx/ob_trans_define_v4.h +++ b/src/storage/tx/ob_trans_define_v4.h @@ -547,7 +547,7 @@ public: void set_with_temporary_table() { flags_.WITH_TEMP_TABLE_ = true; } bool with_temporary_table() const { return flags_.WITH_TEMP_TABLE_; } int64_t get_op_sn() const { return op_sn_; } - int inc_op_sn() { state_change_flags_.DYNAMIC_CHANGED_ = true; return ++op_sn_; } + void inc_op_sn() { state_change_flags_.DYNAMIC_CHANGED_ = true; ++op_sn_; } share::SCN get_commit_version() const { return commit_version_; } bool contain_savepoint(const ObString &sp); bool is_tx_end() { diff --git a/src/storage/tx/ob_trans_log.h b/src/storage/tx/ob_trans_log.h index c311cf5abd..77e092a7f1 100644 --- a/src/storage/tx/ob_trans_log.h +++ b/src/storage/tx/ob_trans_log.h @@ -351,45 +351,6 @@ private: int64_t checkpoint_; }; -class ObTransStateLog : public ObTransLog -{ - OB_UNIS_VERSION(1); -public: - ObTransStateLog() : create_ts_(0), tenant_id_(common::OB_INVALID_TENANT_ID), trans_expired_time_(0), - is_readonly_(false), trans_type_(TransType::UNKNOWN_TRANS), session_id_(0), proxy_session_id_(0), - commit_task_count_(0), schema_version_(0), can_elr_(false), cluster_version_(0), - snapshot_version_(), cur_query_start_time_(0), stmt_expired_time_(0), trx_api_v2_(true) {} - ~ObTransStateLog() {} -public: - bool is_valid() const { return true; } - TO_STRING_KV(K_(log_type)); -private: - int64_t create_ts_; - int64_t tenant_id_; - int64_t trans_expired_time_; - common::ObAddr scheduler_; - ObStartTransParam trans_param_; - bool is_readonly_; - int trans_type_; - int session_id_; - int64_t proxy_session_id_; - int64_t commit_task_count_; - ObTransStmtInfo stmt_info_; - common::ObString app_trace_id_str_; - int64_t schema_version_; - ObElrTransInfoArray prev_trans_arr_; - bool can_elr_; - common::ObAddr proposal_leader_; - uint64_t cluster_version_; - share::SCN snapshot_version_; - int64_t cur_query_start_time_; - int64_t stmt_expired_time_; - ObXATransID xid_; - int64_t last_sql_no_; -public: - bool trx_api_v2_; -}; - class ObTransMutatorLogHelper { public: diff --git a/src/storage/tx/ob_trans_timer.h b/src/storage/tx/ob_trans_timer.h index 9d989dd5b0..8a98190179 100644 --- a/src/storage/tx/ob_trans_timer.h +++ b/src/storage/tx/ob_trans_timer.h @@ -124,7 +124,7 @@ public: virtual int register_timeout_task(ObITimeoutTask &task, const int64_t delay); virtual int unregister_timeout_task(ObITimeoutTask &task); private: - int get_thread_num_() { return common::max(sysconf(_SC_NPROCESSORS_ONLN) / 24, 2); } + int64_t get_thread_num_() { return common::max(sysconf(_SC_NPROCESSORS_ONLN) / 24, 2); } private: DISALLOW_COPY_AND_ASSIGN(ObTransTimer); protected: