fix upper expression return empty string in oracle mode bug
This commit is contained in:
@ -622,6 +622,7 @@ int ObExpr::eval_one_datum_of_batch(ObEvalCtx &ctx, common::ObDatum *&datum) con
|
|||||||
} else {
|
} else {
|
||||||
reset_datum_ptr(frame, ctx.get_batch_size(), ctx.get_batch_idx());
|
reset_datum_ptr(frame, ctx.get_batch_size(), ctx.get_batch_idx());
|
||||||
ret = eval_func_(*this, ctx, *datum);
|
ret = eval_func_(*this, ctx, *datum);
|
||||||
|
CHECK_STRING_LENGTH((*this), (*datum));
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
ObBitVector *evaluated_flags = to_bit_vector(frame + eval_flags_off_);
|
ObBitVector *evaluated_flags = to_bit_vector(frame + eval_flags_off_);
|
||||||
evaluated_flags->set(ctx.get_batch_idx());
|
evaluated_flags->set(ctx.get_batch_idx());
|
||||||
@ -676,6 +677,16 @@ int ObExpr::do_eval_batch(ObEvalCtx &ctx,
|
|||||||
info->cnt_ = size;
|
info->cnt_ = size;
|
||||||
info->evaluated_ = true;
|
info->evaluated_ = true;
|
||||||
}
|
}
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (is_oracle_mode() && (ob_is_string_tc(datum_meta_.type_) || ob_is_raw(datum_meta_.type_))) {
|
||||||
|
ObDatum *datum = reinterpret_cast<ObDatum *>(frame + datum_off_);
|
||||||
|
for (int64_t i = 0; i < size; i++) {
|
||||||
|
if (!skip.contain(i) && 0 == datum[i].len_ && !datum[i].is_null()) {
|
||||||
|
SQL_ENG_LOG(ERROR, "unexpected datum length", KPC(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ObDatum *datum = reinterpret_cast<ObDatum *>(frame + datum_off_);
|
ObDatum *datum = reinterpret_cast<ObDatum *>(frame + datum_off_);
|
||||||
ObDatum *datum_end = datum + size;
|
ObDatum *datum_end = datum + size;
|
||||||
@ -706,6 +717,7 @@ int expr_default_eval_batch_func(const ObExpr &expr,
|
|||||||
// set current evaluate index
|
// set current evaluate index
|
||||||
batch_info_guard.set_batch_idx(i);
|
batch_info_guard.set_batch_idx(i);
|
||||||
ret = expr.eval_func_(expr, ctx, datum[i]);
|
ret = expr.eval_func_(expr, ctx, datum[i]);
|
||||||
|
CHECK_STRING_LENGTH(expr, datum[i]);
|
||||||
evaluated_flags->set(i);
|
evaluated_flags->set(i);
|
||||||
if (datum[i].is_null()) {
|
if (datum[i].is_null()) {
|
||||||
got_null = true;
|
got_null = true;
|
||||||
|
|||||||
@ -351,6 +351,18 @@ typedef common::ObFixedArray<common::ObString, common::ObIAllocator> ObStrValues
|
|||||||
#define EVAL_FUNC_ARG_DECL const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum
|
#define EVAL_FUNC_ARG_DECL const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum
|
||||||
#define EVAL_FUNC_ARG_LIST expr, ctx, expr_datum
|
#define EVAL_FUNC_ARG_LIST expr, ctx, expr_datum
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define CHECK_STRING_LENGTH(expr, datum) \
|
||||||
|
if (OB_SUCC(ret) && 0 == datum.len_ && !datum.is_null() && is_oracle_mode() &&\
|
||||||
|
(ob_is_string_tc(expr.datum_meta_.type_) || ob_is_raw(expr.datum_meta_.type_))) { \
|
||||||
|
SQL_ENG_LOG(ERROR, "unexpected datum length", K(expr)); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define CHECK_STRING_LENGTH(expr, datum)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// default evaluate batch function which call eval() for every datum of batch.
|
// default evaluate batch function which call eval() for every datum of batch.
|
||||||
extern int expr_default_eval_batch_func(BATCH_EVAL_FUNC_ARG_DECL);
|
extern int expr_default_eval_batch_func(BATCH_EVAL_FUNC_ARG_DECL);
|
||||||
|
|
||||||
@ -1016,6 +1028,7 @@ OB_INLINE int ObExpr::eval(ObEvalCtx &ctx, common::ObDatum *&datum) const
|
|||||||
datum->ptr_ = frame + res_buf_off_;
|
datum->ptr_ = frame + res_buf_off_;
|
||||||
}
|
}
|
||||||
ret = eval_func_(*this, ctx, *datum);
|
ret = eval_func_(*this, ctx, *datum);
|
||||||
|
CHECK_STRING_LENGTH((*this), (*datum));
|
||||||
if (OB_LIKELY(common::OB_SUCCESS == ret)) {
|
if (OB_LIKELY(common::OB_SUCCESS == ret)) {
|
||||||
eval_info->evaluated_ = true;
|
eval_info->evaluated_ = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -446,9 +446,14 @@ int ObExprLowerUpper::calc_common(const ObExpr &expr, ObEvalCtx &ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_UNLIKELY(is_oracle_mode() && str_result.length() == 0
|
||||||
|
&& ob_is_string_tc(expr.datum_meta_.type_))) {
|
||||||
|
expr_datum.set_null();
|
||||||
|
} else {
|
||||||
expr_datum.set_string(str_result);
|
expr_datum.set_string(str_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user