diff --git a/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp b/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp index 6343c307cc..620ab71b28 100644 --- a/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp @@ -781,7 +781,7 @@ int ObInnerTableSchema::gv_sql_workarea_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL AS BINARY(8)) AS ADDRESS, CAST(NULL AS SIGNED) AS HASH_VALUE, SQL_ID, CAST(NULL AS SIGNED) AS CHILD_NUMBER, CAST(NULL AS BINARY(8)) AS WORKAREA_ADDRESS, OPERATION_TYPE, OPERATION_ID, POLICY, ESTIMATED_OPTIMAL_SIZE, ESTIMATED_ONEPASS_SIZE, LAST_MEMORY_USED, LAST_EXECUTION, LAST_DEGREE, TOTAL_EXECUTIONS, OPTIMAL_EXECUTIONS, ONEPASS_EXECUTIONS, MULTIPASSES_EXECUTIONS, ACTIVE_TIME, MAX_TEMPSEG_SIZE, LAST_TEMPSEG_SIZE, TENANT_ID AS CON_ID, SVR_IP, SVR_PORT FROM OCEANBASE.__ALL_VIRTUAL_SQL_WORKAREA_HISTORY_STAT )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL AS BINARY(8)) AS ADDRESS, CAST(NULL AS SIGNED) AS HASH_VALUE, SQL_ID, CAST(PLAN_ID AS SIGNED) AS CHILD_NUMBER, CAST(NULL AS BINARY(8)) AS WORKAREA_ADDRESS, OPERATION_TYPE, OPERATION_ID, POLICY, ESTIMATED_OPTIMAL_SIZE, ESTIMATED_ONEPASS_SIZE, LAST_MEMORY_USED, LAST_EXECUTION, LAST_DEGREE, TOTAL_EXECUTIONS, OPTIMAL_EXECUTIONS, ONEPASS_EXECUTIONS, MULTIPASSES_EXECUTIONS, ACTIVE_TIME, MAX_TEMPSEG_SIZE, LAST_TEMPSEG_SIZE, TENANT_ID AS CON_ID, SVR_IP, SVR_PORT FROM OCEANBASE.__ALL_VIRTUAL_SQL_WORKAREA_HISTORY_STAT )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.28051_28100.cpp b/src/share/inner_table/ob_inner_table_schema.28051_28100.cpp index 79a094fdb8..81a9858c8b 100644 --- a/src/share/inner_table/ob_inner_table_schema.28051_28100.cpp +++ b/src/share/inner_table/ob_inner_table_schema.28051_28100.cpp @@ -210,7 +210,7 @@ int ObInnerTableSchema::gv_sql_workarea_ora_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL AS RAW(8)) AS ADDRESS, CAST(NULL AS NUMBER) AS HASH_VALUE, SQL_ID, CAST(NULL AS NUMBER) AS CHILD_NUMBER, CAST(NULL AS RAW(8)) AS WORKAREA_ADDRESS, CAST(OPERATION_TYPE AS VARCHAR2(160)) AS OPERATION_TYPE, CAST(OPERATION_ID AS NUMBER) AS OPERATION_ID, CAST(POLICY AS VARCHAR2(40)) AS POLICY, CAST(ESTIMATED_OPTIMAL_SIZE AS NUMBER) AS ESTIMATED_OPTIMAL_SIZE, CAST(ESTIMATED_ONEPASS_SIZE AS NUMBER) AS ESTIMATED_ONEPASS_SIZE, CAST(LAST_MEMORY_USED AS NUMBER) AS LAST_MEMORY_USED, CAST(LAST_EXECUTION AS VARCHAR2(40)) AS LAST_EXECUTION, CAST(LAST_DEGREE AS NUMBER) AS LAST_DEGREE, CAST(TOTAL_EXECUTIONS AS NUMBER) AS TOTAL_EXECUTIONS, CAST(OPTIMAL_EXECUTIONS AS NUMBER) AS OPTIMAL_EXECUTIONS, CAST(ONEPASS_EXECUTIONS AS NUMBER) AS ONEPASS_EXECUTIONS, CAST(MULTIPASSES_EXECUTIONS AS NUMBER) AS MULTIPASSES_EXECUTIONS, CAST(ACTIVE_TIME AS NUMBER) AS ACTIVE_TIME, CAST(MAX_TEMPSEG_SIZE AS NUMBER) AS MAX_TEMPSEG_SIZE, CAST(LAST_TEMPSEG_SIZE AS NUMBER) AS LAST_TEMPSEG_SIZE, CAST(TENANT_ID AS NUMBER) AS CON_ID, SVR_IP, SVR_PORT FROM SYS.ALL_VIRTUAL_SQL_WORKAREA_HISTORY_STAT )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL AS RAW(8)) AS ADDRESS, CAST(NULL AS NUMBER) AS HASH_VALUE, SQL_ID, CAST(PLAN_ID AS NUMBER) AS CHILD_NUMBER, CAST(NULL AS RAW(8)) AS WORKAREA_ADDRESS, CAST(OPERATION_TYPE AS VARCHAR2(160)) AS OPERATION_TYPE, CAST(OPERATION_ID AS NUMBER) AS OPERATION_ID, CAST(POLICY AS VARCHAR2(40)) AS POLICY, CAST(ESTIMATED_OPTIMAL_SIZE AS NUMBER) AS ESTIMATED_OPTIMAL_SIZE, CAST(ESTIMATED_ONEPASS_SIZE AS NUMBER) AS ESTIMATED_ONEPASS_SIZE, CAST(LAST_MEMORY_USED AS NUMBER) AS LAST_MEMORY_USED, CAST(LAST_EXECUTION AS VARCHAR2(40)) AS LAST_EXECUTION, CAST(LAST_DEGREE AS NUMBER) AS LAST_DEGREE, CAST(TOTAL_EXECUTIONS AS NUMBER) AS TOTAL_EXECUTIONS, CAST(OPTIMAL_EXECUTIONS AS NUMBER) AS OPTIMAL_EXECUTIONS, CAST(ONEPASS_EXECUTIONS AS NUMBER) AS ONEPASS_EXECUTIONS, CAST(MULTIPASSES_EXECUTIONS AS NUMBER) AS MULTIPASSES_EXECUTIONS, CAST(ACTIVE_TIME AS NUMBER) AS ACTIVE_TIME, CAST(MAX_TEMPSEG_SIZE AS NUMBER) AS MAX_TEMPSEG_SIZE, CAST(LAST_TEMPSEG_SIZE AS NUMBER) AS LAST_TEMPSEG_SIZE, CAST(TENANT_ID AS NUMBER) AS CON_ID, SVR_IP, SVR_PORT FROM SYS.ALL_VIRTUAL_SQL_WORKAREA_HISTORY_STAT )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index e93b895c00..9d775f65da 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -14604,7 +14604,7 @@ def_table_schema( CAST(NULL AS BINARY(8)) AS ADDRESS, CAST(NULL AS SIGNED) AS HASH_VALUE, SQL_ID, - CAST(NULL AS SIGNED) AS CHILD_NUMBER, + CAST(PLAN_ID AS SIGNED) AS CHILD_NUMBER, CAST(NULL AS BINARY(8)) AS WORKAREA_ADDRESS, OPERATION_TYPE, OPERATION_ID, @@ -46297,7 +46297,7 @@ def_table_schema( CAST(NULL AS RAW(8)) AS ADDRESS, CAST(NULL AS NUMBER) AS HASH_VALUE, SQL_ID, - CAST(NULL AS NUMBER) AS CHILD_NUMBER, + CAST(PLAN_ID AS NUMBER) AS CHILD_NUMBER, CAST(NULL AS RAW(8)) AS WORKAREA_ADDRESS, CAST(OPERATION_TYPE AS VARCHAR2(160)) AS OPERATION_TYPE, CAST(OPERATION_ID AS NUMBER) AS OPERATION_ID, diff --git a/src/sql/engine/aggregate/ob_aggregate_processor.cpp b/src/sql/engine/aggregate/ob_aggregate_processor.cpp index 7e51900d6b..3b1920f914 100644 --- a/src/sql/engine/aggregate/ob_aggregate_processor.cpp +++ b/src/sql/engine/aggregate/ob_aggregate_processor.cpp @@ -1861,7 +1861,7 @@ int ObAggregateProcessor::generate_group_row(GroupRow *&new_group_row, ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", K(ret)); } else { - GroupConcatExtraResult *result = new (tmp_buf) GroupConcatExtraResult(aggr_alloc_); + GroupConcatExtraResult *result = new (tmp_buf) GroupConcatExtraResult(aggr_alloc_, op_monitor_info_); aggr_cell.set_extra(result); const bool need_rewind = (in_window_func_ || group_id > 0); if (OB_FAIL(result->init(eval_ctx_.exec_ctx_.get_my_session()->get_effective_tenant_id(), @@ -1904,7 +1904,7 @@ int ObAggregateProcessor::generate_group_row(GroupRow *&new_group_row, ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", "size", sizeof(HybridHistExtraResult)); } else { - HybridHistExtraResult *result = new (tmp_buf) HybridHistExtraResult(aggr_alloc_); + HybridHistExtraResult *result = new (tmp_buf) HybridHistExtraResult(aggr_alloc_, op_monitor_info_); aggr_cell.set_extra(result); const bool need_rewind = (in_window_func_ || group_id > 0); if (OB_FAIL(result->init(eval_ctx_.exec_ctx_.get_my_session()->get_effective_tenant_id(), @@ -1927,7 +1927,7 @@ int ObAggregateProcessor::generate_group_row(GroupRow *&new_group_row, ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", K(ret)); } else { - TopKFreHistExtraResult *result = new (tmp_buf) TopKFreHistExtraResult(aggr_alloc_); + TopKFreHistExtraResult *result = new (tmp_buf) TopKFreHistExtraResult(aggr_alloc_, op_monitor_info_); aggr_cell.set_extra(result); } break; @@ -1937,24 +1937,23 @@ int ObAggregateProcessor::generate_group_row(GroupRow *&new_group_row, CK(NULL != aggr_info.dll_udf_); DllUdfExtra *extra = NULL; if (OB_SUCC(ret)) { - extra = OB_NEWx(DllUdfExtra, (&aggr_alloc_), - aggr_alloc_); - if (NULL == extra) { + void *tmp_buf = NULL; + if (OB_ISNULL(tmp_buf = aggr_alloc_.alloc(sizeof(DllUdfExtra)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", K(ret)); - } - aggr_cell.set_extra(extra); - } - if (OB_SUCC(ret)) { - OZ(ObUdfUtil::init_udf_args(aggr_alloc_, + } else { + DllUdfExtra *extra = new (tmp_buf) DllUdfExtra(aggr_alloc_, op_monitor_info_); + aggr_cell.set_extra(extra); + OZ(ObUdfUtil::init_udf_args(aggr_alloc_, aggr_info.dll_udf_->udf_attributes_, aggr_info.dll_udf_->udf_attributes_types_, extra->udf_ctx_.udf_args_)); - OZ(aggr_info.dll_udf_->udf_func_.process_init_func(extra->udf_ctx_)); - if (OB_SUCC(ret)) { // set func after udf ctx inited - extra->udf_fun_ = &aggr_info.dll_udf_->udf_func_; + OZ(aggr_info.dll_udf_->udf_func_.process_init_func(extra->udf_ctx_)); + if (OB_SUCC(ret)) { // set func after udf ctx inited + extra->udf_fun_ = &aggr_info.dll_udf_->udf_func_; + } + OZ(extra->udf_fun_->process_clear_func(extra->udf_ctx_)); } - OZ(extra->udf_fun_->process_clear_func(extra->udf_ctx_)); } break; } @@ -1971,7 +1970,7 @@ int ObAggregateProcessor::generate_group_row(GroupRow *&new_group_row, ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", K(ret)); } else { - ExtraResult *result = new (tmp_buf) ExtraResult(aggr_alloc_); + ExtraResult *result = new (tmp_buf) ExtraResult(aggr_alloc_, op_monitor_info_); aggr_cell.set_extra(result); } } diff --git a/src/sql/engine/aggregate/ob_aggregate_processor.h b/src/sql/engine/aggregate/ob_aggregate_processor.h index 2987526dd1..c1f52befc1 100644 --- a/src/sql/engine/aggregate/ob_aggregate_processor.h +++ b/src/sql/engine/aggregate/ob_aggregate_processor.h @@ -280,8 +280,8 @@ public: { public: // %alloc is used to initialize the structures, can not be used to hold the data - explicit ExtraResult(common::ObIAllocator &alloc) - : alloc_(alloc), unique_sort_op_(NULL) + explicit ExtraResult(common::ObIAllocator &alloc, ObMonitorNode &op_monitor_info) + : alloc_(alloc), op_monitor_info_(op_monitor_info), unique_sort_op_(NULL) {} virtual ~ExtraResult(); virtual void reuse(); @@ -293,7 +293,7 @@ public: DECLARE_VIRTUAL_TO_STRING; protected: common::ObIAllocator &alloc_; - ObMonitorNode op_monitor_info_; + ObMonitorNode &op_monitor_info_; public: // for distinct calculate may be replace by hash based distinct in the future. ObUniqueSortImpl *unique_sort_op_; @@ -302,8 +302,8 @@ public: struct TopKFreHistExtraResult : public ExtraResult { public: - TopKFreHistExtraResult(common::ObIAllocator &alloc) - : ExtraResult(alloc), topk_fre_hist_() {} + TopKFreHistExtraResult(common::ObIAllocator &alloc, ObMonitorNode &op_monitor_info) + : ExtraResult(alloc, op_monitor_info), topk_fre_hist_() {} virtual ~TopKFreHistExtraResult() {} virtual void reuse() { @@ -317,8 +317,8 @@ public: class GroupConcatExtraResult : public ExtraResult { public: - explicit GroupConcatExtraResult(common::ObIAllocator &alloc) - : ExtraResult(alloc), row_count_(0), iter_idx_(0), sort_op_(NULL), separator_datum_(NULL), bool_mark_(alloc) + explicit GroupConcatExtraResult(common::ObIAllocator &alloc, ObMonitorNode &op_monitor_info) + : ExtraResult(alloc, op_monitor_info), row_count_(0), iter_idx_(0), sort_op_(NULL), separator_datum_(NULL), bool_mark_(alloc) { } virtual ~GroupConcatExtraResult(); @@ -383,8 +383,8 @@ public: class HybridHistExtraResult : public ExtraResult { public: - explicit HybridHistExtraResult(common::ObIAllocator &alloc) - : ExtraResult(alloc), + explicit HybridHistExtraResult(common::ObIAllocator &alloc, ObMonitorNode &op_monitor_info) + : ExtraResult(alloc, op_monitor_info), sort_row_count_(0), material_row_count_(0), sort_op_(nullptr), @@ -425,8 +425,8 @@ public: struct DllUdfExtra : public ExtraResult { - explicit DllUdfExtra(common::ObIAllocator &alloc) - : ExtraResult(alloc), udf_fun_(NULL) + explicit DllUdfExtra(common::ObIAllocator &alloc, ObMonitorNode &op_monitor_info) + : ExtraResult(alloc, op_monitor_info), udf_fun_(NULL) { } diff --git a/src/sql/engine/aggregate/ob_hash_groupby_op.cpp b/src/sql/engine/aggregate/ob_hash_groupby_op.cpp index bf5bbcf7da..33b986e3d5 100644 --- a/src/sql/engine/aggregate/ob_hash_groupby_op.cpp +++ b/src/sql/engine/aggregate/ob_hash_groupby_op.cpp @@ -662,8 +662,8 @@ int ObHashGroupByOp::init_distinct_info(bool is_part) &ctx_.get_allocator(), tenant_id, est_size, - PHY_HASH_DISTINCT, // hardcode to distinct - MY_SPEC.id_ + 1, // for unique, using op_id + 1 + MY_SPEC.type_, + MY_SPEC.id_, &ctx_))) { LOG_WARN("failed to init sql mem processor", K(ret)); } else if (is_part) { diff --git a/src/sql/engine/expr/ob_expr_nvl.cpp b/src/sql/engine/expr/ob_expr_nvl.cpp index f2e29f5dfb..6f93fef7fc 100644 --- a/src/sql/engine/expr/ob_expr_nvl.cpp +++ b/src/sql/engine/expr/ob_expr_nvl.cpp @@ -290,9 +290,9 @@ ObExprNaNvl::~ObExprNaNvl() {} int ObExprNaNvl::calc_result_type2(ObExprResType &type, - ObExprResType &type1, - ObExprResType &type2, - ObExprTypeCtx &type_ctx) const + ObExprResType &type1, + ObExprResType &type2, + ObExprTypeCtx &type_ctx) const { UNUSED(type_ctx); int ret = OB_SUCCESS; @@ -308,6 +308,10 @@ int ObExprNaNvl::calc_result_type2(ObExprResType &type, LOG_USER_ERROR(OB_ERR_INVALID_TYPE_FOR_OP, "NUMBER", ob_obj_type_str(type2.get_type())); LOG_WARN("invalid type of parameter", K(ret), K(type2)); + } else if (ObTinyIntType == type1.get_type() || ObTinyIntType == type2.get_type()) { + ret = OB_ERR_CALL_WRONG_ARG; + LOG_WARN("PLS-00306: wrong number or types of arguments in call", K(ret)); + LOG_USER_ERROR(OB_ERR_CALL_WRONG_ARG, static_cast(strlen(get_name())), get_name()); } if (OB_SUCC(ret)) { type.set_type(ObNumberType); diff --git a/src/sql/engine/ob_sql_mem_mgr_processor.h b/src/sql/engine/ob_sql_mem_mgr_processor.h index be4a1783da..9753d11dd5 100644 --- a/src/sql/engine/ob_sql_mem_mgr_processor.h +++ b/src/sql/engine/ob_sql_mem_mgr_processor.h @@ -120,7 +120,6 @@ public: } int64_t get_dumped_size() const { return profile_.dumped_size_; } void reset_delta_size() { profile_.delta_size_ = 0; } - void reset_mem_used() { profile_.mem_used_ = 0; } int64_t get_mem_used() const { return profile_.mem_used_; } int64_t get_delta_size() const { return profile_.delta_size_; } int64_t get_data_size() const { return profile_.data_size_ + profile_.delta_size_; } diff --git a/src/sql/engine/ob_tenant_sql_memory_manager.cpp b/src/sql/engine/ob_tenant_sql_memory_manager.cpp index 067c2d564d..6e79c829ee 100644 --- a/src/sql/engine/ob_tenant_sql_memory_manager.cpp +++ b/src/sql/engine/ob_tenant_sql_memory_manager.cpp @@ -1257,7 +1257,7 @@ int ObTenantSqlMemoryManager::get_workarea_stat(ObIArray &wa_ if (OB_FAIL(wa_stats.push_back(workarea_stats_.at(nth)))) { LOG_WARN("failed to push back workarea stat", K(ret)); } else { - LOG_TRACE("trace workarea history", K(workarea_stats_.at(i)), + LOG_TRACE("trace workarea history", K(workarea_stats_.at(nth)), K(wa_stats.at(wa_stats.count() - 1))); } } diff --git a/src/sql/engine/sort/ob_sort_op_impl.cpp b/src/sql/engine/sort/ob_sort_op_impl.cpp index 20943960a8..f8c5e91dee 100644 --- a/src/sql/engine/sort/ob_sort_op_impl.cpp +++ b/src/sql/engine/sort/ob_sort_op_impl.cpp @@ -989,7 +989,7 @@ int ObSortOpImpl::before_add_row() if (OB_FAIL(sql_mem_processor_.init( &mem_context_->get_malloc_allocator(), tenant_id_, - size, op_type_, op_id_, exec_ctx_))) { + size, op_monitor_info_.op_type_, op_monitor_info_.op_id_, exec_ctx_))) { LOG_WARN("failed to init sql mem processor", K(ret)); } else { datum_store_.set_dir_id(sql_mem_processor_.get_dir_id()); @@ -1944,7 +1944,7 @@ int ObSortOpImpl::add_heap_sort_row(const common::ObIArray &exprs, int64_t size = OB_INVALID_ID == input_rows_ ? 0 : input_rows_ * input_width_ * 2; if (OB_FAIL(sql_mem_processor_.init( &mem_context_->get_malloc_allocator(), - tenant_id_, size, op_type_, op_id_, &eval_ctx_->exec_ctx_))) { + tenant_id_, size, op_monitor_info_.op_type_, op_monitor_info_.op_id_, &eval_ctx_->exec_ctx_))) { LOG_WARN("failed to init sql mem processor", K(ret)); } } else {