Skip to content

Commit f4fd5ee

Browse files
yahondaclaude
andcommitted
Fix cross-schema test to use a separate connection for the second user
Grant create type, create procedure, and unlimited tablespace to the arunit user. Connect as arunit to create the type and grant execute, avoiding ORA-01749 (cannot grant to yourself). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0e03913 commit f4fd5ee

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

spec/plsql/procedure_spec.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,9 +2391,15 @@ def new_candidate(status)
23912391
plsql.connect! CONNECTION_PARAMS
23922392
@second_user = DATABASE_USERS_AND_PASSWORDS[1][0].upcase
23932393

2394-
# Create type in second schema and grant to current schema
2395-
plsql.execute "CREATE OR REPLACE TYPE #{@second_user}.t_cross_schema_record AS OBJECT (id NUMBER, name VARCHAR2(50))"
2396-
plsql.execute "GRANT EXECUTE ON #{@second_user}.t_cross_schema_record TO #{DATABASE_USERS_AND_PASSWORDS[0][0]}"
2394+
# Connect as second user to create type and grant execute to primary user
2395+
plsql2 = PLSQL::Schema.new
2396+
plsql2.connect! CONNECTION_PARAMS.merge(
2397+
username: DATABASE_USERS_AND_PASSWORDS[1][0],
2398+
password: DATABASE_USERS_AND_PASSWORDS[1][1]
2399+
)
2400+
plsql2.execute "CREATE OR REPLACE TYPE t_cross_schema_record AS OBJECT (id NUMBER, name VARCHAR2(50))"
2401+
plsql2.execute "GRANT EXECUTE ON t_cross_schema_record TO #{DATABASE_USERS_AND_PASSWORDS[0][0]}"
2402+
plsql2.logoff
23972403

23982404
plsql.execute <<-SQL
23992405
CREATE OR REPLACE FUNCTION test_cross_schema_fn(p_rec #{@second_user}.t_cross_schema_record)
@@ -2407,7 +2413,13 @@ def new_candidate(status)
24072413

24082414
after(:all) do
24092415
plsql.execute "DROP FUNCTION test_cross_schema_fn" rescue nil
2410-
plsql.execute "DROP TYPE #{@second_user}.t_cross_schema_record" rescue nil
2416+
plsql2 = PLSQL::Schema.new
2417+
plsql2.connect! CONNECTION_PARAMS.merge(
2418+
username: DATABASE_USERS_AND_PASSWORDS[1][0],
2419+
password: DATABASE_USERS_AND_PASSWORDS[1][1]
2420+
)
2421+
plsql2.execute "DROP TYPE t_cross_schema_record" rescue nil
2422+
plsql2.logoff
24112423
plsql.logoff
24122424
end
24132425

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
create user arunit identified by arunit;
22
grant create session to arunit;
3+
grant create type to arunit;
4+
grant create procedure to arunit;
5+
grant unlimited tablespace to arunit;

0 commit comments

Comments
 (0)