Merge branch 'cassandra-3.0' into cassandra-3.11

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

Branch: refs/heads/cassandra-3.11
Commit: 6d429cd0315d3509c904d0e83f91f7d12ba12085
Parents: c8a3b58 6c29ee8
Author: Alex Petrov <oleksandr.pet...@gmail.com>
Authored: Mon Nov 6 15:52:31 2017 +0100
Committer: Alex Petrov <oleksandr.pet...@gmail.com>
Committed: Mon Nov 6 15:52:31 2017 +0100

----------------------------------------------------------------------
 NEWS.txt                                        |  20 +
 bin/cqlsh.py                                    |   7 +-
 doc/native_protocol_v4.spec                     |   4 +
 doc/source/cql/appendices.rst                   |  22 +
 ...dra-driver-internal-only-3.11.0-bb96859b.zip | Bin 0 -> 266661 bytes
 src/antlr/Lexer.g                               |   4 +
 src/antlr/Parser.g                              |  41 +-
 .../cassandra/auth/CassandraRoleManager.java    |   3 +-
 .../org/apache/cassandra/config/CFMetaData.java |  59 ++-
 .../apache/cassandra/cql3/QueryProcessor.java   |   2 +-
 .../cql3/statements/AlterTableStatement.java    |  26 +-
 .../statements/AuthenticationStatement.java     |   2 +-
 .../cql3/statements/AuthorizationStatement.java |   2 +-
 .../cql3/statements/BatchStatement.java         |   4 +-
 .../statements/CreateAggregateStatement.java    |   4 +-
 .../statements/CreateFunctionStatement.java     |   4 +-
 .../cql3/statements/CreateIndexStatement.java   |   9 +-
 .../cql3/statements/CreateTableStatement.java   |   2 +-
 .../cql3/statements/CreateViewStatement.java    |   2 +-
 .../cql3/statements/DropFunctionStatement.java  |   4 +-
 .../cql3/statements/ModificationStatement.java  |  12 +-
 .../cql3/statements/ParsedStatement.java        |   3 +-
 .../statements/SchemaAlteringStatement.java     |  32 +-
 .../cql3/statements/SelectStatement.java        |   8 +-
 .../cql3/statements/TruncateStatement.java      |   2 +-
 .../cassandra/cql3/statements/UseStatement.java |   2 +-
 src/java/org/apache/cassandra/db/view/View.java |  31 +-
 .../index/internal/keys/KeysSearcher.java       |   8 +-
 .../cassandra/io/sstable/CQLSSTableWriter.java  |   2 +-
 .../apache/cassandra/repair/RepairRunnable.java |   3 +-
 .../apache/cassandra/service/ClientState.java   |  16 +
 .../cassandra/thrift/ThriftValidation.java      |  10 +-
 .../transport/messages/StartupMessage.java      |   4 +
 .../org/apache/cassandra/cql3/ViewTest.java     |  16 +-
 .../cql3/validation/entities/UFTest.java        |  25 +
 .../cql3/validation/entities/UserTypesTest.java |  20 +
 .../cql3/validation/operations/AlterTest.java   |   8 +
 .../DropCompactStorageThriftTest.java           | 525 +++++++++++++++++++
 .../cassandra/index/sasi/SASIIndexTest.java     |   3 +-
 .../io/sstable/StressCQLSSTableWriter.java      |   2 +-
 40 files changed, 876 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d429cd0/NEWS.txt
----------------------------------------------------------------------
diff --cc NEWS.txt
index f8dd93b,621866b..9812b22
--- a/NEWS.txt
+++ b/NEWS.txt
@@@ -33,16 -34,28 +33,36 @@@ Materialized View
  
  Upgrading
  ---------
 -   - Nothing specific to this release, but please see previous upgrading 
sections,
 -     especially if you are upgrading from 2.2.
 +    - Creating Materialized View with filtering on non-primary-key base column
 +      (added in CASSANDRA-10368) is disabled, because the liveness of view row
 +      is depending on multiple filtered base non-key columns and base non-key
 +      column used in view primary-key. This semantic cannot be supported 
without
 +      storage format change, see CASSANDRA-13826. For append-only use case, 
you
 +      may still use this feature with a startup flag: 
