unexpected behaviour of search queries with mixed AND and OR

Aki Tuomi aki.tuomi at dovecot.fi
Wed Dec 14 10:50:26 UTC 2016



On 14.12.2016 12:18, Juergen Raschke wrote:
> Hello,
>
>
> I found out an unexpected behaviour of search queries with mixed
> "AND" and "OR".
>
>
> With search query "\( condA OR condB condC \)" I get an error:
> Fatal: Use parenthesis when mixing ANDs and ORs
>
> if I switch left and right OR-part and use the query
> "\( condB condC OR condA \)"
>
> I get a result, but it is not the expected result of the query
> "\( \( condB condC \) OR condA \)"
>
> I get the result of the query
> "\( condB OR condC OR condA \)"
> which is more then suprising.
>
>
> The query "\( condB condC OR condA \)" should either throw an
> error like "\( condA OR condB condC \)" or deliever the result
> of "\( \( condB condC \) OR condA \)"
>
>
>
>
> Example:
>
> doveadm -f flow  fetch -u USER  guid  \( savedbefore 21d OR seen savedbefore 5d \) | wc -l
> Fatal: Use parenthesis when mixing ANDs and ORs
> 0
>
> doveadm -f flow  fetch -u USER  guid  \( seen savedbefore 5d OR savedbefore 21d \) | wc -l
> 63690
>
> doveadm -f flow  fetch -u USER  guid  \( seen OR savedbefore 5d OR savedbefore 21d \) | wc -l
> 63690
>
> doveadm -f flow  fetch -u USER  guid  \( \( seen savedbefore 5d \) OR savedbefore 21d \) |wc -l
> 63247
>
> doveadm -f flow  fetch -u USER  guid  \( savedbefore 21d OR \( seen savedbefore 5d \) \) |wc -l
> 63247
>
>
>
> doveconf -n
> # 2.2.24 (a82c823): /etc/dovecot/dovecot.conf
> # Pigeonhole version 0.4.9 (357ac0a0e68b+)
> # OS: Linux 3.16.0-0.bpo.4-amd64 x86_64 Debian 7.9
>
>
>
>
>
> Mit freundlichen Gruessen,
>
> Juergen Raschke
>

Hi!

We believe this has been fixed in

https://github.com/dovecot/core/commit/df8046c9a4f6bc2a478ad1e74504d50f3110c906

Aki Tuomi
Dovecot oy


More information about the dovecot mailing list