Hi Tom,

Tom Lane <[email protected]> writes:
> Concretely, the attached fixes the given test case and passes
> check-world; but I've not tried harder than that to break it.

I like this better than my 0001, and I could not break it. I kept
0001 small only because of where 19 is. If you think moving the call
is right for 19 and 18 too, I am fine with that.

I did a simple fuzz test generating 2200 random self join queries giving
the same results as 18.6 and the same plans as master. Tests pass
on REL_19_STABLE and REL_18_STABLE too.

> Good catch, although I kind of wonder why we're allowing lateral
> refs in tablesample clauses in the first place.

0002 is still needed, the Assert fires with only your patch.

I also hit one more of that kind. Self join elimination leaves the
removed rel's securityQuals in its rte, now pointing at the kept rel.
When a later pass removes the kept rel too, the same Assert fires.

create table r (k int primary key, v int);
alter table r enable row level security;
create policy p on r using (v > 0);
create table x (k int primary key);
create role u1;
grant select on r, x to u1;
set role u1;
select x.k from x left join (r a join r b on a.k = b.k) on x.k = a.k;

I will send a patch to address ^^^^^ later today.

Thanks,
Shihao

Reply via email to