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.94.2) (envelope-from ) id 1rUlf2-00Cv6V-NB for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jan 2024 10:48:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rUlf1-004LIc-HG for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jan 2024 10:48:11 +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.94.2) (envelope-from ) id 1rUlf1-004LIU-7S for pgsql-hackers@lists.postgresql.org; Tue, 30 Jan 2024 10:48:11 +0000 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rUlez-004Vb2-JH for pgsql-hackers@postgresql.org; Tue, 30 Jan 2024 10:48:10 +0000 Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-7d317aafbd1so1505140241.2 for ; Tue, 30 Jan 2024 02:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706611687; x=1707216487; 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=eHGTWeDdLJk/xhdG3/zZiYrwTGjZrH2EKoNdCz0Be6A=; b=go1xR1fnx39L8E+ztue/rxX0da6t4pvWvdZ2i3CBJuNXpImniTt8s5WtOSqCj8cSW3 jwHVc84dUlVxjKFWf4W0yDkKunWZpuGpWB2odFHt46i8G+j1XBxRcZ8OsfxFETNwegOb xkDJTg3TndC/BqWb6QGjGxqQ1fl0rfKrlzfHGHIh3YEOG2XJv83I0xEmMPZlEUJEvM59 H0cdcTSv8gWrNaNgdzGSvXTm/vCCMmN9y+xqNehDCJ9DNgNRcNfU9fd1mPyZQRkwjNUj pxdKOxyR22LqnapyvAL2TcSzYp8ORD0d886QXFzgqja6gJ0fLcxZAOLN+qZfIs9tchbr 51xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706611687; x=1707216487; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eHGTWeDdLJk/xhdG3/zZiYrwTGjZrH2EKoNdCz0Be6A=; b=UVyNeshXv4e0wCEPkur8YaeUoCsPngjUszdTOdQTSadkUZL0Zc/dvn/Ou4oAh+hpSn 7PqngKVhdicyWIdosQcdD6XZ44aGQExBlAh8+OTk9WRtUDDJcDYktRsUrHuVM2Uv/EVk 9jitjmEaVPxzQyuxw10PD6nDpPZVZToUzgu6OidqBgnZM21b/slfqqyVj+VD/BbVzbkg v6EtjYqtMtEWBkmBd6GgXsg6Z3HF0SbslRdfS0JdWXqO+aMb/InAGHVz1PanSXSuMdTm FbrzQhdaNjWWrZ0/pcstr6hNTl9t1WBAh4nZefKy8Q67zxlBN/fywOBXpQ/f/dBQsVR1 xExw== X-Gm-Message-State: AOJu0YxY4NrCCqP3uCmnqsNLwKSsZGK53uspRpdF9en1pZ/1Sa3pFCFy BkWGVLRw7A0gSvdyd890SC5YYmezmE0gf4aUF6Oz/6MAo35dXxMtC355GF2ZdgxUYz3acv1ZIws s2Ftt31t9b1TtqyV/ntuRk9CCtdM= X-Google-Smtp-Source: AGHT+IEVySMNbhfWoq5BFFfyCReDAg8gst/n4XJBO5rQhq/gw6Yx0QaMZbNh0KEkwjM8BOGiCTbwRob0Oh9Qp4MGi/I= X-Received: by 2002:a05:6102:c88:b0:46b:74c8:5cb2 with SMTP id f8-20020a0561020c8800b0046b74c85cb2mr1857122vst.31.1706611687397; Tue, 30 Jan 2024 02:48:07 -0800 (PST) MIME-Version: 1.0 References: <149ff9264db27cdf724b65709fbbaee4bf316835.camel@j-davis.com> <830a2bc6cbbb2e6e01c6c0d9f31f320822e10603.camel@j-davis.com> <433d0845248e86c0317d9d396926182cfe157340.camel@j-davis.com> <05ae37abb207cd6bf6b126780024692d91402b0b.camel@j-davis.com> <93392ffa941ab0d436e19e0ab5d04d0e42c02d3f.camel@j-davis.com> <26be917cb07b6aa3ef5dd15f6b59d1b375ece6e8.camel@j-davis.com> <55201bd916e748acfc754c8f95880dae8e4e5ed0.camel@j-davis.com> <2a89b14a2b1622bffb8b137ca1f9ab7866f2d2b9.camel@j-davis.com> <61831790a0a937038f78ce09f8dd4cef7de7456a.camel@j-davis.com> <0910b47040406c1d24ec0150dafb5bae6b910ed7.camel@j-davis.com> <7338f22c4534322a08ab6ce9f879e2e308eb5e5d.camel@j-davis.com> In-Reply-To: <7338f22c4534322a08ab6ce9f879e2e308eb5e5d.camel@j-davis.com> From: Ashutosh Bapat Date: Tue, 30 Jan 2024 16:17:55 +0530 Message-ID: Subject: Re: [17] CREATE SUBSCRIPTION ... SERVER To: Jeff Davis Cc: Bharath Rupireddy , Joe Conway , pgsql-hackers@postgresql.org 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, Jan 24, 2024 at 7:15=E2=80=AFAM Jeff Davis wrot= e: > > On Tue, 2024-01-23 at 15:21 +0530, Ashutosh Bapat wrote: > > I am with the prefix. The changes it causes make review difficult. If > > you can separate those changes into a patch that will help. > > I ended up just removing the dummy FDW. Real users are likely to want > to use postgres_fdw, and if not, it's easy enough to issue a CREATE > FOREIGN DATA WRAPPER. Or I can bring it back if desired. > > Updated patch set (patches are renumbered): > > * removed dummy FDW and test churn > * made a new pg_connection_validator function which leaves > postgresql_fdw_validator in place. (I didn't document the new function > -- should I?) > * included your tests improvements > * removed dependency from the subscription to the user mapping -- we > don't depend on the user mapping for foreign tables, so we shouldn't > depend on them here. Of course a change to a user mapping still > invalidates the subscription worker and it will restart. > * general cleanup > Thanks. > Overall it's simpler and hopefully easier to review. The patch to > introduce the pg_create_connection role could use some more discussion, > but I believe 0001 and 0002 are nearly ready. 0001 commit message says "in preparation of CREATE SUBSCRIPTION" but I do not see the function being used anywhere except in testcases. Am I missing something? Is this function necessary for this feature? But more importantly this function and its minions are closely tied with libpq and not an FDW. Converting a server and user mapping to conninfo should be delegated to the FDW being used since that FDW knows best how to use those options. Similarly options_to_conninfo() should be delegated to the FDW. I imagine that the FDWs which want to support subscriptions will need to implement hooks in WalReceiverFunctionsType which seems to be designed to be pluggable. --- quote This API should be considered internal at the moment, but we could open it up for 3rd party replacements of libpqwalreceiver in the future, allowing pluggable methods for receiving WAL. --- unquote Not all of those hooks are applicable to every FDW since the publisher may be different and may not provide all the functionality. So we might need to rethink WalReceiverFunctionsType interface eventually. But for now, we will need to change postgres_fdw to implement it. We should mention something about the user mapping that will be used to connect to SERVER when subscription specifies SERVER. I am not sure where to mention this. May be we can get some clue from foreign server documentation. -- Best Wishes, Ashutosh Bapat