You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by la...@apache.org on 2019/11/26 00:20:30 UTC

[phoenix] branch 4.x-HBase-1.5 updated: PHOENIX-5584 Older clients don't get correct view metadata when a 4.15 client creates a view.

This is an automated email from the ASF dual-hosted git repository.

larsh pushed a commit to branch 4.x-HBase-1.5
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.5 by this push:
     new 8828b98  PHOENIX-5584 Older clients don't get correct view metadata when a 4.15 client creates a view.
8828b98 is described below

commit 8828b98c75bb7c6df1fb2d287beb44815b0a9909
Author: Lars Hofhansl <la...@apache.org>
AuthorDate: Mon Nov 25 16:20:58 2019 -0800

    PHOENIX-5584 Older clients don't get correct view metadata when a 4.15 client creates a view.
---
 .../apache/phoenix/coprocessor/MetaDataEndpointImpl.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 9fc6020..21c0823 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -601,6 +601,14 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
             getCoprocessorHost().preGetTable(Bytes.toString(tenantId), SchemaUtil.getTableName(schemaName, tableName),
                     TableName.valueOf(table.getPhysicalName().getBytes()));
 
+            if (request.getClientVersion() < MIN_SPLITTABLE_SYSTEM_CATALOG
+                    && table.getType() == PTableType.VIEW
+                    && table.getViewType() != ViewType.MAPPED) {
+                try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)) {
+                    PTable pTable = PhoenixRuntime.getTableNoCache(connection, table.getParentName().getString());
+                    table = ViewUtil.addDerivedColumnsAndIndexesFromParent(connection, table, pTable);
+                }
+            }
             builder.setReturnCode(MetaDataProtos.MutationCode.TABLE_ALREADY_EXISTS);
             builder.setMutationTime(currentTime);
             if (blockWriteRebuildIndex) {
@@ -2806,14 +2814,13 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
     }
 
     /**
-     * Looks up the table locally if its present on this region, or else makes an rpc call
-     * to look up the region using PhoenixRuntime.getTable
+     * Looks up the table locally if its present on this region.
      */
     private PTable doGetTable(byte[] tenantId, byte[] schemaName, byte[] tableName,
                               long clientTimeStamp, RowLock rowLock, int clientVersion) throws IOException, SQLException {
         Region region = env.getRegion();
         final byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
-        // if this region doesn't contain the metadata rows look up the table by using PhoenixRuntime.getTable
+        // if this region doesn't contain the metadata rows then fail
         if (!region.getRegionInfo().containsRow(key)) {
             throw new SQLExceptionInfo.Builder(SQLExceptionCode.GET_TABLE_ERROR)
                     .setSchemaName(Bytes.toString(schemaName))