changeset 22690:b66965f62ae8

lib-storage: Fix sorting mails with the same primary sort key The sorting order may have been wrong when there was a combination of: * Messages were sorted by a string (e.g. Subject) * Some messages had the same sort key (e.g. same base subject) * Within the messages with the same sort key, some of the messages already had the "sort-*" index number in Dovecot indexes, but some of them didn't. The result was that Dovecot found that the two messages had exactly the same sort key. It should have continued with the secondary sort key (e.g. message sequence number), but it didn't.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 24 Nov 2017 12:31:22 +0200
parents ac58eecfb8b0
children dca05b22217b
files src/lib-storage/index/index-sort-string.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-sort-string.c	Mon Nov 27 11:58:39 2017 +0200
+++ b/src/lib-storage/index/index-sort-string.c	Fri Nov 24 12:31:22 2017 +0200
@@ -496,6 +496,11 @@
 			ret = 1;
 		}
 
+		if (ret == 0) {
+			ret = index_sort_node_cmp_type(ctx->program,
+					ctx->program->sort_program + 1,
+					znodes[zpos].seq, nznodes[nzpos].seq);
+		}
 		if (ret <= 0) {
 			array_append(&ctx->sorted_nodes, &znodes[zpos], 1);
 			prev_str = zstr;