v7-0002-Add-publish_using_root_schema-parameter-for-publi.patch
application/octet-stream
Filename: v7-0002-Add-publish_using_root_schema-parameter-for-publi.patch
Type: application/octet-stream
Part: 2
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v7-0002
Subject: Add publish_using_root_schema parameter for publications
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/create_publication.sgml | 15 | 0 |
| src/backend/catalog/pg_publication.c | 1 | 0 |
| src/backend/commands/publicationcmds.c | 56 | 38 |
| src/bin/pg_dump/pg_dump.c | 19 | 3 |
| src/bin/pg_dump/pg_dump.h | 1 | 0 |
| src/bin/psql/describe.c | 16 | 1 |
| src/include/catalog/pg_publication.h | 3 | 0 |
| src/test/regress/expected/publication.out | 57 | 46 |
| src/test/regress/sql/publication.sql | 3 | 0 |
From e9775f0ca7f3195a2aed3a4a19ed202b67c21dd8 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Fri, 29 Nov 2019 17:40:11 +0900
Subject: [PATCH v7 2/4] Add publish_using_root_schema parameter for
publications
It dictates whether to publish (leaf) partition changes using
the the schema of root parent table.
---
doc/src/sgml/ref/create_publication.sgml | 15 +++++
src/backend/catalog/pg_publication.c | 1 +
src/backend/commands/publicationcmds.c | 94 ++++++++++++++++-----------
src/bin/pg_dump/pg_dump.c | 22 ++++++-
src/bin/pg_dump/pg_dump.h | 1 +
src/bin/psql/describe.c | 17 ++++-
src/include/catalog/pg_publication.h | 3 +
src/test/regress/expected/publication.out | 103 +++++++++++++++++-------------
src/test/regress/sql/publication.sql | 3 +
9 files changed, 171 insertions(+), 88 deletions(-)
diff --git a/doc/src/sgml/ref/create_publication.sgml b/doc/src/sgml/ref/create_publication.sgml
index 848779a00f..a8cf2c4629 100644
--- a/doc/src/sgml/ref/create_publication.sgml
+++ b/doc/src/sgml/ref/create_publication.sgml
@@ -124,6 +124,21 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>publish_using_root_schema</literal> (<type>boolean</type>)</term>
+ <listitem>
+ <para>
+ This parameter determines whether DML operations on a partitioned
+ table contained in the publication will be published using its own
+ schema rather than of the individual partitions which are actually
+ changed; the latter is the default. Setting it to
+ <literal>true</literal> allows the changes to be replicated into a
+ non-partitioned table or a partitioned table consisting of a
+ a different set of partitions.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 9e14a8216e..5ef77f1014 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -404,6 +404,7 @@ GetPublication(Oid pubid)
pub->pubactions.pubupdate = pubform->pubupdate;
pub->pubactions.pubdelete = pubform->pubdelete;
pub->pubactions.pubtruncate = pubform->pubtruncate;
+ pub->publish_using_root_schema = pubform->pubasroot;
ReleaseSysCache(tup);
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index ee56acf3f3..06e833fe57 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -55,20 +55,23 @@ static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
static void
parse_publication_options(List *options,
bool *publish_given,
- bool *publish_insert,
- bool *publish_update,
- bool *publish_delete,
- bool *publish_truncate)
+ PublicationActions *pubactions,
+ bool *publish_using_root_schema_given,
+ bool *publish_using_root_schema)
{
ListCell *lc;
+ *publish_using_root_schema_given = false;
*publish_given = false;
/* Defaults are true */
- *publish_insert = true;
- *publish_update = true;
- *publish_delete = true;
- *publish_truncate = true;
+ pubactions->pubinsert = true;
+ pubactions->pubupdate = true;
+ pubactions->pubdelete = true;
+ pubactions->pubtruncate = true;
+
+ /* Relation changes published as of itself by default. */
+ *publish_using_root_schema = false;
/* Parse options */
foreach(lc, options)
@@ -90,10 +93,10 @@ parse_publication_options(List *options,
* If publish option was given only the explicitly listed actions
* should be published.
*/
- *publish_insert = false;
- *publish_update = false;
- *publish_delete = false;
- *publish_truncate = false;
+ pubactions->pubinsert = false;
+ pubactions->pubupdate = false;
+ pubactions->pubdelete = false;
+ pubactions->pubtruncate = false;
*publish_given = true;
publish = defGetString(defel);
@@ -109,19 +112,28 @@ parse_publication_options(List *options,
char *publish_opt = (char *) lfirst(lc);
if (strcmp(publish_opt, "insert") == 0)
- *publish_insert = true;
+ pubactions->pubinsert = true;
else if (strcmp(publish_opt, "update") == 0)
- *publish_update = true;
+ pubactions->pubupdate = true;
else if (strcmp(publish_opt, "delete") == 0)
- *publish_delete = true;
+ pubactions->pubdelete = true;
else if (strcmp(publish_opt, "truncate") == 0)
- *publish_truncate = true;
+ pubactions->pubtruncate = true;
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unrecognized \"publish\" value: \"%s\"", publish_opt)));
}
}
+ else if (strcmp(defel->defname, "publish_using_root_schema") == 0)
+ {
+ if (*publish_using_root_schema_given)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options")));
+ *publish_using_root_schema_given = true;
+ *publish_using_root_schema = defGetBoolean(defel);
+ }
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -142,10 +154,9 @@ CreatePublication(CreatePublicationStmt *stmt)
Datum values[Natts_pg_publication];
HeapTuple tup;
bool publish_given;
- bool publish_insert;
- bool publish_update;
- bool publish_delete;
- bool publish_truncate;
+ PublicationActions pubactions;
+ bool publish_using_root_schema_given;
+ bool publish_using_root_schema;
AclResult aclresult;
/* must have CREATE privilege on database */
@@ -182,9 +193,9 @@ CreatePublication(CreatePublicationStmt *stmt)
values[Anum_pg_publication_pubowner - 1] = ObjectIdGetDatum(GetUserId());
parse_publication_options(stmt->options,
- &publish_given, &publish_insert,
- &publish_update, &publish_delete,
- &publish_truncate);
+ &publish_given, &pubactions,
+ &publish_using_root_schema_given,
+ &publish_using_root_schema);
puboid = GetNewOidWithIndex(rel, PublicationObjectIndexId,
Anum_pg_publication_oid);
@@ -192,13 +203,15 @@ CreatePublication(CreatePublicationStmt *stmt)
values[Anum_pg_publication_puballtables - 1] =
BoolGetDatum(stmt->for_all_tables);
values[Anum_pg_publication_pubinsert - 1] =
- BoolGetDatum(publish_insert);
+ BoolGetDatum(pubactions.pubinsert);
values[Anum_pg_publication_pubupdate - 1] =
- BoolGetDatum(publish_update);
+ BoolGetDatum(pubactions.pubupdate);
values[Anum_pg_publication_pubdelete - 1] =
- BoolGetDatum(publish_delete);
+ BoolGetDatum(pubactions.pubdelete);
values[Anum_pg_publication_pubtruncate - 1] =
- BoolGetDatum(publish_truncate);
+ BoolGetDatum(pubactions.pubtruncate);
+ values[Anum_pg_publication_pubasroot - 1] =
+ BoolGetDatum(publish_using_root_schema);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -250,17 +263,16 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
bool replaces[Natts_pg_publication];
Datum values[Natts_pg_publication];
bool publish_given;
- bool publish_insert;
- bool publish_update;
- bool publish_delete;
- bool publish_truncate;
+ PublicationActions pubactions;
+ bool publish_using_root_schema_given;
+ bool publish_using_root_schema;
ObjectAddress obj;
Form_pg_publication pubform;
parse_publication_options(stmt->options,
- &publish_given, &publish_insert,
- &publish_update, &publish_delete,
- &publish_truncate);
+ &publish_given, &pubactions,
+ &publish_using_root_schema_given,
+ &publish_using_root_schema);
/* Everything ok, form a new tuple. */
memset(values, 0, sizeof(values));
@@ -269,19 +281,25 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
if (publish_given)
{
- values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(publish_insert);
+ values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(pubactions.pubinsert);
replaces[Anum_pg_publication_pubinsert - 1] = true;
- values[Anum_pg_publication_pubupdate - 1] = BoolGetDatum(publish_update);
+ values[Anum_pg_publication_pubupdate - 1] = BoolGetDatum(pubactions.pubupdate);
replaces[Anum_pg_publication_pubupdate - 1] = true;
- values[Anum_pg_publication_pubdelete - 1] = BoolGetDatum(publish_delete);
+ values[Anum_pg_publication_pubdelete - 1] = BoolGetDatum(pubactions.pubdelete);
replaces[Anum_pg_publication_pubdelete - 1] = true;
- values[Anum_pg_publication_pubtruncate - 1] = BoolGetDatum(publish_truncate);
+ values[Anum_pg_publication_pubtruncate - 1] = BoolGetDatum(pubactions.pubtruncate);
replaces[Anum_pg_publication_pubtruncate - 1] = true;
}
+ if (publish_using_root_schema_given)
+ {
+ values[Anum_pg_publication_pubasroot - 1] = BoolGetDatum(publish_using_root_schema);
+ replaces[Anum_pg_publication_pubasroot - 1] = true;
+ }
+
tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
replaces);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index b5e91771e4..cfe89d4e09 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3780,6 +3780,7 @@ getPublications(Archive *fout)
int i_pubupdate;
int i_pubdelete;
int i_pubtruncate;
+ int i_pubasroot;
int i,
ntups;
@@ -3791,11 +3792,18 @@ getPublications(Archive *fout)
resetPQExpBuffer(query);
/* Get the publications. */
- if (fout->remoteVersion >= 110000)
+ if (fout->remoteVersion >= 130000)
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.pubname, "
+ "(%s p.pubowner) AS rolname, "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubasroot "
+ "FROM pg_publication p",
+ username_subquery);
+ else if (fout->remoteVersion >= 110000)
appendPQExpBuffer(query,
"SELECT p.tableoid, p.oid, p.pubname, "
"(%s p.pubowner) AS rolname, "
- "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as pubasroot "
"FROM pg_publication p",
username_subquery);
else
@@ -3819,6 +3827,7 @@ getPublications(Archive *fout)
i_pubupdate = PQfnumber(res, "pubupdate");
i_pubdelete = PQfnumber(res, "pubdelete");
i_pubtruncate = PQfnumber(res, "pubtruncate");
+ i_pubasroot = PQfnumber(res, "pubasroot");
pubinfo = pg_malloc(ntups * sizeof(PublicationInfo));
@@ -3841,6 +3850,8 @@ getPublications(Archive *fout)
(strcmp(PQgetvalue(res, i, i_pubdelete), "t") == 0);
pubinfo[i].pubtruncate =
(strcmp(PQgetvalue(res, i, i_pubtruncate), "t") == 0);
+ pubinfo[i].pubasroot =
+ (strcmp(PQgetvalue(res, i, i_pubasroot), "t") == 0);
if (strlen(pubinfo[i].rolname) == 0)
pg_log_warning("owner of publication \"%s\" appears to be invalid",
@@ -3917,7 +3928,12 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
first = false;
}
- appendPQExpBufferStr(query, "');\n");
+ appendPQExpBufferStr(query, "'");
+
+ if (pubinfo->pubasroot)
+ appendPQExpBufferStr(query, ", publish_using_root_schema = true");
+
+ appendPQExpBufferStr(query, ");\n");
ArchiveEntry(fout, pubinfo->dobj.catId, pubinfo->dobj.dumpId,
ARCHIVE_OPTS(.tag = pubinfo->dobj.name,
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 7b2c1524a5..99b0c1611d 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -600,6 +600,7 @@ typedef struct _PublicationInfo
bool pubupdate;
bool pubdelete;
bool pubtruncate;
+ bool pubasroot;
} PublicationInfo;
/*
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index b3b9313b36..ce1321e17f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5706,7 +5706,7 @@ listPublications(const char *pattern)
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
- static const bool translate_columns[] = {false, false, false, false, false, false, false};
+ static const bool translate_columns[] = {false, false, false, false, false, false, false, false};
if (pset.sversion < 100000)
{
@@ -5737,6 +5737,10 @@ listPublications(const char *pattern)
appendPQExpBuffer(&buf,
",\n pubtruncate AS \"%s\"",
gettext_noop("Truncates"));
+ if (pset.sversion >= 130000)
+ appendPQExpBuffer(&buf,
+ ",\n pubasroot AS \"%s\"",
+ gettext_noop("Publishes Using Root Schema"));
appendPQExpBufferStr(&buf,
"\nFROM pg_catalog.pg_publication\n");
@@ -5778,6 +5782,7 @@ describePublications(const char *pattern)
int i;
PGresult *res;
bool has_pubtruncate;
+ bool has_pubasroot;
if (pset.sversion < 100000)
{
@@ -5790,6 +5795,7 @@ describePublications(const char *pattern)
}
has_pubtruncate = (pset.sversion >= 110000);
+ has_pubasroot = (pset.sversion >= 130000);
initPQExpBuffer(&buf);
@@ -5800,6 +5806,9 @@ describePublications(const char *pattern)
if (has_pubtruncate)
appendPQExpBufferStr(&buf,
", pubtruncate");
+ if (has_pubasroot)
+ appendPQExpBufferStr(&buf,
+ ", pubasroot");
appendPQExpBufferStr(&buf,
"\nFROM pg_catalog.pg_publication\n");
@@ -5849,6 +5858,8 @@ describePublications(const char *pattern)
if (has_pubtruncate)
ncols++;
+ if (has_pubasroot)
+ ncols++;
initPQExpBuffer(&title);
printfPQExpBuffer(&title, _("Publication %s"), pubname);
@@ -5861,6 +5872,8 @@ describePublications(const char *pattern)
printTableAddHeader(&cont, gettext_noop("Deletes"), true, align);
if (has_pubtruncate)
printTableAddHeader(&cont, gettext_noop("Truncates"), true, align);
+ if (has_pubasroot)
+ printTableAddHeader(&cont, gettext_noop("Publishes Using Root Schema"), true, align);
printTableAddCell(&cont, PQgetvalue(res, i, 2), false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false);
@@ -5869,6 +5882,8 @@ describePublications(const char *pattern)
printTableAddCell(&cont, PQgetvalue(res, i, 6), false, false);
if (has_pubtruncate)
printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
+ if (has_pubasroot)
+ printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
if (!puballtables)
{
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 5ee7091472..61d338b110 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -52,6 +52,8 @@ CATALOG(pg_publication,6104,PublicationRelationId)
/* true if truncates are published */
bool pubtruncate;
+ /* true if partition changes are published using root schema */
+ bool pubasroot;
} FormData_pg_publication;
/* ----------------
@@ -74,6 +76,7 @@ typedef struct Publication
Oid oid;
char *name;
bool alltables;
+ bool publish_using_root_schema;
PublicationActions pubactions;
} Publication;
diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out
index e3fabe70f9..da22ca3c6a 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -25,21 +25,23 @@ CREATE PUBLICATION testpub_xxx WITH (foo);
ERROR: unrecognized publication parameter: "foo"
CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
ERROR: unrecognized "publish" value: "cluster"
+CREATE PUBLICATION testpub_xxx WITH (publish_using_root_schema = 'true', publish_using_root_schema = '0');
+ERROR: conflicting or redundant options
\dRp
- List of publications
- Name | Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------+--------------------------+------------+---------+---------+---------+-----------
- testpib_ins_trunct | regress_publication_user | f | t | f | f | f
- testpub_default | regress_publication_user | f | f | t | f | f
+ List of publications
+ Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ testpib_ins_trunct | regress_publication_user | f | t | f | f | f | f
+ testpub_default | regress_publication_user | f | f | t | f | f | f
(2 rows)
ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
\dRp
- List of publications
- Name | Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------+--------------------------+------------+---------+---------+---------+-----------
- testpib_ins_trunct | regress_publication_user | f | t | f | f | f
- testpub_default | regress_publication_user | f | t | t | t | f
+ List of publications
+ Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ testpib_ins_trunct | regress_publication_user | f | t | f | f | f | f
+ testpub_default | regress_publication_user | f | t | t | t | f | f
(2 rows)
--- adding tables
@@ -83,10 +85,10 @@ Publications:
"testpub_foralltables"
\dRp+ testpub_foralltables
- Publication testpub_foralltables
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | t | t | t | f | f
+ Publication testpub_foralltables
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | t | t | t | f | f | f
(1 row)
DROP TABLE testpub_tbl2;
@@ -98,19 +100,19 @@ CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3;
CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
RESET client_min_messages;
\dRp+ testpub3
- Publication testpub3
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | t
+ Publication testpub3
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | t | f
Tables:
"public.testpub_tbl3"
"public.testpub_tbl3a"
\dRp+ testpub4
- Publication testpub4
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | t
+ Publication testpub4
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | t | f
Tables:
"public.testpub_tbl3"
@@ -124,10 +126,19 @@ RESET client_min_messages;
CREATE TABLE testpub_parted1 PARTITION OF testpub_parted FOR VALUES IN (1);
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
\dRp+ testpub_forparted
- Publication testpub_forparted
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | t
+ Publication testpub_forparted
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | t | f
+Tables:
+ "public.testpub_parted"
+
+ALTER PUBLICATION testpub_forparted SET (publish_using_root_schema = true);
+\dRp+ testpub_forparted
+ Publication testpub_forparted
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | t | t
Tables:
"public.testpub_parted"
@@ -146,10 +157,10 @@ ERROR: relation "testpub_tbl1" is already member of publication "testpub_fortbl
CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1;
ERROR: publication "testpub_fortbl" already exists
\dRp+ testpub_fortbl
- Publication testpub_fortbl
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | t
+ Publication testpub_fortbl
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | t | f
Tables:
"pub_test.testpub_nopk"
"public.testpub_tbl1"
@@ -187,10 +198,10 @@ Publications:
"testpub_fortbl"
\dRp+ testpub_default
- Publication testpub_default
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | f
+ Publication testpub_default
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | f | f
Tables:
"pub_test.testpub_nopk"
"public.testpub_tbl1"
@@ -234,10 +245,10 @@ DROP TABLE testpub_parted;
DROP VIEW testpub_view;
DROP TABLE testpub_tbl1;
\dRp+ testpub_default
- Publication testpub_default
- Owner | All tables | Inserts | Updates | Deletes | Truncates
---------------------------+------------+---------+---------+---------+-----------
- regress_publication_user | f | t | t | t | f
+ Publication testpub_default
+ Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ regress_publication_user | f | t | t | t | f | f
(1 row)
-- fail - must be owner of publication
@@ -247,20 +258,20 @@ ERROR: must be owner of publication testpub_default
RESET ROLE;
ALTER PUBLICATION testpub_default RENAME TO testpub_foo;
\dRp testpub_foo
- List of publications
- Name | Owner | All tables | Inserts | Updates | Deletes | Truncates
--------------+--------------------------+------------+---------+---------+---------+-----------
- testpub_foo | regress_publication_user | f | t | t | t | f
+ List of publications
+ Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+-------------+--------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ testpub_foo | regress_publication_user | f | t | t | t | f | f
(1 row)
-- rename back to keep the rest simple
ALTER PUBLICATION testpub_foo RENAME TO testpub_default;
ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2;
\dRp testpub_default
- List of publications
- Name | Owner | All tables | Inserts | Updates | Deletes | Truncates
------------------+---------------------------+------------+---------+---------+---------+-----------
- testpub_default | regress_publication_user2 | f | t | t | t | f
+ List of publications
+ Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Publishes Using Root Schema
+-----------------+---------------------------+------------+---------+---------+---------+-----------+-----------------------------
+ testpub_default | regress_publication_user2 | f | t | t | t | f | f
(1 row)
DROP PUBLICATION testpub_default;
diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql
index b79a3f8f8f..7ddca1b974 100644
--- a/src/test/regress/sql/publication.sql
+++ b/src/test/regress/sql/publication.sql
@@ -23,6 +23,7 @@ ALTER PUBLICATION testpub_default SET (publish = update);
-- error cases
CREATE PUBLICATION testpub_xxx WITH (foo);
CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
+CREATE PUBLICATION testpub_xxx WITH (publish_using_root_schema = 'true', publish_using_root_schema = '0');
\dRp
@@ -77,6 +78,8 @@ RESET client_min_messages;
CREATE TABLE testpub_parted1 PARTITION OF testpub_parted FOR VALUES IN (1);
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
\dRp+ testpub_forparted
+ALTER PUBLICATION testpub_forparted SET (publish_using_root_schema = true);
+\dRp+ testpub_forparted
DROP PUBLICATION testpub_forparted;
-- fail - view
--
2.16.5