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 1tk2Kw-00GYzc-3N for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 14:43:06 +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 1tk2Ku-00GYTg-Rr for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 14:43: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.94.2) (envelope-from ) id 1tk2Ku-00GYTW-I3 for pgsql-hackers@lists.postgresql.org; Mon, 17 Feb 2025 14:43:04 +0000 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tk2Ks-001Lo1-13 for pgsql-hackers@lists.postgresql.org; Mon, 17 Feb 2025 14:43:04 +0000 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-6efe4e3d698so40041077b3.0 for ; Mon, 17 Feb 2025 06:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739803381; x=1740408181; darn=lists.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=NfmsZIVnYG1+I4Dvmw1ZWVgst4M8FmzTJBS67V2wAbs=; b=AU+r1F2wFFx+wHVFZhANOyBnn079uO/8j/nFaPa+tikv7WdphBhDV04F54cb2CxaVj dObTNyQgEet0IoGgS3SrtB+ybPHJmzCisu4taTzWREYtBmUd8Far+p5pfEeoHMqneZ/p bmdRf6ybhnyfzv01XkE8Ls/E3o8MBLw8jah3bP0ylZbL5FewWkii+pYQ3BBsHy1uQ3Hd FWheOX5TrFjktNtQAVsu/9WSwkiEivM0FyqE2gowJS+j7fgyBFykIG/rxpbn2h4btM51 98bbasbQomnChVadbKO4LRNEy/EPWMcqd5YFFD/wt/YauAi1GrWUJnUbdwiTuaU9ct9q HmsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739803381; x=1740408181; 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=NfmsZIVnYG1+I4Dvmw1ZWVgst4M8FmzTJBS67V2wAbs=; b=vCddUXjgONMQR7/rd39b26Ov2O1SBS5OFKbTXoNT5AzRsRYLbGYeTJnJdHQQlh9RxC WRmcGzRJ4hm/umPIfoNWS6HJqqBsKn7XId0M5Fw+R7K0U7Iz1R5as7WTPJFfG1SzILDA O9dhCNn/9Uge7oe55CAAwPq95zHswoXK2uU6qBwq8Jov5n5p0OqpssO2xIy3fdjPklmy sjGFSEZZ+LfDQjvPAnFH2frh6NFyzEdt1deTQEWPQO/NQPrQUKUpM25OrkTXCet8OW02 OhpsG2pwvq1nKeWYqWOLG6nkNWTI2erVvUvcWaDzFHTBjG6/0+sDPWPIRghBDdnToKUK dcoQ== X-Forwarded-Encrypted: i=1; AJvYcCWLyXxoh3pLvN/V1bd2FmRgjz4ZGaxrCySF46cmY8yCXCun+6OqEvb3TkVsEk994bxAGgS4FoJ/gjMahN0C@lists.postgresql.org X-Gm-Message-State: AOJu0YzQcnTTPJ4yY6iZw2ibxlmNPOs6TRV7ttxYtBodsft89JHRYzrz 6HQNHk/AAckmCctJbMw4v4X8ZuRmEghirpzOOnMuI//GZc3UW4p7a1l2OH1sYbQ4OP/VA19SgOX 0QGZfjsU11zeWYa4azXAkuJ0zSAs= X-Gm-Gg: ASbGncvCmm+kENqIUtA1rbHDqszNTE00pmNxbv2ZKBtOMgb6P8l51nYlWx59cNsajH5 yH+hpXN732CS/VyqZQnc5uhb9d6tRSNCF3hzkX8faJwsP/JKq9BbVhlJV0KNoDjLwyq87UmlSAq KWrLEFBHkPGT9egGqxr6V/sHJcW2srDJw= X-Google-Smtp-Source: AGHT+IFsyohDgk+oVyNwISsHnxLYL/xVG0bZlfQomT/wr4E7f6WFrsGhu8mDxKvNNFbI6IuEqzPre1k6anMrt+3htZc= X-Received: by 2002:a05:690c:d8a:b0:6ef:7312:d05c with SMTP id 00721157ae682-6fb5826f264mr78095187b3.2.1739803380617; Mon, 17 Feb 2025 06:43:00 -0800 (PST) MIME-Version: 1.0 References: <202502050844.4lrgg3aoudat@alvherre.pgsql> In-Reply-To: From: vignesh C Date: Mon, 17 Feb 2025 20:12:49 +0530 X-Gm-Features: AWEUYZnv6TwUW94G6bljyWn3HMifyl-8TC1p1a9hKAHDNw_l1i0HqNA-jrEI6zo Message-ID: Subject: Re: Restrict publishing of partitioned table with a foreign table as partition To: Shlok Kyal Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Sergey Tatarintsev , pgsql-hackers@lists.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 Fri, 14 Feb 2025 at 12:59, Shlok Kyal wrote: > > I have used the changes suggested by you. Also I have updated the > comments and the function name. There is another concurrency issue possible: +/* Check if a partitioned table has a foreign partition */ +bool +check_partrel_has_foreign_table(Form_pg_class relform) +{ + bool has_foreign_tbl = false; + + if (relform->relkind == RELKIND_PARTITIONED_TABLE) + { + List *relids = NIL; + + relids = find_all_inheritors(relform->oid, NoLock, NULL); Create a publication with publish_via_partition_root as true, hold the execution after check_partrel_has_foreign_table execution finishes. Then parallely execute the following: CREATE TABLE t1(id int) PARTITION BY RANGE(id); CREATE TABLE part1 PARTITION OF t1 FOR VALUES FROM (0) TO (5); CREATE TABLE part2 PARTITION OF t1 FOR VALUES FROM (5) TO (15) PARTITION BY RANGE(id); CREATE FOREIGN TABLE part2_1 PARTITION OF part2 FOR VALUES FROM (10) TO (15) SERVER fdw Now both the partitioned table having foreign table and a publication will be created. Regards, Vignesh