Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w63re-003udQ-2F for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 09:52:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w63rd-008sKT-0O for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 09:52:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w63rc-008sKL-2k for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 09:52:25 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w63ra-00000001IQT-3hmE for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 09:52:24 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-359fea895b5so1466525a91.0 for ; Fri, 27 Mar 2026 02:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774605141; x=1775209941; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=efRFdmamlVnXDf7yWLkbl92VMxiabd/O408BKkiY2xY=; b=M7b74UWfBR5Axe6xmd5ff/c5G9OFVreanTr/FOylNBu/b0WRRlaXWCIZrH3/7hznC+ ZuwzkQTDzGTXdoC6GYALJgmfOdO1P4FFBKYFuUp+NCZ17pxcQKzlwJ3tnatz+1Txltpi cFaFRnbrL/qW/qr4VxORvS19M1PGbtbHK6grx/CwWfRr1732tIzm8w8FXfQP8X2z8RWf cbwl28XKhj2kqDAdDa0T9jZrYnBcoxOujmXOvQKv9b5bJSv7jKa9RlbvzIOEd9ItkhaG mRGy9V5s4kh3t25UEStdt7Cl77TDeMT1OXcqSKc+5s32+G2eM4EghNQltvC2UKI3Lon+ G9XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774605141; x=1775209941; h=to:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=efRFdmamlVnXDf7yWLkbl92VMxiabd/O408BKkiY2xY=; b=l+WBIOXvISdi6znx8q9gRNG8N+S8v3BY9UvVr5Jj5vJuOUjEn8saJeyaKjB7xR4h83 oK1OSWABl2bAE/+SnfhxgPXv6bl/c8tFPhLMHg2KMhuHZHpBHSeU6n8kjOx4pjsybQ8g lkO9V22VY2u1opTV6nOojXKr7PSkezTP0oN6fppokWPFJEKVGp8Bf2DshMnUOFQgLMCD drwTHuZob5r05j5+x7SdR+lAR4ecocmIR9ZyxEbbgp7XWpJyDP6PikutoxAMwqxChdyp PRy/7HF5ojAB3D6TYbjTCtfc11Fov7arl81OBomII8hFNHVY/S7GP8Unqnt8fzL1YlWo WWgQ== X-Gm-Message-State: AOJu0YzJLA1mdUCeLWXO9Ze3nHD2MUrFrrUwr/kQBROoTDXuMjAquBnv YRlzpN9oHeCkIEfA18nlWwDMoQwX4pncaq+rMbPARY1sHTg4I1cCL6Y+OGbaJ5oiiNU/3w== X-Gm-Gg: ATEYQzz4DXTGJUjQ+qC7dq54RRScvEDYJUR3LG1HkvwDWWkzBfRFKa6lmORbRXFkfze fk5tzMjyKtJ6qTvg/Tf7eZ1xPcsgp+3mhY55pTqFLBQTlBZZV0xF8YV74zyH3fkoMdDXpZm5XhI qE+FkeRPR2e+MFqUexI+tFlmPSf8eo0dO4t5a4q7FEE6eQCQPkWfJjhcSJ/KvdbPJyK+bq9mRE/ 7Thx5k5CIkbmHuuTo3A/eUF2EEl1iJ+Pyvg7Vxf1q0IVeFOJMJ8BUKOa/MIPkcm2seteWvWYe3Q caAGJosFtzcAGKpoVrLTBGinuy3PWuVyuDS984oUDujR3OVH49/aUhDUTT2gryvJOw9nCjLqQ0S Eh0jB1IWB21nPRkz6ehTinpmGiAvYMCsA3bcS2pTV5sVc8U7PVNgOA9s4sdwqRiDDnf+scG0VM0 Yn4KZKCIfN5hRXeErQHoBdnIZh/nwQFnQ= X-Received: by 2002:a17:90b:53c8:b0:35b:e4d7:9694 with SMTP id 98e67ed59e1d1-35c3005b938mr1978419a91.19.1774605141324; Fri, 27 Mar 2026 02:52:21 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c22b9fc96sm3979896a91.7.2026.03.27.02.52.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2026 02:52:20 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_E088A7F8-947E-4A7D-9783-F7BE63540B01" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Bug: wrong relname in RemoveSubscriptionRel() error detail Message-Id: Date: Fri, 27 Mar 2026 17:51:57 +0800 To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_E088A7F8-947E-4A7D-9783-F7BE63540B01 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, I just noticed a wrong relation name in the error detail emitted by = RemoveSubscriptionRel(): ``` * * Drop subscription relation mapping. These can be for a particular * subscription, or for a particular relation, or both. */ void RemoveSubscriptionRel(Oid subid, Oid relid) { Relation rel; TableScanDesc scan; ScanKeyData skey[2]; HeapTuple tup; int nkeys =3D 0; rel =3D table_open(SubscriptionRelRelationId, RowExclusiveLock); if (OidIsValid(subid)) { ScanKeyInit(&skey[nkeys++], = Anum_pg_subscription_rel_srsubid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(subid)); } if (OidIsValid(relid)) { ScanKeyInit(&skey[nkeys++], = Anum_pg_subscription_rel_srrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); } /* Do the search and delete what we found. */ scan =3D table_beginscan_catalog(rel, nkeys, skey); while (HeapTupleIsValid(tup =3D heap_getnext(scan, = ForwardScanDirection))) { Form_pg_subscription_rel subrel; subrel =3D (Form_pg_subscription_rel) GETSTRUCT(tup); if (!OidIsValid(subid) && subrel->srsubstate !=3D SUBREL_STATE_READY && get_rel_relkind(subrel->srrelid) !=3D = RELKIND_SEQUENCE) { ereport(ERROR, = (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("could not drop relation = mapping for subscription \"%s\"", = get_subscription_name(subrel->srsubid, false)), errdetail("Table = synchronization for relation \"%s\" is in progress and is in state = \"%c\".", = get_rel_name(relid), subrel->srsubstate), // <=3D=3D=3D=3D=3D=3D bug is = here ``` In the error detail, it uses relid to get the relation name. But at that = point we are iterating over subrel, and the function argument relid can = be InvalidOid. So the error detail should use subrel->srrelid instead. This looks like a first-day bug introducing by ce0fdbf, so I think = it=E2=80=99s worth back-patching. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_E088A7F8-947E-4A7D-9783-F7BE63540B01 Content-Disposition: attachment; filename=v1-0001-Fix-wrong-relname-in-RemoveSubscriptionRel-error-.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-Fix-wrong-relname-in-RemoveSubscriptionRel-error-.patch" Content-Transfer-Encoding: quoted-printable =46rom=20c49dc0495607c05c6ac8e15cc0300f91bacf0f6c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=2027=20Mar=202026=2017:39:30=20+0800=0ASubject:=20[PATCH=20= v1]=20Fix=20wrong=20relname=20in=20RemoveSubscriptionRel()=20error=20= detail=0A=0AAuthor:=20Chao=20Li=20=0AReviewed-by:=0A= Discussion:=20https://postgr.es/m/=0A---=0A=20= src/backend/catalog/pg_subscription.c=20|=202=20+-=0A=201=20file=20= changed,=201=20insertion(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/src/backend/catalog/pg_subscription.c=20= b/src/backend/catalog/pg_subscription.c=0Aindex=20= 5a733585490..0ee00d91d83=20100644=0A---=20= a/src/backend/catalog/pg_subscription.c=0A+++=20= b/src/backend/catalog/pg_subscription.c=0A@@=20-525,7=20+525,7=20@@=20= RemoveSubscriptionRel(Oid=20subid,=20Oid=20relid)=0A=20=09=09=09=09=09=20= errmsg("could=20not=20drop=20relation=20mapping=20for=20subscription=20= \"%s\"",=0A=20=09=09=09=09=09=09=09= get_subscription_name(subrel->srsubid,=20false)),=0A=20=09=09=09=09=09=20= errdetail("Table=20synchronization=20for=20relation=20\"%s\"=20is=20in=20= progress=20and=20is=20in=20state=20\"%c\".",=0A-=09=09=09=09=09=09=09=20=20= =20get_rel_name(relid),=20subrel->srsubstate),=0A+=09=09=09=09=09=09=09=20= =20=20get_rel_name(subrel->srrelid),=20subrel->srsubstate),=0A=20=0A=20=09= =09=09/*=0A=20=09=09=09=20*=20translator:=20first=20%s=20is=20a=20SQL=20= ALTER=20command=20and=20second=20%s=20is=20a=0A--=20=0A2.50.1=20(Apple=20= Git-155)=0A=0A= --Apple-Mail=_E088A7F8-947E-4A7D-9783-F7BE63540B01--