"-Dcassandra.mv.allow_filtering_nonkey_columns_unsafe=true"
  
 -Compact Storage
++Compact Storage (only when upgrading from 3.X or any version lower than 
3.0.15)
+ ---------------
+     - Starting version 4.0, Thrift and COMPACT STORAGE is no longer supported.
+       'ALTER ... DROP COMPACT STORAGE' statement makes Compact Tables 
CQL-compatible,
+       exposing internal structure of Thrift/Compact Tables. You can find more 
details
+       on exposed internal structure under: 
+       
http://cassandra.apache.org/doc/latest/cql/appendices.html#appendix-c-dropping-compact-storage
+ 
+       For uninterrupted cluster upgrades, drivers now support 'NO_COMPACT' 
startup option.
+       Supplying this flag will have same effect as 'DROP COMPACT STORAGE', 
but only for the
+       current connection.
+ 
+       In order to upgrade, clients supporting a non-compact schema view can 
be rolled out
+       gradually. When all the clients are updated 'ALTER ... DROP COMPACT 
STORAGE' can be
+       executed. After dropping compact storage, ’NO_COMPACT' option will 
have no effect
+       after that.
+ 
++
+ Materialized Views
+ -------------------
 +
 +Materialized Views (only when upgrading from 3.X or any version lower than 
3.0.15)
 
+---------------------------------------------------------------------------------------
      - Cassandra will no longer allow dropping columns on tables with 
Materialized Views.
      - A change was made in the way the Materialized View timestamp is 
computed, which
        may cause an old deletion to a base column which is view primary key 
(PK) column

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d429cd0/bin/cqlsh.py
----------------------------------------------------------------------
diff --cc bin/cqlsh.py
index 85a0489,8d05d9d..ca76e34
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@@ -439,8 -701,9 +440,9 @@@ class Shell(cmd.Cmd)
      def __init__(self, hostname, port, color=False,
                   username=None, password=None, encoding=None, stdin=None, 
tty=True,
                   completekey=DEFAULT_COMPLETEKEY, browser=None, use_conn=None,
 -                 cqlver=DEFAULT_CQLVER, keyspace=None,
 +                 cqlver=None, keyspace=None,
                   tracing_enabled=False, expand_enabled=False,
+                  no_compact=False,
                   display_nanotime_format=DEFAULT_NANOTIME_FORMAT,
                   display_timestamp_format=DEFAULT_TIMESTAMP_FORMAT,
                   display_date_format=DEFAULT_DATE_FORMAT,
@@@ -470,11 -732,9 +472,12 @@@
          if use_conn:
              self.conn = use_conn
          else:
 +            kwargs = {}
 +            if protocol_version is not None:
 +                kwargs['protocol_version'] = protocol_version
              self.conn = Cluster(contact_points=(self.hostname,), 
port=self.port, cql_version=cqlver,
 -                                protocol_version=protocol_version,
 -                                auth_provider=self.auth_provider, 
no_compact=no_compact,
 +                                auth_provider=self.auth_provider,
++                                no_compact=no_compact,
                                  
ssl_options=sslhandling.ssl_settings(hostname, CONFIG_FILE) if ssl else None,
                                  
load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]),
                                  control_connection_timeout=connect_timeout,
@@@ -2396,9 -2644,9 +2400,10 @@@ def main(options, hostname, port)
                        tty=options.tty,
                        completekey=options.completekey,
                        browser=options.browser,
 +                      protocol_version=options.protocol_version,
                        cqlver=options.cqlversion,
                        keyspace=options.keyspace,
+                       no_compact=options.no_compact,
                        display_timestamp_format=options.time_format,
                        display_nanotime_format=options.nanotime_format,
                        display_date_format=options.date_format,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d429cd0/doc/source/cql/appendices.rst
