smiklosovic commented on code in PR #3562:
URL: https://github.com/apache/cassandra/pull/3562#discussion_r1778896551
##########
src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:
##########
@@ -703,6 +705,79 @@ private void validateCanDropCompactStorage()
}
}
+ public static class DropConstraint extends AlterTableStatement
+ {
+ final ColumnIdentifier constraintName;
+
+ DropConstraint(String keyspaceName, String tableName, boolean
ifTableExists, ColumnIdentifier constraintName)
+ {
+ super(keyspaceName, tableName, ifTableExists);
+ this.constraintName = constraintName;
+ }
+
+ @Override
+ public KeyspaceMetadata apply(Epoch epoch, KeyspaceMetadata keyspace,
TableMetadata table, ClusterMetadata metadata)
+ {
+ boolean removed = false;
+ TableMetadata.Builder tableBuilder = table.unbuild().epoch(epoch);
+ for(CqlConstraint constraint : tableBuilder.constraints())
+ {
+ if (constraint.constraintName == constraintName)
+ {
+ tableBuilder.removeConstraint(constraint);
+ removed = true;
Review Comment:
don't you need to `break`? If you found such constrain, you are done, you do
not need to iterate to the end.
##########
src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:
##########
@@ -703,6 +705,79 @@ private void validateCanDropCompactStorage()
}
}
+ public static class DropConstraint extends AlterTableStatement
+ {
+ final ColumnIdentifier constraintName;
+
+ DropConstraint(String keyspaceName, String tableName, boolean
ifTableExists, ColumnIdentifier constraintName)
+ {
+ super(keyspaceName, tableName, ifTableExists);
+ this.constraintName = constraintName;
+ }
+
+ @Override
+ public KeyspaceMetadata apply(Epoch epoch, KeyspaceMetadata keyspace,
TableMetadata table, ClusterMetadata metadata)
+ {
+ boolean removed = false;
+ TableMetadata.Builder tableBuilder = table.unbuild().epoch(epoch);
+ for(CqlConstraint constraint : tableBuilder.constraints())
+ {
+ if (constraint.constraintName == constraintName)
+ {
+ tableBuilder.removeConstraint(constraint);
+ removed = true;
Review Comment:
don't you need to `break`? If you found such constraint, you are done, you
do not need to iterate to the end.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]