You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by rm...@apache.org on 2016/03/30 19:31:30 UTC

[1/2] incubator-trafodion git commit: Fixed udr/TEST103 regression issue. Forgot to add a java file needed to compile a procedure and added a filter for the created .dll file.

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 7b04f91e6 -> 70b17ed56


Fixed udr/TEST103 regression issue.  Forgot to add a java file needed
to compile a procedure and added a filter for the created .dll file.


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

Branch: refs/heads/master
Commit: 4677b6d0865c12175294c191ca258426bb935f88
Parents: f918a26
Author: Roberta Marton <ro...@apache.org>
Authored: Wed Mar 30 14:52:43 2016 +0000
Committer: Roberta Marton <ro...@apache.org>
Committed: Wed Mar 30 14:52:43 2016 +0000

----------------------------------------------------------------------
 core/sql/regress/udr/FILTER103  |  25 ++++
 core/sql/regress/udr/Utils.java | 279 +++++++++++++++++++++++++++++++++++
 2 files changed, 304 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4677b6d0/core/sql/regress/udr/FILTER103
----------------------------------------------------------------------
diff --git a/core/sql/regress/udr/FILTER103 b/core/sql/regress/udr/FILTER103
new file mode 100755
index 0000000..582cb8a
--- /dev/null
+++ b/core/sql/regress/udr/FILTER103
@@ -0,0 +1,25 @@
+#!/bin/sh
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+sed "
+s#[^ ]*/TEST103_functions.dll#rundir/TEST103_functions.dll#g
+" "$1"

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4677b6d0/core/sql/regress/udr/Utils.java
----------------------------------------------------------------------
diff --git a/core/sql/regress/udr/Utils.java b/core/sql/regress/udr/Utils.java
new file mode 100644
index 0000000..d73f6bc
--- /dev/null
+++ b/core/sql/regress/udr/Utils.java
@@ -0,0 +1,279 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+// ===================================================================
+// Class:  Utils
+//
+//  This is a helper class for the other SPJs that: 
+//     - gets connection (myConnection)
+//     - gets current user executing the SPJ (getCurrentUser)
+//     - gets session user if definer rights are used (getSessionUser)
+//     - gets current timestamp ( getCurrentTime )
+//     - transaction management ops
+//        - BEGIN
+//        - COMMIT
+//        - ROLLBACK
+//     - log debug statements (log)
+//     - log execeptions (printExceptionStack)
+//
+// ===================================================================
+public class Utils 
+{
+   static boolean log = false;
+   static String logFileName = "udr_tools.log";
+   static String logLocation = null;
+   static String sqRoot = null;
+   static String userName = null;
+
+   Utils () 
+   {
+     if (!log)
+       log = Boolean.getBoolean("debugOn");
+     
+     if (log) { 
+       sqRoot = System.getenv("MY_SQROOT");
+       logLocation = sqRoot + "/logs/";
+     }
+   }
+
+   // Returns a JDBC Connection for use within the SPJ 
+   // returns Connection and throws Exception
+
+    public static Connection myConnection() throws SQLException
+    {
+        Connection conn = null;
+        try
+        {
+           String url = "jdbc:default:connection";
+           java.util.Properties props = new java.util.Properties();
+           props.setProperty("maxStatements", "0"); // disable JDBC statement caching
+           conn = DriverManager.getConnection(url, props);
+           log("Returning connection from myConnection " + (conn != null));
+        }
+        catch (Throwable t)
+        {
+           log("Error encountered while getting connection " + t.getMessage());
+           printExceptionStack(t);
+           throw new SQLException(t.getMessage());
+        }
+        return conn;
+    }
+
+    private static String getLogFile(String path) 
+    {
+       String file=null;
+
+       if (path != null)
+        file = path + logFileName;
+       else 
+        file = logFileName;
+       return file;
+    }
+
+    // Log a message to a log file.    
+    protected static void log(String message)
+    {
+      if (log)
+      {
+       try
+       {
+          String file = getLogFile(logLocation);
+          FileWriter fw = new FileWriter(file, true);
+          PrintWriter pw = new PrintWriter(fw);
+          pw.println("@" + Calendar.getInstance().getTime() + ": " + message);
+          pw.close();
+          fw.flush();
+          fw.close();
+       } catch (Exception ex) {}
+      }
+    }
+    
+     // Print exception stack.
+    protected static void printExceptionStack(Throwable t)
+    {
+      if (log)
+      {
+       try
+       {
+          String file = getLogFile(logLocation);
+          FileWriter fw = new FileWriter(file, true);
+          PrintWriter pw = new PrintWriter(fw);
+          t.printStackTrace(pw);
+          pw.close();
+          fw.flush();
+          fw.close();
+        } catch (Exception ex) { }
+      }
+    }
+
+    public static String getCurrentUser(Connection conn) throws SQLException
+    {
+        log("In method getCurrentUser");
+        try {
+          Statement stmt = conn.createStatement();
+          log("In method getCurrentUser:gotStatement");
+          ResultSet rset = stmt.executeQuery("VALUES(USER)");
+          while (rset != null && rset.next())
+          {
+            userName = rset.getString(1);
+          }
+          log("In method getCurrentUser:doneExecuteQuery::" + userName);
+          rset.close(); stmt.close();
+        } catch (SQLException e) {
+          log("Error encountered in getCurrentUser " + e.getMessage());
+          printExceptionStack(e);
+          throw new SQLException(e.getMessage());
+        }
+        return userName;
+    }
+    
+    public static String getSessionUser(Connection conn) throws SQLException
+    {
+        log("In method getSessionUser");
+        try {
+          Statement stmt = conn.createStatement();
+          log("In method getSessionUser:gotStatement");
+          ResultSet rset = stmt.executeQuery("VALUES(SESSION_USER)");
+          while (rset != null && rset.next())
+          {
+            userName = rset.getString(1);
+          }
+          log("In method getSessionUser:doneExecuteQuery::" + userName);
+          rset.close(); stmt.close();
+        } catch (SQLException e) {
+          log("Error encountered in getSessionUser " + e.getMessage());
+          printExceptionStack(e);
+          throw new SQLException(e.getMessage());
+        }
+        return userName;
+    }
+
+    public static String getCurrentTime(Connection conn) throws SQLException
+    {
+        log("In method getCurrentTime");
+        try {
+          Statement stmt = conn.createStatement();
+          log("In method getCurrentTime:gotStatement");
+          ResultSet rset = stmt.executeQuery("VALUES(CURRENT_TIMESTAMP(2))");
+          while (rset != null && rset.next())
+          {
+            userName = rset.getString(1);
+          }
+          log("In method getCurrentTime:doneExecuteQuery::" + userName);
+          rset.close(); stmt.close();
+        } catch (SQLException e) {
+          log("Error encountered in getCurrentTime " + e.getMessage());
+          printExceptionStack(e);
+          throw new SQLException(e.getMessage());
+        }
+        return userName;
+    }
+
+    public static void beginTxn(Connection conn) throws SQLException
+    {
+        log("In method beginTxn");
+        try {
+          log("In method beginTxn:gotStatement");
+          PreparedStatement stmt = conn.prepareStatement("begin work;");
+          stmt.executeUpdate();
+
+          log("In method beginTxn:doneExecuteUpdate");
+          stmt.close();
+        } catch (SQLException e) {
+          if (e.getErrorCode() != -8603) {
+            log("Error encountered in beginTxn " + e.getMessage());
+            printExceptionStack(e);
+            throw new SQLException(e.getMessage());
+          }
+        }
+    }
+
+    public static void commitTxn(Connection conn) throws SQLException
+    {
+        log("In method commitTxn");
+        try {
+          log("In method commitTxn:gotStatement");
+          PreparedStatement stmt = conn.prepareStatement("commit work;");
+          stmt.executeUpdate();
+
+          log("In method commitTxn:doneExecuteUpdate");
+          stmt.close();
+        } catch (SQLException e) {
+          if (e.getErrorCode() != -8605) {
+            log("Error encountered in commitTxn " + e.getMessage());
+            printExceptionStack(e);
+            throw new SQLException(e.getMessage());
+          }
+        }
+    }
+
+    public static void rollbackTxn(Connection conn) throws SQLException
+    {
+        log("In method rollbackTxn");
+        try {
+          log("In method rollbackTxn:gotStatement");
+          PreparedStatement stmt = conn.prepareStatement("rollback work;");
+          stmt.executeUpdate();
+
+          log("In method rollbackTxn:doneExecuteUpdate");
+          stmt.close();
+        } catch (SQLException e) {
+          if (e.getErrorCode() != -8609) {
+            log("Error encountered in rollbackTxn " + e.getMessage());
+            printExceptionStack(e);
+            throw new SQLException(e.getMessage());
+          }
+        }
+    }
+
+    InputStream origIn_;
+    PrintStream origOut_;
+    PrintStream origErr_;
+    
+    public static void RedirectStdOut(String filename) throws Exception
+    {
+       InputStream origIn_  = System.in;
+       PrintStream origOut_ = System.out;
+       PrintStream origErr_ = System.err;
+        
+       String sqRoot      = System.getenv("MY_SQROOT");
+       String stdoutFile  = sqRoot + "/sql/scripts/" + filename;
+       PrintStream stdout = null;
+
+       try
+       {
+          stdout = new PrintStream(new FileOutputStream(stdoutFile));
+       }
+       catch (Exception e)
+       {
+          System.out.println("RedirectStdOut: unable to open " + stdoutFile);
+          throw new Exception(e.getMessage());
+       }
+       
+       System.setOut(stdout);
+    } // RedirectStdOut  
+
+} // class utils
+


[2/2] incubator-trafodion git commit: Merge regression fixes for udr/TEST103 PR-407

Posted by rm...@apache.org.
Merge regression fixes for udr/TEST103 PR-407


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

Branch: refs/heads/master
Commit: 70b17ed56a2a45a5ddfd94e9d53f83c8a7241b26
Parents: 7b04f91 4677b6d
Author: Roberta Marton <ro...@apache.org>
Authored: Wed Mar 30 17:31:07 2016 +0000
Committer: Roberta Marton <ro...@apache.org>
Committed: Wed Mar 30 17:31:07 2016 +0000

----------------------------------------------------------------------
 core/sql/regress/udr/FILTER103  |  25 ++++
 core/sql/regress/udr/Utils.java | 279 +++++++++++++++++++++++++++++++++++
 2 files changed, 304 insertions(+)
----------------------------------------------------------------------