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 1twhMU-00GjVA-9E for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 12:57:02 +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 1twhMS-0038YD-Uv for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 12:57:00 +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 1twhMS-0038Y1-Kl for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 12:57:00 +0000 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twhMQ-000s8M-1v for pgsql-hackers@postgresql.org; Mon, 24 Mar 2025 12:57:00 +0000 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-6feb229b716so39353437b3.3 for ; Mon, 24 Mar 2025 05:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742821017; x=1743425817; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GvIPLeRZ24YX4EhkQhUjgojfrab3mDnPYsor1wPHKao=; b=Mc7yZk4HvgmZtLGJJnoTNGQpZWE44u9IFiCq31NJO04ihzCFubCrcJEEAzUFx9zsKi 0MfZDDpSbaNv1J2Ul6awRwZnvIiZBDUNMxeUdqrp/adN7bTLiNocoEaFCzajosMUmL5L 2HZEojwTtksPGRizk9iRyJO09/YOO2xylTvODQkwYfZswf9gBsNkDHKquWUCSI46VdPf 4Mj50MXeAjr99dL95GbLSs3SpjmjWc6hSzDDckzNZ1qNzJCdrKDbk8RIH65l0aPGrqRf 2DcxVlJ7n3DO155Ruyg4t9WLdDpIA5gFeSjyDE016cQXtTcpDaLpKsPE3wfBIBcfavuy +EcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742821017; x=1743425817; h=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=GvIPLeRZ24YX4EhkQhUjgojfrab3mDnPYsor1wPHKao=; b=ao45mljbnhI+wNLEWvCnMAwJohdpd3/WZu4ltS/DnYmJzGUPZMYA72BPS9A+edLYH/ QeCPravaH9DQH0CiNBsg5qaLDl6HlYyDY4DdQgQd/z5hnG92KiXtHKeqmBwmUkeV6IdH gSVik/3kRcmZ79ABknm+rZn5R+sL+pW7gADaEoxTWbteHSj9E2hSxKD1+Sizke7wGfr4 bbWI8TAaHHqtGp6Tr83hZ/NYk/Z3ZH+tqX04uHI3KOKkZ3GQ3JOKXjAwqrgyDxzC0QWc SqrEQ8H6BhlSLKWzUWrdN0WFqxqVgjdnIfS4WPkQXiijKYrCwBbxu0/XTiVc4qLgxWiE ieUw== X-Forwarded-Encrypted: i=1; AJvYcCX3qIfSE0s++1AClOT3FQNB1wk8cv0ykXIKB/FpDQt6xXNgPBcHzOMM88Wzgexjii+uSkouq2fdSWtqegtB@postgresql.org X-Gm-Message-State: AOJu0YyL7z9vps0TrB0t8I499X1ovj9W39FGKU8XsMidaolNdWosUIy6 F3fpvkCLodb9Ti9uSVh9BMrT4mBx4naXyNLejWoVjnTDKqsJyrG0I+T+InMV1xZ2bKckK3rAr1C fO1FCfdOOP1K+6xEWUKCrX7GHERc= X-Gm-Gg: ASbGnctj1V/TRG3XWUTokHpfz/N6l3W1ke0VpYwZdTUOFZV8CPpq/jCtTJYsjsCVP+L 5cJpmxyJG2Y9fxhtDrsLo7waY20/xqUeRvqwSlZozwUtr3QWIxdujI+vY8nJGyXM294Zsy4Ngpp 4ZpxGgfpdyxLTqyG4XnEPToNcFzA== X-Google-Smtp-Source: AGHT+IHqoOGMaP6EuZU+7qhd2QL1ESpocybZvszsHYoui/HKE5FSIU4yDlNDE7lVSijgTBF9T+Pguhu8VY+NuPiSsTc= X-Received: by 2002:a05:690c:f15:b0:6ff:1fac:c4f2 with SMTP id 00721157ae682-700bad023a4mr132661357b3.33.1742821016552; Mon, 24 Mar 2025 05:56:56 -0700 (PDT) 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> <34fd5885b8245d1014f4426ea22af61229d42e3e.camel@j-davis.com> In-Reply-To: From: vignesh C Date: Mon, 24 Mar 2025 18:26:44 +0530 X-Gm-Features: AQ5f1JreBLuabm4wPrBaJ05k8g9XFWLooiw4_wP-3E1X31neVBnFiEO4cbYnGb0 Message-ID: Subject: Re: [18] CREATE SUBSCRIPTION ... SERVER To: Jeff Davis Cc: Ashutosh Bapat , Bharath Rupireddy , Joe Conway , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 1 Mar 2025 at 04:35, Jeff Davis wrote: > > On Mon, 2024-12-16 at 20:05 -0800, Jeff Davis wrote: > > On Wed, 2024-10-30 at 08:08 -0700, Jeff Davis wrote: > > > > Rebased v14. > > The approach has changed multiple times. It starte off with more in- > core code, but in response to review feedback, has become more > decoupled from core and more coupled to postgres_fdw. > > But the patch has been about the same (just rebases) since March of > last year, and hasn't gotten feedback since. I still think it's a nice > feature, but I'd like some feedback on the externals of the feature. +1 for this feature. I started having a look at the patch, here are some initial comments: 1) The hint given here does not help anymore as subscription is global object: postgres=# drop server myserver ; ERROR: cannot drop server myserver because other objects depend on it DETAIL: user mapping for vignesh on server myserver depends on server myserver subscription tap_sub depends on server myserver HINT: Use DROP ... CASCADE to drop the dependent objects too. postgres=# drop server myserver cascade; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vignesh on server myserver drop cascades to subscription tap_sub ERROR: global objects cannot be deleted by doDeletion Should we do anything about this? 2) I felt this change is not required as TAP_TESTS is already defined: diff --git a/contrib/postgres_fdw/Makefile b/contrib/postgres_fdw/Makefile index adfbd2ef758..59b805656c1 100644 --- a/contrib/postgres_fdw/Makefile +++ b/contrib/postgres_fdw/Makefile @@ -19,6 +19,8 @@ DATA = postgres_fdw--1.0.sql postgres_fdw--1.0--1.1.sql postgres_fdw--1.1--1.2.s REGRESS = postgres_fdw query_cancel TAP_TESTS = 1 +TAP_TESTS = 1 + ifdef USE_PGXS PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) 3) Copyright year to be updated: diff --git a/contrib/postgres_fdw/t/010_subscription.pl b/contrib/postgres_fdw/t/010_subscription.pl new file mode 100644 index 00000000000..a39e8fdbba4 --- /dev/null +++ b/contrib/postgres_fdw/t/010_subscription.pl @@ -0,0 +1,71 @@ + +# Copyright (c) 2021-2024, PostgreSQL Global Development Group + +# Basic logical replication test 4) I'm not sure if so many records are required, may be 10 records is enough: +# Create some preexisting content on publisher +$node_publisher->safe_psql('postgres', + "CREATE TABLE tab_ins AS SELECT a, a + 1 as b FROM generate_series(1,1002) AS a"); + 5) Should subscription be server and user mapping here in the comments? + /* Keep us informed about subscription changes. */ + CacheRegisterSyscacheCallback(FOREIGNSERVEROID, + subscription_change_cb, + (Datum) 0); + /* Keep us informed about subscription changes. */ + CacheRegisterSyscacheCallback(USERMAPPINGOID, + subscription_change_cb, + (Datum) 0); 6) Should "initial data" be "incremental data" here: +$node_publisher->wait_for_catchup('tap_sub'); + +$result = + $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM (SELECT f.b = l.b as match FROM tab_ins l, f_tab_ins f WHERE l.a = f.a) WHERE match"); +is($result, qq(1050), 'check initial data was copied to subscriber'); Regards, Vignesh