[2/3] incubator-trafodion git commit: Update statistics auth check update from code review

2017-06-06 Thread rmarton
Update statistics auth check update from code review


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

Branch: refs/heads/master
Commit: d87f71d2db0e59883a218489af3129b28eac0e02
Parents: 63b275d
Author: Roberta Marton 
Authored: Tue Jun 6 16:02:25 2017 +
Committer: Roberta Marton 
Committed: Tue Jun 6 16:02:25 2017 +

--
 core/sql/ustat/hs_globals.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d87f71d2/core/sql/ustat/hs_globals.cpp
--
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 827304c..d78f5fc 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -3776,11 +3776,11 @@ NABoolean HSGlobalsClass::isAuthorized(NABoolean 
isShowStats)
if (privs == NULL)
  {
*CmpCommon::diags() << DgSqlCode(-1034);
-return FALSE;
+authorized = FALSE;
  }
 
// Requester must have at least select privilege
-   if ( privs->hasSelectPriv() )
+   else if ( privs->hasSelectPriv() )
  authorized = TRUE;
else
  {
@@ -3788,7 +3788,7 @@ NABoolean HSGlobalsClass::isAuthorized(NABoolean 
isShowStats)
 << DgSqlCode( -4481 )
 << DgString0( "SELECT or MANAGE_STATISTICS" )
 << DgString1( 
objDef->getNATable()->getTableName().getQualifiedNameAsAnsiString() );
-return FALSE;
+authorized = FALSE;
   }
}
 



[1/3] incubator-trafodion git commit: TRAFODION - 2632 Performing update statistics on metadata tables causes issues

2017-06-06 Thread rmarton
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master e57890a9b -> 5c0abc96e


TRAFODION - 2632 Performing update statistics on metadata tables causes issues

Added code to return error and cleanup code a bit:
*** ERROR[9205] UPDATE STATISTICS is not supported for object 

Also fixed a problem where privileges on Hive tables that included external
table gave false "no priv" error for the SHOWDDL  command.


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

Branch: refs/heads/master
Commit: 63b275d406e29bcaba1ab42e57a656bb8dd8ce31
Parents: 7643e58
Author: Roberta Marton 
Authored: Fri Jun 2 23:04:08 2017 +
Committer: Roberta Marton 
Committed: Fri Jun 2 23:04:08 2017 +

--
 core/sql/sqlcomp/CmpDescribe.cpp | 82 ++-
 core/sql/sqlcomp/CmpSeabaseDDL.h |  8 ++--
 core/sql/ustat/hs_globals.cpp|  4 +-
 core/sql/ustat/hs_globals.h  | 12 ++---
 core/sql/ustat/hs_parser.cpp | 77 +++-
 core/sql/ustat/hs_util.cpp   | 10 ++---
 6 files changed, 64 insertions(+), 129 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63b275d4/core/sql/sqlcomp/CmpDescribe.cpp
