Skip to content

Commit 979c788

Browse files
yahondaclaude
andcommitted
Grant execute on dbms_lock as SYS
Since Oracle 12c, SYSTEM cannot grant EXECUTE on SYS-owned packages like DBMS_LOCK; only SYS (or a user with GRANT ANY OBJECT PRIVILEGE) can. The grant in spec/support/unlock_and_setup_hr_user.sql therefore fails on gvenzl/oracle-free with grant execute on dbms_lock to hr * ERROR at line 1: ORA-01031: insufficient privileges sqlplus does not propagate the error, so the failure has been silently logged in CI. The hr user happens not to need DBMS_LOCK on modern Oracle (the threaded-cursor spec in spec/plsql/schema_spec.rb uses DBMS_SESSION.sleep on 18c+ and only falls back to DBMS_LOCK.sleep on older versions), so the grant only matters for the 11g matrix. Move the grant into a separate `as sysdba` sqlplus session in ci/setup_accounts.sh so it succeeds on both gvenzl/oracle-xe:11 and gvenzl/oracle-free, and add `whenever sqlerror exit failure` so any future grant failure surfaces instead of being hidden. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d096dd5 commit 979c788

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

ci/setup_accounts.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ sqlplus system/${DATABASE_SYS_PASSWORD}@${DATABASE_NAME} <<SQL
77
@@spec/support/create_arunit_user.sql
88
exit
99
SQL
10+
11+
# `grant execute on dbms_lock` requires SYS in 12c+; SYSTEM no longer has the
12+
# privilege. Run it through a separate `as sysdba` session so the same script
13+
# works on both gvenzl/oracle-xe:11 and gvenzl/oracle-free.
14+
sqlplus -s sys/${DATABASE_SYS_PASSWORD}@${DATABASE_NAME} as sysdba <<SQL
15+
whenever sqlerror exit failure
16+
grant execute on dbms_lock to hr;
17+
exit
18+
SQL
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
create user hr identified by hr;
22
alter user hr identified by hr account unlock;
33
grant dba to hr;
4-
grant execute on dbms_lock to hr;

0 commit comments

Comments
 (0)