dovecot-1.1: dict sql: Iterated keys need to contain private/sha...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 11 23:55:42 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/3bda11abf5e1
changeset: 7631:3bda11abf5e1
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 11 23:55:36 2008 +0300
description:
dict sql: Iterated keys need to contain private/shared prefix.

diffstat:

1 file changed, 14 insertions(+), 1 deletion(-)
src/lib-dict/dict-sql.c |   15 ++++++++++++++-

diffs (53 lines):

diff -r 133874d84577 -r 3bda11abf5e1 src/lib-dict/dict-sql.c
--- a/src/lib-dict/dict-sql.c	Wed Jun 11 23:48:57 2008 +0300
+++ b/src/lib-dict/dict-sql.c	Wed Jun 11 23:55:36 2008 +0300
@@ -28,6 +28,8 @@ struct sql_dict_iterate_context {
 	struct dict_iterate_context ctx;
 
 	struct sql_result *result;
+	char *prev_key;
+	bool priv;
 };
 
 struct sql_dict_transaction_context {
@@ -220,6 +222,8 @@ sql_dict_iterate_init(struct dict *_dict
 		ctx->result = NULL;
 		return &ctx->ctx;
 	}
+	ctx->priv = priv;
+
 	T_BEGIN {
 		string_t *query = t_str_new(256);
 		str_printfa(query, "SELECT %s, %s FROM %s WHERE ",
@@ -268,6 +272,7 @@ static int sql_dict_iterate(struct dict_
 {
 	struct sql_dict_iterate_context *ctx =
 		(struct sql_dict_iterate_context *)_ctx;
+	const char *key;
 	int ret;
 
 	if (ctx->result == NULL)
@@ -276,7 +281,14 @@ static int sql_dict_iterate(struct dict_
 	if ((ret = sql_result_next_row(ctx->result)) <= 0)
 		return ret;
 
-	*key_r = sql_result_get_field_value(ctx->result, 0);
+	key = sql_result_get_field_value(ctx->result, 0);
+	i_free(ctx->prev_key);
+	if (ctx->priv)
+		ctx->prev_key = i_strconcat(DICT_PATH_PRIVATE, key, NULL);
+	else
+		ctx->prev_key = i_strconcat(DICT_PATH_SHARED, key, NULL);
+
+	*key_r = ctx->prev_key;
 	*value_r = sql_result_get_field_value(ctx->result, 1);
 	return 1;
 }
@@ -287,6 +299,7 @@ static void sql_dict_iterate_deinit(stru
 		(struct sql_dict_iterate_context *)_ctx;
 
 	sql_result_free(ctx->result);
+	i_free(ctx->prev_key);
 	i_free(ctx);
 }
 


More information about the dovecot-cvs mailing list