Tom,
I am seeing a strange problem in 10.2.0.2 database. After I drop and recreate a function (or package), its grants remain till I do an alter system flush shared_pool. I have taken the function from PL/SQL manual.
Here is an example:
Create users and role as system:create user test_ag1 identified by test default tablespace users_data;
grant create session, create table, create procedure, create trigger, create view to test_ag1;
create user test_ag2 identified by test default tablespace users_data;
grant create session to test_ag2;
create role test_ag_role;
grant test_ag_role to test_ag2;
Now connect as test_ag1 and create a function:CREATE OR REPLACE FUNCTION half_of_square(original NUMBER)
RETURN NUMBER IS
BEGIN
RETURN (original * original)/2 + (original * 4);
END half_of_square;
/
grant execute on half_of_square to test_ag_role;
Connect as test_ag2 and run the function:set
serverout on
declare
a number;
begin
a:=test_ag1.half_of_square(100);
dbms_output.put_line(a);
end;
/
SQL> /
5400
PL/SQL procedure successfully completed.
SQL>
Now connect as test_ag1 and drop the function:drop function half_of_square;
Connect as test_ag2 and verify that we cannot run the function.SQL> /
a:=test_ag1.half_of_square(100);
*
ERROR at line 4:
ORA-06550: line 4, column 4:
PLS-00201: identifier 'TEST_AG1.HALF_OF_SQUARE' must be declared
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
SQL>
Connect as test_ag1 and recreate the function but do not grant execute to anyone:CREATE OR REPLACE FUNCTION half_of_square(original NUMBER)
RETURN NUMBER IS
BEGIN
RETURN (original * original)/2 + (original * 4);
END half_of_square;
/
Function created.
SQL>
Connect as test_ag2 and try to run the function:SQL> set serverout on
SQL> declare
2 a number;
3 begin
4 a:=test_ag1.half_of_square(100);
5 dbms_output.put_line(a);
6 end;
7 /
5400
PL/SQL procedure successfully completed.
SQL>
It runs successfully even without the grant via role. On a low activity database, it will keep running till I do an alter system flush shared_pool.
Is this a bug?
Thanks