patch 4.0
This commit is contained in:
@ -10,47 +10,61 @@
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SQL_ENG
|
||||
#include "sql/engine/expr/ob_expr_version.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "share/system_variable/ob_sys_var_class_type.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprVersion::ObExprVersion(ObIAllocator& alloc) : ObStringExprOperator(alloc, T_FUN_SYS_VERSION, N_VERSION, 0)
|
||||
{}
|
||||
|
||||
ObExprVersion::ObExprVersion(ObIAllocator &alloc)
|
||||
: ObStringExprOperator(alloc, T_FUN_SYS_VERSION, N_VERSION, 0)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprVersion::~ObExprVersion()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprVersion::calc_result_type0(ObExprResType& type, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprVersion::calc_result_type0(ObExprResType &type, ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
type.set_varchar();
|
||||
type.set_length(static_cast<common::ObLength>(strlen(PACKAGE_VERSION_INFO)));
|
||||
type.set_length(static_cast<common::ObLength>(OB_MAX_SYS_VAR_VAL_LENGTH));
|
||||
type.set_default_collation_type();
|
||||
type.set_collation_level(CS_LEVEL_SYSCONST);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExprVersion::calc_result0(ObObj& result, ObExprCtx& expr_ctx) const
|
||||
int ObExprVersion::eval_version(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObDatum &expr_datum)
|
||||
{
|
||||
UNUSED(expr_ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("session is null", K(ret));
|
||||
} else {
|
||||
ObString version;
|
||||
if (OB_FAIL(session->get_sys_variable(share::SYS_VAR_VERSION, version))) {
|
||||
LOG_WARN("fail to get version", K(ret));
|
||||
} else {
|
||||
expr_datum.set_string(version);
|
||||
}
|
||||
}
|
||||
|
||||
result.set_varchar(common::ObString(PACKAGE_VERSION_INFO));
|
||||
result.set_collation(result_type_);
|
||||
return OB_SUCCESS;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprVersion::eval_version(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
{
|
||||
UNUSED(expr);
|
||||
UNUSED(ctx);
|
||||
expr_datum.set_string(common::ObString(PACKAGE_VERSION_INFO));
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExprVersion::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprVersion::cg_expr(ObExprCGCtx &op_cg_ctx, const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
UNUSED(raw_expr);
|
||||
UNUSED(op_cg_ctx);
|
||||
@ -58,5 +72,5 @@ int ObExprVersion::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, Ob
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}/* ns sql*/
|
||||
}/* ns oceanbase */
|
||||
|
||||
Reference in New Issue
Block a user