Vallishp commented on code in PR #33264: URL: https://github.com/apache/doris/pull/33264#discussion_r1569061149
########## fe/fe-core/src/main/java/org/apache/doris/plsql/functions/DorisFunctionRegistry.java: ########## @@ -89,15 +92,62 @@ private String qualified(String name) { return (ConnectContext.get().getDatabase() + "." + name).toUpperCase(); } + private String getDbName(long catalogId, long dbId) { + String dbName = ""; + CatalogIf catalog = Env.getCurrentEnv().getCatalogMgr().getCatalog(catalogId); + if (catalog != null) { + DatabaseIf db = catalog.getDbNullable(dbId); + if (db != null) { + dbName = db.getFullName(); + } + } + return dbName; + } + + public static boolean like(String str, String expr) { + expr = expr.toLowerCase(); + expr = expr.replace(".", "\\."); + expr = expr.replace("?", "."); + expr = expr.replace("%", ".*"); + str = str.toLowerCase(); + return str.matches(expr); + } + + public boolean applyProcFilter(String value, String filter) { + if (filter.isEmpty()) { + return true; + } + if (filter.contains("%")) { + return like(value, filter); + } + if (value.equals(filter)) { + return true; + } + return false; + } + @Override - public void showProcedure(List<List<String>> columns) { + public void showProcedure(List<List<String>> columns, String dbFilter, String procFilter, String likeFilter) { Map<PlsqlProcedureKey, PlsqlStoredProcedure> allProc = client.getAllPlsqlStoredProcedures(); for (Map.Entry<PlsqlProcedureKey, PlsqlStoredProcedure> entry : allProc.entrySet()) { List<String> row = new ArrayList<>(); PlsqlStoredProcedure proc = entry.getValue(); + if (!applyProcFilter(proc.getName(), procFilter)) { + continue; + } + String dbName = getDbName(proc.getCatalogId(), proc.getDbId()); + if (!dbFilter.isEmpty() + && !dbName.equals(dbFilter)) { + continue; + } + if (!likeFilter.isEmpty() + && !like(proc.getName(), likeFilter)) { Review Comment: yes. it wont work. if required we can improve it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org