Hi Peter, > I'm now very close to committing everything. Though I do still want > another pair of eyes on the newer > 0003-Improve-skip-scan-primitive-scan-scheduling.patch stuff before > commiting (since I still intend to commit all the remaining patches > together).
Can you think of any tests specifically for 0003, or relying on the added Asserts() is best we can do? Same question for 0002. I can confirm that v33 applies and passes the test. 0002 adds _bt_set_startikey() to nbtutils.c but it is not well-covered by tests, many branches of the new code are never executed. ``` @@ -2554,9 +2865,20 @@ _bt_check_compare(IndexScanDesc scan, ScanDirection dir, */ if (requiredSameDir) *continuescan = false; + else if (unlikely(key->sk_flags & SK_BT_SKIP)) + { + /* + * If we're treating scan keys as nonrequired, and encounter a + * skip array scan key whose current element is NULL, then it + * must be a non-range skip array + */ + Assert(forcenonrequired && *ikey > 0); + return _bt_advance_array_keys(scan, NULL, tuple, tupnatts, + tupdesc, *ikey, false); + } ``` This branch is also never executed during the test run. In 0003: ``` @@ -2006,6 +2008,10 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate, else if (has_required_opposite_direction_only && pstate->finaltup && unlikely(!_bt_oppodir_checkkeys(scan, dir, pstate->finaltup))) { + /* + * Make sure that any SAOP arrays that were not marked required by + * preprocessing are reset to their first element for this direction + */ _bt_rewind_nonrequired_arrays(scan, dir); goto new_prim_scan; } ``` This branch is never executed too. This being said, technically there is no new code here. For your convenience I uploaded a complete HTML code coverage report (~36 Mb) [1]. [1]: https://drive.google.com/file/d/1breVpHapvJLtw8AlFAdXDAbK8ZZytY6v/view?usp=sharing -- Best regards, Aleksander Alekseev