You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/12/15 17:45:21 UTC

(shardingsphere) branch master updated: Handle ALTER DATABASE without null result (#37394)

This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 1f7d9c79887 Handle ALTER DATABASE without null result (#37394)
1f7d9c79887 is described below

commit 1f7d9c79887fc995fcb9166e402d9ee40db23823
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Dec 16 01:45:13 2025 +0800

    Handle ALTER DATABASE without null result (#37394)
---
 .../visitor/statement/type/PostgreSQLDDLStatementVisitor.java      | 7 +++++++
 test/it/parser/src/main/resources/case/ddl/alter-database.xml      | 1 +
 .../parser/src/main/resources/sql/supported/ddl/alter-database.xml | 1 +
 3 files changed, 9 insertions(+)

diff --git a/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java b/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
index 0858d312869..346da9c4d7a 100644
--- a/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
+++ b/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.Ad
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AddConstraintSpecificationContext;
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AllContext;
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterAggregateContext;
+import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterDatabaseContext;
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterCollationContext;
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterConversionContext;
 import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterDefaultPrivilegesContext;
@@ -216,6 +217,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.Tr
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.collation.AlterCollationStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.collation.CreateCollationStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.collation.DropCollationStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.AlterDatabaseStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.DropDatabaseStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.domain.AlterDomainStatement;
@@ -847,6 +849,11 @@ public final class PostgreSQLDDLStatementVisitor extends PostgreSQLStatementVisi
         return new DropDatabaseStatement(getDatabaseType(), ((IdentifierValue) visit(ctx.name())).getValue(), null != ctx.ifExists());
     }
     
+    @Override
+    public ASTNode visitAlterDatabase(final AlterDatabaseContext ctx) {
+        return new AlterDatabaseStatement(getDatabaseType());
+    }
+    
     @Override
     public ASTNode visitAlterRoutine(final AlterRoutineContext ctx) {
         return new PostgreSQLAlterRoutineStatement(getDatabaseType());
diff --git a/test/it/parser/src/main/resources/case/ddl/alter-database.xml b/test/it/parser/src/main/resources/case/ddl/alter-database.xml
index 4feccdd432b..cd43e5c88d3 100644
--- a/test/it/parser/src/main/resources/case/ddl/alter-database.xml
+++ b/test/it/parser/src/main/resources/case/ddl/alter-database.xml
@@ -97,4 +97,5 @@
     <alter-database sql-case-id="alter_schema_set_location" />
     <alter-database sql-case-id="alter_database_set_managedlocation" />
     <alter-database sql-case-id="alter_schema_set_managedlocation" />
+    <alter-database sql-case-id="alter_database_set_lc_messages" />
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/alter-database.xml b/test/it/parser/src/main/resources/sql/supported/ddl/alter-database.xml
index ebdfe1f8a75..5b7da87eeeb 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/alter-database.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/alter-database.xml
@@ -97,4 +97,5 @@
     <sql-case id="alter_schema_set_location" value="ALTER SCHEMA test_db SET LOCATION 'hdfs://namenode:8020/user/hive/warehouse/another_location';" db-types="Hive" />
     <sql-case id="alter_database_set_managedlocation" value="ALTER DATABASE test_db SET MANAGEDLOCATION 'hdfs://namenode:8020/user/hive/managed/test_db';" db-types="Hive" />
     <sql-case id="alter_schema_set_managedlocation" value="ALTER SCHEMA test_db SET MANAGEDLOCATION 'hdfs://namenode:8020/user/hive/managed/another_test_db';" db-types="Hive" />
+    <sql-case id="alter_database_set_lc_messages" value="ALTER DATABASE &quot;regression&quot; SET lc_messages TO 'C'" db-types="PostgreSQL" />
 </sql-cases>