fix lrpad return null when param is empty string && fix nanvl return null when 1st param is binary double
This commit is contained in:

committed by
ob-robot

parent
03fdde5756
commit
d38916c6f0
@ -653,7 +653,7 @@ int ObExprBaseLRpad::calc_mysql_inner(const LRpadType pad_type,
|
||||
result_size = ObCharset::charpos(cs_type, str_text.ptr(), str_text.length(), int_len);
|
||||
res.set_string(ObString(result_size, str_text.ptr()));
|
||||
} else if (str_pad.length() == 0) {
|
||||
res.set_null();
|
||||
res.set_string(ObString::make_empty_string());
|
||||
} else if (OB_FAIL(get_padding_info_mysql(cs_type, str_text, int_len, str_pad,
|
||||
max_result_size, repeat_count, prefix_size, result_size))) {
|
||||
LOG_WARN("Failed to get padding info", K(ret), K(str_text), K(int_len),
|
||||
|
@ -438,9 +438,7 @@ int ObExprNaNvl::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
|
||||
int ObExprNaNvl::eval_nanvl_util(const ObExpr &expr, ObDatum &expr_datum, ObDatum *param1, ObDatum *param2, bool &ret_bool)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (param1->is_null() || param2->is_null()) {
|
||||
expr_datum.set_null();
|
||||
} else if (expr.args_[0]->datum_meta_.type_ != ObFloatType
|
||||
if (expr.args_[0]->datum_meta_.type_ != ObFloatType
|
||||
&& expr.args_[0]->datum_meta_.type_ != ObDoubleType) {
|
||||
expr_datum.set_datum(*param1);
|
||||
} else {
|
||||
@ -470,7 +468,7 @@ int ObExprNaNvl::eval_nanvl(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_da
|
||||
expr_datum.set_null();
|
||||
} else if (OB_FAIL(expr.args_[1]->eval(ctx, param2))) {
|
||||
LOG_WARN("eval second param failed", K(ret));
|
||||
} else if (param1->is_null() || param2->is_null()) {
|
||||
} else if (param1->is_null() || (param2->is_null() && ObDoubleType != expr.args_[1]->datum_meta_.get_type())) {
|
||||
expr_datum.set_null();
|
||||
} else {
|
||||
if (OB_FAIL(eval_nanvl_util(expr, expr_datum, param1, param2, ret_bool))){
|
||||
@ -520,7 +518,9 @@ int ObExprNaNvl::eval_nanvl_batch(const ObExpr &expr,
|
||||
param1 = &expr.args_[0]->locate_expr_datum(ctx, i);
|
||||
param2 = &expr.args_[1]->locate_expr_datum(ctx, i);
|
||||
eval_flags.set(i);
|
||||
if (OB_FAIL(eval_nanvl_util(expr, results[i], param1, param2, ret_bool))){
|
||||
if (param1->is_null() || (param2->is_null() && ObDoubleType != expr.args_[1]->datum_meta_.get_type())) {
|
||||
results[i].set_null();
|
||||
} else if (OB_FAIL(eval_nanvl_util(expr, results[i], param1, param2, ret_bool))){
|
||||
LOG_WARN("eval_nanvl unexpect error", K(ret));
|
||||
} else {
|
||||
// do nothing
|
||||
|
@ -35,7 +35,8 @@ ObMergeSetOp::ObMergeSetOp(ObExecContext &exec_ctx, const ObOpSpec &spec, ObOpIn
|
||||
last_row_(alloc_),
|
||||
cmp_(),
|
||||
need_skip_init_row_(false),
|
||||
last_row_idx_(-1)
|
||||
last_row_idx_(-1),
|
||||
use_last_row_(false)
|
||||
{}
|
||||
|
||||
int ObMergeSetOp::inner_open()
|
||||
|
@ -6124,7 +6124,7 @@ select lpad('a', 5, '');
|
||||
+------------------+
|
||||
| lpad('a', 5, '') |
|
||||
+------------------+
|
||||
| NULL |
|
||||
| |
|
||||
+------------------+
|
||||
select lpad(NULL, 5, 'a');
|
||||
+--------------------+
|
||||
|
Reference in New Issue
Block a user