]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-sql: Remove unnecessary "affected rows" tracking from dict_set()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 14 Jan 2017 14:54:34 +0000 (16:54 +0200)
committerGitLab <gitlab@git.dovecot.net>
Sat, 14 Jan 2017 20:48:32 +0000 (22:48 +0200)
This was useful for dict_atomic_inc(), but not for dict_set().

Fixes assert-crash with Cassandra:
Panic: file driver-cassandra.c: line 1350 (driver_cassandra_update): assertion failed: (affected_rows == NULL)

src/lib-dict/dict-sql.c

index 36e06456a2d7dee1d70c55b1f65b7d230e14364a..b1000c56a292736bbfd1e9bfd7382eedef89553e 100644 (file)
@@ -70,8 +70,6 @@ struct sql_dict_transaction_context {
        const struct dict_sql_map *prev_set_map;
        char *prev_set_key;
        char *prev_set_value;
-       pool_t set_row_pool;
-       struct sql_dict_inc_row *set_row;
 
        dict_transaction_commit_callback_t *async_callback;
        void *async_context;
@@ -786,8 +784,6 @@ static void sql_dict_transaction_free(struct sql_dict_transaction_context *ctx)
 {
        if (ctx->inc_row_pool != NULL)
                pool_unref(&ctx->inc_row_pool);
-       if (ctx->set_row_pool != NULL)
-               pool_unref(&ctx->set_row_pool);
        i_free(ctx->prev_inc_key);
        i_free(ctx->error);
        i_free(ctx);
@@ -1065,6 +1061,8 @@ static void sql_dict_set_real(struct dict_transaction_context *_ctx,
 
        if (ctx->prev_inc_map != NULL)
                sql_dict_prev_inc_flush(ctx);
+       if (ctx->prev_set_map != NULL)
+               sql_dict_prev_set_flush(ctx);
 
        field.map = map;
        field.value = value;
@@ -1118,22 +1116,6 @@ static void sql_dict_unset(struct dict_transaction_context *_ctx,
        }
 }
 
-static unsigned int *
-sql_dict_next_set_row(struct sql_dict_transaction_context *ctx)
-{
-       struct sql_dict_inc_row *row;
-
-       if (ctx->set_row_pool == NULL) {
-               ctx->set_row_pool =
-                       pool_alloconly_create("sql dict set rows", 128);
-       }
-       row = p_new(ctx->set_row_pool, struct sql_dict_inc_row, 1);
-       row->prev = ctx->set_row;
-       row->rows = UINT_MAX;
-       ctx->set_row = row;
-       return &row->rows;
-}
-
 static unsigned int *
 sql_dict_next_inc_row(struct sql_dict_transaction_context *ctx)
 {
@@ -1292,8 +1274,7 @@ static void sql_dict_set(struct dict_transaction_context *_ctx,
                        ctx->error = i_strdup_printf(
                                "dict-sql: Failed to set %s: %s", key, error);
                } else {
-                       sql_update_get_rows(ctx->sql_ctx, query,
-                                           sql_dict_next_set_row(ctx));
+                       sql_update(ctx->sql_ctx, query);
                }
                i_free_and_null(ctx->prev_set_value);
                i_free_and_null(ctx->prev_set_key);