This is an automated email from the ASF dual-hosted git repository. larsh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new f3f722e PHOENIX-5533 Creating a view or index with a 4.14 client and 4.15.0 server fails with a NullPointerException. f3f722e is described below commit f3f722e4f29293885f1854cca9dd4cd37e6ff085 Author: Lars Hofhansl <la...@apache.org> AuthorDate: Thu Oct 24 08:47:44 2019 -0700 PHOENIX-5533 Creating a view or index with a 4.14 client and 4.15.0 server fails with a NullPointerException. --- .../phoenix/coprocessor/MetaDataEndpointImpl.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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 8c80cd3..312602b 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 @@ -1735,6 +1735,45 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr byte[][] parentPhysicalSchemaTableNames = new byte[3][]; getParentAndPhysicalNames(tableMetadata, parentSchemaTableNames, parentPhysicalSchemaTableNames); if (parentPhysicalSchemaTableNames[2] != null) { + if (parentTable == null) { + // This is needed when we connect with a 4.14 client to + // a 4.15.0+ server. + // In that case we need to resolve the parent table on + // the server. + parentTable = doGetTable(ByteUtil.EMPTY_BYTE_ARRAY, + parentPhysicalSchemaTableNames[1], + parentPhysicalSchemaTableNames[2], clientTimeStamp, clientVersion); + if (parentTable == null) { + builder.setReturnCode( + MetaDataProtos.MutationCode.PARENT_TABLE_NOT_FOUND); + builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis()); + done.run(builder.build()); + return; + } + if (parentSchemaTableNames[2] != null + && Bytes.compareTo(parentSchemaTableNames[2], + parentPhysicalSchemaTableNames[2]) != 0) { + // if view is created on view + byte[] tenantId = parentSchemaTableNames[0] == null + ? ByteUtil.EMPTY_BYTE_ARRAY + : parentSchemaTableNames[0]; + parentTable = doGetTable(tenantId, parentSchemaTableNames[1], + parentSchemaTableNames[2], clientTimeStamp, clientVersion); + if (parentTable == null) { + // it could be a global view + parentTable = doGetTable(ByteUtil.EMPTY_BYTE_ARRAY, + parentSchemaTableNames[1], parentSchemaTableNames[2], + clientTimeStamp, clientVersion); + } + } + if (parentTable == null) { + builder.setReturnCode( + MetaDataProtos.MutationCode.PARENT_TABLE_NOT_FOUND); + builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis()); + done.run(builder.build()); + return; + } + } parentTableKey = SchemaUtil.getTableKey(ByteUtil.EMPTY_BYTE_ARRAY, parentPhysicalSchemaTableNames[1], parentPhysicalSchemaTableNames[2]); cParentPhysicalName = parentTable.getPhysicalName().getBytes(); @@ -1757,6 +1796,13 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr */ parentTableName = MetaDataUtil.getParentTableName(tableMetadata); parentTableKey = SchemaUtil.getTableKey(tenantIdBytes, parentSchemaName, parentTableName); + if (parentTable == null) { + // This is needed when we connect with a 4.14 client to a 4.15.0+ server. + // In that case we need to resolve the parent table on the server. + parentTable = + doGetTable(tenantIdBytes, parentSchemaName, parentTableName, clientTimeStamp, null, + request.getClientVersion()); + } if (IndexType.LOCAL == indexType) { cPhysicalName = parentTable.getPhysicalName().getBytes(); cParentPhysicalName = parentTable.getPhysicalName().getBytes();