Re: Key joins

From: Arne Roland <arne(dot)roland(at)malkut(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Joel Jacobson <joel(at)compiler(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Anders Granlund <anders(dot)granlund(dot)0(at)gmail(dot)com>, Andreas Karlsson <andreas(at)proxel(dot)se>, Vik Fearing <vik(at)chouppes(dot)com>, Alexander Melnikov <asmmp(at)protonmail(dot)com>
Subject: Re: Key joins
Date: 2026-11-12 21:43:38
Message-ID: 0c507d2d-14e5-4033-98e9-cc138093dc83@malkut.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

the main change with this patch are the simplified regression tests.
While most of the tests were create with the help of claude (mix of
different models cooperating), I've gone over them three times. I have
ripped out most of senseless duplication and added in four test cases,
which seemed relevant to me. A few comments were also rewritten by me. I
do not think the tests are perfect, but they are way more reasonable
than the extreme amount of pilled on regression tests, we had prior.

Two small changes for : KeyJoinBarrier is a new enum for tracking which
object has no foreign key, because that is helpful to report. Also I
added a new unrecognized key join requirement, because an earlier
version of this patch forgot to set the return, so the error detail was
misleading. This now gives a clean error in case that is forgotten.

I also got rid of the revalidate of ALTER CONSTRAINT .. NO INHERIT; as
that keeps the constraint row of the child intact and as far as I am
concerned never really warranted any special treatment.

Note I did not touch the injection tests yet, but I started working on
them. This is still blowing up the Record and revalidate where 14 of the
15 ones live (the last one is routine).

Regards
Arne

On 2026-10-08 10:15 PM, Arne Roland wrote:
> Hi hackers,
>
> the attached patch is rebased on master. We also decided to drop the
> FILTER (WHERE ...) syntax, to avoid further discussions about that
> syntax hold back the patch itself.
>
> The biggest change is the syntax change affecting the whole chain, but
> mostly our first commit. FOR KEY now names a table on both sides of
> the arrow, left operand first: a JOIN b FOR KEY a_tab (id) <- b_tab
> (a_id) replaces the old FOR KEY (a_id) -> a_tab (id), which named only
> the referenced table. The arrow still points from the referencing side
> to the referenced side. This moves the nice canonical form from all
> left arrows to all forward right arrows. This lead to a lot of
> mechanical changes in the tests. I did not review all of them by hand.
>
> This patch also patches the debug section of pg_rewrite_query (the
> roundtrip eq check). Because proofDependencies are never written,
> we skip the serialization tests for FOR KEY JOIN dependencies. This is
> not done to address any live bugs, but avoid failing tests with
> debug_write_read_parse_plan_trees enabled. This is part of the Record
> and revalidate member of the series.
>
> Regards
> Arne
>

Attachment Content-Type Size
v16-0004-Derive-key-join-proof-facts-from-GROUP-BY-and-DI.patch.gz application/gzip 6.8 KB
v16-0011-Add-psql-tab-completion-for-FOR-KEY-joins.patch.gz application/gzip 11.6 KB
v16-0010-Add-information_schema.view_constraint_usage.patch.gz application/gzip 2.1 KB
v16-0007-Record-and-revalidate-FOR-KEY-proof-dependencies.patch.gz application/gzip 48.9 KB
v16-0009-Extend-stored-FOR-KEY-proofs-to-row-level-securi.patch.gz application/gzip 5.9 KB
v16-0005-Prove-FOR-KEY-joins-whose-referenced-input-is-fi.patch.gz application/gzip 11.3 KB
v16-0003-Prove-FOR-KEY-joins-over-derived-inputs.patch.gz application/gzip 21.2 KB
v16-0002-Add-error-details-to-FOR-KEY-join-rejections.patch.gz application/gzip 6.2 KB
v16-0001-Add-FOR-KEY-join-clause-and-parse-time-proof.patch.gz application/gzip 29.1 KB
v16-0006-Serialize-concurrent-routine-definition-changes.patch.gz application/gzip 3.4 KB
v16-0008-Extend-stored-FOR-KEY-proofs-to-SQL-routine-bodi.patch.gz application/gzip 5.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-11-12 21:44:59 Re: Vacuumlo improvements
Previous Message Dean Rasheed 2026-11-12 21:34:54 Re: MERGE fails with RETURNING when an excluded inheritance parent has an extra-column child