[FEAT MERGE] patch 423 sql compatible features to 432

Co-authored-by: akaError <lzg020616@163.com>
Co-authored-by: JinmaoLi <ljm.csmaster@gmail.com>
Co-authored-by: qingzhu521 <q15000557748@gmail.com>
This commit is contained in:
yinyj17
2024-05-27 11:18:00 +00:00
committed by ob-robot
parent a718b67350
commit 5ce9ef5136
208 changed files with 11028 additions and 495 deletions

View File

@ -101,6 +101,9 @@ ObExprSysContext::UserEnvParameter ObExprSysContext::userenv_parameters_[] =
{"CLIENT_INFO", eval_client_info},
{"MODULE", eval_module},
{"CLIENT_IDENTIFIER", eval_client_identifier},
{"PROXY_USER", eval_proxy_user},
{"PROXY_USERID", eval_proxy_user_id},
{"AUTHENTICATED_IDENTITY", eval_auth_identity},
};
ObExprSysContext::NLS_Lang ObExprSysContext::lang_map_[] =
{
@ -876,5 +879,80 @@ int ObExprSysContext::get_schema_guard(share::schema::ObSchemaGetterGuard &schem
return ret;
}
int ObExprSysContext::eval_proxy_user(const ObExpr &expr, ObDatum &res, const ObDatum &arg1,
const ObDatum &arg2, ObEvalCtx &ctx)
{
int ret = OB_SUCCESS;
UNUSED(arg1);
UNUSED(arg2);
const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
CK(OB_NOT_NULL(session));
if (OB_SUCC(ret)) {
const ObString &user_name = session->get_proxy_user_name();
ObString out_user_name;
ObExprStrResAlloc res_alloc(expr, ctx);
ObEvalCtx::TempAllocGuard alloc_guard(ctx);
ObIAllocator &calc_alloc = alloc_guard.get_allocator();
OZ(ObExprUtil::convert_string_collation(user_name, ObCharset::get_system_collation(),
out_user_name, expr.datum_meta_.cs_type_,
calc_alloc));
OZ(deep_copy_ob_string(res_alloc, out_user_name, out_user_name));
OX(res.set_string(out_user_name));
}
return ret;
}
int ObExprSysContext::eval_proxy_user_id(const ObExpr &expr, ObDatum &res,
const ObDatum &arg1, const ObDatum &arg2,
ObEvalCtx &ctx)
{
int ret = OB_SUCCESS;
UNUSED(arg1);
UNUSED(arg2);
const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
CK(OB_NOT_NULL(session));
if (OB_SUCC(ret)) {
uint64_t id = session->get_proxy_user_id();
char out_id[256];
sprintf(out_id, "%lu", id);
ObString out_id_str(strlen(out_id), out_id);
ObExprStrResAlloc res_alloc(expr, ctx);
ObEvalCtx::TempAllocGuard alloc_guard(ctx);
ObIAllocator &calc_alloc = alloc_guard.get_allocator();
OZ(ObExprUtil::convert_string_collation(out_id_str, ObCharset::get_system_collation(),
out_id_str, expr.datum_meta_.cs_type_,
calc_alloc));
OZ(deep_copy_ob_string(res_alloc, out_id_str, out_id_str));
OX(res.set_string(out_id_str));
}
return ret;
}
int ObExprSysContext::eval_auth_identity(const ObExpr &expr, ObDatum &res, const ObDatum &arg1,
const ObDatum &arg2, ObEvalCtx &ctx)
{
int ret = OB_SUCCESS;
UNUSED(arg1);
UNUSED(arg2);
const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
CK(OB_NOT_NULL(session));
if (OB_SUCC(ret)) {
const ObString user_name = session->get_user_name();
ObString out_user_name;
ObExprStrResAlloc res_alloc(expr, ctx);
ObEvalCtx::TempAllocGuard alloc_guard(ctx);
ObIAllocator &calc_alloc = alloc_guard.get_allocator();
OZ(ObExprUtil::convert_string_collation(user_name, ObCharset::get_system_collation(),
out_user_name, expr.datum_meta_.cs_type_,
calc_alloc));
OZ(deep_copy_ob_string(res_alloc, out_user_name, out_user_name));
OX(res.set_string(out_user_name));
}
return ret;
}
} // namespace sql
} // namespace oceanbase