Commit Graph

103 Commits

Author SHA1 Message Date
Avi Kivity
7bd4b7ca63 cql3: split use_statement into raw and prepared variants
Rather than having one class fulfil both roles, have one class per role,
disentangling dependencies.
Message-Id: <1465053407-20931-1-git-send-email-avi@scylladb.com>
2016-06-08 16:48:45 +03:00
Avi Kivity
c8b5104aa5 cql3: extract raw batch_statement into raw sub-namespace
prepare() was moved to .cc to avoid circular dependencies.
2016-05-31 21:41:26 +03:00
Avi Kivity
1d144699f6 cql3: extract raw delete_statement into raw sub-namespace 2016-05-31 21:24:56 +03:00
Avi Kivity
e596799962 cql3: extract raw update_statement into raw sub-namespace
update_statment also has an insert_statement counterpart, convert it too.
2016-05-31 21:16:53 +03:00
Avi Kivity
10213c4211 cql3: extract raw modification_statement into raw sub-namespace 2016-05-31 20:53:37 +03:00
Avi Kivity
25b3d74f45 cql3: Split select_statement::raw_statement into raw namespace
cql3::select_statement::raw_statement
    -> cql3::raw::select_statement
Message-Id: <1464609556-3756-4-git-send-email-avi@scylladb.com>
2016-05-31 09:09:30 +03:00
Avi Kivity
caf8d4f0e6 cql3: separate parsed_statement and parsed_statment::prepared
cql3::statements::parsed_statement
    -> cql3::statements::raw::parsed_statement
  cql3::statements::parsed_statement::prepared
    -> cql3::statements::prepared_statement
Message-Id: <1464609556-3756-2-git-send-email-avi@scylladb.com>
2016-05-31 09:09:10 +03:00
Calle Wilund
147aa81177 Cql.g: Handle ALTER KEYSPACE 2016-05-10 14:36:46 +00:00
Duarte Nunes
7911438de0 udt: Add grammar for altering user types
This patch adds support in Cql.g for the alter user type statement.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-04-20 18:07:07 +02:00
Duarte Nunes
6cb57a567f udt: Add grammar for dropping user types
This patch adds support in Cql.g for the drop user type statement.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-04-20 18:07:06 +02:00
Calle Wilund
9ed25a970e Cql.g: Permission statements parsing 2016-04-19 11:49:06 +00:00
Pekka Enberg
7af46e41e5 Merge "CQL authentication implementation" from Calle
"Adds support for CQL commands to create, alter, drop and list users.
Verified manually and by relevant dtests.

With this patch set, scylla supports adding super/regular users and
run sessions logged in as these. Note however that since actual
authorization is still not implemented, no CF/KS is really protected
by the authentication beyond initial login.

Some fixes for lingering bugs in user management in the existing code
as well.

Fixes #1121"
2016-04-11 12:57:00 +03:00
Pekka Enberg
4e04805352 cql3: Make lexer and parser error messages compatible with Cassandra
The default recognition error messages in antlr C++ backend are
different from Java backend which makes Scylla's CQL error messages
incompatible with Cassandra. This makes it very hard to write CQL level
test cases which are portable between Scylla and Cassandra.

To fix the issue, override the most common lexer and parser error
messages to follow the convention set by the antlr Java backend. This
unlocks various test cases in AlterTest, for example.
Message-Id: <1460032883-14422-1-git-send-email-penberg@scylladb.com>
2016-04-11 12:35:53 +03:00
Calle Wilund
ceac4df164 Cql.g: Add create/drop/alter/list user parsing 2016-04-11 09:10:41 +00:00
Duarte Nunes
26a3461908 cql: Fix antlr3 missing token leak
This patch overrides the antlr3 function that allocates the missing
tokens that would eventually leak. The override stores these tokens in
a vector, ensuring memory is freed whenever the parser is destroyed.

Fixes #1147

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
Message-Id: <1459355146-17402-1-git-send-email-duarte@scylladb.com>
2016-03-31 08:44:45 +03:00
Duarte Nunes
db881fdc8f cql: Add support for pg-style string literal
This patch adds support for pg-style string literals to the CQL
grammar.

