to issue<50010749>:fix memory leak about forall stmt & searray

This commit is contained in:
hanr881
2023-05-30 06:41:06 +00:00
committed by ob-robot
parent 54f01814ec
commit 0993ee7420
3 changed files with 41 additions and 9 deletions

View File

@ -3794,6 +3794,13 @@ int ObPLStmt::set_label_idx(int64_t idx)
return ret;
}
ObPLCompileUnitAST::~ObPLCompileUnitAST()
{
if (NULL != body_) {
body_->~ObPLStmtBlock();
}
}
void ObPLCompileUnitAST::process_default_compile_flag()
{
if (compile_flag_.has_flag()) {

View File

@ -1541,7 +1541,7 @@ public:
analyze_flag_(0)
{}
virtual ~ObPLCompileUnitAST() {}
virtual ~ObPLCompileUnitAST();
inline UnitType get_type() const { return type_; }
inline void set_type(UnitType type) { type_ = type; }
@ -1910,7 +1910,13 @@ public:
in_handler_scope_(false),
is_contain_goto_stmt_(false),
is_autonomous_block_(false) {}
virtual ~ObPLStmtBlock() {}
virtual ~ObPLStmtBlock() {
for (int64_t i = 0; i < stmts_.count(); ++i) {
if (NULL != stmts_.at(i)) {
stmts_.at(i)->~ObPLStmt();
}
}
}
int accept(ObPLStmtVisitor &visitor) const;
virtual int64_t get_child_size() const { return stmts_.count(); }
@ -2030,7 +2036,14 @@ class ObPLIfStmt : public ObPLStmt
{
public:
ObPLIfStmt() : ObPLStmt(PL_IF), cond_(OB_INVALID_INDEX), then_(NULL), else_(NULL) {}
virtual ~ObPLIfStmt() {}
virtual ~ObPLIfStmt() {
if (NULL != then_) {
then_->~ObPLStmtBlock();
}
if (NULL != else_) {
else_->~ObPLStmtBlock();
}
}
int accept(ObPLStmtVisitor &visitor) const;
virtual int64_t get_child_size() const { return NULL == else_ ? 1 : 2; }
@ -2058,7 +2071,11 @@ public:
: ObPLStmt(PL_CASE),
case_expr_idx_(OB_INVALID_INDEX), case_var_idx_(OB_INVALID_INDEX),
when_(allocator), else_(nullptr) {}
virtual ~ObPLCaseStmt() {}
virtual ~ObPLCaseStmt() {
if (NULL != else_) {
else_->~ObPLStmtBlock();
}
}
virtual int64_t get_child_size() const override { return when_.count() + 1; }
virtual const ObPLStmt *get_child_stmt(int64_t i) const override {
@ -2207,7 +2224,11 @@ class ObPLLoop : public ObPLStmt
{
public:
ObPLLoop(ObPLStmtType type) : ObPLStmt(type), body_(NULL) {}
virtual ~ObPLLoop() {}
virtual ~ObPLLoop() {
if (NULL != body_) {
body_->~ObPLStmtBlock();
}
}
virtual int64_t get_child_size() const { return 1; }
virtual const ObPLStmt *get_child_stmt(int64_t i) const { return 0 == i ? body_ : NULL; }
@ -2467,7 +2488,10 @@ public:
inline const hash::ObHashMap<int64_t, int64_t>& get_tab_to_subtab_map() const { return tab_to_subtab_; }
inline hash::ObHashMap<int64_t, int64_t>& get_tab_to_subtab_map() { return tab_to_subtab_; }
inline int create_tab_to_subtab() { return tab_to_subtab_.create(16, ObModIds::OB_PL_TEMP); }
inline int create_tab_to_subtab()
{
return tab_to_subtab_.create(16, ObModIds::OB_PL_TEMP, ObModIds::OB_HASH_NODE, MTL_ID());
}
int accept(ObPLStmtVisitor &visitor) const;

View File

@ -2764,10 +2764,11 @@ int ObObjAccessRawExpr::add_access_indexs(const ObIArray<pl::ObObjAccessIdx> &ac
LOG_WARN("store access index failed", K(ret));
}
}
if (OB_SUCC(ret) && OB_FAIL(orig_access_indexs_.push_back(access_idx))) {
LOG_WARN("failed to assign access indexs", K(ret), K(access_idx));
}
if (OB_SUCC(ret) && OB_FAIL(orig_access_indexs_.assign(access_idxs))) {
LOG_WARN("failed to assign access indexs", K(ret), K(access_idxs));
}
return ret;
}