Commit Graph

255 Commits

Author SHA1 Message Date
Avi Kivity
20e616131f cql3: convert grammar for map literals and setting a map value by key 2015-03-12 10:22:17 +02:00
Avi Kivity
6e646efb85 cql3: implement operation::setter::prepare() for maps 2015-03-12 10:22:17 +02:00
Avi Kivity
1172f65d50 cql3: convert maps::setter_by_key to C++ 2015-03-12 10:22:17 +02:00
Avi Kivity
a64cd8f22f cql3: convert maps::literal to C++ 2015-03-12 10:22:17 +02:00
Avi Kivity
0f793f1aa7 cql3: convert maps::delayed_value to C++ 2015-03-12 10:22:15 +02:00
Avi Kivity
561d72879a cql3: convert maps::value to C++ 2015-03-12 10:14:25 +02:00
Avi Kivity
33f6703be6 cql3: move enable_shared_from_this up the cql3::term hierarchy
Casting upwards past an enable_shared_from_this confuses shared_ptr,
so move it to the base of the hierarchy.
2015-03-12 10:10:43 +02:00
Avi Kivity
70d1be8e82 cql3: add stringifying operators
Helps during debugging.
2015-03-12 10:10:43 +02:00
Avi Kivity
08b07f5093 cql3: add helpers to assignment_testable
Less qualification needed.
2015-03-12 10:10:43 +02:00
Avi Kivity
49a93b333b cql: pass operations by reference to specializedColumnOperation
If we want our

   set map[key] = value

operation to work, we better return it from the parser.
2015-03-12 09:56:53 +02:00
Tomasz Grabiec
3db3207b85 Merge branch seastar-dev.git 'collections'
Collections support from Avi.
2015-03-05 20:25:48 +01:00
Avi Kivity
a6b692612a cql3: convert grammer for setting a collection element 2015-03-05 18:11:37 +02:00
Avi Kivity
1fcce7cdcb cql3: convert operation::set_element 2015-03-05 18:11:37 +02:00
Avi Kivity
7a94b0c0a3 cql3: convert maps::setter_by_key
Basic operation to set a single map element to a value.
2015-03-05 18:11:31 +02:00
Avi Kivity
4602d86dc9 cql3: convert maps::key_spec_of/maps::value_spec_of 2015-03-05 15:31:52 +02:00
Pekka Enberg
817486d27f cql3: Convert schema_altering_statement::execute() to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-05 15:06:31 +02:00
Avi Kivity
bb58deadc0 cql3: add virtual destructor to class operation 2015-03-05 14:03:36 +02:00
Pekka Enberg
c72f5796c4 cql3: Fix create_keyspace_statement::prepare()
Move enable_shared_from_this to the concrete create_keyspace_statement
class to make sure prepare() instantiates the right type. Fixes "pure
virtual method called" errors when calling create_keyspace_statement
methods that are pure virtual in the base class.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-05 12:20:39 +01:00
Avi Kivity
a49330095a db: wrap bytes in atomic_cell format
We use bytes for many different things, and it is easy to get confused as
to what format the data is actually in.

Fix that for atomic_cell by proving wrappers.  atomic_cell::one corresponds
to a bytes object holding exactly one atomic cell, and atomic_cell::view is
a bytes_view to an atomic_cell.  The static functions of atomic_cell itself
are privatized to prevent the unwashed masses from using them on the wrong
objects.

Since a row entry can hold either a an atomic cell, or a collection,
depending on the schema, also introduce a variant type
atomic_cell_or_collection and allow the user to pick the type explicitly.
Internally both are stored as bytes object.
2015-03-04 15:49:35 +02:00
Nadav Har'El
6f2a2529a2 add "double" and "float" types
Implement "double" and "float" cql types.

This implementation doesn't touch serialization.hh (which should be
eventually removed) and rather follows the other examples in types.cc.
It is relatively ugly, because of all the cleverness of our "general"
byte swapping implementation actually works only for integer types, and
we need to get it to work for float/double as well.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-04 10:54:19 +01:00
Pekka Enberg
6751f7a305 cql3/Cql.g: Create keyspace statement
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
4b384ef705 cql3/Cql.g: Properties
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
79caf1bc95 cql3: Fix schema_altering_statement::uses_function()
The schema_altering_statement class must implement
cql_statement::uses_function() to be instantiable.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
8e0903fdbd cql3: Convert statements.CreateKeyspaceStatement to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:57:43 +02:00
Pekka Enberg
48f21ff39b cql3: Convert statements.PropertyDefinitions to C++, take 2
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-03 11:30:18 +02:00
Tomasz Grabiec
74295a9759 db: Use opaque bytes for cell values instead of boost::any
Storing cells as boost::any objects makes us use expensive
boost::any_cast to access the data. This change replaces boost::any
with bytes object which holds the value in serialized form (the same
as will be used for on-wire format).

