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 1w7Bb3-0052uG-2J for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:19:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7Bb2-003AaX-0a for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:19:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7Bb1-003AaO-2w for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 12:19:56 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7Baz-00000001zU0-3GGq for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 12:19:56 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5a27daa652fso3135574e87.0 for ; Mon, 30 Mar 2026 05:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774873193; cv=none; d=google.com; s=arc-20240605; b=ZlplnLaQ+F1cSwHjjnHJm/XjGoXOaZn3xIJN/ZfgkjPb9TwnLFEfTWS+yIqvEI58ih amEjun46wI7kibeW/hG8chVu2V1KGzjepjd1CU1u5RiFKKoon6pE2be4gvh3hl7Vct3a mo0Oy3+KAr1A/9Xt7iRJ5FjbgjBawZq/EF3K/XFjX+jcdVF0j5vDS5QJgx5NU9ONi1Ml SXBK2Vyrm6i6/uMzSieKp6Ny6GX/4VuyiKtwu3TCVox69MZCKwOPLnwbvyZ6CE5QrlAU 48XU3FVZhsdw6gxeJWOnjyLFuPfJgiRdut5GvxcXbvBK4oigBTCEPEW1Shqcrd1ywRHq ROfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Mc1+RWiXsUm390R6Z6qgjipPmB7Mh4bHh2U2lzRR+xs=; fh=ukCOulBQkdh0EZxNIKGHOTXdxGdS/BPqwfYG7Hw5ZG8=; b=Yzi8SqfKHGJTwpZPSlhYu1z+3ImoKsc6C/fghJIbqKSkAi9y5lxUBm6U2cL58lNiHj 0ol5jYU16oZay/KOTYR1O0O7J+WceRLzgrZu/1tXcACCnLvjVi/N4hC+eEtSdsTadTHw w5z8YCFCh8b9Z2kGS7vitGH+GLIBWh/7/VA19mkhBxkgbYeOrhH/WJB0kbliXKmRnof+ 0CBgerVsGVH2ZGJLsodFXV8w4S/DzhIue97drMvRgcbh/oYk3u2A4bLuDiB3KuJl7/sv AyLA0I4ORPHyFTri/hhmPl046RFNMwfRwg4v7k8aCJCVEGNA62wpDT4kloq7hG3LzaAl LaMg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774873193; x=1775477993; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Mc1+RWiXsUm390R6Z6qgjipPmB7Mh4bHh2U2lzRR+xs=; b=BtFvU9qvAHKKXr/hoNTZe/FAIR0Ega6Yn8L/oRnWGEdhj7je+ANNiU9zsvN9NV1hVn jZQfPMtoPaF3fr94hzIhftoRZUp6sVs18z2ydhjiLUTPKZJ2PS+KviwLh0ByxYMikfwr Jov08wjZyrq/SwBxF27x366q0eGJaHrsjPaxrc54fMH5KMutSvtyqIEURXf9ul5F8Bd3 syVdMQLbARfAhOLN9gtd0qLHzJllsIs82bqq/LQLwH3lg4SdiKlqbrUSdJ46ieMLgobb 1PuSfEFUeOzxrNtAEnIjiut37W1hK49+XhajxEkC5HAJl2xeHnw4emhEsMyLYJ+QObV3 BZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774873193; x=1775477993; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mc1+RWiXsUm390R6Z6qgjipPmB7Mh4bHh2U2lzRR+xs=; b=nfzcOiVrkEA2tZ8JOpeszm9gsgDw9PkvOhvzJDjJYk1E+B/r/WBbYeX3vpJ02MzvLJ 5f8HCf1odNjDgZb4bI1jJ8YQg3pOK47d5OLOLRis1bvRaHCkEQm2ARR4Dx71m5UybCdk te/tVg8o+6UvSfc2iIf0BRkRuPhdiNwYvG59G746ibcrGzBdwMTNIeURc7UGDhCgXonW buKYS2JPwFvsJu+G+xvg6dkNwPslmx9jAe9iBg5xZgdA26J+CrD0eFWQFswEI07ptd14 f/nccpMejqjuCEH6GoLdrq5slTda5szVWZAGhsGVDXeTWp22EvFwZUlMpbuohH8VAAca xrug== X-Forwarded-Encrypted: i=1; AJvYcCWcR4GlE3AmZNWVLCAhikKVpN2BQ/X6ySdisvxHuV4gF6L1oiE7cem0Hhk4oKEPLjr7kng3NqB69yeUUaj9@lists.postgresql.org X-Gm-Message-State: AOJu0YzPeDGjhTl4wSKpFsOhtUZVt1mLtQIWF8vswAdYg61Fr7lLfb7K 0VgsfzEUjt/LW7R1e7lRQ1IlJeRc8OeejRFQkrXtbf8wt1b9++C5XAL2ISSpeEyAuc0qkMlhkNL 2I3Ibf6aorTgA4shgjo5QJleFPX9RT0I= X-Gm-Gg: ATEYQzzdFoLSpAd/XFDyInlNR7byF+hqC6+hfiRN6EnOPezSQuxf67g51AIJofgg87g 1Sdjao/odSTMdx+oaXqcMFSi6txVNwK2jmNXV86zw+l6eNR+Lg8QvjU9O1oMQqCZClkaCAKOfpg tOGf9NEPnJoLjvN7KE744LykbkbD9a2a6xQGm+hkyfHzbZKR9fwuVRCvJrwPzU5A3lvnS7Fdph+ LfeQZQyYV9n9blyMSVLlFlDMceijZAmTnoc8PjLxnw+PfDSyyjcRWHCmLYoO6JA37C+AsF2J0B1 SKl0g95G14X22lbtNmxsBRvlp1/s+D8Whso0cgAEqA== X-Received: by 2002:a05:6512:39c4:b0:5a0:4344:a519 with SMTP id 2adb3069b0e04-5a2ab7e9755mr4721856e87.4.1774873193211; Mon, 30 Mar 2026 05:19:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Mon, 30 Mar 2026 17:49:41 +0530 X-Gm-Features: AQROBzC0NhOMq6SmcfnqJGZ50WitYp-6s7B9FZ7NiV7eaD3zHuxEOKX2S9qqOsE Message-ID: Subject: Re: Bug: wrong relname in RemoveSubscriptionRel() error detail To: "Zhijie Hou (Fujitsu)" Cc: Chao Li , Nisha Moond , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 30, 2026 at 1:44=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Monday, March 30, 2026 2:33 PM Chao Li wrote: > > > On Mar 30, 2026, at 14:16, Nisha Moond > > wrote: > > > > > > On Fri, Mar 27, 2026 at 3:22=E2=80=AFPM Chao Li wrote: > > > > This looks like a first-day bug introducing by ce0fdbf, so I think = it=E2=80=99s worth > > > > back-patching. > > > > > > > I tried reproducing the said bug on HEAD, but it doesn=E2=80=99t seem= to exist > > > in the current code. > > > > > > To hit the mentioned error, the subid has to be invalid - > > > if (!OidIsValid(subid) && <=3D=3D > > > And currently, the only path that uses an invalid subid is via > > > heap_drop_with_catalog() : > > > =E2=80=A6 > > > /* > > > * Remove any associated relation synchronization states. > > > */ > > > RemoveSubscriptionRel(InvalidOid, relid); > > > =E2=80=A6 > > > > > > But here relid is always a valid OID (it's the table being dropped). > > > The corresponding pg_class row is deleted after > > > RemoveSubscriptionRel(), i.e. via a later call to > > > DeleteRelationTuple(relid); > > > > > > It can only happen with a hypothetical future caller of > > > RemoveSubscriptionRel(InvalidOid, InvalidOid). And in that case, usin= g > > > "subrel->srrelid" would be correct. > > > > > > So this doesn=E2=80=99t appear to be a real issue in the current code= , and > > > doesn=E2=80=99t look like a bug to fix now. IMO, if such a caller is = added in > > > the future, we can add a guard at that point. > > > > > > -- > > > Thanks, > > > Nisha > > > > Hi Nisha, > > > > Thanks for your review. > > > > I think one current call site may have been overlooked. In DropSubscrip= tion(), > > we have: > > ``` > > /* Remove any associated relation synchronization states. */ > > RemoveSubscriptionRel(subid, InvalidOid); > > ``` > > This won't trigger the bug either, since it passes a valid subscription O= ID to > the function, while the function only reports an error when an invalid OI= D is > passed. > > > > > I agree this is an edge-case bug and may be difficult to reproduce in p= ractice. > > But from the function=E2=80=99s semantics, it seems clear to me that th= e wrong > > relation OID is used in the error detail, regardless of how easy it is = to trigger > > today. > > Since this is a public function, I think it should be OK to fix it as it'= s good > to make the function future-proof anyway. > Even if it is exposed, it is not clear to me in which case one would like to use it the way it can lead to a problem. I feel unless we have some concrete case it may not be beneficial to change it. --=20 With Regards, Amit Kapila.