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

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


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

commit 5f7acf46bf01e8e1e714c6a7556d794cc9c4c7cf
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))

Reply via email to