If the cell type is atomic, you use fields accessors defined in
atomic_cell class, eg like this:

if (column.type.is_atomic()) {
   if (atomic_cell::is_live(c) {
      auto timestamp = atomic_cell::timestamp(c);
      ...
   }
}

Eventually we could switch to a more officient semi-serialized form
with native byte order but I don't want to introduce it just yet for
simplicity.
2015-02-27 10:59:43 +01:00
Tomasz Grabiec
1a0ffdfb99 schema: Encapsulate column sets 2015-02-27 10:48:56 +01:00
Tomasz Grabiec
b77367dabe cql3: Simplify primary key membership checks 2015-02-27 10:48:56 +01:00
Tomasz Grabiec
609e893055 unimplemented: Separate subject from behavior
You can now do:

  fail(unimplemented::cause::PAGING);

and:

  warn(unimplemented::cause::PAGING);
2015-02-27 10:48:56 +01:00
Tomasz Grabiec
1dfc7267db cql3: Fix formatting in relation.hh 2015-02-27 10:46:05 +01:00
Nadav Har'El
8701273006 Add inet type
In v2: rebase, and add a more descriptive exception if trying to deserialize
an ipv6 address.

Add to list of types the Internet address type, known as INET in CQL
or as InetAddressType in the Cassandra code.

I based this code on stuff I found in InetAddressType and
InetAddressSerializer in the Cassandra code.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-25 15:57:05 +01:00
Tomasz Grabiec
ec262ab3e9 cql3: Fix use-after-free on statement
Reported by Pekka:

READ of size 8 at 0x611000062ee8 thread T6
    #0 0x64d20f in std::unique_ptr<cql3::attributes, std::default_delete<cql3::attributes> >::get() const /usr/include/c++/4.9.2/bits/unique_ptr.h:305
    #1 0x641532 in std::unique_ptr<cql3::attributes, std::default_delete<cql3::attributes> >::operator->() const /usr/include/c++/4.9.2/bits/unique_ptr.h:299
    #2 0x63af5b in cql3::statements::modification_statement::get_time_to_live(cql3::query_options const&) const cql3/statements/modification_statement.hh:190
    #3 0x61e072 in _ZZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorI13basic_sstringIcjLj31EESaIS5_EEES2_IS3_INSt12experimental8optionalIS5_EESaISB_EEERKNS_13query_optionsEblENKUlT_E_clINSA_ISt13unordered_mapIS5_St3mapIjN5boost3anyESt4lessIjESaISt4pairIKjSO_EEE15serialized_hash16serialized_equalSaISR_IKS5_SV_EEEEEEEDaSI_ (/home/penberg/urchin/build/debug/seastar+0x61e072)
    #4 0x625ce1 in apply core/apply.hh:34
    #5 0x625df4 in apply<cql3::statements::modification_statement::make_update_parameters(lw_shared_ptr<std::vector<basic_sstring<char, unsigned int, 31u> > >, lw_shared_ptr<std::vector<std::experimental::optional<basic_sstring<char, unsigned int, 31u> > > >, const cql3::query_options&, bool, int64_t)::<lambda(auto:18)>, std::experimental::optional<std::unordered_map<basic_sstring<char, unsigned int, 31u>, std::map<unsigned int, boost::any, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, boost::any> > >, serialized_hash, serialized_equal, std::allocator<std::pair<const basic_sstring<char, unsigned int, 31u>, std::map<unsigned int, boost::any, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, boost::any> > > > > > > > core/apply.hh:41
    #6 0x628354 in _ZZN6futureIINSt12experimental8optionalISt13unordered_mapI13basic_sstringIcjLj31EESt3mapIjN5boost3anyESt4lessIjESaISt4pairIKjS7_EEE15serialized_hash16serialized_equalSaISA_IKS4_SE_EEEEEEE4thenIZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorIS4_SaIS4_EEESR_ISS_INS1_IS4_EESaISW_EEERKNSO_13query_optionsEblEUlT_E_EENSt9result_ofIFT_OSL_EE4typeEOS16_NSt9enable_ifIXsr9is_futureIIS1A_EE5valueEPvE4typeEENUlRS13_E_clI12future_stateIISL_EEEEDaRS16_ (/home/penberg/urchin/build/debug/seastar+0x628354)
    #7 0x628503 in _ZZN6futureIINSt12experimental8optionalISt13unordered_mapI13basic_sstringIcjLj31EESt3mapIjN5boost3anyESt4lessIjESaISt4pairIKjS7_EEE15serialized_hash16serialized_equalSaISA_IKS4_SE_EEEEEEE8scheduleIZNSM_4thenIZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorIS4_SaIS4_EEESS_IST_INS1_IS4_EESaISX_EEERKNSP_13query_optionsEblEUlT_E_EENSt9result_ofIFT_OSL_EE4typeEOS17_NSt9enable_ifIXsr9is_futureIIS1B_EE5valueEPvE4typeEEUlRS14_E_EEvS1C_EN21task_with_ready_state3runEv (/home/penberg/urchin/build/debug/seastar+0x628503)
    #8 0x7a6600 in reactor::run_tasks(circular_buffer<std::unique_ptr<task, std::default_delete<task> >, std::allocator<std::unique_ptr<task, std::default_delete<task> > > >&, unsigned long) core/reactor.cc:691
    #9 0x7a8ccc in reactor::run() core/reactor.cc:785
    #10 0x7b0bef in smp::configure(boost::program_options::variables_map)::{lambda()#1}::operator()() const (/home/penberg/urchin/build/debug/seastar+0x7b0bef)
    #11 0x84011d in _M_invoke /usr/include/c++/4.9.2/functional:2039
    #12 0x860c97 in std::function<void ()>::operator()() const /usr/include/c++/4.9.2/functional:2439
    #13 0x8e45fa in posix_thread::start_routine(void*) core/posix.cc:50
    #14 0x7f25abb05529 in start_thread (/lib64/libpthread.so.0+0x7529)
    #15 0x7f25ab84179c in __clone (/lib64/libc.so.6+0x10079c)

0x611000062ee8 is located 40 bytes inside of 216-byte region [0x611000062ec0,0x611000062f98)
freed by thread T6 here:
    #0 0x7f25af4bf64f in operator delete(void*) (/lib64/libasan.so.1+0x5864f)
    #1 0x684dbf in shared_ptr_count_for<cql3::statements::update_statement>::~shared_ptr_count_for() core/shared_ptr.hh:261
    #2 0x63de36 in shared_ptr<cql3::cql_statement>::~shared_ptr() core/shared_ptr.hh:326
    #3 0x772711 in cql3::statements::parsed_statement::prepared::~prepared() cql3/statements/parsed_statement.hh:60
    #4 0x77591d in std::default_delete<cql3::statements::parsed_statement::prepared>::operator()(cql3::statements::parsed_statement::prepared*) const /usr/include/c++/4.9.2/bits/unique_ptr.h:76
    #5 0x772cef in std::unique_ptr<cql3::statements::parsed_statement::prepared, std::default_delete<cql3::statements::parsed_statement::prepared> >::~unique_ptr() /usr/include/c++/4.9.2/bits/unique_ptr.h:236
    #6 0x76c8ea in cql3::query_processor::process(std::experimental::basic_string_view<char, std::char_traits<char> > const&, service::query_state&, cql3::query_options&) cql3/query_processor.cc:51
    #7 0x554e9c in cql_server::connection::process_query(unsigned short, temporary_buffer<char>) transport/server.cc:408
    #8 0x553a7a in cql_server::connection::process_request()::{lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)#1}::operator()(future<std::experimental::optional<cql_binary_frame_v3> >&&) const::{lambda(temporary_buffer<char>)#1}::operator()(temporary_buffer) const (/home/penberg/urchin/build/debug/seastar+0x553a7a)
    #9 0x55df9e in apply core/apply.hh:34
    #10 0x55e0b1 in apply<cql_server::connection::process_request()::<lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)>::<lambda(temporary_buffer<char>)>, temporary_buffer<char> > core/apply.hh:41
    #11 0x55e43b in then<cql_server::connection::process_request()::<lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)>::<lambda(temporary_buffer<char>)> > core/future.hh:480
    #12 0x5542c1 in cql_server::connection::process_request()::{lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)#1}::operator()(future<std::experimental::optional<cql_binary_frame_v3> >&&) const (/home/penberg/urchin/build/debug/seastar+0x5542c1)
    #13 0x564846 in _ZZNO6futureIINSt12experimental8optionalI19cql_binary_frame_v3EEEE12then_wrappedIZN10cql_server10connection15process_requestEvEUlOS4_E_EENSt9result_ofIFT_S4_EE4typeEOSB_ENUlRT_E_clI12future_stateIIS3_EEEEDaRSB_ (/home/penberg/urchin/build/debug/seastar+0x564846)
    #14 0x5649c7 in _ZZN7promiseIINSt12experimental8optionalI19cql_binary_frame_v3EEEE8scheduleIZNO6futureIIS3_EE12then_wrappedIZN10cql_server10connection15process_requestEvEUlOS7_E_EENSt9result_ofIFT_S7_EE4typeEOSE_EUlRT_E_EEvSI_EN15task_with_state3runEv (/home/penberg/urchin/build/debug/seastar+0x5649c7)
    #15 0x7a6600 in reactor::run_tasks(circular_buffer<std::unique_ptr<task, std::default_delete<task> >, std::allocator<std::unique_ptr<task, std::default_delete<task> > > >&, unsigned long) core/reactor.cc:691
    #16 0x7a8ccc in reactor::run() core/reactor.cc:785
    #17 0x7b0bef in smp::configure(boost::program_options::variables_map)::{lambda()#1}::operator()() const (/home/penberg/urchin/build/debug/seastar+0x7b0bef)
    #18 0x84011d in _M_invoke /usr/include/c++/4.9.2/functional:2039
    #19 0x860c97 in std::function<void ()>::operator()() const /usr/include/c++/4.9.2/functional:2439
    #20 0x8e45fa in posix_thread::start_routine(void*) core/posix.cc:50
    #21 0x7f25abb05529 in start_thread (/lib64/libpthread.so.0+0x7529)

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-02-25 12:48:54 +01:00
Pekka Enberg
39f4a58bde cql3: Implement use_statement::execute()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 10:18:18 +01:00
Pekka Enberg
48e568af37 cql3/Cql.g: Convert comparatorType to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-24 15:56:16 +02:00
Pekka Enberg
91bd90db0a cql3/Cql.g: Convert mapLiteral rule to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-24 15:56:16 +02:00
Pekka Enberg
64957cb34e cql3: Convert CQL3Type.Raw to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-24 15:56:16 +02:00
Pekka Enberg
2cfc7a8908 cql3: Convert Maps.Literal to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-24 15:24:44 +02:00
Pekka Enberg
ebe5faaac4 cql3: Finish cfOrKsName rule conversion to C++
We support recognition errors now so finish up the job.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-24 14:47:09 +02:00
Avi Kivity
70381a6da5 db: distribute database object
s/database/distributed<database>/ everywhere.

Use simple distribution rules: writes are broadcast, reads are local.
This causes tremendous data duplication, but will change soon.
2015-02-19 17:53:13 +02:00
Tomasz Grabiec
204bb79d33 transport: Make CQL3 server use query_processor
This change also converts parsing of query options.
2015-02-16 12:27:04 +01:00
Tomasz Grabiec
8c013c8b1a cql3: Fix option types
Lost in translation.
2015-02-16 12:15:10 +01:00
Tomasz Grabiec
b23180b6be cql3: Convert QueryOptionsWrapper and QueryOptions.OptionsWithNames 2015-02-16 12:15:10 +01:00
Tomasz Grabiec
f074aa6a15 cql3: Add missing header inclusion guard 2015-02-16 12:00:03 +01:00
Tomasz Grabiec
14546bf5c5 cql3: Convert rules for parsing UPDATE statements 2015-02-12 19:40:59 +01:00
Tomasz Grabiec
87821f2d12 Add missing copyright banners 2015-02-12 19:40:59 +01:00
Tomasz Grabiec
572b61a2bb cql3: Convert more of ColumnCondition and ColumnCondition::Raw 2015-02-12 19:40:59 +01:00
Tomasz Grabiec
08eed72021 cql3: Convert more of SingleColumnRelation 2015-02-12 19:40:59 +01:00
Tomasz Grabiec
6ca084fdb3 cql3: Implement operator== for column_identifier::raw 2015-02-12 19:40:59 +01:00
Tomasz Grabiec
ee699bff1c cql3: Convert more of constants:: 2015-02-12 19:40:58 +01:00
Tomasz Grabiec
bd2892c8fb cql3: Cleanup code formatting 2015-02-12 19:40:58 +01:00