Commit Graph

36 Commits

Author SHA1 Message Date
Vlad Zolotarov
ff55b76562 cql3::query_processor: use weak_ptr for passing the prepared statements around
Use seastar::checked_ptr<weak_ptr<pepared_statement>> instead of shared_ptr for passing prepared statements around.
This allows an easy tracking and handling of statements invalidation.

This implementation will throw an exception every time an invalidated
statement reference is dereferenced.

Signed-off-by: Vlad Zolotarov <vladz@scylladb.com>
2017-04-12 12:24:03 -04:00
Paweł Dziepak
fa29ef3cc0 cql3: allow counters in CREATE TABLE statements 2017-02-02 10:35:14 +00:00
Tomasz Grabiec
e6cc0a2e10 Merge branch '1766/v1' from duarten/scylla.git
This patchset adds missing properties to the create_view_statement,
such as whether the view is compact or the order of its clustering
columns.

Fixes #1766
2016-11-07 10:44:24 +01:00
Vlad Zolotarov
7606588267 cql3::query_processor: add cql_stats
- Add cql_stats member.
   - Pass it to cql3::raw::parsed_statement::prepare() virtual method.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2016-11-03 11:48:57 -04:00
Duarte Nunes
7c28ed3dfc schema: Extract default compressor
This patch extracts the definition of the default compressor into the
compression_parameters class, so that the table and view creation
statements don't have to explicitly deal with it.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-10-18 01:18:52 +00:00
Duarte Nunes
dc470e6a36 cql3: Extract cf_properties
This patch extracts the cf_properties class, which contains common
attributes of tables and materialized views.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-10-18 01:18:51 +00:00
Avi Kivity
0687dc3689 cql3: add fake create_table_statement::prepare()
In preparation for the removal of schema_altering_statement::prepare(),
add a fake create_table_statement::prepare().  create_table_statement
has already been split to raw and prepared variants, so this prepare()
will never be called, but it is required because schema_altering_statement
is both a cql_statement and a prepared_statement.  This confusion will
be fixed later on.
2016-07-30 23:26:28 +03:00
Avi Kivity
c8f98c5981 cql3: move cf_statement into raw hierarchy
cql3::statements::cf_statement
    -> cql3::statements::raw::cf_statement
Message-Id: <1464609556-3756-3-git-send-email-avi@scylladb.com>
2016-05-31 09:09:21 +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
3906dc9f0d cql3::statements: Change check_access to future<> + implement 2016-04-19 11:49:05 +00:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Tomasz Grabiec
d376167bd4 cql: create_table_statement: Optimize duplicate column names detection
Current algorithm is O(N^2) where N is the column count. This causes
limits.py:TestLimits.max_columns_and_query_parameters_test to timeout
because CREATE TABLE statement takes too long.

This change replaces it with an algorithm of O(N)
complexity. _defined_names are already sorted so if any duplicates
exist, they must be next to each other.

Message-Id: <1456058447-5080-1-git-send-email-tgrabiec@scylladb.com>
2016-02-21 14:55:03 +02:00
Takuya ASADA
f8ecd338b8 cql3: replace PRId32 with %d on sprint()
fixes #374

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-09-20 13:15:24 +03:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03: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
1119141959 cql3: translate validation code for compact storage tables
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 14:53:35 +02:00
Pekka Enberg
feb6b7d316 service/migration_manager: Remove storage proxy arguments
Use get_storage_proxy() and get_local_storage_proxy() helpers under the
hood to simplify migration manager API users.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 13:31:46 +03:00
Pekka Enberg
a3c95235e6 migration_manager: Make stateful with sharded<>
In preparation for adding listener state to migration manager, use
sharded<> for migration manager.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-04 11:23:23 +03:00
Glauber Costa
3bb16fba7e create table: fix creation of compact storage tables
The statement being removed in this patch is wrong, and nonexistent in Origin.
If the list of column aliases is empty, we should leave it this way.

This code was already present before the compact storage series. But because
tables created using the schema_builder directly won't exercise this code path,
I ended up not noticing - specially because it only happens with tables that
lack a clustering key. The ones I tested through cqlsh, all had a clustering
key.

