Clean up the proper-subset cost adjustment logic to make it more compact
and easier to read and so that full branch test coverage is more easily
obtained.
Avoid discarding an ORDER BY clause in the case where an identical GROUP BY clauses uses an index to group, but not sort, the rows. Fix for [b75a9ca6b0].
Comment tweaks on the test case for the [b75a9ca6b0] bug fix.
Merge all recent trunk changes into the threads branch.