patch 4.0
This commit is contained in:
@ -17,18 +17,24 @@
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
using namespace oceanbase::common;
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprTimestampNvl::ObExprTimestampNvl(ObIAllocator& alloc)
|
||||
ObExprTimestampNvl::ObExprTimestampNvl(ObIAllocator &alloc)
|
||||
: ObStringExprOperator(alloc, T_FUN_SYS_TIMESTAMP_NVL, N_TIMESTAMP_NVL, 2)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
ObExprTimestampNvl::~ObExprTimestampNvl()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprTimestampNvl::calc_result_type2(
|
||||
ObExprResType& type, ObExprResType& type1, ObExprResType& type2, common::ObExprTypeCtx& type_ctx) const
|
||||
int ObExprTimestampNvl::calc_result_type2(ObExprResType &type,
|
||||
ObExprResType &type1,
|
||||
ObExprResType &type2,
|
||||
common::ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(type_ctx);
|
||||
@ -42,37 +48,14 @@ int ObExprTimestampNvl::calc_result_type2(
|
||||
type.set_collation_level(type1.get_collation_level());
|
||||
type.set_collation_type(type1.get_collation_type());
|
||||
|
||||
const ObSQLSessionInfo* session = static_cast<const ObSQLSessionInfo*>(type_ctx.get_session());
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("session is null", K(ret));
|
||||
} else if (session->use_static_typing_engine()) {
|
||||
type1.set_calc_meta(type.get_obj_meta());
|
||||
type2.set_calc_meta(type.get_obj_meta());
|
||||
}
|
||||
type1.set_calc_meta(type.get_obj_meta());
|
||||
type2.set_calc_meta(type.get_obj_meta());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprTimestampNvl::calc_result2(ObObj& result, const ObObj& obj1, const ObObj& obj2, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (obj1.is_null()) {
|
||||
result = obj2;
|
||||
} else {
|
||||
result = obj1;
|
||||
}
|
||||
|
||||
if (false == result.is_null()) {
|
||||
ObObjType res_type = get_result_type().get_type();
|
||||
EXPR_DEFINE_CAST_CTX(expr_ctx, expr_ctx.cast_mode_);
|
||||
if (OB_FAIL(ObObjCaster::to_type(res_type, cast_ctx, result, result))) {
|
||||
LOG_WARN("convert result to timestamp failed", K(res_type), K(result), K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprTimestampNvl::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprTimestampNvl::cg_expr(ObExprCGCtx &op_cg_ctx,
|
||||
const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
UNUSED(op_cg_ctx);
|
||||
UNUSED(raw_expr);
|
||||
@ -80,7 +63,8 @@ int ObExprTimestampNvl::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_exp
|
||||
if (rt_expr.arg_cnt_ != 2) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("timestampnvl expr should have two params", K(ret), K(rt_expr.arg_cnt_));
|
||||
} else if (OB_ISNULL(rt_expr.args_) || OB_ISNULL(rt_expr.args_[0]) || OB_ISNULL(rt_expr.args_[1])) {
|
||||
} else if (OB_ISNULL(rt_expr.args_) || OB_ISNULL(rt_expr.args_[0])
|
||||
|| OB_ISNULL(rt_expr.args_[1])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("children of timestampnvl expr is null", K(ret), K(rt_expr.args_));
|
||||
} else {
|
||||
@ -89,18 +73,19 @@ int ObExprTimestampNvl::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_exp
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprTimestampNvl::calc_timestampnvl(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
int ObExprTimestampNvl::calc_timestampnvl(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObDatum &expr_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* param_datum1 = NULL;
|
||||
ObDatum* param_datum2 = NULL;
|
||||
ObDatum *param_datum1 = NULL;
|
||||
ObDatum *param_datum2 = NULL;
|
||||
bool oracle_mode = is_oracle_mode();
|
||||
if (OB_FAIL(expr.eval_param_value(ctx, param_datum1, param_datum2))) {
|
||||
LOG_WARN("eval param value failed", K(ret));
|
||||
} else if (param_datum1->is_null()) {
|
||||
if (param_datum2->is_null()) {
|
||||
expr_datum.set_null();
|
||||
} else if (oracle_mode) {
|
||||
} else if (oracle_mode){
|
||||
expr_datum.set_otimestamp_tiny(param_datum2->get_otimestamp_tiny());
|
||||
} else {
|
||||
expr_datum.set_timestamp(param_datum2->get_timestamp());
|
||||
@ -113,5 +98,5 @@ int ObExprTimestampNvl::calc_timestampnvl(const ObExpr& expr, ObEvalCtx& ctx, Ob
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user