ChinmaySKulkarni commented on a change in pull request #541: PHOENIX-4893 Move 
parent column combining logic of view and view inde…
URL: https://github.com/apache/phoenix/pull/541#discussion_r305165018
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 ##########
 @@ -2898,35 +2381,65 @@ else if (tableType != PTableType.VIEW) {
                 EnvironmentEdgeManager.currentTimeMillis(), table, 
tableNamesToDelete, sharedTablesToDelete);
     }
 
-    private static interface ColumnMutator {
-        MetaDataMutationResult updateMutation(PTable table, byte[][] 
rowKeyMetaData,
-                List<Mutation> tableMetadata, Region region, 
List<ImmutableBytesPtr> invalidateList,
-                List<RowLock> locks, long clientTimeStamp) throws IOException, 
SQLException;
-    }
-
     private MetaDataMutationResult
-    mutateColumn(MutatateColumnType mutateColumnType, List<Mutation> 
tableMetadata, ColumnMutator mutator, int clientVersion) throws IOException {
+    mutateColumn(List<Mutation> tableMetadata, ColumnMutator mutator, int 
clientVersion, PTable parentTable)
+            throws IOException {
         byte[][] rowKeyMetaData = new byte[5][];
         MetaDataUtil.getTenantIdAndSchemaAndTableName(tableMetadata, 
rowKeyMetaData);
         byte[] tenantId = 
rowKeyMetaData[PhoenixDatabaseMetaData.TENANT_ID_INDEX];
         byte[] schemaName = 
rowKeyMetaData[PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX];
         byte[] tableName = 
rowKeyMetaData[PhoenixDatabaseMetaData.TABLE_NAME_INDEX];
         byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
         String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+        // server-side, except for indexing, we always expect the keyvalues to 
be standard KeyValues
+        PTableType expectedType = MetaDataUtil.getTableType(tableMetadata, 
GenericKeyValueBuilder.INSTANCE,
+                new ImmutableBytesWritable());
+        List<byte[]> tableNamesToDelete = Lists.newArrayList();
+        List<SharedTableState> sharedTablesToDelete = Lists.newArrayList();
+        List<PTable> childViews = Lists.newArrayList();
+        long clientTimeStamp = MetaDataUtil.getClientTimeStamp(tableMetadata);
         try {
             Region region = env.getRegion();
             MetaDataMutationResult result = checkTableKeyInRegion(key, region);
             if (result != null) {
                 return result;
             }
+
             List<RowLock> locks = Lists.newArrayList();
             try {
+                if (expectedType == PTableType.TABLE) {
+                    childViews = findAllChildViews(clientTimeStamp, tenantId, 
schemaName, tableName);
+
+                    if (!childViews.isEmpty()) {
+                        // From 4.15 onwards we allow SYSTEM.CATALOG to split 
and no longer propagate parent
+                        // metadata changes to child views.
+                        // If the client is on a version older than 4.15 we 
have to block adding a column to a
+                        // parent able as we no longer lock the parent table 
on the server side while creating a
+                        // child view to prevent conflicting changes. This is 
handled on the client side from
+                        // 4.15 onwards.
+                        // Also if 
QueryServices.ALLOW_SPLITTABLE_SYSTEM_CATALOG_ROLLBACK is true, we block adding
+                        // a column to a parent table so that we can rollback 
the upgrade if required.
+                        if (clientVersion < MIN_SPLITTABLE_SYSTEM_CATALOG) {
 
 Review comment:
   So an older client can no longer add any columns to a base table if that 
table has child views?

----------------------------------------------------------------
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