diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index b1b114e418e..1c9027d04b5 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -18,6 +18,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6143](https://github.com/apache/incubator-seata/pull/6143)] gracefully shut down the server - [[#6204](https://github.com/apache/incubator-seata/pull/6204)] fix the problem that The incorrect configuration needs to be fixed - [[#6248](https://github.com/apache/incubator-seata/pull/6248)] fix JDBC resultSet, statement, connection closing order +- [[#6261](https://github.com/apache/incubator-seata/pull/6261)] AT mode support the URL of a PGSQL cluster - [[#6256](https://github.com/apache/incubator-seata/pull/6256)] fix raft-discovery cannot read registry configuration for seata-all sdk - [[#6232](https://github.com/apache/incubator-seata/pull/6232)] convert to utf8mb4 if mysql column is json type diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index ebeec80036a..f7ad3285853 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -18,6 +18,7 @@ - [[#6143](https://github.com/apache/incubator-seata/pull/6143)] 修复优雅停机 - [[#6204](https://github.com/apache/incubator-seata/pull/6204)] 修复错误配置问题 - [[#6248](https://github.com/apache/incubator-seata/pull/6248)] 修复JDBC resultSet, statement, connection关闭顺序 +- [[#6261](https://github.com/apache/incubator-seata/pull/6261)] at模式支持pgsql集群模式url - [[#6256](https://github.com/apache/incubator-seata/pull/6256)] 修复在seata-all sdk下,raft-discovery模块不能读取registry.conf的配置的问题 - [[#6232](https://github.com/apache/incubator-seata/pull/6232)] 修复在mysql的json类型下出现Cannot create a JSON value from a string with CHARACTER SET 'binary'问题 diff --git a/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java b/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java index 292859058db..7555a62e026 100644 --- a/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java +++ b/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java @@ -352,6 +352,9 @@ private void initPGResourceId() { } else { resourceId = jdbcUrl; } + if (resourceId.contains(",")) { + resourceId = resourceId.replace(",", "|"); + } } /** diff --git a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java index aafae33d0d0..ce791027faa 100644 --- a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java +++ b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java @@ -133,6 +133,7 @@ public void getResourceIdTest() throws SQLException, NoSuchFieldException, Illeg Assertions.assertEquals("jdbc:mock:xxx/username", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); } + // case: dbType = postgresql { resourceIdField.set(proxy, null); @@ -142,6 +143,23 @@ public void getResourceIdTest() throws SQLException, NoSuchFieldException, Illeg resourceIdField.set(proxy, null); jdbcUrlField.set(proxy, "jdbc:postgresql://mock/postgresql?xxx=1111¤tSchema=schema1,schema2&yyy=1"); Assertions.assertEquals("jdbc:postgresql://mock/postgresql?currentSchema=schema1!schema2", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + + resourceIdField.set(proxy, null); + jdbcUrlField.set(proxy, "jdbc:postgresql://192.168.1.123:30100,192.168.1.124:30100?xxx=1111¤tSchema=schema1,schema2&yyy=1"); + Assertions.assertEquals("jdbc:postgresql://192.168.1.123:30100|192.168.1.124:30100?currentSchema=schema1!schema2", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + + jdbcUrlField.set(proxy, jdbcUrl); + } + + // case: dbType = dm + { + resourceIdField.set(proxy, null); + dbTypeField.set(proxy, io.seata.sqlparser.util.JdbcConstants.DM); + Assertions.assertEquals(jdbcUrl, proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + + resourceIdField.set(proxy, null); + jdbcUrlField.set(proxy, "jdbc:dm://mock/dm?xxx=1111&schema=schema1"); + Assertions.assertEquals("jdbc:dm://mock/dm?schema=schema1", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); jdbcUrlField.set(proxy, jdbcUrl); }