Skip to content

Use type_owner for cross-schema type lookups#254

Open
yahonda wants to merge 3 commits intorsim:masterfrom
yahonda:fix-cross-schema-type-owner
Open

Use type_owner for cross-schema type lookups#254
yahonda wants to merge 3 commits intorsim:masterfrom
yahonda:fix-cross-schema-type-owner

Conversation

@yahonda
Copy link
Copy Markdown
Collaborator

@yahonda yahonda commented Apr 13, 2026

Summary

  • get_field_definitions and get_element_definition used @schema_name when querying type metadata, which fails when a procedure parameter references a type owned by a different schema
  • Use argument_metadata[:type_owner] instead, which contains the actual type owner

Based on #208

Test plan

  • Verify test workflow passes (Oracle 23c Free)
  • Verify test_11g workflow passes (Oracle 11g XE)
  • New test creates a type in a second schema (arunit), grants execute to the primary schema, and verifies cross-schema type resolution and function execution

Co-Authored-By: Jochen Schug 4573581+joschug@users.noreply.github.com

Generated with Claude Code

yahonda and others added 3 commits April 13, 2026 10:33
The get_field_definitions and get_element_definition methods used
@schema_name when querying type metadata from ALL_PLSQL_TYPE_ATTRS,
ALL_TAB_COLS, ALL_PLSQL_COLL_TYPES, and ALL_COLL_TYPES. This fails
when a procedure parameter references a type owned by a different
schema. Use argument_metadata[:type_owner] instead.

Based on rsim#208

Co-Authored-By: Jochen Schug <4573581+joschug@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes cross-schema PL/SQL type resolution by using the actual type owner from argument metadata when looking up composite type details, ensuring procedure/function parameters can reference types owned by other schemas.

Changes:

  • Update composite type metadata queries to use argument_metadata[:type_owner] instead of @schema_name for type lookups.
  • Expand the secondary test user (arunit) privileges to support creating types/procedures needed by specs.
  • Add an RSpec case that creates a type in a second schema, grants access, and validates cross-schema function discovery/execution.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
spec/support/create_arunit_user.sql Grants additional privileges to the secondary schema user so cross-schema type tests can create required objects.
spec/plsql/procedure_spec.rb Adds an integration spec covering cross-schema object type parameters and execution.
lib/plsql/procedure.rb Fixes cross-schema composite type lookups by querying dictionary views using type_owner from all_arguments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants