sandynz commented on a change in pull request #14297:
URL: https://github.com/apache/shardingsphere/pull/14297#discussion_r774965150



##########
File path: 
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializerTest.java
##########
@@ -128,4 +130,15 @@ public void assertDestroyWhenSlotExists() throws 
SQLException {
         new PostgreSQLPositionInitializer().destroy(dataSource);
         verify(preparedStatement).execute();
     }
+    
+    /**
+     * Get the unique slot name by connection.
+     *
+     * @param conn the connection
+     * @return the unique name by connection
+     * @throws SQLException failed when getCatalog
+     */
+    public static String getUniqueSlotName(final Connection conn) throws 
SQLException {
+        return String.format("%s_%s", "sharding_scaling", conn.getCatalog());
+    }

Review comment:
       Looks it's the same code as 
`PostgreSQLPositionInitializer.getUniqueSlotName`

##########
File path: 
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java
##########
@@ -113,8 +113,19 @@ private void dropSlotIfExists(final Connection connection) 
throws SQLException {
         log.info("drop, slot exist, slot name: {}", SLOT_NAME);
         String dropSlotSQL = "SELECT pg_drop_replication_slot(?)";
         try (PreparedStatement preparedStatement = 
connection.prepareStatement(dropSlotSQL)) {
-            preparedStatement.setString(1, SLOT_NAME);
+            preparedStatement.setString(1, getUniqueSlotName(connection));
             preparedStatement.execute();
         }
     }
+    
+    /**
+     * Get the unique slot name by connection.
+     *
+     * @param conn the connection
+     * @return the unique name by connection
+     * @throws SQLException failed when getCatalog
+     */
+    public static String getUniqueSlotName(final Connection conn) throws 
SQLException {

Review comment:
       Use `connection` instead of `conn` could be better, keep consistent 
variable naming.




-- 
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]


Reply via email to