Fix limit/offset handling when sort option is no sort.
Review Request #125544 - Created Oct. 7, 2015 and submitted
The bug is obvious, old code uses limit instead of (limit > 0), which gracefully handles limit < 0 case (means everything).
After offset is introduced, limit < 0 case is not handled properly.
This patch contains following changes:
1. make offset uint, m_offset is uint in Query already.
2. handle limit < 0 case properly.
Also fix offset with sorting.
baloosearch:/ doesn't return anything because of this, now it properly returns result.
Play with baloosearch command a little bit, offset and limit returns the [offset, offset + limit) and no crash on the border case.
I'm adding the release team since maybe we can delay the release of Baloo or make a special bug fix release with this patch. Shipping Baloo with a broken kioslave is not good.
Say we have 50 results
limit = 10
offset = 5
So we want results from [5, 14]
With this code -
for (i = 5; i < 10; i++)
We we would get [5, 10). Could you please fix this? I think a simple
i < limit + offsetwould do.
The entire code in this else case is absolutely rubbish. The person implementing it should feel bad (me).
We seem to be completly ignoring the offset over here.
Status: Closed (submitted)
Submitted with commit 64c57e56fe3392cf057ac2948cddb1e5a011a0c1 by Weng Xuetian to branch master.