patch 4.0
This commit is contained in:
@ -17,25 +17,30 @@
|
||||
#include <string.h>
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "share/object/ob_obj_cast.h"
|
||||
#include "sql/parser/ob_item_type.h"
|
||||
#include "objit/common/ob_item_type.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/expr/ob_expr_util.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprBitLength::ObExprBitLength(ObIAllocator& alloc)
|
||||
ObExprBitLength::ObExprBitLength(ObIAllocator &alloc)
|
||||
: ObFuncExprOperator(alloc, T_FUN_SYS_BIT_LENGTH, N_BIT_LENGTH, 1, NOT_ROW_DIMENSION)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
ObExprBitLength::~ObExprBitLength()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprBitLength::calc_result_type1(ObExprResType& type, ObExprResType& text, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprBitLength::calc_result_type1(ObExprResType &type, ObExprResType &text,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObSQLSessionInfo* session = type_ctx.get_session();
|
||||
const ObSQLSessionInfo *session = type_ctx.get_session();
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
@ -49,22 +54,7 @@ int ObExprBitLength::calc_result_type1(ObExprResType& type, ObExprResType& text,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprBitLength::calc_result1(ObObj& result, const ObObj& text, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
UNUSED(expr_ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
ObObjTypeClass type_class = ob_obj_type_class(text.get_type());
|
||||
if (!ob_is_castable_type_class(type_class)) {
|
||||
result.set_null();
|
||||
} else {
|
||||
TYPE_CHECK(text, ObVarcharType);
|
||||
ObString m_text = text.get_string();
|
||||
result.set_int(static_cast<int64_t>(m_text.length() * 8));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprBitLength::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprBitLength::cg_expr(ObExprCGCtx &op_cg_ctx, const ObRawExpr &raw_expr, ObExpr &rt_expr) const
|
||||
{
|
||||
UNUSED(op_cg_ctx);
|
||||
UNUSED(raw_expr);
|
||||
@ -89,7 +79,7 @@ int ObExprBitLength::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprBitLength::calc_null(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
int ObExprBitLength::calc_null(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
|
||||
{
|
||||
UNUSED(expr);
|
||||
UNUSED(ctx);
|
||||
@ -97,10 +87,10 @@ int ObExprBitLength::calc_null(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExprBitLength::calc_bit_length(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
int ObExprBitLength::calc_bit_length(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* text_datum = NULL;
|
||||
ObDatum *text_datum = NULL;
|
||||
if (OB_FAIL(expr.args_[0]->eval(ctx, text_datum))) {
|
||||
LOG_WARN("eval param value failed", K(ret));
|
||||
} else if (text_datum->is_null()) {
|
||||
@ -111,5 +101,5 @@ int ObExprBitLength::calc_bit_length(const ObExpr& expr, ObEvalCtx& ctx, ObDatum
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user