I'm curious about this. What happens if the DBA (or a grantor) revokes a user's (grantee's) privileges while that user (grantee) has an ongoing transaction that needs those privileges (obviously, when the user (grantee) issued his transaction, he had those privileges).
A trivial scenario to make this more concrete: user A grants user B privileges to insert data into a table (say Table1) in his (user A's) schema. User B goes ahead and issues a transaction that makes a lot of insertions. While the insertions are going on, user A revokes B's insert privileges. Does:
-
1. user B's transaction fail midway with an automatic rollback performed on Table1 (I'm assuming this is an example of an "abnormally terminated" process -- one of the conditions for a rollback; is it?)? If yes, how is data integrity handled? For example, does Oracle guarantee that the insertions won't be halted in the middle of a row?
2. user B's transaction complete before his privileges are taken away (meaning he can't make any more insertions after this)?
Logically, I'd guess it'd be 2 but I can't find any information to confirm this in Oracle docs.
Thanks.
EDIT: Adding some PL/SQL code I wrote to test this (I just cobbled this together for testing this scenario. I don't know PL/SQL so please correct me if I'm wrong).
/* Start by testing select privileges */ set serveroutput on; declare v_emp HR.tempemp%rowtype; begin dbms_output.enable(300000); for count_var in 1..200000 loop -- loop a large number of times, and BEFORE the loop exits, -- revoke the permissions manually from the grantor's session select * into v_emp from HR.tempemp where employee_id = 100; dbms_output.put_line(count_var||' '||v_emp.employee_id); -- print count_var so we know which iteration we're in end loop; end; /* Now test insert privileges */ set serveroutput on; begin dbms_output.enable(300000); for count_var in 1..20000000 loop -- loop a large number of times, and BEFORE the loop exits, -- revoke the permissions manually from the grantor's session insert into HR.tempemp values(100); dbms_output.put_line(count_var); -- print count_var so we know which iteration we're in end loop; end;
Observations:
-
1. The
for
loop falls through as soon as the revoke takes effect. So, as Dave said, privileges are checked each time a statement is executed.2. For the insert part of the test, once the
for
loop fails midway, none of the insertions (not even the ones for which the for
went through are visible in the grantee's session).