MYSQL兼容性 创建函数存储过程指定用户

This commit is contained in:
liuyongzhen
2022-06-17 11:45:07 +08:00
parent b410c30342
commit 652ed08bc4
19 changed files with 1142 additions and 46 deletions

View File

@ -1432,9 +1432,26 @@ static void init_fcache(
{
AclResult aclresult;
MemoryContext oldcontext;
Form_pg_proc procStruct;
HeapTuple procTup;
Oid definer = GetUserId();
if (u_sess->attr.attr_sql.sql_compatibility == B_FORMAT)
{
/* Get the function's pg_proc entry */
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(foid));
if (!HeapTupleIsValid(procTup)) {
ereport(ERROR, (errmodule(MOD_EXECUTOR), errcode(ERRCODE_CACHE_LOOKUP_FAILED),
errmsg("cache lookup failed for function %u", foid)));
}
procStruct = (Form_pg_proc)GETSTRUCT(procTup);
if (procStruct->prosecdef)
definer = procStruct->proowner;
ReleaseSysCache(procTup);
}
/* Check permission to call function */
aclresult = pg_proc_aclcheck(foid, GetUserId(), ACL_EXECUTE);
aclresult = pg_proc_aclcheck(foid, definer, ACL_EXECUTE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_PROC, get_func_name(foid));