Hi Richard,
v1 looks good to me. It also fixes the same error with plaininheritance and with a self join of the RLS table.
Thanks,Shihao