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 1wHwnK-007eE4-0j for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 04:45:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHwnI-001mlx-0G for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 04:45:04 +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 1wHwnH-001mlo-2Y for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 04:45:03 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHwnF-00000003ihY-2wfi for pgsql-hackers@postgresql.org; Wed, 29 Apr 2026 04:45:03 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-38dfb789d7fso93615601fa.2 for ; Tue, 28 Apr 2026 21:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777437900; cv=none; d=google.com; s=arc-20240605; b=MMGMk7G1nhS1dnuEbFSiZAqH7LBYiqnMuOKBNW3hcLBAfKDs/5D+s4Ou/5v4XFaUqQ vDvncONIP2p1uEJk4EtZeLn/PzP4iHp38xg2nSK44ceDbuVQqB4AHy3qbDx2nKBV2C/2 /Ar6BkWjGsj518Vd+n63E9R2nYQyqeRPExoB1U6NzmkPv/2f5kkiEaHuPTchdlMw5MLH JDioIUriTYAC52qhDyazd/Pl3wznxL86hP0eytP86pdOa1w8J7JqMdC4ySHRDcjz5v6j u/IXjrGQkUsuFkz48V+omcuSx9bfEGR07wTX5uP3WUfDLrLvPAvlWIsmHqChcRnzvPgl azLA== 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=HG9/8ZWqnumZFdNhxutZen4PE6htUcuHmuLAUG67QpI=; fh=tppwkZDvKrKJDLuNZyX2kA+g7IeMDuD/wutgKf2uWlc=; b=WtmmZpbi4dh20kvcLubRKADdcopmwP+cV2bEHUOSmlZ5rmEPQdtHDJK3yi5BC7HhT3 J6Q8kATrO42EN9zxnUsHVpswR4ZA5jE2PHectLCL+pN+6BRUbpjHNBZlZ5OcWyi/WJM4 CGcZBwCyvA5e+EGQJRTEv7XaO0xWc5jDqvWsgF56L7dazhlWF6tSf6bnTNznrTXUkzUg 9jJqnGRJBdaoWPcdqB8nIrE8eRFY5HflIcN1UjRm0Dm6WhwCAOK2vqFWBTBVEcNBR26x Knr372N5uRVYuHFRKr9Om6WMI8OJyN92OWUhCZtJTBNNcIrtS5QgkSsKo3nfgPkXfP2W WnBw==; darn=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=1777437900; x=1778042700; darn=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=HG9/8ZWqnumZFdNhxutZen4PE6htUcuHmuLAUG67QpI=; b=oOYJfEJeC8gTRuBpS893LosmTltSf2O9RYcIopIc1VCfDdFMRhFDYT7xtY1+8f//xu qOvqPVS7nrJwdHe2SLLx1a+ZfBfjurmWwZFQOf3l4rknDzx1Q5F8i6mFAFPxGqDXUhdz qGwUnXp283SzB+uvrBGDo+biZgQicT9KTvZA/d1CwMA/7QZjrFl9EyKQVokrwRCF07Jn A5JQiwhjtSjzw9pJPOFdxWE7OMUgtNBuYNRPAo2xhX7aTIkKVKJa5jOoKPwgAmaMT5o4 Xr8xqL96eAvjcSK0EAyE/y20sftqJUZh9d4Wf/8IHk4S+A76dKAe1GTJFlKI6y5kYQC0 Iryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777437900; x=1778042700; 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=HG9/8ZWqnumZFdNhxutZen4PE6htUcuHmuLAUG67QpI=; b=POSef5VSZzCEZmAPbpPQUE0DasGI4d1E0sA357UwoYE5q4BO0MdjELdnRSQaIn9pIs QQb5EHJUyvnbRVySkFfGjAhJGhsFbpbQnJ3t5zjX+cfP20q4UBpINqYUOqd/d5BuMMAZ trq6FEI81O/9lQlTZ1thk4Df/WGlTnT5CF2EhxkHSTD0q+Y6YCzsfTnAWZztLGjqmTh6 9URDJeqyESh1xl9sLyTMblqntGSza+yememaL4iupXKynYkDoDdZ3h+Oq4rNCtQ/UBhR LU3T5xnaScqlyqPAXWYV7SuereabFvzOkQqUVTYRaLeFAwzBl7EUkkaBWVx25aG4VEky u3rA== X-Gm-Message-State: AOJu0YxGdNj98pbDloI2tqg7dKq6vNVRV480zFkk+K9vhvmrY6v+d1x5 RHceE41yHNkPoyf16gEtNwswFrADIzilHMcie2AcziZJ8wmdxXtpZHJkk4gv4Fr68wPliau82V9 dvWmtp67naX9IEkH4XjZpkCOKOivogcU= X-Gm-Gg: AeBDietWqtBGvGABomPrdZf5eiXGkG+ivbWK+vMUU888BZDhi1kqLCYGpen7D8RiFE8 RdBVGazBDBPwsCPxc2JH90ama6MsWOjuwTpSu4PK2VAUGs6D5eDbCAIxbcs2heA2Co1VfNI95qt gR0/+lCv8/GrAOWOpAGA6f3eMxzvUngFsta2sS2RwNFo4tWZrUVM/CVmj4sbU4E2Wk7NSnVaOIl W4gNY2Hln4vMW/htTVp9We+rne778z6714KhHNX89u7fLFcPwodwoT98Fblt+UbAENlopOF5eot I8Fvr1ThkbrEnfXFZg== X-Received: by 2002:a2e:bc20:0:b0:383:20cd:52fe with SMTP id 38308e7fff4ca-39240fb9e9emr22971601fa.17.1777437899431; Tue, 28 Apr 2026 21:44:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ajin Cherian Date: Wed, 29 Apr 2026 14:44:47 +1000 X-Gm-Features: AVHnY4JS5TlguCKUHGbP8p2U7Nox-gMLbCWHE4AKu4-jJ3Ohlw0e8GLV0dggs_E Message-ID: Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server To: Chao Li Cc: PostgreSQL-development 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 Wed, Apr 22, 2026 at 11:52=E2=80=AFAM Chao Li w= rote: > > Hi, > > The comment explicitly says to skip ACL checks on the old server because = it will be removed anyway. > > But after looking into GetSubscription(), I found that when the aclcheck = parameter is false, it still calls ForeignServerConnectionString(). I think= that is the root cause of the bug. > > To fix this, I worked out a solution that stores the server OID in Subscr= iption, and only calls ForeignServerConnectionString()lazily when sub->conn= info is actually needed. I also added a new test case to cover this scenari= o. Without the fix, the new test fails. > See attached patch for details. > Hi Li, Thanks for the patch. Some comments: 1. if (aclresult !=3D ACLCHECK_OK) ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("subscription owner \"%s\" does not have permission on foreign server \"%s\"", - GetUserNameFromId(subform->subowner, false= ), - server->servername))); + errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("subscription owner \"%s\" does not have permission on foreign server \"%s\"", + GetUserNameFromId(subform->subowner, false)= , + server->servername)); + sub->conninfo =3D ForeignServerConnectionString(subform->subow= ner, + server); } Add a new line before the call to ForeignServerConnectionString(), also I think you should put the if condition within curly brackets because it spans more than one line and might confuse developers while adding new code. 2. I think you should add a comment in the function header above GetSubscription() stating that if aclcheck is false, then the conninfo will be set to null and users need to call GetSubscriptionConnInfo to get the conninfo. 3. Datum test_fdw_connection(PG_FUNCTION_ARGS) { + GetUserMapping(PG_GETARG_OID(0), PG_GETARG_OID(1)); PG_RETURN_TEXT_P(cstring_to_text("dbname=3Dregress_doesnotexist user=3Ddoesnotexist password=3Dsecret")); } Add a comment above this change describing why it's required. regards, Ajin Cherian Fujitsu Australia