changeset 22355:d950ffd7cbe0

dict-sql: Add support for sql_result_more()
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 17 Jul 2017 17:54:36 +0300
parents b9a2a6135419
children 2fe6e07903f2
files src/lib-dict/dict-sql.c
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict-sql.c	Mon Jul 17 14:22:35 2017 +0300
+++ b/src/lib-dict/dict-sql.c	Mon Jul 17 17:54:36 2017 +0300
@@ -731,6 +731,21 @@
 	}
 
 	ret = sql_result_next_row(ctx->result);
+	while (ret == SQL_RESULT_NEXT_MORE) {
+		if ((ctx->flags & DICT_ITERATE_FLAG_ASYNC) == 0)
+			sql_result_more_s(&ctx->result);
+		else {
+			/* get more results asynchronously */
+			ctx->synchronous_result = TRUE;
+			sql_result_more(&ctx->result, sql_dict_iterate_callback, ctx);
+			ctx->synchronous_result = FALSE;
+			if (ctx->result == NULL) {
+				_ctx->has_more = TRUE;
+				return FALSE;
+			}
+		}
+		ret = sql_result_next_row(ctx->result);
+	}
 	if (ret == 0) {
 		/* see if there are more results in the next map.
 		   don't do it if we're looking for an exact match, since we