Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.3 e99b738b6 -> e126dd1dd


PHOENIX-2566 Support NOT NULL constraint for any column for immutable table 
(addendum)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e126dd1d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e126dd1d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e126dd1d

Branch: refs/heads/4.x-HBase-1.3
Commit: e126dd1dda5aa80e8296d3b0c84736b22b658999
Parents: e99b738
Author: James Taylor <jtay...@salesforce.com>
Authored: Wed Feb 14 20:05:17 2018 -0800
Committer: James Taylor <jtay...@salesforce.com>
Committed: Wed Feb 14 20:05:17 2018 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/phoenix/schema/MetaDataClient.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e126dd1d/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 10ad199..81a09af 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -3189,7 +3189,6 @@ public class MetaDataClient {
                 }
 
                 int position = table.getColumns().size();
-                boolean isImmutableRows = table.isImmutableRows();
 
                 List<PColumn> currentPKs = table.getPKColumns();
                 PColumn lastPK = currentPKs.get(currentPKs.size()-1);
@@ -3207,6 +3206,8 @@ public class MetaDataClient {
 
                 MetaPropertiesEvaluated metaPropertiesEvaluated = new 
MetaPropertiesEvaluated();
                 changingPhoenixTableProperty = 
evaluateStmtProperties(metaProperties,metaPropertiesEvaluated,table,schemaName,tableName);
+                // If changing isImmutableRows to true or it's not being 
changed and is already true
+                boolean willBeImmutableRows = 
Boolean.TRUE.equals(metaPropertiesEvaluated.getIsImmutableRows()) || 
(metaPropertiesEvaluated.getIsImmutableRows() == null && 
table.isImmutableRows());
 
                 Long timeStamp = TransactionUtil.getTableTimestamp(connection, 
table.isTransactional() || metaProperties.getNonTxToTx());
                 int numPkColumnsAdded = 0;
@@ -3229,7 +3230,7 @@ public class MetaDataClient {
                                 if(colDef.isPK()) {
                                     throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.NOT_NULLABLE_COLUMN_IN_ROW_KEY)
                                     
.setColumnName(colDef.getColumnDefName().getColumnName()).build().buildException();
-                                } else if (!isImmutableRows) {
+                                } else if (!willBeImmutableRows) {
                                     throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.KEY_VALUE_NOT_NULL)
                                     
.setColumnName(colDef.getColumnDefName().getColumnName()).build().buildException();
                                 }
@@ -3274,7 +3275,7 @@ public class MetaDataClient {
                                 .setSchemaName(schemaName)
                                 
.setTableName(tableName).build().buildException();
                             }
-                            PColumn column = newColumn(position++, colDef, 
PrimaryKeyConstraint.EMPTY, table.getDefaultFamilyName() == null ? null : 
table.getDefaultFamilyName().getString(), true, columnQualifierBytes, 
isImmutableRows);
+                            PColumn column = newColumn(position++, colDef, 
PrimaryKeyConstraint.EMPTY, table.getDefaultFamilyName() == null ? null : 
table.getDefaultFamilyName().getString(), true, columnQualifierBytes, 
willBeImmutableRows);
                             columns.add(column);
                             String pkName = null;
                             Short keySeq = null;

Reply via email to