Copy datums for dynamic const exprs in remote stage
This commit is contained in:
		| @ -26,7 +26,7 @@ namespace oceanbase | ||||
| { | ||||
| namespace sql | ||||
| { | ||||
| OB_SERIALIZE_MEMBER((ObDirectReceiveSpec, ObOpSpec)); | ||||
| OB_SERIALIZE_MEMBER((ObDirectReceiveSpec, ObOpSpec), dynamic_const_exprs_); | ||||
|  | ||||
| ObDirectReceiveOp::ObDirectReceiveOp(ObExecContext &exec_ctx, | ||||
|                                      const ObOpSpec &spec, | ||||
| @ -318,8 +318,24 @@ int ObDirectReceiveOp::get_next_row_from_cur_scanner() | ||||
|     ret = OB_ERR_UNEXPECTED; | ||||
|   } else { | ||||
|     for (uint32_t i = 0; i < tmp_sr->cnt_; ++i) { | ||||
|       MY_SPEC.output_.at(i)->locate_expr_datum(eval_ctx_) = tmp_sr->cells()[i]; | ||||
|       MY_SPEC.output_.at(i)->set_evaluated_projected(eval_ctx_); | ||||
|       if (MY_SPEC.output_.at(i)->is_static_const_) { | ||||
|         continue; | ||||
|       } else { | ||||
|         MY_SPEC.output_.at(i)->locate_expr_datum(eval_ctx_) = tmp_sr->cells()[i]; | ||||
|         MY_SPEC.output_.at(i)->set_evaluated_projected(eval_ctx_); | ||||
|       } | ||||
|     } | ||||
|     // deep copy dynamic const expr datum | ||||
|     clear_dynamic_const_parent_flag(); | ||||
|     if (MY_SPEC.dynamic_const_exprs_.count() > 0) { | ||||
|       for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.dynamic_const_exprs_.count(); i++) { | ||||
|         ObExpr *expr = MY_SPEC.dynamic_const_exprs_.at(i); | ||||
|         if (0 == expr->res_buf_off_) { | ||||
|           // for compat 4.0, do nothing | ||||
|         } else if (OB_FAIL(expr->deep_copy_self_datum(eval_ctx_))) { | ||||
|           LOG_WARN("fail to deep copy datum", K(ret), K(eval_ctx_), K(*expr)); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     LOG_DEBUG("direct receive next row", "row", ROWEXPR2STR(eval_ctx_, MY_SPEC.output_)); | ||||
|   } | ||||
|  | ||||
| @ -26,9 +26,9 @@ class ObDirectReceiveSpec : public ObReceiveSpec | ||||
|   OB_UNIS_VERSION_V(1); | ||||
| public: | ||||
|   ObDirectReceiveSpec(common::ObIAllocator &alloc, const ObPhyOperatorType type) | ||||
|   : ObReceiveSpec(alloc, type) | ||||
|   : ObReceiveSpec(alloc, type), dynamic_const_exprs_(alloc) | ||||
|   {} | ||||
|  | ||||
|   ExprFixedArray dynamic_const_exprs_; // const expr which contain dynamic param | ||||
|   virtual ~ObDirectReceiveSpec() {}; | ||||
| }; | ||||
|  | ||||
| @ -49,6 +49,18 @@ private: | ||||
|   int setup_next_scanner(); | ||||
|   int get_next_row_from_cur_scanner(); | ||||
|   int update_user_var(); | ||||
|   // clear dynamic const expr parent evaluate flag, because when dynmaic param datum | ||||
|   // changed, if we don't clear dynamic const expr parent expr evaluate flag, the | ||||
|   // parent expr datum ptr may point to the last dynamic param datum memory which | ||||
|   // is invalid now | ||||
|   OB_INLINE void clear_dynamic_const_parent_flag() | ||||
|   { | ||||
|     const ObDirectReceiveSpec &spec = static_cast<const ObDirectReceiveSpec &>(spec_); | ||||
|     for (int64_t i = 0; i < spec.dynamic_const_exprs_.count(); i++) { | ||||
|       ObDynamicParamSetter::clear_parent_evaluated_flag( | ||||
|                           eval_ctx_, *spec.dynamic_const_exprs_.at(i)); | ||||
|     } | ||||
|   } | ||||
| private: | ||||
|   common::ObScanner *scanner_; | ||||
|   ObChunkDatumStore::Iterator scanner_iter_; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev