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

zhangyv pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 61e375f9e7 bugfix: undo log table name dynamic derivation (#7747)
61e375f9e7 is described below

commit 61e375f9e72dc02406680b55986842d012e08985
Author: maple <[email protected]>
AuthorDate: Fri Oct 31 14:29:09 2025 +0800

    bugfix: undo log table name dynamic derivation (#7747)
---
 changes/en-us/2.x.md                               |   1 +
 changes/zh-cn/2.x.md                               |   2 +-
 .../undo/kingbase/KingbaseUndoLogManager.java      |   2 +-
 .../undo/oracle/OracleUndoLogManager.java          |   2 +-
 .../datasource/undo/oscar/OscarUndoLogManager.java |   2 +-
 .../undo/postgresql/PostgresqlUndoLogManager.java  |   2 +-
 .../undo/kingbase/KingbaseUndoLogManagerTest.java  | 383 +++++++++++++++++++++
 .../undo/oracle/OracleUndoLogManagerTest.java      | 383 +++++++++++++++++++++
 .../undo/oscar/OscarUndoLogManagerTest.java        | 383 +++++++++++++++++++++
 .../postgresql/PostgresqlUndoLogManagerTest.java   | 345 +++++++++++++++++++
 10 files changed, 1500 insertions(+), 5 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 70878588dc..3178235a75 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -47,6 +47,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#7662](https://github.com/apache/incubator-seata/pull/7662)] ensure 
visibility of rm and The methods in MockTest are executed in order
 - [[#7683](https://github.com/apache/incubator-seata/pull/7683)] Override 
XABranchXid equals() and hashCode() to fix memory leak in mysql driver
 - [[#7643](https://github.com/apache/incubator-seata/pull/7643)] fix DM 
transaction rollback not using database auto-increment primary keys
+- [[#7747](https://github.com/apache/incubator-seata/pull/7747)] undo log 
table name dynamic derivation
 - [[#7749](https://github.com/apache/incubator-seata/pull/7749)] fix error 
parsing application/x-www-form-urlencoded requests in Http2HttpHandler
 
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 9d707fb830..d721c718e1 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -47,6 +47,7 @@
 - [[#7662](https://github.com/apache/incubator-seata/pull/7662)] 确保 rm 的可见性,并且 
MockTest 中的方法按顺序执行
 - [[#7683](https://github.com/apache/incubator-seata/pull/7683)] 重写 
XABranchXid的equals和hashCode,解决mysql driver内存泄漏问题
 - [[#7643](https://github.com/apache/incubator-seata/pull/7643)] 修复 DM 
事务回滚不使用数据库自动增量主键
+- [[#7747](https://github.com/apache/incubator-seata/pull/7747)] 
支持undo_log序列名动态推导
 - [[#7749](https://github.com/apache/incubator-seata/pull/7749)] 修复 
Http2HttpHandler 解析 application/x-www-form-urlencoded 请求失败的问题
 
 
@@ -69,7 +70,6 @@
 - [[#7722](https://github.com/apache/incubator-seata/pull/7722)] 优化 
SerializerType 枚举含义
 - [[#7741](https://github.com/apache/incubator-seata/pull/7741)] 支持发布基于JDK 
25的镜像
 - [[#7743](https://github.com/seata/seata/pull/7743)] 将 Apache Tomcat 依赖项从 
9.0.108 升级到 9.0.109
-
 - [[#7740](https://github.com/apache/incubator-seata/pull/7740)] 
优化http工具类使之支持h2c协议
 
 
diff --git 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManager.java
 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManager.java
index 60c7075aa8..f0ab78fb51 100644
--- 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManager.java
+++ 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManager.java
@@ -46,7 +46,7 @@ public class KingbaseUndoLogManager extends 
AbstractUndoLogManager {
             + ClientTableColumnsName.UNDO_LOG_XID + ", " + 
ClientTableColumnsName.UNDO_LOG_CONTEXT + ", "
             + ClientTableColumnsName.UNDO_LOG_ROLLBACK_INFO + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_STATUS + ", "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_MODIFIED + ")"
-            + "VALUES (UNDO_LOG_SEQ.nextval, ?, ?, ?, ?, ?, sysdate, sysdate)";
+            + "VALUES (" + UNDO_LOG_TABLE_NAME.toUpperCase() + "_SEQ.nextval, 
?, ?, ?, ?, ?, sysdate, sysdate)";
 
     private static final String DELETE_UNDO_LOG_BY_CREATE_SQL = "DELETE FROM " 
+ UNDO_LOG_TABLE_NAME + " WHERE "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + " <= 
to_date(?,'yyyy-mm-dd hh24:mi:ss') and ROWNUM <= ?";
diff --git 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManager.java
 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManager.java
index ae7a7e19fc..5adec584b3 100644
--- 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManager.java
+++ 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManager.java
@@ -44,7 +44,7 @@ public class OracleUndoLogManager extends 
AbstractUndoLogManager {
             + ClientTableColumnsName.UNDO_LOG_XID + ", " + 
ClientTableColumnsName.UNDO_LOG_CONTEXT + ", "
             + ClientTableColumnsName.UNDO_LOG_ROLLBACK_INFO + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_STATUS + ", "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_MODIFIED + ")"
-            + "VALUES (UNDO_LOG_SEQ.nextval, ?, ?, ?, ?, ?, sysdate, sysdate)";
+            + "VALUES (" + UNDO_LOG_TABLE_NAME.toUpperCase() + "_SEQ.nextval, 
?, ?, ?, ?, ?, sysdate, sysdate)";
 
     private static final String DELETE_UNDO_LOG_BY_CREATE_SQL = "DELETE FROM " 
+ UNDO_LOG_TABLE_NAME + " WHERE "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + " <= 
to_date(?,'yyyy-mm-dd hh24:mi:ss') and ROWNUM <= ?";
diff --git 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManager.java
 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManager.java
index 6e104510fc..3100764ca7 100644
--- 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManager.java
+++ 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManager.java
@@ -47,7 +47,7 @@ public class OscarUndoLogManager extends 
AbstractUndoLogManager {
             + ClientTableColumnsName.UNDO_LOG_XID + ", " + 
ClientTableColumnsName.UNDO_LOG_CONTEXT + ", "
             + ClientTableColumnsName.UNDO_LOG_ROLLBACK_INFO + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_STATUS + ", "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_MODIFIED + ")"
-            + "VALUES (UNDO_LOG_SEQ.nextval, ?, ?, ?, ?, ?, sysdate, sysdate)";
+            + "VALUES (" + UNDO_LOG_TABLE_NAME.toUpperCase() + "_SEQ.nextval, 
?, ?, ?, ?, ?, sysdate, sysdate)";
 
     private static final String DELETE_UNDO_LOG_BY_CREATE_SQL = "DELETE FROM " 
+ UNDO_LOG_TABLE_NAME + " WHERE "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + " <= 
to_date(?,'yyyy-mm-dd hh24:mi:ss') and ROWNUM <= ?";
diff --git 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManager.java
 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManager.java
index dce5ba1098..32b36d952f 100644
--- 
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManager.java
+++ 
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManager.java
@@ -40,7 +40,7 @@ public class PostgresqlUndoLogManager extends 
AbstractUndoLogManager {
             + ClientTableColumnsName.UNDO_LOG_XID + ", " + 
ClientTableColumnsName.UNDO_LOG_CONTEXT + ", "
             + ClientTableColumnsName.UNDO_LOG_ROLLBACK_INFO + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_STATUS + ", "
             + ClientTableColumnsName.UNDO_LOG_LOG_CREATED + ", " + 
ClientTableColumnsName.UNDO_LOG_LOG_MODIFIED + ")"
-            + "VALUES (nextval('undo_log_id_seq'), ?, ?, ?, ?, ?, now(), 
now())";
+            + "VALUES (nextval('" + UNDO_LOG_TABLE_NAME + "_id_seq'), ?, ?, ?, 
?, ?, now(), now())";
 
     private static final String DELETE_UNDO_LOG_BY_CREATE_SQL = "DELETE FROM " 
+ UNDO_LOG_TABLE_NAME + " WHERE "
             + ClientTableColumnsName.UNDO_LOG_ID + " IN ("
diff --git 
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManagerTest.java
 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManagerTest.java
new file mode 100644
index 0000000000..dce44b905a
--- /dev/null
+++ 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/kingbase/KingbaseUndoLogManagerTest.java
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.undo.kingbase;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.pool.DruidStatementConnection;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.seata.common.loader.EnhancedServiceLoader;
+import org.apache.seata.rm.datasource.ConnectionProxy;
+import org.apache.seata.rm.datasource.DataSourceProxy;
+import org.apache.seata.rm.datasource.DataSourceProxyTest;
+import org.apache.seata.rm.datasource.mock.MockDriver;
+import org.apache.seata.rm.datasource.sql.struct.Row;
+import org.apache.seata.rm.datasource.sql.struct.TableRecords;
+import org.apache.seata.rm.datasource.undo.AbstractUndoLogManager;
+import org.apache.seata.rm.datasource.undo.SQLUndoLog;
+import org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser;
+import org.apache.seata.sqlparser.SQLRecognizerFactory;
+import org.apache.seata.sqlparser.SQLType;
+import org.apache.seata.sqlparser.SqlParserType;
+import org.apache.seata.sqlparser.druid.DruidDelegatingSQLRecognizerFactory;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolder;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolderFactory;
+import org.apache.seata.sqlparser.struct.TableMeta;
+import org.apache.seata.sqlparser.util.JdbcConstants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class KingbaseUndoLogManagerTest {
+
+    List<String> returnValueColumnLabels = Lists.newArrayList("log_status");
+    Object[][] returnValue = new Object[][] {
+        new Object[] {1}, new Object[] {2},
+    };
+    Object[][] columnMetas = new Object[][] {
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "id",
+            Types.INTEGER,
+            "INTEGER",
+            64,
+            0,
+            10,
+            1,
+            "",
+            "",
+            0,
+            0,
+            64,
+            1,
+            "NO",
+            "YES"
+        },
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "name",
+            Types.VARCHAR,
+            "VARCHAR",
+            64,
+            0,
+            10,
+            0,
+            "",
+            "",
+            0,
+            0,
+            64,
+            2,
+            "YES",
+            "NO"
+        },
+    };
+    Object[][] indexMetas = new Object[][] {
+        new Object[] {"PRIMARY", "id", false, "", 3, 1, "A", 34},
+    };
+
+    private DruidDataSource dataSource;
+    private DataSourceProxy dataSourceProxy;
+    private ConnectionProxy connectionProxy;
+    private KingbaseUndoLogManager undoLogManager;
+    private TableMeta tableMeta;
+
+    @BeforeAll
+    public static void setup() {
+        EnhancedServiceLoader.load(
+                SQLOperateRecognizerHolder.class,
+                JdbcConstants.KINGBASE,
+                SQLOperateRecognizerHolderFactory.class.getClassLoader());
+        DruidDelegatingSQLRecognizerFactory recognizerFactory = 
(DruidDelegatingSQLRecognizerFactory)
+                EnhancedServiceLoader.load(SQLRecognizerFactory.class, 
SqlParserType.SQL_PARSER_TYPE_DRUID);
+    }
+
+    @BeforeEach
+    public void init() throws SQLException {
+        MockDriver mockDriver = new MockDriver(returnValueColumnLabels, 
returnValue, columnMetas, indexMetas);
+        dataSource = new DruidDataSource();
+        dataSource.setUrl("jdbc:mock:xxx");
+        dataSource.setDriver(mockDriver);
+
+        dataSourceProxy = DataSourceProxyTest.getDataSourceProxy(dataSource);
+
+        connectionProxy = new ConnectionProxy(dataSourceProxy, 
getPhysicsConnection(dataSource));
+        undoLogManager = new KingbaseUndoLogManager();
+        tableMeta = new TableMeta();
+        tableMeta.setTableName("table_plain_executor_test");
+    }
+
+    private Connection getPhysicsConnection(DruidDataSource dataSource) throws 
SQLException {
+        Connection connection = dataSource.getConnection().getConnection();
+        if (connection instanceof DruidStatementConnection) {
+            return ((DruidStatementConnection) connection).getConnection();
+        }
+        return connection;
+    }
+
+    @Test
+    public void testDeleteUndoLogByLogCreated() throws SQLException {
+        Assertions.assertEquals(
+                0, undoLogManager.deleteUndoLogByLogCreated(new Date(), 3000, 
dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.deleteUndoLogByLogCreated(new Date(), 
3000, connectionProxy));
+    }
+
+    @Test
+    public void testInsertUndoLog() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.insertUndoLogWithGlobalFinished(
+                "xid", 1L, new JacksonUndoLogParser(), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.insertUndoLogWithNormal("xid", 1L, "", 
new byte[] {}, dataSource.getConnection()));
+    }
+
+    @Test
+    public void testDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, connectionProxy));
+    }
+
+    @Test
+    public void testBatchDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> undoLogManager.batchDeleteUndoLog(
+                Sets.newHashSet("xid"), Sets.newHashSet(1L), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> 
undoLogManager.batchDeleteUndoLog(Sets.newHashSet("xid"), Sets.newHashSet(1L), 
connectionProxy));
+    }
+
+    @Test
+    public void testUndo() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.undo(dataSourceProxy, "xid", 1L));
+    }
+
+    /**
+     * Test sequence name generation with default table name (backward 
compatibility).
+     * Kingbase defaults to using undo_log table and UNDO_LOG_SEQ sequence.
+     */
+    @Test
+    public void testDefaultTableNameSequenceGeneration() throws Exception {
+        // Use reflection to access private INSERT_UNDO_LOG_SQL field
+        Field insertSqlField = 
KingbaseUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify default uses UNDO_LOG_SEQ (uppercase, following Kingbase 
community convention)
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should use UNDO_LOG_SEQ sequence (uppercase) by default. 
Actual SQL: " + insertSql);
+
+        // Verify SQL contains correct table name
+        Assertions.assertTrue(
+                insertSql.contains("INSERT INTO undo_log"),
+                "SQL should insert into undo_log table. Actual SQL: " + 
insertSql);
+
+        // Verify uses Kingbase-specific time function
+        Assertions.assertTrue(
+                insertSql.contains("sysdate"), "Kingbase should use sysdate 
time function. Actual SQL: " + insertSql);
+    }
+
+    /**
+     * Test that sequence name is derived from table name at class loading 
time.
+     * This test verifies the fix works by checking the actual static SQL 
contains the expected pattern.
+     * Kingbase convention: sequence names are converted to uppercase.
+     *
+     * Note: Since UNDO_LOG_TABLE_NAME and INSERT_UNDO_LOG_SQL are static 
final fields,
+     * they are initialized once at class loading time based on configuration.
+     * This test validates that the sequence name follows the pattern: 
{table_name}_SEQ (uppercase)
+     */
+    @Test
+    public void testSequenceNameDerivedFromTableName() throws Exception {
+        // Get the actual INSERT_UNDO_LOG_SQL that was constructed at class 
loading time
+        Field insertSqlField = 
KingbaseUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String actualInsertSql = (String) insertSqlField.get(null);
+
+        // Get the actual UNDO_LOG_TABLE_NAME that was loaded from 
configuration
+        Field undoLogTableNameField = 
AbstractUndoLogManager.class.getDeclaredField("UNDO_LOG_TABLE_NAME");
+        undoLogTableNameField.setAccessible(true);
+        String actualTableName = (String) undoLogTableNameField.get(null);
+
+        // Verify the sequence name follows the pattern: {table_name}_SEQ 
(uppercase for Kingbase)
+        String expectedSequenceName = actualTableName.toUpperCase() + "_SEQ";
+        String expectedSequenceCall = expectedSequenceName + ".nextval";
+
+        // Test that the INSERT SQL contains the properly derived sequence name
+        Assertions.assertTrue(
+                actualInsertSql.contains(expectedSequenceCall),
+                String.format(
+                        "INSERT SQL should contain sequence call '%s' for 
table '%s'. Actual SQL: %s",
+                        expectedSequenceCall, actualTableName, 
actualInsertSql));
+
+        // Verify the SQL uses the correct table name in INSERT statement
+        Assertions.assertTrue(
+                actualInsertSql.contains("INSERT INTO " + actualTableName),
+                String.format("INSERT SQL should target table '%s'. Actual 
SQL: %s", actualTableName, actualInsertSql));
+
+        // Verify Kingbase-specific characteristics
+        Assertions.assertTrue(
+                actualInsertSql.contains("sysdate"),
+                String.format("Kingbase should use sysdate time function. 
Actual SQL: %s", actualInsertSql));
+
+        // Test the pattern works for different theoretical table names 
(Kingbase uppercase convention)
+        String[] testTableNames = {"undo_log", "my_undo_log", "custom_table", 
"seata_undo"};
+        for (String testTableName : testTableNames) {
+            String testSequenceName = testTableName.toUpperCase() + "_SEQ";
+            String testSequenceCall = testSequenceName + ".nextval";
+
+            Assertions.assertEquals(
+                    testSequenceName,
+                    testTableName.toUpperCase() + "_SEQ",
+                    String.format(
+                            "Table '%s' should derive sequence '%s' (Kingbase 
uppercase convention)",
+                            testTableName, testSequenceName));
+        }
+    }
+
+    /**
+     * Test sequence name generation rules for various table names.
+     * Verify uppercase conversion following Kingbase convention.
+     */
+    @Test
+    public void testSequenceNameGenerationRules() {
+        // Test various table name formats - Kingbase convention converts to 
uppercase
+        String[][] testCases = {
+            {"undo_log", "UNDO_LOG_SEQ"}, // Default to uppercase
+            {"UNDO_LOG", "UNDO_LOG_SEQ"}, // Already uppercase
+            {"my_undo_log", "MY_UNDO_LOG_SEQ"}, // Custom to uppercase
+            {"MyUndoLog", "MYUNDOLOG_SEQ"}, // CamelCase to uppercase
+            {"CUSTOM_TABLE", "CUSTOM_TABLE_SEQ"}, // Already uppercase
+            {"seata_undo", "SEATA_UNDO_SEQ"} // Project prefix to uppercase
+        };
+
+        for (String[] testCase : testCases) {
+            String tableName = testCase[0];
+            String expectedSequence = testCase[1];
+
+            // Verify sequence name generation rule - Kingbase convention 
converts to uppercase
+            String actualSequence = tableName.toUpperCase() + "_SEQ";
+            Assertions.assertEquals(
+                    expectedSequence,
+                    actualSequence,
+                    String.format(
+                            "Table '%s' should generate sequence '%s' 
(following Kingbase uppercase convention)",
+                            tableName, expectedSequence));
+        }
+    }
+
+    /**
+     * Test backward compatibility - ensure existing deployments are not 
impacted.
+     */
+    @Test
+    public void testBackwardCompatibility() throws Exception {
+        // Verify default configuration behavior stays consistent
+        Field insertSqlField = 
KingbaseUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify key SQL components
+        Assertions.assertTrue(insertSql.contains("INSERT INTO undo_log"), 
"Should keep default table name 'undo_log'");
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should keep default sequence name 'UNDO_LOG_SEQ' 
(uppercase)");
+        Assertions.assertTrue(insertSql.contains("sysdate"), "Should keep 
Kingbase time function sysdate");
+
+        // Verify parameter placeholder count is correct
+        long parameterCount = insertSql.chars().filter(ch -> ch == 
'?').count();
+        Assertions.assertEquals(
+                5,
+                parameterCount,
+                "INSERT SQL should contain 5 parameter placeholders 
(branch_id, xid, context, rollback_info, log_status)");
+    }
+
+    /**
+     * Test comparison before and after fix - Kingbase-specific verification.
+     */
+    @Test
+    public void testFixComparison() {
+        System.out.println("\n=== Kingbase Sequence Name Fix Comparison ===");
+
+        // Before fix (hardcoded)
+        String oldSequenceName = "UNDO_LOG_SEQ";
+        System.out.println("Before: " + oldSequenceName + ".nextval - 
hardcoded uppercase");
+
+        // After fix (dynamically generated based on table name, following 
Kingbase uppercase convention)
+        String defaultTableName = "undo_log";
+        String newSequenceName = defaultTableName.toUpperCase() + "_SEQ";
+        System.out.println("After: " + newSequenceName
+                + ".nextval - dynamically generated, following Kingbase 
uppercase convention");
+
+        // Same result by default (backward compatible)
+        Assertions.assertEquals(
+                oldSequenceName,
+                newSequenceName,
+                "Before and after fix should be same with default config, 
ensuring backward compatibility");
+
+        // Custom table name scenario
+        String customTableName = "my_undo_log";
+        String customSequenceName = customTableName.toUpperCase() + "_SEQ";
+        System.out.println("Custom table: " + customSequenceName
+                + ".nextval - supports customization and follows Kingbase 
uppercase convention");
+
+        // Verify conversion to uppercase (following Kingbase community 
convention)
+        Assertions.assertEquals(
+                "MY_UNDO_LOG_SEQ",
+                customSequenceName,
+                "Custom table name should be converted to uppercase sequence 
name");
+        Assertions.assertNotEquals(
+                "my_undo_log_SEQ", customSequenceName, "Kingbase should 
convert sequence name to uppercase");
+    }
+
+    private SQLUndoLog getUndoLogItem(int size) throws NoSuchFieldException, 
IllegalAccessException {
+        SQLUndoLog sqlUndoLog = new SQLUndoLog();
+        sqlUndoLog.setTableName("table_plain_executor_test");
+        sqlUndoLog.setSqlType(SQLType.INSERT);
+        sqlUndoLog.setTableMeta(tableMeta);
+
+        Field rowsField = TableRecords.class.getDeclaredField("rows");
+        rowsField.setAccessible(true);
+
+        List<Row> rows = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            Row row = new Row();
+            row.add(new org.apache.seata.rm.datasource.sql.struct.Field("id", 
1, "value_id_" + i));
+            row.add(new 
org.apache.seata.rm.datasource.sql.struct.Field("name", 1, "value_name_" + i));
+            rows.add(row);
+        }
+
+        sqlUndoLog.setAfterImage(TableRecords.empty(tableMeta));
+        TableRecords afterImage = new TableRecords(tableMeta);
+        rowsField.set(afterImage, rows);
+        sqlUndoLog.setAfterImage(afterImage);
+
+        return sqlUndoLog;
+    }
+}
diff --git 
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManagerTest.java
 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManagerTest.java
new file mode 100644
index 0000000000..37fd193b35
--- /dev/null
+++ 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oracle/OracleUndoLogManagerTest.java
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.undo.oracle;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.pool.DruidStatementConnection;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.seata.common.loader.EnhancedServiceLoader;
+import org.apache.seata.rm.datasource.ConnectionProxy;
+import org.apache.seata.rm.datasource.DataSourceProxy;
+import org.apache.seata.rm.datasource.DataSourceProxyTest;
+import org.apache.seata.rm.datasource.mock.MockDriver;
+import org.apache.seata.rm.datasource.sql.struct.Row;
+import org.apache.seata.rm.datasource.sql.struct.TableRecords;
+import org.apache.seata.rm.datasource.undo.AbstractUndoLogManager;
+import org.apache.seata.rm.datasource.undo.SQLUndoLog;
+import org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser;
+import org.apache.seata.sqlparser.SQLRecognizerFactory;
+import org.apache.seata.sqlparser.SQLType;
+import org.apache.seata.sqlparser.SqlParserType;
+import org.apache.seata.sqlparser.druid.DruidDelegatingSQLRecognizerFactory;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolder;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolderFactory;
+import org.apache.seata.sqlparser.struct.TableMeta;
+import org.apache.seata.sqlparser.util.JdbcConstants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class OracleUndoLogManagerTest {
+
+    List<String> returnValueColumnLabels = Lists.newArrayList("log_status");
+    Object[][] returnValue = new Object[][] {
+        new Object[] {1}, new Object[] {2},
+    };
+    Object[][] columnMetas = new Object[][] {
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "id",
+            Types.INTEGER,
+            "INTEGER",
+            64,
+            0,
+            10,
+            1,
+            "",
+            "",
+            0,
+            0,
+            64,
+            1,
+            "NO",
+            "YES"
+        },
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "name",
+            Types.VARCHAR,
+            "VARCHAR",
+            64,
+            0,
+            10,
+            0,
+            "",
+            "",
+            0,
+            0,
+            64,
+            2,
+            "YES",
+            "NO"
+        },
+    };
+    Object[][] indexMetas = new Object[][] {
+        new Object[] {"PRIMARY", "id", false, "", 3, 1, "A", 34},
+    };
+
+    private DruidDataSource dataSource;
+    private DataSourceProxy dataSourceProxy;
+    private ConnectionProxy connectionProxy;
+    private OracleUndoLogManager undoLogManager;
+    private TableMeta tableMeta;
+
+    @BeforeAll
+    public static void setup() {
+        EnhancedServiceLoader.load(
+                SQLOperateRecognizerHolder.class,
+                JdbcConstants.ORACLE,
+                SQLOperateRecognizerHolderFactory.class.getClassLoader());
+        DruidDelegatingSQLRecognizerFactory recognizerFactory = 
(DruidDelegatingSQLRecognizerFactory)
+                EnhancedServiceLoader.load(SQLRecognizerFactory.class, 
SqlParserType.SQL_PARSER_TYPE_DRUID);
+    }
+
+    @BeforeEach
+    public void init() throws SQLException {
+        MockDriver mockDriver = new MockDriver(returnValueColumnLabels, 
returnValue, columnMetas, indexMetas);
+        dataSource = new DruidDataSource();
+        dataSource.setUrl("jdbc:mock:xxx");
+        dataSource.setDriver(mockDriver);
+
+        dataSourceProxy = DataSourceProxyTest.getDataSourceProxy(dataSource);
+
+        connectionProxy = new ConnectionProxy(dataSourceProxy, 
getPhysicsConnection(dataSource));
+        undoLogManager = new OracleUndoLogManager();
+        tableMeta = new TableMeta();
+        tableMeta.setTableName("table_plain_executor_test");
+    }
+
+    private Connection getPhysicsConnection(DruidDataSource dataSource) throws 
SQLException {
+        Connection connection = dataSource.getConnection().getConnection();
+        if (connection instanceof DruidStatementConnection) {
+            return ((DruidStatementConnection) connection).getConnection();
+        }
+        return connection;
+    }
+
+    @Test
+    public void testDeleteUndoLogByLogCreated() throws SQLException {
+        Assertions.assertEquals(
+                0, undoLogManager.deleteUndoLogByLogCreated(new Date(), 3000, 
dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.deleteUndoLogByLogCreated(new Date(), 
3000, connectionProxy));
+    }
+
+    @Test
+    public void testInsertUndoLog() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.insertUndoLogWithGlobalFinished(
+                "xid", 1L, new JacksonUndoLogParser(), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.insertUndoLogWithNormal("xid", 1L, "", 
new byte[] {}, dataSource.getConnection()));
+    }
+
+    @Test
+    public void testDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, connectionProxy));
+    }
+
+    @Test
+    public void testBatchDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> undoLogManager.batchDeleteUndoLog(
+                Sets.newHashSet("xid"), Sets.newHashSet(1L), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> 
undoLogManager.batchDeleteUndoLog(Sets.newHashSet("xid"), Sets.newHashSet(1L), 
connectionProxy));
+    }
+
+    @Test
+    public void testUndo() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.undo(dataSourceProxy, "xid", 1L));
+    }
+
+    /**
+     * Test sequence name generation with default table name (backward 
compatibility).
+     * Oracle defaults to using undo_log table and UNDO_LOG_SEQ sequence.
+     */
+    @Test
+    public void testDefaultTableNameSequenceGeneration() throws Exception {
+        // Use reflection to access private INSERT_UNDO_LOG_SQL field
+        Field insertSqlField = 
OracleUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify default uses UNDO_LOG_SEQ (uppercase, following Oracle 
community convention)
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should use UNDO_LOG_SEQ sequence (uppercase) by default. 
Actual SQL: " + insertSql);
+
+        // Verify SQL contains correct table name
+        Assertions.assertTrue(
+                insertSql.contains("INSERT INTO undo_log"),
+                "SQL should insert into undo_log table. Actual SQL: " + 
insertSql);
+
+        // Verify uses Oracle-specific time function
+        Assertions.assertTrue(
+                insertSql.contains("sysdate"), "Oracle should use sysdate time 
function. Actual SQL: " + insertSql);
+    }
+
+    /**
+     * Test that sequence name is derived from table name at class loading 
time.
+     * This test verifies the fix works by checking the actual static SQL 
contains the expected pattern.
+     * Oracle convention: sequence names are converted to uppercase.
+     *
+     * Note: Since UNDO_LOG_TABLE_NAME and INSERT_UNDO_LOG_SQL are static 
final fields,
+     * they are initialized once at class loading time based on configuration.
+     * This test validates that the sequence name follows the pattern: 
{table_name}_SEQ (uppercase)
+     */
+    @Test
+    public void testSequenceNameDerivedFromTableName() throws Exception {
+        // Get the actual INSERT_UNDO_LOG_SQL that was constructed at class 
loading time
+        Field insertSqlField = 
OracleUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String actualInsertSql = (String) insertSqlField.get(null);
+
+        // Get the actual UNDO_LOG_TABLE_NAME that was loaded from 
configuration
+        Field undoLogTableNameField = 
AbstractUndoLogManager.class.getDeclaredField("UNDO_LOG_TABLE_NAME");
+        undoLogTableNameField.setAccessible(true);
+        String actualTableName = (String) undoLogTableNameField.get(null);
+
+        // Verify the sequence name follows the pattern: {table_name}_SEQ 
(uppercase for Oracle)
+        String expectedSequenceName = actualTableName.toUpperCase() + "_SEQ";
+        String expectedSequenceCall = expectedSequenceName + ".nextval";
+
+        // Test that the INSERT SQL contains the properly derived sequence name
+        Assertions.assertTrue(
+                actualInsertSql.contains(expectedSequenceCall),
+                String.format(
+                        "INSERT SQL should contain sequence call '%s' for 
table '%s'. Actual SQL: %s",
+                        expectedSequenceCall, actualTableName, 
actualInsertSql));
+
+        // Verify the SQL uses the correct table name in INSERT statement
+        Assertions.assertTrue(
+                actualInsertSql.contains("INSERT INTO " + actualTableName),
+                String.format("INSERT SQL should target table '%s'. Actual 
SQL: %s", actualTableName, actualInsertSql));
+
+        // Verify Oracle-specific characteristics
+        Assertions.assertTrue(
+                actualInsertSql.contains("sysdate"),
+                String.format("Oracle should use sysdate time function. Actual 
SQL: %s", actualInsertSql));
+
+        // Test the pattern works for different theoretical table names 
(Oracle uppercase convention)
+        String[] testTableNames = {"undo_log", "my_undo_log", "custom_table", 
"seata_undo"};
+        for (String testTableName : testTableNames) {
+            String testSequenceName = testTableName.toUpperCase() + "_SEQ";
+            String testSequenceCall = testSequenceName + ".nextval";
+
+            Assertions.assertEquals(
+                    testSequenceName,
+                    testTableName.toUpperCase() + "_SEQ",
+                    String.format(
+                            "Table '%s' should derive sequence '%s' (Oracle 
uppercase convention)",
+                            testTableName, testSequenceName));
+        }
+    }
+
+    /**
+     * Test sequence name generation rules for various table names.
+     * Verify uppercase conversion following Oracle convention.
+     */
+    @Test
+    public void testSequenceNameGenerationRules() {
+        // Test various table name formats - Oracle convention converts to 
uppercase
+        String[][] testCases = {
+            {"undo_log", "UNDO_LOG_SEQ"}, // Default to uppercase
+            {"UNDO_LOG", "UNDO_LOG_SEQ"}, // Already uppercase
+            {"my_undo_log", "MY_UNDO_LOG_SEQ"}, // Custom to uppercase
+            {"MyUndoLog", "MYUNDOLOG_SEQ"}, // CamelCase to uppercase
+            {"CUSTOM_TABLE", "CUSTOM_TABLE_SEQ"}, // Already uppercase
+            {"seata_undo", "SEATA_UNDO_SEQ"} // Project prefix to uppercase
+        };
+
+        for (String[] testCase : testCases) {
+            String tableName = testCase[0];
+            String expectedSequence = testCase[1];
+
+            // Verify sequence name generation rule - Oracle convention 
converts to uppercase
+            String actualSequence = tableName.toUpperCase() + "_SEQ";
+            Assertions.assertEquals(
+                    expectedSequence,
+                    actualSequence,
+                    String.format(
+                            "Table '%s' should generate sequence '%s' 
(following Oracle uppercase convention)",
+                            tableName, expectedSequence));
+        }
+    }
+
+    /**
+     * Test backward compatibility - ensure existing deployments are not 
impacted.
+     */
+    @Test
+    public void testBackwardCompatibility() throws Exception {
+        // Verify default configuration behavior stays consistent
+        Field insertSqlField = 
OracleUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify key SQL components
+        Assertions.assertTrue(insertSql.contains("INSERT INTO undo_log"), 
"Should keep default table name 'undo_log'");
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should keep default sequence name 'UNDO_LOG_SEQ' 
(uppercase)");
+        Assertions.assertTrue(insertSql.contains("sysdate"), "Should keep 
Oracle time function sysdate");
+
+        // Verify parameter placeholder count is correct
+        long parameterCount = insertSql.chars().filter(ch -> ch == 
'?').count();
+        Assertions.assertEquals(
+                5,
+                parameterCount,
+                "INSERT SQL should contain 5 parameter placeholders 
(branch_id, xid, context, rollback_info, log_status)");
+    }
+
+    /**
+     * Test comparison before and after fix - Oracle-specific verification.
+     */
+    @Test
+    public void testFixComparison() {
+        System.out.println("\n=== Oracle Sequence Name Fix Comparison ===");
+
+        // Before fix (hardcoded)
+        String oldSequenceName = "UNDO_LOG_SEQ";
+        System.out.println("Before: " + oldSequenceName + ".nextval - 
hardcoded uppercase");
+
+        // After fix (dynamically generated based on table name, following 
Oracle uppercase convention)
+        String defaultTableName = "undo_log";
+        String newSequenceName = defaultTableName.toUpperCase() + "_SEQ";
+        System.out.println("After: " + newSequenceName
+                + ".nextval - dynamically generated, following Oracle 
uppercase convention");
+
+        // Same result by default (backward compatible)
+        Assertions.assertEquals(
+                oldSequenceName,
+                newSequenceName,
+                "Before and after fix should be same with default config, 
ensuring backward compatibility");
+
+        // Custom table name scenario
+        String customTableName = "my_undo_log";
+        String customSequenceName = customTableName.toUpperCase() + "_SEQ";
+        System.out.println("Custom table: " + customSequenceName
+                + ".nextval - supports customization and follows Oracle 
uppercase convention");
+
+        // Verify conversion to uppercase (following Oracle community 
convention)
+        Assertions.assertEquals(
+                "MY_UNDO_LOG_SEQ",
+                customSequenceName,
+                "Custom table name should be converted to uppercase sequence 
name");
+        Assertions.assertNotEquals(
+                "my_undo_log_SEQ", customSequenceName, "Oracle should convert 
sequence name to uppercase");
+    }
+
+    private SQLUndoLog getUndoLogItem(int size) throws NoSuchFieldException, 
IllegalAccessException {
+        SQLUndoLog sqlUndoLog = new SQLUndoLog();
+        sqlUndoLog.setTableName("table_plain_executor_test");
+        sqlUndoLog.setSqlType(SQLType.INSERT);
+        sqlUndoLog.setTableMeta(tableMeta);
+
+        Field rowsField = TableRecords.class.getDeclaredField("rows");
+        rowsField.setAccessible(true);
+
+        List<Row> rows = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            Row row = new Row();
+            row.add(new org.apache.seata.rm.datasource.sql.struct.Field("id", 
1, "value_id_" + i));
+            row.add(new 
org.apache.seata.rm.datasource.sql.struct.Field("name", 1, "value_name_" + i));
+            rows.add(row);
+        }
+
+        sqlUndoLog.setAfterImage(TableRecords.empty(tableMeta));
+        TableRecords afterImage = new TableRecords(tableMeta);
+        rowsField.set(afterImage, rows);
+        sqlUndoLog.setAfterImage(afterImage);
+
+        return sqlUndoLog;
+    }
+}
diff --git 
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManagerTest.java
 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManagerTest.java
new file mode 100644
index 0000000000..235222905b
--- /dev/null
+++ 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/oscar/OscarUndoLogManagerTest.java
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.undo.oscar;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.pool.DruidStatementConnection;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.seata.common.loader.EnhancedServiceLoader;
+import org.apache.seata.rm.datasource.ConnectionProxy;
+import org.apache.seata.rm.datasource.DataSourceProxy;
+import org.apache.seata.rm.datasource.DataSourceProxyTest;
+import org.apache.seata.rm.datasource.mock.MockDriver;
+import org.apache.seata.rm.datasource.sql.struct.Row;
+import org.apache.seata.rm.datasource.sql.struct.TableRecords;
+import org.apache.seata.rm.datasource.undo.AbstractUndoLogManager;
+import org.apache.seata.rm.datasource.undo.SQLUndoLog;
+import org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser;
+import org.apache.seata.sqlparser.SQLRecognizerFactory;
+import org.apache.seata.sqlparser.SQLType;
+import org.apache.seata.sqlparser.SqlParserType;
+import org.apache.seata.sqlparser.druid.DruidDelegatingSQLRecognizerFactory;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolder;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolderFactory;
+import org.apache.seata.sqlparser.struct.TableMeta;
+import org.apache.seata.sqlparser.util.JdbcConstants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class OscarUndoLogManagerTest {
+
+    List<String> returnValueColumnLabels = Lists.newArrayList("log_status");
+    Object[][] returnValue = new Object[][] {
+        new Object[] {1}, new Object[] {2},
+    };
+    Object[][] columnMetas = new Object[][] {
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "id",
+            Types.INTEGER,
+            "INTEGER",
+            64,
+            0,
+            10,
+            1,
+            "",
+            "",
+            0,
+            0,
+            64,
+            1,
+            "NO",
+            "YES"
+        },
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "name",
+            Types.VARCHAR,
+            "VARCHAR",
+            64,
+            0,
+            10,
+            0,
+            "",
+            "",
+            0,
+            0,
+            64,
+            2,
+            "YES",
+            "NO"
+        },
+    };
+    Object[][] indexMetas = new Object[][] {
+        new Object[] {"PRIMARY", "id", false, "", 3, 1, "A", 34},
+    };
+
+    private DruidDataSource dataSource;
+    private DataSourceProxy dataSourceProxy;
+    private ConnectionProxy connectionProxy;
+    private OscarUndoLogManager undoLogManager;
+    private TableMeta tableMeta;
+
+    @BeforeAll
+    public static void setup() {
+        EnhancedServiceLoader.load(
+                SQLOperateRecognizerHolder.class,
+                JdbcConstants.OSCAR,
+                SQLOperateRecognizerHolderFactory.class.getClassLoader());
+        DruidDelegatingSQLRecognizerFactory recognizerFactory = 
(DruidDelegatingSQLRecognizerFactory)
+                EnhancedServiceLoader.load(SQLRecognizerFactory.class, 
SqlParserType.SQL_PARSER_TYPE_DRUID);
+    }
+
+    @BeforeEach
+    public void init() throws SQLException {
+        MockDriver mockDriver = new MockDriver(returnValueColumnLabels, 
returnValue, columnMetas, indexMetas);
+        dataSource = new DruidDataSource();
+        dataSource.setUrl("jdbc:mock:xxx");
+        dataSource.setDriver(mockDriver);
+
+        dataSourceProxy = DataSourceProxyTest.getDataSourceProxy(dataSource);
+
+        connectionProxy = new ConnectionProxy(dataSourceProxy, 
getPhysicsConnection(dataSource));
+        undoLogManager = new OscarUndoLogManager();
+        tableMeta = new TableMeta();
+        tableMeta.setTableName("table_plain_executor_test");
+    }
+
+    private Connection getPhysicsConnection(DruidDataSource dataSource) throws 
SQLException {
+        Connection connection = dataSource.getConnection().getConnection();
+        if (connection instanceof DruidStatementConnection) {
+            return ((DruidStatementConnection) connection).getConnection();
+        }
+        return connection;
+    }
+
+    @Test
+    public void testDeleteUndoLogByLogCreated() throws SQLException {
+        Assertions.assertEquals(
+                0, undoLogManager.deleteUndoLogByLogCreated(new Date(), 3000, 
dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.deleteUndoLogByLogCreated(new Date(), 
3000, connectionProxy));
+    }
+
+    @Test
+    public void testInsertUndoLog() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.insertUndoLogWithGlobalFinished(
+                "xid", 1L, new JacksonUndoLogParser(), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.insertUndoLogWithNormal("xid", 1L, "", 
new byte[] {}, dataSource.getConnection()));
+    }
+
+    @Test
+    public void testDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, connectionProxy));
+    }
+
+    @Test
+    public void testBatchDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> undoLogManager.batchDeleteUndoLog(
+                Sets.newHashSet("xid"), Sets.newHashSet(1L), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> 
undoLogManager.batchDeleteUndoLog(Sets.newHashSet("xid"), Sets.newHashSet(1L), 
connectionProxy));
+    }
+
+    @Test
+    public void testUndo() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.undo(dataSourceProxy, "xid", 1L));
+    }
+
+    /**
+     * Test sequence name generation with default table name (backward 
compatibility).
+     * Oscar defaults to using undo_log table and UNDO_LOG_SEQ sequence.
+     */
+    @Test
+    public void testDefaultTableNameSequenceGeneration() throws Exception {
+        // Use reflection to access private INSERT_UNDO_LOG_SQL field
+        Field insertSqlField = 
OscarUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify default uses UNDO_LOG_SEQ (uppercase, following Oscar 
community convention)
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should use UNDO_LOG_SEQ sequence (uppercase) by default. 
Actual SQL: " + insertSql);
+
+        // Verify SQL contains correct table name
+        Assertions.assertTrue(
+                insertSql.contains("INSERT INTO undo_log"),
+                "SQL should insert into undo_log table. Actual SQL: " + 
insertSql);
+
+        // Verify uses Oscar-specific time function
+        Assertions.assertTrue(
+                insertSql.contains("sysdate"), "Oscar should use sysdate time 
function. Actual SQL: " + insertSql);
+    }
+
+    /**
+     * Test that sequence name is derived from table name at class loading 
time.
+     * This test verifies the fix works by checking the actual static SQL 
contains the expected pattern.
+     * Oscar convention: sequence names are converted to uppercase.
+     *
+     * Note: Since UNDO_LOG_TABLE_NAME and INSERT_UNDO_LOG_SQL are static 
final fields,
+     * they are initialized once at class loading time based on configuration.
+     * This test validates that the sequence name follows the pattern: 
{table_name}_SEQ (uppercase)
+     */
+    @Test
+    public void testSequenceNameDerivedFromTableName() throws Exception {
+        // Get the actual INSERT_UNDO_LOG_SQL that was constructed at class 
loading time
+        Field insertSqlField = 
OscarUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String actualInsertSql = (String) insertSqlField.get(null);
+
+        // Get the actual UNDO_LOG_TABLE_NAME that was loaded from 
configuration
+        Field undoLogTableNameField = 
AbstractUndoLogManager.class.getDeclaredField("UNDO_LOG_TABLE_NAME");
+        undoLogTableNameField.setAccessible(true);
+        String actualTableName = (String) undoLogTableNameField.get(null);
+
+        // Verify the sequence name follows the pattern: {table_name}_SEQ 
(uppercase for Oscar)
+        String expectedSequenceName = actualTableName.toUpperCase() + "_SEQ";
+        String expectedSequenceCall = expectedSequenceName + ".nextval";
+
+        // Test that the INSERT SQL contains the properly derived sequence name
+        Assertions.assertTrue(
+                actualInsertSql.contains(expectedSequenceCall),
+                String.format(
+                        "INSERT SQL should contain sequence call '%s' for 
table '%s'. Actual SQL: %s",
+                        expectedSequenceCall, actualTableName, 
actualInsertSql));
+
+        // Verify the SQL uses the correct table name in INSERT statement
+        Assertions.assertTrue(
+                actualInsertSql.contains("INSERT INTO " + actualTableName),
+                String.format("INSERT SQL should target table '%s'. Actual 
SQL: %s", actualTableName, actualInsertSql));
+
+        // Verify Oscar-specific characteristics
+        Assertions.assertTrue(
+                actualInsertSql.contains("sysdate"),
+                String.format("Oscar should use sysdate time function. Actual 
SQL: %s", actualInsertSql));
+
+        // Test the pattern works for different theoretical table names (Oscar 
uppercase convention)
+        String[] testTableNames = {"undo_log", "my_undo_log", "custom_table", 
"seata_undo"};
+        for (String testTableName : testTableNames) {
+            String testSequenceName = testTableName.toUpperCase() + "_SEQ";
+            String testSequenceCall = testSequenceName + ".nextval";
+
+            Assertions.assertEquals(
+                    testSequenceName,
+                    testTableName.toUpperCase() + "_SEQ",
+                    String.format(
+                            "Table '%s' should derive sequence '%s' (Oscar 
uppercase convention)",
+                            testTableName, testSequenceName));
+        }
+    }
+
+    /**
+     * Test sequence name generation rules for various table names.
+     * Verify uppercase conversion following Oscar convention.
+     */
+    @Test
+    public void testSequenceNameGenerationRules() {
+        // Test various table name formats - Oscar convention converts to 
uppercase
+        String[][] testCases = {
+            {"undo_log", "UNDO_LOG_SEQ"}, // Default to uppercase
+            {"UNDO_LOG", "UNDO_LOG_SEQ"}, // Already uppercase
+            {"my_undo_log", "MY_UNDO_LOG_SEQ"}, // Custom to uppercase
+            {"MyUndoLog", "MYUNDOLOG_SEQ"}, // CamelCase to uppercase
+            {"CUSTOM_TABLE", "CUSTOM_TABLE_SEQ"}, // Already uppercase
+            {"seata_undo", "SEATA_UNDO_SEQ"} // Project prefix to uppercase
+        };
+
+        for (String[] testCase : testCases) {
+            String tableName = testCase[0];
+            String expectedSequence = testCase[1];
+
+            // Verify sequence name generation rule - Oscar convention 
converts to uppercase
+            String actualSequence = tableName.toUpperCase() + "_SEQ";
+            Assertions.assertEquals(
+                    expectedSequence,
+                    actualSequence,
+                    String.format(
+                            "Table '%s' should generate sequence '%s' 
(following Oscar uppercase convention)",
+                            tableName, expectedSequence));
+        }
+    }
+
+    /**
+     * Test backward compatibility - ensure existing deployments are not 
impacted.
+     */
+    @Test
+    public void testBackwardCompatibility() throws Exception {
+        // Verify default configuration behavior stays consistent
+        Field insertSqlField = 
OscarUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify key SQL components
+        Assertions.assertTrue(insertSql.contains("INSERT INTO undo_log"), 
"Should keep default table name 'undo_log'");
+        Assertions.assertTrue(
+                insertSql.contains("UNDO_LOG_SEQ.nextval"),
+                "Should keep default sequence name 'UNDO_LOG_SEQ' 
(uppercase)");
+        Assertions.assertTrue(insertSql.contains("sysdate"), "Should keep 
Oscar time function sysdate");
+
+        // Verify parameter placeholder count is correct
+        long parameterCount = insertSql.chars().filter(ch -> ch == 
'?').count();
+        Assertions.assertEquals(
+                5,
+                parameterCount,
+                "INSERT SQL should contain 5 parameter placeholders 
(branch_id, xid, context, rollback_info, log_status)");
+    }
+
+    /**
+     * Test comparison before and after fix - Oscar-specific verification.
+     */
+    @Test
+    public void testFixComparison() {
+        System.out.println("\n=== Oscar Sequence Name Fix Comparison ===");
+
+        // Before fix (hardcoded)
+        String oldSequenceName = "UNDO_LOG_SEQ";
+        System.out.println("Before: " + oldSequenceName + ".nextval - 
hardcoded uppercase");
+
+        // After fix (dynamically generated based on table name, following 
Oscar uppercase convention)
+        String defaultTableName = "undo_log";
+        String newSequenceName = defaultTableName.toUpperCase() + "_SEQ";
+        System.out.println(
+                "After: " + newSequenceName + ".nextval - dynamically 
generated, following Oscar uppercase convention");
+
+        // Same result by default (backward compatible)
+        Assertions.assertEquals(
+                oldSequenceName,
+                newSequenceName,
+                "Before and after fix should be same with default config, 
ensuring backward compatibility");
+
+        // Custom table name scenario
+        String customTableName = "my_undo_log";
+        String customSequenceName = customTableName.toUpperCase() + "_SEQ";
+        System.out.println("Custom table: " + customSequenceName
+                + ".nextval - supports customization and follows Oscar 
uppercase convention");
+
+        // Verify conversion to uppercase (following Oscar community 
convention)
+        Assertions.assertEquals(
+                "MY_UNDO_LOG_SEQ",
+                customSequenceName,
+                "Custom table name should be converted to uppercase sequence 
name");
+        Assertions.assertNotEquals(
+                "my_undo_log_SEQ", customSequenceName, "Oscar should convert 
sequence name to uppercase");
+    }
+
+    private SQLUndoLog getUndoLogItem(int size) throws NoSuchFieldException, 
IllegalAccessException {
+        SQLUndoLog sqlUndoLog = new SQLUndoLog();
+        sqlUndoLog.setTableName("table_plain_executor_test");
+        sqlUndoLog.setSqlType(SQLType.INSERT);
+        sqlUndoLog.setTableMeta(tableMeta);
+
+        Field rowsField = TableRecords.class.getDeclaredField("rows");
+        rowsField.setAccessible(true);
+
+        List<Row> rows = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            Row row = new Row();
+            row.add(new org.apache.seata.rm.datasource.sql.struct.Field("id", 
1, "value_id_" + i));
+            row.add(new 
org.apache.seata.rm.datasource.sql.struct.Field("name", 1, "value_name_" + i));
+            rows.add(row);
+        }
+
+        sqlUndoLog.setAfterImage(TableRecords.empty(tableMeta));
+        TableRecords afterImage = new TableRecords(tableMeta);
+        rowsField.set(afterImage, rows);
+        sqlUndoLog.setAfterImage(afterImage);
+
+        return sqlUndoLog;
+    }
+}
diff --git 
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManagerTest.java
 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManagerTest.java
new file mode 100644
index 0000000000..dccaa8b60a
--- /dev/null
+++ 
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/postgresql/PostgresqlUndoLogManagerTest.java
@@ -0,0 +1,345 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.undo.postgresql;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.pool.DruidStatementConnection;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.seata.common.loader.EnhancedServiceLoader;
+import org.apache.seata.rm.datasource.ConnectionProxy;
+import org.apache.seata.rm.datasource.DataSourceProxy;
+import org.apache.seata.rm.datasource.DataSourceProxyTest;
+import org.apache.seata.rm.datasource.mock.MockDriver;
+import org.apache.seata.rm.datasource.sql.struct.Row;
+import org.apache.seata.rm.datasource.sql.struct.TableRecords;
+import org.apache.seata.rm.datasource.undo.AbstractUndoLogManager;
+import org.apache.seata.rm.datasource.undo.SQLUndoLog;
+import org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser;
+import org.apache.seata.sqlparser.SQLRecognizerFactory;
+import org.apache.seata.sqlparser.SQLType;
+import org.apache.seata.sqlparser.SqlParserType;
+import org.apache.seata.sqlparser.druid.DruidDelegatingSQLRecognizerFactory;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolder;
+import org.apache.seata.sqlparser.druid.SQLOperateRecognizerHolderFactory;
+import org.apache.seata.sqlparser.struct.TableMeta;
+import org.apache.seata.sqlparser.util.JdbcConstants;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class PostgresqlUndoLogManagerTest {
+
+    List<String> returnValueColumnLabels = Lists.newArrayList("log_status");
+    Object[][] returnValue = new Object[][] {
+        new Object[] {1}, new Object[] {2},
+    };
+    Object[][] columnMetas = new Object[][] {
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "id",
+            Types.INTEGER,
+            "INTEGER",
+            64,
+            0,
+            10,
+            1,
+            "",
+            "",
+            0,
+            0,
+            64,
+            1,
+            "NO",
+            "YES"
+        },
+        new Object[] {
+            "",
+            "",
+            "table_plain_executor_test",
+            "name",
+            Types.VARCHAR,
+            "VARCHAR",
+            64,
+            0,
+            10,
+            0,
+            "",
+            "",
+            0,
+            0,
+            64,
+            2,
+            "YES",
+            "NO"
+        },
+    };
+    Object[][] indexMetas = new Object[][] {
+        new Object[] {"PRIMARY", "id", false, "", 3, 1, "A", 34},
+    };
+
+    private DruidDataSource dataSource;
+    private DataSourceProxy dataSourceProxy;
+    private ConnectionProxy connectionProxy;
+    private PostgresqlUndoLogManager undoLogManager;
+    private TableMeta tableMeta;
+
+    @BeforeAll
+    public static void setup() {
+        EnhancedServiceLoader.load(
+                SQLOperateRecognizerHolder.class,
+                JdbcConstants.POSTGRESQL,
+                SQLOperateRecognizerHolderFactory.class.getClassLoader());
+        DruidDelegatingSQLRecognizerFactory recognizerFactory = 
(DruidDelegatingSQLRecognizerFactory)
+                EnhancedServiceLoader.load(SQLRecognizerFactory.class, 
SqlParserType.SQL_PARSER_TYPE_DRUID);
+    }
+
+    @BeforeEach
+    public void init() throws SQLException {
+        MockDriver mockDriver = new MockDriver(returnValueColumnLabels, 
returnValue, columnMetas, indexMetas);
+        dataSource = new DruidDataSource();
+        dataSource.setUrl("jdbc:mock:xxx");
+        dataSource.setDriver(mockDriver);
+
+        dataSourceProxy = DataSourceProxyTest.getDataSourceProxy(dataSource);
+
+        connectionProxy = new ConnectionProxy(dataSourceProxy, 
getPhysicsConnection(dataSource));
+        undoLogManager = new PostgresqlUndoLogManager();
+        tableMeta = new TableMeta();
+        tableMeta.setTableName("table_plain_executor_test");
+    }
+
+    private Connection getPhysicsConnection(DruidDataSource dataSource) throws 
SQLException {
+        Connection connection = dataSource.getConnection().getConnection();
+        if (connection instanceof DruidStatementConnection) {
+            return ((DruidStatementConnection) connection).getConnection();
+        }
+        return connection;
+    }
+
+    @Test
+    public void testDeleteUndoLogByLogCreated() throws SQLException {
+        Assertions.assertEquals(
+                0, undoLogManager.deleteUndoLogByLogCreated(new Date(), 3000, 
dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.deleteUndoLogByLogCreated(new Date(), 
3000, connectionProxy));
+    }
+
+    @Test
+    public void testInsertUndoLog() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.insertUndoLogWithGlobalFinished(
+                "xid", 1L, new JacksonUndoLogParser(), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> undoLogManager.insertUndoLogWithNormal("xid", 1L, "", 
new byte[] {}, dataSource.getConnection()));
+    }
+
+    @Test
+    public void testDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, dataSource.getConnection()));
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.deleteUndoLog("xid", 1L, connectionProxy));
+    }
+
+    @Test
+    public void testBatchDeleteUndoLog() {
+        Assertions.assertDoesNotThrow(() -> undoLogManager.batchDeleteUndoLog(
+                Sets.newHashSet("xid"), Sets.newHashSet(1L), 
dataSource.getConnection()));
+
+        Assertions.assertDoesNotThrow(
+                () -> 
undoLogManager.batchDeleteUndoLog(Sets.newHashSet("xid"), Sets.newHashSet(1L), 
connectionProxy));
+    }
+
+    @Test
+    public void testUndo() throws SQLException {
+        Assertions.assertDoesNotThrow(() -> 
undoLogManager.undo(dataSourceProxy, "xid", 1L));
+    }
+
+    /**
+     * Test sequence name generation with default table name (backward 
compatibility).
+     * Focus of the fix: using default table name "undo_log" should generate 
"undo_log_id_seq".
+     */
+    @Test
+    public void testDefaultTableNameSequenceGeneration() throws Exception {
+        // Use reflection to access private INSERT_UNDO_LOG_SQL field
+        Field insertSqlField = 
PostgresqlUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify default uses undo_log_id_seq
+        Assertions.assertTrue(
+                insertSql.contains("nextval('undo_log_id_seq')"),
+                "Should use undo_log_id_seq by default. Actual SQL: " + 
insertSql);
+
+        // Verify SQL contains correct table name
+        Assertions.assertTrue(
+                insertSql.contains("INSERT INTO undo_log"),
+                "SQL should insert into undo_log. Actual SQL: " + insertSql);
+    }
+
+    /**
+     * Test that sequence name is derived from table name at class loading 
time.
+     * This test verifies the fix works by checking the actual static SQL 
contains the expected pattern.
+     *
+     * Note: Since UNDO_LOG_TABLE_NAME and INSERT_UNDO_LOG_SQL are static 
final fields,
+     * they are initialized once at class loading time based on configuration.
+     * This test validates that the sequence name follows the pattern: 
{table_name}_id_seq
+     */
+    @Test
+    public void testSequenceNameDerivedFromTableName() throws Exception {
+        // Get the actual INSERT_UNDO_LOG_SQL that was constructed at class 
loading time
+        Field insertSqlField = 
PostgresqlUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String actualInsertSql = (String) insertSqlField.get(null);
+
+        // Get the actual UNDO_LOG_TABLE_NAME that was loaded from 
configuration
+        Field undoLogTableNameField = 
AbstractUndoLogManager.class.getDeclaredField("UNDO_LOG_TABLE_NAME");
+        undoLogTableNameField.setAccessible(true);
+        String actualTableName = (String) undoLogTableNameField.get(null);
+
+        // Verify the sequence name follows the pattern: {table_name}_id_seq
+        String expectedSequenceName = actualTableName + "_id_seq";
+        String expectedSequenceCall = "nextval('" + expectedSequenceName + 
"')";
+
+        // Test that the INSERT SQL contains the properly derived sequence name
+        Assertions.assertTrue(
+                actualInsertSql.contains(expectedSequenceCall),
+                String.format(
+                        "INSERT SQL should contain sequence call '%s' for 
table '%s'. Actual SQL: %s",
+                        expectedSequenceCall, actualTableName, 
actualInsertSql));
+
+        // Verify the SQL uses the correct table name in INSERT statement
+        Assertions.assertTrue(
+                actualInsertSql.contains("INSERT INTO " + actualTableName),
+                String.format("INSERT SQL should target table '%s'. Actual 
SQL: %s", actualTableName, actualInsertSql));
+
+        // Test the pattern works for different theoretical table names
+        String[] testTableNames = {"undo_log", "my_undo_log", "custom_table", 
"seata_undo"};
+        for (String testTableName : testTableNames) {
+            String testSequenceName = testTableName + "_id_seq";
+            String testSequenceCall = "nextval('" + testSequenceName + "')";
+
+            Assertions.assertEquals(
+                    testSequenceName,
+                    testTableName + "_id_seq",
+                    String.format("Table '%s' should derive sequence '%s'", 
testTableName, testSequenceName));
+        }
+    }
+
+    /**
+     * Test sequence name generation rules for various table names.
+     */
+    @Test
+    public void testSequenceNameGenerationRules() {
+        // Various table name formats
+        String[][] testCases = {
+            {"undo_log", "undo_log_id_seq"},
+            {"my_undo_log", "my_undo_log_id_seq"},
+            {"custom_table", "custom_table_id_seq"},
+            {"app_undo_logs", "app_undo_logs_id_seq"},
+            {"seata_undo", "seata_undo_id_seq"}
+        };
+
+        for (String[] testCase : testCases) {
+            String tableName = testCase[0];
+            String expectedSequence = testCase[1];
+
+            // Verify the sequence name rule
+            String actualSequence = tableName + "_id_seq";
+            Assertions.assertEquals(
+                    expectedSequence,
+                    actualSequence,
+                    String.format("Table '%s' should generate sequence '%s'", 
tableName, expectedSequence));
+        }
+    }
+
+    /**
+     * IMPORTANT: Testing real dynamic configuration changes
+     *
+     * The current implementation uses static final fields that are 
initialized at class loading time.
+     * To truly test dynamic table name configuration, you would need 
integration tests with:
+     *
+     * 1. Multiple JVM instances with different configurations
+     * 2. Separate test processes that load classes with different config files
+     * 3. Custom classloader that can reload classes with new configuration
+     *
+     * Example integration test approach:
+     * - Create test-config-1.properties with: 
seata.client.undo.log.table=undo_log
+     * - Create test-config-2.properties with: 
seata.client.undo.log.table=my_undo_log
+     * - Run separate test processes that load these configs before class 
loading
+     * - Verify each process generates the correct SQL with proper sequence 
names
+     */
+
+    /**
+     * Test backward compatibility - ensure existing deployments are not 
impacted.
+     */
+    @Test
+    public void testBackwardCompatibility() throws Exception {
+        // Verify default behavior stays the same
+        Field insertSqlField = 
PostgresqlUndoLogManager.class.getDeclaredField("INSERT_UNDO_LOG_SQL");
+        insertSqlField.setAccessible(true);
+        String insertSql = (String) insertSqlField.get(null);
+
+        // Verify key SQL parts
+        Assertions.assertTrue(insertSql.contains("INSERT INTO undo_log"), 
"Should keep default table name 'undo_log'");
+        Assertions.assertTrue(
+                insertSql.contains("nextval('undo_log_id_seq')"), "Should keep 
default sequence 'undo_log_id_seq'");
+        Assertions.assertTrue(insertSql.contains("now(), now()"), "Should keep 
PostgreSQL time function now()");
+
+        // Verify parameter placeholder count is correct
+        long parameterCount = insertSql.chars().filter(ch -> ch == 
'?').count();
+        Assertions.assertEquals(
+                5,
+                parameterCount,
+                "INSERT SQL should contain 5 placeholders (branch_id, xid, 
context, rollback_info, log_status)");
+    }
+
+    private SQLUndoLog getUndoLogItem(int size) throws NoSuchFieldException, 
IllegalAccessException {
+        SQLUndoLog sqlUndoLog = new SQLUndoLog();
+        sqlUndoLog.setTableName("table_plain_executor_test");
+        sqlUndoLog.setSqlType(SQLType.INSERT);
+        sqlUndoLog.setTableMeta(tableMeta);
+
+        Field rowsField = TableRecords.class.getDeclaredField("rows");
+        rowsField.setAccessible(true);
+
+        List<Row> rows = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            Row row = new Row();
+            row.add(new org.apache.seata.rm.datasource.sql.struct.Field("id", 
1, "value_id_" + i));
+            row.add(new 
org.apache.seata.rm.datasource.sql.struct.Field("name", 1, "value_name_" + i));
+            rows.add(row);
+        }
+
+        sqlUndoLog.setAfterImage(TableRecords.empty(tableMeta));
+        TableRecords afterImage = new TableRecords(tableMeta);
+        rowsField.set(afterImage, rows);
+        sqlUndoLog.setAfterImage(afterImage);
+
+        return sqlUndoLog;
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to