From: Timo Sirainen Date: Wed, 2 Sep 2015 16:38:35 +0000 (+0300) Subject: dict-sql: Fixed iteration with DICT_ITERATE_FLAG_NO_VALUE X-Git-Tag: 2.2.19.rc1~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce06a5036933a4655b660e5f69afa303c7c35d60;p=thirdparty%2Fdovecot%2Fcore.git dict-sql: Fixed iteration with DICT_ITERATE_FLAG_NO_VALUE --- diff --git a/src/lib-dict/dict-sql.c b/src/lib-dict/dict-sql.c index 614316a2ec..7e1325fa24 100644 --- a/src/lib-dict/dict-sql.c +++ b/src/lib-dict/dict-sql.c @@ -573,7 +573,7 @@ static bool sql_dict_iterate(struct dict_iterate_context *_ctx, str_append_c(ctx->key, '/'); count = sql_result_get_fields_count(ctx->result); - i = 1; + i = (ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0 ? 0 : 1; for (p = ctx->map->pattern + ctx->pattern_prefix_len; *p != '\0'; p++) { if (*p != '$') str_append_c(ctx->key, *p); @@ -587,7 +587,10 @@ static bool sql_dict_iterate(struct dict_iterate_context *_ctx, } *key_r = str_c(ctx->key); - *value_r = sql_result_get_field_value(ctx->result, 0); + if ((ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0) + *value_r = ""; + else + *value_r = sql_result_get_field_value(ctx->result, 0); return TRUE; }