--
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index d3bd49a..5116df9 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -2982,53 +2982,57 @@ short CmpDescribeSeabaseTable (
   // Verify that user can perform the describe command
   // No need to check privileges for create like operations (type 3)
   // since the create code performs authorization checks
-  if (type != 3)
-{
-  PrivMgrUserPrivs privs; 
-  PrivMgrUserPrivs *pPrivInfo = NULL;
+  // Nor for hiveExternal tables - already checked
+  if (!isExternalHiveTable)
+  {
+if (type != 3)
+  {
+PrivMgrUserPrivs privs; 
+PrivMgrUserPrivs *pPrivInfo = NULL;
 
-  // metadata tables do not cache privilege information, go get it now
-  if (CmpCommon::context()->isAuthorizationEnabled() &&
-  naTable->getPrivInfo() == NULL)
-{
-  std::string 
privMDLoc(ActiveSchemaDB()->getDefaults().getValue(SEABASE_CATALOG));
-  privMDLoc += std::string(".\"") +
- std::string(SEABASE_PRIVMGR_SCHEMA) +
- std::string("\"");
-  PrivMgrCommands privInterface(privMDLoc, CmpCommon::diags(), 
-PrivMgr::PRIV_INITIALIZED);
-
-
-  // we should switch to another CI only if we are in an embedded CI
-  if (cmpSBD.switchCompiler())
+// metadata tables do not cache privilege information, go get it now
+if (CmpCommon::context()->isAuthorizationEnabled() &&
+naTable->getPrivInfo() == NULL)
   {
- *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
- return -1;
-  }
- 
-  PrivStatus retcode = 
privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
-   
naTable->getObjectType(),
-   
ComUser::getCurrentUser(),
-   privs);
+std::string 
privMDLoc(ActiveSchemaDB()->getDefaults().getValue(SEABASE_CATALOG));
+privMDLoc += std::string(".\"") +
+   std::string(SEABASE_PRIVMGR_SCHEMA) +
+   std::string("\"");
+PrivMgrCommands privInterface(privMDLoc, CmpCommon::diags(), 
+  PrivMgr::PRIV_INITIALIZED);
 
-  // switch back the original commpiler, ignore error for now
-  cmpSBD.switchBackCompiler();
 
-  if (retcode == STATUS_ERROR)
+// we should switch to another CI only if we are in an embedded CI
+if (cmpSBD.switchCompiler())
 {
-  *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
-  return -1;
+   *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+   return -1;
 }
-  pPrivInfo = &privs;
-}
-  else
-pPrivInfo = naTable->getPrivInfo();
+ 
+PrivStatus retcode = 
privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
+ 
naTable->getObjectType(),
+ 
C

[3/3] incubator-trafodion git commit: Merge [TRAFODION 2632] pr #1106 update stats fix

2017-06-06 Thread rmarton
Merge [TRAFODION 2632] pr #1106 update stats fix


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

Branch: refs/heads/master
Commit: 5c0abc96e7db040ce089e8c7f44d1401ca3731e8
Parents: e57890a d87f71d
Author: Roberta Marton 
Authored: Wed Jun 7 00:08:48 2017 +
Committer: Roberta Marton 
Committed: Wed Jun 7 00:08:48 2017 +

--
 core/sql/sqlcomp/CmpDescribe.cpp | 82 ++-
 core/sql/sqlcomp/CmpSeabaseDDL.h |  8 ++--
 core/sql/ustat/hs_globals.cpp|  2 +-
 core/sql/ustat/hs_globals.h  | 12 ++---
 core/sql/ustat/hs_parser.cpp | 77 +++-
 core/sql/ustat/hs_util.cpp   | 10 ++---
 6 files changed, 63 insertions(+), 128 deletions(-)
--




[2/3] incubator-trafodion git commit: Update expected results for core/TEST038

2017-06-06 Thread dbirdsall
Update expected results for core/TEST038


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

Branch: refs/heads/master
Commit: d62eea53814d73e881dec03459226ce5dc338b78
Parents: 14e132b
Author: Dave Birdsall 
Authored: Mon Jun 5 22:32:24 2017 +
Committer: Dave Birdsall 
Committed: Mon Jun 5 22:32:24 2017 +

--
 core/sql/regress/core/EXPECTED038.LINUX | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d62eea53/core/sql/regress/core/EXPECTED038.LINUX
--
diff --git a/core/sql/regress/core/EXPECTED038.LINUX 
b/core/sql/regress/core/EXPECTED038.LINUX
index e45211d..3d86052 100644
--- a/core/sql/regress/core/EXPECTED038.LINUX
+++ b/core/sql/regress/core/EXPECTED038.LINUX
@@ -243,10 +243,10 @@ ORDER_NUMORDER_DATE  ORDER_TIME  ORDER_QTY
 ---  --  --  ---
 
 100  1997-01-3013:40:05 1000
-200  2017-06-0518:32:25   99
+200  2017-06-0521:43:42   99
 300  1996-08-1010:20:10 6000
-400  1997-05-1218:32:25   99
-500  2017-06-0518:32:25   99
+400  1997-05-1221:43:42   99
+500  2017-06-0521:43:42   99
 
 --- 5 row(s) selected.
 >>
@@ -264,7 +264,7 @@ ORDER_NUMORDER_DATE  ORDER_TIME  ORDER_QTY
 T038PART_NUM  ORDER_TIME
   --
 
- 600  2017-06-05 18:32:29.319949
+ 600  2017-06-05 21:43:45.699265
 
 --- 1 row(s) selected.
 >>
@@ -661,9 +661,9 @@ GANESAN   DEV   YOW
 EMPNUM   EMPNAME   DEPTNUM  DEPTNUM  DEPTNAME  
MANAGER   UNITNUM  DEPTNUM  REVENVUE
 ---    ---  ---  
    ---  ---  

 
-100  GANESAN  6400 6400  DEV   
YOW   101 6400 1.000
-100  RAO  6500 6500  QA
DENNIS  ?? ?
 100  BHAVE6400 6400  DEV   
YOW   101 6400 1.000
+100  RAO  6500 6500  QA
DENNIS  ?? ?
+100  GANESAN  6400 6400  DEV   
YOW   101 6400 1.000
 
 --- 3 row(s) selected.
 >>SELECT *
@@ -674,9 +674,8 @@ EMPNUM   EMPNAME   DEPTNUM  DEPTNUM 
 DEPTNAME
 EMPNUM   EMPNAME   DEPTNUM  DEPTNUM  DEPTNAME  
MANAGER   UNITNUM  DEPTNUM  REVENVUE
 ---    ---  ---  
    ---  ---  

 
-100  BHAVE6400 6400  DEV   
YOW   101 6400 1.000
-100  GANESAN  6400 6400  DEV   
YOW   101 6400 1.000
 100  RAO  6500 6500  QA
DENNIS  ?? ?
+100  BHAVE6400 6400  DEV   
YOW   101 6400 1.000
 100  GANESAN  6400 6400  DEV   
YOW   101 6400 1.000
 
 --- 3 row(s) selected.
@@ -690,8 +689,8 @@ EMPNUM   EMPNAME   DEPTNUM  DEPTNUM 
 DEPTNAME
 EMPNUM   EMPNAME   DEPTNUM  DEPTNUM  DEPTNAME  
MANAGER   UNITNUM  DEPTNUM  REVENVUE
 ---    ---  ---  
    ---  ---  

 
-100  GANESAN  6400 6400  DEV   
YOW   101 6400 1.000
 100  RAO  6500 6500  QA
DENNIS  ??  

[1/3] incubator-trafodion git commit: [TRAFODION-2634] Change return type of FLOOR/CEIL to an integer type

2017-06-06 Thread dbirdsall
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master cb0a7242e -> e57890a9b


[TRAFODION-2634] Change return type of FLOOR/CEIL to an integer type


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

Branch: refs/heads/master
Commit: 14e132bddb73090e58d1bee4385f7fc6b0fca7a1
Parents: 52cca83
Author: Dave Birdsall 
Authored: Mon Jun 5 18:59:56 2017 +
Committer: Dave Birdsall 
Committed: Mon Jun 5 21:32:23 2017 +

--
 core/sql/common/NumericType.cpp |   2 +
 core/sql/exp/exp_conv.cpp   |  34 +
 core/sql/exp/exp_math_func.cpp  | 220 ++-
 core/sql/optimizer/ItemFunc.h   |   2 +
 core/sql/optimizer/SynthType.cpp|  72 -
 core/sql/regress/core/EXPECTED038.LINUX |  70 +++--
 core/sql/regress/core/TEST038   |  21 +++
 7 files changed, 403 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/14e132bd/core/sql/common/NumericType.cpp
--
diff --git a/core/sql/common/NumericType.cpp b/core/sql/common/NumericType.cpp
index 34206a3..2ee1e5c 100644
--- a/core/sql/common/NumericType.cpp
+++ b/core/sql/common/NumericType.cpp
@@ -1905,6 +1905,7 @@ double SQLNumeric::getMinValue() const
break;
 
case sizeof(short):
+   case sizeof(Int8):
{
   short temp = 0;
   Lng32 i=0;
@@ -1969,6 +1970,7 @@ double SQLNumeric::getMaxValue() const
 break;
 
 case sizeof(short):
+case sizeof(Int8):
 {
   short temp = 0;
   Lng32 i=0;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/14e132bd/core/sql/exp/exp_conv.cpp
--
diff --git a/core/sql/exp/exp_conv.cpp b/core/sql/exp/exp_conv.cpp
index 3477d4d..8467be4 100644
--- a/core/sql/exp/exp_conv.cpp
+++ b/core/sql/exp/exp_conv.cpp
@@ -2387,6 +2387,40 @@ ex_expr::exp_return_type convAsciiToDec(char *target,
 };
 
 ///
+// function to convert a DOUBLE to BIGNUM. 
+///
+NA_EIDPROC
+ex_expr::exp_return_type convDoubleToBigNum(char *target,
+Lng32 targetLen,
+Lng32 targetType,
+Lng32 targetPrecision,
+Lng32 targetScale,
+double source,
+CollHeap *heap,
+ComDiagsArea** diagsArea)
+{
+  SimpleType sourceAttr(REC_FLOAT64, sizeof(double), 0, 0,
+ExpTupleDesc::SQLMX_FORMAT,
+8, 0, 0, 0, Attributes::NO_DEFAULT, 0);
+  char * opData[2];
+  opData[0] = target;
+  opData[1] = (char*)&source;
+  NABoolean isSigned = (targetType == REC_NUM_BIG_SIGNED);
+  BigNum bn(targetLen, targetPrecision, (short)targetScale, isSigned);
+  bn.setTempSpaceInfo(ITM_CAST, 0, targetLen);
+  if (bn.castFrom(&sourceAttr, opData, heap, diagsArea) != 0)
+{
+  ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW, 
+(char*)&source,
+8, REC_FLOAT64, 0, targetType, 0 /* flags */);
+ 
+  return ex_expr::EXPR_ERROR; 
+}
+
+  return ex_expr::EXPR_OK;
+}
+
+///
 // function to convert an ASCII string to BIGNUM. 
 // 
 // First convert from ASCII to LARGEDEC, then convert from LARGEDEC

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/14e132bd/core/sql/exp/exp_math_func.cpp
--
diff --git a/core/sql/exp/exp_math_func.cpp b/core/sql/exp/exp_math_func.cpp
index 6978430..b4c9778 100644
--- a/core/sql/exp/exp_math_func.cpp
+++ b/core/sql/exp/exp_math_func.cpp
@@ -76,6 +76,23 @@
 #define HUGE_VAL_REAL64 1.15792089237316192E+77
 #define HUGE_VAL_INT64  07
 
+NA_EIDPROC
+ex_expr::exp_return_type convInt64ToDec(char *target,
+Lng32 targetLen,
+Int64 source,
+CollHeap *heap,
+ComDiagsArea** diagsArea);
+
+NA_EIDPROC
+ex_e

[3/3] incubator-trafodion git commit: Merge [TRAFODION-2634] PR 1111 Change return of FLOOR/CEIL to integer type

2017-06-06 Thread dbirdsall
Merge [TRAFODION-2634] PR  Change return of FLOOR/CEIL to integer type


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

Branch: refs/heads/master
Commit: e57890a9b9693ed6a9f3a2fc24f8788d09c0efe0
Parents: cb0a724 d62eea5
Author: Dave Birdsall 
Authored: Tue Jun 6 23:41:31 2017 +
Committer: Dave Birdsall 
Committed: Tue Jun 6 23:41:31 2017 +

--
 core/sql/common/NumericType.cpp |   2 +
 core/sql/exp/exp_conv.cpp   |  34 +
 core/sql/exp/exp_math_func.cpp  | 220 ++-
 core/sql/optimizer/ItemFunc.h   |   2 +
 core/sql/optimizer/SynthType.cpp|  72 -
 core/sql/regress/core/EXPECTED038.LINUX |  67 ++--
 core/sql/regress/core/TEST038   |  21 +++
 7 files changed, 401 insertions(+), 17 deletions(-)
--