Github user robertamarton commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1721#discussion_r225014925
--- 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 ();
--- End diff --
deallocEHI? Probably in existing dropSeabaseLibrary2 code also.
---