Repository: phoenix
Updated Branches:
  refs/heads/master cc3c952b3 -> 22c76a280


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/22c76a28
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/22c76a28
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/22c76a28

Branch: refs/heads/master
Commit: 22c76a2802bdb85ee29028b6016ae688e07ed351
Parents: cc3c952
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:06:07 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/22c76a28/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