[CP] fix duplicate definition not recognized bug

This commit is contained in:
obdev
2022-11-03 00:06:01 +00:00
committed by wangzelin.wzl
parent 7e5730a2f3
commit c32d7e433b
2 changed files with 12 additions and 2 deletions

View File

@ -1200,6 +1200,10 @@ int ObPLBlockNS::check_dup_symbol(const ObString &name, const ObPLDataType &type
is_dup = true;
ObPLVar *pl_var = const_cast<ObPLVar *>(symbol_table_->get_symbol(symbols_.at(i)));
pl_var->set_dup_declare(is_dup);
if (pl_var->is_referenced()) {
ret = OB_ERR_DECL_MORE_THAN_ONCE;
LOG_USER_ERROR(OB_ERR_DECL_MORE_THAN_ONCE, name.length(), name.ptr());
}
}
} else { /*do nothing*/ }
}
@ -2371,11 +2375,13 @@ int ObPLBlockNS::resolve_symbol(const ObString &var_name,
&& OB_INVALID_INDEX == var_idx
&& OB_INVALID_INDEX == parent_id
&& i < get_symbols().count(); ++i) {
const ObPLVar *pl_var = symbol_table_->get_symbol(get_symbols().at(i));
ObPLVar *pl_var = const_cast<ObPLVar *>(symbol_table_->get_symbol(get_symbols().at(i)));
if (OB_ISNULL(pl_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("PL var ns is null", K(i), K(get_symbols().at(i)), K(ret));
} else if (ObCharset::case_compat_mode_equal(var_name, pl_var->get_name())) {
bool is_referenced = true;
pl_var->set_is_referenced(is_referenced);
if (pl_var->is_dup_declare()) {
ret = OB_ERR_DECL_MORE_THAN_ONCE;
LOG_USER_ERROR(OB_ERR_DECL_MORE_THAN_ONCE, var_name.length(), var_name.ptr());

View File

@ -121,7 +121,8 @@ public:
is_readonly_(false),
is_not_null_(false),
is_default_construct_(false),
is_formal_param_(false) {}
is_formal_param_(false),
is_referenced_(false) {}
virtual ~ObPLVar() {}
inline const common::ObString &get_name() const { return name_; }
@ -146,6 +147,8 @@ public:
int deep_copy(const ObPLVar &var, common::ObIAllocator &allocator);
inline void set_dup_declare(bool dup_declare) { is_dup_declare_ = dup_declare; }
inline bool is_dup_declare() const { return is_dup_declare_; }
inline void set_is_referenced(bool is_referenced) { is_referenced_ = is_referenced; }
inline bool is_referenced() const { return is_referenced_; }
TO_STRING_KV(K_(name),
K_(type),
@ -164,6 +167,7 @@ private:
bool is_default_construct_; //默认值是否是该变量的构造函数
bool is_formal_param_; // this is formal param of a routine
bool is_dup_declare_;
bool is_referenced_;
};
class ObPLSymbolTable