cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [8/9] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0
Date Fri, 27 Nov 2015 10:02:09 GMT
Merge branch 'cassandra-2.2' into cassandra-3.0


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

Branch: refs/heads/cassandra-3.1
Commit: d300a1850b4c9aa8b854f5fbc7921c8f9b2892b0
Parents: e8091d5 b3e6a43
Author: Robert Stupp <snazy@snazy.de>
Authored: Fri Nov 27 10:51:23 2015 +0100
Committer: Robert Stupp <snazy@snazy.de>
Committed: Fri Nov 27 10:55:02 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cql3/statements/DropAggregateStatement.java | 15 ++++----
 .../cql3/statements/DropFunctionStatement.java  | 27 +++++++++-----
 .../cql3/statements/DropTableStatement.java     |  2 ++
 .../cql3/statements/DropTypeStatement.java      | 10 ++++--
 .../org/apache/cassandra/cql3/ViewTest.java     | 10 ++++++
 .../cql3/validation/entities/TypeTest.java      | 10 ++++++
 .../cql3/validation/entities/UFTest.java        | 14 ++++++++
 .../validation/operations/AggregationTest.java  | 14 ++++++++
 .../cql3/validation/operations/DropTest.java    | 37 ++++++++++++++++++++
 10 files changed, 123 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d300a185/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index bc183fc,c2940cc..5e6c03c
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -17,7 -5,16 +17,8 @@@ Merged from 2.2
   * Fix SimpleDateType type compatibility (CASSANDRA-10027)
   * (Hadoop) fix splits calculation (CASSANDRA-10640)
   * (Hadoop) ensure that Cluster instances are always closed (CASSANDRA-10058)
 - * (cqlsh) show partial trace if incomplete after max_trace_wait (CASSANDRA-7645)
 - * Use most up-to-date version of schema for system tables (CASSANDRA-10652)
 - * Deprecate memory_allocator in cassandra.yaml (CASSANDRA-10581,10628)
 - * Expose phi values from failure detector via JMX and tweak debug
 -   and trace logging (CASSANDRA-9526)
 - * Fix RangeNamesQueryPager (CASSANDRA-10509)
 - * Deprecate Pig support (CASSANDRA-10542)
 - * Reduce contention getting instances of CompositeType (CASSANDRA-10433)
  Merged from 2.1:
+  * Some DROP ... IF EXISTS incorrectly result in exceptions on non-existing KS (CASSANDRA-10658)
   * DeletionTime.compareTo wrong in rare cases (CASSANDRA-10749)
   * Force encoding when computing statement ids (CASSANDRA-10755)
   * Properly reject counters as map keys (CASSANDRA-10760)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d300a185/src/java/org/apache/cassandra/cql3/statements/DropAggregateStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/DropAggregateStatement.java
index bef9e74,2d5ea70..2b1432b
--- a/src/java/org/apache/cassandra/cql3/statements/DropAggregateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropAggregateStatement.java
@@@ -88,14 -94,14 +88,17 @@@ public final class DropAggregateStateme
                                                              "'DESCRIBE AGGREGATE %s' command
to find all overloads",
                                                              functionName, functionName,
functionName));
  