----------------------------------------------------------------------
diff --cc doc/source/cql/appendices.rst
index 8c63a32,0000000..480b78e
mode 100644,000000..100644
--- a/doc/source/cql/appendices.rst
+++ b/doc/source/cql/appendices.rst
@@@ -1,308 -1,0 +1,330 @@@
 +.. Licensed to the Apache Software Foundation (ASF) under one
 +.. or more contributor license agreements.  See the NOTICE file
 +.. distributed with this work for additional information
 +.. regarding copyright ownership.  The ASF licenses this file
 +.. to you under the Apache License, Version 2.0 (the
 +.. "License"); you may not use this file except in compliance
 +.. with the License.  You may obtain a copy of the License at
 +..
 +..     http://www.apache.org/licenses/LICENSE-2.0
 +..
 +.. Unless required by applicable law or agreed to in writing, software
 +.. distributed under the License is distributed on an "AS IS" BASIS,
 +.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 +.. See the License for the specific language governing permissions and
 +.. limitations under the License.
 +
 +.. highlight:: cql
 +
 +Appendices
 +----------
 +
 +.. _appendix-A:
 +
 +Appendix A: CQL Keywords
 +~~~~~~~~~~~~~~~~~~~~~~~~
 +
 +CQL distinguishes between *reserved* and *non-reserved* keywords.
 +Reserved keywords cannot be used as identifier, they are truly reserved
 +for the language (but one can enclose a reserved keyword by
 +double-quotes to use it as an identifier). Non-reserved keywords however
 +only have a specific meaning in certain context but can used as
 +identifier otherwise. The only *raison d’être* of these non-reserved
 +keywords is convenience: some keyword are non-reserved when it was
 +always easy for the parser to decide whether they were used as keywords
 +or not.
 +
 ++--------------------+-------------+
 +| Keyword            | Reserved?   |
 ++====================+=============+
 +| ``ADD``            | yes         |
 ++--------------------+-------------+
 +| ``AGGREGATE``      | no          |
 ++--------------------+-------------+
 +| ``ALL``            | no          |
 ++--------------------+-------------+
 +| ``ALLOW``          | yes         |
 ++--------------------+-------------+
 +| ``ALTER``          | yes         |
 ++--------------------+-------------+
 +| ``AND``            | yes         |
 ++--------------------+-------------+
 +| ``APPLY``          | yes         |
 ++--------------------+-------------+
 +| ``AS``             | no          |
 ++--------------------+-------------+
 +| ``ASC``            | yes         |
 ++--------------------+-------------+
 +| ``ASCII``          | no          |
 ++--------------------+-------------+
 +| ``AUTHORIZE``      | yes         |
 ++--------------------+-------------+
 +| ``BATCH``          | yes         |
 ++--------------------+-------------+
 +| ``BEGIN``          | yes         |
 ++--------------------+-------------+
 +| ``BIGINT``         | no          |
 ++--------------------+-------------+
 +| ``BLOB``           | no          |
 ++--------------------+-------------+
 +| ``BOOLEAN``        | no          |
 ++--------------------+-------------+
 +| ``BY``             | yes         |
 ++--------------------+-------------+
 +| ``CALLED``         | no          |
 ++--------------------+-------------+
 +| ``CLUSTERING``     | no          |
 ++--------------------+-------------+
 +| ``COLUMNFAMILY``   | yes         |
 ++--------------------+-------------+
 +| ``COMPACT``        | no          |
 ++--------------------+-------------+
 +| ``CONTAINS``       | no          |
 ++--------------------+-------------+
 +| ``COUNT``          | no          |
 ++--------------------+-------------+
 +| ``COUNTER``        | no          |
 ++--------------------+-------------+
 +| ``CREATE``         | yes         |
 ++--------------------+-------------+
 +| ``CUSTOM``         | no          |
 ++--------------------+-------------+
 +| ``DATE``           | no          |
 ++--------------------+-------------+
 +| ``DECIMAL``        | no          |
 ++--------------------+-------------+
 +| ``DELETE``         | yes         |
 ++--------------------+-------------+
 +| ``DESC``           | yes         |
 ++--------------------+-------------+
 +| ``DESCRIBE``       | yes         |
 ++--------------------+-------------+
 +| ``DISTINCT``       | no          |
 ++--------------------+-------------+
 +| ``DOUBLE``         | no          |
 ++--------------------+-------------+
 +| ``DROP``           | yes         |
 ++--------------------+-------------+
 +| ``ENTRIES``        | yes         |
 ++--------------------+-------------+
 +| ``EXECUTE``        | yes         |
 ++--------------------+-------------+
 +| ``EXISTS``         | no          |
 ++--------------------+-------------+
 +| ``FILTERING``      | no          |
 ++--------------------+-------------+
 +| ``FINALFUNC``      | no          |
 ++--------------------+-------------+
 +| ``FLOAT``          | no          |
 ++--------------------+-------------+
 +| ``FROM``           | yes         |
 ++--------------------+-------------+
 +| ``FROZEN``         | no          |
 ++--------------------+-------------+
 +| ``FULL``           | yes         |
 ++--------------------+-------------+
 +| ``FUNCTION``       | no          |
 ++--------------------+-------------+
 +| ``FUNCTIONS``      | no          |
 ++--------------------+-------------+
 +| ``GRANT``          | yes         |
 ++--------------------+-------------+
 +| ``IF``             | yes         |
 ++--------------------+-------------+
 +| ``IN``             | yes         |
 ++--------------------+-------------+
 +| ``INDEX``          | yes         |
 ++--------------------+-------------+
 +| ``INET``           | no          |
 ++--------------------+-------------+
 +| ``INFINITY``       | yes         |
 ++--------------------+-------------+
 +| ``INITCOND``       | no          |
 ++--------------------+-------------+
 +| ``INPUT``          | no          |
 ++--------------------+-------------+
 +| ``INSERT``         | yes         |
 ++--------------------+-------------+
 +| ``INT``            | no          |
 ++--------------------+-------------+
 +| ``INTO``           | yes         |
 ++--------------------+-------------+
 +| ``JSON``           | no          |
 ++--------------------+-------------+
 +| ``KEY``            | no          |
 ++--------------------+-------------+
 +| ``KEYS``           | no          |
 ++--------------------+-------------+
 +| ``KEYSPACE``       | yes         |
 ++--------------------+-------------+
 +| ``KEYSPACES``      | no          |
 ++--------------------+-------------+
 +| ``LANGUAGE``       | no          |
 ++--------------------+-------------+
 +| ``LIMIT``          | yes         |
 ++--------------------+-------------+
 +| ``LIST``           | no          |
 ++--------------------+-------------+
 +| ``LOGIN``          | no          |
 ++--------------------+-------------+
 +| ``MAP``            | no          |
 ++--------------------+-------------+
 +| ``MODIFY``         | yes         |
 ++--------------------+-------------+
 +| ``NAN``            | yes         |
 ++--------------------+-------------+
 +| ``NOLOGIN``        | no          |
 ++--------------------+-------------+
 +| ``NORECURSIVE``    | yes         |
 ++--------------------+-------------+
 +| ``NOSUPERUSER``    | no          |
 ++--------------------+-------------+
 +| ``NOT``            | yes         |
 ++--------------------+-------------+
 +| ``NULL``           | yes         |
 ++--------------------+-------------+
 +| ``OF``             | yes         |
 ++--------------------+-------------+
 +| ``ON``             | yes         |
 ++--------------------+-------------+
 +| ``OPTIONS``        | no          |
 ++--------------------+-------------+
 +| ``OR``             | yes         |
 ++--------------------+-------------+
 +| ``ORDER``          | yes         |
 ++--------------------+-------------+
 +| ``PASSWORD``       | no          |
 ++--------------------+-------------+
 +| ``PERMISSION``     | no          |
 ++--------------------+-------------+
 +| ``PERMISSIONS``    | no          |
 ++--------------------+-------------+
 +| ``PRIMARY``        | yes         |
 ++--------------------+-------------+
 +| ``RENAME``         | yes         |
 ++--------------------+-------------+
 +| ``REPLACE``        | yes         |
 ++--------------------+-------------+
 +| ``RETURNS``        | no          |
 ++--------------------+-------------+
 +| ``REVOKE``         | yes         |
 ++--------------------+-------------+
 +| ``ROLE``           | no          |
 ++--------------------+-------------+
 +| ``ROLES``          | no          |
 ++--------------------+-------------+
 +| ``SCHEMA``         | yes         |
 ++--------------------+-------------+
 +| ``SELECT``         | yes         |
 ++--------------------+-------------+
 +| ``SET``            | yes         |
 ++--------------------+-------------+
 +| ``SFUNC``          | no          |
 ++--------------------+-------------+
 +| ``SMALLINT``       | no          |
 ++--------------------+-------------+
 +| ``STATIC``         | no          |
 ++--------------------+-------------+
 +| ``STORAGE``        | no          |
 ++--------------------+-------------+
 +| ``STYPE``          | no          |
 ++--------------------+-------------+
 +| ``SUPERUSER``      | no          |
 ++--------------------+-------------+
 +| ``TABLE``          | yes         |
 ++--------------------+-------------+
 +| ``TEXT``           | no          |
 ++--------------------+-------------+
 +| ``TIME``           | no          |
 ++--------------------+-------------+
 +| ``TIMESTAMP``      | no          |
 ++--------------------+-------------+
 +| ``TIMEUUID``       | no          |
 ++--------------------+-------------+
 +| ``TINYINT``        | no          |
 ++--------------------+-------------+
 +| ``TO``             | yes         |
 ++--------------------+-------------+
 +| ``TOKEN``          | yes         |
 ++--------------------+-------------+
 +| ``TRIGGER``        | no          |
 ++--------------------+-------------+
 +| ``TRUNCATE``       | yes         |
 ++--------------------+-------------+
 +| ``TTL``            | no          |
 ++--------------------+-------------+
 +| ``TUPLE``          | no          |
 ++--------------------+-------------+
 +| ``TYPE``           | no          |
 ++--------------------+-------------+
 +| ``UNLOGGED``       | yes         |
 ++--------------------+-------------+
 +| ``UPDATE``         | yes         |
 ++--------------------+-------------+
 +| ``USE``            | yes         |
 ++--------------------+-------------+
 +| ``USER``           | no          |
 ++--------------------+-------------+
 +| ``USERS``          | no          |
 ++--------------------+-------------+
 +| ``USING``          | yes         |
 ++--------------------+-------------+
 +| ``UUID``           | no          |
 ++--------------------+-------------+
 +| ``VALUES``         | no          |
 ++--------------------+-------------+
 +| ``VARCHAR``        | no          |
 ++--------------------+-------------+
 +| ``VARINT``         | no          |
 ++--------------------+-------------+
 +| ``WHERE``          | yes         |
 ++--------------------+-------------+
 +| ``WITH``           | yes         |
 ++--------------------+-------------+
 +| ``WRITETIME``      | no          |
 ++--------------------+-------------+
 +
 +Appendix B: CQL Reserved Types
 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +
 +The following type names are not currently used by CQL, but are reserved
 +for potential future use. User-defined types may not use reserved type
 +names as their name.
 +
 ++-----------------+
 +| type            |
 ++=================+
 +| ``bitstring``   |
 ++-----------------+
 +| ``byte``        |
 ++-----------------+
 +| ``complex``     |
 ++-----------------+
 +| ``enum``        |
 ++-----------------+
 +| ``interval``    |
 ++-----------------+
 +| ``macaddr``     |
 ++-----------------+
