]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-sql: Fixed iteration with DICT_ITERATE_FLAG_NO_VALUE
authorTimo Sirainen <tss@iki.fi>
Wed, 2 Sep 2015 16:38:35 +0000 (19:38 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 2 Sep 2015 16:38:35 +0000 (19:38 +0300)
src/lib-dict/dict-sql.c

index 614316a2ecfa52119842de7d0fc417cabc410cfc..7e1325fa248a6e661d87e85ad173c07004a6b7d3 100644 (file)
@@ -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;
 }