From b1644a413c4b8439d7fed2a459cb9746d290d899 Mon Sep 17 00:00:00 2001 From: Yulei-Yang Date: Wed, 25 Dec 2024 19:46:22 +0800 Subject: [PATCH] rebase --- .../apache/doris/analysis/ShowDataStmt.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java index abdb3ec01c7c648..920d463c48f9ee2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java @@ -220,6 +220,8 @@ public int compare(Table t1, Table t2) { } }); + boolean isAdmin = Env.getCurrentEnv().getAccessManager() + .checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN); for (Table table : tables) { if (!Env.getCurrentEnv().getAccessManager() .checkTblPriv(ConnectContext.get(), InternalCatalog.INTERNAL_CATALOG_NAME, dbName, @@ -227,6 +229,14 @@ public int compare(Table t1, Table t2) { PrivPredicate.SHOW)) { continue; } + // admin users can see all temporary tables no matter they are created by which session + if (!isAdmin) { + // non admin user can only see temporary tables in current session + if (table.isTemporary() && Util.getTempTableSessionId(table.getName()) + != ConnectContext.get().getSessionId()) { + continue; + } + } sortedTables.add(table); } @@ -244,16 +254,20 @@ public int compare(Table t1, Table t2) { replicaCount = olapTable.getReplicaCount(); remoteSize = olapTable.getRemoteDataSize(); - String tableShowName = olapTable.getType() == TableType.TEMP - ? Util.getTempTableOuterName(tableName.getTbl()) : tableName.getTbl(); + boolean useDisplayName = false; + if (!isAdmin && olapTable.isTemporary()) { + useDisplayName = true; + } + String tableName = useDisplayName + ? Util.getTempTableDisplayName(olapTable.getName()) : olapTable.getName(); if (!detailed) { - totalRowsObject.add(Arrays.asList(tableShowName, tableSize, replicaCount, remoteSize)); + totalRowsObject.add(Arrays.asList(tableName, tableSize, replicaCount, remoteSize)); } else { long localIndexSize = olapTable.getLocalIndexFileSize(); long localSegmentSize = olapTable.getLocalSegmentSize(); long remoteIndexSize = olapTable.getRemoteIndexFileSize(); long remoteSegmentSize = olapTable.getRemoteSegmentSize(); - totalRowsObject.add(Arrays.asList(tableShowName, tableSize, replicaCount, remoteSize, + totalRowsObject.add(Arrays.asList(tableName, tableSize, replicaCount, remoteSize, localIndexSize, localSegmentSize, remoteIndexSize, remoteSegmentSize)); totalLocalInvertedSize += localIndexSize; totalLocalSegmentSize += localSegmentSize;