This is an automated email from the ASF dual-hosted git repository.
chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 96fd0a0e52b Add AllowNotUseDatabaseSQLStatementAttribute to support
some mysql dal statement execute without use database (#37033)
96fd0a0e52b is described below
commit 96fd0a0e52b02af6a0e1e5b388a5f11466c83f78
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Fri Nov 7 13:49:26 2025 +0800
Add AllowNotUseDatabaseSQLStatementAttribute to support some mysql dal
statement execute without use database (#37033)
---
RELEASE-NOTES.md | 1 +
.../MySQLDALStatementBroadcastRouteDecider.java | 8 ++++++
.../infra/session/query/QueryContext.java | 31 +++++++++++++++++++--
.../infra/session/query/QueryContextTest.java | 28 ++++++++++++++++---
.../AllowNotUseDatabaseSQLStatementAttribute.java} | 32 ++++++++++++++++------
.../core/statement/type/dal/SetStatement.java | 7 +++++
.../core/statement/type/dml/SelectStatement.java | 3 +-
.../statement/mysql/dal/MySQLKillStatement.java | 7 +++++
.../statement/mysql/dal/MySQLResetStatement.java | 7 +++++
.../statement/mysql/dal/MySQLUseStatement.java | 7 +++++
.../dal/plugin/MySQLShowPluginsStatement.java | 7 +++++
.../binlog/MySQLShowBinaryLogsStatement.java | 7 +++++
.../binlog/MySQLShowBinlogEventsStatement.java | 7 +++++
.../show/MySQLShowMasterStatusStatement.java | 7 +++++
.../show/MySQLShowRelayLogEventsStatement.java | 7 +++++
.../show/MySQLShowReplicaStatusStatement.java | 7 +++++
.../show/MySQLShowReplicasStatement.java | 7 +++++
.../show/MySQLShowSlaveHostsStatement.java | 7 +++++
.../show/MySQLShowSlaveStatusStatement.java | 7 +++++
.../replication/show/MySQLShowStatusStatement.java | 7 +++++
.../character/MySQLShowCharacterSetStatement.java | 7 +++++
.../character/MySQLShowCollationStatement.java | 7 +++++
.../database/MySQLShowCreateDatabaseStatement.java | 7 +++++
.../show/database/MySQLShowDatabasesStatement.java | 3 +-
.../dal/show/engine/MySQLShowEngineStatement.java | 7 +++++
.../dal/show/error/MySQLShowErrorsStatement.java | 7 +++++
.../dal/show/error/MySQLShowWarningsStatement.java | 7 +++++
.../show/event/MySQLShowCreateEventStatement.java | 7 +++++
.../dal/show/event/MySQLShowEventsStatement.java | 7 +++++
.../function/MySQLShowFunctionStatusStatement.java | 7 +++++
.../privilege/MySQLShowCreateUserStatement.java | 7 +++++
.../show/privilege/MySQLShowGrantsStatement.java | 7 +++++
.../privilege/MySQLShowPrivilegesStatement.java | 7 +++++
.../MySQLShowProcedureStatusStatement.java | 7 +++++
.../process/MySQLShowProcessListStatement.java | 7 +++++
.../show/profile/MySQLShowProfileStatement.java | 7 +++++
.../show/profile/MySQLShowProfilesStatement.java | 7 +++++
.../show/table/MySQLShowOpenTablesStatement.java | 8 ++++++
.../show/table/MySQLShowTableStatusStatement.java | 6 ++--
.../dal/show/table/MySQLShowTablesStatement.java | 6 ++--
.../show/trigger/MySQLShowTriggersStatement.java | 8 ++++++
.../show/variable/MySQLShowVariablesStatement.java | 7 +++++
42 files changed, 329 insertions(+), 22 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 5cfa248ad20..1a200eb49a2 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -54,6 +54,7 @@
### Bug Fixes
1. Kernel: Fix not return generate key when set null in INSERT statement -
[35783](https://github.com/apache/shardingsphere/pull/35783)
+1. Kernel: Add AllowNotUseDatabaseSQLStatementAttribute to support some mysql
dal statement execute without use database -
[#37033](https://github.com/apache/shardingsphere/pull/37033)
1. Metadata: Fix the exception to rename schema name when executing ALTER
SCHEMA - [#34465](https://github.com/apache/shardingsphere/pull/34465)
1. SQL Parser: Support multiple column names with pivot and unpivot clause -
[35586](https://github.com/apache/shardingsphere/pull/35586)
1. SQL Parser: Fix set OnDuplicateKeyColumnsSegment on INSERT for PostgreSQL -
[#34425](https://github.com/apache/shardingsphere/pull/34425)
diff --git
a/infra/route/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/route/mysql/MySQLDALStatementBroadcastRouteDecider.java
b/infra/route/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/route/mysql/MySQLDALStatementBroadcastRouteDecider.java
index ae676a27e8d..ebe61457a2f 100644
---
a/infra/route/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/route/mysql/MySQLDALStatementBroadcastRouteDecider.java
+++
b/infra/route/dialect/mysql/src/main/java/org/apache/shardingsphere/infra/route/mysql/MySQLDALStatementBroadcastRouteDecider.java
@@ -18,12 +18,15 @@
package org.apache.shardingsphere.infra.route.mysql;
import
org.apache.shardingsphere.infra.route.engine.tableless.DialectDALStatementBroadcastRouteDecider;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.resource.MySQLAlterResourceGroupStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.resource.MySQLCreateResourceGroupStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.resource.MySQLDropResourceGroupStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.resource.MySQLSetResourceGroupStatement;
+import java.util.Optional;
+
/**
* Dialect DAL statement broadcast route decider for MySQL.
*/
@@ -36,6 +39,11 @@ public final class MySQLDALStatementBroadcastRouteDecider
implements DialectDALS
@Override
public boolean isInstanceBroadcastRoute(final DALStatement sqlStatement) {
+ Optional<AllowNotUseDatabaseSQLStatementAttribute> attribute =
sqlStatement.getAttributes().findAttribute(AllowNotUseDatabaseSQLStatementAttribute.class);
+ return isResourceGroupStatement(sqlStatement) || attribute.isPresent()
&& attribute.get().isAllowNotUseDatabase();
+ }
+
+ private boolean isResourceGroupStatement(final DALStatement sqlStatement) {
return sqlStatement instanceof MySQLCreateResourceGroupStatement ||
sqlStatement instanceof MySQLAlterResourceGroupStatement || sqlStatement
instanceof MySQLDropResourceGroupStatement
|| sqlStatement instanceof MySQLSetResourceGroupStatement;
}
diff --git
a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/query/QueryContext.java
b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/query/QueryContext.java
index f9326ac3c11..a6f2d1f8c4a 100644
---
a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/query/QueryContext.java
+++
b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/query/QueryContext.java
@@ -21,6 +21,7 @@ import com.google.common.base.Joiner;
import lombok.Getter;
import
org.apache.shardingsphere.database.exception.core.exception.syntax.database.NoDatabaseSelectedException;
import
org.apache.shardingsphere.database.exception.core.exception.syntax.database.UnknownDatabaseException;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
import
org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
@@ -28,14 +29,18 @@ import
org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
/**
* Query context.
*/
+@HighFrequencyInvocation
@Getter
public final class QueryContext {
@@ -68,13 +73,33 @@ public final class QueryContext {
this.hintValueContext = hintValueContext;
this.connectionContext = connectionContext;
this.metaData = metaData;
- usedDatabaseNames = getUsedDatabaseNames(sqlStatementContext,
connectionContext);
+ usedDatabaseNames = getUsedDatabaseNames(sqlStatementContext,
connectionContext, metaData);
this.useCache = useCache;
}
- private Collection<String> getUsedDatabaseNames(final SQLStatementContext
sqlStatementContext, final ConnectionContext connectionContext) {
+ private Collection<String> getUsedDatabaseNames(final SQLStatementContext
sqlStatementContext, final ConnectionContext connectionContext, final
ShardingSphereMetaData metaData) {
Collection<String> databaseNamesFromSQL =
sqlStatementContext.getTablesContext().getDatabaseNames();
- return databaseNamesFromSQL.isEmpty() ?
connectionContext.getCurrentDatabaseName().map(Collections::singletonList).orElse(Collections.emptyList())
: databaseNamesFromSQL;
+ return databaseNamesFromSQL.isEmpty()
+ ?
connectionContext.getCurrentDatabaseName().map(Collections::singletonList)
+ .orElseGet(() ->
getUsedDatabaseNamesFromSQLStatementAttribute(sqlStatementContext.getSqlStatement(),
metaData))
+ : databaseNamesFromSQL;
+ }
+
+ private List<String> getUsedDatabaseNamesFromSQLStatementAttribute(final
SQLStatement sqlStatement, final ShardingSphereMetaData metaData) {
+ Optional<AllowNotUseDatabaseSQLStatementAttribute> attribute =
sqlStatement.getAttributes().findAttribute(AllowNotUseDatabaseSQLStatementAttribute.class);
+ if (attribute.isPresent() && attribute.get().isAllowNotUseDatabase()) {
+ return
attribute.get().findDatabaseName().map(Collections::singletonList).orElseGet(()
->
findAnyDatabaseName(metaData).map(Collections::singletonList).orElse(Collections.emptyList()));
+ }
+ return Collections.emptyList();
+ }
+
+ private Optional<String> findAnyDatabaseName(final ShardingSphereMetaData
metaData) {
+ for (ShardingSphereDatabase each : metaData.getAllDatabases()) {
+ if (each.isComplete()) {
+ return Optional.of(each.getName());
+ }
+ }
+ return Optional.empty();
}
/**
diff --git
a/infra/session/src/test/java/org/apache/shardingsphere/infra/session/query/QueryContextTest.java
b/infra/session/src/test/java/org/apache/shardingsphere/infra/session/query/QueryContextTest.java
index 27b9f599f20..53ba2c049f7 100644
---
a/infra/session/src/test/java/org/apache/shardingsphere/infra/session/query/QueryContextTest.java
+++
b/infra/session/src/test/java/org/apache/shardingsphere/infra/session/query/QueryContextTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -59,8 +60,27 @@ class QueryContextTest {
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.empty());
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
- QueryContext queryContext = new QueryContext(sqlStatementContext,
"SELECT 1", Collections.emptyList(), mock(HintValueContext.class),
connectionContext, metaData);
- assertThrows(NoDatabaseSelectedException.class,
queryContext::getUsedDatabase);
+ QueryContext actual = new QueryContext(sqlStatementContext, "SELECT
1", Collections.emptyList(), mock(HintValueContext.class), connectionContext,
metaData);
+ assertThrows(NoDatabaseSelectedException.class,
actual::getUsedDatabase);
+ }
+
+ @Test
+ void
assertGetUsedDatabaseForShowTableStatusStatementWhenNoDatabaseSelected() {
+ ConnectionContext connectionContext = mock(ConnectionContext.class);
+
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.empty());
+ ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
+ when(database.isComplete()).thenReturn(true);
+ when(database.getName()).thenReturn("foo_db");
+ when(metaData.containsDatabase("foo_db")).thenReturn(true);
+
when(metaData.getAllDatabases()).thenReturn(Collections.singletonList(database));
+ when(metaData.getDatabase("foo_db")).thenReturn(database);
+ SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+
when(sqlStatementContext.getSqlStatement().getAttributes().findAttribute(AllowNotUseDatabaseSQLStatementAttribute.class))
+ .thenReturn(Optional.of(new
AllowNotUseDatabaseSQLStatementAttribute(true)));
+
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
+ QueryContext actual = new QueryContext(sqlStatementContext, "SELECT
1", Collections.emptyList(), mock(HintValueContext.class), connectionContext,
metaData);
+ assertThat(actual.getUsedDatabase(), is(database));
}
@Test
@@ -70,7 +90,7 @@ class QueryContextTest {
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of("unknown_db"));
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
- QueryContext queryContext = new QueryContext(sqlStatementContext,
"SELECT 1", Collections.emptyList(), mock(HintValueContext.class),
connectionContext, metaData);
- assertThrows(UnknownDatabaseException.class,
queryContext::getUsedDatabase);
+ QueryContext actual = new QueryContext(sqlStatementContext, "SELECT
1", Collections.emptyList(), mock(HintValueContext.class), connectionContext,
metaData);
+ assertThrows(UnknownDatabaseException.class, actual::getUsedDatabase);
}
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/attribute/type/AllowNotUseDatabaseSQLStatementAttribute.java
similarity index 54%
copy from
parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
copy to
parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/attribute/type/AllowNotUseDatabaseSQLStatementAttribute.java
index 5977e348a5a..c3c0a114f0d 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/attribute/type/AllowNotUseDatabaseSQLStatementAttribute.java
@@ -15,22 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.database;
+package
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type;
import lombok.Getter;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttribute;
+
+import java.util.Optional;
/**
- * Show create database statement for MySQL.
+ * Allow not use database SQL statement attribute.
*/
-@Getter
-public final class MySQLShowCreateDatabaseStatement extends DALStatement {
+@RequiredArgsConstructor
+public final class AllowNotUseDatabaseSQLStatementAttribute implements
SQLStatementAttribute {
+
+ @Getter
+ private final boolean allowNotUseDatabase;
private final String databaseName;
- public MySQLShowCreateDatabaseStatement(final DatabaseType databaseType,
final String databaseName) {
- super(databaseType);
- this.databaseName = databaseName;
+ public AllowNotUseDatabaseSQLStatementAttribute(final boolean
allowNotUseDatabase) {
+ this.allowNotUseDatabase = allowNotUseDatabase;
+ databaseName = null;
+ }
+
+ /**
+ * Find database name.
+ *
+ * @return database name
+ */
+ public Optional<String> findDatabaseName() {
+ return Optional.ofNullable(databaseName);
}
}
diff --git
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/SetStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/SetStatement.java
index b34d52a1173..a04275afce3 100644
---
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/SetStatement.java
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/SetStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.VariableAssignSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import java.util.List;
@@ -35,4 +37,9 @@ public final class SetStatement extends DALStatement {
super(databaseType);
this.variableAssigns = variableAssigns;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dml/SelectStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dml/SelectStatement.java
index 29e2f55dac0..8a1125a1c12 100644
---
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dml/SelectStatement.java
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dml/SelectStatement.java
@@ -35,6 +35,7 @@ import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.Windo
import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.WithSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.WithSQLStatementAttribute;
import java.util.Optional;
@@ -208,6 +209,6 @@ public final class SelectStatement extends DMLStatement {
@Override
public SQLStatementAttributes getAttributes() {
- return new SQLStatementAttributes(new WithSQLStatementAttribute(with));
+ return new SQLStatementAttributes(new WithSQLStatementAttribute(with),
new AllowNotUseDatabaseSQLStatementAttribute(null == from));
}
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLKillStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLKillStatement.java
index e4b7c32d7cc..69840f9cc76 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLKillStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLKillStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -36,4 +38,9 @@ public final class MySQLKillStatement extends DALStatement {
this.processId = processId;
this.scope = scope;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLResetStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLResetStatement.java
index ef01427a53a..9c73674e8a0 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLResetStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLResetStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ResetOptionSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
import java.util.List;
@@ -36,4 +38,9 @@ public final class MySQLResetStatement extends DALStatement {
super(databaseType);
this.options = options;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLUseStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLUseStatement.java
index ad49d408b0e..d039d4330ca 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLUseStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/MySQLUseStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLUseStatement extends DALStatement {
super(databaseType);
this.database = database;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/plugin/MySQLShowPluginsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/plugin/MySQLShowPluginsStatement.java
index 425ea5eeaed..fb83f64b863 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/plugin/MySQLShowPluginsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/plugin/MySQLShowPluginsStatement.java
@@ -18,6 +18,8 @@
package org.apache.shardingsphere.sql.parser.statement.mysql.dal.plugin;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowPluginsStatement extends
DALStatement {
public MySQLShowPluginsStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinaryLogsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinaryLogsStatement.java
index 5308e86b427..0716189ece5 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinaryLogsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinaryLogsStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.binlog;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowBinaryLogsStatement extends
DALStatement {
public MySQLShowBinaryLogsStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinlogEventsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinlogEventsStatement.java
index 56c3ca9d87b..ba72ad54e37 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinlogEventsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/binlog/MySQLShowBinlogEventsStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.bin
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -37,4 +39,9 @@ public final class MySQLShowBinlogEventsStatement extends
DALStatement {
this.logName = logName;
this.limit = limit;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowMasterStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowMasterStatusStatement.java
index 0d99c68ff49..f48b5b4fef4 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowMasterStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowMasterStatusStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.show;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowMasterStatusStatement extends
DALStatement {
public MySQLShowMasterStatusStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowRelayLogEventsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowRelayLogEventsStatement.java
index 1e87c5d42a2..5bbd01452fa 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowRelayLogEventsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowRelayLogEventsStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.sho
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -40,4 +42,9 @@ public final class MySQLShowRelayLogEventsStatement extends
DALStatement {
this.limit = limit;
this.channel = channel;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicaStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicaStatusStatement.java
index fb7760d89f5..abaa7c31d8a 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicaStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicaStatusStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.sho
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowReplicaStatusStatement extends
DALStatement {
super(databaseType);
this.channel = channel;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicasStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicasStatement.java
index 0bca0150444..6cc19d653dd 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicasStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowReplicasStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.show;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowReplicasStatement extends
DALStatement {
public MySQLShowReplicasStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveHostsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveHostsStatement.java
index 8ded4460674..0025c28f034 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveHostsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveHostsStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.show;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowSlaveHostsStatement extends
DALStatement {
public MySQLShowSlaveHostsStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveStatusStatement.java
index cc717bc1c94..1d9ee453094 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowSlaveStatusStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.sho
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowSlaveStatusStatement extends
DALStatement {
super(databaseType);
this.channel = channel;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowStatusStatement.java
index 888df19767f..ed2fb50a2cb 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/replication/show/MySQLShowStatusStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.replication.sho
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowStatusStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCharacterSetStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCharacterSetStatement.java
index ba29ddf68fa..f39e7a5ffe3 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCharacterSetStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCharacterSetStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.character;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowCharacterSetStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCollationStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCollationStatement.java
index 39dea7738dd..d9abc86df91 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCollationStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/character/MySQLShowCollationStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.character;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowCollationStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
index 5977e348a5a..6351c897622 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowCreateDatabaseStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.database;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowCreateDatabaseStatement extends
DALStatement {
super(databaseType);
this.databaseName = databaseName;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowDatabasesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowDatabasesStatement.java
index 4837e86d148..1225de7171a 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowDatabasesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/database/MySQLShowDatabasesStatement.java
@@ -20,6 +20,7 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.database;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
@@ -48,6 +49,6 @@ public final class MySQLShowDatabasesStatement extends
DALStatement {
@Override
public SQLStatementAttributes getAttributes() {
- return new SQLStatementAttributes(new
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+ return new SQLStatementAttributes(new
TablelessDataSourceBroadcastRouteSQLStatementAttribute(), new
AllowNotUseDatabaseSQLStatementAttribute(true));
}
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/engine/MySQLShowEngineStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/engine/MySQLShowEngineStatement.java
index 0e83c4ac1b0..77428991136 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/engine/MySQLShowEngineStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/engine/MySQLShowEngineStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.engine;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowEngineStatement extends
DALStatement {
super(databaseType);
this.engineName = engineName;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowErrorsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowErrorsStatement.java
index 347161e4908..812db05a68d 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowErrorsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowErrorsStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.error;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowErrorsStatement extends
DALStatement {
super(databaseType);
this.limit = limit;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowWarningsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowWarningsStatement.java
index f1eed04807e..5efeb6a3a91 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowWarningsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/error/MySQLShowWarningsStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.error;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowWarningsStatement extends
DALStatement {
super(databaseType);
this.limit = limit;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowCreateEventStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowCreateEventStatement.java
index b9e166a2a39..6aeab4036e0 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowCreateEventStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowCreateEventStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.event;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowCreateEventStatement extends
DALStatement {
super(databaseType);
this.eventName = eventName;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowEventsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowEventsStatement.java
index e06b37960f9..52869fec437 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowEventsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/event/MySQLShowEventsStatement.java
@@ -21,6 +21,8 @@ import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -38,4 +40,9 @@ public final class MySQLShowEventsStatement extends
DALStatement {
this.fromDatabase = fromDatabase;
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/function/MySQLShowFunctionStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/function/MySQLShowFunctionStatusStatement.java
index 7e48aacfdf3..eb943a94c79 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/function/MySQLShowFunctionStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/function/MySQLShowFunctionStatusStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.function;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowFunctionStatusStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowCreateUserStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowCreateUserStatement.java
index d5107fca64a..ef7a447aee4 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowCreateUserStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowCreateUserStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.privilege;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowCreateUserStatement extends
DALStatement {
super(databaseType);
this.name = name;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowGrantsStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowGrantsStatement.java
index 95f152ad95e..e28808c0734 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowGrantsStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowGrantsStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.privilege;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowGrantsStatement extends
DALStatement {
public MySQLShowGrantsStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowPrivilegesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowPrivilegesStatement.java
index 53ccf81249b..5dda21eb169 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowPrivilegesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/privilege/MySQLShowPrivilegesStatement.java
@@ -18,6 +18,8 @@
package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.privilege;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowPrivilegesStatement extends
DALStatement {
public MySQLShowPrivilegesStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/procedure/MySQLShowProcedureStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/procedure/MySQLShowProcedureStatusStatement.java
index 192871c6031..2110490050c 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/procedure/MySQLShowProcedureStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/procedure/MySQLShowProcedureStatusStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.procedure;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowProcedureStatusStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/process/MySQLShowProcessListStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/process/MySQLShowProcessListStatement.java
index 8487050941d..063ba76b92a 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/process/MySQLShowProcessListStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/process/MySQLShowProcessListStatement.java
@@ -19,6 +19,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.process;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -33,4 +35,9 @@ public final class MySQLShowProcessListStatement extends
DALStatement {
super(databaseType);
this.full = full;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfileStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfileStatement.java
index 80360978611..dd050323883 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfileStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfileStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.profile;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowProfileStatement extends
DALStatement {
super(databaseType);
this.limit = limit;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfilesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfilesStatement.java
index 7500ad2f885..83f4e1ea03a 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfilesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/profile/MySQLShowProfilesStatement.java
@@ -18,6 +18,8 @@
package org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.profile;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -28,4 +30,9 @@ public final class MySQLShowProfilesStatement extends
DALStatement {
public MySQLShowProfilesStatement(final DatabaseType databaseType) {
super(databaseType);
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowOpenTablesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowOpenTablesStatement.java
index 0fcd25286c0..6287f768ba3 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowOpenTablesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowOpenTablesStatement.java
@@ -21,6 +21,8 @@ import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -38,4 +40,10 @@ public final class MySQLShowOpenTablesStatement extends
DALStatement {
this.fromDatabase = fromDatabase;
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ String databaseName = null == fromDatabase ? null :
fromDatabase.getDatabase().getIdentifier().getValue();
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true, databaseName));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTableStatusStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTableStatusStatement.java
index f017dad31aa..6597e8e5b8e 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTableStatusStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTableStatusStatement.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.DatabaseSelectRequiredSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.FromDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
@@ -65,7 +66,8 @@ public final class MySQLShowTableStatusStatement extends
DALStatement {
@Override
public SQLStatementAttributes getAttributes() {
- return new SQLStatementAttributes(
- new DatabaseSelectRequiredSQLStatementAttribute(), new
FromDatabaseSQLStatementAttribute(fromDatabase), new
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+ String databaseName = null == fromDatabase ? null :
fromDatabase.getDatabase().getIdentifier().getValue();
+ return new SQLStatementAttributes(new
DatabaseSelectRequiredSQLStatementAttribute(), new
FromDatabaseSQLStatementAttribute(fromDatabase),
+ new TablelessDataSourceBroadcastRouteSQLStatementAttribute(),
new AllowNotUseDatabaseSQLStatementAttribute(true, databaseName));
}
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTablesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTablesStatement.java
index 7b69310499a..2fe9c8b555a 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTablesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/table/MySQLShowTablesStatement.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.DatabaseSelectRequiredSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.FromDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
@@ -68,7 +69,8 @@ public final class MySQLShowTablesStatement extends
DALStatement {
@Override
public SQLStatementAttributes getAttributes() {
- return new SQLStatementAttributes(
- new DatabaseSelectRequiredSQLStatementAttribute(), new
FromDatabaseSQLStatementAttribute(fromDatabase), new
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+ String databaseName = null == fromDatabase ? null :
fromDatabase.getDatabase().getIdentifier().getValue();
+ return new SQLStatementAttributes(new
DatabaseSelectRequiredSQLStatementAttribute(), new
FromDatabaseSQLStatementAttribute(fromDatabase),
+ new TablelessDataSourceBroadcastRouteSQLStatementAttribute(),
new AllowNotUseDatabaseSQLStatementAttribute(true, databaseName));
}
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/trigger/MySQLShowTriggersStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/trigger/MySQLShowTriggersStatement.java
index 270b1b55e9a..d794ab44a78 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/trigger/MySQLShowTriggersStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/trigger/MySQLShowTriggersStatement.java
@@ -21,6 +21,8 @@ import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -38,4 +40,10 @@ public final class MySQLShowTriggersStatement extends
DALStatement {
this.fromDatabase = fromDatabase;
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ String databaseName = null == fromDatabase ? null :
fromDatabase.getDatabase().getIdentifier().getValue();
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true, databaseName));
+ }
}
diff --git
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/variable/MySQLShowVariablesStatement.java
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/variable/MySQLShowVariablesStatement.java
index 43d42c7a25f..8d3652ccb7e 100644
---
a/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/variable/MySQLShowVariablesStatement.java
+++
b/parser/sql/statement/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/statement/mysql/dal/show/variable/MySQLShowVariablesStatement.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.variable;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.AllowNotUseDatabaseSQLStatementAttribute;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
/**
@@ -34,4 +36,9 @@ public final class MySQLShowVariablesStatement extends
DALStatement {
super(databaseType);
this.filter = filter;
}
+
+ @Override
+ public SQLStatementAttributes getAttributes() {
+ return new SQLStatementAttributes(new
AllowNotUseDatabaseSQLStatementAttribute(true));
+ }
}