diff --git a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDALStatementVisitor.java b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDALStatementVisitor.java index 05b2ae0c04b71..b625e117f02a0 100644 --- a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDALStatementVisitor.java +++ b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDALStatementVisitor.java @@ -982,7 +982,7 @@ public ASTNode visitSetCharacter(final SetCharacterContext ctx) { int stopIndex = null == ctx.CHARSET() ? ctx.SET(1).getSymbol().getStopIndex() : ctx.CHARSET().getSymbol().getStopIndex(); // TODO Consider setting all three system variables: character_set_client, character_set_results, character_set_connection VariableSegment variable = new VariableSegment(startIndex, stopIndex, (null == ctx.CHARSET()) ? "character_set_client" : ctx.CHARSET().getText()); - String assignValue = (null == ctx.DEFAULT()) ? ctx.charsetName().getText() : ctx.DEFAULT().getText(); + String assignValue = null == ctx.DEFAULT() ? ctx.charsetName().getText() : ctx.DEFAULT().getText(); VariableAssignSegment characterSet = new VariableAssignSegment(startIndex, stopIndex, variable, assignValue); DorisSetStatement result = new DorisSetStatement(); result.getVariableAssigns().add(characterSet); diff --git a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java index be10c6f74da31..cd8b97463e15a 100644 --- a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java +++ b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java @@ -87,8 +87,7 @@ private ConnectionContext mockConnectionContext() { } private SetStatement prepareSetStatement() { - VariableSegment maxConnectionVariableSegment = new VariableSegment(0, 0, "max_connections"); - maxConnectionVariableSegment.setScope("global"); + VariableSegment maxConnectionVariableSegment = new VariableSegment(0, 0, "max_connections", "global"); VariableAssignSegment setGlobalMaxConnectionAssignSegment = new VariableAssignSegment(0, 0, maxConnectionVariableSegment, "151"); VariableSegment characterSetClientSegment = new VariableSegment(0, 0, "character_set_client"); VariableAssignSegment setCharacterSetClientVariableSegment = new VariableAssignSegment(0, 0, characterSetClientSegment, "'utf8mb4'"); diff --git a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java index 2924796579ec0..22bcd49130a6a 100644 --- a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java +++ b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java @@ -47,8 +47,7 @@ class MySQLSystemVariableQueryExecutorTest { void assertTryGetSystemVariableQueryExecutorWithOtherExpressionProjection() { MySQLSelectStatement selectStatement = new MySQLSelectStatement(); selectStatement.setProjections(new ProjectionsSegment(0, 0)); - VariableSegment variable = new VariableSegment(0, 0, "max_connections"); - variable.setScope("session"); + VariableSegment variable = new VariableSegment(0, 0, "max_connections", "session"); selectStatement.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "@@session.max_connections", variable)); selectStatement.getProjections().getProjections().add(new ColumnProjectionSegment(new ColumnSegment(0, 0, new IdentifierValue("some_column")))); assertFalse(MySQLSystemVariableQueryExecutor.tryGetSystemVariableQueryExecutor(selectStatement).isPresent()); @@ -66,11 +65,9 @@ void assertTryGetSystemVariableQueryExecutorWithUnknownVariable() { void assertTryGetSystemVariableQueryExecutorAndExecuteWithCorrectScope() throws SQLException { MySQLSelectStatement selectStatement = new MySQLSelectStatement(); selectStatement.setProjections(new ProjectionsSegment(0, 0)); - VariableSegment maxConnectionsVariable = new VariableSegment(0, 0, "max_connections"); - maxConnectionsVariable.setScope("global"); + VariableSegment maxConnectionsVariable = new VariableSegment(0, 0, "max_connections", "global"); selectStatement.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "@@global.max_connections", maxConnectionsVariable)); - VariableSegment warningCountVariable = new VariableSegment(0, 0, "warning_count"); - warningCountVariable.setScope("session"); + VariableSegment warningCountVariable = new VariableSegment(0, 0, "warning_count", "session"); ExpressionProjectionSegment warningCountProjection = new ExpressionProjectionSegment(0, 0, "@@session.warning_count", warningCountVariable); warningCountProjection.setAlias(new AliasSegment(0, 0, new IdentifierValue("session_warning"))); selectStatement.getProjections().getProjections().add(warningCountProjection); @@ -96,8 +93,7 @@ void assertTryGetSystemVariableQueryExecutorAndExecuteWithCorrectScope() throws void assertExecuteWithIncorrectScope() { MySQLSelectStatement selectStatement = new MySQLSelectStatement(); selectStatement.setProjections(new ProjectionsSegment(0, 0)); - VariableSegment variable = new VariableSegment(0, 0, "max_connections"); - variable.setScope("session"); + VariableSegment variable = new VariableSegment(0, 0, "max_connections", "session"); selectStatement.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "@@session.max_connections", variable)); Optional executor = MySQLSystemVariableQueryExecutor.tryGetSystemVariableQueryExecutor(selectStatement); assertTrue(executor.isPresent());