Repository: trafodion
Updated Branches:
  refs/heads/master 92476567f -> c826bceb5


[TRAFODION-2249] Cannot use library management SPJs after an upgrade

Updated initialize trafodion, upgrade library management to modify the
jar/dll file locations for all system libraries to the new location.

Changed python installer to call ..., upgrade library management during
an upgrade operation


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

Branch: refs/heads/master
Commit: e3b01d41d6305695ade2961d6c2edd6b0c5959af
Parents: ad1c676
Author: Roberta Marton <[email protected]>
Authored: Fri Apr 13 17:44:03 2018 +0000
Committer: Roberta Marton <[email protected]>
Committed: Fri Apr 13 17:44:03 2018 +0000

----------------------------------------------------------------------
 core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp      | 65 +++++++++++++++++++++
 core/sql/sqlcomp/CmpSeabaseDDLroutine.h        |  3 +
 install/python-installer/scripts/traf_start.py |  8 +++
 3 files changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/e3b01d41/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
index c1fc51d..b28d2cf 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
@@ -1778,6 +1778,71 @@ short 
CmpSeabaseDDL::upgradeSeabaseLibmgr(ExeCliInterface * cliInterface)
       return -1;
     }
 
+  // Update the jar locations for system procedures and functions.  This 
should 
+  // be done before adding any new jar's since we use a system procedure to add
+  // procedures.
+  NAString jarLocation(getenv("TRAF_HOME"));
+  jarLocation += "/export/lib";
+
+  char queryBuf[1000];
+
+  // trafodion-sql_currversion.jar 
+  Int32 stmtSize = snprintf(queryBuf, sizeof(queryBuf), "update %s.\"%s\".%s  "
+           "set library_filename = '%s/trafodion-sql-currversion.jar' "
+           "where library_uid = "
+           "(select object_uid from %s.\"%s\".%s "
+           " where object_name = '%s'  and object_type = 'LB')",
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_LIBRARIES, 
jarLocation.data(),
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_OBJECTS, 
SEABASE_VALIDATE_LIBRARY);
+  CMPASSERT(stmtSize < sizeof(queryBuf));
+
+  cliRC = cliInterface->executeImmediate(queryBuf);
+  if (cliRC < 0)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      return -1;
+    }
+
+  // lib_mgmt.jar
+  stmtSize = snprintf(queryBuf, sizeof(queryBuf), "update %s.\"%s\".%s  "
+           "set library_filename = '%s/lib_mgmt.jar' "
+           "where library_uid = "
+           "(select object_uid from %s.\"%s\".%s "
+           " where object_name = '%s'  and object_type = 'LB')",
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_LIBRARIES, 
jarLocation.data(),
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_OBJECTS, 
SEABASE_LIBMGR_LIBRARY);
+  CMPASSERT(stmtSize < sizeof(queryBuf));
+
+  cliRC = cliInterface->executeImmediate(queryBuf);
+  if (cliRC < 0)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      return -1;
+    }
+
+  // libudr_predef.so
+  NAString dllLocation(getenv("TRAF_HOME"));
+  dllLocation += "/export/lib64";
+  if (strcmp(getenv("SQ_MBTYPE"), "64d") == 0)
+    dllLocation += "d";
+
+  stmtSize = snprintf(queryBuf, sizeof(queryBuf), "update %s.\"%s\".%s  "
+           "set library_filename = '%s/libudr_predef.so' "
+           "where library_uid = "
+           "(select object_uid from %s.\"%s\".%s "
+           " where object_name = '%s'  and object_type = 'LB')",
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_LIBRARIES, 
dllLocation.data(),
+           getSystemCatalog(),SEABASE_MD_SCHEMA, SEABASE_OBJECTS, 
SEABASE_LIBMGR_LIBRARY_CPP);
+  CMPASSERT(stmtSize < sizeof(queryBuf));
+
+  cliRC = cliInterface->executeImmediate(queryBuf);
+  if (cliRC < 0)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      return -1;
+    }
+
+
   // now check for the C++ library, which was added in Trafodion 2.3
   cliRC = existsInSeabaseMDTable(cliInterface,
                                  getSystemCatalog(), SEABASE_LIBMGR_SCHEMA,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/e3b01d41/core/sql/sqlcomp/CmpSeabaseDDLroutine.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLroutine.h 
b/core/sql/sqlcomp/CmpSeabaseDDLroutine.h
index deadac4..92adf18 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLroutine.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLroutine.h
@@ -32,6 +32,9 @@
 //   perform initialize trafodion, upgrade library management
 // recommend that new procedures are added in alphabetic order
 
+// If adding a new library, be sure to update upgradeSeabaseLibmgr to
+// update jar/dll locations to the new version.
+
 // At this time there is no support to drop or change the signature of an
 // existing procedure.  Since customers may be using the procedures, it is
 // recommended that they not be dropped or changed - instead add new ones

http://git-wip-us.apache.org/repos/asf/trafodion/blob/e3b01d41/install/python-installer/scripts/traf_start.py
----------------------------------------------------------------------
diff --git a/install/python-installer/scripts/traf_start.py 
b/install/python-installer/scripts/traf_start.py
index f05abbc..f1d221b 100755
--- a/install/python-installer/scripts/traf_start.py
+++ b/install/python-installer/scripts/traf_start.py
@@ -52,10 +52,18 @@ def run():
         if meta_current != "1":
             print 'Initialize trafodion, upgrade'
             run_cmd('echo "initialize trafodion, upgrade;" | sqlci > %s' % 
tmp_file)
+
+        # update system library procedures and functions
+        run_cmd('echo "initialize trafodion, upgrade library management;" | 
sqlci > %s' %tmp_file)
+        library_output = cmd_output('cat %s' % tmp_file)
+        if 'ERROR' in library_output:
+           err('Failed to initialize trafodion, upgrade library management:\n 
%s' % library_output)
+
     # other errors
     elif 'ERROR' in init_output:
         err('Failed to initialize trafodion:\n %s' % init_output)
 
+
     run_cmd('rm -rf %s' % tmp_file)
     if dbcfgs['ldap_security'] == 'Y':
         run_cmd('echo "initialize authorization; alter user DB__ROOT set 
external name \\\"%s\\\";" | sqlci > %s' % (dbcfgs['db_root_user'], tmp_file))

Reply via email to