http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/parser/StmtDDLCreate.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp index 7dcd4a2..1ff6542 100644 --- a/core/sql/parser/StmtDDLCreate.cpp +++ b/core/sql/parser/StmtDDLCreate.cpp @@ -4418,9 +4418,9 @@ StmtDDLCreateTable::synthesize() col->setColumnAttribute(pk); ElemDDLNode * pColAttrList = NULL; - if (col->getChild(1)) + if (col->getChild(ElemDDLColDef::INDEX_ELEM_DDL_COL_ATTR_LIST)) pColAttrList = - col->getChild(1)->castToElemDDLNode(); //INDEX_ELEM_DDL_COL_ATTR_LIST); + col->getChild(ElemDDLColDef::INDEX_ELEM_DDL_COL_ATTR_LIST)->castToElemDDLNode(); ElemDDLNode * newColAttrList = NULL; if (pColAttrList) @@ -4428,7 +4428,8 @@ StmtDDLCreateTable::synthesize() new (PARSERHEAP()) ElemDDLList(pColAttrList, pk); else newColAttrList = pk; - col->setChild(1 /*INDEX_ELEM_DDL_COL_ATTR_LIST*/, newColAttrList); + col->setChild(ElemDDLColDef::INDEX_ELEM_DDL_COL_ATTR_LIST, + newColAttrList); userSpecifiedPKey = TRUE; }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/parser/sqlparser.y ---------------------------------------------------------------------- diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y index dc1a323a..637c0ab 100755 --- a/core/sql/parser/sqlparser.y +++ b/core/sql/parser/sqlparser.y @@ -2553,7 +2553,6 @@ static void enableMakeQuotedStringISO88591Mechanism() %type <pElemDDL> column_attributes %type <pElemDDL> column_attribute %type <tokval> constraints_keyword -%type <pElemDDL> optional_col_def_default_clause %type <pElemDDL> col_def_default_clause %type <pElemDDL> col_def_default_clause_argument %type <pElemDDL> alter_col_default_clause_arg @@ -24930,8 +24929,7 @@ reset_in_column_defn : } /* type pElemDDL */ -column_definition : qualified_name data_type optional_col_def_default_clause - optional_column_attributes +column_definition : qualified_name data_type optional_column_attributes { NAType * type = $2; @@ -24995,8 +24993,7 @@ column_definition : qualified_name data_type optional_col_def_default_clause colFam /* column family */, colNam /*column_name*/, type /*data_type*/, - $3 /*optional_col_def_default_clause*/, - $4 /*optional_column_attributes*/); + $3 /*optional_column_attributes*/); delete $1 /*column_name*/; } @@ -25030,7 +25027,6 @@ column_definition : qualified_name ElemDDLColDef( colFam /* column family */, colNam /*column_name*/, - NULL, NULL, NULL); delete $1 /*column_name*/; @@ -25040,14 +25036,6 @@ column_definition : qualified_name column_name : identifier /* type pElemDDL */ -optional_col_def_default_clause : empty - { - $$ = NULL; - } - - | col_def_default_clause - -/* type pElemDDL */ col_def_default_clause : TOK_DEFAULT enableCharsetInferenceInColDefaultVal col_def_default_clause_argument { $$ = $3 /*col_def_default_clause_argument*/; @@ -25164,6 +25152,7 @@ column_attribute : column_constraint_definition | optional_lobattrs | heading | serialized + | col_def_default_clause /* type pElemDDL */ column_constraint_definition : constraint_name_definition http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/core/EXPECTED131 ---------------------------------------------------------------------- diff --git a/core/sql/regress/core/EXPECTED131 b/core/sql/regress/core/EXPECTED131 index c5a3fb5..57a464d 100644 --- a/core/sql/regress/core/EXPECTED131 +++ b/core/sql/regress/core/EXPECTED131 @@ -51,6 +51,18 @@ --- SQL operation complete. >> +>>-- setup for test_native +>>grant role DB__HIVEROLE to SQL_USER4; + +--- SQL operation complete. +>>showddl role DB__HIVEROLE; + +CREATE ROLE "DB__HIVEROLE"; + +--- SQL operation complete. +>>create external table item for hive.hive.item; + +--- SQL operation complete. >> >>log; >> @@ -308,9 +320,9 @@ SQL_USER7 >> >>-- expect error 8031 since the query is not running. >>obey cancel_cmd; ->>control query cancel qid MXID11000006223212317056413926129000000000206U3334000_52_S1; +>>control query cancel qid MXID11000007219212324915937583329000000000206U3335600_52_S1; -*** ERROR[8031] Server declined cancel request for query ID MXID11000006223212317056413926129000000000206U3334000_52_S1. The query is not in OPEN or FETCH or EXECUTE state. +*** ERROR[8031] Server declined cancel request for query ID MXID11000007219212324915937583329000000000206U3335600_52_S1. The query is not in OPEN or FETCH or EXECUTE state. --- SQL operation failed with errors. >> @@ -450,6 +462,65 @@ End of MXCI Session End of MXCI Session +>>sh sqlci -i"TEST131(test_native)" -u sql_user3; +>>values(user); + +(EXPR) +--------------------------------------------------------------------------------------------------------------------------------- + +SQL_USER3 + +--- 1 row(s) selected. +>> +>>-- user3 has no privs +>>select count(*) from hive.hive.item; + +*** ERROR[4481] The user does not have SELECT privilege on table or view HIVE.HIVE.ITEM. + +*** ERROR[8822] The statement was not prepared. + +>> +>>-- grant privs to user3, now user3 can execute dml +>>sh sqlci -i"TEST131(grant_hive_privs)" -u"SQL_User4" ; +>>grant select on hive.hive.item to sql_user3; + +--- SQL operation complete. +>> +>>exit; + +End of MXCI Session + +>>select count(*) from hive.hive.item; + +(EXPR) +-------------------- + + 18000 + +--- 1 row(s) selected. +>> +>>-- revoke privs from user3, user3 can no longer perform dml +>>-- verify that query invalidate works as designed +>>sh sqlci -i"TEST131(revoke_hive_privs)" -u"SQL_User4" ; +>>revoke select on hive.hive.item from sql_user3; + +--- SQL operation complete. +>> +>>exit; + +End of MXCI Session + +>>select count(*) from hive.hive.item; + +*** ERROR[4481] The user does not have SELECT privilege on table or view HIVE.HIVE.ITEM. + +*** ERROR[8822] The statement was not prepared. + +>> +>>exit; + +End of MXCI Session + >> >>obey TEST131(clnup); >> @@ -487,5 +558,19 @@ End of MXCI Session --- SQL operation failed with errors. >> +>>-- cleanup for test_native +>>drop external table item for hive.hive.item; + +--- SQL operation complete. +>>revoke role DB__HIVEROLE from SQL_USER4; + +--- SQL operation complete. +>>showddl role DB__HIVEROLE; + +CREATE ROLE "DB__HIVEROLE"; + -- GRANT ROLE "DB__HIVEROLE" TO "DB__ROOT" WITH ADMIN OPTION; + +--- SQL operation complete. +>> >> >>log; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/core/TEST131 ---------------------------------------------------------------------- diff --git a/core/sql/regress/core/TEST131 b/core/sql/regress/core/TEST131 index 75eb331..bffa4be 100755 --- a/core/sql/regress/core/TEST131 +++ b/core/sql/regress/core/TEST131 @@ -33,8 +33,10 @@ log LOG131 ; -- run the test in sqlci sessions which start after authorization -- is enabled. log; +cqd SHOWDDL_DISPLAY_PRIVILEGE_GRANTS 'ON'; sh sqlci -i"TEST131(test_session1)"; log LOG131 ; +sh sqlci -i"TEST131(test_native)" -u sql_user3; obey TEST131(clnup); @@ -74,6 +76,11 @@ revoke component privilege QUERY_CANCEL on sql_operations from SQL_USER7; revoke role role131 from sql_user7; revoke component privilege QUERY_CANCEL on SQL_OPERATIONS from role131; drop role role131; + +-- cleanup for test_native +drop external table item for hive.hive.item; +revoke role DB__HIVEROLE from SQL_USER4; +showddl role DB__HIVEROLE; ?section setup @@ -111,6 +118,10 @@ grant all on t131a to SQL_USER7; grant all on t131b to SQL_USER7; grant all on t131c to SQL_USER7; +-- setup for test_native +grant role DB__HIVEROLE to SQL_USER4; +showddl role DB__HIVEROLE; +create external table item for hive.hive.item; ?section dml @@ -361,5 +372,34 @@ revoke role role131 from sql_user7; revoke component privilege QUERY_CANCEL on SQL_OPERATIONS from role131; drop role role131; +?section test_native +-- user3 +log LOG131; +values(user); + +-- user3 has no privs +select count(*) from hive.hive.item; + +-- grant privs to user3, now user3 can execute dml +sh sqlci -i"TEST131(grant_hive_privs)" -u"SQL_User4" ; +select count(*) from hive.hive.item; + +-- revoke privs from user3, user3 can no longer perform dml +-- verify that query invalidate works as designed +sh sqlci -i"TEST131(revoke_hive_privs)" -u"SQL_User4" ; +select count(*) from hive.hive.item; + +?section grant_hive_privs +-- user4 who has been granted DB__HIVEROLE +values (user); +log LOG131; +grant select on hive.hive.item to sql_user3; + +?section revoke_hive_privs +-- user4, has been granted DB__HIVEROLE +values (user); +log LOG131; +revoke select on hive.hive.item from sql_user3; + ?section end_of_test -- end of test. http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/privs1/EXPECTED133 ---------------------------------------------------------------------- diff --git a/core/sql/regress/privs1/EXPECTED133 b/core/sql/regress/privs1/EXPECTED133 index 6edbc65..c20d1a0 100644 Binary files a/core/sql/regress/privs1/EXPECTED133 and b/core/sql/regress/privs1/EXPECTED133 differ http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/privs1/TEST133 ---------------------------------------------------------------------- diff --git a/core/sql/regress/privs1/TEST133 b/core/sql/regress/privs1/TEST133 index d630bda..0b1899f 100755 --- a/core/sql/regress/privs1/TEST133 +++ b/core/sql/regress/privs1/TEST133 @@ -35,9 +35,9 @@ -- authorized - runs authorization tests -- ============================================================================ +cqd SHOWDDL_DISPLAY_PRIVILEGE_GRANTS 'ON'; obey TEST133(clean_up); log LOG133 clear; -obey TEST133(create_db); obey TEST133(tests); sh sqlci -i "TEST133(authorized)" -u sql_user4; log; @@ -46,11 +46,14 @@ initialize authorization; exit; ?section clean_up -set schema "_PRIVMGR_MD_"; drop sequence t133sch.team_number_sequence; -- drop database drop schema t133sch cascade; +set parserflags 131072; +drop schema "_HV_HIVE_" cascade; +reset parserflags 131072; + ?section create_db create schema t133sch; set schema t133sch; @@ -64,13 +67,6 @@ create table teams alter table teams add constraint valid_team_no check (team_number > 0); -insert into teams values - (1, 'White Socks', 'Sam','4082282222'), - (2, 'Giants', 'Joe', '5102839483'), - (3, 'Cardinals', 'Stella', '9513849384'), - (4, 'Indians', 'Matt', '5128383748'), - (5, 'Tigers', 'Ronit', '6198273827'); - create table team_statistics (team_number int not null primary key, num_players int not null) @@ -83,7 +79,6 @@ create table games game_time timestamp not null, game_location varchar(50) not null) ; ---create index home_games on games (home_team_number); alter table games add constraint valid_game_number check (game_number > 0); @@ -93,18 +88,6 @@ create table standings loses int default 0, last_updated timestamp default current_timestamp) ; -insert into standings (team_number) - select team_number from teams; - -insert into games values - (1, 2, 1, timestamp '2009-04-23 19:30:00', 'California'), - (1, 3, 2, timestamp '2009-04-24 19:30:00', 'California'), - (1, 4, 3, timestamp '2009-04-25 10:00:00', 'Oklahoma'), - (2, 3, 4, timestamp '2009-04-25 13:30:00', 'Michigan'), - (1, 5, 5, timestamp '2009-04-25 15:00:00', 'Oklahoma'), - (2, 5, 6, timestamp '2009-04-27 17:00:00', 'New York'), - (3, 4, 7, timestamp '2009-04-28 17:00:00', 'Florida'), - (4, 2, 8, current_timestamp, 'Missouri'); create view home_teams_games as select t.team_number, g.game_number, g.game_time @@ -122,20 +105,6 @@ create table players primary key (player_number, player_team_number)) no partition; -insert into players values - (1, 'Tom', 1, '4083948394', null), - (2, 'Bob', 1, '4089483948', null), - (3, 'Toby',1, '4082938493', 'pitcher'), - (3, 'Toby',2, '4082938493', null), - (4, 'Julie', 2, '5108394839', 'catcher'), - (5, 'Joanne', 2, '5103849384', null), - (6, 'Pete', 2, '5102839483', null), - (6, 'Pete', 3, '5102839483', 'third base'), - (7, 'Jared',4, '9518293849', 'short stop'), - (8, 'Zachary', 4, '9518293840', null), - (9, 'Lynne', 5, '9518293892', 'pitcher'), - (10, 'Omar', 5, '5128394893', null); - alter table players add constraint valid_player_number check(player_number > 0); create view players_on_team as @@ -143,7 +112,6 @@ create view players_on_team as from teams t, players p where p.player_team_number = t.team_number order by t.team_name; -select * from players_on_team; create view games_by_player as select player_name, game_time @@ -155,12 +123,6 @@ create view games_by_player as alter table players add constraint players_teams foreign key (player_team_number) references teams (team_number); -insert into team_statistics - select team_number, count (player_number) - from teams t, players p - where t.team_number = p.player_team_number - group by team_number; - create volatile table home_games as select home_team_number, visitor_team_number, game_number, game_location from games @@ -171,22 +133,34 @@ create volatile table home_games as create sequence team_number_sequence; +-- create function to display bitmaps as a bitmap rather than longs +sh rm -f ./etest141.dll; +sh sh $$scriptsdir$$/tools/dll-compile.ksh etest141.cpp + 2>&1 | tee LOG133-SECONDARY; +set pattern $$DLL$$ etest141.dll; +set pattern $$QUOTE$$ ''''; + +create library t133_l1 file $$QUOTE$$ $$REGRRUNDIR$$/$$DLL$$ $$QUOTE$$ ; +create function translateBitmap(bitmap largeint) returns (bitmap_string char (20)) +language c parameter style sql external name 'translateBitmap' +library t133_l1 +deterministic no sql final call allow any parallelism state area size 1024 ; + ?section set_up set schema "_PRIVMGR_MD_"; prepare get_owner_privs from select distinct substring (object_name,1,40) as object_name, object_type as type, + substring(authname(grantor_id),1,10) as grantor, substring(authname(grantee_id),1,10) as grantee, - privileges_bitmap, - grantable_bitmap -from object_privileges -where grantor_id = -2 - and object_uid in + t133sch.translateBitmap(privileges_bitmap) as granted_privs, + t133sch.translateBitmap(grantable_bitmap) as grantable_privs +from "_PRIVMGR_MD_".object_privileges +where object_uid in (select object_uid from "_MD_".objects - where object_type in ('VI','BT','LB','UR') - and schema_name in ('_PRIVMGR_MD_', 'T133SCH')) + where schema_name in ('_PRIVMGR_MD_', 'T133SCH', '_HV_HIVE_')) order by 1, 2, 3, 4, 5 ; @@ -195,26 +169,40 @@ where grantor_id = -2 -- this set of tests run basic initialize authorization tests -- ================================================================= +obey TEST133(create_db); set schema "_PRIVMGR_MD_"; get tables; +-- verify can't create an object in "_PRIVMGR_MD_" schema create table t133_t1 (c1 int not null primary key, c2 int); -create view t133_v1 as select * from t133_t1; -create index t133_i1 on t133_t1(c2); -create table t133_t2 like t133_t1; obey TEST133(set_up); -get tables; execute get_owner_privs; initialize authorization, drop; get tables; + +-- owner s/b db__root +create external table customer for hive.hive.customer; +create external table item for hive.hive.item; +create external table promotion for hive.hive.promotion; +select schema_owner, object_owner, substring (object_name,1,20) as object_name +from "_MD_".objects where schema_name = '_HV_HIVE_'; + initialize authorization; get tables; select count (*) from components; select count (*) from component_operations; select count (*) from component_privileges; + +-- external Hive schema now owned by DB__HIVEROLE +select schema_owner, object_owner, substring (object_name,1,20) as object_name +from "_MD_".objects where schema_name = '_HV_HIVE_'; + +-- External hive table show owner as DB__HIVEROLE execute get_owner_privs; + +-- drop role_usage and make sure initialize authorization recreates set parserflags 131072; drop table role_usage; get tables; @@ -223,6 +211,7 @@ initialize authorization; get tables; execute get_owner_privs; +-- drop components and make sure initialize authorization recreates drop table components; get tables; initialize authorization, drop; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/seabase/EXPECTED010 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/EXPECTED010 b/core/sql/regress/seabase/EXPECTED010 index c6f739f..052b722 100644 --- a/core/sql/regress/seabase/EXPECTED010 +++ b/core/sql/regress/seabase/EXPECTED010 @@ -10383,7 +10383,7 @@ _SALT_ A B C D >>drop table if exists minotaur.events_load75; --- SQL operation complete. ->>create schema minotaur; +>>create schema if not exists minotaur; --- SQL operation complete. >>CREATE TABLE if not exists TRAFODION.MINOTAUR.EVENTS_LOAD75 http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/seabase/EXPECTED027 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/EXPECTED027 b/core/sql/regress/seabase/EXPECTED027 index 2465664..c4a7920 100644 --- a/core/sql/regress/seabase/EXPECTED027 +++ b/core/sql/regress/seabase/EXPECTED027 @@ -12,7 +12,7 @@ >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:58:49 2016 +-- Definition current Mon Mar 21 01:06:26 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -40,7 +40,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:58:59 2016 +-- Definition current Mon Mar 21 01:06:35 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -69,7 +69,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:05 2016 +-- Definition current Mon Mar 21 01:06:41 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -101,7 +101,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:14 2016 +-- Definition current Mon Mar 21 01:06:46 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -131,7 +131,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:16 2016 +-- Definition current Mon Mar 21 01:06:54 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -196,7 +196,7 @@ A B C >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:22 2016 +-- Definition current Mon Mar 21 01:06:59 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -234,7 +234,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:26 2016 +-- Definition current Mon Mar 21 01:07:06 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -274,7 +274,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:31 2016 +-- Definition current Mon Mar 21 01:07:11 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -312,7 +312,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01 >>invoke t027t01; -- Definition of Trafodion table TRAFODION.SCH027.T027T01 --- Definition current Sat Mar 12 02:59:32 2016 +-- Definition current Mon Mar 21 01:07:12 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -352,7 +352,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01 >>invoke t027t011; -- Definition of Trafodion table TRAFODION.SCH027.T027T011 --- Definition current Sat Mar 12 02:59:40 2016 +-- Definition current Mon Mar 21 01:07:15 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -397,7 +397,7 @@ A B C E D >>invoke t027t011; -- Definition of Trafodion table TRAFODION.SCH027.T027T011 --- Definition current Sat Mar 12 02:59:43 2016 +-- Definition current Mon Mar 21 01:07:19 2016 ( "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -437,7 +437,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011 >>invoke t027t011; -- Definition of Trafodion table TRAFODION.SCH027.T027T011 --- Definition current Sat Mar 12 02:59:53 2016 +-- Definition current Mon Mar 21 01:07:28 2016 ( SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE @@ -472,7 +472,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011 >>invoke t027t011; -- Definition of Trafodion table TRAFODION.SCH027.T027T011 --- Definition current Sat Mar 12 02:59:57 2016 +-- Definition current Mon Mar 21 01:07:32 2016 ( SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE @@ -504,7 +504,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011 >>invoke t027t03; -- Definition of Trafodion volatile table T027T03 --- Definition current Sat Mar 12 03:00:03 2016 +-- Definition current Mon Mar 21 01:07:38 2016 ( "cf1".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -536,7 +536,7 @@ CREATE VOLATILE TABLE T027T03 >>invoke t027t03; -- Definition of Trafodion volatile table T027T03 --- Definition current Sat Mar 12 03:00:24 2016 +-- Definition current Mon Mar 21 01:07:58 2016 ( "cf1".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -585,7 +585,7 @@ CREATE VOLATILE TABLE T027T03 >>invoke t027t02; -- Definition of Trafodion table TRAFODION.SCH027.T027T02 --- Definition current Sat Mar 12 03:00:45 2016 +-- Definition current Mon Mar 21 01:08:18 2016 ( "cf".SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE @@ -637,7 +637,7 @@ CREATE VOLATILE TABLE T027T03 >>invoke t027t03; -- Definition of Trafodion table TRAFODION.SCH027.T027T03 --- Definition current Sat Mar 12 03:01:07 2016 +-- Definition current Mon Mar 21 01:08:40 2016 ( "cf1".A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -674,7 +674,7 @@ A B C D >>invoke t027t02; -- Definition of Trafodion table TRAFODION.SCH027.T027T02 --- Definition current Sat Mar 12 03:01:20 2016 +-- Definition current Mon Mar 21 01:08:53 2016 ( OBJECT_UID LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE @@ -787,7 +787,7 @@ create index t027t01i2 on t027t01("cf2".b); >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:01:46 2016 +-- Definition current Mon Mar 21 01:09:19 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -819,7 +819,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:01:54 2016 +-- Definition current Mon Mar 21 01:09:28 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -840,7 +840,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:02:19 2016 +-- Definition current Mon Mar 21 01:09:51 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -861,7 +861,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:02:42 2016 +-- Definition current Mon Mar 21 01:10:14 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -883,7 +883,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:03:05 2016 +-- Definition current Mon Mar 21 01:10:35 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -904,7 +904,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:03:25 2016 +-- Definition current Mon Mar 21 01:10:55 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -925,7 +925,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:03:42 2016 +-- Definition current Mon Mar 21 01:11:16 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -946,7 +946,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:04:05 2016 +-- Definition current Mon Mar 21 01:11:35 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -967,7 +967,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:04:25 2016 +-- Definition current Mon Mar 21 01:12:03 2016 ( A INT DEFAULT NULL /*altered_col*/ @@ -988,7 +988,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:04:44 2016 +-- Definition current Mon Mar 21 01:12:26 2016 ( A SMALLINT DEFAULT 0 NOT NULL NOT DROPPABLE @@ -1025,7 +1025,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:05:07 2016 +-- Definition current Mon Mar 21 01:12:50 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -1057,7 +1057,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:05:32 2016 +-- Definition current Mon Mar 21 01:13:16 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -1086,7 +1086,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:05:57 2016 +-- Definition current Mon Mar 21 01:13:44 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -1113,7 +1113,7 @@ A C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:06:00 2016 +-- Definition current Mon Mar 21 01:13:51 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -1142,7 +1142,7 @@ A C Z B >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:06:25 2016 +-- Definition current Mon Mar 21 01:14:16 2016 ( A LARGEINT DEFAULT NULL /*altered_col*/ @@ -1177,7 +1177,7 @@ SCH027.T027V1 >>invoke t027v1; -- Definition of Trafodion view TRAFODION.SCH027.T027V1 --- Definition current Sat Mar 12 03:06:33 2016 +-- Definition current Mon Mar 21 01:14:24 2016 ( A LARGEINT DEFAULT NULL @@ -1193,7 +1193,7 @@ SCH027.T027V1 >>invoke t027v1; -- Definition of Trafodion view TRAFODION.SCH027.T027V1 --- Definition current Sat Mar 12 03:07:06 2016 +-- Definition current Mon Mar 21 01:14:58 2016 ( A SMALLINT DEFAULT NULL @@ -1266,7 +1266,7 @@ SCH027.T027V1 >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:09:01 2016 +-- Definition current Mon Mar 21 01:17:02 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -1295,7 +1295,7 @@ A B C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:09:12 2016 +-- Definition current Mon Mar 21 01:17:13 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -1324,7 +1324,7 @@ A BB C Z >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Sat Mar 12 03:09:24 2016 +-- Definition current Mon Mar 21 01:17:28 2016 ( A INT NO DEFAULT NOT NULL NOT DROPPABLE @@ -1534,10 +1534,10 @@ SCH027.T027V122 >>invoke t027t7; -- Definition of Trafodion table TRAFODION.SCH027.T027T7 --- Definition current Thu Mar 17 14:48:27 2016 +-- Definition current Mon Mar 21 01:21:43 2016 ( - SYSKEY INT NO DEFAULT NOT NULL NOT DROPPABLE + SYSKEY INT NO DEFAULT NOT NULL NOT DROPPABLE , "_SALT_" INT DEFAULT NULL /*altered_col*/ , "_DIVISION_1" INT DEFAULT NULL /*added_col*/ ) @@ -1545,6 +1545,83 @@ SCH027.T027V122 --- SQL operation complete. >> +>>-- not null and default clause can appear in any order +>>drop table if exists t027t1 cascade; + +--- SQL operation complete. +>>create table t027t1 (a int, b int not null, c int default 10, ++> d int default 10 not null, e int not null default 10, ++> f int not null default 10 check (f > 0), ++> g int not null not droppable default 10); + +--- SQL operation complete. +>>invoke t027t1; + +-- Definition of Trafodion table TRAFODION.SCH027.T027T1 +-- Definition current Mon Mar 21 01:21:53 2016 + + ( + SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE + , A INT DEFAULT NULL + , B INT NO DEFAULT NOT NULL NOT DROPPABLE + , C INT DEFAULT 10 + , D INT DEFAULT 10 NOT NULL NOT DROPPABLE + , E INT DEFAULT 10 NOT NULL NOT DROPPABLE + , F INT DEFAULT 10 NOT NULL NOT DROPPABLE + , G INT DEFAULT 10 NOT NULL NOT DROPPABLE + ) + +--- SQL operation complete. +>>insert into t027t1 (b) values (10); + +--- 1 row(s) inserted. +>>select * from t027t1; + +A B C D E F G +----------- ----------- ----------- ----------- ----------- ----------- ----------- + + ? 10 10 10 10 10 10 + +--- 1 row(s) selected. +>>alter table t027t1 add column h int not null default 10; + +--- SQL operation complete. +>>invoke t027t1; + +-- Definition of Trafodion table TRAFODION.SCH027.T027T1 +-- Definition current Mon Mar 21 01:22:00 2016 + + ( + SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE + , A INT DEFAULT NULL + , B INT NO DEFAULT NOT NULL NOT DROPPABLE + , C INT DEFAULT 10 + , D INT DEFAULT 10 NOT NULL NOT DROPPABLE + , E INT DEFAULT 10 NOT NULL NOT DROPPABLE + , F INT DEFAULT 10 NOT NULL NOT DROPPABLE + , G INT DEFAULT 10 NOT NULL NOT DROPPABLE + , H INT DEFAULT 10 NOT NULL NOT DROPPABLE + /*added_col*/ + ) + +--- SQL operation complete. +>>select * from t027t1; + +A B C D E F G H +----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- + + ? 10 10 10 10 10 10 10 + +--- 1 row(s) selected. +>> +>>--should give error +>>create table t027t2 (a int default 10 not null default 20); + +*** ERROR[3052] Duplicate DEFAULT clauses were specified in column definition A. + +*** ERROR[8822] The statement was not prepared. + +>> >>-- cleanup >>?section clean_up >>drop table if exists t027t7 cascade; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/seabase/TEST010 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/TEST010 b/core/sql/regress/seabase/TEST010 index 4efc187..7848bd6 100644 --- a/core/sql/regress/seabase/TEST010 +++ b/core/sql/regress/seabase/TEST010 @@ -281,7 +281,7 @@ select "_SALT_", * from table(table t010t3, partition number from 1 to 3); ?section otherMdam drop table if exists minotaur.events_load75; -create schema minotaur; +create schema if not exists minotaur; CREATE TABLE if not exists TRAFODION.MINOTAUR.EVENTS_LOAD75 ( SRCIP CHAR(45) CHARACTER SET ISO88591 COLLATE http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/regress/seabase/TEST027 ---------------------------------------------------------------------- diff --git a/core/sql/regress/seabase/TEST027 b/core/sql/regress/seabase/TEST027 index b3d2710..41d2b79 100644 --- a/core/sql/regress/seabase/TEST027 +++ b/core/sql/regress/seabase/TEST027 @@ -308,6 +308,22 @@ alter table t027t7 add column "_DIVISION_1" int; alter table t027t7 alter column b rename to "_SALT_"; invoke t027t7; +-- not null and default clause can appear in any order +drop table if exists t027t1 cascade; +create table t027t1 (a int, b int not null, c int default 10, + d int default 10 not null, e int not null default 10, + f int not null default 10 check (f > 0), + g int not null not droppable default 10); +invoke t027t1; +insert into t027t1 (b) values (10); +select * from t027t1; +alter table t027t1 add column h int not null default 10; +invoke t027t1; +select * from t027t1; + +--should give error +create table t027t2 (a int default 10 not null default 20); + -- cleanup ?section clean_up drop table if exists t027t7 cascade; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/sqlcomp/CmpSeabaseDDL.h ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h index 6edcb51..c45ac0a 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDL.h +++ b/core/sql/sqlcomp/CmpSeabaseDDL.h @@ -1176,6 +1176,7 @@ class CmpSeabaseDDL short createLibmgrProcs(ExeCliInterface * cliInterface); short grantLibmgrPrivs(ExeCliInterface *cliInterface); + short adjustHiveExternalSchemas(ExeCliInterface *cliInterface); void createSeabaseSequence(StmtDDLCreateSequence * createSequenceNode, NAString &currCatName, NAString &currSchName); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp index e89f3e3..cb7325c 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp @@ -5727,7 +5727,7 @@ short CmpSeabaseDDL::buildColInfoArray( ElemDDLParamDef *paramNode = (*paramArray)[index]; ElemDDLColDef colNode(NULL, ¶mNode->getParamName(), paramNode->getParamDataType(), - NULL, NULL, STMTHEAP); + NULL, STMTHEAP); NAString colFamily; NAString colName; @@ -7726,6 +7726,15 @@ short CmpSeabaseDDL::initSeabaseAuthorization( for (short i = 0; i < GetCliGlobals()->currContext()->getNumArkcmps(); i++) GetCliGlobals()->currContext()->getArkcmp(i)->endConnection(); + // Adjust hive external table ownership - if someone creates external + // tables before initializing authorization, the external schemas are + // owned by DB__ROOT -> change to DB__HIVEROLE. + // Also if you have initialized authorization and created external tables + // before the fix for JIRA 1895, rerunning initialize authorization will + // fix the metadata inconsistencies + if (adjustHiveExternalSchemas(cliInterface) != 0) + return -1; + // If someone initializes trafodion with library management but does not // initialize authorization, then the role DB__LIBMGRROLE has not been // granted to LIBMGR procedures. Do this now http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp index 158ab70..88832f2 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp @@ -1184,6 +1184,99 @@ short CmpSeabaseDDL::createHistogramTables( // ***************************************************************************** // * * +// * Function: adjustHiveExternalSchemas * +// * * +// * Changes the ownership and privilege grants to DB__HIVEROLE * +// * * +// ***************************************************************************** +// * * +// * Parameters: * +// * * +// * <cliInterface> ExeCliInterface * In * +// * is a reference to an Executor CLI interface handle. * +// ***************************************************************************** +// * * +// * Returns: Int32 * +// * * +// * 0: Adjustment was successful * +// * -1: Adjustment failed * +// * * +// ***************************************************************************** +short CmpSeabaseDDL::adjustHiveExternalSchemas(ExeCliInterface *cliInterface) +{ + char buf[sizeof(SEABASE_MD_SCHEMA) + + sizeof(SEABASE_OBJECTS) + + strlen(getSystemCatalog()) + 300]; + + // get all the objects in special hive schemas + sprintf(buf, "SELECT catalog_name, schema_name, object_name, object_uid, object_type, object_owner " + " from %s.\"%s\".%s WHERE schema_name like '_HV_%c_'", + getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS, '%'); + + Queue * objectsQueue = NULL; + Int32 cliRC = cliInterface->fetchAllRows(objectsQueue, buf, 0, FALSE, FALSE, TRUE); + if (cliRC < 0) + { + cliInterface->retrieveSQLDiagnostics(CmpCommon::diags()); + return -1; + } + + // adjust owner and privilege information for external hive objects + objectsQueue->position(); + for (size_t i = 0; i < objectsQueue->numEntries(); i++) + { + OutputInfo * vi = (OutputInfo*)objectsQueue->getNext(); + NAString catName = vi->get(0); + NAString schName = vi->get(1); + NAString objName = vi->get(2); + Int64 objUID = *(Int64*)vi->get(3); + NAString objectTypeLit = vi->get(4); + Int32 objOwner = *(Int32*)vi->get(5); + ComObjectType objType = PrivMgr::ObjectLitToEnum(objectTypeLit.data()); + + // If object owner is already the HIVE_ROLE_ID, then we are done. + if (objOwner == HIVE_ROLE_ID) + continue; + else + { + // only need to adjust privileges on securable items + if (PrivMgr::isSecurableObject(objType)) + { + ComObjectName tblName(catName, schName, objName, COM_TABLE_NAME, + ComAnsiNamePart::INTERNAL_FORMAT, STMTHEAP); + + NAString extTblName = tblName.getExternalName(TRUE); + + // remove existing privs on object + if (!deletePrivMgrInfo(extTblName, objUID, objType)) + return -1; + + // add owner privs + if (!insertPrivMgrInfo(objUID, extTblName, objType, + HIVE_ROLE_ID, HIVE_ROLE_ID, ComUser::getCurrentUser())) + return -1; + } + + // update schema_owner and objectOwner for object + sprintf(buf,"UPDATE %s.\"%s\".%s SET object_owner = %d " + ", schema_owner = %d WHERE object_uid = %ld ", + getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS, + HIVE_ROLE_ID, HIVE_ROLE_ID, objUID); + cliRC = cliInterface->executeImmediate(buf); + if (cliRC < 0) + { + cliInterface->retrieveSQLDiagnostics(CmpCommon::diags()); + return -1; + } + } + } + + return 0; +} +//********************* End of adjustHiveExternalTables ************************ + +// ***************************************************************************** +// * * // * Function: dropOneTable * // * * // * Drops a table and all its dependent objects. * @@ -1337,17 +1430,19 @@ NAString privMgrMDLoc; PrivMgrCommands privInterface(std::string(privMgrMDLoc.data()),CmpCommon::diags()); std::vector<UIDAndOwner> objectRows; -std::string whereClause(" WHERE catalogName = "); +std::string whereClause(" WHERE catalog_name = '"); whereClause += catalogName; - whereClause += " AND schema_name = "; + whereClause += "' AND schema_name = '"; whereClause += schemaName; + whereClause += "'"; std::string orderByClause(" ORDER BY OBJECT_OWNER"); std::string metadataLocation(systemCatalogName); - metadataLocation += "."; + metadataLocation += ".\""; metadataLocation += SEABASE_MD_SCHEMA; + metadataLocation += "\""; PrivMgrObjects objects(metadataLocation,CmpCommon::diags()); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp index d6325e7..5b9174d 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp @@ -485,7 +485,7 @@ short CmpSeabaseDDL::createSeabaseTableExternal( if (isAuthorizationEnabled()) { - if (srcTableName.isExternalHive()) + if (tgtTableName.isExternalHive()) { tableInfo->objOwnerID = HIVE_ROLE_ID; tableInfo->schemaOwnerID = HIVE_ROLE_ID; @@ -1548,7 +1548,7 @@ short CmpSeabaseDDL::createSeabaseTable2( NAString syskeyColName("SYSKEY"); SQLLargeInt * syskeyType = new(STMTHEAP) SQLLargeInt(TRUE, FALSE, STMTHEAP); - ElemDDLColDef syskeyColDef(NULL, &syskeyColName, syskeyType, NULL, NULL, + ElemDDLColDef syskeyColDef(NULL, &syskeyColName, syskeyType, NULL, STMTHEAP); ElemDDLColRef edcr("SYSKEY", COM_ASCENDING_ORDER); CollIndex numSysCols = 0; @@ -1688,7 +1688,7 @@ short CmpSeabaseDDL::createSeabaseTable2( ElemDDLColDefault::COL_COMPUTED_DEFAULT); saltDef->setComputedDefaultExpr(saltExprText); ElemDDLColDef * saltColDef = - new(STMTHEAP) ElemDDLColDef(NULL, &saltColName, saltType, saltDef, NULL, + new(STMTHEAP) ElemDDLColDef(NULL, &saltColName, saltType, saltDef, STMTHEAP); ElemDDLColRef * edcrs = @@ -1866,7 +1866,7 @@ short CmpSeabaseDDL::createSeabaseTable2( boundDivExpr->unparse(divExprText, PARSER_PHASE, COMPUTED_COLUMN_FORMAT); divColDefault->setComputedDefaultExpr(divExprText); ElemDDLColDef * divColDef = - new(STMTHEAP) ElemDDLColDef(NULL, &divColName, divColType, divColDefault, NULL, + new(STMTHEAP) ElemDDLColDef(NULL, &divColName, divColType, divColDefault, STMTHEAP); ElemDDLColRef * edcrs = http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/sqlcomp/CmpSeabaseDDLview.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp index 34ea07c..958b96d 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp @@ -234,7 +234,6 @@ short CmpSeabaseDDL::buildViewColInfo(StmtDDLCreateView * createViewParseNode, colDefArray->insert(new (STMTHEAP) ElemDDLColDef ( NULL, &viewColDefArray[i]->getColumnName() , (NAType *)&valIdList[i].getType() - , NULL // default value (n/a for view def) , NULL // col attr list (not needed) , STMTHEAP)); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/core/sql/ustat/hs_globals.cpp ---------------------------------------------------------------------- diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp index c323865..84ee7d0 100644 --- a/core/sql/ustat/hs_globals.cpp +++ b/core/sql/ustat/hs_globals.cpp @@ -5671,7 +5671,7 @@ Lng32 HSGlobalsClass::CollectStatistics() /* sampled UEC -> est UEC */ /* sampled ROWCOUNT -> est ROWCOUNT*/ /*=================================*/ - if (sampleRowCount > 0 && actualRowCount > sampleRowCount) + if (samplingUsed && sampleRowCount > 0 && actualRowCount > sampleRowCount) { LM->StartTimer("fix sample row counts"); retcode = FixSamplingCounts(group); @@ -5681,6 +5681,24 @@ Lng32 HSGlobalsClass::CollectStatistics() } group = group->next; } + + // If we used cqd USTAT_ESTIMATE_HBASE_ROW_COUNT 'ON', then actualRowCount + // is the estimate of the row count given by HBase. If we also did not do + // sampling, we know the true row count; this is in sampleRowCount. We + // take the opportunity here to correct the actualRowCount in this case. + if (!samplingUsed && isHbaseTable && + CmpCommon::getDefault(USTAT_ESTIMATE_HBASE_ROW_COUNT) == DF_ON) + { + if (LM->LogNeeded()) + { + sprintf(LM->msg, "Correcting actualRowCount (was " PF64 ") from sampleRowCount (" PF64 ")", + actualRowCount,sampleRowCount); + LM->Log(LM->msg); + } + actualRowCount = sampleRowCount; + } + + if (singleGroup && LM->LogNeeded()) LM->StopTimer(); @@ -5712,7 +5730,7 @@ Lng32 HSGlobalsClass::CollectStatistics() LM->StartTimer("MC: fix MC stats"); - if (sampleRowCount > 0 && actualRowCount > sampleRowCount) + if (samplingUsed && sampleRowCount > 0 && actualRowCount > sampleRowCount) { group = multiGroup; while (group != NULL) @@ -11414,7 +11432,7 @@ Lng32 HSGlobalsClass::createStatsForColumn(HSColGroupStruct *group, Int64 rowsAl } // Upscale rowcounts and estimate UECs when sampling. - if (sampleRowCount > 0 && actualRowCount > sampleRowCount) + if (samplingUsed && sampleRowCount > 0 && actualRowCount > sampleRowCount) { retcode = FixSamplingCounts(group); HSHandleError(retcode); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/SQuirrel.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/SQuirrel.adoc b/docs/client_install/src/asciidoc/_chapters/SQuirrel.adoc index 0d11df5..3c3315f 100644 --- a/docs/client_install/src/asciidoc/_chapters/SQuirrel.adoc +++ b/docs/client_install/src/asciidoc/_chapters/SQuirrel.adoc @@ -27,8 +27,8 @@ These configuration instructions apply to Trafodion Release 1.3.*_n_* and subseq Make sure that you have this software installed on your workstation: -* Java Runtime Environment (JRE) 1.7 or higher. See <<jdbct4_JRE, Install Java Runtime Environment (JRE)>>. -* Trafodion JDBC Type-4 Driver. See <<jdbct4_install, JDBC Type-4 Installation>>. +* Java Runtime Environment (JRE) 1.7 or higher. See <<jdbct4-java-environment, Java Environment>> in the <<jdbct4, Install JDBC Type-4 Driver>> chapter above. +* Trafodion JDBC Type-4 Driver. See <<jdbct4,Install JDBC Type-4 Driver>> above. * SQuirreL SQL Client 3.5.0. See the http://squirrel-sql.sourceforge.net/[_SQuirreL SQL Client website_]. <<< @@ -44,7 +44,7 @@ Use the *Add Driver* function and register the Trafodion JDBC Type-4 Driver: image:{images}/Add_Driver_SQuirreL.jpg[alt="SQuirreL Add Driver Dialog Box"] + * Name: `Trafodion` -* Example URL: `jdbc:t4jdbc://_host-name or ip-address_:37800/:` +* Example URL: `jdbc:t4jdbc://_host-name or ip-address_:37800/:` (Default port number: *23400*) <<< === Connect to Trafodion @@ -55,6 +55,8 @@ image:{images}/Add_Alias_SQuirreL.jpg[alt="SQuirreL Add Alias Dialog Box"] 1. Edit the connection *URL* to match your Trafodion system's host name and port number: + +*Example* ++ ``` jdbc:t4jdbc://<host-name or ip-address>:37800/: ``` http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/about.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/about.adoc b/docs/client_install/src/asciidoc/_chapters/about.adoc index e29d926..1f42ab3 100644 --- a/docs/client_install/src/asciidoc/_chapters/about.adoc +++ b/docs/client_install/src/asciidoc/_chapters/about.adoc @@ -30,7 +30,7 @@ This manual describes how to install and configure client applications that enab This manual is intended for users who want to connect to and use a Trafodion database. == New and Changed Information -This manual shows updated versions for Trafodion Release 1.3.0. It also provides instructions on how to download and install <<odb,Trafodion odb>>, a +This manual shows updated versions for Trafodion Release {project-version}. It also provides instructions on how to download and install <<odb,Trafodion odb>>, a new multi-threaded, ODBC-based command-line tool for parallel data loading and extracting. == Notation Conventions @@ -133,6 +133,7 @@ For example: "{" module-name [, module-name] ... "}" ``` +<<< * Item Spacing + Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. @@ -147,7 +148,6 @@ If there is no space between two items, spaces are not permitted. In this exampl myfile.sh ``` -<<< * Line Spacing + If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. @@ -159,13 +159,6 @@ match-value [NOT] LIKE _pattern [ESCAPE esc-char-expression] ``` -== Publishing History -[cols="2*",options="header"] -|=== -| Product Version | Publication Date -| Trafodion Release 1.3.0 | To be announced. -|=== - == Comments Encouraged The Trafodion community encourages your comments concerning this document. We are committed to providing documentation that meets your needs. Send any errors found, suggestions for improvement, or compliments to: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/dbviz.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/dbviz.adoc b/docs/client_install/src/asciidoc/_chapters/dbviz.adoc index 127af27..b355cfb 100644 --- a/docs/client_install/src/asciidoc/_chapters/dbviz.adoc +++ b/docs/client_install/src/asciidoc/_chapters/dbviz.adoc @@ -21,19 +21,16 @@ //// = Configure DbVisualizer -These configuration instructions apply to Trafodion Release 1.3.*_n_* and subsequent updates of Trafodion until otherwise indicated. == Prerequisite Software Make sure that you have this software installed on your workstation: -* Java Runtime Environment (JRE) 1.7 or higher. -+ -See <<jdbct4_JRE, Install Java Runtime Environment (JRE)>>. +* Java Runtime Environment (JRE) 1.7 or higher. See <<jdbct4-java-environment, Java Environment>> in the <<jdbct4, Install JDBC Type-4 Driver>> chapter above. + In addition, see DbVisualizerâs FAQ âHow toâ page: http://confluence.dbvis.com/pages/viewpage.action?pageId=3146120[_How do I change the Java version that DbVisualizer uses?_] -* Trafodion JDBC Type-4 Driver. See <<jdbct4_install, JDBC Type-4 Installation>>. +* Trafodion JDBC Type-4 Driver. See <<jdbct4,Install JDBC Type-4 Driver>> above. * DbVisualizer 9.x.x. See the http://www.dbvis.com/[_DbVisualizer website_]. == Configuration Instructions @@ -51,9 +48,9 @@ dbvis.generic.-ConnectionValidationSelect=disabled ==== DbVisualizer 9.2 (or a later version) Set the *Physical Connection* property to keep your connections alive. Follow these steps: -1. For the database connection, select the *Properties* tab. +1. Double-click the database connection, select the *Properties* tab. 2. In the left navigation tree, expand the *Generic* connection properties, and select *Physical Connection*. -3. Under *Validation SQL*, enter `values(current_timestamp)`. +3. Under *Validation SQL*, enter `values(current_timestamp)` and click *Apply*. + <<< image:{images}/Physical_Connection.jpg[width=600,height=600,alt="DbVisualizer Physical Connection"] @@ -69,14 +66,16 @@ image:{images}/DbVisualizer_Driver_Manager.jpg[image] * Use the JDBC URL format: + ``` -jdbc:t4jdbc://<host-name or ip-address>:37800/: +jdbc:t4jdbc://<host-name or ip-address>:23400/: ``` ++ +*NOTE*: This example uses a modified port number (*37800*) rather than the default port number (*23400*). <<< === Connect to Trafodion Create a new connection by selecting the Trafodion JDBC Type-4 Driver and filling in the connection parameters. Edit the database URL to match -your Trafodion systemâs host name and port number: `jdbc:t4jdbc://<host-name or ip-address>:37800/:` +your Trafodion systemâs host name and port number; for example: `jdbc:t4jdbc://<host-name or ip-address>:37800/:` (default is: *23400*). image:{images}/Database_Connection_in_DbVisualizer.jpg[image] http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/introduction.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/introduction.adoc b/docs/client_install/src/asciidoc/_chapters/introduction.adoc index c347335..0d88d72 100644 --- a/docs/client_install/src/asciidoc/_chapters/introduction.adoc +++ b/docs/client_install/src/asciidoc/_chapters/introduction.adoc @@ -20,30 +20,128 @@ */ //// -= Trafodion Client Products +[[introduction]] += Introduction This manual describes how to install and configure the following client applications, which enable you to connect to and use a Trafodion database. == Client Summary -The following table lists the clients supported by Trafodion. -[cols="30%h,70%",options="header"] + +=== JDBC-Based Clients + +The following table lists JDBC-based clients supported by Trafodion. +[cols="30%,70%",options="header"] |=== | Client Name | Description -| Trafodion ODBC Driver for Windows | A driver that enables applications, which were developed for the Microsoft Open Database Connectivity (ODBC) application programming -interface (API) and which run on a Windows workstation, to connect to a Trafodion database. -| Trafodion ODBC Driver for Linux | A driver that enables applications, which were developed for the Microsoft ODBC API and run on a Linux workstation, to connect to a +| *Trafodion JDBC Type 4 Driver* | A driver that enables Java applications that run on a client workstation to connect to a Trafodion database. + + + +*NOTE:* The Trafodion Command Interface (TrafCI), DbVisualizer, and SQuirreL SQL Client require this driver to be installed on the client +workstation. +| *Trafodion Command Interface (TrafCI)* | A command-line interface that allows you to connect to a Trafodion database and run SQL statements and other commands interactively or from +script files. For more information, see the http://trafodion.incubator.apache.org/docs/command_interface/index.html[Trafodion Command Interface Guide]. +| *DbVisualizer* | A third-party database tool that allows you to connect to a Trafodion database. For more information, see the http://www.dbvis.com/[DbVisualizer website]. +| *SQuirreL SQL Client* | A third-party database tool that allows you to connect to a Trafodion database. For more information, see the +http://squirrel-sql.sourceforge.net/[SQuirreL SQL Client website]. +|=== + +=== ODBC-Based Clients + +The following table lists ODBC-based clients supported by Trafodion. +[cols="30%,70%",options="header"] +|=== +| Client Name | Description +| *Trafodion ODBC Driver for Linux* | A driver that enables applications, which were developed for the Microsoft ODBC API and run on a Linux workstation, to connect to a Trafodion database. -| Trafodion JDBC Type 4 Driver | A driver that enables Java applications that run on a client workstation to connect to a Trafodion database. +| *Trafodion ODBC Driver for Windows* | *[Not included in this release]*^1^ + + + +A driver that enables applications, which were developed for the Microsoft Open Database Connectivity (ODBC) application programming +interface (API) and which run on a Windows workstation, to connect to a Trafodion database. +| *Trafodion odb tool* | A multi-threaded, ODBC-based command-line tool for parallel data loading and extracting. For more information, see the +http://trafodion.incubator.apache.org/docs/odb_user/index.html[Trafodion odb User Guide]. +|=== -NOTE: The Trafodion Command Interface (TrafCI), DbVisualizer, and SQuirreL SQL Client require this driver to be installed on the client -workstation. -| Trafodion Command Interface (TrafCI) | A command-line interface that allows you to connect to a Trafodion database and run SQL statements and other commands interactively or from -script files. For more information, see the http://trafodion.incubator.apache.org/docs/command_interface/index.html[_Trafodion Command Interface Guide_]. -| Trafodion odb tool | A multi-threaded, ODBC-based command-line tool for parallel data loading and extracting. For more information, see the -http://trafodion.incubator.apache.org/docs/odb_user/index.html[_Trafodion odb User Guide_]. -| DbVisualizer | A third-party database tool that allows you to connect to a Trafodion database. For more information, see the http://www.dbvis.com/[_DbVisualizer website_]. -| SQuirreL SQL Client | A third-party database tool that allows you to connect to a Trafodion database. For more information, see the -http://squirrel-sql.sourceforge.net/[_SQuirreL SQL Client website_]. +^1^ License issues prevent us from including the ODBC Driver for Windows in this release. Contact the +Trafodion user e-mail list ([email protected]) for help obtaining the driver. + +<<< +[[introduction-download]] +== Download Installation Package +The Trafodion client software is available from the http://http://trafodion.apache.org/download.html[Trafodion Download] page. There is one +`Trafodion Clients` package per release listed under *<version> Binaries*. + +The `Trafodion Clients` package consists of a zipped tar file that contains the Trafodion Clients tar file. The Trafodion Client +binaries are located in the Clients folder, which contains the following files: + +[cols="30%l,70%", options="header"] |=== +| File | Usage +| odbc64_linux.tar.gz | Trafodion odb tool. +| TFODBC64-*.exe | *[Not included in this release]*^1^ Trafodion ODBC Driver for Windows. +| TRAF_ODBC_Linux_Driver_64.tar.gz | Trafodion ODBC driver for Linux. +| trafci.zip | The Trafodion command interpreter `trafci`. +| JDBCT4.zip | Trafodion JDBC Type 4 Driver. +|=== + +^1^ License issues prevent us from including the ODBC Driver for Windows in this release. Contact the +Trafodion user e-mail list ([email protected]) for help obtaining the driver. + +[[introduction-windows-download]] +=== Windows Download + +Do the following: + +1. Create a download folder on the client workstation. For example, `Trafodion Downloads`. + +2. Open a Web browser and navigate to the Trafodion downloads site http://trafodion.incubator.apache.org/download.html. + +3. Orient yourself to the binaries for the release you're installing. +Click on the `Trafodion Clients` link to start downloading the Trafodion clients tar file to your workstation. + +4. Place the `apache-trafodion-clients-*.tar.gz` file into the download folder. + +5. Unpack the `apache-trafodion-clients-\*.tar.gz` file using an unzip program of your choice. This creates +an `apache-trafodion-clients-*.tar` file. + +6. Unpack the `apache-trafodion-clients-*.tar` file using an unzip program of your choice. This creates +the `clients` folder, which has the following content: ++ +``` +JDBCT4.zip odb64_linux.tar.gz trafci.zip TRAF_ODBC_Linux_Driver_64.tar.gz +``` ++ +You use these files to install the different Trafodion clients. + +[[introduction-linux-download]] +=== Linux Download + +Do the following: + +1. Create a download directory on the client workstation. For example, `$HOME/trafodion-downloads`. + +2. Open a Web browser and navigate to the Trafodion downloads site http://trafodion.incubator.apache.org/download.html. + +3. Orient yourself to the binaries for the release you're installing. +Right-click on the `Trafodion Clients` link and select *Copy link address*. + +4. Go to the download directory on the client workstation and use `wget` to download the client package +using the link address you copied in step 3 above. + +5. Unpack the `apache-trafodion-clients-*.tar.gz` using `tar`. ++ +*Example* ++ +``` +$ mkdir $HOME/trafodion-downloads +$ cd $HOME/trafodion-downloads +$ wget <link to package> +$ tar -xzf apache-trafodion-clients-1.3.0-incubating-bin.tar.gz +$ cd clients +$ ls +JDBCT4.zip odb64_linux.tar.gz trafci.zip TRAF_ODBC_Linux_Driver_64.tar.gz +$ +``` ++ +You use these files to install the different Trafodion clients. + http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/jdbct4.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/jdbct4.adoc b/docs/client_install/src/asciidoc/_chapters/jdbct4.adoc index a2c2e34..74b68c2 100644 --- a/docs/client_install/src/asciidoc/_chapters/jdbct4.adoc +++ b/docs/client_install/src/asciidoc/_chapters/jdbct4.adoc @@ -20,61 +20,24 @@ * //// +[[jdbct4]] = Install JDBC Type-4 Driver -These installation instructions apply to Trafodion Release 1.3.*_n_* and subsequent updates of the product until otherwise indicated. - -== Installation Package - -The distribution file for the Trafodion JDBC Type 4 Driver is packaged within the Trafodion clients tar file, `clients-1.3.*_n_*.tar.gz`, -on the Trafodion downloads site http://trafodion.incubator.apache.org/download.html. - -Use this distribution file to install the Trafodion JDBC Type 4 Driver: - -[cols="35%l,35%,30%",options="header"] -|=== -| Distribution File | Description | Client Operating System -| JDBCT4.zip | Zip file | Windows or Linux -|=== - -By default, a new version of the JDBC Type 4 driver will be installed in this directory and its folders unless you specify a -different directory during installation: - -[cols="65%,35%",options="header"] -|=== -| Default Installation Directory | Client Operating System -| _<user-specified directory>_ (For example: /usr/local/jdbc) | Windows or Linux -|=== - -[cols="30%l,25%l,45%",options="header"] -|=== -| Installation Folder | Files | Description -| /lib | jdbcT4.jar | Product JAR file. -| /samples | t4jdbc.properties | Properties file that you can configure for your application environment. -| | README | Readme file that explains how to use the common sample set. -| /samples/common | sampleUtils.java | Sample source code for creating, populating, and dropping sample tables. -| /samples/DBMetaSample | DBMetaSample.java | Sample source code for getting metadata about the sample tables. -| | README | Readme file that explains how to use this sample set. -| /samples/PreparedStatementSample | PreparedStatementSample.java | Sample code for simple or parameterized SELECT statements that are prepared. -| | README | Readme file that explains how to use this sample set. -| /samples/ResultSetSample | README | Readme file that explains how to use this sample set. -| | ResultSetSample.java | Sample source code for fetching rows from a result set. -| /samples/StatementSample | README | Readme file that explains how to use this sample set. -| | StatementSample.java | Sample source code for fetching rows from a simple SELECT statement. -|=== +[[jdbct4-installation-requirements]] == Installation Requirements The Trafodion JDBC Type 4 Driver requires a Java-enabled platform that supports the Java Development Kit (JDK) 1.7 or higher. -To determine the Java version that you have installed on your client workstation and to install a supported version, please refer to -<<jdbct4_JRE, Install Java Runtime Environment (JRE)>> below. - -[[jdbct4_JRE]] -=== Install Java Runtime Environment (JRE) +[[jdbct4-java-environment]] +=== Java Environment The Trafodion JDBC Type 4 Driver requires that a compatible Java version be installed on the client workstation and that the Java path be set to the correct location. The supported Java version is 1.7 or higher. +NOTE: If you plan to do Java-based development, install the Java Development Kit (JDK) rather than the Java Runtime Environment (JRE). +These examples use JRE. + +[[jdbct4-verify-java-version]] ==== Verify Java Version To display the Java version of the client workstation on the screen, enter: @@ -93,7 +56,7 @@ C:\> ``` The Java version should be *1.7* or higher. If the returned version is not supported, please refer to -<<jdbct4_install_java, Installing a Supported Java Version>> below. +<<jdbct4-install-java, Installing a Supported Java Version>> below. <<< If you see this message: @@ -105,10 +68,10 @@ If you see this message: It indicates that the Java PATH is not set. Follow one of these sets of instructions, depending on the operating system of your client workstation: -* <<jdbct4_path_windows, Setting the PATH to a Supported Java Version on Windows>> -* <<jdbct4_path_linux, Setting the PATH to a Supported Java Version on Linux>> +* <<jdbct4-path-windows, Setting the PATH to a Supported Java Version on Windows>> +* <<jdbct4-path-linux, Setting the PATH to a Supported Java Version on Linux>> -[[jdbct4_install_java]] +[[jdbct4-install-java]] ==== Install Supported Java Version The supported Java version is 1.7 or higher. To install one of the supported Java versions on the client workstation, @@ -117,16 +80,42 @@ go to this link: http://www.java.com/en/download After installing the Java version, proceed with setting the Java path. Follow one of these sets of instructions, depending on the operating system of your client workstation: -* <<jdbct4_path_windows, Setting the PATH to a Supported Java Version on Windows>> -* <<jdbct4_path_linux, Setting the PATH to a Supported Java Version on Linux>> +* <<jdbct4-path-windows, Setting the PATH to a Supported Java Version on Windows>> +* <<jdbct4-path-linux, Setting the PATH to a Supported Java Version on Linux>> -[[jdbct4_path_windows]] +[[jdbct4-path-windows]] ==== Set Windows PATH Variable -1. Right-click the *Computer* icon on your desktop, and then select *Properties*. The *Control Panel > System and Security > System* window +===== Windows 10 + +1. Right-click on the Windows icon on the menu bar. Select *System*. + +2. Click on *Advanced System Settings*. + +3. In the *System Properties* dialog box, click the *Advanced* tab. +4. Click the *Environment Variables* button. +5. Under *System* variables, select the variable named *Path*, and then click *Edit. . .*: ++ +image:{images}/win10_edit_path.jpg[Windows 10 Edit Path Variable] + +6. Click *Browse. . .*. Find the directory where you installed Java and select it. ++ +image:{images}/win10_select_java.jpg[image] + +7. Click *OK* to close the browse window. Click *OK* to close the edit window. +8. Verify that the updated *Path* appears under *System* variables, and click *OK*. +9. In the *System Properties* dialog box, click *OK* to accept the changes. + + +===== Windows 8 + +1. Open system Right-click the *Computer* icon on your desktop, and then select *Properties*. The *Control Panel > System and Security > System* window appears. -2. In the left navigation bar, click the *Advanced* system settings link. + +2. In the left navigation bar, click the *Advanced* system settings link. + 3. In the *System Properties* dialog box, click the *Environment Variables* button. + 4. Under *System* variables, select the variable named *Path*, and then click *Edit*: + image:{images}/path2.jpg[image] @@ -148,7 +137,7 @@ path in double quotes (") before the semicolon. 7. Verify that the updated *Path* appears under *System* variables, and click *OK*. 8. In the *System Properties* dialog box, click *OK* to accept the changes. -[[jdbct4_path_linux]] +[[jdbct4-path_linux]] ==== Set Linux PATH Variable 1. Open the user profile (`.profile` or `.bash_profile` for the Bash shell) in the `$HOME` directory. @@ -174,46 +163,189 @@ use the setenv command instead of export. . .profile ``` -<<< -[[jdbct4_install]] +[[jdbct4-install-instructions]] == Installation Instructions -[[jdbct4_download]] -=== Download JDBC Type-4 Driver +You download and extract the Trafodion client package using the instructions in <<introduction-download, Download Installation Package>> above. -1. Create a download folder on the client workstation. -2. Open a Web browser and navigate to the Trafodion downloads site http://trafodion.incubator.apache.org/download.html. -3. Click on the `clients-1.3.*_n_*.tar.gz` link to start downloading the Trafodion clients tar file to your workstation. -4. Place the `clients-1.3.*_n_*.tar.gz` file into the download folder. -5. Unpack the `clients-1.3.*_n_*.tar.gz` file. +[[jdbct4-install-driver]] +=== Install JDBC Type-4 Driver + +1. Change the directory to the `clients` subdirectory. +2. Extract the contents of the `JDBCT4.zip` file by using the unzip command (or the extract function of your compression software): ++ +*Example* + ``` -tar -xzf clients-1.3.0.tar.gz +unzip JDBCT4.zip -d $HOME/jdbc ``` -+ -The package file contains the `JDBCT4.zip` distribution file, which is extracted to the clients subdirectory. -6. Proceed with <<jdbct4_install_zip, Installing the Trafodion JDBC Type 4 Driver From the Zip File>> below. +The content of the target directory is as follows: -[[jdbct4_install_zip]] -=== Install JDBC Type-4 Driver +[cols="33%l,30%l,37%",options="header"] +|=== +| Installation Folder | Files | Description +| /lib | jdbcT4.jar | Product JAR file. +| /samples | t4jdbc.properties | Properties file that you can configure for your application environment. +| | README | Readme file that explains how to use the common sample set. +| /samples/common | sampleUtils.java | Sample source code for creating, populating, and dropping sample tables. +| /samples/DBMetaSample | DBMetaSample.java | Sample source code for getting metadata about the sample tables. +| | README | Readme file that explains how to use this sample set. +| /samples/PreparedStatementSample | PreparedStatementSample.java | Sample code for simple or parameterized SELECT statements that are prepared. +| | README | Readme file that explains how to use this sample set. +| /samples/ResultSetSample | README | Readme file that explains how to use this sample set. +| | ResultSetSample.java | Sample source code for fetching rows from a result set. +| /samples/StatementSample | README | Readme file that explains how to use this sample set. +| | StatementSample.java | Sample source code for fetching rows from a simple SELECT statement. +|=== + +[[jdbct4-setup-env]] +== Set Up Client Environment + +=== Java Development + +If you plan to write and run Java applications that use the Trafodion JDBC Type 4 Driver to connect to a Trafodion database, then set these +environment variables on the client workstation, replacing `_jdk-directory_` with the location of your Java Development Kit and +replacing `_jdbc-installation-directory_` with the name of the directory where you downloaded the JDBC Type 4 driver: + +[cols="20%l,40%l,40%l",options="header"] +|=== +| Environment Variable | On Windows | On Linux +| JAVA_HOME | set JAVA_HOME="_jdk-directory_"^1^ | export JAVA_HOME=_jdk-directory_ +| PATH | set PATH=%PATH%;%JAVA_HOME%\bin | export PATH=$PATH:$JAVA_HOME/bin +| CLASSPATH | set CLASSPATH=%CLASSPATH%;_jdbc-installation-directory_\lib\jdbcT4.jar; | export CLASSPATH=$CLASSPATH:_jdbc-installation-directory_/lib/jdbcT4.jar: +|=== + +^1^ Enclose the _jdk-directory_ in quotes to ensure that Windows can find the directory correctly. You can use the `set <variable>` command to verify the setting. + +<<< +=== Configure Applications + +Edit the `t4jdbc.properties` file in the `samples` folder. Refer to the `README` file in the `samples` folder for instructions. + +Set these values for your environment: + +* _catalog_: Specify a catalog that exists in the database. +* _schema_: Specify a schema that exists in the database. +* _user_: Specify the name of a user who will be accessing the database. +* _password_: Specify the password of a user who will be accessing the database. +* _url_: Specify this string: _jdbc:t4jdbc://_host-name_:_port-number_/:_ + +_host-name_ is the IP address or host name of the database platform, and _port-number_ is the location where the +Trafodion Database Connectivity Service (DCS) is running, which is *23400* by default. See the +http://trafodion.incubator.apache.org/docs/dcs_reference/index.html[Trafodion Database Connectivity Services Reference Guide] +for information about how to configure the DCS port. + +*Example* + +In this example, Trafodion authentication has not been enabled. Therefore, you can use a dummy +user and password. If authentication is enabled, then use your user and password information. -1. Change the directory to the clients subdirectory. -2. Extract the contents of the `JDBCT4.zip` file by using the unzip command (or the WinZip extract tool): -+ ``` -unzip JDBCT4.zip +catalog = TRAFODION +schema = SEABASE +user = usr +password = pwd + +url = jdbc:t4jdbc://trafodion.host.com:23400/: ``` -+ -The command creates these subdirectories: -+ -* `lib`, which contains the `jdbcT4.jar` file -* `samples`, which contains sample programs -3. Set up the client environment. See <<jdbct4_setup_env, Set Up Client Environment>>. +NOTE: The driverâs class name is `org.trafodion.jdbc.t4.T4Driver`. <<< -=== Uninstall JDBC Type-4 Driver +[[jdbct4-test-programs]] +== Test Programs + +The `README` file in the `samples` folder provide information for how you build and run sample Java programs. +You can use these programs to verify the setup of the Trafodion JDBC Type-4 driver. +See the <<jdbct4-install-driver, Install JDBC Type-4 Driver>> section above for information on the different +sample programs that are included with the Trafodion JDBC Type-4 driver. + +*Example* + +Build and run the StatementSample test program to verify the JDBC Type-4 driver installation. + +``` +C:\Development Tools\Trafodion JDBCT4\samples>cd StatementSample + +C:\Development Tools\Trafodion JDBCT4\samples\StatementSample>%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java +Note: ..\common\sampleUtils.java uses or overrides a deprecated API. +Note: Recompile with -Xlint:deprecation for details. +v +C:\Development Tools\Trafodion JDBCT4\samples\StatementSample>%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties StatementSample +Mar 16, 2016 9:36:54 PM common.sampleUtils getPropertiesConnection +INFO: DriverManager.getConnection(url, props) passed + +Inserting TimeStamp + +Simple Select + +Printing ResultSetMetaData ... +No. of Columns 12 +Column 1 Data Type: CHAR Name: C1 +Column 2 Data Type: SMALLINT Name: C2 +Column 3 Data Type: INTEGER Name: C3 +Column 4 Data Type: BIGINT Name: C4 +Column 5 Data Type: VARCHAR Name: C5 +Column 6 Data Type: NUMERIC Name: C6 +Column 7 Data Type: DECIMAL Name: C7 +Column 8 Data Type: DATE Name: C8 +Column 9 Data Type: TIME Name: C9 +Column 10 Data Type: TIMESTAMP Name: C10 +Column 11 Data Type: REAL Name: C11 +Column 12 Data Type: DOUBLE PRECISION Name: C12 + +Fetching rows... + +Printing Row 1 using getString(), getObject() +Column 1 - Row1 ,Row1 +Column 2 - 100,100 +Column 3 - 12345678,12345678 +Column 4 - 123456789012,123456789012 +Column 5 - Selva,Selva +Column 6 - 100.12,100.12 +Column 7 - 100.12,100.12 +Column 8 - 2000-05-06,2000-05-06 +Column 9 - 10:11:12,10:11:12 +Column 10 - 2000-05-06 10:11:12.000000,2000-05-06 10:11:12.0 +Column 11 - 100.12,100.12 +Column 12 - 100.12,100.12 + +Printing Row 2 using getString(), getObject() +Column 1 - Row2 ,Row2 +Column 2 - -100,-100 +Column 3 - -12345678,-12345678 +Column 4 - -123456789012,-123456789012 +Column 5 - Selva,Selva +Column 6 - -100.12,-100.12 +Column 7 - -100.12,-100.12 +Column 8 - 2000-05-16,2000-05-16 +Column 9 - 10:11:12,10:11:12 +Column 10 - 2000-05-06 10:11:12.000000,2000-05-06 10:11:12.0 +Column 11 - -100.12,-100.12 +Column 12 - -100.12,-100.12 + +Printing Row 3 using getString(), getObject() +Column 1 - TimeStamp ,TimeStamp +Column 2 - -100,-100 +Column 3 - -12345678,-12345678 +Column 4 - -123456789012,-123456789012 +Column 5 - Selva,Selva +Column 6 - -100.12,-100.12 +Column 7 - -100.12,-100.12 +Column 8 - 2016-03-16,2016-03-16 +Column 9 - 21:37:03,21:37:03 +Column 10 - 2016-03-16 21:37:03.053,2016-03-16 21:37:03.053 +Column 11 - -100.12,-100.12 +Column 12 - -100.12,-100.12 + +End of Data + +C:\Development Tools\Trafodion JDBCT4\samples\StatementSample> +``` + +<<< +== Uninstall JDBC Type-4 Driver Run one of these sets of commands to remove the Trafodion JDBC Type 4 Driver: * On Linux: @@ -225,10 +357,9 @@ rm -rf <jdbc-installation-directory> *Example* + ``` -rm -rf /usr/local/jdbc +rm -rf ~/jdbc ``` -<<< * On Windows: + ``` @@ -236,6 +367,8 @@ del <jdbc-installation-directory> rmdir <jdbc-installation-directory> ``` + +<<< ++ *Example* + Windows uninstall @@ -272,54 +405,10 @@ C:\> ``` <<< -=== Reinstall JDBC Type-4 Driver - -1. Close all applications running on the workstation, except the Web browser. -2. In the browser, navigate to the download site and download the client package file. For more information, please refer to -<<jdbct4_download, Downloading the Trafodion JDBC Type 4 Driver>>. -3. Extract the contents of the zip file by following these instructions: <<jdbct4_install_zip, Installing the Trafodion JDBC Type 4 Driver From the Zip File>>. -4. Set up the client environment. Please refer to: <<jdbct4_setup_env, Setting Up the Client Environment>>. - -[[jdbct4_setup_env]] -== Set Up Client Environment - -Check that you have a supported Java version installed on the client workstation. The supported Java version is 1.7 or higher. For more -information, see <<jdbct4_JRE, Installing and Verifying the Java Runtime>>. - -If you plan to write and run Java applications that use the Trafodion JDBC Type 4 Driver to connect to a Trafodion database, set these -environment variables on the client workstation, replacing `_jdk-directory_` with the location of your Java Development Kit and -replacing `_jdbc-installation-directory_` with the name of the directory where you downloaded the JDBC Type 4 driver: +== Reinstall JDBC Type-4 Driver -[cols="20%l,40%l,40%l",options="header"] -|=== -| Environment Variable | On Windows | On Linux -| JAVA_HOME | set JAVA_HOME=_jdk-directory_ | export JAVA_HOME=_jdk-directory_ -| PATH | set PATH=%PATH%;%JAVA_HOME%\bin | export PATH=$PATH:$JAVA_HOME/bin -| CLASSPATH | set CLASSPATH=%CLASSPATH%;_jdbc-installation-directory_\lib\jdbcT4.jar; | export CLASSPATH=$CLASSPATH:_jdbc-installation-directory_/lib/jdbcT4.jar: -|=== - -<<< -=== Configure Applications - -Edit the `t4jdbc.properties` file. Set these values for your environment: - -* _catalog_: Specify a catalog that exists in the database. -* _schema_: Specify a schema that exists in the database. -* _user_: Specify the name of a user who will be accessing the database. -* _password_: Specify the password of a user who will be accessing the database. -* _url_: Specify this string: _jdbc:t4jdbc://_host-name_:_port-number_/:_ - -_host-name_ is the IP address or host name of the database platform, and _port-number_ is the location where the -Trafodion Database Connectivity Service (DCS) is running, which is 37800 by default. - -*Example* - -``` -catalog = <your-catalog> schema = <your-schema> user = <user-name> -password = <password> - -url = jdbc:t4jdbc://<host-name>:<port-number>/: -``` - -NOTE: The driverâs class name is `org.trafodion.jdbc.t4.T4Driver`. +1. Close all applications running on the workstation, except the Web browser. +2. Download and extract the Trafodion client package using the instructions in <<introduction-download, Download Installation Package>> above. +3. Install the new Trafodion JDBC Type-4 driver. See <<jdbct4-install-driver, Install JDBC Type-4 Driver>>. +4. Set up the client environment. Please refer to: <<jdbct4-setup-env, Set Up Client Environment>>. http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c86d2385/docs/client_install/src/asciidoc/_chapters/odb.adoc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/asciidoc/_chapters/odb.adoc b/docs/client_install/src/asciidoc/_chapters/odb.adoc index af97723..4e397af 100644 --- a/docs/client_install/src/asciidoc/_chapters/odb.adoc +++ b/docs/client_install/src/asciidoc/_chapters/odb.adoc @@ -22,21 +22,6 @@ [[install-odb]] = Install odb -These installation instructions apply to Trafodion Release 1.3.*_n_* and subsequent updates of the product until otherwise indicated. - -[[installation-package]] -== Installation Package - -The distribution file for odb is packaged within the Trafodion clients tar file, `clients-1.3.*_n_*.tar.gz`, -on the Trafodion downloads site http://trafodion.incubator.apache.org/download.html. -Use this distribution file to install odb: - -[cols="35%l,35%l,30%",options="header"] -|=== -| Distribution File | File Contents | Client Operating System -| odb64_linux.tar.gz | README + -/bin/odb64luo | 64-bit Linux -|=== [[installation-requirements]] == Installation Requirements @@ -51,50 +36,28 @@ http://trafodion.apache.org/docs/odb_user/index.html[_Trafodion odb User Guide_] NOTE: Before following these installation instructions, please make sure to install and configure unixODBC on the client workstation. For more information, see the http://trafodion.apache.org/docs/odb_user/index.html[_Trafodion odb User Guide_]. -Follow these instructions to download and install odb on the client workstation. - -* <<odb-download, Downloading odb>> -* <<odb-install, Installing odb>> - -To uninstall odb, please refer to <<odb_uninstall, Uninstalling odb>>. - -<<< -[[odb-download]] -=== Download odb - -1. Create a download folder on the client workstation. -2. Open a Web browser and navigate to the Trafodion downloads site http://trafodion.incubator.apache.org/download.html -3. Click on the `clients-1.3.*_n_*.tar.gz` link to start downloading the Trafodion clients tar file to your workstation. -4. Place the `clients-1.3.*_n_*.tar.gz` file into the download folder. -5. Unpack the `clients-1.3.*_n_*.tar.gz` file. -+ -``` -tar -xzf clients-1.3.0.tar.gz -``` -+ -The package file contains the `odb64_linux.tar.gz` distribution file, which is extracted to the clients subdirectory. - -6. Proceed with <<odb_install, Installing odb>>. +You download and extract the Trafodion client package using the instructions in <<introduction-download, Download Installation Package>> above. [[odb-install]] === Install odb -1. Change the directory to the clients subdirectory. +1. Change the directory to the `clients` subdirectory. 2. Unpack the contents of the `odb64_linux.tar.gz` file to a location on your client workstation: + ``` -tar -xzf odb64_linux.tar.gz +mkdir $HOME/odb +tar -xzf odb64_linux.tar.gz -C $HOME/odb ``` + The command extracts these files: + * `README` -* `/bin/odb64luo` `odb64luo` is the odb executable. +* `/bin/odb64luo` (the odb executable) 3. You are now ready to run the odb executable. For more information, see the http://trafodion.apache.org/docs/odb_user/index.html[_Trafodion odb User Guide_]. [[odb-uninstall]] -=== Uninstall odb +== Uninstall odb To uninstall odb, delete the `README` and `/bin/odb64luo` files from their installed location.
