IDEMPIERE-6100 Table Partitioning Issue with Tables having Index with where condition (#2307)

This commit is contained in:
hengsin 2024-04-11 01:16:28 +08:00 committed by Carlos Ruiz
parent adea9db390
commit 76edaa9e1d
1 changed files with 11 additions and 2 deletions

View File

@ -235,8 +235,17 @@ public class TablePartitionService implements ITablePartitionService {
//unique index must include partition key column
String indexdef = uniqueMap.get(indexName);
for(String partitionKey : partitionKeyColumnNames) {
if (!indexdef.contains(partitionKey.toLowerCase()+",") && !indexdef.contains(partitionKey.toLowerCase()+")"))
if (!indexdef.contains(partitionKey.toLowerCase()+",") && !indexdef.contains(partitionKey.toLowerCase()+")")) {
int whereIndex = indexdef.toLowerCase().indexOf(" where ");
if (whereIndex > 0) {
String whereClause = indexdef.substring(whereIndex);
indexdef = indexdef.substring(0, whereIndex);
indexdef = indexdef.substring(0, indexdef.length()-1)+", "+partitionKey.toLowerCase()+")";
indexdef = indexdef + whereClause;
} else {
indexdef = indexdef.substring(0, indexdef.length()-1)+", "+partitionKey.toLowerCase()+")";
}
}
}
StringBuilder alter = new StringBuilder("DROP INDEX ").append(indexName);
DB.executeUpdateEx(alter.toString(), trxName);