IDEMPIERE-6100 Table Partitioning Issue with Tables having Index with where condition (#2307)
This commit is contained in:
parent
adea9db390
commit
76edaa9e1d
|
@ -235,8 +235,17 @@ public class TablePartitionService implements ITablePartitionService {
|
||||||
//unique index must include partition key column
|
//unique index must include partition key column
|
||||||
String indexdef = uniqueMap.get(indexName);
|
String indexdef = uniqueMap.get(indexName);
|
||||||
for(String partitionKey : partitionKeyColumnNames) {
|
for(String partitionKey : partitionKeyColumnNames) {
|
||||||
if (!indexdef.contains(partitionKey.toLowerCase()+",") && !indexdef.contains(partitionKey.toLowerCase()+")"))
|
if (!indexdef.contains(partitionKey.toLowerCase()+",") && !indexdef.contains(partitionKey.toLowerCase()+")")) {
|
||||||
indexdef = indexdef.substring(0, indexdef.length()-1)+", "+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);
|
StringBuilder alter = new StringBuilder("DROP INDEX ").append(indexName);
|
||||||
DB.executeUpdateEx(alter.toString(), trxName);
|
DB.executeUpdateEx(alter.toString(), trxName);
|
||||||
|
|
Loading…
Reference in New Issue