Merge pull request from GitHub pr175
This commit is contained in:
		
				
					committed by
					
						
						wangzelin.wzl
					
				
			
			
				
	
			
			
			
						parent
						
							99f2835249
						
					
				
				
					commit
					58f7fb882e
				
			@ -346,6 +346,7 @@ ob_set_subtarget(ob_sql engine
 | 
			
		||||
  engine/expr/ob_expr_regexp_like.cpp
 | 
			
		||||
  engine/expr/ob_expr_repeat.cpp
 | 
			
		||||
  engine/expr/ob_expr_replace.cpp
 | 
			
		||||
  engine/expr/ob_expr_export_set.cpp
 | 
			
		||||
  engine/expr/ob_expr_translate.cpp
 | 
			
		||||
  engine/expr/ob_expr_pi.cpp
 | 
			
		||||
  engine/expr/ob_expr_pi.h
 | 
			
		||||
 | 
			
		||||
@ -234,9 +234,12 @@ int ObStaticEngineCG::postorder_generate_op(
 | 
			
		||||
  }
 | 
			
		||||
  if (is_subplan) {
 | 
			
		||||
    cur_op_exprs_.reset();
 | 
			
		||||
    cur_op_exprs_.assign(tmp_cur_op_exprs);
 | 
			
		||||
    cur_op_self_produced_exprs_.reset();
 | 
			
		||||
    cur_op_self_produced_exprs_.assign(tmp_cur_op_self_produced_exprs);
 | 
			
		||||
    if (OB_FAIL(cur_op_exprs_.assign(tmp_cur_op_exprs))) {
 | 
			
		||||
      LOG_WARN("assign exprs failed", K(ret)); 
 | 
			
		||||
    } else if (OB_FAIL(cur_op_self_produced_exprs_.assign(tmp_cur_op_self_produced_exprs))) {
 | 
			
		||||
      LOG_WARN("assign exprs failed", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
 | 
			
		||||
@ -69,6 +69,7 @@
 | 
			
		||||
#include "ob_expr_regexp_replace.h"
 | 
			
		||||
#include "ob_expr_regexp_substr.h"
 | 
			
		||||
#include "ob_expr_repeat.h"
 | 
			
		||||
#include "ob_expr_export_set.h"
 | 
			
		||||
#include "ob_expr_replace.h"
 | 
			
		||||
#include "ob_expr_func_dump.h"
 | 
			
		||||
#include "ob_expr_func_part_hash.h"
 | 
			
		||||
@ -663,6 +664,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
 | 
			
		||||
    ObExprTimeFormat::calc_time_format,               /* 407 */
 | 
			
		||||
    ObExprMakedate::calc_makedate,                    /* 408 */
 | 
			
		||||
    ObExprPeriodAdd::calc_periodadd,                  /* 409 */
 | 
			
		||||
    ObExprExportSet::eval_export_set,                 /* 401 */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
REG_SER_FUNC_ARRAY(OB_SFA_SQL_EXPR_EVAL, g_expr_eval_functions, ARRAYSIZEOF(g_expr_eval_functions));
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										268
									
								
								src/sql/engine/expr/ob_expr_export_set.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										268
									
								
								src/sql/engine/expr/ob_expr_export_set.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,268 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright (c) 2021 OceanBase
 | 
			
		||||
 * OceanBase CE is licensed under Mulan PubL v2.
 | 
			
		||||
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 | 
			
		||||
 * You may obtain a copy of Mulan PubL v2 at:
 | 
			
		||||
 *          http://license.coscl.org.cn/MulanPubL-2.0
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 | 
			
		||||
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 | 
			
		||||
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 | 
			
		||||
 * See the Mulan PubL v2 for more details.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define USING_LOG_PREFIX SQL_ENG
 | 
			
		||||
 | 
			
		||||
#include "sql/engine/expr/ob_expr_export_set.h"
 | 
			
		||||
#include "lib/oblog/ob_log.h"
 | 
			
		||||
#include "share/object/ob_obj_cast.h"
 | 
			
		||||
#include "sql/session/ob_sql_session_info.h"
 | 
			
		||||
using namespace oceanbase::common;
 | 
			
		||||
namespace oceanbase {
 | 
			
		||||
namespace sql {
 | 
			
		||||
 | 
			
		||||
ObExprExportSet::ObExprExportSet(ObIAllocator& alloc)
 | 
			
		||||
    : ObStringExprOperator(alloc, T_FUN_SYS_EXPORT_SET, N_EXPORT_SET, MORE_THAN_TWO)
 | 
			
		||||
{
 | 
			
		||||
  need_charset_convert_ = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ObExprExportSet::~ObExprExportSet()
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::calc_result_typeN(ObExprResType& type, ObExprResType* types_array,
 | 
			
		||||
    int64_t param_num, common::ObExprTypeCtx& type_ctx) const
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (3 != param_num && 4 != param_num && 5 != param_num) {
 | 
			
		||||
    ret = OB_INVALID_ARGUMENT;
 | 
			
		||||
    LOG_WARN("Export_Set() should have three or four or five arguments", K(ret), K(param_num));
 | 
			
		||||
  } else if (OB_ISNULL(types_array) || OB_ISNULL(type_ctx.get_session())) {
 | 
			
		||||
    ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
    LOG_WARN("unexpected error. types_array or session null", K(ret), KP(types_array),
 | 
			
		||||
        KP(type_ctx.get_session()));
 | 
			
		||||
  } else {
 | 
			
		||||
    // deduce length
 | 
			
		||||
    // Maximum occurrences of on and of in result
 | 
			
		||||
    const uint64_t MAX_BIT_NUM = 64;
 | 
			
		||||
    // Maximum occurrences of sep in result
 | 
			
		||||
    const uint64_t MAX_SEP_NUM = 63;
 | 
			
		||||
    const int64_t on_len = types_array[1].get_length();
 | 
			
		||||
    const int64_t off_len = types_array[2].get_length();
 | 
			
		||||
    int64_t sep_len = 1;
 | 
			
		||||
    int64_t str_num = 2;
 | 
			
		||||
    const uint64_t max_len = std::max(on_len, off_len);
 | 
			
		||||
    // when bits exceed uint_max or int_min, ob is not compatible to mysql.
 | 
			
		||||
    types_array[0].set_calc_type(common::ObBitType); 
 | 
			
		||||
    types_array[1].set_calc_type(common::ObVarcharType);
 | 
			
		||||
    types_array[2].set_calc_type(common::ObVarcharType);
 | 
			
		||||
    if (3 < param_num) {
 | 
			
		||||
      sep_len = types_array[3].get_length();
 | 
			
		||||
      str_num = 3;
 | 
			
		||||
      types_array[3].set_calc_type(common::ObVarcharType);
 | 
			
		||||
      if (4 < param_num) {
 | 
			
		||||
        types_array[4].set_calc_type(common::ObIntType);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    common::ObLength len = static_cast<common::ObLength>(MAX_BIT_NUM * max_len + 
 | 
			
		||||
        MAX_SEP_NUM * sep_len);
 | 
			
		||||
    type.set_length(len);
 | 
			
		||||
    type.set_varchar();
 | 
			
		||||
    // set collation_type for string type
 | 
			
		||||
    OZ(ObExprOperator::aggregate_charsets_for_string_result_with_comparison(
 | 
			
		||||
        type, &types_array[1], str_num, type_ctx.get_coll_type()));
 | 
			
		||||
    for (int64_t i = 1; OB_SUCC(ret) && i <= str_num; ++i) {
 | 
			
		||||
      types_array[i].set_calc_meta(type);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::calc_resultN(ObObj& result, const ObObj* objs_array, int64_t param_num,
 | 
			
		||||
    ObExprCtx& expr_ctx) const
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (OB_ISNULL(expr_ctx.calc_buf_)) {
 | 
			
		||||
    ret = OB_NOT_INIT;
 | 
			
		||||
    LOG_WARN("calc_buf of expr_ctx is NULL", K(ret));
 | 
			
		||||
  } else if (3 == param_num) {
 | 
			
		||||
    ObObj tmp_n_bits;
 | 
			
		||||
    ObObj tmp_sep;
 | 
			
		||||
    tmp_n_bits.set_int(64);
 | 
			
		||||
    tmp_sep.set_string(common::ObVarcharType, ObCharsetUtils::get_const_str(
 | 
			
		||||
        objs_array[1].get_collation_type(), ','));
 | 
			
		||||
    if (OB_FAIL(calc_export_set(result, objs_array[0], objs_array[1], objs_array[2], 
 | 
			
		||||
        tmp_sep, tmp_n_bits, expr_ctx))) {
 | 
			
		||||
      LOG_WARN("calc_export_set failed", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  } else if (4 == param_num) {
 | 
			
		||||
    ObObj tmp_n_bits;
 | 
			
		||||
    tmp_n_bits.set_int(64);
 | 
			
		||||
    if (OB_FAIL(calc_export_set(result, objs_array[0], objs_array[1], objs_array[2],
 | 
			
		||||
        objs_array[3], tmp_n_bits, expr_ctx))) {
 | 
			
		||||
      LOG_WARN("calc_export_set failed", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  } else if (5 == param_num) {
 | 
			
		||||
    if (OB_FAIL(calc_export_set(result, objs_array[0], objs_array[1], objs_array[2],
 | 
			
		||||
        objs_array[3], objs_array[4], expr_ctx))) {
 | 
			
		||||
      LOG_WARN("calc_export_set failed", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::calc_export_set(ObObj& result, const ObObj& bits, const ObObj& on,
 | 
			
		||||
    const ObObj& off, const ObObj& sep, const ObObj& n_bits, ObExprCtx& expr_ctx) const
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (bits.is_null() || on.is_null() || off.is_null() || sep.is_null() || n_bits.is_null()) {
 | 
			
		||||
    result.set_null();
 | 
			
		||||
  } else if (OB_ISNULL(expr_ctx.calc_buf_)) {
 | 
			
		||||
    ret = OB_NOT_INIT;
 | 
			
		||||
    LOG_WARN("varchar buffer not init", K(ret));
 | 
			
		||||
  } else {
 | 
			
		||||
    uint64_t local_bits;
 | 
			
		||||
    ObString local_on;
 | 
			
		||||
    ObString local_off;
 | 
			
		||||
    ObString local_sep;
 | 
			
		||||
    int64_t local_n_bits;
 | 
			
		||||
    ObString res;
 | 
			
		||||
    local_on = on.get_string();
 | 
			
		||||
    local_off = off.get_string();
 | 
			
		||||
    local_sep = sep.get_string();
 | 
			
		||||
    if (OB_FAIL(bits.get_bit(local_bits))) {
 | 
			
		||||
      LOG_WARN("fail to get bit", K(ret), K(bits));
 | 
			
		||||
    } else if (OB_FAIL(n_bits.get_int(local_n_bits))) {
 | 
			
		||||
      LOG_WARN("fail to get int", K(ret), K(n_bits));
 | 
			
		||||
    } else if (OB_FAIL(calc_export_set_inner(res, local_bits, local_on, local_off,
 | 
			
		||||
        local_sep, local_n_bits, *expr_ctx.calc_buf_))) {
 | 
			
		||||
      LOG_WARN("do export set failed", K(ret));
 | 
			
		||||
    } else {
 | 
			
		||||
      result.set_string(result_type_.get_type(), res);
 | 
			
		||||
      result.set_collation(result_type_);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::calc_export_set_inner(ObString& ret_str, const uint64_t bits,
 | 
			
		||||
    const ObString& on, const ObString& off, const ObString& sep, const int64_t n_bits,
 | 
			
		||||
    ObExprStringBuf& string_buf)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (OB_UNLIKELY(n_bits == 0)) {
 | 
			
		||||
    // Return empty string
 | 
			
		||||
    ret_str.reset();
 | 
			
		||||
  } else if (OB_UNLIKELY(on.length() <= 0 && off.length() <= 0 && sep.length() <= 0)) {
 | 
			
		||||
    ret_str.reset();
 | 
			
		||||
  } else {
 | 
			
		||||
    const uint64_t MAX_BIT_NUM = 64UL;
 | 
			
		||||
    uint64_t local_n_bits = static_cast<uint64_t>(n_bits);
 | 
			
		||||
    local_n_bits = std::min(MAX_BIT_NUM, local_n_bits);
 | 
			
		||||
    const int64_t length_on = on.length();
 | 
			
		||||
    const int64_t length_off = off.length();
 | 
			
		||||
    const int64_t length_sep = sep.length();
 | 
			
		||||
    int64_t tot_length = 0;  // total length for the result.
 | 
			
		||||
    uint64_t i;
 | 
			
		||||
    const uint64_t mask = 1;
 | 
			
		||||
    //compute tot_length and save ans
 | 
			
		||||
    tot_length += (local_n_bits - 1) * length_sep;
 | 
			
		||||
    for (i = 0; i < local_n_bits; ++i) {
 | 
			
		||||
      if (bits & (mask << i)){
 | 
			
		||||
        tot_length += length_on;
 | 
			
		||||
      } else {
 | 
			
		||||
        tot_length += length_off;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // Avoid realloc
 | 
			
		||||
    if (OB_UNLIKELY(tot_length <= 0)) {
 | 
			
		||||
      // tot_length equals to 0 indicates that length_to is zero and "to" is empty string
 | 
			
		||||
      ret_str.reset();
 | 
			
		||||
    } else {
 | 
			
		||||
      char* buf = static_cast<char*>(string_buf.alloc(tot_length));
 | 
			
		||||
      if (OB_ISNULL(buf)) {
 | 
			
		||||
        ret = OB_ALLOCATE_MEMORY_FAILED;
 | 
			
		||||
        LOG_ERROR("alloc memory failed.", K(ret), K(tot_length));
 | 
			
		||||
      } else {
 | 
			
		||||
        // Core function
 | 
			
		||||
        char* tmp_buf = buf;
 | 
			
		||||
        if (local_n_bits > 0) {
 | 
			
		||||
          if (bits & mask) {
 | 
			
		||||
            MEMCPY(tmp_buf, on.ptr(), length_on);
 | 
			
		||||
            tmp_buf += length_on;
 | 
			
		||||
          } else {
 | 
			
		||||
            MEMCPY(tmp_buf, off.ptr(), length_off);
 | 
			
		||||
            tmp_buf += length_off;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        for (i = 1; i < local_n_bits; ++i) {
 | 
			
		||||
          MEMCPY(tmp_buf, sep.ptr(), length_sep);
 | 
			
		||||
          tmp_buf += length_sep;
 | 
			
		||||
          if (bits & (mask << i)) {
 | 
			
		||||
            MEMCPY(tmp_buf, on.ptr(), length_on);
 | 
			
		||||
            tmp_buf += length_on;
 | 
			
		||||
          } else {
 | 
			
		||||
            MEMCPY(tmp_buf, off.ptr(), length_off);
 | 
			
		||||
            tmp_buf += length_off;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        ret_str.assign_ptr(buf, static_cast<int32_t>(tot_length));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& rt_expr) const
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  CK(3 == rt_expr.arg_cnt_ || 4 == rt_expr.arg_cnt_ || 5 == rt_expr.arg_cnt_);
 | 
			
		||||
  rt_expr.eval_func_ = &eval_export_set;
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObExprExportSet::eval_export_set(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  ObDatum* bits = NULL;
 | 
			
		||||
  ObDatum* on = NULL;
 | 
			
		||||
  ObDatum* off = NULL;
 | 
			
		||||
  ObDatum* sep = NULL; 
 | 
			
		||||
  ObDatum* n_bits = NULL;
 | 
			
		||||
  int64_t max_size = 0;
 | 
			
		||||
  if (OB_FAIL(expr.eval_param_value(ctx, bits, on, off, sep, n_bits))) {
 | 
			
		||||
    LOG_WARN("evaluate parameters failed", K(ret));
 | 
			
		||||
  } else if (bits->is_null() || on->is_null() || off->is_null()) {
 | 
			
		||||
    expr_datum.set_null();
 | 
			
		||||
  } else if (OB_NOT_NULL(sep) && sep->is_null()) {
 | 
			
		||||
    expr_datum.set_null();
 | 
			
		||||
  } else if (OB_NOT_NULL(n_bits) && n_bits->is_null()) {
 | 
			
		||||
    expr_datum.set_null();
 | 
			
		||||
  } else {
 | 
			
		||||
    ObExprStrResAlloc expr_res_alloc(expr, ctx);
 | 
			
		||||
    ObString output;
 | 
			
		||||
    //default parm
 | 
			
		||||
    ObString sep_parm;
 | 
			
		||||
    int64_t n_bits_parm;
 | 
			
		||||
    if (OB_ISNULL(sep)) {
 | 
			
		||||
      sep_parm = ObCharsetUtils::get_const_str(expr.datum_meta_.cs_type_, ',');
 | 
			
		||||
    } else {
 | 
			
		||||
      sep_parm = sep->get_string();
 | 
			
		||||
    }
 | 
			
		||||
    if (OB_ISNULL(n_bits)) {
 | 
			
		||||
      n_bits_parm = 64;
 | 
			
		||||
    } else {
 | 
			
		||||
      n_bits_parm = n_bits->get_uint64();
 | 
			
		||||
    }
 | 
			
		||||
    if (OB_FAIL(calc_export_set_inner(output, bits->get_uint64(), on->get_string(),
 | 
			
		||||
        off->get_string(), sep_parm, n_bits_parm, expr_res_alloc))) {
 | 
			
		||||
      LOG_WARN("do export set failed", K(ret));
 | 
			
		||||
    } else {
 | 
			
		||||
      expr_datum.set_string(output);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace sql
 | 
			
		||||
}  // namespace oceanbase
 | 
			
		||||
							
								
								
									
										42
									
								
								src/sql/engine/expr/ob_expr_export_set.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/sql/engine/expr/ob_expr_export_set.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright (c) 2021 OceanBase
 | 
			
		||||
 * OceanBase CE is licensed under Mulan PubL v2.
 | 
			
		||||
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 | 
			
		||||
 * You may obtain a copy of Mulan PubL v2 at:
 | 
			
		||||
 *          http://license.coscl.org.cn/MulanPubL-2.0
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 | 
			
		||||
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 | 
			
		||||
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 | 
			
		||||
 * See the Mulan PubL v2 for more details.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_EXPORT_SET_
 | 
			
		||||
#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_EXPORT_SET_
 | 
			
		||||
 | 
			
		||||
#include "sql/engine/expr/ob_expr_operator.h"
 | 
			
		||||
 | 
			
		||||
namespace oceanbase {
 | 
			
		||||
namespace sql {
 | 
			
		||||
class ObExprExportSet : public ObStringExprOperator {
 | 
			
		||||
public:
 | 
			
		||||
  explicit ObExprExportSet(common::ObIAllocator& alloc);
 | 
			
		||||
  virtual ~ObExprExportSet();
 | 
			
		||||
  virtual int calc_result_typeN(
 | 
			
		||||
      ObExprResType& type, ObExprResType* types_array, int64_t param_num, common::ObExprTypeCtx& type_ctx) const;
 | 
			
		||||
  virtual int calc_resultN(
 | 
			
		||||
      common::ObObj& result, const common::ObObj* objs_array, int64_t param_num, common::ObExprCtx& expr_ctx) const;
 | 
			
		||||
  virtual int calc_export_set(common::ObObj& result, const common::ObObj& bits, const common::ObObj& on,
 | 
			
		||||
      const common::ObObj& off, const common::ObObj& sep, const common::ObObj& n_bits, common::ObExprCtx& expr_ctx) const;
 | 
			
		||||
  virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
 | 
			
		||||
  static int eval_export_set(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
 | 
			
		||||
private:
 | 
			
		||||
  // disallow copy
 | 
			
		||||
  DISALLOW_COPY_AND_ASSIGN(ObExprExportSet);
 | 
			
		||||
  // helper func
 | 
			
		||||
  static int calc_export_set_inner(ObString& ret_str, const uint64_t bits, const ObString& on, const ObString& off,
 | 
			
		||||
    const ObString& sep, const int64_t n_bits, ObExprStringBuf& string_buf);
 | 
			
		||||
};
 | 
			
		||||
}  // namespace sql
 | 
			
		||||
}  // namespace oceanbase
 | 
			
		||||
 | 
			
		||||
#endif  // OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_EXPORT_SET_
 | 
			
		||||
@ -4776,8 +4776,10 @@ int ObRelationalExprOperator::cg_row_cmp_expr(const int row_dimension, ObIAlloca
 | 
			
		||||
        ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
        LOG_WARN("unexpected error", K(ret));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (OB_UNLIKELY(left_row->arg_cnt_ != right_row->arg_cnt_)) {
 | 
			
		||||
      if (OB_ISNULL(right_row) || OB_ISNULL(left_row)) {
 | 
			
		||||
        ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
        LOG_WARN("right_row or left_row is null ptr", K(ret), K(right_row), K(left_row));
 | 
			
		||||
      } else if (OB_UNLIKELY(left_row->arg_cnt_ != right_row->arg_cnt_)) {
 | 
			
		||||
        ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
        LOG_WARN("unexpected row cnt", K(left_row->arg_cnt_), K(right_row->arg_cnt_));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -143,6 +143,7 @@
 | 
			
		||||
#include "sql/engine/expr/ob_expr_merging_frozen_time.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_remainder.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_repeat.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_export_set.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_replace.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_translate.h"
 | 
			
		||||
#include "sql/engine/expr/ob_expr_func_part_hash.h"
 | 
			
		||||
@ -535,6 +536,7 @@ void ObExprOperatorFactory::register_expr_operators()
 | 
			
		||||
  REG_OP(ObExprFuncCeiling);
 | 
			
		||||
  REG_OP(ObExprFuncDump);
 | 
			
		||||
  REG_OP(ObExprRepeat);
 | 
			
		||||
  REG_OP(ObExprExportSet);
 | 
			
		||||
  REG_OP(ObExprReplace);
 | 
			
		||||
  REG_OP(ObExprFuncPartOldHash);
 | 
			
		||||
  REG_OP(ObExprFuncPartHash);
 | 
			
		||||
 | 
			
		||||
@ -376,7 +376,7 @@ int ObExprRegexContext::like(const ObString& text, int64_t occurrence, bool& sub
 | 
			
		||||
  } else if (text.length() < 0 || (text.length() > 0 && OB_ISNULL(text.ptr()))) {
 | 
			
		||||
    ret = OB_INVALID_ARGUMENT;
 | 
			
		||||
    LOG_WARN("invalid param, source text is null", K(ret), K(text));
 | 
			
		||||
  } else if (reg_.re_nsub >= 0) {
 | 
			
		||||
  } else {
 | 
			
		||||
    size_t nsub = reg_.re_nsub;
 | 
			
		||||
    ob_regmatch_t pmatch[nsub + 1];
 | 
			
		||||
    int error = 0;
 | 
			
		||||
 | 
			
		||||
@ -61,8 +61,11 @@ int ObExprUid::calc_result0(ObObj& result, ObExprCtx& expr_ctx) const
 | 
			
		||||
    const uint64_t sess_uid = session_info->get_user_id();
 | 
			
		||||
    // result.set_uint64_value(sess_uid);
 | 
			
		||||
    number::ObNumber num;
 | 
			
		||||
    num.from(sess_uid, *(expr_ctx.calc_buf_));
 | 
			
		||||
    result.set_number(num);
 | 
			
		||||
    if (OB_FAIL(num.from(sess_uid, *(expr_ctx.calc_buf_)))) {
 | 
			
		||||
      LOG_WARN("convert int to number failed", K(ret), K(sess_uid));
 | 
			
		||||
    } else {
 | 
			
		||||
      result.set_number(num);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -426,6 +426,8 @@ typedef enum ObItemType {
 | 
			
		||||
  T_FUN_SYS_QUARTER = 711,
 | 
			
		||||
  T_FUN_SYS_BIT_LENGTH = 712,
 | 
			
		||||
  T_FUN_SYS_PI = 713,
 | 
			
		||||
  T_FUN_SYS_EXPORT_SET = 714,
 | 
			
		||||
  
 | 
			
		||||
  ///< @note add new mysql only function type before this line
 | 
			
		||||
  T_MYSQL_ONLY_SYS_MAX_OP = 800,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1552,6 +1552,7 @@ const char* get_type_name(int type)
 | 
			
		||||
	case T_HASH_PARTITION_LIST : return "T_HASH_PARTITION_LIST";
 | 
			
		||||
	case T_RANGE_PARTITION_LIST : return "T_RANGE_PARTITION_LIST";
 | 
			
		||||
	case T_LIST_PARTITION_LIST : return "T_LIST_PARTITION_LIST";
 | 
			
		||||
	case T_FUN_SYS_EXPORT_SET : return "T_FUN_SYS_EXPORT_SET";
 | 
			
		||||
	default:return "Unknown";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user