++
++
++Appendix C: Dropping Compact Storage
++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++
++Starting version 4.0, Thrift and COMPACT STORAGE is no longer supported.
++
++'ALTER ... DROP COMPACT STORAGE' statement makes Compact Tables 
CQL-compatible,
++exposing internal structure of Thrift/Compact Tables:
++
++- CQL-created Compact Tables that have no clustering columns, will expose an
++  additional clustering column ``column1`` with ``UTF8Type``.
++- CQL-created Compact Tables that had no regular columns, will expose a
++  regular column ``value`` with ``BytesType``.
++- For CQL-Created Compact Tables, all columns originally defined as
++  ``regular`` will be come ``static``
++- CQL-created Compact Tables that have clustering but have no regular
++  columns will have an empty value column (of ``EmptyType``)
++- SuperColumn Tables (can only be created through Thrift) will expose
++  a compact value map with an empty name.
++- Thrift-created Compact Tables will have types corresponding to their
++  Thrift definition.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d429cd0/src/antlr/Lexer.g
----------------------------------------------------------------------
diff --cc src/antlr/Lexer.g
index 23cbed6,0000000..1c52d4c
mode 100644,000000..100644
--- a/src/antlr/Lexer.g
+++ b/src/antlr/Lexer.g
@@@ -1,350 -1,0 +1,354 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *   http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +
 +lexer grammar Lexer;
 +
 +@lexer::members {
 +    List<Token> tokens = new ArrayList<Token>();
 +
 +    public void emit(Token token)
 +    {
 +        state.token = token;
 +        tokens.add(token);
 +    }
 +
 +    public Token nextToken()
 +    {
 +        super.nextToken();
 +        if (tokens.size() == 0)
 +            return new CommonToken(Token.EOF);
 +        return tokens.remove(0);
 +    }
 +
 +    private final List<ErrorListener> listeners = new 
ArrayList<ErrorListener>();
 +
 +    public void addErrorListener(ErrorListener listener)
 +    {
 +        this.listeners.add(listener);
 +    }
 +
 +    public void removeErrorListener(ErrorListener listener)
 +    {
 +        this.listeners.remove(listener);
 +    }
 +
 +    public void displayRecognitionError(String[] tokenNames, 
RecognitionException e)
 +    {
 +        for (int i = 0, m = listeners.size(); i < m; i++)
 +            listeners.get(i).syntaxError(this, tokenNames, e);
 +    }
 +}
 +
 +// Case-insensitive keywords
 +// When adding a new reserved keyword, add entry to 