Fixes #1078

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
Message-Id: <1459093238-2529-1-git-send-email-duarte@scylladb.com>
2016-03-28 17:06:03 +03:00
Calle Wilund
5982c0ee10 Cql.g: Add extension function SCYLLA_TIMEUUID_LIST_INDEX
Allows scylla sstable loader (cql) to do by-uuid updates to
non-frozen lists.
2016-03-21 12:28:37 +00:00
Pekka Enberg
4ff1692248 cql3: Make 'CREATE TYPE' error message human readable
We don't support the 'CREATE TYPE' statement for now. The user-visible
error message, however, is unreadable because our CQL parser doesn't
even recognize the statement.

  cqlsh:ks1> CREATE TYPE config (url text);
  SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message=" : cannot match to any predicted input...

Implement just enough of 'CREATE TYPE' parsing to be able to report a
human readable error message if someone tries to execute such
statements:

  cqlsh:ks1> CREATE TYPE config (url text);
  ServerError: <ErrorMessage code=0000 [Server error] message="User-defined types are not supported yet">
Message-Id: <1456148719-9473-2-git-send-email-penberg@scylladb.com>
2016-02-22 14:50:25 +01:00
Paweł Dziepak
70f5ed6c64 cql3: enable ALTER TABLE in cql3 grammar definition
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-01-05 09:49:04 +01:00
Pekka Enberg
32d22a1544 cql3: Fix relation grammar rule
There's two untranslated grammar subrules in the 'relation' rule. We
have all the necessary AST classes translated, so translate the
remaining subrules.

Refs #534.

Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-12-31 11:44:15 +01:00
Pekka Enberg
569d288891 cql3: Add TRUNCATE TABLE alias for TRUNCATE
CQL 3.2.1 introduces a "TRUNCATE TABLE X" alias for "TRUNCATE X":

  4e3555c1d9

Fix our CQL grammar to also support that.

Please note that we don't bump up advertised CQL version yet because our
cqlsh clients won't be able to connect by default until we upgrade them
to C* 2.1.10 or later.

Fixes #576

Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-11-26 18:45:50 +02:00
Pekka Enberg
2344bd806d cql3: Fix grammar 'WITH WITH' bug that causes a SIGSEGV
Fix an issue where 'WITH WITH' in CREATE and ALTER KEYSPACE would bring
down the whole server.

  https://issues.apache.org/jira/browse/CASSANDRA-9565

  c939422637

Spotted by C* unit tests.

Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-10-29 10:59:57 +01:00
Paweł Dziepak
39c29a3fb4 types: add decimal type
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-09-08 16:04:48 +02:00
Pekka Enberg
d63649bf65 cql3: Fix CQL parser error message for counter types
The CQL tokenizer recognizes "COUNTER" token but the parser rule for
counter type is disabled. This causes users to see the following error
in cqlsh, for example:

  CREATE TABLE count (u int PRIMARY KEY, c counter);
  SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message=" : cannot match to any predicted input...  ">

We cannot disable the "COUNTER" token because it's also used in batch
statements. Instead, fix the issue by implementing a stub counter type.

