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 1wXAgr-0036Rr-0f for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 04:37:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXAgo-0097l4-0A for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 04:37:18 +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.96) (envelope-from ) id 1wXAgn-0097kw-2A for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 04:37:17 +0000 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXAgl-00000002Gm5-0gd5 for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 04:37:17 +0000 Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-8ccdf8d4ac5so67261576d6.1 for ; Tue, 09 Jun 2026 21:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781066233; cv=none; d=google.com; s=arc-20240605; b=kERK1mxyPLLluLbODemJHFKcq083UFqX7gPBh7Y43RHZaQNu1SmoHgzoMorttnsWOR iNmNiMi+xpD7LS+XjQAZdwVwZrYwCu/uW3xa5HFIyWXWt9llAsOQoADui9t4wZ3TSCSB Hq14hm3N35CPCEImUzceM75vx6FrqHhbNEfFmDGBiXsbDI4wED+g86IU1fGOKKRqWkUl gxsbGViD+hx6H3dDziDIzhMsY865MY6BOL/fnKMR9234vkAadNSlo9Dq7+fDTY6DWFEk e5lJszv29qK4TS2K2eHLysak2Q/1EHt0HjL54oSSFX6phqTnJc4rFIAAONR5sicsltuj 47wg== 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=BZylxh8ftEDiz+1cMhfAc00UYQ228NEbWs9mhMVYt/o=; fh=4eBsROP6U7UGu1Il175lbat6Dl1VlBp/skAVVri1rvY=; b=DkPkBusiwbDqCoPGx1HAaYRxZqxSlHrwHxyncq0fxLTUnZ4DX281+mMOAKFZu44dZF xsmNMKTeSb8xtPYmNI9UcvCqQwmKfnr9f3VnjrG4AXBDjkWogN3LsriyP9+5XGbcgXnF wmjP1wMb2Oh1bciegjW60H+pdMF8OxuYVzN4PpsmXVQEUxzBVI9T83vIXS+IJ3WrHwiE 2+035pOmPdkxg5Od/xg3nCLTzv/meZK1nWhqdE13xTVfugu4svRFrYgJOZCeJ+0DZRNP KTJ3jfk9lq11AeWv5PlTMpn5sadmSXgB4xdqYrc6Gz1VLycnAf8rGl2OsB2sfBCX10k5 NVlg==; 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=1781066233; x=1781671033; 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=BZylxh8ftEDiz+1cMhfAc00UYQ228NEbWs9mhMVYt/o=; b=f1kilfzHBh/PWwINTRYTETEznm7jTRE8gLf3gUD9r9lIC9oNvkUibN179K+x8nllav sGCRyDlz8lcZLBuupaM0+p86KMCILh8Ejvpv3sAxL5UfEdj6vPdG1pPNDVC9ZwA4mlVz iVA6a1p27HBbHpOR1bpGWA9N7E6LteSUfsFUahE3j0raJdo2lfLCk8F9UfJEnhwg0XrS xEX7zq0gXRgEY1YwikUgV0iWj9ibMYk2NV3VBDUdzw7H58l918Il5EKOxZ8hy7ieQBu4 kp3wkKJY2HvOgRn00FqL9svhYRoBMI4I4tB2COyoCyAkk9uWpkJTx23/G6SbUAyv6a21 cLuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781066233; x=1781671033; 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=BZylxh8ftEDiz+1cMhfAc00UYQ228NEbWs9mhMVYt/o=; b=bMjo2QhIySrBkx3aJjrr7Y9DB5ualuLqYEa8VWZnny2E9AmVYi9lOAkxarxevX89P+ 79rWqggKRx3X7zb2K1Yz93Z9Q9qkyRhyDQGDL9n+hdeYdwdNN07nEhnaulWBdVHZFs1w JXHgwmnBojZyJOIsbAlLkzsrOsRnfAPSAZ0qLYuoe00+c8CXHS1+mNfPGNhmLloMUsJ/ /p96M6w0HtiuGR3+pMICnGqpis6Pzj6jBk3RH9LSHO6J3k9ENCYRofIQhefEcjeJV+Go 9rc7sY/p0J2nJf2arq6KHwDgCqU0d3X6KJBgbGEz8Hl9HAwEVVCVGh3kz8gGZi5I+x4h gHxA== X-Forwarded-Encrypted: i=1; AFNElJ+DG5rH3BKGVWKPBCJttJoRXnaLdYHKXTUmNsxFEtzEvvAU8HOL6/57w6YVqGKL1NOBzA7qlG2XvM6nwUOQ@lists.postgresql.org X-Gm-Message-State: AOJu0YyGgECRi8DTBNu4tEcjzURSVOC/fYzeUEUB4KnHO/jDWs0fPnbz M7p6/bSdr4PANtLdBRsHGyqhs3zbkveXP9eE8TZ+P3nDH4v5I5l/sTCWbijMD3Mz5C+B5cN5pm1 wMWKNXqFYp05Q+g5XTGbrc58rmuUUlQ8= X-Gm-Gg: Acq92OE2/OOzviVNh/BC6qF8Jdvsbm1rfHV0evF8GUOFqfAYWV7gYMCwSRAQF8aQJzY c1/r3UhZVZbAJ6KIzIS3YR8QP+SUE2ptjOs4inYpLk3ePOsAD37i2fNsfEnfhDw/qB1jTKaQhr0 n+MBWrmL4BW82hPFT75oFoZCJLJMRHtpYzzky0sFxbyHuaGZi7CHo/RZjWXObdiJ+4iqS2fhFWY maWln+spBM76xK0BXUkTYiRXaNGU3alFnMb3HFgmiqLtTxKEnRDFMNfDmVHRfhBYxVQNYrx8Bmy I58OjPMBHUYQkkQXh7UTerxrqyjk X-Received: by 2002:a05:622a:2612:b0:517:7d99:f32c with SMTP id d75a77b69052e-51795bbdd16mr313459251cf.32.1781066232971; Tue, 09 Jun 2026 21:37:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Wed, 10 Jun 2026 14:36:44 +1000 X-Gm-Features: AVVi8CeMTI5HrI23MdmfQKhAnbAbZezXnXXbqslUtYe_5YF6we9L7FPKOBz7Lsg Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Nisha Moond Cc: Zsolt Parragi , 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 Hi Nisha. Some review comments for v11-0001. (I had no new review comments for v11-0002, v11-0003) ====== doc/src/sgml/ref/create_publication.sgml 1. + + For FOR TABLES IN SCHEMA publications, the + EXCEPT clause is schema-scoped: the exclusion applies + only in the context of the schema to which it was attached. If a table + listed in the EXCEPT clause is later moved to a + different schema using ALTER TABLE ... SET SCHEMA, + the exclusion is removed. The table will then be published if its new + schema is part of a publication. If the table is moved back to + the original schema, the exclusion is not restored; the user must + re-establish it explicitly using ALTER PUBLICATION. + Dropping a table always removes it from the EXCEPT + list regardless of publication type. + 1a. I felt this should be moved up to be the 2nd paragraph of the "EXCEPT" part. Subsequent information about inheritance/partitions/multi-publications is common for both EXCEPTS. ~ 1b. All that info about "If a table..." seemed more relevant to ALTER PUBLICATION than to CREATE PUBLICATION, so I didn't think we needed those details here. ====== src/backend/commands/publicationcmds.c RemovePublicationExceptForRelation: 2. +/* + * Remove any EXCEPT clause entries for a relation from schema publications. + * Called when a table changes schema (ALTER TABLE ... SET SCHEMA), so that + * a schema-scoped exclusion does not silently follow the table to its new + * schema. FOR ALL TABLES publications are skipped because their EXCEPT + * clause is publication-scoped, not schema-scoped, so that exclusion should + * persist regardless of what schema the table is in. + */ Instead of saying "FOR ALL TABLES publications are skipped", rephrase that to be something like: "This problem does not apply to FOR ALL TABLES publications because..." Anyway, I think you can remove that note from the function comment, and instead put it here: + if (!is_schema_publication(pubid)) + continue; ~~~ 3. +{ + List *pubids; + ListCell *lc; + ObjectAddress obj; + + pubids = GetRelationExcludedPublications(relid); + + foreach(lc, pubids) Using a `foreach_oid` loop might be tidier here. ====== src/backend/commands/tablecmds.c 4. table_close(classRel, RowExclusiveLock); + + /* + * Remove any EXCEPT clause entries for this relation from schema + * publications. A schema-scoped exclusion is no longer meaningful once + * the table moves to a different schema. + */ + if (rel->rd_rel->relkind == RELKIND_RELATION || + rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) + RemovePublicationExceptForRelation(RelationGetRelid(rel)); Should this code be put prior to the table_close, where the other dependent stuff is also removed? ====== src/backend/parser/gram.y 5. + /* For TABLES_IN_CUR_SCHEMA: leave except_tables for execution time */ Isn't this repeating exactly what you already said in the other comment ("For TABLES_IN_CUR_SCHEMA the schema name is not yet known...")? ====== src/test/regress/sql/publication.sql 6. +-- test for EXCEPT clause with schema publication (bug: excluded table was incorrectly returned) +SELECT * FROM test_gpt(ARRAY['pub_schema_except'], 'gpt_test_sch.tbl_sch'); -- no result (excluded) +SELECT * FROM test_gpt(ARRAY['pub_schema_except'], 'gpt_test_sch.tbl_sch2'); -- one row (included via schema) + Is that "(bug: ...)" comment necessary? ====== Kind Regards, Peter Smith. Fujitsu Australia