trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmar...@apache.org
Subject [1/4] trafodion git commit: TRAFODION-3046: Privilege support for native HBase tables
Date Fri, 11 May 2018 18:33:11 GMT
Repository: trafodion
Updated Branches:
  refs/heads/master 5fa28f37b -> a5b67c9e9


http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED022 b/core/sql/regress/seabase/EXPECTED022
index b1efc0f..bbdb252 100644
--- a/core/sql/regress/seabase/EXPECTED022
+++ b/core/sql/regress/seabase/EXPECTED022
@@ -8,6 +8,8 @@
 >>
 >>drop hbase table T022HBT1;
 
+*** WARNING[1004] Object T022HBT1 does not exist or object type is invalid for the current operation.
+
 --- SQL operation complete.
 >>create hbase table T022HBT1 (column family 'cf');
 
@@ -15,6 +17,8 @@
 >>
 >>drop hbase table T022HBT2;
 
+*** WARNING[1004] Object T022HBT2 does not exist or object type is invalid for the current operation.
+
 --- SQL operation complete.
 >>create hbase table T022HBT2 (column family 'cf');
 
@@ -406,7 +410,7 @@ ROW_ID      (EXPR)
 
 >>insert into hbase."_ROW_".t022hbt1 values ('2', column_create(':b', '201'));
 
-*** ERROR[1426] An invalid HBase column name :b was specified. A valid name must be of the format:   <ColumnFamily>:<ColumnName>
+*** ERROR[1426] An invalid HBase column name :b was specified. A valid name must be of the format: <ColumnFamily>:<ColumnName>
 
 --- 0 row(s) inserted.
 >>insert into hbase."_ROW_".t022hbt1 values ('2', '100');
@@ -426,7 +430,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_CELL_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current  Mon May 15 01:28:23 2017
+-- Definition current  Wed May  9 21:08:44 2018
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -445,7 +449,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_ROW_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current  Mon May 15 01:28:24 2017
+-- Definition current  Wed May  9 21:08:44 2018
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -465,7 +469,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_CELL_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current  Mon May 15 01:28:24 2017
+-- Definition current  Wed May  9 21:08:45 2018
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -484,7 +488,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_ROW_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current  Mon May 15 01:28:25 2017
+-- Definition current  Wed May  9 21:08:45 2018
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -576,6 +580,8 @@ ROW_ID      (EXPR)
 >>
 >>drop hbase table t022hbm1;
 
+*** WARNING[1004] Object T022HBM1 does not exist or object type is invalid for the current operation.
+
 --- SQL operation complete.
 >>create hbase table t022hbm1 (column family 'cf');
 
@@ -603,7 +609,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:28:41 2017
+-- Definition current  Wed May  9 21:09:03 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -619,7 +625,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:28:41 2017
+-- Definition current  Wed May  9 21:09:04 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -636,7 +642,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T022HBM1
--- Definition current  Mon May 15 01:28:44 2017
+-- Definition current  Wed May  9 21:09:09 2018
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -667,7 +673,7 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:28:50 2017
+-- Definition current  Wed May  9 21:09:18 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -727,7 +733,7 @@ a2              ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:28:55 2017
+-- Definition current  Wed May  9 21:09:27 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -750,7 +756,7 @@ a2              ?
 >>invoke t022hbm1_like;
 
 -- Definition of Trafodion table TRAFODION.SCH.T022HBM1_LIKE