Fixes #195.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-27 15:34:43 +03:00
Paweł Dziepak
0069040eb3 cql3: enable multi column restrictions
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:59:13 +02:00
Paweł Dziepak
babb2fa261 types: add varint type
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-21 14:46:34 +02:00
Paweł Dziepak
c5e9434183 cql3: change orderings_type to std::vector
We need to preserve the order of orderings in order to validate them
properly.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-14 19:34:27 +02:00
Paweł Dziepak
922779747d Cql.g: orderings should be passed by reference
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-14 19:34:27 +02:00
Pekka Enberg
c820078916 cql3/Cql.g: Fix index name case sensitivity
Fix index name case sensitivity as per Origin commit 68be72f ("Fix
case-sensitivity of index name on CREATE/DROP INDEX") which addressed
CASSANDRA-8365.

The grammar rules were imported from the following Origin commit:

  ebc50d783505854f04f183297ad3009b9095b07e

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-10 11:16:42 +03:00
Pekka Enberg
31248ee0cf cql3: Enable DROP TABLE statement grammar
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-09 09:36:39 +03:00
Pekka Enberg
69c56997e2 cql3: Enable DROP KEYSPACE statement grammar
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-08 18:40:30 +02:00
Avi Kivity
a209c91662 Merge "Fix empty sstable_compression property" from Paweł
"This patches prevent compression validation code from rejecting statements
with an empty sstable_compression property. Correct behaviour in such cases
is not to use compression at all.

This would have been a 10 minuts fix if antlr3 didn't prepare surprise of its
own. Empty STRING_LITERALS weren't handled properly and a workaround for that
problem was introduced."
2015-07-08 13:14:12 +03:00
Paweł Dziepak
8405361e81 Cql.g: support empty STRING_LITERALS
setText() is meant to override the token value. However, when antlr3 is
asked to return the token value and needs to determine whether setText()
was called it checks if the string set by setText() is empty or not.
This basically means that it is impossible to override token value with
an empty string.

This problem is solved by using a string with a single byte set to -1 to
represent empty string.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-08 10:38:33 +02:00
Calle Wilund
94fcce501e Cql3.g: handle token in grammar 2015-07-08 10:02:31 +02:00
Paweł Dziepak
cce2996cde cql3: enable inet type in cql grammar definition
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:26:40 +02:00
Tomasz Grabiec
510f236e7c Merge branch 'penberg/cql-truncate-stmt' from seastar-dev.git
"truncate" statement grammar from Pekka.
2015-07-06 09:54:12 +02:00
Pekka Enberg
55fd6cc629 cql3: Enable create index statement grammar definition
Create index statement AST class is converted to C++ so enable its grammar
definition.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-06 10:23:13 +03:00
Pekka Enberg
480200f0ea cql3: Enable truncate statement grammar definition
Truncate statement AST class is converted to C++ (although its
functionality is unimplemented). Enable the CQL grammar definition so
that users get an "not implemented" error instead of a syntax error.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-06 10:07:20 +03:00
Paweł Dziepak
67551832c0 cql3: implement displayRecogintionError for lexer and parser
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-23 16:17:45 +02:00
Pekka Enberg
d088cb8181 Fix keyspace strategy options to preserve key-value ordering
Fix keyspace strategy options to preserve key-value ordering by
switching to std::map. We need this to be able to store the map in
database as JSON because unordered maps can cause the schema merging
code to attempt a keyspace update, which we don't support, even though
the values did not change.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-11 13:02:42 +03:00
Tomasz Grabiec
f00f5f39d9 Merge tag 'avi/remedial-collections-2/v1' from seastar-dev.git
Collection support remedial from Avi.
2015-04-28 17:48:07 +02:00
Avi Kivity
0b09296f5d cql3: enable grammer for collection conditions
map['key'] IN (1, 2, 3)

etc.
2015-04-28 18:17:25 +03:00
Avi Kivity
01347bf091 cql3: enable grammar for frozen<type> 2015-04-26 19:25:39 +03:00
Avi Kivity
3fec0842ef cql3: enable grammar for user type names 2015-04-26 19:25:39 +03:00
Avi Kivity
bc1ab16adc cql3: convert reserved_type_names() in grammar 2015-04-26 19:25:39 +03:00
Avi Kivity
6f2751750f cql3: add uninitialized<> helper for ANTLR
ANTLR insists on default-initializing rule return values, which doesn't
always make sense.  Rather than wrapping with optional<> or shared_ptr<>,
introduce a specialized wrapper that only handles late initialization (by
assignment).

Example:

  foo returns [uninitialized<some_type> ret]
     ...
         { $ret = ...; }
2015-04-26 19:25:39 +03:00
Avi Kivity
b4e380b922 cql3: enable user_type literal grammar 2015-04-20 16:15:35 +03:00
Avi Kivity
3920ab18b2 cql3: enable user type grammar for field selection 2015-04-20 16:15:35 +03:00
Avi Kivity
6866fd4620 cql3: enable IN marker grammar and some call sites 2015-04-15 18:01:50 +02:00
Tomasz Grabiec
560c972bb3 Merge tag 'avi/tuples/v3' from seastar-dev.git
Resolved trivial conflicts in:
	cql3/lists.cc
	tests/urchin/cql_query_test.cc
2015-04-15 18:01:37 +02:00