Skip to content

Commit 5442b0e

Browse files
committed
Fix the issue where the tablet_id is incorrect when the partition table has a single partition
1 parent 1381fa5 commit 5442b0e

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
@@ -1654,8 +1654,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16541654
TableEntry tableEntry = getOrRefreshTableEntry(tableName, refresh, waitForRefresh,
16551655
needFetchAll);
16561656
Row row = new Row();
1657-
if (tableEntry.isPartitionTable()
1658-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
1657+
if (tableEntry.isPartitionTable()) {
16591658
List<String> curTableRowKeyNames = new ArrayList<String>();
16601659
Map<String, Integer> tableRowKeyEle = getRowKeyElement(tableName);
16611660
if (tableRowKeyEle != null) {
@@ -2048,8 +2047,7 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, ObTableQuery
20482047
Row startRow = new Row();
20492048
Row endRow = new Row();
20502049
// ensure the format of column names and values if the current table is a table with partition
2051-
if (tableEntry.isPartitionTable()
2052-
&& tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) {
2050+
if (tableEntry.isPartitionTable()) {
20532051
// scanRangeColumn may be longer than start/end in prefix scanning situation
20542052
if (scanRangeColumns == null || scanRangeColumns.size() < start.length) {
20552053
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
@@ -716,10 +716,10 @@ private static TableEntry getTableEntryFromRemote(Connection connection, TableEn
716716
if (null != tableEntry) {
717717
tableEntry.setTableEntryKey(key);
718718
// TODO: check capacity flag later
719+
// fetch partition info
720+
fetchPartitionInfo(connection, tableEntry);
719721
// fetch tablet ids when table is partition table
720722
if (tableEntry.isPartitionTable()) {
721-
// fetch partition info
722-
fetchPartitionInfo(connection, tableEntry);
723723
if (null != tableEntry.getPartitionInfo()) {
724724
// fetch first range part
725725
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
@@ -105,7 +105,9 @@ public Long getReplicaNum() {
105105
* Is partition table.
106106
*/
107107
public boolean isPartitionTable() {
108-
return this.partitionNum > 1;
108+
return partitionNum > 1 || (partitionInfo != null && partitionInfo.getLevel()
109+
.getIndex() > ObPartitionLevel.LEVEL_ZERO.getIndex() && partitionInfo.getLevel()
110+
.getIndex() < ObPartitionLevel.UNKNOWN.getIndex());
109111
}
110112

111113
/*

0 commit comments

Comments
 (0)