Skip to content

Grant execute on dbms_lock as SYS#280

Merged
yahonda merged 1 commit intorsim:masterfrom
yahonda:fix-dbms-lock-grant
May 5, 2026
Merged

Grant execute on dbms_lock as SYS#280
yahonda merged 1 commit intorsim:masterfrom
yahonda:fix-dbms-lock-grant

Conversation

@yahonda
Copy link
Copy Markdown
Collaborator

@yahonda yahonda commented May 5, 2026

Summary

  • 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 ORA-01031: insufficient privileges. sqlplus does not propagate the error, so the failure has been silently logged in CI runs (see for example run 25378360238 / job 74419513314).
  • The hr user happens not to need DBMS_LOCK on modern Oracle: the threaded-cursor spec in spec/plsql/schema_spec.rb:255 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.

Test plan

  • .github/workflows/test.yml (gvenzl/oracle-free 23c) passes with no ORA-01031 line 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 uses DBMS_LOCK.sleep still has access.
  • .github/workflows/devcontainer.yml passes end-to-end.

🤖 Generated with Claude Code

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>
@yahonda yahonda force-pushed the fix-dbms-lock-grant branch from 979c788 to 476bdd2 Compare May 5, 2026 13:26
@yahonda yahonda merged commit 11c4d58 into rsim:master May 5, 2026
21 checks passed
@yahonda yahonda deleted the fix-dbms-lock-grant branch May 5, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant