cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [11/16] cassandra git commit: Merge branch 'cassandra-3.0' into cassandra-3.11
Date Mon, 16 Jan 2017 09:51:09 GMT
Merge branch 'cassandra-3.0' into cassandra-3.11

* cassandra-3.0:
  Use timestamp from ClientState by default in AlterTableStatement
  Fix test interference in ColumnFamilyStoreTest


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

Branch: refs/heads/cassandra-3.X
Commit: 0b489776c63caeec2b63cd33d4b076d1048a651a
Parents: db2c50d 806ac77
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Jan 16 10:46:32 2017 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Jan 16 10:46:32 2017 +0100

----------------------------------------------------------------------
 .../cassandra/cql3/statements/AlterKeyspaceStatement.java    | 3 ++-
 .../cassandra/cql3/statements/AlterTableStatement.java       | 8 ++++----
 .../apache/cassandra/cql3/statements/AlterTypeStatement.java | 3 ++-
 .../apache/cassandra/cql3/statements/AlterViewStatement.java | 3 ++-
 .../cassandra/cql3/statements/CreateAggregateStatement.java  | 2 +-
 .../cassandra/cql3/statements/CreateFunctionStatement.java   | 2 +-
 .../cassandra/cql3/statements/CreateIndexStatement.java      | 3 ++-
 .../cassandra/cql3/statements/CreateKeyspaceStatement.java   | 2 +-
 .../cassandra/cql3/statements/CreateTableStatement.java      | 2 +-
 .../cassandra/cql3/statements/CreateTriggerStatement.java    | 3 ++-
 .../cassandra/cql3/statements/CreateTypeStatement.java       | 3 ++-
 .../cassandra/cql3/statements/CreateViewStatement.java       | 3 ++-
 .../cassandra/cql3/statements/DropAggregateStatement.java    | 3 ++-
 .../cassandra/cql3/statements/DropFunctionStatement.java     | 3 ++-
 .../apache/cassandra/cql3/statements/DropIndexStatement.java | 4 ++--
 .../cassandra/cql3/statements/DropKeyspaceStatement.java     | 3 ++-
 .../apache/cassandra/cql3/statements/DropTableStatement.java | 3 ++-
 .../cassandra/cql3/statements/DropTriggerStatement.java      | 3 ++-
 .../apache/cassandra/cql3/statements/DropTypeStatement.java  | 3 ++-
 .../apache/cassandra/cql3/statements/DropViewStatement.java  | 3 ++-
 .../cassandra/cql3/statements/SchemaAlteringStatement.java   | 6 +++---
 21 files changed, 41 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index 48666be,6210d16..5f3b2ff
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@@ -65,10 -71,12 +65,10 @@@ public class AlterTableStatement extend
      {
          super(name);
          this.oType = type;
 -        this.rawColumnName = columnName;
 -        this.validator = validator; // used only for ADD/ALTER commands
 +        this.colNameList = colDataList;
          this.attrs = attrs;
          this.renames = renames;
-         this.deleteTimestamp = deleteTimestamp == null ? FBUtilities.timestampMicros() :
deleteTimestamp;
 -        this.isStatic = isStatic;
+         this.deleteTimestamp = deleteTimestamp;
      }
  
      public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
@@@ -221,72 -218,66 +221,72 @@@
                  break;
  
              case DROP:
 -                assert columnName != null;
                  if (!cfm.isCQLTable())
                      throw new InvalidRequestException("Cannot drop columns from a non-CQL3
table");
 -                if (def == null)
 -                    throw new InvalidRequestException(String.format("Column %s was not found
in table %s", columnName, columnFamily()));
  
 -                switch (def.kind)
 +                for (AlterTableStatementColumn colData : colNameList)
                  {
 -                    case PARTITION_KEY:
 -                    case CLUSTERING:
 -                        throw new InvalidRequestException(String.format("Cannot drop PRIMARY
KEY part %s", columnName));
 -                    case REGULAR:
 -                    case STATIC:
 -                        ColumnDefinition toDelete = null;
 -                        for (ColumnDefinition columnDef : cfm.partitionColumns())
 -                        {
 -                            if (columnDef.name.equals(columnName))
 -                            {
 -                                toDelete = columnDef;
 -                                break;
 -                            }
 -                        }
 -                        assert toDelete != null;
 -                        cfm.removeColumnDefinition(toDelete);
 -                        cfm.recordColumnDrop(toDelete, deleteTimestamp == null ? queryState.getTimestamp()
: deleteTimestamp);
 -                        break;
 -                }
 +                    columnName = colData.getColumnName().getIdentifier(cfm);
 +                    def = cfm.getColumnDefinition(columnName);
  
 -                // If the dropped column is required by any secondary indexes
 -                // we reject the operation, as the indexes must be dropped first
 -                Indexes allIndexes = cfm.getIndexes();
 -                if (!allIndexes.isEmpty())
 -                {
 -                    ColumnFamilyStore store = Keyspace.openAndGetStore(cfm);
 -                    Set<IndexMetadata> dependentIndexes = store.indexManager.getDependentIndexes(def);
 -                    if (!dependentIndexes.isEmpty())
 -                        throw new InvalidRequestException(String.format("Cannot drop column
%s because it has " +
 -                                                                        "dependent secondary
indexes (%s)",
 -                                                                        def,
 -                                                                        dependentIndexes.stream()
 -                                                                                       
.map(i -> i.name)
 -                                                                                       
.collect(Collectors.joining(","))));
 -                }
 +                    if (def == null)
 +                        throw new InvalidRequestException(String.format("Column %s was not
found in table %s", columnName, columnFamily()));
  
 -                // If a column is dropped which is included in a view, we don't allow the
drop to take place.
 -                boolean rejectAlter = false;
 -                StringBuilder builder = new StringBuilder();
 -                for (ViewDefinition view : views)
 -                {
 -                    if (!view.includes(columnName)) continue;
 +                    switch (def.kind)
 +                    {
 +                         case PARTITION_KEY:
 +                         case CLUSTERING:
 +                              throw new InvalidRequestException(String.format("Cannot drop
PRIMARY KEY part %s", columnName));
 +                         case REGULAR:
 +                         case STATIC:
 +                              ColumnDefinition toDelete = null;
 +                              for (ColumnDefinition columnDef : cfm.partitionColumns())
 +                              {
 +                                   if (columnDef.name.equals(columnName))
 +                                   {
 +                                       toDelete = columnDef;
 +                                       break;
 +                                   }
 +                               }
 +                             assert toDelete != null;
 +                             cfm.removeColumnDefinition(toDelete);
-                              cfm.recordColumnDrop(toDelete, deleteTimestamp);
++                             cfm.recordColumnDrop(toDelete, deleteTimestamp  == null ? queryState.getTimestamp()
: deleteTimestamp);
 +                             break;
 +                    }
 +
 +                    // If the dropped column is required by any secondary indexes
 +                    // we reject the operation, as the indexes must be dropped first
 +                    Indexes allIndexes = cfm.getIndexes();
 +                    if (!allIndexes.isEmpty())
 +                    {
 +                        ColumnFamilyStore store = Keyspace.openAndGetStore(cfm);
 +                        Set<IndexMetadata> dependentIndexes = store.indexManager.getDependentIndexes(def);
 +                        if (!dependentIndexes.isEmpty())
 +                            throw new InvalidRequestException(String.format("Cannot drop
column %s because it has " +
 +                                                                            "dependent secondary
indexes (%s)",
 +                                                                            def,
 +                                                                            dependentIndexes.stream()
 +                                                                                       
    .map(i -> i.name)
 +                                                                                       
    .collect(Collectors.joining(","))));
 +                    }
 +
 +                    // If a column is dropped which is included in a view, we don't allow
the drop to take place.
 +                    boolean rejectAlter = false;
 +                    StringBuilder builder = new StringBuilder();
 +                    for (ViewDefinition view : views)
 +                    {
 +                        if (!view.includes(columnName)) continue;
 +                        if (rejectAlter)
 +                            builder.append(',');
 +                        rejectAlter = true;
 +                        builder.append(view.viewName);
 +                    }
                      if (rejectAlter)
 -                        builder.append(',');
 -                    rejectAlter = true;
 -                    builder.append(view.viewName);
 +                        throw new InvalidRequestException(String.format("Cannot drop column
%s, depended on by materialized views (%s.{%s})",
 +                                                                        columnName.toString(),
 +                                                                        keyspace(),
 +                                                                        builder.toString()));
                  }
 -                if (rejectAlter)
 -                    throw new InvalidRequestException(String.format("Cannot drop column
%s, depended on by materialized views (%s.{%s})",
 -                                                                    columnName.toString(),
 -                                                                    keyspace(),
 -                                                                    builder.toString()));
                  break;
              case OPTS:
                  if (attrs == null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
index 0b0b203,e7f8feb..ff9af75
--- a/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
@@@ -27,9 -27,10 +27,10 @@@ import org.apache.cassandra.db.marshal.
  import org.apache.cassandra.db.marshal.UserType;
  import org.apache.cassandra.exceptions.*;
  import org.apache.cassandra.schema.KeyspaceMetadata;
 +import org.apache.cassandra.schema.Types;
  import org.apache.cassandra.service.ClientState;
  import org.apache.cassandra.service.MigrationManager;
+ import org.apache.cassandra.service.QueryState;
  import org.apache.cassandra.transport.Event;
  
  public class CreateTypeStatement extends SchemaAlteringStatement
@@@ -114,10 -110,10 +115,10 @@@
          for (CQL3Type.Raw type : columnTypes)
              types.add(type.prepare(keyspace()).getType());
  
 -        return new UserType(name.getKeyspace(), name.getUserTypeName(), names, types);
 +        return new UserType(name.getKeyspace(), name.getUserTypeName(), columnNames, types,
true);
      }
  
-     public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException,
ConfigurationException
+     public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly)
throws InvalidRequestException, ConfigurationException
      {
          KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
          assert ksm != null; // should haven't validate otherwise

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
index 3cc0d97,708d551..668f791
--- a/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateViewStatement.java
@@@ -42,7 -41,9 +42,8 @@@ import org.apache.cassandra.exceptions.
  import org.apache.cassandra.exceptions.UnauthorizedException;
  import org.apache.cassandra.schema.TableParams;
  import org.apache.cassandra.service.ClientState;
 -import org.apache.cassandra.service.ClientWarn;
  import org.apache.cassandra.service.MigrationManager;
+ import org.apache.cassandra.service.QueryState;
  import org.apache.cassandra.thrift.ThriftValidation;
  import org.apache.cassandra.transport.Event;
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
index 70a86db,35aee3c..fcd06d4
--- a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
@@@ -64,9 -64,9 +64,9 @@@ public class DropIndexStatement extend
      }
  
      @Override
 -    public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
 +    public ResultMessage execute(QueryState state, QueryOptions options, long queryStartNanoTime)
throws RequestValidationException
      {
-         Event.SchemaChange ce = announceMigration(false);
+         Event.SchemaChange ce = announceMigration(state, false);
          return ce == null ? null : new ResultMessage.SchemaChange(ce);
      }
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/DropViewStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0b489776/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
index 139c566,62ba0ae..4a20451
--- a/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
@@@ -84,9 -84,9 +84,9 @@@ public abstract class SchemaAlteringSta
       *
       * @throws RequestValidationException
       */
-     public abstract Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException;
+     protected abstract Event.SchemaChange announceMigration(QueryState queryState, boolean
isLocalOnly) throws RequestValidationException;
  
 -    public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
 +    public ResultMessage execute(QueryState state, QueryOptions options, long queryStartNanoTime)
throws RequestValidationException
      {
          // If an IF [NOT] EXISTS clause was used, this may not result in an actual schema
change.  To avoid doing
          // extra work in the drivers to handle schema changes, we return an empty message
in this case. (CASSANDRA-7600)


Mime
View raw message