dovecot-2.2: dict-sql: Fixed iteration with blob fields.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Sep 2 17:31:05 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/da570231062f
changeset: 19074:da570231062f
user: Timo Sirainen <tss at iki.fi>
date: Wed Sep 02 20:30:07 2015 +0300
description:
dict-sql: Fixed iteration with blob fields.
diffstat:
src/lib-dict/dict-sql.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diffs (64 lines):
diff -r 0453c466c601 -r da570231062f src/lib-dict/dict-sql.c
--- a/src/lib-dict/dict-sql.c Wed Sep 02 19:46:36 2015 +0300
+++ b/src/lib-dict/dict-sql.c Wed Sep 02 20:30:07 2015 +0300
@@ -44,7 +44,7 @@
string_t *key;
const struct dict_sql_map *map;
unsigned int key_prefix_len, pattern_prefix_len, next_map_idx;
- unsigned int path_idx;
+ unsigned int path_idx, sql_fields_start_idx;
bool failed;
};
@@ -358,11 +358,11 @@
static const char *
sql_dict_result_unescape_field(const struct dict_sql_map *map, pool_t pool,
struct sql_result *result, unsigned int result_idx,
- unsigned int field_idx)
+ unsigned int sql_field_idx)
{
const struct dict_sql_field *sql_field;
- sql_field = array_idx(&map->sql_fields, field_idx);
+ sql_field = array_idx(&map->sql_fields, sql_field_idx);
return sql_dict_result_unescape(sql_field->value_is_hexblob, pool,
result, result_idx);
}
@@ -516,6 +516,7 @@
i_assert(i > 0);
i--;
}
+ ctx->sql_fields_start_idx = i;
for (; i < count; i++)
str_printfa(query, "%s,", sql_fields[i].name);
str_truncate(query, str_len(query)-1);
@@ -613,7 +614,7 @@
struct sql_dict_iterate_context *ctx =
(struct sql_dict_iterate_context *)_ctx;
const char *p, *value;
- unsigned int i, field_i, count;
+ unsigned int i, sql_field_i, count;
int ret;
_ctx->has_more = FALSE;
@@ -653,17 +654,17 @@
count = sql_result_get_fields_count(ctx->result);
i = (ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0 ? 0 : 1;
- field_i = 0;
+ sql_field_i = ctx->sql_fields_start_idx;
for (p = ctx->map->pattern + ctx->pattern_prefix_len; *p != '\0'; p++) {
if (*p != '$')
str_append_c(ctx->key, *p);
else {
i_assert(i < count);
value = sql_dict_result_unescape_field(ctx->map,
- pool_datastack_create(), ctx->result, i, field_i);
+ pool_datastack_create(), ctx->result, i, sql_field_i);
if (value != NULL)
str_append(ctx->key, value);
- i++; field_i++;
+ i++; sql_field_i++;
}
}
More information about the dovecot-cvs
mailing list