tristaZero opened a new issue #8912:
URL: https://github.com/apache/shardingsphere/issues/8912
### Product
Sharding Proxy, master branch
### Steps
- Create a single table
- Do a query on this new table
- An exception is thrown
```sql
CREATE TABLE `single1` (
`id` int DEFAULT NULL,
`type` varchar(10) DEFAULT NULL
)
select * from single1;
```
### Cause
Only `ShardingSphereSchema` is refreshed after creating a new table. It is
necessary to refresh `shardingRule`, since we calculate routeUnits by
`shardingRule`. The relevant class is below.
```java
// CreateTableStatementSchemaRefresher
@Override
public void refresh(final ShardingSphereSchema schema,
final Collection<String> routeDataSourceNames, final
CreateTableStatement sqlStatement, final SchemaBuilderMaterials materials)
throws SQLException {
String tableName =
sqlStatement.getTable().getTableName().getIdentifier().getValue();
TableMetaData tableMetaData;
if (containsInTableContainedRule(tableName, materials)) {
tableMetaData = TableMetaDataBuilder.build(tableName,
materials).orElse(new TableMetaData());
} else {
tableMetaData = new TableMetaData();
}
schema.put(tableName, tableMetaData);
}
```
Moreover, the similar incomplete handling still exists in `public
synchronized void renew(final SchemaChangedEvent event) {` of
`GovernanceMetaDataContexts`.
----------------------------------------------------------------
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]