Fixes #45

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-28 10:05:05 +02:00
Glauber Costa
21fc542af1 create_table_statement: revert reversed types
We have the information that they should be reverted, but we are not yet
reverting them. Go ahead and do it

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04:00
Glauber Costa
5306c70f3f create_table statement: sanity test defined_order
Code-conversion, mainly

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04:00
Glauber Costa
3c0982a01f create_table_statement: adjust _defined_ordering
First of all, we should abide by our convention of prepending member names with
a '_'. (That is the underline character, it just looks like a face)

But more importantly, because we will be searching its contents frequently, a
helper function is provided.

Note that obviously a hash is better suited for this: but because we do need to
keep the fields in order they are inserted, a vector really is the best choice
for that.

A table is not expected to have a lot of clustering keys. So this search should
be cheap. If it turns out to be a problem, we can adjust later.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04:00
Glauber Costa
cb94f3f27e schema_builder: calculate is_dense from the schema builder
We currently have code to calculate "is_dense" in the create statement handler.
That obviously don't work for the system schemas, which are not defined this
way.

Since all of our schemas now have to pass through the schema_builder one way or
another, that is the best place in which to do that calculation.

Note that unfortunately, that does not mean we can just get rid of
set_is_dense() in the schema builder: we still need to set it in some
situations, where for instance, we read that property in schema_columnfamilies,
and then apply to the relevant CF. Those uses are, however, all internal to
legacy_schema_tables.cc

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:09:05 -04:00
Avi Kivity
c84fc789c5 cql3: avoid use-after-free of stack variable in create_keyspace_statement
Capture it by value.
2015-07-21 12:19:19 +03:00
Paweł Dziepak
fe491ee5f5 cql3: make sure an exception is caught in create statements
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-16 16:23:39 +02:00
Pekka Enberg
86d913954a db/legacy_schema_tables: Store CF "is_dense" to system tables
Persist column family's "is_dense" value to system tables. Please note
that we throw an exception if "is_dense" is null upon read. That needs
to be fixed later by inferring the value from other information like
Origin does.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-07 12:36:50 +02:00
Pekka Enberg
c24b7d42ce db/legacy_schema_tables: Store CF key validator in system tables
Store the column family key validator in system tables. Please note that
we derive the validator from CQL partition keys and never actually read
it from the database. This is different from Origin which uses
CompositeType that is both stored and read from the system tables.

Fixes #7.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Tested-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-06 20:33:05 +03:00
Paweł Dziepak
51e3f2bcea cql3: use default compressor if none specified
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-25 14:17:46 +02:00
Paweł Dziepak
0369d169cc cql3: validate name and columns of the created table
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-23 16:17:45 +02:00
Pekka Enberg
765ace5900 cql3: Fix static column set lookups
The column_identifiers are wrapped in shared_ptr<> so use the
appropriate hash and comparison functions for the container.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 16:34:09 +03:00
Gleb Natapov
a338407e29 make storage_proxy object distributed
storage_proxy holds per cpu state now to track clustering, so it has to
be distributed otherwise smp setup does not work.
2015-06-17 15:14:06 +02:00
Pekka Enberg
b6c348807c cql3: Add clustering key support to create_table_statement
Add clustering key support to create_table_statement. While at it, add
compound types for partition keys, to unify schema building code for
both partition and clustering keys.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 11:18:53 +02:00
Pekka Enberg
24e74f331d cql3: Move create_table_statement::raw_statement implementation
Move raw_statement implementation out of the header file. This makes
life easier when we modify the class for clustering key support.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-16 17:35:24 +03:00
Pekka Enberg
07e4286f9e cql3: Make 'create table' include columns in schema_ptr
Make 'create table' statements also specify the following for
schema_ptrs:

  - Partition keys
  - Regular columns
  - Static columns

Please note that clustering keys are _not_ included because we seem to
lack infrastructure like CompoundType and CellNameType to properly
enable them.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-05 15:15:12 +03:00
Pekka Enberg
4365b8bb69 cql3: Use schema_builder for create table statements
Switch to using schema_builder in create_table_statement in preparation
for also defining columns in the resulting schema_ptr.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-05 15:15:12 +03:00
Pekka Enberg
cf6cdc6541 cql3: Move create_table_statement code out-of-line
Move create_table_statement code out-of-line in preparation for
modifying the implementation.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-05 15:15:12 +03:00