[ 
https://issues.apache.org/jira/browse/TRAFODION-2161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15425644#comment-15425644
 ] 

ASF GitHub Bot commented on TRAFODION-2161:
-------------------------------------------

Github user robertamarton commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/661#discussion_r75231316
  
    --- 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 --
    
    If there is a view defined on a REPOS table and the REPOS table is being 
dropped, would table UID be -1 at this time?  That is, we would not need to 
migrate the view.


> Metadata upgrade failed when there is user view on repository tables
> --------------------------------------------------------------------
>
>                 Key: TRAFODION-2161
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2161
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: sql-cmu
>         Environment: centos6.7 CDH5.4.8
> esgynDB R2.2 0811 daily build
>            Reporter: Gao, Rui-Xian
>            Assignee: David Wayne Birdsall
>
> [trafodion@centosqa-1 ~]$ sqlci
> EsgynDB Advanced Conversational Interface 2.2.0
> Copyright (c) 2015-2016 Esgyn Corporation
> >>get schemas;
>  
> *** ERROR[1395] Trafodion needs to be upgraded on this system due to metadata 
> version mismatch. Do 'initialize trafodion, upgrade' to upgrade metadata. Or 
> do 'initialize trafodion, drop' followed by 'initialize trafodion'. Be aware 
> that the second option will delete all metadata and user objects from 
> Trafodion database                       .
>  
> *** ERROR[8822] The statement was not prepared.
>  
> >>initialize trafodion, upgrade;
> Metadata Upgrade: started
>  
> Version Check: started
>   Metadata needs to be upgraded from Version 1.0.1 to 2.1.0.
>   Upgrade needed for Catalogs, Privileges, Repository.
> Version Check: done
>  
> Drop Old Metadata: started
> Drop Old Metadata: done
>  
> Backup Current Metadata: started
> Backup Current Metadata: done
>  
> Drop Current Metadata: started
> Drop Current Metadata: done
>  
> Initialize New Metadata: started
> Initialize New Metadata: done
>  
> Copy Old Metadata: started
> Copy Old Metadata: done
>  
> Validate Metadata Copy: started
> Validate Metadata Copy: done
>  
>  
> Delete Old Metadata Info: started
> Delete Old Metadata Info: done
>  
> Upgrade Repository: Started
>   Start: Drop Old Repository
>   End:   Drop Old Repository
>   Start: Rename Current Repository
> Upgrade Repository: Restoring Old Repository
> Start: Rename Old Repository back to New
> End: Rename Old Repository back to New
> Upgrade Repository: Restore done
>  
> Drop Old Metadata: started
> Drop Old Metadata: done
>  
> Metadata Upgrade: failed
>  
>  
> *** ERROR[1427] Table cannot be renamed. Reason: Operation not allowed if 
> dependent views exist. Drop the views and recreate them after rename.
>  
> *** ERROR[8839] Transaction was aborted.
>  
> --- SQL operation failed with errors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to