Skip to content

Commit

Permalink
bugfix: getQueryGlobalTransactionSQLByStatus method do not support or…
Browse files Browse the repository at this point in the history
…acle (apache#1615)
  • Loading branch information
tq02ksu committed Sep 10, 2019
1 parent d334f85 commit 26b9875
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions core/src/main/java/io/seata/core/store/db/LogStoreSqls.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,19 @@ public class LogStoreSqls {
/**
* The constant QUERY_GLOBAL_TRANSACTION_BY_STATUS.
*/
public static final String QUERY_GLOBAL_TRANSACTION_BY_STATUS = "select " + ALL_GLOBAL_COLUMNS + " from "
+ GLOBAL_TABLE_PLACEHOLD +
" where " + ServerTableColumnsName.GLOBAL_TABLE_STATUS + " in (" + PRAMETER_PLACEHOLD + ") order by " + ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED + " limit ?";
public static final String QUERY_GLOBAL_TRANSACTION_BY_STATUS_MYSQL =
"select " + ALL_GLOBAL_COLUMNS + " from " + GLOBAL_TABLE_PLACEHOLD
+ " where " + ServerTableColumnsName.GLOBAL_TABLE_STATUS + " in (" + PRAMETER_PLACEHOLD + ")"
+ " order by " + ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED + " limit ?";

public static final String QUERY_GLOBAL_TRANSACTION_BY_STATUS_ORACLE =
"select * from ("
+ " select tt.*, ROWNUM as rowno from ("
+ " select " + ALL_GLOBAL_COLUMNS + " from " + GLOBAL_TABLE_PLACEHOLD
+ " where " + ServerTableColumnsName.GLOBAL_TABLE_STATUS + " in (" + PRAMETER_PLACEHOLD + ")"
+ " order by " + ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED + ") tt"
+ " where ROWNUM <= ?) table_alias"
+ " where table_alias.rowno >= 0";
/**
* The constant QUERY_GLOBAL_TRANSACTION_FOR_RECOVERY_MYSQL.
*/
Expand Down Expand Up @@ -257,8 +267,15 @@ public static String getQueryGlobalTransactionSQLByTransactionId(String globalTa
*/
public static String getQueryGlobalTransactionSQLByStatus(String globalTable, String dbType,
String paramsPlaceHolder) {
return QUERY_GLOBAL_TRANSACTION_BY_STATUS.replace(GLOBAL_TABLE_PLACEHOLD, globalTable).replace(
PRAMETER_PLACEHOLD, paramsPlaceHolder);
if (DBType.MYSQL.name().equalsIgnoreCase(dbType)) {
return QUERY_GLOBAL_TRANSACTION_BY_STATUS_MYSQL.replace(GLOBAL_TABLE_PLACEHOLD, globalTable).replace(
PRAMETER_PLACEHOLD, paramsPlaceHolder);
} else if (DBType.ORACLE.name().equalsIgnoreCase(dbType)) {
return QUERY_GLOBAL_TRANSACTION_BY_STATUS_ORACLE.replace(GLOBAL_TABLE_PLACEHOLD, globalTable).replace(
PRAMETER_PLACEHOLD, paramsPlaceHolder);
} else {
throw new IllegalArgumentException("unknown database type");
}
}

/**
Expand Down

0 comments on commit 26b9875

Please sign in to comment.