From: Timo Sirainen Date: Thu, 25 Feb 2021 15:19:49 +0000 (+0200) Subject: dict-sql: Keep trying to merge INSERT/UPDATE always to the previous key X-Git-Tag: 2.3.15~318 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69a1c091d30701230fdc09b5b6650858e71dd22e;p=thirdparty%2Fdovecot%2Fcore.git dict-sql: Keep trying to merge INSERT/UPDATE always to the previous key Previously if the first two couldn't be merged, it would flush both. Now it flushes only the first and attempts to merge the 2nd and 3rd. --- diff --git a/src/lib-dict-backend/dict-sql.c b/src/lib-dict-backend/dict-sql.c index db94b6aada..c76a4f54bf 100644 --- a/src/lib-dict-backend/dict-sql.c +++ b/src/lib-dict-backend/dict-sql.c @@ -1381,6 +1381,13 @@ static void sql_dict_set(struct dict_transaction_context *_ctx, return; } + if (ctx->prev_set != NULL && + !sql_dict_maps_are_mergeable(dict, ctx->prev_set, + map, key, &values)) { + /* couldn't merge to the previous set - flush it */ + sql_dict_prev_set_flush(ctx); + } + if (ctx->prev_set == NULL) { /* see if we can merge this increment SQL query with the next one */ @@ -1391,11 +1398,8 @@ static void sql_dict_set(struct dict_transaction_context *_ctx, return; } - if (!sql_dict_maps_are_mergeable(dict, ctx->prev_set, - map, key, &values)) { - sql_dict_prev_set_flush(ctx); - sql_dict_set_real(&ctx->ctx, key, value); - } else { + /* merge with prev_set */ + { struct dict_sql_build_query build; struct dict_sql_build_query_field *field; struct sql_statement *stmt; @@ -1448,6 +1452,13 @@ static void sql_dict_atomic_inc(struct dict_transaction_context *_ctx, return; } + if (ctx->prev_inc != NULL && + !sql_dict_maps_are_mergeable(dict, ctx->prev_inc, + map, key, &values)) { + /* couldn't merge to the previous inc - flush it */ + sql_dict_prev_inc_flush(ctx); + } + if (ctx->prev_inc == NULL) { /* see if we can merge this increment SQL query with the next one */ @@ -1458,11 +1469,8 @@ static void sql_dict_atomic_inc(struct dict_transaction_context *_ctx, return; } - if (!sql_dict_maps_are_mergeable(dict, ctx->prev_inc, - map, key, &values)) { - sql_dict_prev_inc_flush(ctx); - sql_dict_atomic_inc_real(ctx, key, diff); - } else { + /* merge with prev_inc */ + { struct dict_sql_build_query build; struct dict_sql_build_query_field *field; ARRAY_TYPE(sql_dict_param) params;