cherrylzhao opened a new pull request #5016: refactor DatabaseMetaData for 
sharding-jdbc
URL: https://github.com/apache/incubator-shardingsphere/pull/5016
 
 
   in sharding-jdbc getMetaData is like this:
   ```java
       @Override
       public DatabaseMetaData getMetaData() throws SQLException {
           return getCachedConnections().isEmpty() ? 
runtimeContext.getCachedDatabaseMetaData() : 
getCachedConnections().values().iterator().next().getMetaData();
       }
   ```
   two problems exists:
   
   - if `getCachedConnections().isEmpty()`, databaseMetaData will get from a 
physical connection, however physical connection's metadata will not return a 
logic tableName which we have converted in CachedDatabaseMetaData by 
ShardingRule currently.
   
   - getCachedConnections().isNotEmpty, databaseMetaData will get from 
CachedDatabaseMetaData which get connection every time for ResultSet returned 
interface
   
   I have extract a MultipleDatabaseMetaData abstract class which includes 
cacchedConnection, subclass is ShardingDatabaseMetaData and 
MasterSlaveDatabaseMetaData. CachedDatabaseMetaData will only contains cached 
properties only, initialized when DataSource was created. In this way below 2 
problems will be resolved, meantime the performance will not reduce.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to