Skip to content

Commit 4da4d13

Browse files
branch-4.1: [fix](fe) Allow show tablet without selected database #63280 (#63512)
Cherry-picked from #63280 Co-authored-by: minghong <zhouminghong@selectdb.com>
1 parent 0f218bd commit 4da4d13

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.apache.doris.statistics.query.QueryStatsUtil;
4747

4848
import com.google.common.annotations.VisibleForTesting;
49-
import com.google.common.base.Strings;
5049
import com.google.common.collect.Lists;
5150

5251
import java.util.List;
@@ -56,7 +55,6 @@
5655
*/
5756
public class ShowTabletIdCommand extends ShowCommand {
5857
private final long tabletId;
59-
private String dbName;
6058

6159
/**
6260
* constructor
@@ -97,11 +95,6 @@ protected void validate(ConnectContext ctx) throws AnalysisException {
9795
if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) {
9896
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "SHOW TABLET");
9997
}
100-
101-
dbName = ctx.getDatabase();
102-
if (Strings.isNullOrEmpty(dbName)) {
103-
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
104-
}
10598
}
10699

107100
private ShowResultSet handleShowTabletId() {

fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ void noGlobalPriv() {
7878
}
7979

8080
@Test
81-
void dbIsEmpty() {
81+
void noDatabaseSelected() {
8282
runBefore("", true);
8383
ShowTabletIdCommand command = new ShowTabletIdCommand(CatalogMocker.TEST_TBL_ID);
84-
Assertions.assertThrows(AnalysisException.class, () -> command.validate(ctx));
84+
Assertions.assertDoesNotThrow(() -> command.validate(ctx));
8585
}
8686
}

regression-test/suites/show_p0/test_show_tablet.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ suite("test_show_tablet") {
2727
);"""
2828

2929
def res = sql """ SHOW TABLETS FROM show_tablets_test_t """
30+
def noDbJdbcUrl = context.config.jdbcUrl.replaceFirst(/(jdbc:mysql:\/\/[^\/]+\/)[^?]*/, '$1')
31+
connect(context.config.jdbcUser, context.config.jdbcPassword, noDbJdbcUrl) {
32+
def tabletId = res[0][0]
33+
def tabletRes = sql """ SHOW TABLET ${tabletId} """
34+
assertTrue(tabletRes.size() == 1)
35+
}
3036
if (res.size() == 5) {
3137
// replication num == 1
3238
res = sql """SHOW TABLETS FROM show_tablets_test_t limit 5, 1;"""
@@ -53,4 +59,4 @@ suite("test_show_tablet") {
5359
} else {
5460
assertTrue(1 == 2)
5561
}
56-
}
62+
}

0 commit comments

Comments
 (0)