trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/2] incubator-trafodion git commit: [TRAFODION-1714] Sample table population plan now printed before execution
Date Tue, 22 Dec 2015 16:18:33 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 55a5d00c6 -> 1f9b52a63


[TRAFODION-1714] Sample table population plan now printed before execution


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

Branch: refs/heads/master
Commit: 8a2085f2dfbf8fc6673bd7fb48099faeae3dd484
Parents: dd1b373
Author: Dave Birdsall <dbirdsall@apache.org>
Authored: Mon Dec 21 19:49:35 2015 +0000
Committer: Dave Birdsall <dbirdsall@apache.org>
Committed: Mon Dec 21 19:49:35 2015 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_cli.cpp | 51 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 45 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8a2085f2/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index ed10d97..2a2cfce 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -112,6 +112,49 @@ private:
 #pragma warn(770)  // warning elimination
 
 // -----------------------------------------------------------------------
+// DESCRIPTION: Call SQL CLI to execute a SQL statement. The caller is
+//          responsible for all error checking and recovery.
+// INPUTS:  stmt = statement descriptor for the SQL query
+//          srcDesc = source descriptor pointing to the 
+//               text string of SQL query.
+//          doPrintPlan = if true, the plan for the query will be
+//                printed after the statement is prepared but before
+//                execution; if false we do a single CLI ExecDirect call
+// -----------------------------------------------------------------------
+
+Lng32 HSExecDirect( SQLSTMT_ID * stmt
+                  , SQLDESC_ID * srcDesc
+                  , NABoolean doPrintPlan
+                  )
+{
+  Lng32 retcode = 0;
+
+  if (doPrintPlan)
+    {
+      retcode = SQL_EXEC_Prepare(stmt, srcDesc);
+      if (retcode >= 0) // ignore warnings
+        {
+          if (doPrintPlan)
+            {
+              HSLogMan *LM = HSLogMan::Instance();
+              if (LM->LogNeeded()) 
+                {
+                  printPlan(stmt);
+                }
+            } 
+          retcode = SQL_EXEC_ExecFetch(stmt,0,0);
+        }
+    }
+  else
+    {
+      retcode = SQL_EXEC_ExecDirect(stmt, srcDesc, 0, 0);
+    }
+
+  return retcode;
+}
+
+
+// -----------------------------------------------------------------------
 // DESCRIPTION: Execute a standalone dml/ddl statement.
 // INPUTS:  dml = text string of SQL query.
 //          sqlcode = the error to issue upon failure, or HS_WARNING if
@@ -227,7 +270,7 @@ Lng32 HSFuncExecQuery( const char *dml
   if (!doRetry)
   {
     // execute immediate this statement
-    retcode = SQL_EXEC_ExecDirect(&stmt, &srcDesc, 0, 0);
+    retcode = HSExecDirect(&stmt, &srcDesc, srcTabRowCount != 0);
     // If retcode is > 0 or sqlcode is HS_WARNING, then set to 0 (no error/ignore).
     if (retcode >= 0) retcode = 0;
     // If sqlcode is HS_WARNING, then this means failures should be returned as
@@ -258,7 +301,7 @@ Lng32 HSFuncExecQuery( const char *dml
       }
 
       // execute immediate this statement
-      retcode = SQL_EXEC_ExecDirect(&stmt, &srcDesc, 0, 0);
+      retcode = HSExecDirect(&stmt, &srcDesc, srcTabRowCount != 0);
 
       // filter retcode for HSHandleError
       HSFilterWarning(retcode);
@@ -319,10 +362,6 @@ Lng32 HSFuncExecQuery( const char *dml
       if (srcTabRowCount)
       {
         getRowCountFromStats(srcTabRowCount, tabDef) ;
-        // printing plan for insert...selects
-        if (LM->LogNeeded()) {
-          printPlan(&stmt) ;
-        }
       }
     }
   return retcode;


Mime
View raw message