swaroopak commented on a change in pull request #699: PHOENIX-5496 Ensure that 
we handle all server-side mutation codes on the client
URL: https://github.com/apache/phoenix/pull/699#discussion_r377398883
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
 ##########
 @@ -3074,23 +3068,36 @@ public boolean isViewReferenced() {
         }
     }
 
-    private void handleCreateTableMutationCode(MetaDataMutationResult result, 
MutationCode code,
+    @VisibleForTesting
+    public boolean handleCreateTableMutationCode(MetaDataMutationResult 
result, MutationCode code,
                  CreateTableStatement statement, String schemaName, String 
tableName,
                  PTable parent) throws SQLException {
         switch(code) {
+            case TABLE_ALREADY_EXISTS:
+                if(result.getTable() != null) {
+                    addTableToCache(result);
+                }
+                if(!statement.ifNotExists()) {
+                    throw new TableAlreadyExistsException(schemaName, 
tableName, result.getTable());
+                }
+                return true;
             case NEWER_TABLE_FOUND:
                 // Add table to ConnectionQueryServices so it's cached, but 
don't add
                 // it to this connection as we can't see it.
                 if (!statement.ifNotExists()) {
-                    throw new NewerTableAlreadyExistsException(schemaName, 
tableName, result.getTable());
+                    throw new NewerTableAlreadyExistsException(schemaName, 
tableName,
+                            result.getTable());
                 }
+                return false;
             case UNALLOWED_TABLE_MUTATION:
                 throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_MUTATE_TABLE)
                        
.setSchemaName(schemaName).setTableName(tableName).build().buildException();
             case CONCURRENT_TABLE_MUTATION:
                 addTableToCache(result);
                 throw new ConcurrentTableMutationException(schemaName, 
tableName);
             case AUTO_PARTITION_SEQUENCE_NOT_FOUND:
+                throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.AUTO_PARTITION_SEQUENCE_UNDEFINED)
 
 Review comment:
   also, why not use throwsSQLExceptionUtil method for this and other cases? If 
it is increasing the scope of your jira at least for the cases that are not 
added/modified in this PR,  could you please file a new Jira? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to