有人可以解释oracle中不同用户下相同函数的不同行为吗?
我有一个名为 A 的包,A 具有函数 doSomething();
用户 x 是 A 的所有者。 用户 y 有一个同义词 testSyn 指向 xA;
以 x 身份登录并执行函数 doSomething() 返回 true 但何时 以用户 y 登录并执行 testSyn.doSomething() 等函数,它会返回 false 相同的值。
有人可以解释一下为什么会发生这种情况吗?
I have a package called A and A has function doSomething();
user x is the owner of A.
user y has a synonym testSyn which points to x.A;
Logged in as x and executed function doSomething() is returning true but When
logged in as user y and executed the function like testSyn.doSomething(), it returns false for the same value.
Could someone please explain why this happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下过程的定义。如果它类似于
PROCEDURE a AUTHID CURRENT_USER
,那么它将使用 当前用户的权限和名称解析。如果该过程使用考虑用户权限的视图(例如user_objects
),则可以解释不同的结果。评论回复: 您的区分是错误的。想象一下,您编写了一个从
user_objects
返回第一行的object_name
的过程。该过程由schema_owner
所有,并且schema_invoker
有权执行它。如果定义该过程时没有使用 AUTHID CURRENT_USER ,它将返回 schema_owner 架构中对象的对象名称。使用AUTHID CURRENT_USER
的相同过程将从schema_invoker
架构中返回对象名称。这与执行权限无关。我不知道这是问题的根源,但它是一个很好的候选者,并且很容易检查(只需查看包规范中的过程定义)。
Take a look at the procedure's definition. If it's something like
PROCEDURE a AUTHID CURRENT_USER
then it will execute with the current user's permissions and name resolution. If the procedure uses views that take user privileges into account (such asuser_objects
), that could explain the different result.Comment response: You're making the wrong distinction. Imagine that you write a procedure that returns the
object_name
of the first row fromuser_objects
. That procedure is owned byschema_owner
andschema_invoker
has permission to execute it. If the procedure is defined withoutAUTHID CURRENT_USER
, it will return an object name for an object in theschema_owner
schema. The same procedure withAUTHID CURRENT_USER
will return an object name from theschema_invoker
schema instead. This has nothing to do with execution privileges.I don't know that this is the source of your problem, but it's a good candidate and it's easy to check (just look at the procedure definition found in the package specification).
您可以执行该函数,但可能没有该函数引用的所有对象的访问权限。对于初学者,我会尝试找出您的函数访问哪些数据库对象,并尝试从 sqlplus 等工具访问这些对象以进行验证
You're able to execute that function but you might not have access rights to all the objects the function references. For starters, I'd try to figure out which DB objects your function accesses and try to access those from a tool like sqlplus to verify