This is an automated email from the ASF dual-hosted git repository.

englefly pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2eff9ea9894 [fix](fe) Allow show tablet without selected database 
(#63280)
2eff9ea9894 is described below

commit 2eff9ea9894aa305fcc0cac83d1b75dc6c005ed9
Author: minghong <[email protected]>
AuthorDate: Fri May 22 08:56:28 2026 +0800

    [fix](fe) Allow show tablet without selected database (#63280)
    
    ### What problem does this PR solve?
    Problem Summary: SHOW TABLET <tablet_id> looked up tablet metadata by id
    but still required a selected session database during validation. This
    caused No database selected when the mysql client had not executed USE
    <db>, even though the command can resolve the owning database from
    TabletMeta.
    Issue Number: close #xxx
    
    Related PR: #48815
---
 .../doris/nereids/trees/plans/commands/ShowTabletIdCommand.java   | 7 -------
 .../nereids/trees/plans/commands/ShowTabletIdCommandTest.java     | 4 ++--
 regression-test/suites/show_p0/test_show_tablet.groovy            | 8 +++++++-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java
index 15d83237816..a311ad5404f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java
@@ -46,7 +46,6 @@ import org.apache.doris.qe.StmtExecutor;
 import org.apache.doris.statistics.query.QueryStatsUtil;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 
 import java.util.List;
@@ -56,7 +55,6 @@ import java.util.List;
  */
 public class ShowTabletIdCommand extends ShowCommand {
     private final long tabletId;
-    private String dbName;
 
     /**
      * constructor
@@ -97,11 +95,6 @@ public class ShowTabletIdCommand extends ShowCommand {
         if 
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), 
PrivPredicate.ADMIN)) {
             
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, 
"SHOW TABLET");
         }
-
-        dbName = ctx.getDatabase();
-        if (Strings.isNullOrEmpty(dbName)) {
-            ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
-        }
     }
 
     private ShowResultSet handleShowTabletId() {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java
index d3a3ad0f7fd..9d3c335721f 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java
@@ -85,9 +85,9 @@ public class ShowTabletIdCommandTest {
     }
 
     @Test
-    void dbIsEmpty() {
+    void noDatabaseSelected() {
         runBefore("", true);
         ShowTabletIdCommand command = new 
ShowTabletIdCommand(CatalogMocker.TEST_TBL_ID);
-        Assertions.assertThrows(AnalysisException.class, () -> 
command.validate(ctx));
+        Assertions.assertDoesNotThrow(() -> command.validate(ctx));
     }
 }
diff --git a/regression-test/suites/show_p0/test_show_tablet.groovy 
b/regression-test/suites/show_p0/test_show_tablet.groovy
index 024e90fdd19..abe54d7e93f 100644
--- a/regression-test/suites/show_p0/test_show_tablet.groovy
+++ b/regression-test/suites/show_p0/test_show_tablet.groovy
@@ -27,6 +27,12 @@ suite("test_show_tablet") {
             );"""
 
     def res = sql """ SHOW TABLETS FROM show_tablets_test_t """
+    def noDbJdbcUrl = 
context.config.jdbcUrl.replaceFirst(/(jdbc:mysql:\/\/[^\/]+\/)[^?]*/, '$1')
+    connect(context.config.jdbcUser, context.config.jdbcPassword, noDbJdbcUrl) 
{
+        def tabletId = res[0][0]
+        def tabletRes = sql """ SHOW TABLET ${tabletId} """
+        assertTrue(tabletRes.size() == 1)
+    }
     if (res.size() == 5) {
         // replication num == 1
         res = sql """SHOW TABLETS FROM show_tablets_test_t limit 5, 1;"""
@@ -53,4 +59,4 @@ suite("test_show_tablet") {
     } else {
         assertTrue(1 == 2)
     }
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to