Jean Giard
unread,Feb 6, 2015, 6:28:06 AM2/6/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cpp-dri...@lists.datastax.com
Hi,
I found an error using the driver when I try to bind empty collections into statements.
with a table like
CREATE TABLE antidot.click_metas (
query text PRIMARY KEY,
metas map<text, text>
)
and the query
UPDATE foo SET data=? WHERE query=?
when and prepare a statement, and bind an empty collection and then an non-empty string I get the error
1423221545.492 [ERROR] (src/statement.cpp:371:int32_t cass::decode_buffer_size(const cass::Buffer&)): Routing key cannot contain an empty value or a collection
The query UPDATE foo SET data={} WHERE query='bar' work fine with cqlsh.
It looks like the driver believe that 'data' is part of the primary key, is there something I'm not doing right ?
I am using the last driver from the 1.0 branch (sha1 7de3f51), with libuv from branch 1.x and cassandra 2.1.2
below is a function reproducing the problem
void print_error(CassFuture* future)
{
CassString message = cass_future_error_message(future);
std::cerr << string(message.data, message.length) << std::endl;
}
void test_collection(string host, string keyspace)
{
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();
cass_cluster_set_contact_points(cluster, host.c_str());
CassFuture* connect_future = cass_session_connect_keyspace(session, cluster, keyspace.c_str());
if (cass_future_error_code(connect_future) == CASS_OK) {
{
CassString query = cass_string_init("CREATE TABLE IF NOT EXISTS foo (query text PRIMARY KEY, data map<text, text>)");
CassStatement* statement = cass_statement_new(query, 0);
CassFuture* result_future = cass_session_execute(session, statement);
if(cass_future_error_code(result_future) != CASS_OK) {
print_error(result_future);
return;
}
cass_statement_free(statement);
cass_future_free(result_future);
}
{
CassString query = cass_string_init("UPDATE foo SET data=? WHERE query=?");
CassFuture* future = cass_session_prepare(session, query);
cass_future_wait(future);
CassError rc = cass_future_error_code(future);
if (rc != CASS_OK)
{
print_error(future);
return;
}
const CassPrepared* prepared = cass_future_get_prepared(future);
CassStatement* statement = cass_prepared_bind(prepared);
cass_future_free(future);
CassCollection* collection = cass_collection_new(CASS_COLLECTION_TYPE_MAP, 0);
cass_statement_bind_collection(statement, 0, collection);
cass_statement_bind_string(statement, 1, cass_string_init("bar"));
future = cass_session_execute(session, statement);
cass_future_wait(future);
rc = cass_future_error_code(future);
if (rc != CASS_OK)
{
print_error(future);
return;
}
cass_collection_free(collection);
}
CassFuture* close_future = cass_session_close(session);
cass_future_wait(close_future);
cass_future_free(close_future);
} else {
print_error(connect_future);
return;
}
cass_future_free(connect_future);
cass_cluster_free(cluster);
cass_session_free(session);
}