# HG changeset patch # User Timo Sirainen # Date 1503562412 -10800 # Node ID db43860e2b1267e78c94070257b47e5e0921f90c # Parent 33f66557b72e8b72669459a5c2845aa433c02c38 cassandra: sql_transaction_commit_s() - Set query_type correctly The queries were all sent with READ type instead of WRITE/DELETE. This meant they were using potentially wrong consistency values. Although synchronous commits aren't actually used anywhere, so this practically this doesn't fix anything right now. diff -r 33f66557b72e -r db43860e2b12 src/lib-sql/driver-cassandra.c --- a/src/lib-sql/driver-cassandra.c Thu Aug 24 11:09:05 2017 +0300 +++ b/src/lib-sql/driver-cassandra.c Thu Aug 24 11:13:32 2017 +0300 @@ -1118,7 +1118,8 @@ } static struct sql_result * -driver_cassandra_sync_query(struct cassandra_db *db, const char *query) +driver_cassandra_sync_query(struct cassandra_db *db, const char *query, + enum cassandra_query_type query_type) { struct sql_result *result; @@ -1135,7 +1136,8 @@ break; } - driver_cassandra_query(&db->api, query, cassandra_query_s_callback, db); + driver_cassandra_query_full(&db->api, query, query_type, + cassandra_query_s_callback, db); if (db->sync_result == NULL) { db->io_pipe = io_loop_move_io(&db->io_pipe); io_loop_run(db->ioloop); @@ -1160,7 +1162,8 @@ struct sql_result *result; driver_cassandra_sync_init(db); - result = driver_cassandra_sync_query(db, query); + result = driver_cassandra_sync_query(db, query, + CASSANDRA_QUERY_TYPE_READ); driver_cassandra_sync_deinit(db); return result; } @@ -1490,13 +1493,21 @@ driver_cassandra_try_commit_s(struct cassandra_transaction_context *ctx) { struct sql_transaction_context *_ctx = &ctx->ctx; + struct cassandra_db *db = (struct cassandra_db *)_ctx->db; struct sql_transaction_query *single_query = NULL; struct sql_result *result = NULL; + enum cassandra_query_type query_type; if (_ctx->head->next == NULL) { /* just a single query, send it */ single_query = _ctx->head; - result = sql_query_s(_ctx->db, single_query->query); + if (strncasecmp(_ctx->head->query, "DELETE ", 7) == 0) + query_type = CASSANDRA_QUERY_TYPE_DELETE; + else + query_type = CASSANDRA_QUERY_TYPE_WRITE; + driver_cassandra_sync_init(db); + result = driver_cassandra_sync_query(db, single_query->query, query_type); + driver_cassandra_sync_deinit(db); } else { /* multiple queries - we don't actually have a transaction though */ transaction_set_failed(ctx, "Multiple changes in transaction not supported");