vignesh C <[email protected]> wrote:
> That seems better, here is an updated v3 version to handle the same.
> Same patch applies on pg19 branch and tests passes in both the
> branches.
I tested v3 on master at bca67e5a33b and on REL_19_STABLE at
1d094904bc7: it applies cleanly, builds without warnings, and make check
passes on both. With a relation name and a schema name that need
quoting, and a temporary table, the message goes from
cannot specify relation "public."Part One"" in the publication EXCEPT clause
cannot specify relation ""My Schema"."we""ird"" in the publication
EXCEPT clause
cannot specify relation "pg_temp.tmp" in the publication EXCEPT clause
to
cannot specify relation "public.Part One" in the publication EXCEPT clause
cannot specify relation "My Schema.we"ird" in the publication EXCEPT clause
cannot specify relation "pg_temp_0.tmp" in the publication EXCEPT clause
and the FOR TABLE message is unchanged.
v3 no longer has the temporary table test that v2 added, I assume because
the pg_temp_N number depends on the backend. stats_ext.sql already deals
with that by redacting the number, and the attached top-up does the same,
so the case stays covered:
NOTICE: cannot specify relation
"pg_temp_REDACTED.testpub_temptbl" in the publication EXCEPT clause
(This operation is not supported for temporary tables.)
It passes on both branches, and the same block run from three sessions
at once, with temp schemas pg_temp_1, pg_temp_2 and pg_temp_3, prints the
same line in each.
Regards,
Manu
diff --git a/src/test/regress/expected/publication.out
b/src/test/regress/expected/publication.out
index b55da39fde5..57e31e57ea7 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -1573,6 +1573,19 @@ CREATE TEMPORARY TABLE testpub_temptbl(a int);
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 temp schema number
+-- depends on the backend, so it is redacted
+DO $$
+DECLARE
+ detail text;
+BEGIN
+ CREATE PUBLICATION testpub_excepttemptbl FOR ALL TABLES EXCEPT (TABLE
testpub_temptbl);
+EXCEPTION WHEN invalid_parameter_value THEN
+ GET STACKED DIAGNOSTICS detail = PG_EXCEPTION_DETAIL;
+ RAISE NOTICE '% (%)',
+ regexp_replace(SQLERRM, 'pg_temp_[0-9]*', 'pg_temp_REDACTED'), detail;
+END $$;
+NOTICE: cannot specify relation "pg_temp_REDACTED.testpub_temptbl" in the
publication EXCEPT clause (This operation is not supported for temporary
tables.)
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/publication.sql
index e3dbb2bc57c..5ff58d20254 100644
--- a/src/test/regress/sql/publication.sql
+++ b/src/test/regress/sql/publication.sql
@@ -998,6 +998,18 @@ CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view;
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 temp schema number
+-- depends on the backend, so it is redacted
+DO $$
+DECLARE
+ detail text;
+BEGIN
+ CREATE PUBLICATION testpub_excepttemptbl FOR ALL TABLES EXCEPT (TABLE
testpub_temptbl);
+EXCEPTION WHEN invalid_parameter_value THEN
+ GET STACKED DIAGNOSTICS detail = PG_EXCEPTION_DETAIL;
+ RAISE NOTICE '% (%)',
+ regexp_replace(SQLERRM, 'pg_temp_[0-9]*', 'pg_temp_REDACTED'), detail;
+END $$;
DROP TABLE testpub_temptbl;
CREATE UNLOGGED TABLE testpub_unloggedtbl(a int);