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.98.2) (envelope-from ) id 1x99yW-00000001mwI-3dX5 for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 23:32:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x99yW-00000002ByS-005B for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 23:32:36 +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.98.2) (envelope-from ) id 1x99yV-00000002ByK-2lj3 for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2026 23:32:35 +0000 Received: from mail-dy2-x0f.google.com ([2607:f8b0:4864:36::f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x99yT-00000000mef-1eT4 for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2026 23:32:35 +0000 Received: by mail-dy2-x0f.google.com with SMTP id 5a478bee46e88-33e4e75342aso29297eec.1 for ; Tue, 22 Sep 2026 16:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790119951; x=1790724751; darn=lists.postgresql.org; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QZbX93NHoYrjuJVjJiwpiKLO0AxtGcV8mLb20C9O7E8=; b=LqN2ewy4ZHp4wY7JryI4Ntu/s11wJwEpJ7lzCwKipE6ZXabD2bxUpFt6Tf95RkPI7q Muwq3jEBV8xv7XSmVOwPS3/lEanXVbXakjYl56aJu+4OBCqWfmEGUBTfQfvHg7wdiev1 GLqqIAY3kWvHlULc0PqENcgGtG3QyFMFh2cF2M1tZ+YiB0l9+dp2hqu7OBvWXnernIcO SgZmaMaj6wcfSTQti/LpwyMQF7d4Dum6wY21pCHp9I1ffPO+nnXHiQYuUCjDJq48tcSo 8tbMpHhWq9AyK4DHqQVjOqSZ8/5VIjXuGaAmt1pWk9FI+v8S1Gl7cK6keO3NS4zy4DgB 3jPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790119951; x=1790724751; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QZbX93NHoYrjuJVjJiwpiKLO0AxtGcV8mLb20C9O7E8=; b=DQj/JxmQO4+lD5eHSVTw7EoCl2kF6O8b7w7cLfWoutzTnFTcwGpsrMr7bKxazvGk7Z 5u1cmE5aCy7l18vvkjbtTTaHAvucHXq00TT5a/VX9TUv2iCxau0HZw7WOZCXTgcVKC3j uJpJKfxxQDyrhjpNYx9MNEKBQuQHtxz5XlpkY8e517+4ArutlolABy8i92lf7HT3OKvI RLoXFNLmgUr/GZNDajpjcWE9hVYDDyqE1VSKdPJzWSpEp52P4Kl9unSVCWJU8Z6fTA5A HuH+tYxoN2v6McAtRAwitwmQj7eDqXUKhFu8cGdqMt9Gk82UHlwapFAgJm1Py48Fi9S8 Uugw== X-Forwarded-Encrypted: i=1; AKwUvBwG0gN29kFIchhvhY/FWof3QuoI1OO7yiPBhXLxwPUd7BRTpe8e3vQ7nL5TnnX5u/uN0zACP6622o0Cqdm1@lists.postgresql.org X-Gm-Message-State: AFuF++l5G/uT4K1CzVE4kF7790YRntOpP0IFEeMY2R8fRlLyzBAVFnWw GQkjfPpMZxVhqAarUQz8UYl5FenDGF3yAcnKJEJkNVhMjlptcImJTgYY X-Gm-Gg: AYBFou2jAICSiIrmuQf9PvkkMtZCZ1XfYOLN4wPeaeIsVHL14u/TniTiDGb0R1FEuRb hPkJWDjvNHzMclYsjAultTA7n6woBkVDcdiyLGHRKrrZuijl3cdWxewuT/ZEkez+PogNi2J/MMi NBfLEe5MSuc9paPBZdyPNRSuw6WszcBThiqaLg/uJl7A8aDWx5UgtOyvHqivT4BqzeBNS8AJydh G/AjnCviaQHRqXLQLPXNSSJ38RpSyZn2gJHDpLJB74gkbWm5fud+6QEHOTvgok0qKiazrEMCnPq cbS8j3n9lfYeHZ7lPzVxlN4DRspeSw781nvcQQt8Z9Gs9G7U5wmfYvuj5lVvyg3Ckzk84r4I++y 8ZHmTak/MTKhjraXnQqQW4vkHCX+UcdvFRgL/1RkYL5yHI7irhMQFb3ltKRyojx5do6hAJWChQv +g5Z9WZD1QjCsYz8AP6UbQFMS41vjz0yI8Yk18BS5lQAMayViX/5eFM7TL4CyI+cX9VxMWzz0OJ IerzJJfUmLbKbDY/sHmcjVay1KTmH6OKqMwPk2a6ZEnmQs92zvP/HweJfMmfYmaZa5GUVt3MKUC lc90augv0zKmUxJuA5TcJJbvNRnOkhga5gjpGvI9kiKN0bQ= X-Received: by 2002:a05:7022:282:10b0:143:858d:fb0e with SMTP id a92af1059eb24-144f903ac2dmr1520814c88.0.1790119950930; Tue, 22 Sep 2026 16:32:30 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-144f949e51asm1401232c88.1.2026.09.22.16.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 16:32:29 -0700 (PDT) From: Manu To: Amit Kapila Cc: vignesh C , shveta malik , pgsql-hackers@lists.postgresql.org Subject: Re: Distinguish publication exclusions in object addresses Date: Tue, 22 Sep 2026 20:32:27 -0300 Message-ID: <179011994715.485930.9380133175707344860@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3568873159008537116==" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --===============3568873159008537116== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi Amit, > Thanks for sharing the testcase patch but I don't find compelling to > add it along with current patch due to: (a) it is not necessary to use > temp table to test this patch, (b) I am not sure we want to test all > negative cases especially with some special handling though I am open > to consider it separately as a test to increase code-coverage. Fair enough on both counts, and (a) was right: the temporary table was incidental to that patch. Here it is as the separate coverage patch you were open to, and with a reason to exist that does not depend on the quoting fix. check_publication_add_relation() can report cannot specify relation "%s" in the publication EXCEPT clause from six different ereport() sites: a partition with an incomplete detach, an individual partition, an unsupported relkind, a system table, a conflict log table, and a temporary or unlogged relation. Of those six, the regression tests currently reach one. Grepping the expected output for that message finds a single DETAIL: DETAIL: This operation is not supported for individual partitions. The attached patch covers three more, all in publication.sql next to the existing non-EXCEPT cases for the same relations: view -> not supported for views. system table -> not supported for system tables. temp table -> not supported for temporary tables. (the DETAIL of each, verbatim: "This operation is ...") The first two are plain statements. The temporary one prints the message with the schema number redacted, because pg_temp_N depends on the backend; stats_ext.sql already does this. I ran the same block from three concurrent sessions, which got pg_temp_1, pg_temp_2 and pg_temp_3, and all three printed the identical line. make check passes, 239/239. I left the two paths I could not reach cheaply: the incomplete-detach case needs an interrupted concurrent detach, and the conflict log table case needs that namespace to exist. Happy to drop any of the three if you would rather keep publication.sql shorter - the system table and view cases are the ones that cost nothing. Regards, Manu --===============3568873159008537116== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Add-test-coverage-for-the-publication-EXCEPT-clause-.patch" MIME-Version: 1.0 From 39bf631df574fdd7e5120541e7c3f8013227d1ef Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 22 Sep 2026 20:31:45 -0300 Subject: [PATCH] Add test coverage for the publication EXCEPT clause error paths check_publication_add_relation() has six ereport() paths that can report "cannot specify relation \"%s\" in the publication EXCEPT clause", but the regression tests only reach one of them, the one for individual partitions. Cover three more: a view, a system table and a temporary table. The temporary schema number depends on the backend, so that case prints the message with the number redacted, the way stats_ext.sql does. --- src/test/regress/expected/publication.out | 21 +++++++++++++++++++++ src/test/regress/sql/publication.sql | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/test/regress/expected/publication.out b/src/test/regress/exp= ected/publication.out index b55da39fde5..eae1c5ab335 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -1568,11 +1568,32 @@ DROP TABLE testpub_tbl4; CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view; ERROR: cannot add relation "testpub_view" to publication DETAIL: This operation is not supported for views. +-- fail - view in the EXCEPT clause +CREATE PUBLICATION testpub_exceptview FOR ALL TABLES EXCEPT (TABLE testpub_v= iew); +ERROR: cannot specify relation "public.testpub_view" in the publication EXC= EPT clause +DETAIL: This operation is not supported for views. +-- fail - system table in the EXCEPT clause +CREATE PUBLICATION testpub_exceptsystbl FOR ALL TABLES EXCEPT (TABLE pg_clas= s); +ERROR: cannot specify relation "pg_catalog.pg_class" in the publication EXC= EPT clause +DETAIL: This operation is not supported for system tables. CREATE TEMPORARY TABLE testpub_temptbl(a int); -- fail - temporary table CREATE PUBLICATION testpub_fortemptbl FOR TABLE testpub_temptbl; ERROR: cannot add relation "testpub_temptbl" to publication DETAIL: This operation is not supported for temporary tables. +-- fail - temporary table in the EXCEPT clause. The temporary schema number +-- depends on the backend, so the message is printed with it redacted. +DO $$ +DECLARE + detail text; +BEGIN + CREATE PUBLICATION testpub_excepttemptbl FOR ALL TABLES EXCEPT (TABLE te= stpub_temptbl); +EXCEPTION WHEN invalid_parameter_value THEN + GET STACKED DIAGNOSTICS detail =3D PG_EXCEPTION_DETAIL; + RAISE NOTICE '% (%)', + regexp_replace(SQLERRM, 'pg_temp_[0-9]+', 'pg_temp_REDACTED'), detai= l; +END $$; +NOTICE: cannot specify relation "pg_temp_REDACTED.testpub_temptbl" in the p= ublication EXCEPT clause (This operation is not supported for temporary table= s.) DROP TABLE testpub_temptbl; CREATE UNLOGGED TABLE testpub_unloggedtbl(a int); -- fail - unlogged table diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publ= ication.sql index e3dbb2bc57c..dfd1aa83676 100644 --- a/src/test/regress/sql/publication.sql +++ b/src/test/regress/sql/publication.sql @@ -995,9 +995,27 @@ DROP TABLE testpub_tbl4; -- fail - view CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view; =20 +-- fail - view in the EXCEPT clause +CREATE PUBLICATION testpub_exceptview FOR ALL TABLES EXCEPT (TABLE testpub_v= iew); + +-- fail - system table in the EXCEPT clause +CREATE PUBLICATION testpub_exceptsystbl FOR ALL TABLES EXCEPT (TABLE pg_clas= s); + CREATE TEMPORARY TABLE testpub_temptbl(a int); -- fail - temporary table CREATE PUBLICATION testpub_fortemptbl FOR TABLE testpub_temptbl; +-- fail - temporary table in the EXCEPT clause. The temporary schema number +-- depends on the backend, so the message is printed with it redacted. +DO $$ +DECLARE + detail text; +BEGIN + CREATE PUBLICATION testpub_excepttemptbl FOR ALL TABLES EXCEPT (TABLE te= stpub_temptbl); +EXCEPTION WHEN invalid_parameter_value THEN + GET STACKED DIAGNOSTICS detail =3D PG_EXCEPTION_DETAIL; + RAISE NOTICE '% (%)', + regexp_replace(SQLERRM, 'pg_temp_[0-9]+', 'pg_temp_REDACTED'), detai= l; +END $$; DROP TABLE testpub_temptbl; =20 CREATE UNLOGGED TABLE testpub_unloggedtbl(a int); --=20 2.55.0 --===============3568873159008537116==--