zhangbutao commented on code in PR #6088:
URL: https://github.com/apache/hive/pull/6088#discussion_r2465716095


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/database/unlock/UnlockDatabaseAnalyzer.java:
##########
@@ -41,14 +43,19 @@ public UnlockDatabaseAnalyzer(QueryState queryState) throws 
SemanticException {
 
   @Override
   public void analyzeInternal(ASTNode root) throws SemanticException {
-    String databaseName = unescapeIdentifier(root.getChild(0).getText());
+    Pair<String, String> catDbNamePair = getCatDbNamePair((ASTNode) 
root.getChild(0));
+    String catalogName = catDbNamePair.getLeft();
+    if (catalogName != null && getCatalog(catalogName) == null) {
+      throw new SemanticException(ErrorMsg.CATALOG_NOT_EXISTS, catalogName);
+    }
+    String databaseName = catDbNamePair.getRight();
 
-    inputs.add(new ReadEntity(getDatabase(databaseName)));
+    inputs.add(new ReadEntity(getDatabase(catalogName, databaseName, true)));
     // Unlock database operation is to release the lock explicitly, the 
operation itself don't need to be locked.
     // Set the WriteEntity as WriteType: DDL_NO_LOCK here, otherwise it will 
conflict with Hive's transaction.
-    outputs.add(new WriteEntity(getDatabase(databaseName), 
WriteType.DDL_NO_LOCK));
+    outputs.add(new WriteEntity(getDatabase(catalogName, databaseName, true), 
WriteType.DDL_NO_LOCK));

Review Comment:
   > HIVE_LOCKS table doesn't have catalog column.
   
   Currently, this only retrieves a specific database under a particular 
catalog and does not involve any lock/unlock operations on the catalog.  
   However, I believe future development should consider implementing 
lock/unlock operations for catalogs, though I haven't yet identified the 
specific use cases. It might be necessary during cross-catalog federated 
queries.
   
   > Maybe some operation like Unlock/Lock DB, ShowDbLocks should only be 
supported by NATIVE DBs?
   
   To be honest, I haven't fully thought this through. Locking/unlocking 
databases in external catalogs (such as a MySQL JDBC catalog) doesn't seem very 
meaningful, as these lock operations won't take effect on the MySQL source 
side. However, I believe allowing locks on databases in external catalogs in 
Hive might have some significance, particularly in scenarios involving 
cross-catalog and cross-database operations, to ensure task transactional 
consistency. Therefore, let's further explore this issue when we work on 
cross-catalog queries. An already created ticket, HIVE-29242, can be used to 
track this matter.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to