Merge remote-tracking branch 'dev/penberg/cql-cleanups'

This commit is contained in:
Tomasz Grabiec
2015-03-20 12:20:51 +01:00
4 changed files with 10 additions and 27 deletions

View File

@@ -185,7 +185,7 @@ public:
if (!bytes) {
return ::shared_ptr<terminal>{};
}
return ::make_shared<constants::value>(bytes);
return ::make_shared<constants::value>(std::move(bytes));
}
};

View File

@@ -38,6 +38,8 @@ using namespace transport::messages;
thread_local logging::logger log("query_processor");
const sstring query_processor::CQL_VERSION = "3.2.0";
future<::shared_ptr<result_message>>
query_processor::process(const sstring_view& query_string, service::query_state& query_state, query_options& options)
{

View File

@@ -45,9 +45,9 @@ private:
public:
query_processor(service::storage_proxy& proxy, distributed<database>& db) : _proxy(proxy), _db(db) {}
#if 0
public static final SemanticVersion CQL_VERSION = new SemanticVersion("3.2.0");
static const sstring CQL_VERSION;
#if 0
public static final QueryProcessor instance = new QueryProcessor();
#endif
private:

View File

@@ -82,24 +82,6 @@ enum class cql_binary_opcode : uint8_t {
AUTH_SUCCESS = 16,
};
enum class cql_binary_error {
SERVER_ERROR = 0x0000,
PROTOCOL_ERROR = 0x000A,
BAD_CREDENTIALS = 0x0100,
UNAVAILABLE = 0x1000,
OVERLOADED = 0x1001,
IS_BOOTSTRAPPING = 0x1002,
TRUNCATE_ERROR = 0x1003,
WRITE_TIMEOUT = 0x1100,
READ_TIMEOUT = 0x1200,
SYNTAX_ERROR = 0x2000,
UNAUTHORIZED = 0x2100,
INVALID = 0x2200,
CONFIG_ERROR = 0x2300,
ALREADY_EXISTS = 0x2400,
UNPREPARED = 0x2500,
};
inline db::consistency_level wire_to_consistency(int16_t v)
{
switch (v) {
@@ -180,7 +162,7 @@ private:
future<> process_batch(uint16_t stream, temporary_buffer<char> buf);
future<> process_register(uint16_t stream, temporary_buffer<char> buf);
future<> write_error(int16_t stream, cql_binary_error err, sstring msg);
future<> write_error(int16_t stream, exceptions::exception_code err, sstring msg);
future<> write_ready(int16_t stream);
future<> write_supported(int16_t stream);
future<> write_result(int16_t stream, shared_ptr<transport::messages::result_message> msg);
@@ -377,9 +359,9 @@ future<> cql_server::connection::process_request() {
try {
f.get();
} catch (std::exception& ex) {
write_error(stream, cql_binary_error::SERVER_ERROR, ex.what());
write_error(stream, exceptions::exception_code::SERVER_ERROR, ex.what());
} catch (...) {
write_error(stream, cql_binary_error::SERVER_ERROR, "unknown error");
write_error(stream, exceptions::exception_code::SERVER_ERROR, "unknown error");
}
});
});
@@ -489,7 +471,7 @@ future<> cql_server::connection::process_register(uint16_t stream, temporary_buf
return write_ready(stream);
}
future<> cql_server::connection::write_error(int16_t stream, cql_binary_error err, sstring msg)
future<> cql_server::connection::write_error(int16_t stream, exceptions::exception_code err, sstring msg)
{
auto response = make_shared<cql_server::response>(stream, cql_binary_opcode::ERROR);
response->write_int(static_cast<int32_t>(err));
@@ -506,8 +488,7 @@ future<> cql_server::connection::write_ready(int16_t stream)
future<> cql_server::connection::write_supported(int16_t stream)
{
std::multimap<sstring, sstring> opts;
opts.insert({"CQL_VERSION", "3.0.0"});
opts.insert({"CQL_VERSION", "3.2.0"});
opts.insert({"CQL_VERSION", cql3::query_processor::CQL_VERSION});
opts.insert({"COMPRESSION", "snappy"});
auto response = make_shared<cql_server::response>(stream, cql_binary_opcode::SUPPORTED);
response->write_string_multimap(opts);