Repository: incubator-trafodion
Updated Branches:
  refs/heads/master a29825bf6 -> 72e5aa91b


JIRA TRAFODION-2200 Vol/Ext opers with hive schema default return errors

-- JIRA TRAFODION-2200 some operations on volatile and external tables
  no longer return errors if catalog/schema default is set to hive.hive
-- updated compGeneral/test042 regressions expected/known diff file
-- redef time for views was not being updated correctly. That has
   been fixed
-- removed an unneeded printf stmt from native expr optimizer


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

Branch: refs/heads/master
Commit: 8d0fce376c665c68d7e34f513fdebbf73ffd1314
Parents: 2980764
Author: Anoop Sharma <[email protected]>
Authored: Thu Sep 8 19:58:04 2016 +0000
Committer: Anoop Sharma <[email protected]>
Committed: Thu Sep 8 19:58:04 2016 +0000

----------------------------------------------------------------------
 core/sql/exp/ExpPCodeOptsNativeExpr.cpp    |  1 -
 core/sql/optimizer/RelExeUtil.cpp          | 80 ++++++++++++++--------
 core/sql/regress/compGeneral/DIFF042.KNOWN | 88 +++++++++++++++++++++++++
 core/sql/regress/compGeneral/EXPECTED042   | 87 +++++++-----------------
 core/sql/regress/seabase/EXPECTED031       | 50 +++++++++++---
 core/sql/regress/seabase/TEST010           |  1 +
 core/sql/regress/seabase/TEST031           | 12 ++++
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp   | 20 +++---
 8 files changed, 230 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptsNativeExpr.cpp 
b/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
index 7a8bce2..515c831 100755
--- a/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
+++ b/core/sql/exp/ExpPCodeOptsNativeExpr.cpp
@@ -85,7 +85,6 @@ void PCodeCfg::NExLog(const char *data)
      ofstream fileout( NExLogPth, ios::app);
      fileout << data ;
    }
-   else printf( data );
 }
 
 #ifndef __EID

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp 
b/core/sql/optimizer/RelExeUtil.cpp
index 50a42b6..558c246 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -3934,7 +3934,8 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
   NABoolean alterColRename = FALSE;
   NABoolean alterLibrary = FALSE;
   NABoolean externalTable = FALSE;
-  
+  NABoolean isVolatile = FALSE;
+
   returnStatus_ = FALSE;
 
   NABoolean specialType = FALSE;
@@ -3980,6 +3981,9 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
       StmtDDLCreateTable * createTableNode =
         getExprNode()->castToStmtDDLNode()->castToStmtDDLCreateTable();
 
+      if (createTableNode->isVolatile())
+        isVolatile = TRUE;
+
       isCreate_ = TRUE;
       isTable_ = TRUE;
 
@@ -4059,6 +4063,12 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
       isCreate_ = TRUE;
       isIndex_ = TRUE;
 
+      StmtDDLCreateIndex * createIndexNode =
+        getExprNode()->castToStmtDDLNode()->castToStmtDDLCreateIndex();
+
+      if (createIndexNode->isVolatile())
+        isVolatile = TRUE;
+
       objName_ =
         getDDLNode()->castToStmtDDLNode()->castToStmtDDLCreateIndex()->
         getIndexName();
@@ -4088,6 +4098,9 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
       StmtDDLDropTable * dropTableNode =
         getExprNode()->castToStmtDDLNode()->castToStmtDDLDropTable();
 
+      if (dropTableNode->isVolatile())
+        isVolatile = TRUE;
+
       qualObjName_ = dropTableNode->getTableNameAsQualifiedName();
 
       // Normally, when a drop table is executed and DDL transactions is not
@@ -4098,6 +4111,9 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
           (NOT getExprNode()->castToStmtDDLNode()->ddlXns()))
         hbaseDDLNoUserXn_ = TRUE;
 