--        List<AbstractType<?>> argTypes = new ArrayList<>(argRawTypes.size());
--        for (CQL3Type.Raw rawType : argRawTypes)
--            argTypes.add(prepareType("arguments", rawType));
--
--        Function old;
++        Function old = null;
          if (argsPresent)
          {
-             old = Schema.instance.findFunction(functionName, argTypes).orElse(null);
 -            old = Functions.find(functionName, argTypes);
++            if (Schema.instance.getKSMetaData(functionName.keyspace) != null)
++            {
++                List<AbstractType<?>> argTypes = new ArrayList<>(argRawTypes.size());
++                for (CQL3Type.Raw rawType : argRawTypes)
++                    argTypes.add(prepareType("arguments", rawType));
++
++                old = Schema.instance.findFunction(functionName, argTypes).orElse(null);
++            }
              if (old == null || !(old instanceof AggregateFunction))
              {
                  if (ifExists)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d300a185/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
index 3cef2da,edd8a65..6f11f9c
--- a/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
@@@ -64,19 -62,19 +64,23 @@@ public final class DropFunctionStatemen
      @Override
      public Prepared prepare() throws InvalidRequestException
      {
--        argTypes = new ArrayList<>(argRawTypes.size());
--        for (CQL3Type.Raw rawType : argRawTypes)
++        if (Schema.instance.getKSMetaData(functionName.keyspace) != null)
          {
--            if (rawType.isFrozen())
--                throw new InvalidRequestException("The function arguments should not be
frozen; remove the frozen<> modifier");
++            argTypes = new ArrayList<>(argRawTypes.size());
++            for (CQL3Type.Raw rawType : argRawTypes)
++            {
++                if (rawType.isFrozen())
++                    throw new InvalidRequestException("The function arguments should not
be frozen; remove the frozen<> modifier");
  
--            // UDT are not supported non frozen but we do not allow the frozen keyword for
argument. So for the moment we
--            // freeze them here
--            if (!rawType.canBeNonFrozen())
--                rawType.freeze();
++                // UDT are not supported non frozen but we do not allow the frozen keyword
for argument. So for the moment we
++                // freeze them here
++                if (!rawType.canBeNonFrozen())
++                    rawType.freeze();
  
--            argTypes.add(rawType.prepare(functionName.keyspace).getType());
++                argTypes.add(rawType.prepare(functionName.keyspace).getType());
++            }
          }
++
          return super.prepare();
      }
  
@@@ -161,7 -175,7 +165,12 @@@
          Function old;
          if (argsPresent)
          {
 -            old = Functions.find(functionName, argTypes);
++            if (argTypes == null)
++            {
++                return null;
++            }
++
 +            old = Schema.instance.findFunction(functionName, argTypes).orElse(null);
              if (old == null || !(old instanceof ScalarFunction))
              {
                  return null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d300a185/src/java/org/apache/cassandra/cql3/statements/DropTableStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/DropTableStatement.java
index 79c46f5,e690c3e..8e18cad
--- a/src/java/org/apache/cassandra/cql3/statements/DropTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropTableStatement.java
@@@ -62,34 -58,8 +62,36 @@@ public class DropTableStatement extend
      {
          try
          {
 +            KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace());
++            if (ksm == null)
++                throw new ConfigurationException(String.format("Cannot drop table in unknown
keyspace '%s'", keyspace()));
 +            CFMetaData cfm = ksm.getTableOrViewNullable(columnFamily());
 +            if (cfm != null)
 +            {
 +                if (cfm.isView())
 +                    throw new InvalidRequestException("Cannot use DROP TABLE on Materialized
View");
 +
 +                boolean rejectDrop = false;
 +                StringBuilder messageBuilder = new StringBuilder();
 +                for (ViewDefinition def : ksm.views)
 +                {
 +                    if (def.baseTableId.equals(cfm.cfId))
 +                    {
 +                        if (rejectDrop)
 +                            messageBuilder.append(',');
 +                        rejectDrop = true;
 +                        messageBuilder.append(def.viewName);
 +                    }
 +                }
 +                if (rejectDrop)
 +                {
 +                    throw new InvalidRequestException(String.format("Cannot drop table when
materialized views still depend on it (%s.{%s})",
 +                                                                    keyspace(),
 +                                                                    messageBuilder.toString()));
 +                }
 +            }
              MigrationManager.announceColumnFamilyDrop(keyspace(), columnFamily(), isLocalOnly);
 -            return true;
 +            return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.TABLE,
keyspace(), columnFamily());
          }
          catch (ConfigurationException e)
          {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d300a185/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
index 58abde9,6993ea3..6db47ca
--- a/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
@@@ -54,11 -54,17 +54,16 @@@ public class DropTypeStatement extends 
  
      public void validate(ClientState state) throws RequestValidationException
      {
 -        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
 +        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
          if (ksm == null)
-             throw new InvalidRequestException(String.format("Cannot drop type in unknown
keyspace %s", name.getKeyspace()));
+         {
+             if (ifExists)
+                 return;
+             else
+                 throw new InvalidRequestException(String.format("Cannot drop type in unknown
keyspace %s", name.getKeyspace()));
+         }
  
 -        UserType old = ksm.userTypes.getType(name.getUserTypeName());
 -        if (old == null)
 +        if (!ksm.types.get(name.getUserTypeName()).isPresent())
          {
              if (ifExists)
                  return;
@@@ -130,17 -153,18 +135,18 @@@
          return name.getKeyspace();
      }
  
 -    public boolean announceMigration(boolean isLocalOnly) throws InvalidRequestException,
ConfigurationException
 +    public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException,
ConfigurationException
      {
 -        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
 +        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
-         assert ksm != null;
+         if (ksm == null)
 -            return false; // do not assert (otherwise IF EXISTS case fails)
++            return null; // do not assert (otherwise IF EXISTS case fails)
  
 -        UserType toDrop = ksm.userTypes.getType(name.getUserTypeName());
 +        UserType toDrop = ksm.types.getNullable(name.getUserTypeName());
          // Can be null with ifExists
          if (toDrop == null)
 -            return false;
 +            return null;
  
          MigrationManager.announceTypeDrop(toDrop, isLocalOnly);
 -        return true;
 +        return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.TYPE,
keyspace(), name.getStringTypeName());
      }
  }


Mime
View raw message