terrymanu commented on issue #33921:
URL: 
https://github.com/apache/shardingsphere/issues/33921#issuecomment-3497099689

   Root Cause Analysis
   
     After analyzing the ShardingSphere codebase, I've identified that this is 
not a bug but an Oracle database architecture limitation. The issue stems from 
Oracle's schema management mechanism conflicting with
     ShardingSphere's metadata loading process.
   
     Key Technical Limitations
   
     1. Oracle Connection Schema Mechanism: In Oracle, connection.getSchema() 
returns the current username, limiting access to only the current user's schema.
     2. Metadata Query Restriction: OracleMetaDataLoader uses SQL queries with 
WHERE OWNER = ?, where the parameter is connection.getSchema(), which only 
returns the current user schema.
     3. Configuration Parsing Dependency: Single table rule schema parsing 
relies on schema information returned by the database connection.
   
     Solutions
   
     Solution 1: Database-Level Authorization (Recommended)
   
     Grant schema1 user access to schema2 objects in Oracle:
   
     -- Grant access to specific tables
     GRANT SELECT ON schema2.table_name TO schema1;
   
     -- Or grant access to all tables in schema2
     GRANT SELECT ANY TABLE TO schema1;
   
     Solution 2: Configure Multiple DataSources
   
     Configure separate data sources for each schema:
   
     dataSources:
       master_schema1:
         dataSourceClassName: com.zaxxer.hikari.HikariDataSource
         jdbcUrl: jdbc:oracle:thin:@xx.xx.xx.xx:1521:xxxxxx
         username: schema1
         password:
         driverClassName: oracle.jdbc.OracleDriver
         maximumPoolSize: 50
       master_schema2:
         dataSourceClassName: com.zaxxer.hikari.HikariDataSource
         jdbcUrl: jdbc:oracle:thin:@xx.xx.xx.xx:1521:xxxxxx
         username: schema2
         password:
         driverClassName: oracle.jdbc.OracleDriver
         maximumPoolSize: 50
   
     rules:
       - !READWRITE_SPLITTING
         dataSourceGroups:
           readwrite_ds_schema1:
             writeDataSourceName: master_schema1
             readDataSourceNames:
               - slaver_schema1
           readwrite_ds_schema2:
             writeDataSourceName: master_schema2
             readDataSourceNames:
               - slaver_schema2
       - !SINGLE
         tables:
           - "readwrite_ds_schema1.*"
           - "readwrite_ds_schema2.*"
   
     Solution 3: Oracle Synonyms (Oracle-Specific)
   
     Create synonyms in schema1 pointing to schema2 tables:
   
     CREATE SYNONYM schema1.table_name FOR schema2.table_name;
   
     Additional Information Required
   
     To provide the most appropriate solution, please clarify the following:
   
     1. Permissions: Does the schema1 user have permissions to access schema2 
tables?
     2. Business Requirements: Is it necessary to access multiple schemas 
through a single data source?
     3. Table Structure: Are the table structures in schema1 and schema2 
identical?
     4. Access Pattern: Is this primarily for queries or does it include 
insert/update/delete operations?
   
     Conclusion
   
     This issue is caused by the incompatibility between Oracle's schema 
management mechanism and ShardingSphere's metadata loading process. It's not a 
ShardingSphere bug but rather an Oracle database architecture design
     characteristic. We recommend considering database-level authorization 
solutions first, and then adjusting ShardingSphere configuration if necessary.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to