You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2019/07/01 18:22:24 UTC

[hive] branch master updated: HIVE-19831: Hiveserver2 should skip doAuth checks for CREATE DATABASE/TABLE if database/table already exists (Rajkumar Singh, reviewed by Daniel Dai)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2d9e0e4  HIVE-19831: Hiveserver2 should skip doAuth checks for CREATE DATABASE/TABLE if database/table already exists (Rajkumar Singh, reviewed by Daniel Dai)
2d9e0e4 is described below

commit 2d9e0e41ec6db234b8a759f1c5aff8f79227f158
Author: Daniel Dai <da...@cloudera.com>
AuthorDate: Mon Jul 1 11:22:15 2019 -0700

    HIVE-19831: Hiveserver2 should skip doAuth checks for CREATE DATABASE/TABLE if database/table already exists (Rajkumar Singh, reviewed by Daniel Dai)
---
 ql/src/java/org/apache/hadoop/hive/ql/Driver.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index ae622c8..8c764e2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -1088,6 +1088,15 @@ public class Driver implements IDriver {
         additionalInputs.add(new ReadEntity(e.getTable()));
       }
     }
+    // skipping the auth check for the "CREATE DATABASE" operation if database already exists
+    // we know that if the database already exists then "CREATE DATABASE" operation will fail.
+    if(op.equals(HiveOperation.CREATEDATABASE)){
+      for (WriteEntity e : sem.getOutputs()) {
+        if(e.getType() == Entity.Type.DATABASE && db.databaseExists(e.getName().split(":")[1])){
+          return;
+        }
+      }
+    }
 
     Set<WriteEntity> additionalOutputs = new HashSet<WriteEntity>();
     for (WriteEntity e : sem.getOutputs()) {