o.a.c.cql3.ReservedKeywords as well
 +// When adding a new unreserved keyword, add entry to unreserved keywords in 
Parser.g
 +K_SELECT:      S E L E C T;
 +K_FROM:        F R O M;
 +K_AS:          A S;
 +K_WHERE:       W H E R E;
 +K_AND:         A N D;
 +K_KEY:         K E Y;
 +K_KEYS:        K E Y S;
 +K_ENTRIES:     E N T R I E S;
 +K_FULL:        F U L L;
 +K_INSERT:      I N S E R T;
 +K_UPDATE:      U P D A T E;
 +K_WITH:        W I T H;
 +K_LIMIT:       L I M I T;
 +K_PER:         P E R;
 +K_PARTITION:   P A R T I T I O N;
 +K_USING:       U S I N G;
 +K_USE:         U S E;
 +K_DISTINCT:    D I S T I N C T;
 +K_COUNT:       C O U N T;
 +K_SET:         S E T;
 +K_BEGIN:       B E G I N;
 +K_UNLOGGED:    U N L O G G E D;
 +K_BATCH:       B A T C H;
 +K_APPLY:       A P P L Y;
 +K_TRUNCATE:    T R U N C A T E;
 +K_DELETE:      D E L E T E;
 +K_IN:          I N;
 +K_CREATE:      C R E A T E;
 +K_KEYSPACE:    ( K E Y S P A C E
 +                 | S C H E M A );
 +K_KEYSPACES:   K E Y S P A C E S;
 +K_COLUMNFAMILY:( C O L U M N F A M I L Y
 +                 | T A B L E );
 +K_MATERIALIZED:M A T E R I A L I Z E D;
 +K_VIEW:        V I E W;
 +K_INDEX:       I N D E X;
 +K_CUSTOM:      C U S T O M;
 +K_ON:          O N;
 +K_TO:          T O;
 +K_DROP:        D R O P;
 +K_PRIMARY:     P R I M A R Y;
 +K_INTO:        I N T O;
 +K_VALUES:      V A L U E S;
 +K_TIMESTAMP:   T I M E S T A M P;
 +K_TTL:         T T L;
 +K_CAST:        C A S T;
 +K_ALTER:       A L T E R;
 +K_RENAME:      R E N A M E;
 +K_ADD:         A D D;
 +K_TYPE:        T Y P E;
 +K_COMPACT:     C O M P A C T;
 +K_STORAGE:     S T O R A G E;
 +K_ORDER:       O R D E R;
 +K_BY:          B Y;
 +K_ASC:         A S C;
 +K_DESC:        D E S C;
 +K_ALLOW:       A L L O W;
 +K_FILTERING:   F I L T E R I N G;
 +K_IF:          I F;
 +K_IS:          I S;
 +K_CONTAINS:    C O N T A I N S;
 +K_GROUP:       G R O U P;
 +
 +K_GRANT:       G R A N T;
 +K_ALL:         A L L;
 +K_PERMISSION:  P E R M I S S I O N;
 +K_PERMISSIONS: P E R M I S S I O N S;
 +K_OF:          O F;
 +K_REVOKE:      R E V O K E;
 +K_MODIFY:      M O D I F Y;
 +K_AUTHORIZE:   A U T H O R I Z E;
 +K_DESCRIBE:    D E S C R I B E;
 +K_EXECUTE:     E X E C U T E;
 +K_NORECURSIVE: N O R E C U R S I V E;
 +K_MBEAN:       M B E A N;
 +K_MBEANS:      M B E A N S;
 +
 +K_USER:        U S E R;
 +K_USERS:       U S E R S;
 +K_ROLE:        R O L E;
 +K_ROLES:       R O L E S;
 +K_SUPERUSER:   S U P E R U S E R;
 +K_NOSUPERUSER: N O S U P E R U S E R;
 +K_PASSWORD:    P A S S W O R D;
 +K_LOGIN:       L O G I N;
 +K_NOLOGIN:     N O L O G I N;
 +K_OPTIONS:     O P T I O N S;
 +
 +K_CLUSTERING:  C L U S T E R I N G;
 +K_ASCII:       A S C I I;
 +K_BIGINT:      B I G I N T;
 +K_BLOB:        B L O B;
 +K_BOOLEAN:     B O O L E A N;
 +K_COUNTER:     C O U N T E R;
 +K_DECIMAL:     D E C I M A L;
 +K_DOUBLE:      D O U B L E;
 +K_DURATION:    D U R A T I O N;
 +K_FLOAT:       F L O A T;
 +K_INET:        I N E T;
 +K_INT:         I N T;
 +K_SMALLINT:    S M A L L I N T;
 +K_TINYINT:     T I N Y I N T;
 +K_TEXT:        T E X T;
 +K_UUID:        U U I D;
 +K_VARCHAR:     V A R C H A R;
 +K_VARINT:      V A R I N T;
 +K_TIMEUUID:    T I M E U U I D;
 +K_TOKEN:       T O K E N;
 +K_WRITETIME:   W R I T E T I M E;
 +K_DATE:        D A T E;
 +K_TIME:        T I M E;
 +
 +K_NULL:        N U L L;
 +K_NOT:         N O T;
 +K_EXISTS:      E X I S T S;
 +
 +K_MAP:         M A P;
 +K_LIST:        L I S T;
 +K_NAN:         N A N;
 +K_INFINITY:    I N F I N I T Y;
 +K_TUPLE:       T U P L E;
 +
 +K_TRIGGER:     T R I G G E R;
 +K_STATIC:      S T A T I C;
 +K_FROZEN:      F R O Z E N;
 +
 +K_FUNCTION:    F U N C T I O N;
 +K_FUNCTIONS:   F U N C T I O N S;
 +K_AGGREGATE:   A G G R E G A T E;
 +K_SFUNC:       S F U N C;
 +K_STYPE:       S T Y P E;
 +K_FINALFUNC:   F I N A L F U N C;
 +K_INITCOND:    I N I T C O N D;
 +K_RETURNS:     R E T U R N S;
 +K_CALLED:      C A L L E D;
 +K_INPUT:       I N P U T;
 +K_LANGUAGE:    L A N G U A G E;
 +K_OR:          O R;
 +K_REPLACE:     R E P L A C E;
 +
 +K_JSON:        J S O N;
 +K_DEFAULT:     D E F A U L T;
 +K_UNSET:       U N S E T;
 +K_LIKE:        L I K E;
 +
 +// Case-insensitive alpha characters
 +fragment A: ('a'|'A');
 +fragment B: ('b'|'B');
 +fragment C: ('c'|'C');
 +fragment D: ('d'|'D');
 +fragment E: ('e'|'E');
 +fragment F: ('f'|'F');
 +fragment G: ('g'|'G');
 +fragment H: ('h'|'H');
 +fragment I: ('i'|'I');
 +fragment J: ('j'|'J');
 +fragment K: ('k'|'K');
 +fragment L: ('l'|'L');
 +fragment M: ('m'|'M');
 +fragment N: ('n'|'N');
 +fragment O: ('o'|'O');
 +fragment P: ('p'|'P');
 +fragment Q: ('q'|'Q');
 +fragment R: ('r'|'R');
 +fragment S: ('s'|'S');
 +fragment T: ('t'|'T');
 +fragment U: ('u'|'U');
 +fragment V: ('v'|'V');
 +fragment W: ('w'|'W');
 +fragment X: ('x'|'X');
 +fragment Y: ('y'|'Y');
 +fragment Z: ('z'|'Z');
 +
 +STRING_LITERAL
 +    @init{
 +        StringBuilder txt = new StringBuilder(); // temporary to build 
pg-style-string
 +    }
 +    @after{ setText(txt.toString()); }
 +    :
 +      /* pg-style string literal */
 +      (
 +        '\$' '\$'
 +        ( /* collect all input until '$$' is reached again */
 +          {  (input.size() - input.index() > 1)
 +               && !"$$".equals(input.substring(input.index(), input.index() + 
1)) }?
 +             => c=. { txt.appendCodePoint(c); }
 +        )*
 +        '\$' '\$'
 +      )
 +      |
 +      /* conventional quoted string literal */
 +      (
 +        '\'' (c=~('\'') { txt.appendCodePoint(c);} | '\'' '\'' { 
txt.appendCodePoint('\''); })* '\''
 +      )
 +    ;
 +
 +QUOTED_NAME
 +    @init{ StringBuilder b = new StringBuilder(); }
 +    @after{ setText(b.toString()); }
 +    : '\"' (c=~('\"') { b.appendCodePoint(c); } | '\"' '\"' { 
b.appendCodePoint('\"'); })+ '\"'
 +    ;
 +
