Re: Warn on missing replica identity in CREATE/ALTER PUBLICATION
shveta malik <shveta.malik@gmail.com>
From: shveta malik <shveta.malik@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: 南拓弥 <minamitakuya@lifull.com>, pgsql-hackers@lists.postgresql.org, shveta malik <shveta.malik@gmail.com>
Date: 2026-04-23T07:07:41Z
Lists: pgsql-hackers
On Thu, Apr 23, 2026 at 12:21 PM Chao Li <li.evan.chao@gmail.com> wrote: > > > > > On Apr 23, 2026, at 13:46, 南拓弥 <minamitakuya@lifull.com> wrote: > > > > # Reply draft v2 to Shveta > > > > --- > > > > Hi Shveta, > > > > Thanks for pointing out that thread. I've read through it carefully. > > > > I believe the two proposals address different aspects of the same > > problem: > > > > - The fallback RI approach changes runtime behavior so that tables > > without a primary key can still replicate UPDATE/DELETE. > > - This proposal simply warns at DDL time that a publication contains > > tables whose replica identity will cause UPDATE/DELETE to fail at > > replication time. > > > > A WARNING at publication creation time is useful regardless of whether > > a fallback mechanism exists, because: > > > > - If a table has REPLICA IDENTITY DEFAULT with no primary key, it > > silently falls back to NOTHING. Combining that with a publication > > that publishes updates/deletes is guaranteed to fail at runtime. > > A WARNING at DDL time closes this gap. > > - Even users who explicitly set REPLICA IDENTITY NOTHING and add the > > table to an update/delete publication would benefit from a reminder, > > since that combination cannot succeed. > > - The WARNING does not change any existing behavior — it only makes > > the misconfiguration visible earlier. > > > > Notably, Euler mentioned in that thread [1] that he would "suggest a > > way to disallow or add a warning message while creating the > > publication or adding new tables", which is exactly what this proposal > > does. > > > > That said, I see the two proposals as complementary. Should I continue > > this as a separate thread, or would it be better to join the existing > > discussion? > > > > I have a working patch covering all publication paths (FOR TABLE, > > FOR TABLES IN SCHEMA, FOR ALL TABLES, ALTER PUBLICATION). Happy to > > post it either way. > > > > [1] https://www.postgresql.org/message-id/a9da608f-24be-4213-a712-8592852d37f1%40app.fastmail.com > > > > You are very welcome to join the thread, as the initiator of that thread. > > I am not personally against your idea of adding such a warning message, but I think it would be better to consider the two features together as a whole solution from a system perspective. > > In any case, new features will have to wait for v20 until July, so we still have time for more discussion and deeper consideration. I agree. But if the RI fallback option gets delayed due to lack of consensus on the design or other reasons, issuing a WARNING during publication creation seems like a reasonable approach. thanks Shveta