patch 4.0
This commit is contained in:
@ -23,22 +23,30 @@
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprUser::ObExprUser(ObIAllocator& alloc) : ObFuncExprOperator(alloc, T_FUN_SYS_USER, N_USER, 0, NOT_ROW_DIMENSION)
|
||||
{}
|
||||
|
||||
ObExprUser::ObExprUser(ObIAllocator &alloc)
|
||||
: ObFuncExprOperator(alloc, T_FUN_SYS_USER, N_USER, 0, NOT_ROW_DIMENSION)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprUser::~ObExprUser()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprUser::calc_result_type0(ObExprResType& type, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprUser::calc_result_type0(ObExprResType &type,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
if (share::is_oracle_mode()) {
|
||||
// FIXME: This function returns a VARCHAR2 value in oracle mode.
|
||||
if (lib::is_oracle_mode()) {
|
||||
// FIXME @linshen: This function returns a VARCHAR2 value in oracle mode.
|
||||
// https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/USER.html#GUID-AD0B927B-EFD4-4246-89B4-2D55AB3AF531
|
||||
// `Oracle Database compares values of this function with blank-padded comparison semantics.`
|
||||
// 这个比较行为是 char 的比较行为, 由于 OB 目前比较行为是跟类型关联的, 没有单独的变量控制, 所以这里返回 char.
|
||||
type.set_char();
|
||||
// DEFAULT for oracle
|
||||
type.set_collation_type(CS_TYPE_UTF8MB4_BIN);
|
||||
@ -47,39 +55,19 @@ int ObExprUser::calc_result_type0(ObExprResType& type, ObExprTypeCtx& type_ctx)
|
||||
type.set_default_collation_type();
|
||||
}
|
||||
type.set_collation_level(CS_LEVEL_SYSCONST);
|
||||
type.set_length(static_cast<ObLength>((OB_MAX_HOST_NAME_LENGTH + OB_MAX_USER_NAME_LENGTH + 1)));
|
||||
const ObLengthSemantics default_length_semantics =
|
||||
(OB_NOT_NULL(type_ctx.get_session()) ? type_ctx.get_session()->get_actual_nls_length_semantics() : LS_BYTE);
|
||||
type.set_length(static_cast<ObLength>((OB_MAX_HOST_NAME_LENGTH
|
||||
+ OB_MAX_USER_NAME_LENGTH + 1)));
|
||||
const ObLengthSemantics default_length_semantics = (OB_NOT_NULL(type_ctx.get_session()) ? type_ctx.get_session()->get_actual_nls_length_semantics() : LS_BYTE);
|
||||
type.set_length_semantics(default_length_semantics);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExprUser::calc_result0(ObObj& result, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObSQLSessionInfo* session_info = NULL;
|
||||
if (OB_ISNULL(session_info = expr_ctx.my_session_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session info is null", K(ret));
|
||||
} else {
|
||||
if (share::is_oracle_mode()) {
|
||||
const ObString session_user = session_info->get_user_name();
|
||||
result.set_char(session_user);
|
||||
result.set_collation(result_type_);
|
||||
} else {
|
||||
const ObString session_user = session_info->get_user_at_client_ip();
|
||||
result.set_varchar(session_user);
|
||||
result.set_collation(result_type_);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprUser::eval_user(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
int ObExprUser::eval_user(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObDatum &expr_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(expr);
|
||||
const ObBasicSessionInfo* session_info = NULL;
|
||||
const ObBasicSessionInfo *session_info = NULL;
|
||||
if (OB_ISNULL(session_info = ctx.exec_ctx_.get_my_session())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session info is null", K(ret));
|
||||
@ -93,12 +81,13 @@ int ObExprUser::eval_user(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datu
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprUser::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprUser::cg_expr(ObExprCGCtx &op_cg_ctx, const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
UNUSED(raw_expr);
|
||||
UNUSED(op_cg_ctx);
|
||||
rt_expr.eval_func_ = ObExprUser::eval_user;
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}/* ns sql*/
|
||||
}/* ns oceanbase */
|
||||
|
||||
Reference in New Issue
Block a user