diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index a8fa7983bc..dc6063b5a8 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -1768,6 +1768,10 @@ int ObPL::execute(ObExecContext &ctx, ParamStore ¶ms, const ObStmtNodeTree * // stmt_id is OB_INVALID_ID for anonymous block from text protocol OZ (compiler.compile(block, OB_INVALID_ID, *routine, ¶ms, false)); OX (routine->set_debug_priv()); + if (OB_SUCC(ret) && params.count() != routine->get_params_info().count()) { + ret = OB_ERR_BIND_VARIABLE_NOT_EXIST; + LOG_WARN("text anonymous can not contain bind variable", K(ret)); + } } } // restore work timeout @@ -2443,7 +2447,7 @@ int ObPL::generate_pl_function(ObExecContext &ctx, OZ (compiler.compile( block_node, stmt_id, *routine, ¶ms, ctx.get_sql_ctx()->is_prepare_protocol_)); - OZ (routine->set_params_info(params)); + OZ (routine->set_params_info(params, true)); } int64_t compile_end = ObTimeUtility::current_time(); diff --git a/src/pl/pl_cache/ob_pl_cache.cpp b/src/pl/pl_cache/ob_pl_cache.cpp index e73d09bf5d..18fdabe440 100644 --- a/src/pl/pl_cache/ob_pl_cache.cpp +++ b/src/pl/pl_cache/ob_pl_cache.cpp @@ -747,6 +747,9 @@ int ObPLObjectValue::match_param_info(const ObPlParamInfo ¶m_info, is_same = false; } else { is_same = (param.get_scale() == param_info.scale_); + if (is_same && param.is_number() && PL_INTEGER_TYPE == param_info.pl_type_) { + is_same = param.get_number().is_valid_int(); + } } } if (is_same && param_info.flag_.need_to_check_bool_value_) { diff --git a/src/pl/pl_cache/ob_pl_cache_object.cpp b/src/pl/pl_cache/ob_pl_cache_object.cpp index 5e7f08f53d..ccf3a85a4e 100644 --- a/src/pl/pl_cache/ob_pl_cache_object.cpp +++ b/src/pl/pl_cache/ob_pl_cache_object.cpp @@ -40,7 +40,7 @@ void ObPLCacheObject::reset() expressions_.reset(); } -int ObPLCacheObject::set_params_info(const ParamStore ¶ms) +int ObPLCacheObject::set_params_info(const ParamStore ¶ms, bool is_anonymous) { int ret = OB_SUCCESS; int64_t N = params.count(); @@ -95,6 +95,13 @@ int ObPLCacheObject::set_params_info(const ParamStore ¶ms) LOG_DEBUG("ext params info", K(data_type), K(param_info), K(params.at(i))); } else { param_info.scale_ = params.at(i).get_scale(); + if (is_anonymous) { + ObPLFunction *func = static_cast(this); + if (func->get_variables().count() > i && + func->get_variables().at(i).is_pl_integer_type()) { + param_info.pl_type_ = PL_INTEGER_TYPE; + } + } } if (OB_SUCC(ret)) { if (OB_FAIL(params_info_.push_back(param_info))) { diff --git a/src/pl/pl_cache/ob_pl_cache_object.h b/src/pl/pl_cache/ob_pl_cache_object.h index 9082b90568..5c3db9843d 100644 --- a/src/pl/pl_cache/ob_pl_cache_object.h +++ b/src/pl/pl_cache/ob_pl_cache_object.h @@ -89,7 +89,7 @@ public: inline const sql::DependenyTableStore &get_dependency_table() const { return dependency_tables_; } int init_dependency_table_store(int64_t dependency_table_cnt) { return dependency_tables_.init(dependency_table_cnt); } inline sql::DependenyTableStore &get_dependency_table() { return dependency_tables_; } - int set_params_info(const ParamStore ¶ms); + int set_params_info(const ParamStore ¶ms, bool is_anonymous = false); const common::Ob2DArray &get_params_info() const { return params_info_; }