This is a better and less restrictive fix for the problem addressed by
the previous check-in.
FossilOrigin-Name: abcf6a5d054559ee5a093ba39180c47b4958d9cd
constraints on the inner loop match terms of an outer ordered index that
are actually used by the ORDER BY clause.
FossilOrigin-Name: b0e7b4df6c2a8c479f8d210bde50c737eaa248f0
Some test cases fail, but except for the new orderby1.test failures, all
failures appear to be issues with the tests, not with the core code.
FossilOrigin-Name: 75cda864ededb6dc0f84bd52ed3311753a58e351