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 1tfZ7g-003MNp-2T for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 06:42:56 +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 1tfZ7e-00CFIR-Oz for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 06:42:54 +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.94.2) (envelope-from ) id 1tfZ7e-00CFIH-Ew for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2025 06:42:54 +0000 Received: from mail-yb1-xb31.google.com ([2607:f8b0:4864:20::b31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfZ7b-003GRG-37 for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2025 06:42:53 +0000 Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-e545c1e8a15so5818344276.1 for ; Tue, 04 Feb 2025 22:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738737772; x=1739342572; 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=n8AVEnf6dbl3kl7nUNq/s+8Sij0UTSX37KbRFQ9Q/Pc=; b=O6VVnh7+L+tvLP3IJrJaUsTuaLsdwjtk+/oa9zYYciHT2StbfypPXd4CWAC9Jglm+S i6p7O/IeFRMHaDiYPlvAgIPUchs/XnIbgIuqKbo+HjxtjX4XsIyA7pfSOxRtxCwn7nNN 3qWgjLLnKkYJdFIiEHuMeKfuz8Thq89wMl5UFlk0YQBp+ggz5I4/yG71i+9NWnhZFAMs egYWkYYbc+SBfPKEiDXfADVJkcAxqp0bLMLJ+/kj8hSP2ADj4AtdU+1LduZodEKg/GsW CxwI5mz68TGwfdmLOHz8DRU2zXkjASoVyf38R909A88Fx2bT/JRJ0hxIjmgAd7LF6F3c JHKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738737772; x=1739342572; 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=n8AVEnf6dbl3kl7nUNq/s+8Sij0UTSX37KbRFQ9Q/Pc=; b=SOcJ6y/rIL3s/h8lTLlTUcItAwPej7cjjLTZtEyHSnUTGoeNVOYXzdVG+la0x9Hy4d 2zv+I1j55etZkUXeFIw+wwf8WrtWgwVaIEqjU4+KggRe8AfCLezQxuouBqpCXf9W3WSl 66khIvXS0US1zH1mSR5Y8sCr7ifgxYNaNty7WjwpLV43A0Fkiw0CLbQXAlMlnXLbcH+r VuEcbirm2LX0ZSkWoLwDIXf3v4XYnhkNgc6sAJkSM5p+5om4/bc314BM9TMIVCEFcrIb Sg0NtHr4EIp92qn8wTBRe74Zd2kBlZrdYGs+qKfI74RUpCfEIkyLDyE58wQZJbUcJ0ZQ /tmg== X-Forwarded-Encrypted: i=1; AJvYcCWx9Hd9rw9ey1hgz5fJCiMLlSyFk+eSECWpyv3FakOsVDQmeLApT2wmd3KEhPh2Ew+KTmn+SmL66o/q+DaI@lists.postgresql.org X-Gm-Message-State: AOJu0Ywr5OfnwTCibKRDMgSqzW96xOL96agi9sx+JVYJY/yQDFAgRzOn X1F/pfMaA3NrY7BXOY4IQXdNaOhaLy1Y/2NxWjwx2CFAzDVui4XCGJztLQrX+0+SRqjD6D3WOz7 aM1M3srxR9R1cYfx4IDUMuheIOy8= X-Gm-Gg: ASbGncse/SRkETnDak7XCPfMhrHsyNPa79hl1p7ShZCcsP+acZPyWGEkg8xGKtPnKXM qLzt0OXRvkz1WryL3nuTrsX+Pv+nLh8INwdfUEwJVa2ufkfd/dec1fgi6oma+yuJ79r3Gwl3Cwg == X-Google-Smtp-Source: AGHT+IHzSbWVAk7m/jiN2nyYC+UF7LMxS+WS4yNX2wKJm4QWPt1jvLIgNDZ0SElwBjdCwwG35u/aSmIdq6F0Q21VDuM= X-Received: by 2002:a05:6902:218d:b0:e5a:e88e:b2d5 with SMTP id 3f1490d57ef6-e5b259cc676mr1317102276.9.1738737771594; Tue, 04 Feb 2025 22:42:51 -0800 (PST) MIME-Version: 1.0 References: <202502041551.f7njlr25ie3u@alvherre.pgsql> In-Reply-To: <202502041551.f7njlr25ie3u@alvherre.pgsql> From: vignesh C Date: Wed, 5 Feb 2025 12:12:40 +0530 X-Gm-Features: AWEUYZmLS3t7G3PatF8ZXkZtjsaufrRblJlRe1As1MWJmn0gE3Yqn8oqbV3-H1g Message-ID: Subject: Re: Restrict publishing of partitioned table with a foreign table as partition To: =?UTF-8?Q?=C3=81lvaro_Herrera?= Cc: Sergey Tatarintsev , Shlok Kyal , pgsql-hackers@lists.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 Tue, 4 Feb 2025 at 21:21, =C3=81lvaro Herrera = wrote: > > On 2025-Feb-04, vignesh C wrote: > > > We should throw an error for partitioned tables that contain foreign > > partitions, as this would include the data from these foreign tables > > during the initial sync, while incremental changes would not be > > replicated. > > Hmm, I would support the idea of allowing partitioned tables containing > foreign partitions into publications, where only the tuples in > non-foreign partitions would be transmitted -- both during initial sync > and during replicated DML. This way, any partitioned tables with mixed > local and foreign partitions would work okay for replication. If the > subscriber wants the data in the foreign partitions, they can create the > foreign table on the subscription side and all is well. From a users > POV this is probably the most useful. > > Another aspect is the case where you create the publication first and > the foreign table later. I didn't spot in the proposed patch any code > that would check whether a publication including this schema exists, > which we would have to do if we wanted to be watertight about rejecting > publications with foreign tables. But I think that would be a bad > direction to go it. > > I'd rather have the table-listing code for publications skip any foreign > tables. For instance, GetPubPartitionOptionRelations() and > PublicationAddTables() should skip tables with relkind RELKIND_FOREIGN. > The sync code should also silently ignore all foreign tables. We can maintain the behavior you suggested when the PUBLISH_VIA_PARTITION_ROOT option is set to false. However, when PUBLISH_VIA_PARTITION_ROOT is true, the table data is copied from the root table (as intended by the user), which will also include the foreign table data. In this case, wouldn=E2=80=99t it be better to throw an error? Regards, Vignesh