[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user sandhyasun commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225778436 --- Diff: core/sql/common/ComMisc.cpp --- @@ -357,3 +358,119 @@ NABoolean ComTrafReservedColName( return FALSE; } + + +Int32 ComGenerateUdrCachedLibName(NAString libname,Int64 redeftime, NAString schemaName, NAString userid, NAString &cachedLibName, NAString &cachedLibPath) +{ + NAString libPrefix, libSuffix; + struct stat statbuf; + NAString redefTimeString = Int64ToNAString(redeftime); + size_t lastDot = libname.last('.'); + if (lastDot != NA_NPOS) +{ + libSuffix = libname(lastDot,libname.length()-lastDot); + libPrefix = libname(0,lastDot); +} + + //when isolated user support is added + if (userid.length()!=0) +{ + + cachedLibPath = getenv("TRAF_HOME") ; + cachedLibPath += "/udr"; + if ( stat(cachedLibPath, &statbuf) != 0) + { + if (mkdir(cachedLibPath,S_IRWXU|S_IRWXG|S_IRWXO)) + { + return -1; + } + + } + cachedLibPath += "/"; + cachedLibPath += getenv("MY_UDR_CACHE_LIBDIR"); + if ( stat(cachedLibPath, &statbuf) != 0) + { + if (mkdir(cachedLibPath,S_IRWXU|S_IRWXG|S_IRWXO)) + { + return -1; + } + + } + cachedLibPath += "/"+ userid ; + if (stat(cachedLibPath, &statbuf) != 0) +{ + if (mkdir(cachedLibPath,S_IRUSR|S_IWUSR|S_IXUSR))//Only this user has +//permission to read/write/execute in this directory and below. +{ + return -1; +} + +} + cachedLibPath += "/" + schemaName; + if ( stat(cachedLibPath, &statbuf) != 0) + { + if (mkdir(cachedLibPath,S_IRWXU|S_IRWXG|S_IRWXO)) + { + return -1; --- End diff -- Good idea - added errno to the error message ---
[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user sandhyasun commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225742582 --- Diff: core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp --- @@ -563,32 +795,332 @@ void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode, processReturn(); return; } - -void CmpSeabaseDDL::alterSeabaseLibrary(StmtDDLAlterLibrary *alterLibraryNode, -NAString &currCatName, -NAString &currSchName) +void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode, + NAString &currCatName, + NAString &currSchName) { - Lng32 cliRC; - Lng32 retcode; - - NAString libraryName = alterLibraryNode->getLibraryName(); - NAString libFileName = alterLibraryNode->getFilename(); - - ComObjectName libName(libraryName, COM_TABLE_NAME); + Lng32 cliRC = 0; + Lng32 retcode = 0; + + BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/); + NARoutineDB *pRoutineDBCache = ActiveSchemaDB()->getNARoutineDB(); + const NAString &objName = dropLibraryNode->getLibraryName(); + + ComObjectName libraryName(objName); ComAnsiNamePart currCatAnsiName(currCatName); ComAnsiNamePart currSchAnsiName(currSchName); - libName.applyDefaults(currCatAnsiName, currSchAnsiName); - - NAString catalogNamePart = libName.getCatalogNamePartAsAnsiString(); - NAString schemaNamePart = libName.getSchemaNamePartAsAnsiString(TRUE); - NAString libNamePart = libName.getObjectNamePartAsAnsiString(TRUE); - const NAString extLibName = libName.getExternalName(TRUE); - - ExeCliInterface cliInterface(STMTHEAP, 0, NULL, - CmpCommon::context()->sqlSession()->getParentQid()); - + libraryName.applyDefaults(currCatAnsiName, currSchAnsiName); + + const NAString catalogNamePart = libraryName. +getCatalogNamePartAsAnsiString(); + const NAString schemaNamePart = libraryName. +getSchemaNamePartAsAnsiString(TRUE); + const NAString objectNamePart = libraryName. +getObjectNamePartAsAnsiString(TRUE); + const NAString extLibraryName = libraryName.getExternalName(TRUE); + + ExeCliInterface cliInterface(STMTHEAP, 0, NULL, +CmpCommon::context()->sqlSession()->getParentQid()); + + ExpHbaseInterface * ehi = allocEHI(); + if (ehi == NULL) +return; + retcode = existsInSeabaseMDTable(&cliInterface, - catalogNamePart, schemaNamePart, libNamePart, + catalogNamePart, schemaNamePart, + objectNamePart, + COM_LIBRARY_OBJECT, TRUE, FALSE); + if (retcode < 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + + if (retcode == 0) // does not exist +{ + *CmpCommon::diags() << DgSqlCode(-1389) + << DgString0(extLibraryName); + deallocEHI(ehi); + processReturn(); + return; +} + + Int32 objectOwnerID = 0; + Int32 schemaOwnerID = 0; + Int64 objectFlags = 0; + Int64 objUID = getObjectInfo(&cliInterface, + catalogNamePart.data(), schemaNamePart.data(), + objectNamePart.data(), COM_LIBRARY_OBJECT, + objectOwnerID,schemaOwnerID,objectFlags); + if (objUID < 0 || objectOwnerID == 0 || schemaOwnerID == 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + + if (!isDDLOperationAuthorized(SQLOperation::DROP_LIBRARY, +objectOwnerID, +schemaOwnerID)) + { + *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED); + processReturn (); + return; + } + + Queue * usingRoutinesQueue = NULL; + cliRC = getUsingRoutines(&cliInterface, objUID, usingRoutinesQueue); + if (cliRC < 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + // If RESTRICT and the library is being used, return an error + if (cliRC != 100 && dropLibraryNode->getDropBehavior() == COM_RESTRICT_DROP_BEHAVIOR) +{ + *CmpCommon::diags() << DgSqlCode(-CAT_DEPENDENT_ROUTINES_EXIST); + + deallocEHI(ehi); + processReturn(); + return; +} + + usingRoutinesQueue->position(); + for (size_t i = 0; i < usingRoutinesQueue->numEntries(); i++) + { + OutputInfo * rou = (OutputInfo*)usingRoutinesQueue->ge
[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user zellerh commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225738356 --- Diff: core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp --- @@ -563,32 +795,332 @@ void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode, processReturn(); return; } - -void CmpSeabaseDDL::alterSeabaseLibrary(StmtDDLAlterLibrary *alterLibraryNode, -NAString &currCatName, -NAString &currSchName) +void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode, + NAString &currCatName, + NAString &currSchName) { - Lng32 cliRC; - Lng32 retcode; - - NAString libraryName = alterLibraryNode->getLibraryName(); - NAString libFileName = alterLibraryNode->getFilename(); - - ComObjectName libName(libraryName, COM_TABLE_NAME); + Lng32 cliRC = 0; + Lng32 retcode = 0; + + BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/); + NARoutineDB *pRoutineDBCache = ActiveSchemaDB()->getNARoutineDB(); + const NAString &objName = dropLibraryNode->getLibraryName(); + + ComObjectName libraryName(objName); ComAnsiNamePart currCatAnsiName(currCatName); ComAnsiNamePart currSchAnsiName(currSchName); - libName.applyDefaults(currCatAnsiName, currSchAnsiName); - - NAString catalogNamePart = libName.getCatalogNamePartAsAnsiString(); - NAString schemaNamePart = libName.getSchemaNamePartAsAnsiString(TRUE); - NAString libNamePart = libName.getObjectNamePartAsAnsiString(TRUE); - const NAString extLibName = libName.getExternalName(TRUE); - - ExeCliInterface cliInterface(STMTHEAP, 0, NULL, - CmpCommon::context()->sqlSession()->getParentQid()); - + libraryName.applyDefaults(currCatAnsiName, currSchAnsiName); + + const NAString catalogNamePart = libraryName. +getCatalogNamePartAsAnsiString(); + const NAString schemaNamePart = libraryName. +getSchemaNamePartAsAnsiString(TRUE); + const NAString objectNamePart = libraryName. +getObjectNamePartAsAnsiString(TRUE); + const NAString extLibraryName = libraryName.getExternalName(TRUE); + + ExeCliInterface cliInterface(STMTHEAP, 0, NULL, +CmpCommon::context()->sqlSession()->getParentQid()); + + ExpHbaseInterface * ehi = allocEHI(); + if (ehi == NULL) +return; + retcode = existsInSeabaseMDTable(&cliInterface, - catalogNamePart, schemaNamePart, libNamePart, + catalogNamePart, schemaNamePart, + objectNamePart, + COM_LIBRARY_OBJECT, TRUE, FALSE); + if (retcode < 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + + if (retcode == 0) // does not exist +{ + *CmpCommon::diags() << DgSqlCode(-1389) + << DgString0(extLibraryName); + deallocEHI(ehi); + processReturn(); + return; +} + + Int32 objectOwnerID = 0; + Int32 schemaOwnerID = 0; + Int64 objectFlags = 0; + Int64 objUID = getObjectInfo(&cliInterface, + catalogNamePart.data(), schemaNamePart.data(), + objectNamePart.data(), COM_LIBRARY_OBJECT, + objectOwnerID,schemaOwnerID,objectFlags); + if (objUID < 0 || objectOwnerID == 0 || schemaOwnerID == 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + + if (!isDDLOperationAuthorized(SQLOperation::DROP_LIBRARY, +objectOwnerID, +schemaOwnerID)) + { + *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED); + processReturn (); + return; + } + + Queue * usingRoutinesQueue = NULL; + cliRC = getUsingRoutines(&cliInterface, objUID, usingRoutinesQueue); + if (cliRC < 0) +{ + deallocEHI(ehi); + processReturn(); + return; +} + // If RESTRICT and the library is being used, return an error + if (cliRC != 100 && dropLibraryNode->getDropBehavior() == COM_RESTRICT_DROP_BEHAVIOR) +{ + *CmpCommon::diags() << DgSqlCode(-CAT_DEPENDENT_ROUTINES_EXIST); + + deallocEHI(ehi); + processReturn(); + return; +} + + usingRoutinesQueue->position(); + for (size_t i = 0; i < usingRoutinesQueue->numEntries(); i++) + { + OutputInfo * rou = (OutputInfo*)usingRoutinesQueue->getNe
[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user zellerh commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225738019 --- Diff: core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp --- @@ -1925,3 +2730,568 @@ short CmpSeabaseDDL::createSeabaseLibmgrCPPLib(ExeCliInterface * cliInterface) } return 0; } + +short CmpSeabaseDDL::upgradeLibraries(ExeCliInterface * cliInterface, + CmpDDLwithStatusInfo *mdui) +{ +Lng32 cliRC = 0; + + while (1) // exit via return stmt in switch +{ + switch (mdui->subStep()) +{ +case 0: + { +mdui->setMsg("Upgrade Libraries: Started"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 1: + { +mdui->setMsg(" Start: Drop Old Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 2: + { +// drop old libraries +if (dropLibraries(cliInterface, TRUE/*old */)) + return -3; // error, but no recovery needed + +mdui->setMsg(" End: Drop Old Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 3: + { +mdui->setMsg(" Start: Rename Current Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 4: + { +// rename current libraries tables to *_OLD_LIBRARIES +if (alterRenameLibraries(cliInterface, TRUE)) + return -2; // error, need to undo the rename only + +mdui->setMsg(" End: Rename Current Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 5: + { +mdui->setMsg(" Start: Create New Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 6: + { +// create new libraries +if (createLibraries(cliInterface)) + return -1; // error, need to drop new libraies then undo rename + +mdui->setMsg(" End: Create New Libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 7: + { +mdui->setMsg(" Start: Copy Old Libraries Contents "); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 8: + { +// copy old contents into new + +if (copyOldLibrariesToNew(cliInterface)) + { +mdui->setMsg(" Copy Old Libraries failed ! Drop and recreate the following : "); +//return -1; // error, need to drop new libraries then undo rename + } + +mdui->setMsg(" End: Copy Old Libraries Contents "); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; + +case 9: + { +mdui->setMsg("Upgrade Libraries: Done except for cleaning up"); +mdui->setSubstep(0); +mdui->setEndStep(TRUE); + +return 0; + } + break; + +default: + return -1; +} +} // while + + return 0; +} + +short CmpSeabaseDDL::upgradeLibrariesComplete(ExeCliInterface * cliInterface, + CmpDDLwithStatusInfo *mdui) +{ + switch (mdui->subStep()) +{ +case 0: + { +mdui->setMsg("Upgrade Libraries: Drop old libraries"); +mdui->subStep()++; +mdui->setEndStep(FALSE); + +return 0; + } + break; +case 1: + { +// drop old libraries; ignore errors +dropLibraries(cliInterface, TR
[GitHub] trafodion pull request #1723: TRAFODION - 3218 User still has privilege afte...
Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1723#discussion_r225695077 --- Diff: core/sql/optimizer/NATable.cpp --- @@ -6805,46 +6809,94 @@ void NATable::getPrivileges(TrafDesc * priv_desc) ComSecurityKeySet secKeyVec(heap_); if (priv_desc == NULL) { -if (isHiveTable() || isHbaseCellTable() || -isHbaseRowTable() || isHbaseMapTable()) +if (!isSeabaseTable()) --- End diff -- The old code would return if this "if" were true, but the new code does not (because the return statement after the "else" was placed inside braces. Was this intentional? ---
[GitHub] trafodion pull request #1723: TRAFODION - 3218 User still has privilege afte...
Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1723#discussion_r225662018 --- Diff: core/sql/executor/ExExeUtilGet.cpp --- @@ -1665,10 +1665,10 @@ NABoolean ExExeUtilGetMetadataInfoTcb::checkUserPrivs( if (ComUser::isRootUserID()) return FALSE; - // any user granted the DB__ROOTROLE sees everything Int32 numRoles; Int32 *roleList; - if (currContext->getRoleList(numRoles, roleList) == SUCCESS) + Int32 *granteeList; --- End diff -- Who deletes the memory for the granteeList? (or the roleList for that matter) ---
[GitHub] trafodion pull request #1723: TRAFODION - 3218 User still has privilege afte...
Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1723#discussion_r225659935 --- Diff: core/sql/common/ComSecurityKey.cpp --- @@ -191,33 +216,41 @@ bool buildSecurityKeys( const int32_t userID, return false; } - // If the grantee is a role, generate a special security key - // If the role is revoked from the user, this key takes affect + // If the grantee is a role, generate special security keys, one for + // the user and one for each of the user's roles. + // If the role is revoked from the user these key takes affect if (PrivMgr::isRoleID(granteeID)) { -ComSecurityKey key (userID, granteeID, ComSecurityKey::SUBJECT_IS_USER); -if (doDebug) +char buf [200]; --- End diff -- This variable isn't used anywhere. Maybe we should delete it? ---
[GitHub] trafodion pull request #1723: TRAFODION - 3218 User still has privilege afte...
Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1723#discussion_r225658074 --- Diff: core/sql/cli/Context.cpp --- @@ -4199,19 +4219,35 @@ RETCODE ContextCli::setDatabaseUserByName(const char *userName) // * // * Function: ContextCli::getRoleList // * -// * Return the role IDs granted to the current user +// * Return the role IDs and their grantees for the current user. // * If the list of roles is already stored, just return this list. // * If the list of roles does not exist extract the roles granted to the // * current user from the Metadata and store in roleIDs_. // * // RETCODE ContextCli::getRoleList( - Int32 &numRoles, - Int32 *&roleIDs) + Int32 &numEntries, + Int32 *& roleIDs, + Int32 *& granteeIDs) { // If role list has not been created, go read metadata if (roleIDs_ == NULL) { +// If authorization is not enabled, just setup the PUBLIC role +CmpContext *cmpCntxt = CmpCommon::context(); +ex_assert(cmpCntxt, "No compiler context exists"); --- End diff -- The assert is fine, but unnecessary since we'd just core anyway on the very next statement when we dereference a null pointer. ---
[GitHub] trafodion pull request #1728: [TRAFODION-2626] Make logs directory location ...
GitHub user svarnau opened a pull request: https://github.com/apache/trafodion/pull/1728 [TRAFODION-2626] Make logs directory location configurable Makes path to log directory independent of TRAF_HOME. The default location is still $TRAF_HOME/logs. The DCS and REST log directories are now sub-directories of the main TRAF_LOG directory. Changes were pretty straight-forward, except the monitor stdout_* files. Someone familiar with foundation should have a look. Tested in local_hadoop environment, with TRAF_LOG set to alternate path and normal logs directory blocked. You can merge this pull request into a Git repository by running: $ git pull https://github.com/svarnau/trafodion j2626 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafodion/pull/1728.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1728 commit 2fc08c974766c40dc51b374f172490243cc1239f Author: Steve Varnau Date: 2018-10-16T21:58:01Z [TRAFODION-2626] Make logs directory location configurable Makes path to log directory independent of TRAF_HOME. The default location is still $TRAF_HOME/logs. The DCS and REST log directories are now sub-directories of the main TRAF_LOG directory. ---
[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user sandhyasun commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225719728 --- Diff: core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp --- @@ -1739,7 +1799,31 @@ short CmpSeabaseMDupgrade::executeSeabaseMDupgrade(CmpDDLwithStatusInfo *mdui, } } break; - + case OLD_LIBRARIES_DROP: + { +if (upgradeLibraries.needsUpgrade(this)) + { +if (upgradeLibraries.doDrops(&cliInterface,mdui,this)) + { +// no status message in this case so no return +cliInterface.clearGlobalDiags(); +mdui->setStep(OLD_REPOS_DROP); +mdui->setSubstep(0); +mdui->setEndStep(TRUE); --- End diff -- Yes all the drop steps ignore errors. ---
[GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Github user sandhyasun commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1721#discussion_r225719386 --- Diff: core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp --- @@ -1657,7 +1717,7 @@ short CmpSeabaseMDupgrade::executeSeabaseMDupgrade(CmpDDLwithStatusInfo *mdui, { *CmpCommon::diags() << DgSqlCode(-20123); - mdui->setStep(UPGRADE_FAILED_RESTORE_OLD_REPOS); + mdui->setStep(UPGRADE_FAILED_RESTORE_OLD_LIBRARIES); --- End diff -- We ar ein the phase of rewinding the upgrade. Unless the "needsUpgrade" flag is set, the restore steps wont do anything. So we are ok. We just need to start with last step and rewind but some of the in between steps may not do any rewinding. ---
[GitHub] trafodion pull request #1725: [TRAFODION-3221]Let jdbcT4 support ipv6 to con...
Github user asfgit closed the pull request at: https://github.com/apache/trafodion/pull/1725 ---
[GitHub] trafodion pull request #1724: [TRAFODION-3220] Executor GUI
Github user asfgit closed the pull request at: https://github.com/apache/trafodion/pull/1724 ---
[GitHub] trafodion pull request #1727: [TRAFODION-3222] Windows odbc build fail
GitHub user Weixin-Xu opened a pull request: https://github.com/apache/trafodion/pull/1727 [TRAFODION-3222] Windows odbc build fail 1. header file "cconnect.h" missed in "sqltocconv.h" 2. In README.txt, vs2013 is recommended to build windows odbc but now only the version is set vs2015 or higher. You can merge this pull request into a Git repository by running: $ git pull https://github.com/Weixin-Xu/incubator-trafodion odbc23build Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafodion/pull/1727.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1727 commit 3d132b80ffad3c38589e9e29eb093d5408c4f341 Author: Weixin-Xu <1013438133@...> Date: 2018-10-16T13:35:48Z Windows odbc build fail with missing header file and vs lower version ---
[GitHub] trafodion pull request #1726: [TRAFODION-3222] Windows odbc build fail
Github user Weixin-Xu closed the pull request at: https://github.com/apache/trafodion/pull/1726 ---