Fix `relation.exists?` with giving `distinct`, `offset` and `order` for joined table
#36647

giraffate wants to merge giraffate:fix_exists_with_distinct_and_offset_and_order_in_postgresql into rails:master

We do not currently have an analysis of these two commits