http://git-wip-us.apache.org/repos/asf/cassandra/blob/206a7bba/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
index 7a23231,ceb81be..70f7590
--- a/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnIdentifier.java
@@@ -218,11 -232,139 +218,11 @@@ public class ColumnIdentifier implement
          return ByteBufferUtil.compareUnsigned(this.bytes, that.bytes);
      }
  
 -    /**
 -     * Because Thrift-created tables may have a non-text comparator, we 
cannot determine the proper 'key' until
 -     * we know the comparator. ColumnIdentifier.Raw is a placeholder that can 
be converted to a real ColumnIdentifier
 -     * once the comparator is known with prepare(). This should only be used 
with identifiers that are actual
 -     * column names. See CASSANDRA-8178 for more background.
 -     */
 -    public static interface Raw extends Selectable.Raw
 -    {
 -
 -        public ColumnIdentifier prepare(CFMetaData cfm);
 -
 -        /**
 -         * Returns a string representation of the identifier that is safe to 
use directly in CQL queries.
 -         * In necessary, the string will be double-quoted, and any quotes 
inside the string will be escaped.
 -         */
 -        public String toCQLString();
 -    }
 -
 -    public static class Literal implements Raw
 -    {
 -        private final String rawText;
 -        private final String text;
 -
 -        public Literal(String rawText, boolean keepCase)
 -        {
 -            this.rawText = rawText;
 -            this.text =  keepCase ? rawText : rawText.toLowerCase(Locale.US);
 -        }
 -
 -        public ColumnIdentifier prepare(CFMetaData cfm)
 -        {
 -            if (!cfm.isStaticCompactTable())
 -                return getInterned(text, true);
 -
 -            AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
 -            if (thriftColumnNameType instanceof UTF8Type)
 -                return getInterned(text, true);
 -
 -            // We have a Thrift-created table with a non-text comparator. 
Check if we have a match column, otherwise assume we should use
 -            // thriftColumnNameType
 -            ByteBuffer bufferName = ByteBufferUtil.bytes(text);
 -            for (ColumnDefinition def : cfm.allColumns())
 -            {
 -                if (def.name.bytes.equals(bufferName))
 -                    return def.name;
 -            }
 -            return getInterned(thriftColumnNameType, 
thriftColumnNameType.fromString(rawText), text);
 -        }
 -
 -        public boolean processesSelection()
 -        {
 -            return false;
 -        }
 -
 -        @Override
 -        public final int hashCode()
 -        {
 -            return text.hashCode();
 -        }
 -
 -        @Override
 -        public final boolean equals(Object o)
 -        {
 -            if(!(o instanceof Literal))
 -                return false;
 -
 -            Literal that = (Literal) o;
 -            return text.equals(that.text);
 -        }
 -
 -        @Override
 -        public String toString()
 -        {
 -            return text;
 -        }
 -
 -        public String toCQLString()
 -        {
 -            return maybeQuote(text);
 -        }
 -    }
 -
 -    public static class ColumnIdentifierValue implements Raw
 -    {
 -        private final ColumnIdentifier identifier;
 -
 -        public ColumnIdentifierValue(ColumnIdentifier identifier)
 -        {
 -            this.identifier = identifier;
 -        }
 -
 -        public ColumnIdentifier prepare(CFMetaData cfm)
 -        {
 -            return identifier;
 -        }
 -
 -        public boolean processesSelection()
 -        {
 -            return false;
 -        }
 -
 -        @Override
 -        public final int hashCode()
 -        {
 -            return identifier.hashCode();
 -        }
 -
 -        @Override
 -        public final boolean equals(Object o)
 -        {
 -            if(!(o instanceof ColumnIdentifierValue))
 -                return false;
 -            ColumnIdentifierValue that = (ColumnIdentifierValue) o;
 -            return identifier.equals(that.identifier);
 -        }
 -
 -        @Override
 -        public String toString()
 -        {
 -            return identifier.toString();
 -        }
 -
 -        public String toCQLString()
 -        {
 -            return maybeQuote(identifier.text);
 -        }
 -    }
 -
 +    @VisibleForTesting
      public static String maybeQuote(String text)
      {
-         if (UNQUOTED_IDENTIFIER.matcher(text).matches())
+         if (UNQUOTED_IDENTIFIER.matcher(text).matches() && 
!ReservedKeywords.isReserved(text))
              return text;
 -
 -        return '"' + 
PATTERN_DOUBLE_QUOTE.matcher(text).replaceAll(Matcher.quoteReplacement("\"\"")) 
+ '"';
 +        return '"' + 
PATTERN_DOUBLE_QUOTE.matcher(text).replaceAll(ESCAPED_DOUBLE_QUOTE) + '"';
      }
  }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/206a7bba/test/unit/org/apache/cassandra/cql3/ViewTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/206a7bba/test/unit/org/apache/cassandra/db/ColumnFamilyStoreCQLHelperTest.java
----------------------------------------------------------------------

Reply via email to