Grant execute on dbms_lock as SYS#280
Merged
yahonda merged 1 commit intorsim:masterfrom May 5, 2026
Merged
Conversation
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. DBMS_SESSION.sleep was introduced in 18c specifically
as a relocation of DBMS_LOCK.sleep so that callers no longer need
EXECUTE on DBMS_LOCK just to pause execution. On 11.2 there is no
equivalent in DBMS_SESSION (and no clean alternative outside of
DBMS_PIPE.RECEIVE_MESSAGE-on-a-nonexistent-pipe hacks), so the grant
remains necessary 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>
979c788 to
476bdd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SYSTEMcannot grantEXECUTEon SYS-owned packages likeDBMS_LOCK; onlySYS(or a user withGRANT ANY OBJECT PRIVILEGE) can. The grant inspec/support/unlock_and_setup_hr_user.sqltherefore fails ongvenzl/oracle-freewithORA-01031: insufficient privileges.sqlplusdoes not propagate the error, so the failure has been silently logged in CI runs (see for example run 25378360238 / job 74419513314).hruser happens not to needDBMS_LOCKon modern Oracle: the threaded-cursor spec inspec/plsql/schema_spec.rb:255usesDBMS_SESSION.sleepon 18c+ and only falls back toDBMS_LOCK.sleepon older versions, so the grant only matters for the 11g matrix.as sysdbasqlplussession inci/setup_accounts.shso it succeeds on bothgvenzl/oracle-xe:11andgvenzl/oracle-free, and addwhenever sqlerror exit failureso any future grant failure surfaces instead of being hidden.Test plan
.github/workflows/test.yml(gvenzl/oracle-free 23c) passes with noORA-01031line in the "Create database user" step..github/workflows/test_11g.yml(gvenzl/oracle-xe:11) passes — confirms the as-sysdba grant works on 11g and the threaded-cursor spec that usesDBMS_LOCK.sleepstill has access..github/workflows/devcontainer.ymlpasses end-to-end.🤖 Generated with Claude Code