fix copy shared exec param bug
This commit is contained in:
		| @ -1322,7 +1322,11 @@ int ObQueryRefRawExpr::inner_deep_copy(ObIRawExprCopier &copier) | |||||||
|   for (int64_t i = 0; OB_SUCC(ret) && i < exec_params_.count(); ++i) { |   for (int64_t i = 0; OB_SUCC(ret) && i < exec_params_.count(); ++i) { | ||||||
|     ObRawExpr *exec_param = exec_params_.at(i); |     ObRawExpr *exec_param = exec_params_.at(i); | ||||||
|     ObRawExpr *new_expr = NULL; |     ObRawExpr *new_expr = NULL; | ||||||
|     if (OB_FAIL(copier.do_copy_expr(exec_param, new_expr))) { |     if (OB_FAIL(copier.find_in_copy_context(exec_param, new_expr))) { | ||||||
|  |       LOG_WARN("failed to find in copy context", K(ret)); | ||||||
|  |     } else if (new_expr != NULL) { | ||||||
|  |       exec_params_.at(i) = static_cast<ObExecParamRawExpr *>(new_expr); | ||||||
|  |     } else if (OB_FAIL(copier.do_copy_expr(exec_param, new_expr))) { | ||||||
|       LOG_WARN("failed to copy exec param", K(ret)); |       LOG_WARN("failed to copy exec param", K(ret)); | ||||||
|     } else if (OB_ISNULL(new_expr) || |     } else if (OB_ISNULL(new_expr) || | ||||||
|                OB_UNLIKELY(!new_expr->is_exec_param_expr())) { |                OB_UNLIKELY(!new_expr->is_exec_param_expr())) { | ||||||
|  | |||||||
| @ -61,6 +61,14 @@ int ObPLExprCopier::check_need_copy(const ObRawExpr *old_expr, | |||||||
|   return OB_SUCCESS; |   return OB_SUCCESS; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int ObPLExprCopier::find_in_copy_context(const ObRawExpr *old_expr, | ||||||
|  |                                          ObRawExpr *&new_expr) | ||||||
|  | { | ||||||
|  |   UNUSED(old_expr); | ||||||
|  |   new_expr = NULL; | ||||||
|  |   return OB_SUCCESS; | ||||||
|  | } | ||||||
|  |  | ||||||
| int ObPLExprCopier::do_copy_expr(const ObRawExpr *old_expr, | int ObPLExprCopier::do_copy_expr(const ObRawExpr *old_expr, | ||||||
|                                  ObRawExpr *&new_expr) |                                  ObRawExpr *&new_expr) | ||||||
| { | { | ||||||
| @ -86,6 +94,23 @@ int ObPLExprCopier::do_copy_expr(const ObRawExpr *old_expr, | |||||||
|  |  | ||||||
| int ObRawExprCopier::check_need_copy(const ObRawExpr *old_expr, | int ObRawExprCopier::check_need_copy(const ObRawExpr *old_expr, | ||||||
|                                      ObRawExpr *&new_expr) |                                      ObRawExpr *&new_expr) | ||||||
|  | { | ||||||
|  |   int ret = OB_SUCCESS; | ||||||
|  |   new_expr = NULL; | ||||||
|  |   if (OB_FAIL(find_in_copy_context(old_expr, new_expr))) { | ||||||
|  |     LOG_WARN("faild to find in copy context", K(ret)); | ||||||
|  |   } else if (OB_ISNULL(new_expr) && | ||||||
|  |              old_expr->is_exec_param_expr() && | ||||||
|  |              !static_cast<const ObExecParamRawExpr *>(old_expr)->is_onetime()) { | ||||||
|  |     // TODO link.zt skip the copy of exec param expr | ||||||
|  |     // let the query ref raw expr to copy the expr | ||||||
|  |     // to be improved | ||||||
|  |     new_expr = const_cast<ObRawExpr *>(old_expr); | ||||||
|  |   } | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int ObRawExprCopier::find_in_copy_context(const ObRawExpr *old_expr, ObRawExpr *&new_expr) | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|   int tmp = OB_SUCCESS; |   int tmp = OB_SUCCESS; | ||||||
| @ -106,14 +131,6 @@ int ObRawExprCopier::check_need_copy(const ObRawExpr *old_expr, | |||||||
|     ret = tmp; |     ret = tmp; | ||||||
|     LOG_WARN("get expr from hash map failed", K(ret)); |     LOG_WARN("get expr from hash map failed", K(ret)); | ||||||
|   } |   } | ||||||
|   if (OB_SUCC(ret) && OB_ISNULL(new_expr) && |  | ||||||
|       old_expr->is_exec_param_expr() && |  | ||||||
|       !static_cast<const ObExecParamRawExpr *>(old_expr)->is_onetime()) { |  | ||||||
|     // TODO link.zt skip the copy of exec param expr |  | ||||||
|     // let the query ref raw expr to copy the expr |  | ||||||
|     // to be improved |  | ||||||
|     new_expr = const_cast<ObRawExpr *>(old_expr); |  | ||||||
|   } |  | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -26,6 +26,9 @@ public: | |||||||
|  |  | ||||||
|   virtual int check_need_copy(const ObRawExpr *old_expr, ObRawExpr *&new_expr) = 0; |   virtual int check_need_copy(const ObRawExpr *old_expr, ObRawExpr *&new_expr) = 0; | ||||||
|  |  | ||||||
|  |   // check if old expr has already been copied, and if it has been copied, takes it directly. | ||||||
|  |   virtual int find_in_copy_context(const ObRawExpr *old_expr, ObRawExpr *&new_expr) = 0; | ||||||
|  |  | ||||||
|   virtual int do_copy_expr(const ObRawExpr *old_expr, ObRawExpr *&new_expr) = 0; |   virtual int do_copy_expr(const ObRawExpr *old_expr, ObRawExpr *&new_expr) = 0; | ||||||
|  |  | ||||||
|   virtual bool deep_copy_attributes() const { return false; } |   virtual bool deep_copy_attributes() const { return false; } | ||||||
| @ -76,6 +79,8 @@ public: | |||||||
|   int do_copy_expr(const ObRawExpr *old_expr, ObRawExpr *&new_expr) override; |   int do_copy_expr(const ObRawExpr *old_expr, ObRawExpr *&new_expr) override; | ||||||
|  |  | ||||||
|   bool deep_copy_attributes() const { return true; } |   bool deep_copy_attributes() const { return true; } | ||||||
|  |  | ||||||
|  |   int find_in_copy_context(const ObRawExpr *old_expr, ObRawExpr *&new_expr) override; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -154,6 +159,8 @@ public: | |||||||
|  |  | ||||||
|   int get_copied_exprs(ObIArray<std::pair<ObRawExpr *, ObRawExpr *>> &from_to_exprs); |   int get_copied_exprs(ObIArray<std::pair<ObRawExpr *, ObRawExpr *>> &from_to_exprs); | ||||||
|  |  | ||||||
|  |   int find_in_copy_context(const ObRawExpr *old_expr, ObRawExpr *&new_expr) override; | ||||||
|  |  | ||||||
| private: | private: | ||||||
|  |  | ||||||
|   int add_expr(const ObRawExpr *from, const ObRawExpr *to); |   int add_expr(const ObRawExpr *from, const ObRawExpr *to); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev