Shallow copy variable-length values for implicit aggr expr
This commit is contained in:
		@ -156,14 +156,14 @@ public:
 | 
				
			|||||||
    if (OB_LIKELY(not_nulls.at(agg_col_id) && agg_cell_len != INT32_MAX)) {
 | 
					    if (OB_LIKELY(not_nulls.at(agg_col_id) && agg_cell_len != INT32_MAX)) {
 | 
				
			||||||
      const char *payload = (const char *)(*reinterpret_cast<const int64_t *>(agg_cell));
 | 
					      const char *payload = (const char *)(*reinterpret_cast<const int64_t *>(agg_cell));
 | 
				
			||||||
      char *res_buf = nullptr;
 | 
					      char *res_buf = nullptr;
 | 
				
			||||||
      if (need_extend_buf<AggCalcType<vec_tc>>::value) {
 | 
					      if (is_discrete_vec(vec_tc)) {
 | 
				
			||||||
        res_buf = agg_expr.get_str_res_mem(ctx, agg_cell_len);
 | 
					        // implicit aggr expr may be shared between operators and its
 | 
				
			||||||
        if (OB_ISNULL(res_buf)) {
 | 
					        // data is shallow copied for variable-length types while do backup/restore operations.
 | 
				
			||||||
          ret = OB_ALLOCATE_MEMORY_FAILED;
 | 
					        // Hence child op's data is unexpected modified if deep copy happened here.
 | 
				
			||||||
          SQL_LOG(WARN, "allocate memory failed", K(ret));
 | 
					        // see details in `bug/55372943`
 | 
				
			||||||
        } else {
 | 
					        //
 | 
				
			||||||
          CellWriter<AggCalcType<vec_tc>>::set(payload, agg_cell_len, res_vec, output_idx, res_buf);
 | 
					        // note that variable-length types include ObNumberType.
 | 
				
			||||||
        }
 | 
					        res_vec->set_payload_shallow(output_idx, payload, agg_cell_len);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        CellWriter<AggCalcType<vec_tc>>::set(payload, agg_cell_len, res_vec, output_idx, res_buf);
 | 
					        CellWriter<AggCalcType<vec_tc>>::set(payload, agg_cell_len, res_vec, output_idx, res_buf);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user