trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [3/4] incubator-trafodion git commit: [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver
Date Fri, 27 Oct 2017 16:02:58 GMT
[TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver

Reworked the code as per the comment in the git


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/ef881cf5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/ef881cf5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/ef881cf5

Branch: refs/heads/master
Commit: ef881cf53838c6cb0250fb4587b386379e6c7c6e
Parents: c792319
Author: selvaganesang <selva.govindarajan@esgyn.com>
Authored: Thu Oct 26 19:42:17 2017 +0000
Committer: selvaganesang <selva.govindarajan@esgyn.com>
Committed: Thu Oct 26 19:42:17 2017 +0000

----------------------------------------------------------------------
 core/sql/cli/CliExtern.cpp   | 12 ------------
 core/sql/cli/CliSemaphore.h  |  1 +
 core/sql/cli/Globals.cpp     | 10 ++--------
 core/sql/common/charinfo.cpp | 29 +++++++++++++++++++++--------
 core/sql/common/charinfo.h   |  2 +-
 5 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/CliExtern.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExtern.cpp b/core/sql/cli/CliExtern.cpp
index 8e03ff3..38a766c 100644
--- a/core/sql/cli/CliExtern.cpp
+++ b/core/sql/cli/CliExtern.cpp
@@ -77,10 +77,6 @@
 #include "dfs2rec.h"
 #include "Statement.h"
 #include "ComSqlId.h"
-
-CLISemaphore globalSemaphore ;
-
-
 #include "seabed/ms.h"
 #include "seabed/fs.h"
 #include "seabed/fserr.h"
@@ -92,7 +88,6 @@ CLISemaphore globalSemaphore ;
 #include <unistd.h>
 #include "QRLogger.h"
 
-void initStaticVariables();
 extern char ** environ;
 
 // this is set to true after the first CLI call.
@@ -871,8 +866,6 @@ short sqInit()
       exit(1);
     }
 
-    // Initialize static variables
-    initStaticVariables();
     // Initialize an Instruction Info array's offset index
     ex_conv_clause::populateInstrOffsetIndex();
 
@@ -6999,8 +6992,3 @@ Lng32 SQL_EXEC_PutRoutine
 #ifdef __cplusplus
 }
 #endif
-
-void initStaticVariables()
-{
-   CharInfo::initBuiltinCollationDB();
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/CliSemaphore.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliSemaphore.h b/core/sql/cli/CliSemaphore.h
index 84ad90e..980fc54 100644
--- a/core/sql/cli/CliSemaphore.h
+++ b/core/sql/cli/CliSemaphore.h
@@ -83,5 +83,6 @@ inline CLISemaphore::~CLISemaphore()
    DeleteCriticalSection(&cs);
 }
 
+extern CLISemaphore globalSemaphore;
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/Globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Globals.cpp b/core/sql/cli/Globals.cpp
index 32cb6b0..b9dd6e5 100644
--- a/core/sql/cli/Globals.cpp
+++ b/core/sql/cli/Globals.cpp
@@ -66,15 +66,9 @@
 
 
 #include "ExCextdecs.h"
-#ifndef NA_NO_GLOBAL_EXE_VARS
-// if global variables are allowed in the CLI, and if there isn't
-// a cheat define set, then simply define the CLI globals here
-#ifndef CLI_GLOBALS_DEF_
 CliGlobals * cli_globals = NULL;
-#endif
-// On NSK we store the cli globals in a flat segment with a fixed
-// segment id.
-#endif
+
+CLISemaphore globalSemaphore ;
 
 #include "CmpContext.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/common/charinfo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.cpp b/core/sql/common/charinfo.cpp
index c2cb8e2..547e09c 100644
--- a/core/sql/common/charinfo.cpp
+++ b/core/sql/common/charinfo.cpp
@@ -54,6 +54,7 @@
 #include "CmpConnection.h"
 #include "CmpContext.h"
 #include "CmpCommon.h"
+#include "CliSemaphore.h"
 
 using namespace std;
 
@@ -364,7 +365,8 @@ CollationDB::CollationDB(CollHeap *h)
   : CollationDBSupertype(h), heap_(h), refreshNeeded_(TRUE)
 {
     if (this == CharInfo::builtinCollationDB_) return;
-    cmpCurrentContext->getCollationDBList()->insert(this);
+    if (cmpCurrentContext != NULL)
+       cmpCurrentContext->getCollationDBList()->insert(this);
 }
 
 CollationDB::CollationDB(CollHeap *h, const CollationInfo *co, size_t count)
@@ -430,7 +432,8 @@ CollationDB * CollationDB::nextCDB() const
 
 const CollationInfo* CollationDB::getCollationInfo(CharInfo::Collation co) const
 {
-  CollIndex i, n = entries();
+  CollIndex i, n;
+  n = entries();
   for (i = 0; i < n; i++)
     if (co == at(i)->co_)
       return at(i);
@@ -533,7 +536,7 @@ static const CollationInfo mapCOArray[] = {
 
 #define SIZEOF_CO (sizeof(mapCOArray)/sizeof(CollationInfo))
 
-const CollationDB *CharInfo::builtinCollationDB_;
+const CollationDB *CharInfo::builtinCollationDB_ = NULL;
 
 CharInfo::Collation CharInfo::getCollationEnum(const char* name,
 					       NABoolean formatNSK,
@@ -553,18 +556,18 @@ CharInfo::Collation CharInfo::getCollationEnum(const char* name,
     return CharInfo::UNKNOWN_COLLATION;
 
   // Collapse any nonzero formatNSK to single bit, for XOR
-  return builtinCollationDB_->getCollationEnum(name, !!formatNSK, namlen);
+  return builtinCollationDB()->getCollationEnum(name, !!formatNSK, namlen);
 }
 
 const char* CharInfo::getCollationName(Collation co,
 				       NABoolean retUnknownAsBlank)
 {
-  return builtinCollationDB_->getCollationName(co, retUnknownAsBlank);
+  return builtinCollationDB()->getCollationName(co, retUnknownAsBlank);
 }
 
 Int32 CharInfo::getCollationFlags(Collation co)
 {
-  return builtinCollationDB_->getCollationFlags(co);
+  return builtinCollationDB()->getCollationFlags(co);
 }
 
 //****************************************************************************
@@ -697,8 +700,18 @@ Int32 CharInfo::getMaxConvertedLenInBytes(CharSet sourceCS,
           maxBytesPerChar(targetCS));
 }
 
-void CharInfo::initBuiltinCollationDB()
+const CollationDB *CharInfo::builtinCollationDB()
 {
-   builtinCollationDB_ = new CollationDB(NULL, mapCOArray, SIZEOF_CO);
+   if (CharInfo::builtinCollationDB_ != NULL)
+      return CharInfo::builtinCollationDB_;
+   globalSemaphore.get(); 
+   if (CharInfo::builtinCollationDB_ != NULL) 
+   {
+      globalSemaphore.release();
+      return CharInfo::builtinCollationDB_;
+   }
+   CharInfo::builtinCollationDB_ = new CollationDB(NULL, mapCOArray, SIZEOF_CO);
+   globalSemaphore.release();
+   return CharInfo::builtinCollationDB_;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/common/charinfo.h
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.h b/core/sql/common/charinfo.h
index 8857613..0864a4e 100644
--- a/core/sql/common/charinfo.h
+++ b/core/sql/common/charinfo.h
@@ -260,7 +260,7 @@ public:
                                          Int32   sourceLenInBytes,
                                          CharSet targetCS);
 
-  static void initBuiltinCollationDB();
+  static const CollationDB *builtinCollationDB();
  
 
 private:


Mime
View raw message