[1/3] incubator-trafodion git commit: Miscellaneous authorization changes:
Repository: incubator-trafodion Updated Branches: refs/heads/master 6b07d620e -> 9e5f36cd3 http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/079ea00a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp -- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp index 70d37d1..cc1e4a5 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp @@ -7167,15 +7167,12 @@ short CmpSeabaseDDL::updateSeabaseAuths( Int64 initTime = NA_JulianTimestamp(); - str_sprintf(buf, "insert into %s.\"%s\".%s values (%d, 'DB__ROOT', 'TRAFODION', 'U', %d, 'Y', %ld,%ld, 0) ", - sysCat, SEABASE_MD_SCHEMA, SEABASE_AUTHS, - SUPER_USER, SUPER_USER, initTime, initTime); - cliRC = cliInterface->executeImmediate(buf); - if (cliRC < 0) -{ - cliInterface->retrieveSQLDiagnostics(CmpCommon::diags()); - return -1; -} + NAString mdLocation; + CONCAT_CATSCH(mdLocation, getSystemCatalog(), SEABASE_MD_SCHEMA); + CmpSeabaseDDLuser authOperation(sysCat, mdLocation.data()); + authOperation.registerStandardUser(DB__ROOT, ROOT_USER_ID); + if (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_)) +return -1; return 0; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/079ea00a/core/sql/sqlcomp/PrivMgrComponentDefs.h -- diff --git a/core/sql/sqlcomp/PrivMgrComponentDefs.h b/core/sql/sqlcomp/PrivMgrComponentDefs.h new file mode 100644 index 000..8986dd9 --- /dev/null +++ b/core/sql/sqlcomp/PrivMgrComponentDefs.h @@ -0,0 +1,284 @@ +//* +// @@@ 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_COMPONENTS_DEFS_H +#define PRIVMGR_COMPONENTS_DEFS_H + +// * +// * +// * Component definition section +// * +// * Several system components are created and managed by the database. +// * They are managed by two main structures: +// * ComponentListStruct - the list of components +// * ComponentOpStruct - the list of operations for each component +// * +// * To add a new component (assume xxx is component name): +// *Assign a UID(in enum ComponentOp add xxx_COMPONENT_UID) +// *Generate a component name (add new define called xxx_NAME) +// *Define component operations (add enum xxxOperation) +// *Define operation attributes (add ComponentOpStruct xxxOpStruct) +// *Add component to list (add component to componentList) +// * +// * To add a new operation to an existing component, see comments associated +// * with the component. +// * +// * + +// The ComponentOpStruct describes a component +// operationID - a number from xxxOperation representing the operation +// operationCode - unique 2 charater value that represents the operation +// operationName - unique name for the operation +// isRootRoleOp - grant DB__ROOTROLE this operation +// isAdminOp - grant DB__ADMIN/DB__ADMINROLE this operation +// isDMLOp - this is a DML operation +// isPublicOp- grant PUBLIC this operation +struct ComponentOpStruct +{ + int32_t operationID; + const char * operationCode; + const char * operationName; + const bool isRootRoleOp; + const bool isAdminOp; + const bool isDMLOp; + const bool isPublicOp; +}; + +// The ComponentListStruct describes the relationship between a component UID, +// its name, the number of operations for the component, and a pointer to the +// list of operations. +// componentUID - the UID for the component +// componentName - the component name +// numOps- the number of operations in the component +// componentOps - pointer the ComponentOpStruct describing the operations +struct ComponentListStruct +{ +
[3/3] incubator-trafodion git commit: Merge pr 1274 miscellaneous authorization changes
Merge pr 1274 miscellaneous authorization changes Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9e5f36cd Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9e5f36cd Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9e5f36cd Branch: refs/heads/master Commit: 9e5f36cd36c0b77ca2b9a3f46afbd56761fa7929 Parents: 6b07d62 079ea00 Author: Roberta Marton Authored: Thu Oct 26 17:23:17 2017 + Committer: Roberta Marton Committed: Thu Oct 26 17:23:17 2017 + -- core/sql/bin/SqlciErrors.txt| 2 +- core/sql/common/ComUser.cpp | 6 +- core/sql/common/NAUserId.h | 73 +- core/sql/regress/privs1/EXPECTED132 | 941 ++- core/sql/regress/privs1/TEST132 | 145 +-- core/sql/sqlci/SqlCmd.cpp | 1 + core/sql/sqlci/SqlciCmd.h | 9 +- core/sql/sqlci/SqlciEnv.cpp | 49 +- core/sql/sqlci/sqlci_lex.ll | 1 + core/sql/sqlci/sqlci_yacc.y | 11 + core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 2 +- core/sql/sqlcomp/CmpSeabaseDDLauth.cpp | 351 --- core/sql/sqlcomp/CmpSeabaseDDLauth.h| 18 +- core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp| 15 +- core/sql/sqlcomp/PrivMgrComponentDefs.h | 284 ++ core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp | 240 - core/sql/sqlcomp/PrivMgrComponentPrivileges.h | 2 + core/sql/sqlcomp/PrivMgrMD.cpp | 14 +- core/sql/sqlcomp/PrivMgrRoles.cpp | 2 +- 19 files changed, 1238 insertions(+), 928 deletions(-) --
[2/3] incubator-trafodion git commit: Miscellaneous authorization changes:
Miscellaneous authorization changes: - Unregister user does not remove component privileges - Reuse unused entries from the authID ranges - Add "changeuser" command to update user credentials in place instead of requiring a new sqlci session to be started. Changed privs1/TEST132 to use this change and cut about 5 minutes off the test time. Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/079ea00a Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/079ea00a Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/079ea00a Branch: refs/heads/master Commit: 079ea00a1710c9ca8474db06a44309e21c5a0361 Parents: 5071a20 Author: Roberta Marton Authored: Mon Oct 23 16:13:00 2017 + Committer: Roberta Marton Committed: Mon Oct 23 16:13:00 2017 + -- core/sql/bin/SqlciErrors.txt| 2 +- core/sql/common/ComUser.cpp | 6 +- core/sql/common/NAUserId.h | 73 +- core/sql/regress/privs1/EXPECTED132 | 941 ++- core/sql/regress/privs1/TEST132 | 145 +-- core/sql/sqlci/SqlCmd.cpp | 1 + core/sql/sqlci/SqlciCmd.h | 9 +- core/sql/sqlci/SqlciEnv.cpp | 49 +- core/sql/sqlci/sqlci_lex.ll | 1 + core/sql/sqlci/sqlci_yacc.y | 11 + core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 2 +- core/sql/sqlcomp/CmpSeabaseDDLauth.cpp | 351 --- core/sql/sqlcomp/CmpSeabaseDDLauth.h| 18 +- core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp| 15 +- core/sql/sqlcomp/PrivMgrComponentDefs.h | 284 ++ core/sql/sqlcomp/PrivMgrComponentPrivileges.cpp | 240 - core/sql/sqlcomp/PrivMgrComponentPrivileges.h | 2 + core/sql/sqlcomp/PrivMgrMD.cpp | 14 +- core/sql/sqlcomp/PrivMgrRoles.cpp | 2 +- 19 files changed, 1238 insertions(+), 928 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/079ea00a/core/sql/bin/SqlciErrors.txt -- diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt index d70f23d..8fdd3dc 100644 --- a/core/sql/bin/SqlciErrors.txt +++ b/core/sql/bin/SqlciErrors.txt @@ -5,7 +5,7 @@ 1003 Z 9 BEGINNER MINOR DBADMIN Schema $0~SchemaName does not exist. 1004 Z 9 BEGINNER MINOR DBADMIN Object $0~TableName does not exist or object type is invalid for the current operation. 1005 Z 9 BEGINNER MINOR DBADMIN Constraint $0~ConstraintName does not exist. -1006 Z 9 BEGINNER MINOR DBADMIN --- unused --- +1006 Z 9 BEGINNER MINOR DBADMIN Skipping authorization ID $0~Int0. 1007 Z 9 ADVANCED MAJOR DBADMIN The WITH GRANT OPTION is not supported. 1008 Z 9 BEGINNER MINOR DBADMIN Authorization identifier $0~String0 does not exist. 1009 Z 9 BEGINNER MINOR DBADMIN Column $0~ColumnName does not exist in the specified table. http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/079ea00a/core/sql/common/ComUser.cpp -- diff --git a/core/sql/common/ComUser.cpp b/core/sql/common/ComUser.cpp index b8261f4..796d94b 100644 --- a/core/sql/common/ComUser.cpp +++ b/core/sql/common/ComUser.cpp @@ -408,7 +408,7 @@ Int32 ComUser::getRoleList (char * roleList, const char separator, const bool includeSpecialAuths) { - Int32 numberRoles = sizeof(systemRoles)/sizeof(SystemRolesStruct); + Int32 numberRoles = sizeof(systemRoles)/sizeof(SystemAuthsStruct); Int32 roleListLen = (MAX_AUTHNAME_LEN*numberRoles)+(numberRoles * 4); // 4 = 2 del + 2 sep char generatedRoleList[roleListLen]; char *pRoles = generatedRoleList; @@ -416,13 +416,13 @@ Int32 ComUser::getRoleList (char * roleList, char currentSeparator = ' '; for (Int32 i = 0; i < numberRoles; i++) { -const SystemRolesStruct &roleDefinition = systemRoles[i]; +const SystemAuthsStruct &roleDefinition = systemRoles[i]; if (!includeSpecialAuths && roleDefinition.isSpecialAuth) continue; // str_sprintf does not support the %c format sprintf(roleName, "%c%c%s%c", -currentSeparator, delimiter, roleDefinition.roleName, delimiter); +currentSeparator, delimiter, roleDefinition.authName, delimiter); str_cpy_all(pRoles, roleName, sizeof(roleName)-1); // don't copy null terminator currentSeparator = separator; pRoles = pRoles + strlen(roleName); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/079ea00a/core/sql/common/NAUserId.h
[1/3] incubator-trafodion git commit: fix TRAFODION-2773
Repository: incubator-trafodion Updated Branches: refs/heads/master 9e5f36cd3 -> 9dd862c14 fix TRAFODION-2773 Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9f93e7d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9f93e7d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9f93e7d5 Branch: refs/heads/master Commit: 9f93e7d55357c543c035328ca21e9b70959184b6 Parents: 574452e Author: SuJinpei <873118...@qq.com> Authored: Thu Oct 19 15:54:38 2017 +0800 Committer: SuJinpei <873118...@qq.com> Committed: Thu Oct 19 15:54:38 2017 +0800 -- core/conn/odb/src/odb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9f93e7d5/core/conn/odb/src/odb.c -- diff --git a/core/conn/odb/src/odb.c b/core/conn/odb/src/odb.c index bf72f1b..da88eec 100755 --- a/core/conn/odb/src/odb.c +++ b/core/conn/odb/src/odb.c @@ -4156,18 +4156,17 @@ static void sigcatch(int sig) exit ( EX_SIGNAL ); #else if ( tn == 1 ) { /* single threaded */ -tclean( 0 ); gclean(); -exit( EX_SIGNAL ); } else { for ( i = 0 ; i < tn ; i++ ) { -if ( !pthread_kill(thid[i], 0) ) { /* If this thread is alive... */ +if ( pthread_kill(thid[i], 0) ) { /* If this thread is alive... */ if ( pthread_cancel(thid[i]) ) /* ... cancel it */ fprintf(stderr, "odb [sigcatch(%d)] - Error canceling thread %d: [%d] %s\n", __LINE__, i, errno, strerror(errno) ); } } } +exit(EX_SIGNAL); #endif }
[2/3] incubator-trafodion git commit: original code is valid
original code is valid Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/7b295039 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/7b295039 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/7b295039 Branch: refs/heads/master Commit: 7b2950393bd81138c85f006a0bc82b20d0de6e95 Parents: 9f93e7d Author: SuJinpei <873118...@qq.com> Authored: Tue Oct 24 09:18:59 2017 +0800 Committer: SuJinpei <873118...@qq.com> Committed: Tue Oct 24 09:18:59 2017 +0800 -- core/conn/odb/src/odb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7b295039/core/conn/odb/src/odb.c -- diff --git a/core/conn/odb/src/odb.c b/core/conn/odb/src/odb.c index da88eec..e983be2 100755 --- a/core/conn/odb/src/odb.c +++ b/core/conn/odb/src/odb.c @@ -4159,7 +4159,7 @@ static void sigcatch(int sig) gclean(); } else { for ( i = 0 ; i < tn ; i++ ) { -if ( pthread_kill(thid[i], 0) ) { /* If this thread is alive... */ +if ( !pthread_kill(thid[i], 0) ) { /* If this thread is alive... */ if ( pthread_cancel(thid[i]) ) /* ... cancel it */ fprintf(stderr, "odb [sigcatch(%d)] - Error canceling thread %d: [%d] %s\n", __LINE__, i, errno, strerror(errno) );
[3/3] incubator-trafodion git commit: Merge [TRAFODION-2773] PR 1272 Fix odb hang when timeout is set
Merge [TRAFODION-2773] PR 1272 Fix odb hang when timeout is set Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9dd862c1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9dd862c1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9dd862c1 Branch: refs/heads/master Commit: 9dd862c1416def634ea9c071ff0dfa2dd046683a Parents: 9e5f36c 7b29503 Author: Dave Birdsall Authored: Thu Oct 26 18:33:13 2017 + Committer: Dave Birdsall Committed: Thu Oct 26 18:33:13 2017 + -- core/conn/odb/src/odb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9dd862c1/core/conn/odb/src/odb.c --
[1/2] incubator-trafodion git commit: fix TRAFODION-2714
Repository: incubator-trafodion Updated Branches: refs/heads/master 9dd862c14 -> af54ea41f fix TRAFODION-2714 Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/04c0c46e Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/04c0c46e Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/04c0c46e Branch: refs/heads/master Commit: 04c0c46ee79a832c7e653bbd1b83fcc920dffb8f Parents: 0f8c3e2 Author: SuJinpei <873118...@qq.com> Authored: Thu Oct 19 11:25:47 2017 +0800 Committer: SuJinpei <873118...@qq.com> Committed: Thu Oct 19 11:25:47 2017 +0800 -- core/conn/odb/src/odb.c | 102 +-- 1 file changed, 69 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04c0c46e/core/conn/odb/src/odb.c -- diff --git a/core/conn/odb/src/odb.c b/core/conn/odb/src/odb.c index 5d26c03..308edd1 100755 --- a/core/conn/odb/src/odb.c +++ b/core/conn/odb/src/odb.c @@ -39,7 +39,7 @@ char *odbauth = "Trafodion Dev "; #define TD_CHUNK32 /* Granularity of td[] memory allocation */ #define MAX_ARGS11 /* Max arguments for interactive mode */ #define ARG_LENGTH 128 /* Max argument length in interactive mode */ -#define LINE_CHUNK 512 /* size of memory chunks allocated to store lines */ +#define LINE_CHUNK 51200 /* size of memory chunks allocated to store lines */ #define MAX_VNLEN 32 /* Max variable name length */ #define MAX_PK_COLS 16 /* Max number of PK elements */ #define MAXCOL_LEN 128 /* Max table column name length */ @@ -6196,11 +6196,11 @@ static void Oload(int eid) 0100 = escape flag 0200 = embed file read */ ccl = 0, /* Continue cleaning to RS in the next buffer */ pstats = 0, /* Error flag: 0 = print stats, 1 = don't print stats */ - lfs = etab[eid].fs, /* local field separator */ - lrs = etab[eid].rs, /* local record separator */ - lsq = etab[eid].sq, /* local string qualifier */ - lem = etab[eid].em, /* local embed character */ - lec = etab[eid].ec; /* local escape character */ + lfs = etab[eid].fs, /* local field separator */ + lrs = etab[eid].rs, /* local record separator */ + lsq = etab[eid].sq ? etab[eid].sq : '"',/* local string qualifier, deafult is '"' */ + lem = etab[eid].em, /* local embed character */ + lec = etab[eid].ec; /* local escape character */ int *ldrs=0,/* pointer to array containing loaders EIDs */ *rmap=0;/* Input File Fields Map (reverse map): >=0 maps the correspoding Table Column Number @@ -6778,10 +6778,14 @@ static void Oload(int eid) map[j].max = (int) strtol ( bp, NULL, 10); } else { fg |= 0010; /* delimited format flag */ -map[j].idx = (int)strtol( bp, NULL, 10); +map[j].idx = (int)strtol( bp, NULL, 10) - 1; +if (map[j].idx < 0) { +fprintf(stderr, "odb [Oload(%d)] - Error: Field index should should start from 1\n", __LINE__); +goto oload_exit; +} } while ( *bp && *bp++ != ':' ); -if ( bp ) { +if ( *bp ) { if ( !strmicmp ( "substr", bp, 6 ) ) { map[j].op = 1; while ( *bp && *bp++ != ':' ); @@ -7301,13 +7305,13 @@ static void Oload(int eid) } nb += len; /* update bytes read from file */ p = 0; /* reset buffer index */ -while ( lts ) { /* skip initial lines */ -if ( buff[p++] == lrs ) { -lts-- ; +while (lts && p < len) {/* skip initial lines */ +if (buff[p++] == lrs) { +--lts; } } if ( ccl ) {/* continue cleaning rest of line */ -while ( p < etab[eid].buffsz && buff[p] != lrs )/* ... skip the rest of the line */ +whi
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2714] PR 1270 odb does not load data correctly
Merge [TRAFODION-2714] PR 1270 odb does not load data correctly Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/af54ea41 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/af54ea41 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/af54ea41 Branch: refs/heads/master Commit: af54ea41f35bea9ab8a5cd1d35dd344698ab1db6 Parents: 9dd862c 04c0c46 Author: Dave Birdsall Authored: Thu Oct 26 18:41:58 2017 + Committer: Dave Birdsall Committed: Thu Oct 26 18:41:58 2017 + -- core/conn/odb/src/odb.c | 102 +-- 1 file changed, 69 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/af54ea41/core/conn/odb/src/odb.c --
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2782] PR 1275 Reverse UDR classloader sequence
Merge [TRAFODION-2782] PR 1275 Reverse UDR classloader sequence Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/371cb711 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/371cb711 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/371cb711 Branch: refs/heads/master Commit: 371cb7110362c3f6d132d5c22d17a9cc083b64ad Parents: af54ea4 9d05287 Author: Dave Birdsall Authored: Thu Oct 26 19:11:22 2017 + Committer: Dave Birdsall Committed: Thu Oct 26 19:11:22 2017 + -- .../org/trafodion/sql/udr/LmClassLoader.java| 54 ++-- 1 file changed, 51 insertions(+), 3 deletions(-) --
[1/2] incubator-trafodion git commit: TRAFODION-2782 reserve UDRs classloader sequence
Repository: incubator-trafodion Updated Branches: refs/heads/master af54ea41f -> 371cb7110 TRAFODION-2782 reserve UDRs classloader sequence Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9d05287f Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9d05287f Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9d05287f Branch: refs/heads/master Commit: 9d05287fbe3025a90eb479bf0ceda2b6428c8471 Parents: ea24774 Author: mashengchen Authored: Tue Oct 24 05:54:24 2017 + Committer: mashengchen Committed: Tue Oct 24 05:54:24 2017 + -- .../org/trafodion/sql/udr/LmClassLoader.java| 54 ++-- 1 file changed, 51 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d05287f/core/sql/src/main/java/org/trafodion/sql/udr/LmClassLoader.java -- diff --git a/core/sql/src/main/java/org/trafodion/sql/udr/LmClassLoader.java b/core/sql/src/main/java/org/trafodion/sql/udr/LmClassLoader.java index 04ba64a..76102e6 100644 --- a/core/sql/src/main/java/org/trafodion/sql/udr/LmClassLoader.java +++ b/core/sql/src/main/java/org/trafodion/sql/udr/LmClassLoader.java @@ -63,10 +63,45 @@ import java.security.PrivilegedExceptionAction; * order * **/ -public class LmClassLoader extends URLClassLoader +public class LmClassLoader extends ClassLoader { private final static boolean DEBUG = false; // static DEBUG +private ChildURLClassLoader childClassLoader; + +private static class FindClassClassLoader extends ClassLoader { +public FindClassClassLoader(ClassLoader parent) { +super(parent); +} + +@Override +public Class findClass(String name) throws ClassNotFoundException { +return super.findClass(name); +} +} + +private static class ChildURLClassLoader extends URLClassLoader { +private FindClassClassLoader realParent; + + +public ChildURLClassLoader(URL[] urls, FindClassClassLoader realParent) { +super(urls, null); + +this.realParent = realParent; +} + +@Override +public Class findClass(String name) throws ClassNotFoundException { +try { +Class loaded = super.findLoadedClass(name); +if (loaded != null) +return loaded; +return super.findClass(name); +} catch (ClassNotFoundException e) { +return realParent.loadClass(name); +} +} +} /** * Creates a new instance for a given set of URLs. @@ -77,13 +112,15 @@ public class LmClassLoader extends URLClassLoader **/ public LmClassLoader(URL[] urls) { - super(urls); + //super(urls); + super(Thread.currentThread().getContextClassLoader()); + childClassLoader = new ChildURLClassLoader(urls, new FindClassClassLoader(this.getParent())); } String getContainerPath() { // The first URL points to the container. Get the path of that URL - return getURLs()[0].getPath(); + return childClassLoader.getURLs()[0].getPath(); } /** @@ -164,4 +201,15 @@ public class LmClassLoader extends URLClassLoader System.out.println("LmClassLoader::findResourceInternal did not find resource " + name + "in container " + path); return null; } +@Override +protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { +try { +Class result = childClassLoader.findClass(name); +if (resolve) +resolveClass(result); +return result; +} catch (ClassNotFoundException e) { +return super.loadClass(name, resolve); +} +} }