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 1whOa0-000CIu-2R for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 09:28:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whOZy-006RSK-2V for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 09:28:31 +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 1whOZy-006RRv-1C for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 09:28:31 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whOZw-0000000087W-464f for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 09:28:30 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-381507c9380so355000a91.0 for ; Wed, 08 Jul 2026 02:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783502908; cv=none; d=google.com; s=arc-20260327; b=F5nZs5GBBYp+xaKyCELfyl9+TPUqBUSJ9nARQbuNqrgslkS4qs9+dIugwdc2TnT9AN tc1pnaoRK0RAnRfNPD935na0meQSBZlsjjCHAvPXhWL8vcMRu14/E2y4c+R3FMEW2pKG DIAaKLTs9x/TPQMhCBtshVFJ+Xf9Cb5lT0vDCTrGdAm36nGWwZh+SQNPH5oCc9ZrQ8F+ 0p4d+B7QcMuRqOIKLg4iRrA9XxlpRyljGnRMkS5RkSxndoarOdtieNGjGnMIaeLMhetH u9K/w1SRTa78E2nAoPWmRHbNIYRV5YQp7hIna2qw6JWewUOKgPL6UpBGWCYfK/pbIZ8y IChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ly2yUEVtq+JQBx04/tFMCyhEwP82ScdCojb6s2Dh3RY=; fh=SxfIVGvbF0Cw6X05+7rt51zwOIP8+YbCHjhCjIUeE0Y=; b=BRWXlu4NzVxCjnKLQb+iLsIhfTPrelqYuqhTbSsJGUwkuAtSUPmlzesOiRxLsQo/Ua SHreIBJmvnP/rVf2GWkkEI/1AR3oHVvMDI0gjBHtXQeixarL8Phkj3S8/Lf+7sGbZp63 ay7hmpRhIuhAv8chaWIswUQow1HZvEP2I+5JM5cTNoFuMRSa3LeISi896ytbTPQKsK6o kXt7y+yztqvP9i6gYO9v+dTADHWVEEzPcXNof8robNzGmOyB4KOpzLBKH+ORsrBIZJ48 6Mz2YAauRQv1w+jGLNaYnglqPI/tzcP66VfgCtPOYb/fUwt8Ibl/nEPB4UWZ1HTSRuMN a75Q==; 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=1783502908; x=1784107708; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ly2yUEVtq+JQBx04/tFMCyhEwP82ScdCojb6s2Dh3RY=; b=Igs/zzdWjhjpHTLYUJcmdHqE7CQx/ka1g2nuMv/LGXtj6/w3vytAEOa6QeVvwQJncC KEd/JnOoqA3rr24pCJXAzUMZLshO4nYB4AS0JDR8kzFW99RR3R+o0MBgcEGmg9CaQUIh AoY7M+OLRFhjEzGOjqex8L2zBVJDeppfmPdTik9Fbfp9V76zt1uPvBXFPaD/FY3XcR02 jcbbeS+XI+Xwl6cFSc+T+ICQCzKUM+6D7S8uOEnl2X4HiUHqbowgWVhX9ZduSpVB81iH LMvIudjZioYxrnG8U9ILxN+gJ0IbmP/xjwbArVH+PRuT+aWZ/9H/hymzHVJ937iTXScB 1QQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783502908; x=1784107708; h=content-transfer-encoding:content-type: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 :content-type; bh=ly2yUEVtq+JQBx04/tFMCyhEwP82ScdCojb6s2Dh3RY=; b=OJ2FMf8j6nExbtIAajWMiaUTm+wAehPsGmLdLHGsBMi963UI2Av1lYOZ3+AxImawbF Ymd2lIIZIrc/oCTYMZeuq9T+mrQAZRLVNf8VpUS09ASvHjaakqW8YLQH/oEDGvazJ/zv ScpLiX8Tq/ecReTz8utc49kV23WLmVG7ca01mTqNz1wXZIHWvcksf29tnf8zG9F4zJlT 3GrUGgc7sIYQ0ep+nQzVqMlyA2lO8Dxdh0GL+B17F4CWLvInS8GQCyUIhvFGoX9od1BO qp3k/rcgf516AoKjjkBWg5/lW6BV2/1Uvy7sj4EwK0Q9NnyUbLJQ7zFzGbsgFsWQsVcz PxqA== X-Forwarded-Encrypted: i=1; AHgh+RrO2JYnBpAgKn+EDHCskvvm6RG4zg6diXQAgOGf9mMpPLiAU13vvXNGpj4EoQUevUPenABtah0Y/BGC7u7C@lists.postgresql.org X-Gm-Message-State: AOJu0YxZgXr/lYWIGZ6K8WqcBZ5BOLaPbRVX4T3g+IQaguRK5cBhQW2w yPAeMw3GXGbl3Zhy339OYrqUEJSZwhQxeTxSET5Hw0Q8rgjt734y/R1WumH36MQoDt+lqZ53and hvqKaODD3xFpzGSPB3axBT3Z6M7MzNk4= X-Gm-Gg: AfdE7ckiy+sf7QhMW7Gkf22bAEk4U1aWnRMZdhNuTYnLf+ZWBKh9/zBYQfkvrUINLhb uTd0oS+0wm4K/ExG0Qp/wvnA+5P7ZLAqvU3cLv/FBgncmJmrjtwq77LVDNkFAMUdFE9za4kXeJL ZxOdxxAVs8PU/unP4wsfI5xtRgk52Gdm2ShBKf9nDx1+4NUo6nXGVifQvVQ7j4yI4wKo0iK3Msn jMzid5qHi2dZkNiapH4MSiyibLJnu1VrlcwArWWWxf/TYRE3p98/RqFuRzGnHjF5RwHcKB/FBaR TQfr65tFqHnt28F5r05frRgGi9v+pzyw+P6/nE4n X-Received: by 2002:a05:6a21:1f88:b0:3c0:9c19:b27b with SMTP id adf61e73a8af0-3c0bcce9940mr1866093637.73.1783502907673; Wed, 08 Jul 2026 02:28:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 8 Jul 2026 14:58:15 +0530 X-Gm-Features: AVVi8CfiWTKEBfxd_80Pbq1UdzoT5Qy-SVkd5Z681s31oQwUj1epGw0rtrvGvs4 Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Nisha Moond Cc: Peter Smith , Zsolt Parragi , pgsql-hackers@lists.postgresql.org, Amit Kapila , shveta malik 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, Jul 8, 2026 at 2:22=E2=80=AFPM shveta malik wrote: > > Nisha, the patch (testing wise) is okay, but some code-optimization > might help. I am stuck on reveiw of GetTopMostAncestorInPublication() > and all its callers. > > 1) > caller 1: pub_rf_contains_invalid_column(): > > It is not understood why pub_rf_contains_invalid_column() does not > pass 'exceptPubids' to GetTopMostAncestorInPublication(). Perhaps a > comment will help. IIUC, a parittion (for which we are trying to > verify row-filter expression) can not co-exist in a subscription where > its ROOT is already excluded. This assumption will be true once you > address the issue of CREATE SUB (in [1]) sent in my previous email. > After that, this will still need a comment. > > 2) > Both caller 2 (get_rel_sync_entry) and caller 3 > (is_table_publishable_in_publication) are trying to see if partition > should be considered as included in publication and thus are trying to > see if ROOT is excluded. But the implementation is very different. > > The get_rel_sync_entry() does that by passing except_pubids to > GetTopMostAncestorInPublication(). This except_pubids was computed for > topmost ROOT of the parition in the caller and then it skips checking > pg_pub_namepspace if given pubid is part of except_pubids arguement. > > While is_table_publishable_in_publication() does that by selecting > topmost ancestor incuded in a given pubid using > GetTopMostAncestorInPublication(), without consulting/computing > except_pubids. And then later checks if the ancestor returned by > GetTopMostAncestorInPublication() is in pg_publicaiton_rel with > 'prexcept' true. > > IMO, GetTopMostAncestorInPublication() should itself be inclusive of > logic where it filters out the table (does not return it as result) if > ROOT is excluded. And even we should not be passing an argument for > that (this is my initial thought). By making such a logic, we need not > to bother about all > the callers to see if caller has correct logic to deal with output of > GetTopMostAncestorInPublication(). Can you think on this line and > check the feasibility. > I thought more on this. Do you think we can do this? GetTopMostAncestorInPublication() is already accepting a list of ancestors in a ordered fashion, root at the end. We get root from this ancestor list, check if root is in pg_publication_rel with except=3Dtrue. If so, we skip the rest of the logic and return InvalidOid from GetTopMostAncestorInPublication(). The 'except_pubids' argument is not required. Callers need not to have special logic to send this arguement or to have extra-processing on output as done by is_table_publishable_in_publication() currently. Let me know if I have missed anything. thanks Shveta