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

    https://github.com/apache/tajo/pull/216#discussion_r19790604
  
    --- Diff: 
tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
 ---
    @@ -176,42 +202,47 @@ public Connection getConnection() {
         return conn;
       }
     
    -  private void verifySchemaVersion() throws CatalogException {
    +  private int getSchemaVersion() {
         Connection conn = null;
         PreparedStatement pstmt = null;
         ResultSet result = null;
    +    int schemaVersion = -1;
    +    
    +    String sql = "SELECT version FROM META";
    +    if (LOG.isDebugEnabled()) {
    +      LOG.debug(sql.toString());
    +    }
     
         try {
    -      String sql = "SELECT version FROM META";
    -      if (LOG.isDebugEnabled()) {
    -        LOG.debug(sql.toString());
    -      }
    -
           conn = getConnection();
           pstmt = conn.prepareStatement(sql);
           result = pstmt.executeQuery();
     
    -      boolean noVersion = !result.next();
    -
    -      int schemaVersion = result.getInt(1);
    -      if (noVersion || schemaVersion != getDriverVersion()) {
    -        LOG.error(String.format("Catalog version (%d) and current driver 
version (%d) are mismatch to each other",
    -            schemaVersion, getDriverVersion()));
    -        
LOG.error("=========================================================================");
    -        LOG.error("|                Catalog Store Migration Is Needed      
                |");
    -        
LOG.error("=========================================================================");
    -        LOG.error("| You might downgrade or upgrade Apache Tajo. 
Downgrading or upgrading  |");
    -        LOG.error("| Tajo without migration process is only available in 
some versions.    |");
    -        LOG.error("| In order to learn how to migration Apache Tajo 
instance,              |");
    -        LOG.error("| please refer http://s.apache.org/0_8_migration.       
                |");
    -        
LOG.error("=========================================================================");
    -        throw new CatalogException("Migration Needed. Please refer 
http://s.apache.org/0_8_migration.";);
    +      if (result.next()) {
    +        schemaVersion = result.getInt("VERSION");
           }
         } catch (SQLException e) {
    -      throw new CatalogException(e);
    +      throw new CatalogException(e.getMessage(), e);
         } finally {
           CatalogUtil.closeQuietly(pstmt, result);
         }
    +    
    +    return schemaVersion;
    +  }
    +
    +  private void verifySchemaVersion() throws CatalogException {
    +    int schemaVersion = -1;
    +
    +    schemaVersion = getSchemaVersion();
    +
    +    if (schemaVersion == -1 || schemaVersion != getDriverVersion()) {
    +      LOG.info(String.format("Catalog version (%d) and current driver 
version (%d) are mismatch to each other",
    +          schemaVersion, getDriverVersion()));
    +      LOG.info("It will start upgrade process on catalog stores.");
    +      
    +      catalogSchemaManager.upgradeBaseSchema(getConnection(), 
schemaVersion);
    --- End diff --
    
    Upgrade support is a nice approach. BTW, we have used ```tajo-dump``` for 
upgrading catalog stores. You can see the documentation of this feature at 
http://tajo.apache.org/docs/current/backup_and_restore/catalog.html.
    
    The main reason why Tajo uses ```tajo-dump``` approach is to mitigate the 
maintenance effort of schema changes between versions. With your approach, we 
need to maintain schema changes for each RDBMS catalog store. ```tajo_dump``` 
allows us to reuse the part of DDL statement execution in Tajo, and we just 
need to keep DDL DUMP code.
    
    Even through currently schemas for different RDBMSs are not much different 
to one another, the schemas will much differ as we optimize and specialize 
CatalogStore. Thus, the maintenance effort of schema changes between different 
versions would be costly.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to