trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #661: [TRAFODION-2161] Support migration of...
Date Thu, 18 Aug 2016 00:58:44 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/661#discussion_r75234079
  
    --- Diff: core/sql/sqlcomp/CmpSeabaseDDLrepos.cpp ---
    @@ -358,6 +358,75 @@ short CmpSeabaseDDL::copyOldReposToNew(ExeCliInterface * cliInterface)
       return 0;
     }
     
    +short CmpSeabaseDDL::migrateReposViews(ExeCliInterface * cliInterface,
    +                                       NABoolean & someViewSaved /* out */)
    +{
    +  short retcode = 0;  // assume success
    +  someViewSaved = FALSE;
    +
    +  // for each table that has been migrated, save and drop any views
    +  // on the old table, and attempt to recreate them on the new
    +
    +  for (Int32 i = 0; i < sizeof(allReposUpgradeInfo)/sizeof(MDUpgradeInfo); i++)
    +    {
    +      const MDUpgradeInfo &rti = allReposUpgradeInfo[i];
    +
    +      if ((! rti.newName) || (! rti.oldName) || (NOT rti.upgradeNeeded))
    +        continue;
    +
    +      Int64 tableUID = getObjectUID(cliInterface,
    +        getSystemCatalog(), SEABASE_REPOS_SCHEMA, rti.oldName,
    +        COM_BASE_TABLE_OBJECT_LIT, NULL, NULL, FALSE, FALSE /* ignore error */);
    +
    +      if (tableUID != -1)  // if we got it
    +        {
    +          NAList<NAString> viewNameList;
    +          NAList<NAString> viewDefnList;
    + 
    +          short retcode1 = 
    +             saveAndDropUsingViews(tableUID, cliInterface,
    +                                   viewNameList /* out */,viewDefnList /* out */);
    +          if (retcode1)
    +            retcode = -1;  // couldn't get views for old repository table
    +          else if (viewDefnList.entries() > 0)  // if there are views to migrate
    +            {
    +              Lng32 firstBadOne = -1;
    +              retcode1 = recreateUsingViews(cliInterface, viewNameList, viewDefnList,
    +                                            TRUE, &firstBadOne);
    +              if (retcode1)
    +                {
    +                  retcode = -1; 
    +                  Lng32 objUID = -2;  // use a fake objectUID since there is no object
    +                  
    +                  // For any view that could not be migrated, put its definition text
    +                  // back in the TEXT table so the user can deal with it later. We
    +                  // use a distinctive TEXT_TYPE for this purpose. We have to "make up"
    +                  
    +                  NABoolean xnWasStartedHere = FALSE;
    +                  if (beginXnIfNotInProgress(cliInterface, xnWasStartedHere))
    +                    retcode = -1;
    +                  else
    +                    {                    
    +                      for (Lng32 i = firstBadOne; i < viewDefnList.entries(); i++)
    +                        {                      
    +                          updateTextTable(cliInterface, objUID, COM_BAD_VIEW_TEXT,
    +                                          0, viewDefnList[i], NULL, 0, TRUE);
    +                          objUID--;  // get another fake object UID
    +
    +                          someViewSaved = TRUE; 
    +                        }
    +                      endXnIfStartedHere(cliInterface, xnWasStartedHere, 0);
    +                    }                 
    +                }                  
    +            }
    +        }
    +      else
    +        retcode = -1;  // couldn't get objectUID for old repository table
    --- End diff --
    
    Yes, the test at line 374 handles that case. There would be no rti.newName causing us
to skip the migration logic for that table. Later, when the table is dropped, the code does
a CASCADE so the view disappears.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message