Cherrypick changes [53f5cfe115] and [1f7ef0af8d] in order to fix an issue with DISTINCT
Cherrypick the [3513bf6ee090d9] so that the sqlite_source_id() function works correctly even with newer versions of Fossil
Backport check-in [62678be3df35cd]:
When the same index is used for all OR-terms in a WHERE clause, then try to
use that index as a covering index.