Re: Self-join elimination discards differing row lock wait policies

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Self-join elimination discards differing row lock wait policies
Date: 2026-10-24 14:40:39
Message-ID: 3224761.1792852839@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tender Wang <tndrwang(at)gmail(dot)com> writes:
> Self-join elimination discards one of the row lock wait policies when
> two aliases of the same relation use different policies.

Good catch.

> The attached patch requires the row mark type, locking strength, and
> wait policy to match before eliminating the self-join.
> Thoughts?

In some cases it might be possible to merge two "sufficiently similar"
rowmark requirements, eg keep only the stronger lock type. I'm not
sure that that wouldn't produce visible semantics changes, though.
On the other hand, the code is already willing to merge an RTE with
a RowMark with an RTE that has none, and I'm not convinced that that
has no visible semantics effects either --- for example, if the one
RowMark says "SKIP LOCKED", doesn't it represent a different set of
rows than an RTE with no RowMark? Maybe we should tighten this even
more and reject that case?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuya Kawata 2026-10-24 14:44:16 Re: [PATCH] Add memory/disk usage for Function Scan nodes in EXPLAIN
Previous Message Pierre Forstmann 2026-10-24 14:39:52 Re: Reporting WAL replay progress during pre-consistency standby reovery