Commit Graph

36 Commits

Author SHA1 Message Date
Pekka Enberg
be0351b49c cql3: Introduce raw_value and raw_value_view types
Currently, the code is using bytes_opt and bytes_view_opt to represent
CQL values, which can hold a value or null. In preparation for
supporting a third state, unset value introduced in CQL v4, introduce
new raw_value and raw_value_view types and use them instead.

The new types are based on boost::variant<> and are capable of holding
null, unset values, and blobs that represent a value.
2017-01-26 13:50:04 +02:00
Avi Kivity
1d1b03a7cb cql3: change sprint() of a pointer to use void* explicitly
Otherwise, fmtlib dislikes it.
2016-07-18 19:36:35 +03: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
9d11968ad8 Rename serialization_format to cql_serialization_format 2016-02-15 16:53:56 +01:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Pekka Enberg
9f2bcc6a77 cql3: Change bind_and_get() return type to bytes_view_opt
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +03:00
Pekka Enberg
d50139351f cql3: Use pragma once everywhere
There's no benefit to using C include guards so switch to pragma once
everywhere for consistency.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-12 16:32:56 +03:00
Avi Kivity
3d38708434 cql3: pass a database& instance to most foo::raw::prepare() variants
To prepare a user-defined type, we need to look up its name in the keyspace.
While we get the keyspace name as an argument to prepare(), it is useless
without the database instance.

Fix the problem by passing a database reference along with the keyspace.
This precolates through the class structure, so most cql3 raw types end up
receiving this treatment.

Origin gets along without it by using a singleton.  We can't do this due
to sharding (we could use a thread-local instance, but that's ugly too).

Hopefully the transition to a visitor will clean this up.
2015-04-20 16:15:34 +03:00
Avi Kivity
6a89d8291f cql3: fix multi_item_terminal::get_elements() signature
A tuple is a multi_item_terminal that can contain NULLs, so we need to
return a vector of bytes_opt, not bytes.

Unfortunately the lists code needs to be uglified as a result.
2015-04-15 15:35:30 +03:00
Avi Kivity
c9d3a06157 cql3: fix multi_column_raw::prepare() signature
Wants a shared_ptr<column_specification>, not a reference.  Arguably
column_specification should be made into a value type.

Luckily no users yet.
2015-04-15 15:35:30 +03:00
Avi Kivity
874249800d cql3: provide ostream operator for assignment_testable
To prevent name clashes, we don't call the virtual function implementing
this to_string(), but rather assignment_testable_source_context(), as its
use will be error reporting.
2015-04-01 20:12:39 +03:00
Avi Kivity
4f94829792 cql3: reindent term.hh 2015-03-31 13:03:44 +03:00
Tomasz Grabiec
10a01c31d4 cql3: Implement operator<< for base classes defining to_string() methods 2015-03-23 11:00:54 +01:00
Tomasz Grabiec
375f1db51a cql3: Add const qulifier to to_string() methods 2015-03-23 11:00:54 +01:00
Pekka Enberg
cb6aa2f0b5 cql3: Fix abstract_marker::to_string()
Needed to be able to instantiate abstract_marker class.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-18 11:55:26 +02:00
Avi Kivity
6fee695095 db: replace most uses of protocol_version with serialization_format
Better type safety.
2015-03-16 18:15:16 +02:00
Tomasz Grabiec
2ee58d66d6 Merge tag 'avi/collections/v3'
Conflicts:
	tests/urchin/cql_query_test.cc

[tgrabiec: fixed compilation error in cql3/maps.hh]
2015-03-12 11:30:17 +01:00
Avi Kivity
a64cd8f22f cql3: convert maps::literal to C++ 2015-03-12 10:22:17 +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
Tomasz Grabiec
7596a735f2 cql3: Add term::to_string()
There is some code which tries to print a term. Some terms are
printable, but not all of them. Those who don't override to_string()
will get the default implementation.
2015-03-11 14:56:10 +01:00
Tomasz Grabiec
3a2bf359b8 cql3: Add to_string() virtual method to terminal class 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
f450264a26 cql3: Remove duplicated definition of bytes_opt 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
e589d71a89 cql3: add missing virtual destructors 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
d243fb7a01 cql3: Pass sstrings as const& where applicable 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
fc2d98431a cql3: Implement some to_string() methods 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
d8982abf81 cql3: Allow bind_and_get() to return an optional value
In Origin it can be null and it has a different meaning than empty
value. See org.apache.cassandra.cql3.Constants.Setter#execute.
2015-01-29 19:41:00 +01:00
Avi Kivity
d1210a2daa cql3: add missing include to term.hh 2015-01-12 11:17:43 +02:00
Pekka Enberg
8ded99fdfa cql3: convert AbstractMarker to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-09 13:00:16 +02:00
Pekka Enberg
f235479a2c cql3: Fix term::contains_bind_marker() type signature
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-09 13:00:16 +02:00
Pekka Enberg
f59e47a5d0 cql3: Fix missing includes in term.hh
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-09 13:00:16 +02:00
Pekka Enberg
11491423ac cql3: Use enable_shared_from_this to clean up API
Initial conversion introduced a synthetic shared_ptr as the first
parameter. This deviates from Cassandra's API so switch to
enable_shared_from_this instead.

Suggested by Avi.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 17:26:18 +02:00
Pekka Enberg
56cc7a253a cql3: Fix term::prepare() type signature
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 17:05:28 +02:00
Pekka Enberg
0b77fae1c7 cql3: Switch to our own shared_ptr
It's already used by core code so make life easier for us and just
switch to it.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 13:58:54 +02:00
Pekka Enberg
a78c5b46b2 cql3: Fix term::bind() type signature
The first argument is a synthetic this pointer that we require users to
pass around. Change it to shared_ptr<term> instead to make it accessible
to all callers.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-05 12:39:30 +02:00
Pekka Enberg
9292815bd9 cql3: convert Term to C++
This is not 1:1 conversion because some Term inner classes derive from
Term itself which is not allowed in C++. I therefore moved some of the
inner class definitions outside of Term.

Another painpoint is Terminal.bind() method which returns 'this'. I
changed the API to require callers to pass shared_ptr<terminal> which is
returned in place of 'this'. I went for shared_ptr because I wasn't able
to convince myself that the lifetime rules allow unique_ptr...

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-04 10:42:52 +02:00