You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/09/09 09:08:37 UTC
[07/50] [abbrv] hive git commit: HIVE-11123 : Fix how to confirm the
RDBMS product name at Metastore. (Shinichi Yamashita,
reviewed by Sergey Shelukhin and Deepesh Khandelwal)
HIVE-11123 : Fix how to confirm the RDBMS product name at Metastore. (Shinichi Yamashita, reviewed by Sergey Shelukhin and Deepesh Khandelwal)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/fb152e45
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/fb152e45
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/fb152e45
Branch: refs/heads/beeline-cli
Commit: fb152e45064fcb2846b198ba14e7f7cc13ada4bb
Parents: 9670a2b
Author: Sergey Shelukhin <se...@apache.org>
Authored: Thu Aug 27 10:54:58 2015 -0700
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Thu Aug 27 10:54:58 2015 -0700
----------------------------------------------------------------------
.../hive/metastore/MetaStoreDirectSql.java | 40 +++++++-------------
1 file changed, 13 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/fb152e45/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
index 5776ec6..522fcc2 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
@@ -148,16 +148,16 @@ class MetaStoreDirectSql {
private DB determineDbType() {
DB dbType = DB.OTHER;
- if (runDbCheck("SET @@session.sql_mode=ANSI_QUOTES", "MySql")) {
- dbType = DB.MYSQL;
- } else if (runDbCheck("SELECT version FROM v$instance", "Oracle")) {
- dbType = DB.ORACLE;
- } else if (runDbCheck("SELECT @@version", "MSSQL")) {
- dbType = DB.MSSQL;
- } else {
- // TODO: maybe we should use getProductName to identify all the DBs
- String productName = getProductName();
- if (productName != null && productName.toLowerCase().contains("derby")) {
+ String productName = getProductName();
+ if (productName != null) {
+ productName = productName.toLowerCase();
+ if (productName.contains("mysql")) {
+ dbType = DB.MYSQL;
+ } else if (productName.contains("oracle")) {
+ dbType = DB.ORACLE;
+ } else if (productName.contains("microsoft sql server")) {
+ dbType = DB.MSSQL;
+ } else if (productName.contains("derby")) {
dbType = DB.DERBY;
}
}
@@ -210,6 +210,9 @@ class MetaStoreDirectSql {
private boolean runTestQuery() {
Transaction tx = pm.currentTransaction();
+ if (!tx.isActive()) {
+ tx.begin();
+ }
Query query = null;
// Run a self-test query. If it doesn't work, we will self-disable. What a PITA...
String selfTestQuery = "select \"DB_ID\" from \"DBS\"";
@@ -261,23 +264,6 @@ class MetaStoreDirectSql {
}
}
- private boolean runDbCheck(String queryText, String name) {
- Transaction tx = pm.currentTransaction();
- if (!tx.isActive()) {
- tx.begin();
- }
- try {
- executeNoResult(queryText);
- return true;
- } catch (Throwable t) {
- LOG.debug(name + " check failed, assuming we are not on " + name + ": " + t.getMessage());
- tx.rollback();
- tx = pm.currentTransaction();
- tx.begin();
- return false;
- }
- }
-
public Database getDatabase(String dbName) throws MetaException{
Query queryDbSelector = null;
Query queryDbParams = null;