Skip to content

Commit 534c892

Browse files
stuBirdFlymaochongxin
authored andcommitted
Fix the issue where the tablet_id is incorrect when the partition table has a single partition (#226)
1 parent 136f56c commit 534c892

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
15981598
TableEntry tableEntry = getOrRefreshTableEntry(tableName, refresh, waitForRefresh,
15991599
needFetchAll);
16001600
Row row = new Row();
1601-
if (tableEntry.isPartitionTable()
1602-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
1601+
if (tableEntry.isPartitionTable()) {
16031602
List<String> curTableRowKeyNames = new ArrayList<String>();
16041603
Map<String, Integer> tableRowKeyEle = getRowKeyElement(tableName);
16051604
if (tableRowKeyEle != null) {
@@ -1934,8 +1933,7 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, ObTableQuery
19341933
Row startRow = new Row();
19351934
Row endRow = new Row();
19361935
// ensure the format of column names and values if the current table is a table with partition
1937-
if (tableEntry.isPartitionTable()
1938-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
1936+
if (tableEntry.isPartitionTable()) {
19391937
// scanRangeColumn may be longer than start/end in prefix scanning situation
19401938
if (scanRangeColumns == null || scanRangeColumns.size() < start.length) {
19411939
throw new IllegalArgumentException(

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,10 @@ private static TableEntry getTableEntryFromRemote(Connection connection, TableEn
665665
if (null != tableEntry) {
666666
tableEntry.setTableEntryKey(key);
667667
// TODO: check capacity flag later
668+
// fetch partition info
669+
fetchPartitionInfo(connection, tableEntry);
668670
// fetch tablet ids when table is partition table
669671
if (tableEntry.isPartitionTable()) {
670-
// fetch partition info
671-
fetchPartitionInfo(connection, tableEntry);
672672
if (null != tableEntry.getPartitionInfo()) {
673673
// fetch first range part
674674
if (null != tableEntry.getPartitionInfo().getFirstPartDesc()) {

src/main/java/com/alipay/oceanbase/rpc/location/model/TableEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ public Long getReplicaNum() {
102102
* Is partition table.
103103
*/
104104
public boolean isPartitionTable() {
105-
return this.partitionNum > 1;
105+
return partitionNum > 1 || (partitionInfo != null && partitionInfo.getLevel()
106+
.getIndex() > ObPartitionLevel.LEVEL_ZERO.getIndex() && partitionInfo.getLevel()
107+
.getIndex() < ObPartitionLevel.UNKNOWN.getIndex());
106108
}
107109

108110
/*

0 commit comments

Comments
 (0)