++EMPTY_QUOTED_NAME
++    : '\"' '\"'
++    ;
++
 +fragment DIGIT
 +    : '0'..'9'
 +    ;
 +
 +fragment LETTER
 +    : ('A'..'Z' | 'a'..'z')
 +    ;
 +
 +fragment HEX
 +    : ('A'..'F' | 'a'..'f' | '0'..'9')
 +    ;
 +
 +fragment EXPONENT
 +    : E ('+' | '-')? DIGIT+
 +    ;
 +
 +fragment DURATION_UNIT
 +    : Y
 +    | M O
 +    | W
 +    | D
 +    | H
 +    | M
 +    | S
 +    | M S
 +    | U S
 +    | '\u00B5' S
 +    | N S
 +    ;
 +
 +INTEGER
 +    : '-'? DIGIT+
 +    ;
 +
 +QMARK
 +    : '?'
 +    ;
 +
 +/*
 + * Normally a lexer only emits one token at a time, but ours is tricked out
 + * to support multiple (see @lexer::members near the top of the grammar).
 + */
 +FLOAT
 +    : INTEGER EXPONENT
 +    | INTEGER '.' DIGIT* EXPONENT?
 +    ;
 +
 +/*
 + * This has to be before IDENT so it takes precendence over it.
 + */
 +BOOLEAN
 +    : T R U E | F A L S E
 +    ;
 +
 +DURATION
 +    : '-'? DIGIT+ DURATION_UNIT (DIGIT+ DURATION_UNIT)*
 +    | '-'? 'P' (DIGIT+ 'Y')? (DIGIT+ 'M')? (DIGIT+ 'D')? ('T' (DIGIT+ 'H')? 
(DIGIT+ 'M')? (DIGIT+ 'S')?)? // ISO 8601 "format with designators"
 +    | '-'? 'P' DIGIT+ 'W'
 +    | '-'? 'P' DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT 'T' 
DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT // ISO 8601 "alternative format"
 +    ;
 +
 +IDENT
 +    : LETTER (LETTER | DIGIT | '_')*
 +    ;
 +
 +HEXNUMBER
 +    : '0' X HEX*
 +    ;
 +
 +UUID
 +    : HEX HEX HEX HEX HEX HEX HEX HEX '-'
 +      HEX HEX HEX HEX '-'
 +      HEX HEX HEX HEX '-'
 +      HEX HEX HEX HEX '-'
 +      HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX
 +    ;
 +
 +WS
 +    : (' ' | '\t' | '\n' | '\r')+ { $channel = HIDDEN; }
 +    ;
 +
 +COMMENT
 +    : ('--' | '//') .* ('\n'|'\r') { $channel = HIDDEN; }
 +    ;
 +
 +MULTILINE_COMMENT
 +    : '/*' .* '*/' { $channel = HIDDEN; }
 +    ;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to