patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -16,22 +16,31 @@
#include "lib/ob_name_def.h"
#include "sql/session/ob_sql_session_info.h"
namespace oceanbase {
namespace oceanbase
{
using namespace common;
namespace sql {
namespace sql
{
ObExprTimeToUsec::ObExprTimeToUsec(ObIAllocator& alloc)
ObExprTimeToUsec::ObExprTimeToUsec(ObIAllocator &alloc)
: ObFuncExprOperator(alloc, T_FUN_SYS_TIME_TO_USEC, N_TIME_TO_USEC, 1, NOT_ROW_DIMENSION)
{}
{
}
ObExprTimeToUsec::~ObExprTimeToUsec()
{}
{
}
int ObExprTimeToUsec::calc_result_type1(ObExprResType& type, ObExprResType& date, common::ObExprTypeCtx& type_ctx) const
int ObExprTimeToUsec::calc_result_type1(ObExprResType &type,
ObExprResType &date,
common::ObExprTypeCtx &type_ctx) const
{
UNUSED(type_ctx);
int ret = common::OB_SUCCESS;
if (OB_UNLIKELY(!date.is_varchar() && !date.is_temporal_type() && !date.is_null())) {
if (OB_UNLIKELY(!date.is_varchar()
&& !date.is_temporal_type()
&& !date.is_null())) {
ret = common::OB_INVALID_ARGUMENT_FOR_TIME_TO_USEC;
LOG_WARN("invalid type", K(date.get_type()));
@ -39,30 +48,17 @@ int ObExprTimeToUsec::calc_result_type1(ObExprResType& type, ObExprResType& date
type.set_int();
type.set_precision(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].precision_);
type.set_scale(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].scale_);
// set calc type
//set calc type
date.set_calc_type(ObTimestampType);
}
return ret;
}
int ObExprTimeToUsec::calc_result1(common::ObObj& result, const common::ObObj& date, ObExprCtx& expr_ctx) const
int calc_time_to_usec_expr(const ObExpr &expr, ObEvalCtx &ctx,
ObDatum &res_datum)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(date.is_null())) {
result.set_null();
} else {
TYPE_CHECK(date, ObTimestampType);
int64_t ts_val = date.get_timestamp();
result.set_int(ts_val);
}
UNUSED(expr_ctx);
return ret;
}
int calc_time_to_usec_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
{
int ret = OB_SUCCESS;
ObDatum* arg_datum = NULL;
ObDatum *arg_datum = NULL;
if (OB_FAIL(expr.args_[0]->eval(ctx, arg_datum))) {
LOG_WARN("eval arg failed", K(ret));
} else if (arg_datum->is_null()) {
@ -73,7 +69,8 @@ int calc_time_to_usec_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datu
return ret;
}
int ObExprTimeToUsec::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
int ObExprTimeToUsec::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(expr_cg_ctx);
@ -82,5 +79,5 @@ int ObExprTimeToUsec::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_exp
return ret;
}
} // namespace sql
} // namespace oceanbase
}
}