--- Definition current  Mon May 15 01:29:01 2017
+-- Definition current  Wed May  9 21:09:36 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -812,7 +818,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:22 2017
+-- Definition current  Wed May  9 21:10:05 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -829,7 +835,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:25 2017
+-- Definition current  Wed May  9 21:10:14 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -845,7 +851,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:28 2017
+-- Definition current  Wed May  9 21:10:18 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -908,7 +914,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:41 2017
+-- Definition current  Wed May  9 21:10:29 2018
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -968,7 +974,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:47 2017
+-- Definition current  Wed May  9 21:10:40 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -991,7 +997,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:52 2017
+-- Definition current  Wed May  9 21:10:50 2018
 
   (
     "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1013,7 +1019,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:29:56 2017
+-- Definition current  Wed May  9 21:10:56 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1035,7 +1041,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:30:01 2017
+-- Definition current  Wed May  9 21:11:02 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1058,7 +1064,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:30:06 2017
+-- Definition current  Wed May  9 21:11:08 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1082,7 +1088,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:30:11 2017
+-- Definition current  Wed May  9 21:11:14 2018
 
   (
     "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1105,7 +1111,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:30:15 2017
+-- Definition current  Wed May  9 21:11:20 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1157,7 +1163,7 @@ A            B            C
 >>invoke t022hbm2;
 
 -- Definition of Trafodion HBase mapped table T022HBM2
--- Definition current  Mon May 15 01:30:31 2017
+-- Definition current  Wed May  9 21:12:10 2018
 
   (
     "cf1".A                          INT DEFAULT NULL
@@ -1203,7 +1209,7 @@ A            B            Z
 >>invoke t022hbm2;
 
 -- Definition of Trafodion HBase mapped table T022HBM2
--- Definition current  Mon May 15 01:30:52 2017
+-- Definition current  Wed May  9 21:12:38 2018
 
   (
     "cf1".A                          INT DEFAULT NULL
@@ -1245,9 +1251,21 @@ CREATE TABLE HBASE."_CELL_".T022HBM2
 /* HBase DDL */
 CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
+REGISTER /*INTERNAL*/ HBASE TABLE T022HBM2;
+/* ObjectUID = 6815232663752156408 */
+
 --- SQL operation complete.
 >>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 
+HBase Registered Tables in Catalog TRAFODION
+============================================
+
+"_CELL_".T022HBM2
+"_ROW_".T022HBM2
+
+--- SQL operation complete.
+>>unregister hbase table t022hbm2;
+
 --- SQL operation complete.
 >>register hbase table t022hbm2;
 
@@ -1284,7 +1302,7 @@ CREATE TABLE HBASE."_CELL_".T022HBM2
 CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
 REGISTER HBASE TABLE T022HBM2;
-/* ObjectUID = 8642537124144485947 */
+/* ObjectUID = 6733604920502068557 */
 
 --- SQL operation complete.
 >>showddl hbase."_ROW_".t022hbm2;
@@ -1305,7 +1323,7 @@ CREATE TABLE HBASE."_ROW_".T022HBM2
 CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
 REGISTER HBASE TABLE T022HBM2;
-/* ObjectUID = 8642537124144485957 */
+/* ObjectUID = 6733604920502068566 */
 
 --- SQL operation complete.
 >>unregister hbase table t022hbm2;
@@ -1345,15 +1363,15 @@ CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 >>showstats for table hbase."_CELL_".t022hbm2 on every column;
 
 Histogram data for Table HBASE."_CELL_".T022HBM2
-Table ID: 8849702707055529909
+Table ID: 7262214926783681707
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
-2003317081      1           2           1 ROW_ID
-2003317076      2           2           2 COL_FAMILY
-2003317071      2           2           2 COL_NAME
-2003317066      1           2           1 COL_TIMESTAMP
-2003317061      2           2           2 COL_VALUE
+1401377310      1           2           1 ROW_ID
+1401377305      2           2           2 COL_FAMILY
+1401377300      2           2           2 COL_NAME
+1401377295      1           2           1 COL_TIMESTAMP
+1401377290      2           2           2 COL_VALUE
 
 
 --- SQL operation complete.
@@ -1387,6 +1405,9 @@ CREATE TABLE HBASE."_CELL_".T022HBM2
 /* HBase DDL */
 CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
+REGISTER /*INTERNAL*/ HBASE TABLE T022HBM2;
+/* ObjectUID = 7262214926783681707 */
+
 --- SQL operation complete.
 >>
 >>showstats for table hbase."_ROW_".t022hbm2 on every column;
@@ -1407,15 +1428,15 @@ No Histograms exist for the requested columns or groups
 >>showstats for table hbase."_CELL_".t022hbm2 on every column;
 
 Histogram data for Table HBASE."_CELL_".T022HBM2
-Table ID: 8849702707055529909
+Table ID: 7262214926783681707
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
-2003317080      1           2           1 ROW_ID
-2003317077      2           2           2 COL_FAMILY
-2003317070      2           2           2 COL_NAME
-2003317067      1           2           1 COL_TIMESTAMP
-2003317060      2           2           2 COL_VALUE
+1401377311      1           2           1 ROW_ID
+1401377304      2           2           2 COL_FAMILY
+1401377301      2           2           2 COL_NAME
+1401377294      1           2           1 COL_TIMESTAMP
+1401377291      2           2           2 COL_VALUE
 
 
 --- SQL operation complete.
@@ -1449,12 +1470,15 @@ CREATE TABLE HBASE."_CELL_".T022HBM2
 /* HBase DDL */
 CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
+REGISTER /*INTERNAL*/ HBASE TABLE T022HBM2;
+/* ObjectUID = 7262214926783681707 */
+
 --- SQL operation complete.
 >>
 >>showstats for table hbase."_MAP_".t022hbm2 on every column;
 
 Histogram data for Table HBASE."_MAP_".T022HBM2
-Table ID: 8642537124144485432
+Table ID: 6733604920502066913
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
@@ -1469,13 +1493,13 @@ No Histograms exist for the requested columns or groups
 >>showstats for table hbase."_MAP_".t022hbm2 on every column;
 
 Histogram data for Table HBASE."_MAP_".T022HBM2
-Table ID: 8642537124144485432
+Table ID: 6733604920502066913
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
-2023711938      1           1           1 A
-2023711933      1           1           1 B
-2023711928      1           1           1 Z
+1428445837      1           1           1 A
+1428445832      1           1           1 B
+1428445827      1           1           1 Z
 
 
 --- SQL operation complete.
@@ -1515,7 +1539,7 @@ a1             10
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon May 15 01:31:41 2017
+-- Definition current  Wed May  9 21:13:46 2018
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1688,6 +1712,12 @@ a1             10
 >>create hbase table t022hbm1 (column family 'cf');
 
 --- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++>        primary key (a)
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
 >>insert into hbase."_ROW_".t022hbm1 values ('a1234567', 
 +>                               column_create(('cf:B', '10')));
 
@@ -1705,6 +1735,12 @@ a1             10
 >>create hbase table t022hbm1 (column family 'cf');
 
 --- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++>        primary key (a)
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
 >>insert into hbase."_ROW_".t022hbm1 values ('a1', 
 +>                               column_create(('cf:B', '1000000')));
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/regress/seabase/EXPECTED026
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED026 b/core/sql/regress/seabase/EXPECTED026
index fb16c30..744bc4f 100644
--- a/core/sql/regress/seabase/EXPECTED026
+++ b/core/sql/regress/seabase/EXPECTED026
@@ -307,9 +307,8 @@ Metadata Cleanup: done
 
 
 --- SQL operation complete.
->>drop hbase table "TRAFODION.SCH026.T026T10";
-
---- SQL operation complete.
+>>-- drop hbase table "TRAFODION.SCH026.T026T10" from hbase shell
+>>sh regrhbase.ksh $REGRTSTDIR/TEST026_drop_hbase &> $REGRRUNDIR/TEST026_drop_hbase.log ;
 >>set parserflags 131072;
 
 --- SQL operation complete.
@@ -358,14 +357,14 @@ Metadata Cleanup: started, check only
 
   Start: Cleanup Inconsistent Objects Entries
     Entry #1(OBJECT): TRAFODION.SCH026.T026T12
-    Entry #2(OBJECT): TRAFODION.SCH026.T026T20_438564838_6459
-    Entry #3(OBJECT): TRAFODION.SCH026.T026T2_442664838_6459
+    Entry #2(OBJECT): TRAFODION.SCH026.T026T20_623875359_1692
+    Entry #3(OBJECT): TRAFODION.SCH026.T026T2_736875359_1692
     Entry #4(OBJECT): TRAFODION.SCH026.SB_HISTOGRAMS_PK
     Entry #5(OBJECT): TRAFODION.SCH026.SB_HISTOGRAM_INTERVALS_PK
     Entry #6(OBJECT): TRAFODION.SCH026.SB_PERSISTENT_SAMPLES_PK
-    Entry #7(OBJECT): TRAFODION.SCH026.LOBMD__0210724475547_466795482_9143
-    Entry #8(OBJECT): TRAFODION.SCH026.LOBDescChunks__02107_334895482_9143
-    Entry #9(UID):    2107244755479165497
+    Entry #7(OBJECT): TRAFODION.SCH026.LOBMD__0550637332294_683639881_4496
+    Entry #8(OBJECT): TRAFODION.SCH026.LOBDescChunks__05506_433739881_4496
+    Entry #9(UID):    5506373322942721563
   End:   Cleanup Inconsistent Objects Entries (9 entries found)
 
   Start: Cleanup Inconsistent Views Entries
@@ -391,14 +390,14 @@ Metadata Cleanup: started
 
   Start: Cleanup Inconsistent Objects Entries
     Entry #1(OBJECT): TRAFODION.SCH026.T026T12
-    Entry #2(OBJECT): TRAFODION.SCH026.T026T20_438564838_6459
-    Entry #3(OBJECT): TRAFODION.SCH026.T026T2_442664838_6459
+    Entry #2(OBJECT): TRAFODION.SCH026.T026T20_623875359_1692
+    Entry #3(OBJECT): TRAFODION.SCH026.T026T2_736875359_1692
     Entry #4(OBJECT): TRAFODION.SCH026.SB_HISTOGRAMS_PK
     Entry #5(OBJECT): TRAFODION.SCH026.SB_HISTOGRAM_INTERVALS_PK
     Entry #6(OBJECT): TRAFODION.SCH026.SB_PERSISTENT_SAMPLES_PK
-    Entry #7(OBJECT): TRAFODION.SCH026.LOBMD__0210724475547_466795482_9143
-    Entry #8(OBJECT): TRAFODION.SCH026.LOBDescChunks__02107_334895482_9143
-    Entry #9(UID):    2107244755479165497
+    Entry #7(OBJECT): TRAFODION.SCH026.LOBMD__0550637332294_683639881_4496
+    Entry #8(OBJECT): TRAFODION.SCH026.LOBDescChunks__05506_433739881_4496
+    Entry #9(UID):    5506373322942721563
   End:   Cleanup Inconsistent Objects Entries (9 entries cleaned up)
 
   Start: Cleanup Inconsistent Views Entries

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST022 b/core/sql/regress/seabase/TEST022
index 39da1c7..f68224d 100644
--- a/core/sql/regress/seabase/TEST022
+++ b/core/sql/regress/seabase/TEST022
@@ -386,6 +386,7 @@ select * from t022hbm2;
 
 showddl hbase."_CELL_".t022hbm2;
 get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+unregister hbase table t022hbm2;
 register hbase table t022hbm2;
 get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 showddl hbase."_CELL_".t022hbm2;
@@ -493,6 +494,10 @@ select * from t022hbm1;
 
 drop hbase table t022hbm1;
 create hbase table t022hbm1 (column family 'cf');
+create external table t022hbm1 (a varchar(4) not null, b int)
+        primary key (a)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
 insert into hbase."_ROW_".t022hbm1 values ('a1234567', 
                                column_create(('cf:B', '10')));
 -- primary key col length must be big enough to hold rowID
@@ -500,6 +505,10 @@ select * from t022hbm1;
 
 drop hbase table t022hbm1;
 create hbase table t022hbm1 (column family 'cf');
+create external table t022hbm1 (a varchar(4) not null, b int)
+        primary key (a)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
 insert into hbase."_ROW_".t022hbm1 values ('a1', 
                                column_create(('cf:B', '1000000')));
 -- buffer to retrieve column value must be big enough
@@ -519,4 +528,5 @@ drop table t022hbm1_like;
 drop table t022hbm1_ctas;
 drop table t022t1;
 drop table t022hbm1 cascade;
+drop table t022hbm2;
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/regress/seabase/TEST026
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST026 b/core/sql/regress/seabase/TEST026
index fcc27f8..b16ba51 100644
--- a/core/sql/regress/seabase/TEST026
+++ b/core/sql/regress/seabase/TEST026
@@ -125,7 +125,8 @@ create table t026t10(a int);
 create table t026t11(a int);
 create table t026t12(a int);
 cleanup metadata, check;
-drop hbase table "TRAFODION.SCH026.T026T10";
+-- drop hbase table "TRAFODION.SCH026.T026T10" from hbase shell
+sh regrhbase.ksh $REGRTSTDIR/TEST026_drop_hbase &> $REGRRUNDIR/TEST026_drop_hbase.log ;
 set parserflags 131072;
 delete from "_MD_".objects where schema_name = 'SCH026' and object_name = 'T026T11';
 set parserflags 1;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/regress/seabase/TEST026_drop_hbase
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST026_drop_hbase b/core/sql/regress/seabase/TEST026_drop_hbase
new file mode 100644
index 0000000..3586da0
--- /dev/null
+++ b/core/sql/regress/seabase/TEST026_drop_hbase
@@ -0,0 +1,26 @@
+#######################################################################
+# @@@ 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 @@@
+#######################################################################
+disable 'TRAFODION.SCH026.T026T10'
+drop 'TRAFODION.SCH026.T026T10'
+exit
+

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
index b58189e..3c22d90 100644
--- a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
+++ b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
@@ -58,7 +58,7 @@ enum CatErrorCode { CAT_FIRST_ERROR = 1000
                   // unused                                       = 1023
                   // unused                                       = 1024
                   , CAT_DEPENDENT_OBJECTS_EXIST                   = 1025
-                  // unused                                       = 1026
+                  , CAT_REG_UNREG_OBJECTS                         = 1026
                   , CAT_COLUMN_PRIVILEGE_NOT_ALLOWED              = 1027
                   , CAT_SCHEMA_IS_NOT_EMPTY                       = 1028
                   , CAT_UNABLE_TO_CREATE_OBJECT                   = 1029

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index 7eaf0d6..97f2014 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3007,6 +3007,16 @@ short CmpDescribeSeabaseTable (
   {
     if (type != 3)
       {
+        // For native HBase tables that have no objectUID, we can't check 
+        // user privileges so only allow operation for privileged users
+        if (isHbaseCellOrRowTable && 
+            !ComUser::isRootUserID() && !ComUser::currentUserHasRole(HBASE_ROLE_ID) &&
+            naTable->objectUid().get_value() == 0) 
+        {
+          *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+          return -1;
+        }
+ 
         PrivMgrUserPrivs privs; 
         PrivMgrUserPrivs *pPrivInfo = NULL;
     
@@ -3028,7 +3038,7 @@ short CmpDescribeSeabaseTable (
                *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
                return -1;
             }
- 
+           
             PrivStatus retcode = privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
                                                              naTable->getObjectType(),
                                                              ComUser::getCurrentUser(),
@@ -3047,11 +3057,15 @@ short CmpDescribeSeabaseTable (
         else
           pPrivInfo = naTable->getPrivInfo();
 
-
-        if (!CmpDescribeIsAuthorized(SQLOperation::UNKNOWN, 
-                                     pPrivInfo,
-                                     COM_BASE_TABLE_OBJECT))
-          return -1;
+        // Allow object owners to perform showddl operation
+        if ((naTable->getOwner() != ComUser::getCurrentUser()) &&
+            !ComUser::currentUserHasRole(naTable->getOwner()))
+        {
+          if (!CmpDescribeIsAuthorized(SQLOperation::UNKNOWN, 
+                                       pPrivInfo,
+                                       COM_BASE_TABLE_OBJECT))
+            return -1;
+        }
       }
     }
   

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index c6ff74b..a08a345 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -1406,12 +1406,14 @@ protected:
   
 
  void createNativeHbaseTable(
-			     StmtDDLCreateHbaseTable                  * createTableNode,
-			     NAString &currCatName, NAString &currSchName);
+                             ExeCliInterface *cliInterface,
+                             StmtDDLCreateHbaseTable * createTableNode,
+                             NAString &currCatName, NAString &currSchName);
 
  void dropNativeHbaseTable(
-			     StmtDDLDropHbaseTable                  * createTableNode,
-			     NAString &currCatName, NAString &currSchName);
+                             ExeCliInterface *cliInterface,
+                             StmtDDLDropHbaseTable * dropTableNode,
+                             NAString &currCatName, NAString &currSchName);
   
   void initSeabaseMD(NABoolean ddlXns, NABoolean minimal);
   void dropSeabaseMD(NABoolean ddlXns);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 314486e..b97feba 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -9138,7 +9138,7 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
           StmtDDLCreateHbaseTable * createTableParseNode =
             ddlNode->castToStmtDDLNode()->castToStmtDDLCreateHbaseTable();
           
-          createNativeHbaseTable(createTableParseNode, currCatName, currSchName);
+          createNativeHbaseTable(&cliInterface, createTableParseNode, currCatName, currSchName);
         }
       else if (ddlNode->getOperatorType() == DDL_DROP_TABLE)
         {
@@ -9154,7 +9154,7 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
           StmtDDLDropHbaseTable * dropTableParseNode =
             ddlNode->castToStmtDDLNode()->castToStmtDDLDropHbaseTable();
           
-          dropNativeHbaseTable(dropTableParseNode, currCatName, currSchName);
+          dropNativeHbaseTable(&cliInterface, dropTableParseNode, currCatName, currSchName);
         }
        else if (ddlNode->getOperatorType() == DDL_CREATE_INDEX)
         {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index a2eb2a4..46c92b3 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -9915,6 +9915,20 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
 
   std::string objectName (extTableName.data());
 
+  // Map hbase map table to external name
+  if (ComIsHBaseMappedIntFormat(catalogNamePart, schemaNamePart))
+  {
+    NAString newCatName;
+    NAString newSchName;
+    ComConvertHBaseMappedIntToExt(catalogNamePart, schemaNamePart,
+                                  newCatName, newSchName);
+    objectName = newCatName.data() + std::string(".\"");
+    objectName += newSchName.data() + std::string("\".");
+    objectName += tableName.getObjectNamePart().getExternalName();
+  }
+  else
+    objectName = extTableName.data();
+
   // For now, only support one grantee per request
   // TBD:  support multiple grantees - a testing effort?
   if (pGranteeArray.entries() > 1)
@@ -10221,12 +10235,24 @@ void CmpSeabaseDDL::hbaseGrantRevoke(
 }
 
 void CmpSeabaseDDL::createNativeHbaseTable(
+                                       ExeCliInterface *cliInterface,
                                        StmtDDLCreateHbaseTable * createTableNode,
                                        NAString &currCatName, NAString &currSchName)
 {
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
 
+  // Verify that user has privilege to create HBase tables - must be DB__ROOT 
+  // or granted the DB__HBASEROLE
+  if (isAuthorizationEnabled() && 
+      !ComUser::isRootUserID() && 
+      !ComUser::currentUserHasRole(HBASE_ROLE_ID))
+    {
+      *CmpCommon::diags() << DgSqlCode (-CAT_NOT_AUTHORIZED);
+      processReturn();
+      return;
+    }
+
   ComObjectName tableName(createTableNode->getTableName());
   const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
   const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
@@ -10239,6 +10265,17 @@ void CmpSeabaseDDL::createNativeHbaseTable(
       return;
     }
 
+  // If table already exists, return
+  retcode =  existsInHbase(objectNamePart, ehi);
+  if (retcode)
+    {
+      *CmpCommon::diags() << DgSqlCode(CAT_TABLE_ALREADY_EXISTS)
+                          << DgTableName(objectNamePart.data());
+      deallocEHI(ehi);
+      processReturn();
+      return;
+    }
+ 
   std::vector<NAString> colFamVec;
   for (Lng32 i = 0; i < createTableNode->csl()->entries(); i++)
     {
@@ -10273,23 +10310,44 @@ void CmpSeabaseDDL::createNativeHbaseTable(
       return;
     }
 
+  // Register the table
+  char query[(ComMAX_ANSI_IDENTIFIER_EXTERNAL_LEN) + 100];
+  snprintf(query, sizeof(query),
+           "register internal hbase table if not exists \"%s\"",
+           objectNamePart.data());
+   cliRC = cliInterface->executeImmediate(query);
+   if (cliRC < 0)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      return;
+    }
+
 }
 
 void CmpSeabaseDDL::dropNativeHbaseTable(
+                                       ExeCliInterface *cliInterface,
                                        StmtDDLDropHbaseTable * dropTableNode,
                                        NAString &currCatName, NAString &currSchName)
 {
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
 
+  // Verify that user has privilege to drop HBase tables - must be DB__ROOT 
+  // or granted the DB__HBASEROLE
+  if (isAuthorizationEnabled() && 
+      !ComUser::isRootUserID() &&
+      !ComUser::currentUserHasRole(HBASE_ROLE_ID))
+    {
+      *CmpCommon::diags() << DgSqlCode (-CAT_NOT_AUTHORIZED);
+      processReturn();
+      return;
+    }
+
   ComObjectName tableName(dropTableNode->getTableName());
   const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
   const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
   const NAString objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
   
-  // TDB - add a check to see if there is an external HBASE table that should be
-  // removed
-
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
     {
@@ -10297,6 +10355,71 @@ void CmpSeabaseDDL::dropNativeHbaseTable(
       return;
     }
 
+  // If table does not exist, return
+  retcode =  existsInHbase(objectNamePart, ehi);
+  if (retcode == 0)
+    {
+      *CmpCommon::diags() << DgSqlCode(CAT_TABLE_DOES_NOT_EXIST_ERROR)
+                          << DgTableName(objectNamePart.data());
+      deallocEHI(ehi);
+      processReturn();
+      return;
+    }
+ 
+  // Load definitions into cache
+  BindWA bindWA(ActiveSchemaDB(),CmpCommon::context(),FALSE/*inDDL*/);
+  CorrName cnCell(objectNamePart,STMTHEAP, HBASE_CELL_SCHEMA, HBASE_SYSTEM_CATALOG);
+  NATable *naCellTable = bindWA.getNATableInternal(cnCell);
+  CorrName cnRow(objectNamePart,STMTHEAP, HBASE_ROW_SCHEMA, HBASE_SYSTEM_CATALOG);
+  NATable *naRowTable = bindWA.getNATableInternal(cnRow);
+
+  // unregister tables 
+  char query[(ComMAX_ANSI_IDENTIFIER_EXTERNAL_LEN*4) + 100];
+  snprintf(query, sizeof(query), 
+           "unregister hbase table %s", tableName.getObjectNamePart().getExternalName().data());
+  cliRC = cliInterface->executeImmediate(query);
+  if (cliRC < 0 && cliRC != -CAT_REG_UNREG_OBJECTS && cliRC != -3251)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      deallocEHI(ehi);
+      processReturn();
+      return;
+    }
+
+  // Drop external mapping table
+  //ComObjectName externalName(objectNamePart);
+  snprintf(query, sizeof(query),
+           "drop external table if exists %s ", 
+           tableName.getObjectNamePart().getExternalName().data());
+  cliRC = cliInterface->executeImmediate(query);
+  if (cliRC < 0)
+    {
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+      deallocEHI(ehi);
+      processReturn();
+      return;
+    }
+
+  // Remove cell and row tables from cache.
+  if (naCellTable)
+    {
+      ActiveSchemaDB()->getNATableDB()->removeNATable
+        (cnCell,
+         ComQiScope::REMOVE_FROM_ALL_USERS,
+         COM_BASE_TABLE_OBJECT,
+         dropTableNode->ddlXns(), FALSE);
+    }
+
+  if (naRowTable)
+    {
+      ActiveSchemaDB()->getNATableDB()->removeNATable
+        (cnRow,
+         ComQiScope::REMOVE_FROM_ALL_USERS,
+         COM_BASE_TABLE_OBJECT,
+         dropTableNode->ddlXns(), FALSE);
+    }
+
+  // Remove table from HBase
   HbaseStr hbaseTable;
   hbaseTable.val = (char*)objectNamePart.data();
   hbaseTable.len = objectNamePart.length();
@@ -10304,12 +10427,9 @@ void CmpSeabaseDDL::dropNativeHbaseTable(
   if (retcode < 0)
     {
       deallocEHI(ehi); 
-      
       processReturn();
-      
       return;
     }
-  
 }
 
 short CmpSeabaseDDL::registerNativeTable

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgr.cpp b/core/sql/sqlcomp/PrivMgr.cpp
index c8a1a20..679bf28 100644
--- a/core/sql/sqlcomp/PrivMgr.cpp
+++ b/core/sql/sqlcomp/PrivMgr.cpp
@@ -920,6 +920,15 @@ ComObjectType PrivMgr::ObjectLitToEnum(const char *objectLiteral)
 //********************* End of PrivMgr::ObjectLitToEnum ************************
 
 
+static void translateObjectName(
+  const std::string inputName,
+  std::string &outputName)
+{
+  char prefix[inputName.length()];
+  snprintf(prefix, sizeof(prefix), "%s.\"%s\"",
+     HBASE_SYSTEM_CATALOG, HBASE_EXT_MAP_SCHEMA);
+}
+
 // ----------------------------------------------------------------------------
 // method: isAuthorizationEnabled
 //

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgr.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgr.h b/core/sql/sqlcomp/PrivMgr.h
index 925a9af..d04c410 100644
--- a/core/sql/sqlcomp/PrivMgr.h
+++ b/core/sql/sqlcomp/PrivMgr.h
@@ -136,6 +136,10 @@ class PrivMgr
        bitmap.set(REFERENCES_PRIV);
     }
 
+    static void translateObjectName(
+      const std::string inputName,
+      std::string &outputName);
+
     static void log(
       const std::string filename,
       const std::string message,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrCommands.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrCommands.cpp b/core/sql/sqlcomp/PrivMgrCommands.cpp
index 55cf3a6..05aaec9 100644
--- a/core/sql/sqlcomp/PrivMgrCommands.cpp
+++ b/core/sql/sqlcomp/PrivMgrCommands.cpp
@@ -45,158 +45,6 @@
 #include <algorithm>
 
 // ****************************************************************************
-// Class: PrivMgrObjectInfo
-// ****************************************************************************
-PrivMgrObjectInfo::PrivMgrObjectInfo(
-  const NATable *naTable)
-: objectOwner_ (naTable->getOwner()),
-  schemaOwner_ (naTable->getSchemaOwner()),
-  objectUID_   (naTable->objectUid().get_value()),
-  objectName_  (naTable->getTableName().getQualifiedNameAsAnsiString().data()),
-  objectType_  (naTable->getObjectType())
-{
-  const NAColumnArray &colNameArray = naTable->getNAColumnArray();
-  for (size_t i = 0; i < colNameArray.entries(); i++)
-  {
-    const NAColumn * naCol = colNameArray.getColumn(i);
-    std::string columnName(naCol->getColName().data());
-    columnList_.push_back( columnName);
-  }
-}
- 
-// ****************************************************************************
-// Class: PrivMgrUserPrivs
-// ****************************************************************************
-bool PrivMgrUserPrivs::initUserPrivs(
-  const std::vector<int32_t> & roleIDs,
-  const TrafDesc *priv_desc,
-  const int32_t userID,
-  const int64_t objectUID,
-  ComSecurityKeySet & secKeySet)
-{
-  hasPublicPriv_ = false;
-
-  // generate PrivMgrUserPrivs from the priv_desc structure
-  TrafDesc *priv_grantees_desc = priv_desc->privDesc()->privGrantees;
-  NAList<PrivMgrDesc> descList(NULL);
-
-  // Find relevant descs for the user
-  while (priv_grantees_desc)
-  {
-    Int32 grantee = priv_grantees_desc->privGranteeDesc()->grantee;
-    bool addDesc = false;
-    if (grantee == userID)
-      addDesc = true;
-
-    if (PrivMgr::isRoleID(grantee))
-    {
-      if ((std::find(roleIDs.begin(), roleIDs.end(), grantee)) != roleIDs.end())
-        addDesc = true;
-    }
-
-    if (ComUser::isPublicUserID(grantee))
-    {
-      addDesc = true;
-      hasPublicPriv_ = true;
-    }
-
-    // Create a list of PrivMgrDesc contain privileges for user, user's roles,
-    // and public
-    if (addDesc)
-    {
-      TrafDesc *objectPrivs = priv_grantees_desc->privGranteeDesc()->objectBitmap;
-
-      PrivMgrCoreDesc objectDesc(objectPrivs->privBitmapDesc()->privBitmap,
-                                 objectPrivs->privBitmapDesc()->privWGOBitmap);
-      
-      TrafDesc *priv_grantee_desc = priv_grantees_desc->privGranteeDesc();
-      TrafDesc *columnPrivs = priv_grantee_desc->privGranteeDesc()->columnBitmaps;
-      NAList<PrivMgrCoreDesc> columnDescs(NULL);
-      while (columnPrivs)
-      {
-        PrivMgrCoreDesc columnDesc(columnPrivs->privBitmapDesc()->privBitmap,
-                                   columnPrivs->privBitmapDesc()->privWGOBitmap,
-                                   columnPrivs->privBitmapDesc()->columnOrdinal);
-        columnDescs.insert(columnDesc);
-        columnPrivs = columnPrivs->next;
-      }
-
-      PrivMgrDesc privs(priv_grantees_desc->privGranteeDesc()->grantee);
-      privs.setTablePrivs(objectDesc);
-      privs.setColumnPrivs(columnDescs);
-      privs.setHasPublicPriv(hasPublicPriv_);
-
-      descList.insert(privs);
-    }
-    priv_grantees_desc = priv_grantees_desc->next;
-  }
-
-  // Union privileges from all grantees together to create a single set of
-  // bitmaps.  Create security invalidation keys
-  for (int i = 0; i < descList.entries(); i++)
-  {
-    PrivMgrDesc privs = descList[i];
-
-    // Set up object level privileges
-    objectBitmap_ |= privs.getTablePrivs().getPrivBitmap();
-    grantableBitmap_ |= privs.getTablePrivs().getWgoBitmap();
-
-    // Set up column level privileges
-    NAList<PrivMgrCoreDesc> columnPrivs = privs.getColumnPrivs();
-    std::map<size_t,PrivColumnBitmap>::iterator it;
-    for (int j = 0; j < columnPrivs.entries(); j++)
-    {
-      PrivMgrCoreDesc colDesc = columnPrivs[j];
-      Int32 columnOrdinal = colDesc.getColumnOrdinal();
-      it = colPrivsList_.find(columnOrdinal);
-      if (it == colPrivsList_.end())
-      {
-        colPrivsList_[columnOrdinal] = colDesc.getPrivBitmap();
-        colGrantableList_[columnOrdinal] = colDesc.getWgoBitmap();
-      }
-      else
-      {
-        colPrivsList_[columnOrdinal] |= colDesc.getPrivBitmap();
-        colGrantableList_[columnOrdinal] |= colDesc.getWgoBitmap();
-      }
-    }
-
-    // set up security invalidation keys
-    if (!buildSecurityKeys(userID, privs.getGrantee(), objectUID, privs.getTablePrivs(), secKeySet))
-      return false;
-
-    for (int k = 0; k < colPrivsList_.size(); k++)
-    {
-      PrivMgrCoreDesc colDesc(colPrivsList_[k], colGrantableList_[k]);
-      if (!buildSecurityKeys(userID, privs.getGrantee(), objectUID, colDesc, secKeySet))
-        return false;
-    }
-  }
-
-  // TBD - add schema privilege bitmaps
-  return true;
-}
-
-// ----------------------------------------------------------------------------
-// method: initUserPrivs
-//
-// Creates a PrivMgrUserPrivs object from a PrivMgrDesc object
-// ----------------------------------------------------------------------------
-void PrivMgrUserPrivs::initUserPrivs(PrivMgrDesc &privsOfTheUser)
-{
-  objectBitmap_ = privsOfTheUser.getTablePrivs().getPrivBitmap();
-  grantableBitmap_ = privsOfTheUser.getTablePrivs().getWgoBitmap();
-
-  for (int32_t i = 0; i < privsOfTheUser.getColumnPrivs().entries(); i++)
-  {
-    const int32_t columnOrdinal = privsOfTheUser.getColumnPrivs()[i].getColumnOrdinal();
-    colPrivsList_[columnOrdinal] = privsOfTheUser.getColumnPrivs()[i].getPrivBitmap();
-    colGrantableList_[columnOrdinal] = privsOfTheUser.getColumnPrivs()[i].getWgoBitmap();
-  }
-  hasPublicPriv_ = privsOfTheUser.getHasPublicPriv();
-}
-
-// ****************************************************************************
 // Class: PrivMgrCommands
 // ****************************************************************************
 
@@ -570,6 +418,14 @@ PrivStatus PrivMgrCommands::getPrivileges(
     PrivMgrDesc emptyDesc;
     userPrivs.initUserPrivs(emptyDesc);
   }
+
+  // if an hbase table and is not registered, assume no privs
+ else if ((naTable->isHbaseCellTable() || naTable->isHbaseRowTable()) &&
+          (!naTable->hasExternalTable() && !naTable->isRegistered()))
+  {
+    PrivMgrDesc emptyDesc;
+    userPrivs.initUserPrivs(emptyDesc);
+  }
   else
   {
     PrivMgrPrivileges objectPrivs (metadataLocation_, pDiags_);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrCommands.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrCommands.h b/core/sql/sqlcomp/PrivMgrCommands.h
index e1e06b4..312cbab 100644
--- a/core/sql/sqlcomp/PrivMgrCommands.h
+++ b/core/sql/sqlcomp/PrivMgrCommands.h
@@ -32,6 +32,7 @@
 #include "PrivMgrDefs.h"
 #include "TrafDDLdesc.h"
 #include "ComSecurityKey.h"
+#include "PrivMgrUserPrivs.h"
 
 class ComDiagsArea;
 class ComSecurityKey;
@@ -48,371 +49,12 @@ struct TrafDesc;
 // *****************************************************************************
 
 // Contents of file
-class PrivMgrObjectInfo;
-class ObjectPrivsRow;
-class PrivMgrUserPrivs;
 class PrivMgrCommands;
 
 // Forward references
 class PrivMgrPrivileges;
 class NATable;
 
-// ****************************************************************************
-// *
-// * Class:        PrivMgrObjectInfo
-// * Description:  This class describes object details needed to perform 
-// *               describe requests
-// *
-// ****************************************************************************
-class PrivMgrObjectInfo
-{
-  public:
-
-  PrivMgrObjectInfo( const int64_t objectUID,
-                     const std::string objectName,
-                     const int32_t objectOwner,
-                     const int32_t schemaOwner,
-                     const ComObjectType objectType)
-  : objectOwner_ (objectOwner),
-    objectName_ (objectName),
-    schemaOwner_ (schemaOwner),
-    objectUID_ (objectUID),
-    objectType_ (objectType)
-  {}
-
-
-  PrivMgrObjectInfo(const NATable *naTable);
-
-  const int32_t getObjectOwner()                  { return objectOwner_; }
-  const std::string getObjectName()               { return objectName_; }
-  const int32_t getSchemaOwner()                  { return schemaOwner_; }
-  const int64_t getObjectUID()                    { return objectUID_; }
-  const ComObjectType getObjectType()             { return objectType_; }
-  const std::vector<std::string> &getColumnList() { return columnList_; }
-
-  private:
-
-  int64_t                  objectUID_;
-  std::string              objectName_;
-  int32_t                  objectOwner_;
-  int32_t                  schemaOwner_;
-  ComObjectType            objectType_;
-  std::vector<std::string> columnList_;
-};
-
-// ****************************************************************************
-// class: ObjectPrivsRow
-//
-// ****************************************************************************
-class ObjectPrivsRow
-{
-public:
-   char objectName[(MAX_SQL_IDENTIFIER_NAME_LEN*3) + 2 + 1];
-   ComObjectType objectType;
-   int32_t granteeID;
-   char granteeName[MAX_USERNAME_LEN * 2 + 1];
-   ComGranteeType granteeType;
-   int32_t grantorID;
-   char grantorName[MAX_USERNAME_LEN * 2 + 1];
-   ComGrantorType grantorType;
-   int64_t privilegesBitmap;
-   int64_t grantableBitmap;
-};
-
-
-// *****************************************************************************
-// *
-// * Class:        PrivMgrUserPrivs
-// * Description:  This class encapsulates privileges associated with an object
-// *               for a user.
-// *
-// *****************************************************************************
-class PrivMgrUserPrivs
-{
-  public:
-
-  PrivMgrUserPrivs()
-  : hasPublicPriv_(false)
-  {}
-
-  static std::string convertPrivTypeToLiteral(PrivType which)
-  {
-    std::string privilege;
-    switch (which)
-    {
-      case SELECT_PRIV:
-        privilege = "SELECT";
-        break;
-      case INSERT_PRIV:
-        privilege = "INSERT";
-        break;
-      case DELETE_PRIV:
-        privilege = "DELETE";
-        break;
-      case UPDATE_PRIV:
-        privilege = "UPDATE";
-        break;
-      case USAGE_PRIV:
-        privilege = "USAGE";
-        break;
-      case REFERENCES_PRIV:
-        privilege = "REFERENCES";
-        break;
-      case EXECUTE_PRIV:
-        privilege = "EXECUTE";
-        break;
-      case CREATE_PRIV:
-        privilege = "CREATE";
-        break;
-      case ALTER_PRIV:
-        privilege = "ALTER";
-        break;
-      case DROP_PRIV:
-        privilege = "DROP";
-        break;
-      case ALL_DML:
-        privilege = "ALL_DML";
-        break;
-      case ALL_DDL:
-        privilege = "ALL_DDL";
-        break;
-      case ALL_PRIVS:
-        privilege = "ALL";
-        break;
-      default:
-        privilege = "UNKNOWN";
-    }
-  return privilege;
-}
-
- 
-  // Object level
-  bool hasObjectSelectPriv() const    {return objectBitmap_.test(SELECT_PRIV);}
-  bool hasObjectInsertPriv() const    {return objectBitmap_.test(INSERT_PRIV);}
-  bool hasObjectDeletePriv() const    {return objectBitmap_.test(DELETE_PRIV);}
-  bool hasObjectUpdatePriv() const    {return objectBitmap_.test(UPDATE_PRIV);}
-  bool hasObjectUsagePriv() const     {return objectBitmap_.test(USAGE_PRIV);}
-  bool hasObjectReferencePriv() const {return objectBitmap_.test(REFERENCES_PRIV);}
-  bool hasObjectExecutePriv() const   {return objectBitmap_.test(EXECUTE_PRIV);}
-  bool hasObjectAlterPriv() const     {return objectBitmap_.test(ALTER_PRIV);}
-  bool hasObjectDropPriv() const      {return objectBitmap_.test(DROP_PRIV);}
-  bool hasSelectPriv() const    {return schemaPrivBitmap_.test(SELECT_PRIV) || objectBitmap_.test(SELECT_PRIV);}
-  bool hasInsertPriv() const    {return schemaPrivBitmap_.test(INSERT_PRIV) || objectBitmap_.test(INSERT_PRIV);}
-  bool hasDeletePriv() const    {return schemaPrivBitmap_.test(DELETE_PRIV) || objectBitmap_.test(DELETE_PRIV);}
-  bool hasUpdatePriv() const    {return schemaPrivBitmap_.test(UPDATE_PRIV) || objectBitmap_.test(UPDATE_PRIV);}
-  bool hasUsagePriv() const     {return schemaPrivBitmap_.test(USAGE_PRIV) || objectBitmap_.test(USAGE_PRIV);}
-  bool hasReferencePriv() const {return schemaPrivBitmap_.test(REFERENCES_PRIV) || objectBitmap_.test(REFERENCES_PRIV);}
-  bool hasExecutePriv() const   {return schemaPrivBitmap_.test(EXECUTE_PRIV) || objectBitmap_.test(EXECUTE_PRIV);}
-  bool hasCreatePriv() const    {return schemaPrivBitmap_.test(CREATE_PRIV);}
-  bool hasAlterPriv() const     {return schemaPrivBitmap_.test(ALTER_PRIV) || objectBitmap_.test(ALTER_PRIV);}
-  bool hasDropPriv() const      {return schemaPrivBitmap_.test(DROP_PRIV) || objectBitmap_.test(DROP_PRIV);}
-  bool hasAllObjectPriv() const {return objectBitmap_.all();}
-  bool hasAnyObjectPriv() const {return objectBitmap_.any();}
-  bool hasPriv(PrivType which) const
-  {
-    bool hasPriv = false;
-    switch (which)
-    {
-      case SELECT_PRIV:
-        hasPriv = hasSelectPriv();
-        break;
-      case INSERT_PRIV:
-        hasPriv = hasInsertPriv();
-        break;
-      case DELETE_PRIV:
-        hasPriv = hasDeletePriv();
-        break;
-      case UPDATE_PRIV:
-        hasPriv = hasUpdatePriv();
-        break;
-      case USAGE_PRIV:
-        hasPriv = hasUsagePriv();
-        break;
-      case REFERENCES_PRIV:
-        hasPriv = hasReferencePriv();
-        break;
-      case EXECUTE_PRIV:
-        hasPriv = hasExecutePriv();
-        break;
-
-      // other privileges defined in the PrivType enum are not yet supported
-      default:
-        hasPriv = false;
-    }
-    return hasPriv;
-  }
-
-  bool hasObjectPriv(PrivType which) const
-  {
-    bool hasPriv = false;
-    switch (which)
-    {
-      case SELECT_PRIV:
-        hasPriv = hasObjectSelectPriv();
-        break;
-      case INSERT_PRIV:
-        hasPriv = hasObjectInsertPriv();
-        break;
-      case DELETE_PRIV:
-        hasPriv = hasObjectDeletePriv();
-        break;
-      case UPDATE_PRIV:
-        hasPriv = hasObjectUpdatePriv();
-        break;
-      case USAGE_PRIV:
-        hasPriv = hasObjectUsagePriv();
-        break;
-      case REFERENCES_PRIV:
-        hasPriv = hasObjectReferencePriv();
-        break;
-      case EXECUTE_PRIV:
-        hasPriv = hasObjectExecutePriv();
-        break;
-
-      // other privileges defined in the PrivType enum are not yet supported
-      default:
-        hasPriv = false;
-    }
-    return hasPriv;
-  }
-
-  bool hasAllDMLPriv() const
-  {
-    return (hasSelectPriv() && 
-            hasInsertPriv() && 
-            hasDeletePriv() && 
-            hasUpdatePriv() && 
-            hasReferencePriv());
-  } 
-            
-  bool hasAllLibraryPriv() const
-  { return (hasUpdatePriv() && hasUsagePriv()); }
-
-  bool hasAllUdrPriv() const
-  { return hasExecutePriv(); }
-
-  bool hasAllDDLPriv() const
-   {return (hasCreatePriv() && hasAlterPriv() && hasDropPriv());}
-
-  bool hasWGOOption(PrivType privType) const 
-   {return grantableBitmap_.test(privType);}
-
-  bool hasColSelectPriv(const int32_t ordinal) const {return hasColPriv(SELECT_PRIV,ordinal);}
-  bool hasColInsertPriv(const int32_t ordinal) const {return hasColPriv(INSERT_PRIV,ordinal);}
-  bool hasColUpdatePriv(const int32_t ordinal) const {return hasColPriv(UPDATE_PRIV,ordinal);}
-  bool hasColReferencePriv(const int32_t ordinal) const {return hasColPriv(REFERENCES_PRIV,ordinal);}
-  bool hasAnyColPriv() const       
-  {
-     return (!colPrivsList_.empty());
-  }
-  
-  bool hasAnyColPriv(const PrivType privType) const       
-  {
-
-     PrivColIterator columnIterator;
-     for (columnIterator = colPrivsList_.begin();
-          columnIterator != colPrivsList_.end(); ++columnIterator)
-     {
-        if (columnIterator->second.test(privType))
-           return true;
-     
-     }
-     
-     return false;     
-  }
-
-
-  bool hasColPriv(PrivType privType,const int32_t ordinal) const
-  {
-    // If no privileges for that column, return false.
-    if (colPrivsList_.count(ordinal) <= 0)
-       return false;
-       
-    switch (privType)
-    {
-      case SELECT_PRIV:
-      case INSERT_PRIV:
-      case REFERENCES_PRIV:
-      case UPDATE_PRIV:
-      {
-        PrivColIterator columnIterator = colPrivsList_.find(ordinal);
-        if (columnIterator == colPrivsList_.end())
-           return false;
-        
-        return columnIterator->second.test(privType);
-        break;
-      }
-      // other privileges not column privs
-      default:
-        return false;
-    }
-    return false;
-  }
-
-  PrivColList & getColPrivList() {return colPrivsList_;}
-  void setColPrivList(PrivColList colPrivsList)
-     {colPrivsList_ = colPrivsList;}
-  
-  PrivColList & getColGrantableList() {return colGrantableList_;}
-  void setColGrantableList(PrivColList colGrantableList)
-     {colGrantableList_ = colGrantableList;}
- 
-  PrivColumnBitmap getColumnPrivBitmap(const int32_t ordinal) 
-  {
-     if (colPrivsList_.empty() || colPrivsList_.count(ordinal) == 0)
-        return emptyBitmap_;
-  
-     return colPrivsList_[ordinal];
-  }
-
-  PrivColumnBitmap getColumnGrantableBitmap(const int32_t ordinal) 
-  {
-     if (colGrantableList_.empty() || colGrantableList_.count(ordinal) == 0)
-        return emptyBitmap_;
-  
-     return colGrantableList_[ordinal];
-  }
-
-  PrivMgrBitmap getObjectBitmap() {return objectBitmap_;}
-  void setObjectBitmap (PrivMgrBitmap objectBitmap)
-     {objectBitmap_ = objectBitmap;}
-
-  PrivMgrBitmap getGrantableBitmap() {return grantableBitmap_;}
-  void setGrantableBitmap (PrivMgrBitmap grantableBitmap)
-     {grantableBitmap_ = grantableBitmap;}
-
-  void setOwnerDefaultPrivs() 
-     { objectBitmap_.set(); grantableBitmap_.set(); } 
-     
-  PrivSchemaBitmap getSchemaPrivBitmap() {return schemaPrivBitmap_;}
-  void setSchemaPrivBitmap (PrivSchemaBitmap schemaPrivBitmap)
-     {schemaPrivBitmap_ = schemaPrivBitmap;}
-
-  PrivSchemaBitmap getSchemaGrantableBitmap() {return schemaGrantableBitmap_;}
-  void setSchemaGrantableBitmap (PrivSchemaBitmap schemaGrantableBitmap)
-     {schemaGrantableBitmap_ = schemaGrantableBitmap;}
-
-  bool getHasPublicPriv() { return hasPublicPriv_; }
-  void setHasPublicPriv(bool hasPublicPriv) {hasPublicPriv_ = hasPublicPriv;}
-  void initUserPrivs (PrivMgrDesc &privsOfTheGrantor);
-  bool initUserPrivs ( const std::vector<int32_t> &roleIDs,
-                       const TrafDesc *priv_desc,
-                       const int32_t userID,
-                       const int64_t objectUID,
-                       NASet<ComSecurityKey> & secKeySet);
-
- private:
-   PrivObjectBitmap objectBitmap_;
-   PrivObjectBitmap grantableBitmap_;
-   PrivColList colPrivsList_;
-   PrivColList colGrantableList_;
-   PrivSchemaBitmap schemaPrivBitmap_;
-   PrivSchemaBitmap schemaGrantableBitmap_;
-   PrivColumnBitmap emptyBitmap_;
-   bool hasPublicPriv_;
-};
-
-
 // *****************************************************************************
 // *
 // * Class:        PrivMgrCommands

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp b/core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp
index bbf85ee..a82da0f 100644
--- a/core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp
+++ b/core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp
@@ -204,6 +204,12 @@ using namespace ComponentPrivileges;
 // -----------------------------------------------------------------------
 // Construct a PrivMgrComponentPrivileges object for a new component operation.
 // -----------------------------------------------------------------------
+PrivMgrComponentPrivileges::PrivMgrComponentPrivileges()
+: PrivMgr(),
+  fullTableName_(metadataLocation_ + "." + PRIVMGR_COMPONENT_PRIVILEGES),
+  myTable_(*new MyTable(fullTableName_,pDiags_)) 
+{ };
+
 PrivMgrComponentPrivileges::PrivMgrComponentPrivileges(
    const std::string & metadataLocation,
    ComDiagsArea * pDiags)

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrComponentPrivileges.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrComponentPrivileges.h b/core/sql/sqlcomp/PrivMgrComponentPrivileges.h
index 2081a0f..b87e31f 100644
--- a/core/sql/sqlcomp/PrivMgrComponentPrivileges.h
+++ b/core/sql/sqlcomp/PrivMgrComponentPrivileges.h
@@ -48,6 +48,8 @@ public:
 // -------------------------------------------------------------------
 // Constructors and destructors:
 // -------------------------------------------------------------------
+   PrivMgrComponentPrivileges();
+
    PrivMgrComponentPrivileges( 
       const std::string & metadataLocation,
       ComDiagsArea * pDiags = NULL);
@@ -140,8 +142,6 @@ public:
       PrivDropBehavior dropBehavior); 
      
 private: 
-   PrivMgrComponentPrivileges();
-
    bool grantExists(
       const std::string componentUIDString,
       const std::string operationCode,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrUserPrivs.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrUserPrivs.cpp b/core/sql/sqlcomp/PrivMgrUserPrivs.cpp
new file mode 100644
index 0000000..fcdf247
--- /dev/null
+++ b/core/sql/sqlcomp/PrivMgrUserPrivs.cpp
@@ -0,0 +1,208 @@
+//*****************************************************************************
+// @@@ 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 @@@
+//*****************************************************************************
+  
+// ==========================================================================
+// Contains non inline methods in the following classes
+//   PrivMgrObjectInfo
+//   PrivMgrCommands
+// ==========================================================================
+
+#include "PrivMgrCommands.h"
+#include "PrivMgrMD.h"
+#include "DgBaseType.h"
+#include "NATable.h"
+#include "NAColumn.h"
+#include "ComSecurityKey.h"
+#include "ComUser.h"
+#include "ComMisc.h"
+#include "CmpSeabaseDDL.h"
+#include <cstdio>
+#include <algorithm>
+
+// ****************************************************************************
+// Class: PrivMgrObjectInfo
+// ****************************************************************************
+PrivMgrObjectInfo::PrivMgrObjectInfo(
+  const NATable *naTable)
+: objectOwner_ (naTable->getOwner()),
+  schemaOwner_ (naTable->getSchemaOwner()),
+  objectUID_   (naTable->objectUid().get_value()),
+  objectType_  (naTable->getObjectType())
+{
+  // Map hbase map table to external name
+  if (ComIsHBaseMappedIntFormat(naTable->getTableName().getCatalogName(),
+                                naTable->getTableName().getSchemaName()))
+  {
+    NAString newCatName;
+    NAString newSchName;
+    ComConvertHBaseMappedIntToExt(naTable->getTableName().getCatalogName(), 
+                                  naTable->getTableName().getSchemaName(),
+                                  newCatName, newSchName);
+    CONCAT_CATSCH(objectName_, newCatName, newSchName);
+    objectName_ += std::string(".") + 
+                   naTable->getTableName().getUnqualifiedObjectNameAsAnsiString().data();
+  }
+  else
+    objectName_ = naTable->getTableName().getQualifiedNameAsAnsiString().data();
+
+  const NAColumnArray &colNameArray = naTable->getNAColumnArray();
+  for (size_t i = 0; i < colNameArray.entries(); i++)
+  {
+    const NAColumn * naCol = colNameArray.getColumn(i);
+    std::string columnName(naCol->getColName().data());
+    columnList_.push_back( columnName);
+  }
+}
+ 
+// ****************************************************************************
+// Class: PrivMgrUserPrivs
+// ****************************************************************************
+bool PrivMgrUserPrivs::initUserPrivs(
+  const std::vector<int32_t> & roleIDs,
+  const TrafDesc *priv_desc,
+  const int32_t userID,
+  const int64_t objectUID,
+  ComSecurityKeySet & secKeySet)
+{
+  hasPublicPriv_ = false;
+
+  // generate PrivMgrUserPrivs from the priv_desc structure
+  TrafDesc *priv_grantees_desc = priv_desc->privDesc()->privGrantees;
+  NAList<PrivMgrDesc> descList(NULL);
+
+  // Find relevant descs for the user
+  while (priv_grantees_desc)
+  {
+    Int32 grantee = priv_grantees_desc->privGranteeDesc()->grantee;
+    bool addDesc = false;
+    if (grantee == userID)
+      addDesc = true;
+
+    if (PrivMgr::isRoleID(grantee))
+    {
+      if ((std::find(roleIDs.begin(), roleIDs.end(), grantee)) != roleIDs.end())
+        addDesc = true;
+    }
+
+    if (ComUser::isPublicUserID(grantee))
+    {
+      addDesc = true;
+      hasPublicPriv_ = true;
+    }
+
+    // Create a list of PrivMgrDesc contain privileges for user, user's roles,
+    // and public
+    if (addDesc)
+    {
+      TrafDesc *objectPrivs = priv_grantees_desc->privGranteeDesc()->objectBitmap;
+
+      PrivMgrCoreDesc objectDesc(objectPrivs->privBitmapDesc()->privBitmap,
+                                 objectPrivs->privBitmapDesc()->privWGOBitmap);
+      
+      TrafDesc *priv_grantee_desc = priv_grantees_desc->privGranteeDesc();
+      TrafDesc *columnPrivs = priv_grantee_desc->privGranteeDesc()->columnBitmaps;
+      NAList<PrivMgrCoreDesc> columnDescs(NULL);
+      while (columnPrivs)
+      {
+        PrivMgrCoreDesc columnDesc(columnPrivs->privBitmapDesc()->privBitmap,
+                                   columnPrivs->privBitmapDesc()->privWGOBitmap,
+                                   columnPrivs->privBitmapDesc()->columnOrdinal);
+        columnDescs.insert(columnDesc);
+        columnPrivs = columnPrivs->next;
+      }
+
+      PrivMgrDesc privs(priv_grantees_desc->privGranteeDesc()->grantee);
+      privs.setTablePrivs(objectDesc);
+      privs.setColumnPrivs(columnDescs);
+      privs.setHasPublicPriv(hasPublicPriv_);
+
+      descList.insert(privs);
+    }
+    priv_grantees_desc = priv_grantees_desc->next;
+  }
+
+  // Union privileges from all grantees together to create a single set of
+  // bitmaps.  Create security invalidation keys
+  for (int i = 0; i < descList.entries(); i++)
+  {
+    PrivMgrDesc privs = descList[i];
+
+    // Set up object level privileges
+    objectBitmap_ |= privs.getTablePrivs().getPrivBitmap();
+    grantableBitmap_ |= privs.getTablePrivs().getWgoBitmap();
+
+    // Set up column level privileges
+    NAList<PrivMgrCoreDesc> columnPrivs = privs.getColumnPrivs();
+    std::map<size_t,PrivColumnBitmap>::iterator it;
+    for (int j = 0; j < columnPrivs.entries(); j++)
+    {
+      PrivMgrCoreDesc colDesc = columnPrivs[j];
+      Int32 columnOrdinal = colDesc.getColumnOrdinal();
+      it = colPrivsList_.find(columnOrdinal);
+      if (it == colPrivsList_.end())
+      {
+        colPrivsList_[columnOrdinal] = colDesc.getPrivBitmap();
+        colGrantableList_[columnOrdinal] = colDesc.getWgoBitmap();
+      }
+      else
+      {
+        colPrivsList_[columnOrdinal] |= colDesc.getPrivBitmap();
+        colGrantableList_[columnOrdinal] |= colDesc.getWgoBitmap();
+      }
+    }
+
+    // set up security invalidation keys
+    if (!buildSecurityKeys(userID, privs.getGrantee(), objectUID, privs.getTablePrivs(), secKeySet))
+      return false;
+
+    for (int k = 0; k < colPrivsList_.size(); k++)
+    {
+      PrivMgrCoreDesc colDesc(colPrivsList_[k], colGrantableList_[k]);
+      if (!buildSecurityKeys(userID, privs.getGrantee(), objectUID, colDesc, secKeySet))
+        return false;
+    }
+  }
+
+  // TBD - add schema privilege bitmaps
+  return true;
+}
+
+// ----------------------------------------------------------------------------
+// method: initUserPrivs
+//
+// Creates a PrivMgrUserPrivs object from a PrivMgrDesc object
+// ----------------------------------------------------------------------------
+void PrivMgrUserPrivs::initUserPrivs(PrivMgrDesc &privsOfTheUser)
+{
+  objectBitmap_ = privsOfTheUser.getTablePrivs().getPrivBitmap();
+  grantableBitmap_ = privsOfTheUser.getTablePrivs().getWgoBitmap();
+
+  for (int32_t i = 0; i < privsOfTheUser.getColumnPrivs().entries(); i++)
+  {
+    const int32_t columnOrdinal = privsOfTheUser.getColumnPrivs()[i].getColumnOrdinal();
+    colPrivsList_[columnOrdinal] = privsOfTheUser.getColumnPrivs()[i].getPrivBitmap();
+    colGrantableList_[columnOrdinal] = privsOfTheUser.getColumnPrivs()[i].getWgoBitmap();
+  }
+  hasPublicPriv_ = privsOfTheUser.getHasPublicPriv();
+}
+

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/sqlcomp/PrivMgrUserPrivs.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrUserPrivs.h b/core/sql/sqlcomp/PrivMgrUserPrivs.h
new file mode 100644
index 0000000..a5264c5
--- /dev/null
+++ b/core/sql/sqlcomp/PrivMgrUserPrivs.h
@@ -0,0 +1,400 @@
+//*****************************************************************************
+// @@@ 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 @@@
+//*****************************************************************************
+
+#ifndef PRIVMGR_USERP_H
+#define PRIVMGR_USERP_H
+
+#include <string>
+#include <vector>
+#include <bitset>
+#include "PrivMgrDefs.h"
+
+class ComSecurityKey;
+class ComDiagsArea;
+
+// Contents of file
+class PrivMgrObjectInfo;
+class ObjectPrivsRow;
+class PrivMgrUserPrivs;
+
+// Forward references
+class PrivMgrPrivileges;
+class NATable;
+
+// ****************************************************************************
+// *
+// * Class:        PrivMgrObjectInfo
+// * Description:  This class describes object details needed to perform 
+// *               describe requests
+// *
+// ****************************************************************************
+class PrivMgrObjectInfo
+{
+  public:
+
+  PrivMgrObjectInfo( const int64_t objectUID,
+                     const std::string objectName,
+                     const int32_t objectOwner,
+                     const int32_t schemaOwner,
+                     const ComObjectType objectType)
+  : objectOwner_ (objectOwner),
+    objectName_ (objectName),
+    schemaOwner_ (schemaOwner),
+    objectUID_ (objectUID),
+    objectType_ (objectType)
+  {}
+
+
+  PrivMgrObjectInfo(const NATable *naTable);
+
+  const int32_t getObjectOwner()                  { return objectOwner_; }
+  const std::string getObjectName()               { return objectName_; }
+  const int32_t getSchemaOwner()                  { return schemaOwner_; }
+  const int64_t getObjectUID()                    { return objectUID_; }
+  const ComObjectType getObjectType()             { return objectType_; }
+  const std::vector<std::string> &getColumnList() { return columnList_; }
+
+  private:
+
+  int64_t                  objectUID_;
+  std::string              objectName_;
+  int32_t                  objectOwner_;
+  int32_t                  schemaOwner_;
+  ComObjectType            objectType_;
+  std::vector<std::string> columnList_;
+};
+
+// ****************************************************************************
+// class: ObjectPrivsRow
+//
+// ****************************************************************************
+class ObjectPrivsRow
+{
+public:
+   char objectName[(MAX_SQL_IDENTIFIER_NAME_LEN*3) + 2 + 1];
+   ComObjectType objectType;
+   int32_t granteeID;
+   char granteeName[MAX_USERNAME_LEN * 2 + 1];
+   ComGranteeType granteeType;
+   int32_t grantorID;
+   char grantorName[MAX_USERNAME_LEN * 2 + 1];
+   ComGrantorType grantorType;
+   int64_t privilegesBitmap;
+   int64_t grantableBitmap;
+};
+
+
+// *****************************************************************************
+// *
+// * Class:        PrivMgrUserPrivs
+// * Description:  This class encapsulates privileges associated with an object
+// *               for a user.
+// *
+// *****************************************************************************
+class PrivMgrUserPrivs
+{
+  public:
+
+  PrivMgrUserPrivs()
+  : hasPublicPriv_(false)
+  {}
+
+  static std::string convertPrivTypeToLiteral(PrivType which)
+  {
+    std::string privilege;
+    switch (which)
+    {
+      case SELECT_PRIV:
+        privilege = "SELECT";
+        break;
+      case INSERT_PRIV:
+        privilege = "INSERT";
+        break;
+      case DELETE_PRIV:
+        privilege = "DELETE";
+        break;
+      case UPDATE_PRIV:
+        privilege = "UPDATE";
+        break;
+      case USAGE_PRIV:
+        privilege = "USAGE";
+        break;
+      case REFERENCES_PRIV:
+        privilege = "REFERENCES";
+        break;
+      case EXECUTE_PRIV:
+        privilege = "EXECUTE";
+        break;
+      case CREATE_PRIV:
+        privilege = "CREATE";
+        break;
+      case ALTER_PRIV:
+        privilege = "ALTER";
+        break;
+      case DROP_PRIV:
+        privilege = "DROP";
+        break;
+      case ALL_DML:
+        privilege = "ALL_DML";
+        break;
+      case ALL_DDL:
+        privilege = "ALL_DDL";
+        break;
+      case ALL_PRIVS:
+        privilege = "ALL";
+        break;
+      default:
+        privilege = "UNKNOWN";
+    }
+  return privilege;
+}
+
+ 
+  // Object level
+  bool hasObjectSelectPriv() const    {return objectBitmap_.test(SELECT_PRIV);}
+  bool hasObjectInsertPriv() const    {return objectBitmap_.test(INSERT_PRIV);}
+  bool hasObjectDeletePriv() const    {return objectBitmap_.test(DELETE_PRIV);}
+  bool hasObjectUpdatePriv() const    {return objectBitmap_.test(UPDATE_PRIV);}
+  bool hasObjectUsagePriv() const     {return objectBitmap_.test(USAGE_PRIV);}
+  bool hasObjectReferencePriv() const {return objectBitmap_.test(REFERENCES_PRIV);}
+  bool hasObjectExecutePriv() const   {return objectBitmap_.test(EXECUTE_PRIV);}
+  bool hasObjectAlterPriv() const     {return objectBitmap_.test(ALTER_PRIV);}
+  bool hasObjectDropPriv() const      {return objectBitmap_.test(DROP_PRIV);}
+  bool hasSelectPriv() const    {return schemaPrivBitmap_.test(SELECT_PRIV) || objectBitmap_.test(SELECT_PRIV);}
+  bool hasInsertPriv() const    {return schemaPrivBitmap_.test(INSERT_PRIV) || objectBitmap_.test(INSERT_PRIV);}
+  bool hasDeletePriv() const    {return schemaPrivBitmap_.test(DELETE_PRIV) || objectBitmap_.test(DELETE_PRIV);}
+  bool hasUpdatePriv() const    {return schemaPrivBitmap_.test(UPDATE_PRIV) || objectBitmap_.test(UPDATE_PRIV);}
+  bool hasUsagePriv() const     {return schemaPrivBitmap_.test(USAGE_PRIV) || objectBitmap_.test(USAGE_PRIV);}
+  bool hasReferencePriv() const {return schemaPrivBitmap_.test(REFERENCES_PRIV) || objectBitmap_.test(REFERENCES_PRIV);}
+  bool hasExecutePriv() const   {return schemaPrivBitmap_.test(EXECUTE_PRIV) || objectBitmap_.test(EXECUTE_PRIV);}
+  bool hasCreatePriv() const    {return schemaPrivBitmap_.test(CREATE_PRIV);}
+  bool hasAlterPriv() const     {return schemaPrivBitmap_.test(ALTER_PRIV) || objectBitmap_.test(ALTER_PRIV);}
+  bool hasDropPriv() const      {return schemaPrivBitmap_.test(DROP_PRIV) || objectBitmap_.test(DROP_PRIV);}
+  bool hasAllObjectPriv() const {return objectBitmap_.all();}
+  bool hasAnyObjectPriv() const {return objectBitmap_.any();}
+  bool hasPriv(PrivType which) const
+  {
+    bool hasPriv = false;
+    switch (which)
+    {
+      case SELECT_PRIV:
+        hasPriv = hasSelectPriv();
+        break;
+      case INSERT_PRIV:
+        hasPriv = hasInsertPriv();
+        break;
+      case DELETE_PRIV:
+        hasPriv = hasDeletePriv();
+        break;
+      case UPDATE_PRIV:
+        hasPriv = hasUpdatePriv();
+        break;
+      case USAGE_PRIV:
+        hasPriv = hasUsagePriv();
+        break;
+      case REFERENCES_PRIV:
+        hasPriv = hasReferencePriv();
+        break;
+      case EXECUTE_PRIV:
+        hasPriv = hasExecutePriv();
+        break;
+
+      // other privileges defined in the PrivType enum are not yet supported
+      default:
+        hasPriv = false;
+    }
+    return hasPriv;
+  }
+
+  bool hasObjectPriv(PrivType which) const
+  {
+    bool hasPriv = false;
+    switch (which)
+    {
+      case SELECT_PRIV:
+        hasPriv = hasObjectSelectPriv();
+        break;
+      case INSERT_PRIV:
+        hasPriv = hasObjectInsertPriv();
+        break;
+      case DELETE_PRIV:
+        hasPriv = hasObjectDeletePriv();
+        break;
+      case UPDATE_PRIV:
+        hasPriv = hasObjectUpdatePriv();
+        break;
+      case USAGE_PRIV:
+        hasPriv = hasObjectUsagePriv();
+        break;
+      case REFERENCES_PRIV:
+        hasPriv = hasObjectReferencePriv();
+        break;
+      case EXECUTE_PRIV:
+        hasPriv = hasObjectExecutePriv();
+        break;
+
+      // other privileges defined in the PrivType enum are not yet supported
+      default:
+        hasPriv = false;
+    }
+    return hasPriv;
+  }
+
+  bool hasAllDMLPriv() const
+  {
+    return (hasSelectPriv() && 
+            hasInsertPriv() && 
+            hasDeletePriv() && 
+            hasUpdatePriv() && 
+            hasReferencePriv());
+  } 
+            
+  bool hasAllLibraryPriv() const
+  { return (hasUpdatePriv() && hasUsagePriv()); }
+
+  bool hasAllUdrPriv() const
+  { return hasExecutePriv(); }
+
+  bool hasAllDDLPriv() const
+   {return (hasCreatePriv() && hasAlterPriv() && hasDropPriv());}
+
+  bool hasWGOOption(PrivType privType) const 
+   {return grantableBitmap_.test(privType);}
+
+  bool hasColSelectPriv(const int32_t ordinal) const {return hasColPriv(SELECT_PRIV,ordinal);}
+  bool hasColInsertPriv(const int32_t ordinal) const {return hasColPriv(INSERT_PRIV,ordinal);}
+  bool hasColUpdatePriv(const int32_t ordinal) const {return hasColPriv(UPDATE_PRIV,ordinal);}
+  bool hasColReferencePriv(const int32_t ordinal) const {return hasColPriv(REFERENCES_PRIV,ordinal);}
+  bool hasAnyColPriv() const       
+  {
+     return (!colPrivsList_.empty());
+  }
+  
+  bool hasAnyColPriv(const PrivType privType) const       
+  {
+
+     PrivColIterator columnIterator;
+     for (columnIterator = colPrivsList_.begin();
+          columnIterator != colPrivsList_.end(); ++columnIterator)
+     {
+        if (columnIterator->second.test(privType))
+           return true;
+     
+     }
+     
+     return false;     
+  }
+
+
+  bool hasColPriv(PrivType privType,const int32_t ordinal) const
+  {
+    // If no privileges for that column, return false.
+    if (colPrivsList_.count(ordinal) <= 0)
+       return false;
+       
+    switch (privType)
+    {
+      case SELECT_PRIV:
+      case INSERT_PRIV:
+      case REFERENCES_PRIV:
+      case UPDATE_PRIV:
+      {
+        PrivColIterator columnIterator = colPrivsList_.find(ordinal);
+        if (columnIterator == colPrivsList_.end())
+           return false;
+        
+        return columnIterator->second.test(privType);
+        break;
+      }
+      // other privileges not column privs
+      default:
+        return false;
+    }
+    return false;
+  }
+
+  PrivColList & getColPrivList() {return colPrivsList_;}
+  void setColPrivList(PrivColList colPrivsList)
+     {colPrivsList_ = colPrivsList;}
+  
+  PrivColList & getColGrantableList() {return colGrantableList_;}
+  void setColGrantableList(PrivColList colGrantableList)
+     {colGrantableList_ = colGrantableList;}
+ 
+  PrivColumnBitmap getColumnPrivBitmap(const int32_t ordinal) 
+  {
+     if (colPrivsList_.empty() || colPrivsList_.count(ordinal) == 0)
+        return emptyBitmap_;
+  
+     return colPrivsList_[ordinal];
+  }
+
+  PrivColumnBitmap getColumnGrantableBitmap(const int32_t ordinal) 
+  {
+     if (colGrantableList_.empty() || colGrantableList_.count(ordinal) == 0)
+        return emptyBitmap_;
+  
+     return colGrantableList_[ordinal];
+  }
+
+  PrivMgrBitmap getObjectBitmap() {return objectBitmap_;}
+  void setObjectBitmap (PrivMgrBitmap objectBitmap)
+     {objectBitmap_ = objectBitmap;}
+
+  PrivMgrBitmap getGrantableBitmap() {return grantableBitmap_;}
+  void setGrantableBitmap (PrivMgrBitmap grantableBitmap)
+     {grantableBitmap_ = grantableBitmap;}
+
+  void setOwnerDefaultPrivs() 
+     { objectBitmap_.set(); grantableBitmap_.set(); } 
+     
+  PrivSchemaBitmap getSchemaPrivBitmap() {return schemaPrivBitmap_;}
+  void setSchemaPrivBitmap (PrivSchemaBitmap schemaPrivBitmap)
+     {schemaPrivBitmap_ = schemaPrivBitmap;}
+
+  PrivSchemaBitmap getSchemaGrantableBitmap() {return schemaGrantableBitmap_;}
+  void setSchemaGrantableBitmap (PrivSchemaBitmap schemaGrantableBitmap)
+     {schemaGrantableBitmap_ = schemaGrantableBitmap;}
+
+  bool getHasPublicPriv() { return hasPublicPriv_; }
+  void setHasPublicPriv(bool hasPublicPriv) {hasPublicPriv_ = hasPublicPriv;}
+  void initUserPrivs (PrivMgrDesc &privsOfTheGrantor);
+  bool initUserPrivs ( const std::vector<int32_t> &roleIDs,
+                       const TrafDesc *priv_desc,
+                       const int32_t userID,
+                       const int64_t objectUID,
+                       NASet<ComSecurityKey> & secKeySet);
+
+ private:
+   PrivObjectBitmap objectBitmap_;
+   PrivObjectBitmap grantableBitmap_;
+   PrivColList colPrivsList_;
+   PrivColList colGrantableList_;
+   PrivSchemaBitmap schemaPrivBitmap_;
+   PrivSchemaBitmap schemaGrantableBitmap_;
+   PrivColumnBitmap emptyBitmap_;
+   bool hasPublicPriv_;
+};
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/trafodion/blob/b178915d/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 7267862..1caf904 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -3688,10 +3688,7 @@ NABoolean HSGlobalsClass::isAuthorized(NABoolean isShowStats)
   if (!CmpCommon::context()->isAuthorizationEnabled())
     return TRUE;
 
-   // no privilege support available for hbase and hive tables
-   HS_ASSERT (objDef->getNATable());
-   if (CmpSeabaseDDL::isHbase(objDef->getCatName()))
-     return TRUE;
+  HS_ASSERT (objDef->getNATable());
 
   // Let keep track of how long authorization takes
   HSLogMan *LM = HSLogMan::Instance();


Mime
View raw message