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 1wAJrG-002Gef-1C for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 03:45:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAJrD-004SGY-1v for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 03:45:36 +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.96) (envelope-from ) id 1wAJrD-004SGI-0z for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 03:45:35 +0000 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAJrB-000000019aJ-3tJF for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 03:45:34 +0000 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-7986e538decso61008587b3.1 for ; Tue, 07 Apr 2026 20:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775619933; cv=none; d=google.com; s=arc-20240605; b=f7GkoQJ2AYvc2jnO4RuSBwgIgu6V2KaQNTBhtDsfR8daRA/basI+Xp3fQ2b6jasla+ xxQ4R/cS+hOX9xwmw+nbk/6MxHqeLI5TyobPzxwDqCg8IiIp/DJaC9V+X0LOcTK4LhCG JUQyzixbO6YoBH24R5cy6hnewycseOegY478CmmSNDe4pju0wFRIhq0TYET3+kNk2Pd8 It/7Ut/w8DeqdyuxAtKdCjgrOEF3Zc3b3y7JCUr+8CX2QJpFx9suLPeGgAyCsMAcIqrm YLm9As+YpzVSS7I9Zee++cbn3AJX9prVv9MvAMgIZRTcjsTPW4KfFI03HpjJFJcqERLK 4RKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=26P3L4p0UcROlZrRsOMLli2fny/3ujd35r5jqGJHxMI=; fh=KcfTCw2ZVqAV+lTGR3KRT9q1CRnyXcs7hTtvM0Hb+1I=; b=VOU6dQ7bAxI/FnfVQvXfssSFwth71BbrWunsoLQ7AJwFn3A7su2ETaTo71j0A9jT95 mXrYa5PnVtqcXCifpg7dtUoMNxtVWRYLBymZeLtglZxSj1oTf/zVd8viInY8dWnDwGF8 T+5EPkmuPEejnwmXwqzEjmGkdvMBXeGidVi0vvltYWpyotcLXsMxxUqwSmnn7O33/yA5 wdFQToP2fxv7msRqggqj8xoZ8V6Gn357XMgnjZ2bsv8ZVXCrUHbHgf79xjgZi7dwpxDG CCqHcArT1NQ50tjt6NxiAY5v3ss6GoevgxXy9JxC+0b5Ty1l6QJPiO+7e/aaypOi0BPz kSyw==; darn=lists.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=1775619933; x=1776224733; 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=26P3L4p0UcROlZrRsOMLli2fny/3ujd35r5jqGJHxMI=; b=OdEMLYKfOEDjAD/3gG2b8zC9B7yDAI1eNsUP3jXJ76FTm1u/o7bl8Yqj9PJypBwbkY LVV4++nqf+Xlng4GJWROqSEwE1q1D5aPRi1P0b/Yxylq9waPnyRY4aoOlp+ZNK0BgUZi BD7MAK3+vx/8gH6C2l/Cj/By1c+Vb6eplCMYP1wMWK8iF+7h7XEgN29PMpS1RYjGVb1d 4shzPJ5y3nZafntWcwbVWZfIHzKrpJJ4Ivx4eVENB6MD0Joa/r1V063qoSs2/YsJSt0O 5UA0626gnKI9W5RFCrBMOin72AM749cBtGXPduC1ROQPqIurDEkMK8eXAaL2aMQSJzdY EjPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775619933; x=1776224733; h=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=26P3L4p0UcROlZrRsOMLli2fny/3ujd35r5jqGJHxMI=; b=FPZ6ya4zS7cpx7kC0pKEFTXTKXzaNigW77gxhJfzPht3l0/WZOGNg3LlQQy8NmzTd3 R4UHwEc9eKaNhyerTYcTvFtc3ODv9zaE81LRDIaSMW5fcZF+fDWlNU5Aq7XZ03xa9UeN ZpxokDzVP2EJ1o36x8I8HapKWOkWoKu/VGsIiLVjLXn4J4/JiCEcrESZIdLHKOwaX6B+ f7e23uHn/Iu2dfUI0IOyvucgqarWbKY/LoUp0/h3SNfzv10F6SkoRL4vrBBdy2GDaUVH +CXWmMr0ehpOwHX/fCweM0hNRc1IW01HyhDG9l2s0LuMYixYTwY51csX8B1viZKG0R1W HuGg== X-Gm-Message-State: AOJu0YxMPAUnQYiixpxH2rars8OuaEXGgl93LMfrQFRLlVtYiG6rS4MI VkbrGVMo6pwBPPwnyEGKYvvHM1mT4p5o2tzSdcHXL2ANp3AJG3TAmfGw/+K6ezAnb6fM5/Ti+s3 3VWNqzPNndzaiIbCDYxwpxls2NRlZy3E= X-Gm-Gg: AeBDievoQ/2aXR9YEKBJh0MyYqQ2ngP7V2quvFyv6SR4mNyFngYx//ttImc/pGwdz+X Ujfy8fFDnCtqCmc/M17RWYwBszh1e5P/Z0FQpJMXUuwyzQHYdMwd+34wFNZ8eD4Sn5jIuNMVtIr iYV3O+XpbHy5d+DMAnelLOKFnIbrEGVVhAMn4y5kdBgIFjvqNFGlYWIsyGOpUZzXIsazu0g4PQC NBspjH/qRM1Rb6M4BeZXe3eZt1pTQPpetgtis7ZUCnC1UTyR0QnXbrMTl8u1q66DCJgw8yGxESf 9lJIHnE2fg== X-Received: by 2002:a05:690c:c50a:b0:7a2:ce0e:8635 with SMTP id 00721157ae682-7a4d6b307f0mr198244787b3.19.1775619933382; Tue, 07 Apr 2026 20:45:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: vignesh C Date: Wed, 8 Apr 2026 09:15:22 +0530 X-Gm-Features: AQROBzDJkJHeadnyxYb4Y-OYJF9hdmxW3df9MpCYLfpW6se8-eqsJa3MJTU2nGU Message-ID: Subject: Re: Logical Replication - revisit `is_table_publication` function implementation To: Peter Smith Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 7 Apr 2026 at 12:32, Peter Smith wrote: > > Hi, after confirming my understanding of pg_publication_rel [1], I > revisited some logical replication internal functions. > > Specifically. > * The `is_table_publication` function is for checking if the > publication has a clause like "FOR TABLE t1". > * The `is_schema_publication` function is for checking if the > publication has a clause like "FOR TABLES IN SCHEMA s1". > > Notice that neither of these ("FOR TABLE", "FOR TABLES IN SCHEMA") > clauses are possible simultaneously with "FOR ALL TABLES". > > And we can readily discover if "FOR ALL TABLES" (aka `puballtables`) > is present from the pubform. > > We can use this to optimise and simplify the implementations of the > `is_schema_publication` and `is_table_publication` functions. > > PSA patch v1. > > AFAICT, the result is: > - less code + simpler logic. e.g. is_table_publication does not check > 'prexcept' anymore > - more efficient. e.g. skips unnecessary scanning when puballtables is true. > - more consistent. e.g., both functions are now almost identical. > > Thoughts? I'm not sure if this additional check is sufficient in case of is_schema_publication. Checking only puballtables can exclude FOR ALL TABLES, but it still cannot distinguish regular table publications, empty publications, or sequence publications. In all of those cases, we still need to check pg_publication_namespace. And also why just check for puballtables why not to check for puballsequences +is_schema_publication(Form_pg_publication pubform) { Relation pubschsrel; ScanKeyData scankey; SysScanDesc scan; HeapTuple tup; - bool result = false; + bool result; + + /* FOR TABLES IN SCHEMA cannot coexist with FOR ALL TABLES. */ + if (pubform->puballtables) + return false; Regards, Vignesh