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

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

GitHub user DaveBirdsall opened a pull request:

    https://github.com/apache/incubator-trafodion/pull/661

    [TRAFODION-2161] Support migration of user views on Repository upgrade

    Today, users can create views that reference Repository tables. However, 
when they do so, "initialize trafodion, upgrade" fails because under the covers 
it does ALTER TABLE RENAME on old Repository tables and the latter does not 
support views.
    
    This change adds support for such views to "initialize trafodion, upgrade".
    
    The design is as follows:
    
    1. An internal-only option, "SKIP VIEW CHECK", has been added to ALTER 
TABLE RENAME. This causes any views on the object being renamed to be ignored; 
that is, they remain in the metadata, referring to the object by its old name. 
Note that if we abort the upgrade, we'll rename the old repository tables back 
to their original names (again using "SKIP VIEW CHECK"), so the views are then 
in their original state.
    
    2. When we determine that upgrade has progressed far enough that we will 
not turn back, we drop the views but replay their view text to create new views 
of the same name. If this succeeds, the view has been successfully migrated. 
But it might not succeed, for example if it depends on a column in the old 
repository table that has been dropped. In this case, we save the view text in 
the metadata TEXT table, with TEXT_TYPE = 9 and report that fact to the user. 
This gives the user a way to take that view text and modify it at their leisure 
after the upgrade has completed.
    
    While making these changes, I also noticed and fixed a bug in 
CmpSeabaseDDL::dropOneTableorView where the SQL parser flags global was not 
being handled correctly.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/DaveBirdsall/incubator-trafodion Trafodion2161

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-trafodion/pull/661.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 #661
    
----
commit 3b760a58636cc325093930466ac668d87e43619a
Author: Dave Birdsall <[email protected]>
Date:   2016-08-17T22:01:10Z

    [TRAFODION-2161] Support migration of user views on Repository upgrade

----


> 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