+      if (dropTableNode->isExternal())
+         qualObjName_.applyDefaults(bindWA->getDefaultSchema());
+
       // Drops of Hive and HBase external tables are allowed 
       if (qualObjName_.isHive() || (qualObjName_.isHbase()))
         {
@@ -4127,6 +4143,12 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
     }
     else if (getExprNode()->castToStmtDDLNode()->castToStmtDDLDropIndex())
     {
+      StmtDDLDropIndex * dropIndexNode =
+        getExprNode()->castToStmtDDLNode()->castToStmtDDLDropIndex();
+
+      if (dropIndexNode->isVolatile())
+        isVolatile = TRUE;
+
       isDrop_ = TRUE;
       isIndex_ = TRUE;
 
@@ -4389,7 +4411,8 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
                         alterIdentityCol || alterColDatatype || alterColRename 
||
                         alterHBaseOptions || alterLibrary || otherAlters)))))
       {
-       if (NOT isNative_)
+       if ((NOT isNative_) &&
+            (NOT isVolatile))
          {
            qualObjName_.applyDefaults(bindWA->getDefaultSchema());
            
@@ -4399,6 +4422,12 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
              }
          }
        
+        // volatile tables are traf tables
+        if (isVolatile)
+          {
+            isHbase_ = TRUE;
+          }
+
        if (isHbase_ && otherAlters)
          {
            *CmpCommon::diags() << DgSqlCode(-4222) << DgString0("ALTER");
@@ -4439,7 +4468,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
   if (bindWA->errStatus())
     return NULL;
 
-  if (isHbase_ || externalTable)
+  if (isHbase_ || externalTable || isVolatile)
     return boundExpr;
 
   *CmpCommon::diags() << DgSqlCode(-3242) << DgString0("DDL operations can 
only be done on trafodion or external tables.");
@@ -4519,25 +4548,8 @@ RelExpr * ExeUtilProcessVolatileTable::bindNode(BindWA 
*bindWA)
   RelExpr * boundExpr = DDLExpr::bindNode(bindWA);
   if (bindWA->errStatus()) 
     return NULL;
-  
-  isHbase_ = FALSE;
-  if ((CmpCommon::getDefault(MODE_SEABASE) == DF_ON) &&
-      (CmpCommon::getDefault(SEABASE_VOLATILE_TABLES) == DF_ON))
-    {
-      volTabName_.applyDefaults(bindWA->getDefaultSchema());
-      if (volTabName_.isSeabase())
-       {
-         isHbase_ = TRUE;
-       }
-    }
-  
-  if (NOT isHbase_)
-    {
-      // non-hbase tables not supported in open source
-      *CmpCommon::diags() << DgSqlCode(-3242) << DgString0("Non-hbase tables 
not supported.");
-      bindWA->setErrStatus();
-      return NULL;
-    }
+
+  isHbase_ = TRUE;
 
   return boundExpr;
 }
@@ -4649,32 +4661,44 @@ RelExpr * ExeUtilCreateTableAs::bindNode(BindWA *bindWA)
     createTableNode =
       getExprNode()->castToStmtDDLNode()->castToStmtDDLCreateTable();
 
+  isVolatile_ = FALSE;
+  if (createTableNode && (createTableNode->isVolatile()))
+    {    
+      isVolatile_ = TRUE;
+    }
+
   CorrName savedTableName = getTableName();
   RelExpr * boundExpr = ExeUtilExpr::bindNode(bindWA);
   if (bindWA->errStatus()) 
     return NULL;
 
+  if ((NOT isVolatile_) &&
+      (NOT getTableName().isSeabase())) // can only create traf tables
+    {
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("DDL operations can only be done on 
trafodion or external tables.");
+
+      bindWA->setErrStatus();
+      return NULL;
+    }
+
   // open source path
-  if ((NOT getTableName().isSeabase()) ||
-      (createTableNode->isInMemoryObjectDefn()) ||
+  if ((createTableNode->isInMemoryObjectDefn()) ||
       (createTableNode->isMultiSetTable()) ||
       (createTableNode->isSetTable()))
     {
       return NULL;
     }
 
-
   NABoolean isSeabase = FALSE;
-  //  if (NATableDB::isHbaseTable(getTableName()))
   if (getTableName().isSeabase())
     {
       isSeabase = TRUE;
     }
 
-  if (createTableNode && (createTableNode->isVolatile()))
+  if (isVolatile_)
     {    
       getTableName() = savedTableName;
-      isVolatile_ = TRUE;
     }
 
   Int32 scannedInputCharset = 
createTableNode->getCreateTableAsScannedInputCharset();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/regress/compGeneral/DIFF042.KNOWN
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/DIFF042.KNOWN 
b/core/sql/regress/compGeneral/DIFF042.KNOWN
new file mode 100644
index 0000000..e73fb2d
--- /dev/null
+++ b/core/sql/regress/compGeneral/DIFF042.KNOWN
@@ -0,0 +1,88 @@
+1863c1863
+<  22 0 22
+---
+>  32 0 32
+1875c1875
+<  22 0 22
+---
+>  32 0 32
+1970a1971,1975
+>  0 1
+>  0 1
+>  0 1
+>  0 1
+>  0 1
+1980a1986,1990
+>  1 1
+>  1 1
+>  1 1
+>  1 1
+>  1 1
+1990c2000
+<  9 4
+---
+>  13 4
+1992c2002
+< --- 24 row(s) selected.
+---
+> --- 34 row(s) selected.
+2063a2074,2078
+>  0 1
+>  0 1
+>  0 1
+>  0 1
+>  0 1
+2085a2101,2105
+>  1 1
+>  1 1
+>  1 1
+>  1 1
+>  1 1
+2099c2119
+<  9 4
+---
+>  13 4
+2101c2121
+< --- 99 row(s) selected.
+---
+> --- 109 row(s) selected.
+2119c2139
+<  22 22 5 211
+---
+>  32 32 5 211
+2131c2151
+<  22 22 5 211
+---
+>  32 32 5 211
+2221a2242,2249
+>  227 0 1 0
+>  227 1 1 0
+>  233 0 1 0
+>  233 1 1 0
+>  270 0 1 0
+>  270 1 1 0
+>  282 0 1 0
+>  282 1 1 0
+2224a2253,2254
+>  336 0 1 14
+>  336 1 1 14
+2233c2263
+< --- 24 row(s) selected.
+---
+> --- 34 row(s) selected.
+2315a2346,2353
+>  227 0 1 0
+>  227 1 1 0
+>  233 0 1 0
+>  233 1 1 0
+>  270 0 1 0
+>  270 1 1 0
+>  282 0 1 0
+>  282 1 1 0
+2318a2357,2358
+>  336 0 1 14
+>  336 1 1 14
+2327c2367
+< --- 84 row(s) selected.
+---
+> --- 94 row(s) selected.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/regress/compGeneral/EXPECTED042
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED042 
b/core/sql/regress/compGeneral/EXPECTED042
index 8359519..a02e306 100644
--- a/core/sql/regress/compGeneral/EXPECTED042
+++ b/core/sql/regress/compGeneral/EXPECTED042
@@ -1,9 +1,9 @@
 >>showstats for table t042_orderline on ol_o_id detail;
 
 Detailed Histogram data for Table TRAFODION.ORDERENTRY.T042_ORDERLINE
-Table ID: 5178120267908624440
+Table ID: 5468040854252687878
 
-Hist ID:    1736168167
+Hist ID:    540592453
 Column(s):  OL_O_ID
 Total Rows: 10
 Total UEC:  4
@@ -1789,18 +1789,21 @@ HQC key=SELECT T . VARCHAR0_UNIQ AS T_VARCHAR0_UNIQ , T 
. CHAR2_2 AS T_CHAR2_2 ,
 >>-- test compile time
 >>
 >>sh more /proc/loadavg  | cut -d' ' -f 1-3 | sed -e 's/^/System load: /' >> 
 >>LOG042;
-System load: 0.64 1.30 0.89
+System load: ::::::::::::::
+System load: /proc/loadavg
+System load: ::::::::::::::
+System load: 0.49 0.49 0.47
 >>sh grep "model name" /proc/cpuinfo | head -1 | cut -d '@' -f 2 | sed -e 
 >>'s/^/CPU frequency: /' >> LOG042;
-CPU frequency: model name      : Intel Core Processor (Haswell)
+CPU frequency:  2.40GHz
 >>set statistics on;
 >>prepare xx from select * from t042_orderline where ol_o_id = 1 ;
 
 --- SQL command prepared.
 
-Start Time             2016/08/23 16:14:20.560188
-End Time               2016/08/23 16:14:20.562743
-Elapsed Time                      00:00:00.002555
-Compile Time                      00:00:00.002555
+Start Time             2016/09/08 10:05:44.474034
+End Time               2016/09/08 10:05:44.474891
+Elapsed Time                      00:00:00.000857
+Compile Time                      00:00:00.000857
 Execution Time                    00:00:00.000000
 
 
@@ -1831,10 +1834,10 @@ HQC key=SELECT * FROM T042_ORDERLINE WHERE OL_O_ID = 
#NP# ;
 
 --- SQL command prepared.
 
-Start Time             2016/08/23 16:14:20.742414
-End Time               2016/08/23 16:14:20.745059
-Elapsed Time                      00:00:00.002645
-Compile Time                      00:00:00.002645
+Start Time             2016/09/08 10:05:44.628323
+End Time               2016/09/08 10:05:44.628875
+Elapsed Time                      00:00:00.000552
+Compile Time                      00:00:00.000552
 Execution Time                    00:00:00.000000
 
 
@@ -1875,7 +1878,7 @@ NUM_ENTRIES  TEXT_ENTRIES  NUM_PLANS
 NUM_ENTRIES  TEXT_ENTRIES  NUM_PLANS 
 -----------  ------------  ----------
 
-         32             0          32
+         22             0          22
           2             0           2
 
 --- 2 row(s) selected.
@@ -1888,7 +1891,7 @@ NUM_ENTRIES  TEXT_ENTRIES  NUM_PLANS
 -----------  ------------  ----------
 
          65            10          65
-         32             0          32
+         22             0          22
           2             0           2
 
 --- 3 row(s) selected.
@@ -1984,11 +1987,6 @@ NUM_HITS    NUM_PARAMS
          0           1
          0           1
          0           1
-         0           1
-         0           1
-         0           1
-         0           1
-         0           1
          0           2
          0           2
          0           2
@@ -1999,11 +1997,6 @@ NUM_HITS    NUM_PARAMS
          0           5
          1           1
          1           1
-         1           1
-         1           1
-         1           1
-         1           1
-         1           1
          1           2
          1           2
          1           3
@@ -2013,9 +2006,9 @@ NUM_HITS    NUM_PARAMS
          2           1
          2           3
          3           3
-        13           4
+         9           4
 
---- 34 row(s) selected.
+--- 24 row(s) selected.
 >>select num_hits, num_params from table(querycacheentries('ustats', 'local')) 
 >>order by 1,2;
 
 --- 0 row(s) selected.
@@ -2087,11 +2080,6 @@ NUM_HITS    NUM_PARAMS
          0           1
          0           1
          0           1
-         0           1
-         0           1
-         0           1
-         0           1
-         0           1
          0           2
          0           2
          0           2
@@ -2114,11 +2102,6 @@ NUM_HITS    NUM_PARAMS
          1           1
          1           1
          1           1
-         1           1
-         1           1
-         1           1
-         1           1
-         1           1
          1           2
          1           2
          1           2
@@ -2132,9 +2115,9 @@ NUM_HITS    NUM_PARAMS
          2           3
          3           3
          5           1
-        13           4
+         9           4
 
---- 109 row(s) selected.
+--- 99 row(s) selected.
 >>
 >>
 >>--Stats in Hybrid Query Cache
@@ -2151,7 +2134,7 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
 NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  NUM_HASH_TABLE_BUCKETS
 ----------  ----------  ----------------------  ----------------------
 
-        32          32                       5                     211
+        22          22                       5                     211
          2           2                       5                     211
 
 --- 2 row(s) selected.
@@ -2164,7 +2147,7 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
 ----------  ----------  ----------------------  ----------------------
 
         37          60                       5                     211
-        32          32                       5                     211
+        22          22                       5                     211
          2           2                       5                     211
 
 --- 3 row(s) selected.
@@ -2255,19 +2238,9 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
        208           0              5               0
        222           0              3               1
        222           1              3               1
-       227           0              1               0
-       227           1              1               0
-       233           0              1               0
-       233           1              1               0
-       270           0              1               0
-       270           1              1               0
-       282           0              1               0
-       282           1              1               0
        314           0              3               1
        314           0              3               1
        314           2              1               0
-       336           0              1              14
-       336           1              1              14
        422           2              1               1
        487           0              2               3
        487           1              2               3
@@ -2276,7 +2249,7 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
        619           0              1              14
        619           0              1              14
 
---- 34 row(s) selected.
+--- 24 row(s) selected.
 >>select char_length(hkey), num_hits, num_PLiterals,  num_NPLiterals from 
 >>table(hybridquerycacheentries('ustats', 'local')) order by 1, 2, 3, 4;
 
 --- 0 row(s) selected.
@@ -2359,19 +2332,9 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
        208           0              5               0
        222           0              3               1
        222           1              3               1
-       227           0              1               0
-       227           1              1               0
-       233           0              1               0
-       233           1              1               0
-       270           0              1               0
-       270           1              1               0
-       282           0              1               0
-       282           1              1               0
        314           0              3               1
        314           0              3               1
        314           2              1               0
-       336           0              1              14
-       336           1              1              14
        422           2              1               1
        487           0              2               3
        487           1              2               3
@@ -2380,7 +2343,7 @@ NUM_HKEYS   NUM_SKEYS   NUM_MAX_VALUES_PER_KEY  
NUM_HASH_TABLE_BUCKETS
        619           0              1              14
        619           0              1              14
 
---- 94 row(s) selected.
+--- 84 row(s) selected.
 >>
 >>
 >>-- virtual table ISP queries are not cacheable.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/regress/seabase/EXPECTED031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED031 
b/core/sql/regress/seabase/EXPECTED031
index ddd736f..80e9419 100644
--- a/core/sql/regress/seabase/EXPECTED031
+++ b/core/sql/regress/seabase/EXPECTED031
@@ -567,7 +567,7 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION  
         CARD
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:15 2016
+-- Definition current  Thu Sep  8 19:35:44 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -598,7 +598,7 @@ A            B
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:23 2016
+-- Definition current  Thu Sep  8 19:35:49 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -649,7 +649,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:31 2016
+-- Definition current  Thu Sep  8 19:35:58 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -678,7 +678,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:41 2016
+-- Definition current  Thu Sep  8 19:36:06 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -703,7 +703,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:45 2016
+-- Definition current  Thu Sep  8 19:36:14 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -723,7 +723,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Thu Aug 11 21:06:48 2016
+-- Definition current  Thu Sep  8 19:36:23 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -738,7 +738,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Thu Aug 11 21:06:49 2016
+-- Definition current  Thu Sep  8 19:36:26 2016
 
   (
     A                                INT DEFAULT NULL
@@ -761,7 +761,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Thu Aug 11 21:06:56 2016
+-- Definition current  Thu Sep  8 19:36:33 2016
 
   (
     A                                INT DEFAULT NULL
@@ -779,7 +779,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Thu Aug 11 21:07:02 2016
+-- Definition current  Thu Sep  8 19:36:39 2016
 
   (
     A                                INT DEFAULT NULL
@@ -863,7 +863,7 @@ CREATE INDEX T031T1I1 ON TRAFODION.SCH.T031T1
 >>invoke table(index_table t031t1i1);
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1I1
--- Definition current  Thu Aug 11 21:07:19 2016
+-- Definition current  Thu Sep  8 19:37:03 2016
 
   (
     "A@"                             INT NO DEFAULT
@@ -872,5 +872,35 @@ CREATE INDEX T031T1I1 ON TRAFODION.SCH.T031T1
   PRIMARY KEY ("A@" ASC, SYSKEY ASC)
 
 --- SQL operation complete.
+>>reset parserflags;
+
+--- SQL operation complete.
+>>
+>>-- volatile and external table operation in default hive schema
+>>drop external table t031hive for hive.hive.t031hive;
+
+--- SQL operation complete.
+>>set schema hive.hive;
+
+--- SQL operation complete.
+>>create volatile table vtt (a int);
+
+--- SQL operation complete.
+>>create volatile index vtti on vtt(a);
+
+--- SQL operation complete.
+>>drop volatile index vtti;
+
+--- SQL operation complete.
+>>drop volatile table vtt;
+
+--- SQL operation complete.
+>>
+>>create external table t031hive for t031hive;
+
+--- SQL operation complete.
+>>drop external table t031hive for t031hive;
+
+--- SQL operation complete.
 >>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/regress/seabase/TEST010
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST010 b/core/sql/regress/seabase/TEST010
index ecc8fc9..c4e04ff 100644
--- a/core/sql/regress/seabase/TEST010
+++ b/core/sql/regress/seabase/TEST010
@@ -451,3 +451,4 @@ create volatile table vtab1 (a int);
 create volatile table vtab2 (a int);
 get all volatile schemas;
 get all volatile tables;
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/regress/seabase/TEST031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST031 b/core/sql/regress/seabase/TEST031
index edaee22..a6788f4 100644
--- a/core/sql/regress/seabase/TEST031
+++ b/core/sql/regress/seabase/TEST031
@@ -246,5 +246,17 @@ showddl t031t1;
 
 set parserflags 1;
 invoke table(index_table t031t1i1);
+reset parserflags;
+
+-- volatile and external table operation in default hive schema
+drop external table t031hive for hive.hive.t031hive;
+set schema hive.hive;
+create volatile table vtt (a int);
+create volatile index vtti on vtt(a);
+drop volatile index vtti;
+drop volatile table vtt;
+
+create external table t031hive for t031hive;
+drop external table t031hive for t031hive;
 
 log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8d0fce37/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index e4020e8..ba9fedc 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -5390,7 +5390,7 @@ short CmpSeabaseDDL::updateObjectRedefTime(
 
   char buf[4000];
 
-  Int64 redefTime = (rt == -1 ? NA_JulianTimestamp() : rt);
+  Int64 redefTime = ((rt == -1) ? NA_JulianTimestamp() : rt);
 
   NAString quotedSchName;
   ToQuotedString(quotedSchName, NAString(schName), FALSE);
@@ -5432,6 +5432,7 @@ short CmpSeabaseDDL::updateObjectRedefTime(
       CmpSeabaseDDL::setMDflags(flags, MD_OBJECTS_STORED_DESC);
     }
 
+  buf[0] = 0;
   if ((flags & MD_OBJECTS_STORED_DESC) != 0)
     {
       if (rt == -2)
@@ -5448,7 +5449,7 @@ short CmpSeabaseDDL::updateObjectRedefTime(
                     catName.data(), quotedSchName.data(), quotedObjName.data(),
                     objType);
     }
-  else
+  else if (rt != -2)
     {
       str_sprintf(buf, "update %s.\"%s\".%s set redef_time = %Ld where 
catalog_name = '%s' and schema_name = '%s' and object_name = '%s' and 
object_type = '%s' ",
                   getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
@@ -5457,14 +5458,17 @@ short CmpSeabaseDDL::updateObjectRedefTime(
                   objType);
     }
 
-  cliRC = cliInterface->executeImmediate(buf);
-  
-  if (cliRC < 0)
+  if (strlen(buf) > 0)
     {
-      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
-      return -1;
+      cliRC = cliInterface->executeImmediate(buf);
+      
+      if (cliRC < 0)
+        {
+          cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+          return -1;
+        }
     }
-  
+
   return 0;
 }
 

Reply via email to