tuichenchuxin commented on code in PR #22004:
URL: https://github.com/apache/shardingsphere/pull/22004#discussion_r1016190734
##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -82,9 +83,14 @@ private void route0(final RouteContext routeContext, final
SingleTableRule rule)
if (sqlStatement instanceof CreateTableStatement) {
String dataSourceName = rule.assignNewDataSourceName();
QualifiedTable table = singleTableNames.iterator().next();
- if (isTableExists(table, rule)) {
+ boolean tableExists = isTableExists(table, rule);
+ boolean ifNotExists =
CreateTableStatementHandler.ifNotExists((CreateTableStatement) sqlStatement);
+ if (tableExists && !ifNotExists) {
throw new TableExistsException(table.getTableName());
}
+ if (tableExists) {
+ return;
Review Comment:
just return may cause create table if not exists actually execute. And if
ds_0 has this table. It may execute on ds_1 ,Then we'll get two same name
single table.
--
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]