[CP] [to #2024082700104281249]fix bugs, nvl and nvl2 add support udt type
This commit is contained in:
@ -1506,6 +1506,55 @@ case type: { \
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObPLDataType::datum_is_null(ObDatum* param, bool is_udt_type, bool &is_null)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
OV(OB_NOT_NULL(param), OB_ERR_UNEXPECTED);
|
||||||
|
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
// do nothing
|
||||||
|
} else if (!is_udt_type) {
|
||||||
|
is_null = param->is_null();
|
||||||
|
} else if (param->is_null() || param->extend_obj_->is_null()) {
|
||||||
|
is_null = true;
|
||||||
|
} else {
|
||||||
|
uint64_t ext = param->extend_obj_->get_ext();
|
||||||
|
switch (param->extend_obj_->get_meta().get_extend_type()) {
|
||||||
|
#ifdef OB_BUILD_ORACLE_PL
|
||||||
|
case pl::PL_NESTED_TABLE_TYPE:
|
||||||
|
case pl::PL_ASSOCIATIVE_ARRAY_TYPE:
|
||||||
|
case pl::PL_VARRAY_TYPE: {
|
||||||
|
pl::ObPLCollection *collection = reinterpret_cast<pl::ObPLCollection*>(ext);
|
||||||
|
is_null = OB_ISNULL(collection) ? true : collection->is_collection_null();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case pl::PL_OPAQUE_TYPE: {
|
||||||
|
pl::ObPLOpaque *opaque = reinterpret_cast<pl::ObPLOpaque *>(ext);
|
||||||
|
is_null = OB_ISNULL(opaque) ? true : opaque->is_invalid();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case pl::PL_CURSOR_TYPE:
|
||||||
|
case pl::PL_REF_CURSOR_TYPE: {
|
||||||
|
is_null = param->extend_obj_->get_ext() == 0;
|
||||||
|
} break;
|
||||||
|
#endif
|
||||||
|
case pl::PL_RECORD_TYPE: {
|
||||||
|
pl::ObPLRecord *rec = reinterpret_cast<pl::ObPLRecord *>(ext);
|
||||||
|
is_null = rec->is_null();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
ret = OB_NOT_SUPPORTED;
|
||||||
|
LOG_WARN("check complex value is null not supported", K(ret), K(param->extend_obj_));
|
||||||
|
LOG_USER_ERROR(OB_NOT_SUPPORTED, "check complex is null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ObObjAccessIdx::ObObjAccessIdx(const ObPLDataType &elem_type,
|
ObObjAccessIdx::ObObjAccessIdx(const ObPLDataType &elem_type,
|
||||||
AccessType access_type,
|
AccessType access_type,
|
||||||
const common::ObString &var_name,
|
const common::ObString &var_name,
|
||||||
|
@ -604,6 +604,8 @@ public:
|
|||||||
share::schema::ObRoutineInfo &routine_info);
|
share::schema::ObRoutineInfo &routine_info);
|
||||||
static int deep_copy_pl_type(ObIAllocator &allocator, const ObPLDataType &src, ObPLDataType *&dst);
|
static int deep_copy_pl_type(ObIAllocator &allocator, const ObPLDataType &src, ObPLDataType *&dst);
|
||||||
|
|
||||||
|
static int datum_is_null(ObDatum* param, bool is_udt_type, bool &is_null);
|
||||||
|
|
||||||
DECLARE_TO_STRING;
|
DECLARE_TO_STRING;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -101,43 +101,10 @@ int ObExprIs::calc_collection_is_null(const ObExpr &expr, ObEvalCtx &ctx, ObDatu
|
|||||||
LOG_WARN("evaluate parameter failed", K(ret));
|
LOG_WARN("evaluate parameter failed", K(ret));
|
||||||
} else {
|
} else {
|
||||||
bool v = false;
|
bool v = false;
|
||||||
if (param->is_null() || param->extend_obj_->is_null()) {
|
if (OB_FAIL(pl::ObPLDataType::datum_is_null(param, true, v))) {
|
||||||
v = true;
|
LOG_WARN("check complex value is null not supported", K(ret), K(param->extend_obj_));
|
||||||
} else {
|
} else {
|
||||||
uint64_t ext = param->extend_obj_->get_ext();
|
OX(expr_datum.set_int32(v));
|
||||||
switch (param->extend_obj_->get_meta().get_extend_type()) {
|
|
||||||
#ifdef OB_BUILD_ORACLE_PL
|
|
||||||
case pl::PL_NESTED_TABLE_TYPE:
|
|
||||||
case pl::PL_ASSOCIATIVE_ARRAY_TYPE:
|
|
||||||
case pl::PL_VARRAY_TYPE: {
|
|
||||||
pl::ObPLCollection *collection = reinterpret_cast<pl::ObPLCollection*>(ext);
|
|
||||||
v = OB_ISNULL(collection) ? true : collection->is_collection_null();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case pl::PL_OPAQUE_TYPE: {
|
|
||||||
pl::ObPLOpaque *opaque = reinterpret_cast<pl::ObPLOpaque *>(ext);
|
|
||||||
v = OB_ISNULL(opaque) ? true : opaque->is_invalid();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case pl::PL_CURSOR_TYPE:
|
|
||||||
case pl::PL_REF_CURSOR_TYPE: {
|
|
||||||
v = param->extend_obj_->get_ext() == 0;
|
|
||||||
} break;
|
|
||||||
#endif
|
|
||||||
case pl::PL_RECORD_TYPE: {
|
|
||||||
pl::ObPLRecord *rec = reinterpret_cast<pl::ObPLRecord *>(ext);
|
|
||||||
v = rec->is_null();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
ret = OB_NOT_SUPPORTED;
|
|
||||||
LOG_WARN("check complex value is null not supported", K(ret), K(param->extend_obj_));
|
|
||||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "check complex is null");
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
expr_datum.set_int32(v);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -383,10 +383,14 @@ int ObExprNvlUtil::calc_nvl_expr(const ObExpr &expr, ObEvalCtx &ctx,
|
|||||||
// nvl(arg0, arg1)
|
// nvl(arg0, arg1)
|
||||||
ObDatum *arg0 = NULL;
|
ObDatum *arg0 = NULL;
|
||||||
ObDatum *arg1 = NULL;
|
ObDatum *arg1 = NULL;
|
||||||
|
bool is_udt_type = lib::is_oracle_mode() && expr.args_[0]->obj_meta_.is_ext();
|
||||||
|
bool v = false;
|
||||||
|
|
||||||
if (OB_FAIL(expr.eval_param_value(ctx, arg0, arg1))) {
|
if (OB_FAIL(expr.eval_param_value(ctx, arg0, arg1))) {
|
||||||
LOG_WARN("eval args failed", K(ret));
|
LOG_WARN("eval args failed", K(ret));
|
||||||
} else if (!(arg0->is_null())) {
|
} else if (OB_FAIL(pl::ObPLDataType::datum_is_null(arg0, is_udt_type, v))) {
|
||||||
|
LOG_WARN("check complex value is null not support");
|
||||||
|
} else if (!v) {
|
||||||
res_datum.set_datum(*arg0);
|
res_datum.set_datum(*arg0);
|
||||||
} else {
|
} else {
|
||||||
res_datum.set_datum(*arg1);
|
res_datum.set_datum(*arg1);
|
||||||
@ -404,6 +408,8 @@ int ObExprNvlUtil::calc_nvl_expr_batch(const ObExpr &expr,
|
|||||||
ObBitVector &eval_flags = expr.get_evaluated_flags(ctx);
|
ObBitVector &eval_flags = expr.get_evaluated_flags(ctx);
|
||||||
ObDatumVector args0;
|
ObDatumVector args0;
|
||||||
ObDatumVector args1;
|
ObDatumVector args1;
|
||||||
|
bool is_udt_type = lib::is_oracle_mode() && expr.args_[0]->obj_meta_.is_ext();
|
||||||
|
bool v = false;
|
||||||
if (OB_FAIL(expr.eval_batch_param_value(ctx, skip, batch_size, args0,
|
if (OB_FAIL(expr.eval_batch_param_value(ctx, skip, batch_size, args0,
|
||||||
args1))) {
|
args1))) {
|
||||||
LOG_WARN("eval batch args failed", K(ret));
|
LOG_WARN("eval batch args failed", K(ret));
|
||||||
@ -415,7 +421,9 @@ int ObExprNvlUtil::calc_nvl_expr_batch(const ObExpr &expr,
|
|||||||
eval_flags.set(i);
|
eval_flags.set(i);
|
||||||
ObDatum *arg0 = args0.at(i);
|
ObDatum *arg0 = args0.at(i);
|
||||||
ObDatum *arg1 = args1.at(i);
|
ObDatum *arg1 = args1.at(i);
|
||||||
if (!(arg0->is_null())) {
|
if (OB_FAIL(pl::ObPLDataType::datum_is_null(arg0, is_udt_type, v))) {
|
||||||
|
LOG_WARN("check complex value is null not support");
|
||||||
|
} else if (!v) {
|
||||||
results[i].set_datum(*arg0);
|
results[i].set_datum(*arg0);
|
||||||
} else {
|
} else {
|
||||||
results[i].set_datum(*arg1);
|
results[i].set_datum(*arg1);
|
||||||
@ -434,10 +442,14 @@ int ObExprNvlUtil::calc_nvl_expr2(const ObExpr &expr, ObEvalCtx &ctx,
|
|||||||
ObDatum *arg0 = NULL;
|
ObDatum *arg0 = NULL;
|
||||||
ObDatum *arg1 = NULL;
|
ObDatum *arg1 = NULL;
|
||||||
ObDatum *arg2 = NULL;
|
ObDatum *arg2 = NULL;
|
||||||
|
bool is_udt_type = lib::is_oracle_mode() && expr.args_[0]->obj_meta_.is_ext();
|
||||||
|
bool v = false;
|
||||||
|
|
||||||
if (OB_FAIL(expr.eval_param_value(ctx, arg0, arg1, arg2))) {
|
if (OB_FAIL(expr.eval_param_value(ctx, arg0, arg1, arg2))) {
|
||||||
LOG_WARN("eval args failed", K(ret));
|
LOG_WARN("eval args failed", K(ret));
|
||||||
} else if (!(arg0->is_null())) {
|
} else if (OB_FAIL(pl::ObPLDataType::datum_is_null(arg0, is_udt_type, v))) {
|
||||||
|
LOG_WARN("check complex value is null not support");
|
||||||
|
} else if (!v) {
|
||||||
res_datum.set_datum(*arg1);
|
res_datum.set_datum(*arg1);
|
||||||
} else {
|
} else {
|
||||||
res_datum.set_datum(*arg2);
|
res_datum.set_datum(*arg2);
|
||||||
|
@ -52,6 +52,8 @@ int ObExprNvl2Oracle::calc_nvl2_oracle_expr_batch(const ObExpr &expr,
|
|||||||
ObDatumVector args0;
|
ObDatumVector args0;
|
||||||
ObDatumVector args1;
|
ObDatumVector args1;
|
||||||
ObDatumVector args2;
|
ObDatumVector args2;
|
||||||
|
bool is_udt_type = lib::is_oracle_mode() && expr.args_[0]->obj_meta_.is_ext();
|
||||||
|
bool v = false;
|
||||||
if (OB_FAIL(expr.eval_batch_param_value(ctx, skip, batch_size, args0,
|
if (OB_FAIL(expr.eval_batch_param_value(ctx, skip, batch_size, args0,
|
||||||
args1, args2))) {
|
args1, args2))) {
|
||||||
LOG_WARN("eval batch args failed", K(ret));
|
LOG_WARN("eval batch args failed", K(ret));
|
||||||
@ -64,7 +66,9 @@ int ObExprNvl2Oracle::calc_nvl2_oracle_expr_batch(const ObExpr &expr,
|
|||||||
ObDatum *arg0 = args0.at(i);
|
ObDatum *arg0 = args0.at(i);
|
||||||
ObDatum *arg1 = args1.at(i);
|
ObDatum *arg1 = args1.at(i);
|
||||||
ObDatum *arg2 = args2.at(i);
|
ObDatum *arg2 = args2.at(i);
|
||||||
if (!(arg0->is_null())) {
|
if (OB_FAIL(pl::ObPLDataType::datum_is_null(arg0, is_udt_type, v))) {
|
||||||
|
LOG_WARN("check complex value is null not support");
|
||||||
|
} else if (!v) {
|
||||||
results[i].set_datum(*arg1);
|
results[i].set_datum(*arg1);
|
||||||
} else {
|
} else {
|
||||||
results[i].set_datum(*arg2);
|
results[i].set_datum(*arg2);
|
||||||
|
Reference in New Issue
Block a user