* statext_is_compatible_clause_internal is not on board with offsetting the attnums.
Correct. Good catch! Fix this in v2 patch.
I realized the fix in v2 is not correct. The attnums generated by statext_is_compatible_clause is expected to be NOT offsetting by its caller, i.e. statext_mcv_clauselist_selectivity. Revise that in v3 patch by doing the offsetting when composing clause_attnums that need to have permission check.
* Although the coverage report claims this code is exercised, the fact that nothing failed when you made only a partial fix says it's not exercised well enough.
That's true. We need to provide a better test case to cover this.
Also I'm trying to provide a better test case and at last come up with a case in v3 like:
SELECT * FROM tststats.priv_test_tbl where a = 1 and tststats.priv_test_tbl.* > (1, 1) is not null;
For this case, the clause 'a = 1' would cover that the attnum comes from statext_is_compatible_clause_internal. And the clause 'priv_test_tbl.* > (1, 1) is not null' would cover that the attnum comes from 'exprs' and it has a whole-row reference.