0004-DDL-replication-for-index-DDL-commands-2023_04_07-2.patch
application/octet-stream
Filename: 0004-DDL-replication-for-index-DDL-commands-2023_04_07-2.patch
Type: application/octet-stream
Part: 4
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 0004
Subject: DDL replication for index DDL commands
| File | + | − |
|---|---|---|
| src/backend/catalog/pg_publication.c | 1 | 0 |
| src/backend/commands/publicationcmds.c | 24 | 5 |
| src/backend/replication/logical/ddltrigger.c | 12 | 1 |
| src/backend/replication/logical/logical.c | 16 | 16 |
| src/backend/replication/pgoutput/pgoutput.c | 77 | 2 |
| src/backend/utils/cache/relcache.c | 1 | 0 |
| src/bin/pg_dump/pg_dump.c | 30 | 6 |
| src/bin/pg_dump/pg_dump.h | 1 | 0 |
| src/bin/psql/describe.c | 16 | 5 |
| src/include/catalog/pg_publication.h | 4 | 0 |
| src/include/replication/ddlmessage.h | 2 | 1 |
| src/test/regress/expected/psql.out | 3 | 3 |
| src/test/regress/expected/publication.out | 210 | 210 |
From 20c75ed6a92ad7aceb7012ac94aeb0662d1a624b Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 6 Apr 2023 20:12:20 +0800
Subject: [PATCH 4/6] DDL replication for index DDL commands
---
src/backend/catalog/pg_publication.c | 1 +
src/backend/commands/publicationcmds.c | 29 +-
src/backend/replication/logical/ddltrigger.c | 13 +-
src/backend/replication/logical/logical.c | 32 +-
src/backend/replication/pgoutput/pgoutput.c | 79 +++-
src/backend/utils/cache/relcache.c | 1 +
src/bin/pg_dump/pg_dump.c | 36 +-
src/bin/pg_dump/pg_dump.h | 1 +
src/bin/psql/describe.c | 21 +-
src/include/catalog/pg_publication.h | 4 +
src/include/replication/ddlmessage.h | 3 +-
src/test/regress/expected/psql.out | 6 +-
src/test/regress/expected/publication.out | 420 +++++++++----------
13 files changed, 397 insertions(+), 249 deletions(-)
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index d209602e28..1a3105e025 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -1029,6 +1029,7 @@ GetPublication(Oid pubid)
pub->pubactions.pubdelete = pubform->pubdelete;
pub->pubactions.pubtruncate = pubform->pubtruncate;
pub->pubactions.pubddl_table = pubform->pubddl_table;
+ pub->pubactions.pubddl_index = pubform->pubddl_index;
pub->pubviaroot = pubform->pubviaroot;
ReleaseSysCache(tup);
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 64423ff35f..e3aad1c883 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -103,6 +103,7 @@ parse_publication_options(ParseState *pstate,
pubactions->pubdelete = true;
pubactions->pubtruncate = true;
pubactions->pubddl_table = false;
+ pubactions->pubddl_index = false;
*publish_via_partition_root = false;
/* Parse options */
@@ -178,6 +179,7 @@ parse_publication_options(ParseState *pstate,
* should be published.
*/
pubactions->pubddl_table = false;
+ pubactions->pubddl_index = false;
*ddl_type_given = true;
ddl_level = defGetString(defel);
@@ -194,6 +196,8 @@ parse_publication_options(ParseState *pstate,
if (strcmp(publish_opt, "table") == 0)
pubactions->pubddl_table = true;
+ else if (strcmp(publish_opt, "index") == 0)
+ pubactions->pubddl_index = true;
else
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
@@ -856,6 +860,15 @@ CreateDDLReplicaEventTriggers(PublicationActions pubactions, Oid puboid)
end_commands = lappend_int(end_commands, CMDTAG_DROP_TABLE);
}
+ if (pubactions.pubddl_index)
+ {
+ start_commands = lappend_int(start_commands, CMDTAG_DROP_INDEX);
+
+ end_commands = lappend_int(end_commands, CMDTAG_CREATE_INDEX);
+ end_commands = lappend_int(end_commands, CMDTAG_ALTER_INDEX);
+ end_commands = lappend_int(end_commands, CMDTAG_DROP_INDEX);
+ }
+
/* Create the ddl_command_end event trigger */
if (end_commands != NIL)
CreateDDLReplicaEventTrigger(PUB_TRIG_EVENT1, end_commands, puboid);
@@ -992,6 +1005,8 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
BoolGetDatum(pubactions.pubtruncate);
values[Anum_pg_publication_pubddl_table - 1] =
BoolGetDatum(pubactions.pubddl_table);
+ values[Anum_pg_publication_pubddl_index - 1] =
+ BoolGetDatum(pubactions.pubddl_index);
values[Anum_pg_publication_pubviaroot - 1] =
BoolGetDatum(publish_via_partition_root);
@@ -1029,7 +1044,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
{
List *rels;
- if (pubactions.pubddl_table)
+ if (pubactions.pubddl_table || pubactions.pubddl_index)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add table to publication \"%s\" if DDL replication is enabled",
@@ -1188,7 +1203,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
}
}
- if (ddl_type_given && pubactions.pubddl_table)
+ if (ddl_type_given && (pubactions.pubddl_table || pubactions.pubddl_index))
{
if (root_relids == NIL)
root_relids = GetPublicationRelations(pubform->oid,
@@ -1223,7 +1238,8 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
if (ddl_type_given)
{
/* Recreate the event triggers if the ddl option is changed. */
- if (pubform->pubddl_table != pubactions.pubddl_table)
+ if (pubform->pubddl_table != pubactions.pubddl_table ||
+ pubform->pubddl_index != pubactions.pubddl_index)
{
DropDDLReplicaEventTriggers(pubform->oid);
CreateDDLReplicaEventTriggers(pubactions, pubform->oid);
@@ -1231,6 +1247,9 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
values[Anum_pg_publication_pubddl_table - 1] = BoolGetDatum(pubactions.pubddl_table);
replaces[Anum_pg_publication_pubddl_table - 1] = true;
+
+ values[Anum_pg_publication_pubddl_index - 1] = BoolGetDatum(pubactions.pubddl_index);
+ replaces[Anum_pg_publication_pubddl_index - 1] = true;
}
if (publish_via_partition_root_given)
@@ -1338,7 +1357,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
if (stmt->action == AP_AddObjects)
{
- if (pubform->pubddl_table)
+ if (pubform->pubddl_table || pubform->pubddl_index)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add table to publication \"%s\" if DDL replication is enabled",
@@ -1362,7 +1381,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
List *delrels = NIL;
ListCell *oldlc;
- if (pubform->pubddl_table)
+ if (pubform->pubddl_table || pubform->pubddl_index)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add table to publication \"%s\" if DDL replication is enabled",
diff --git a/src/backend/replication/logical/ddltrigger.c b/src/backend/replication/logical/ddltrigger.c
index 1282340c2b..fb35cc2c7f 100644
--- a/src/backend/replication/logical/ddltrigger.c
+++ b/src/backend/replication/logical/ddltrigger.c
@@ -81,8 +81,17 @@ publication_deparse_ddl_command_start(PG_FUNCTION_ARGS)
* new table.
*/
if (relpersist == RELPERSISTENCE_PERMANENT)
- LogLogicalDDLMessage("deparse", address.objectId, DCT_TableDropStart,
+ {
+ DeparsedCommandType cmdtype;
+
+ if (stmt->removeType == OBJECT_TABLE)
+ cmdtype = DCT_TableDropStart;
+ else
+ cmdtype = DCT_ObjectDropStart;
+
+ LogLogicalDDLMessage("deparse", address.objectId, cmdtype,
command, strlen(command) + 1);
+ }
if (relation)
table_close(relation, NoLock);
@@ -225,6 +234,8 @@ publication_deparse_ddl_command_end(PG_FUNCTION_ARGS)
if (strcmp(obj->objecttype, "table") == 0)
cmdtype = DCT_TableDropEnd;
+ else if (strcmp(obj->objecttype, "index") == 0)
+ cmdtype = DCT_ObjectDropEnd;
else
continue;
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index f56a716567..533e27fb07 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -75,9 +75,9 @@ static void message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
XLogRecPtr message_lsn, bool transactional,
const char *prefix, Size message_size, const char *message);
static void ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
- XLogRecPtr message_lsn, const char *prefix,
- Oid relid, DeparsedCommandType cmdtype,
- Size message_size, const char *message);
+ XLogRecPtr message_lsn, const char *prefix,
+ Oid relid, DeparsedCommandType cmdtype,
+ Size message_size, const char *message);
/* streaming callbacks */
static void stream_start_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
@@ -96,10 +96,10 @@ static void stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *tx
XLogRecPtr message_lsn, bool transactional,
const char *prefix, Size message_size, const char *message);
static void stream_ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
- XLogRecPtr message_lsn,
- const char *prefix,
- Oid relid, DeparsedCommandType cmdtype,
- Size message_size, const char *message);
+ XLogRecPtr message_lsn,
+ const char *prefix,
+ Oid relid, DeparsedCommandType cmdtype,
+ Size message_size, const char *message);
static void stream_truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
int nrelations, Relation relations[], ReorderBufferChange *change);
@@ -1248,10 +1248,10 @@ message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
static void
ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
- XLogRecPtr message_lsn,
- const char *prefix, Oid relid, DeparsedCommandType cmdtype,
- Size message_size,
- const char *message)
+ XLogRecPtr message_lsn,
+ const char *prefix, Oid relid, DeparsedCommandType cmdtype,
+ Size message_size,
+ const char *message)
{
LogicalDecodingContext *ctx = cache->private_data;
LogicalErrorCallbackState state;
@@ -1278,7 +1278,7 @@ ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
/* do the actual work: call callback */
ctx->callbacks.ddl_cb(ctx, txn, message_lsn, prefix, relid, cmdtype,
- message_size, message);
+ message_size, message);
/* Pop the error context stack */
error_context_stack = errcallback.previous;
@@ -1601,10 +1601,10 @@ stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
static void
stream_ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
- XLogRecPtr message_lsn,
- const char *prefix, Oid relid, DeparsedCommandType cmdtype,
- Size message_size,
- const char *message)
+ XLogRecPtr message_lsn,
+ const char *prefix, Oid relid, DeparsedCommandType cmdtype,
+ Size message_size,
+ const char *message)
{
LogicalDecodingContext *ctx = cache->private_data;
LogicalErrorCallbackState state;
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 7ea9ff51ec..9a54cbd152 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -219,10 +219,20 @@ typedef struct PGOutputTxnData
/* Map used to remember which relation schemas we sent. */
static HTAB *RelationSyncCache = NULL;
+/* Struct to cache the published DDL. */
+typedef struct DDLSyncCache
+{
+ bool valid;
+ bool pubindex;
+} DDLSyncCache;
+
+static DDLSyncCache *ddlcache = NULL;
+
static void init_rel_sync_cache(MemoryContext cachectx);
static void cleanup_rel_sync_cache(TransactionId xid, bool is_commit);
static RelationSyncEntry *get_rel_sync_entry(PGOutputData *data,
Relation relation);
+static void build_ddl_sync_cache(PGOutputData *data);
static void rel_sync_cache_relation_cb(Datum arg, Oid relid);
static void rel_sync_cache_publication_cb(Datum arg, int cacheid,
uint32 hashvalue);
@@ -1760,6 +1770,27 @@ is_object_published(LogicalDecodingContext *ctx, Oid objid)
relentry->publish_as_relid != objid)
return false;
+ break;
+ case RELKIND_INDEX:
+ build_ddl_sync_cache(data);
+
+ if (!ddlcache->pubindex)
+ return false;
+
+ /* Get the table OID that the index is for. */
+ relation = RelationIdGetRelation(objid);
+ objid = relation->rd_index->indrelid;
+ RelationClose(relation);
+
+ /* Filter the index DDLs if the index's table was not published. */
+ relation = RelationIdGetRelation(objid);
+ relentry = get_rel_sync_entry(data, relation);
+ RelationClose(relation);
+
+ if (!relentry->pubactions.pubddl_table ||
+ relentry->publish_as_relid != objid)
+ return false;
+
break;
default:
/* unsupported objects */
@@ -1785,12 +1816,14 @@ pgoutput_ddl(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
* we cannot get the required information from the catalog, so we skip the
* check for them.
*/
- if (cmdtype != DCT_TableDropEnd && !is_object_published(ctx, relid))
+ if (cmdtype != DCT_TableDropEnd && cmdtype != DCT_ObjectDropEnd &&
+ !is_object_published(ctx, relid))
return;
switch (cmdtype)
{
case DCT_TableDropStart:
+ case DCT_ObjectDropStart:
{
MemoryContext old;
@@ -1814,6 +1847,7 @@ pgoutput_ddl(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
return;
case DCT_TableDropEnd:
+ case DCT_ObjectDropEnd:
if (!list_member_oid(txndata->deleted_relids, relid))
return;
@@ -1936,6 +1970,9 @@ publication_invalidation_cb(Datum arg, int cacheid, uint32 hashvalue)
* is checked it will be updated with the new publication settings.
*/
rel_sync_cache_publication_cb(arg, cacheid, hashvalue);
+
+ if (ddlcache != NULL)
+ ddlcache->valid = false;
}
/*
@@ -2203,7 +2240,7 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
entry->streamed_txns = NIL;
entry->pubactions.pubinsert = entry->pubactions.pubupdate =
entry->pubactions.pubdelete = entry->pubactions.pubtruncate =
- entry->pubactions.pubddl_table = false;
+ entry->pubactions.pubddl_table = entry->pubactions.pubddl_index = false;
entry->new_slot = NULL;
entry->old_slot = NULL;
memset(entry->exprstate, 0, sizeof(entry->exprstate));
@@ -2250,6 +2287,7 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
entry->pubactions.pubdelete = false;
entry->pubactions.pubtruncate = false;
entry->pubactions.pubddl_table = false;
+ entry->pubactions.pubddl_index = false;
/*
* Tuple slots cleanups. (Will be rebuilt later if needed).
@@ -2364,6 +2402,7 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
entry->pubactions.pubdelete |= pub->pubactions.pubdelete;
entry->pubactions.pubtruncate |= pub->pubactions.pubtruncate;
entry->pubactions.pubddl_table |= pub->pubactions.pubddl_table;
+ entry->pubactions.pubddl_index |= pub->pubactions.pubddl_index;
/*
* We want to publish the changes as the top-most ancestor
@@ -2428,6 +2467,42 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
return entry;
}
+/*
+ * This looks up all publications and build the cache about which DDLs to
+ * publish.
+ */
+static void
+build_ddl_sync_cache(PGOutputData *data)
+{
+ ListCell *lc;
+ MemoryContext oldctx;
+
+ if (ddlcache == NULL)
+ {
+ oldctx = MemoryContextSwitchTo(CacheMemoryContext);
+ ddlcache = (DDLSyncCache *) palloc0(sizeof(DDLSyncCache));
+ MemoryContextSwitchTo(oldctx);
+ }
+
+ if (ddlcache->valid)
+ return;
+
+ ddlcache->pubindex = false;
+
+ reload_publications(data);
+
+ foreach(lc, data->publications)
+ {
+ Publication *pub = lfirst(lc);
+
+ ddlcache->pubindex |= pub->pubactions.pubddl_index;
+ }
+
+ ddlcache->valid = true;
+
+ return;
+}
+
/*
* Cleanup list of streamed transactions and update the schema_sent flag.
*
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 9198da2eb1..12259c9dd8 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -5721,6 +5721,7 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
pubdesc->pubactions.pubdelete |= pubform->pubdelete;
pubdesc->pubactions.pubtruncate |= pubform->pubtruncate;
pubdesc->pubactions.pubddl_table |= pubform->pubddl_table;
+ pubdesc->pubactions.pubddl_index |= pubform->pubddl_index;
/*
* Check if all columns referenced in the filter expression are part
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 3c3a34267f..c34d33b9a1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4066,6 +4066,7 @@ getPublications(Archive *fout, int *numPublications)
int i_pubdelete;
int i_pubtruncate;
int i_pubddl_table;
+ int i_pubddl_index;
int i_pubviaroot;
int i,
ntups;
@@ -4085,25 +4086,25 @@ getPublications(Archive *fout, int *numPublications)
appendPQExpBufferStr(query,
"SELECT p.tableoid, p.oid, p.pubname, "
"p.pubowner, "
- "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubddl_table, p.pubviaroot "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubddl_table, p.pubddl_index, p.pubviaroot "
"FROM pg_publication p");
else if (fout->remoteVersion >= 130000)
appendPQExpBufferStr(query,
"SELECT p.tableoid, p.oid, p.pubname, "
"p.pubowner, "
- "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as p.pubddl_table, p.pubviaroot "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as p.pubddl_table, false as p.pubddl_index, p.pubviaroot "
"FROM pg_publication p");
else if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
"SELECT p.tableoid, p.oid, p.pubname, "
"p.pubowner, "
- "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as p.pubddl_table, false AS pubviaroot "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as p.pubddl_table, false as p.pubddl_index, false AS pubviaroot "
"FROM pg_publication p");
else
appendPQExpBufferStr(query,
"SELECT p.tableoid, p.oid, p.pubname, "
"p.pubowner, "
- "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false as p.pubddl_table, false AS pubviaroot "
+ "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false as p.pubddl_table, false as p.pubddl_index, false AS pubviaroot "
"FROM pg_publication p");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -4120,6 +4121,7 @@ getPublications(Archive *fout, int *numPublications)
i_pubdelete = PQfnumber(res, "pubdelete");
i_pubtruncate = PQfnumber(res, "pubtruncate");
i_pubddl_table = PQfnumber(res, "pubddl_table");
+ i_pubddl_index = PQfnumber(res, "pubddl_index");
i_pubviaroot = PQfnumber(res, "pubviaroot");
pubinfo = pg_malloc(ntups * sizeof(PublicationInfo));
@@ -4145,6 +4147,8 @@ getPublications(Archive *fout, int *numPublications)
(strcmp(PQgetvalue(res, i, i_pubtruncate), "t") == 0);
pubinfo[i].pubddl_table =
(strcmp(PQgetvalue(res, i, i_pubddl_table), "t") == 0);
+ pubinfo[i].pubddl_index =
+ (strcmp(PQgetvalue(res, i, i_pubddl_index), "t") == 0);
pubinfo[i].pubviaroot =
(strcmp(PQgetvalue(res, i, i_pubviaroot), "t") == 0);
@@ -4226,8 +4230,28 @@ dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
appendPQExpBufferStr(query, "'");
- if (pubinfo->pubddl_table)
- appendPQExpBufferStr(query, ", ddl = 'table'");
+ if (pubinfo->pubddl_table || pubinfo->pubddl_index)
+ {
+ first = true;
+ appendPQExpBufferStr(query, ", ddl = '");
+
+ if (pubinfo->pubddl_table)
+ {
+ appendPQExpBufferStr(query, "table");
+ first = false;
+ }
+
+ if (pubinfo->pubddl_index)
+ {
+ if (!first)
+ appendPQExpBufferStr(query, ", ");
+
+ appendPQExpBufferStr(query, "index");
+ first = false;
+ }
+
+ appendPQExpBufferStr(query, "'");
+ }
if (pubinfo->pubviaroot)
appendPQExpBufferStr(query, ", publish_via_partition_root = true");
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index bd5f8fb669..9ae6a38e00 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -621,6 +621,7 @@ typedef struct _PublicationInfo
bool pubdelete;
bool pubtruncate;
bool pubddl_table;
+ bool pubddl_index;
bool pubviaroot;
} PublicationInfo;
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e977e6f464..7068dc0388 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -6183,7 +6183,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, false, false, false};
+ static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false};
if (pset.sversion < 100000)
{
@@ -6205,9 +6205,13 @@ listPublications(const char *pattern)
gettext_noop("Owner"),
gettext_noop("All tables"));
if (pset.sversion >= 160000)
+ {
appendPQExpBuffer(&buf,
- ",\n pubddl_table AS \"%s\"",
- gettext_noop("Table DDLs"));
+ ",\n pubddl_table AS \"%s\",\n"
+ " pubddl_index AS \"%s\"\n",
+ gettext_noop("Table DDLs"),
+ gettext_noop("Index DDLs"));
+ }
appendPQExpBuffer(&buf,
",\n pubinsert AS \"%s\",\n"
" pubupdate AS \"%s\",\n"
@@ -6339,7 +6343,8 @@ describePublications(const char *pattern)
" puballtables");
if (has_pubddl)
appendPQExpBufferStr(&buf,
- ", pubddl_table");
+ ", pubddl_table, pubddl_index");
+
appendPQExpBufferStr(&buf,
", pubinsert, pubupdate, pubdelete");
if (has_pubtruncate)
@@ -6400,7 +6405,7 @@ describePublications(const char *pattern)
if (has_pubviaroot)
ncols++;
if (has_pubddl)
- ncols++;
+ ncols += 2;
initPQExpBuffer(&title);
printfPQExpBuffer(&title, _("Publication %s"), pubname);
@@ -6409,7 +6414,10 @@ describePublications(const char *pattern)
printTableAddHeader(&cont, gettext_noop("Owner"), true, align);
printTableAddHeader(&cont, gettext_noop("All tables"), true, align);
if (has_pubddl)
+ {
printTableAddHeader(&cont, gettext_noop("Table DDLs"), true, align);
+ printTableAddHeader(&cont, gettext_noop("Index DDLs"), true, align);
+ }
printTableAddHeader(&cont, gettext_noop("Inserts"), true, align);
printTableAddHeader(&cont, gettext_noop("Updates"), true, align);
printTableAddHeader(&cont, gettext_noop("Deletes"), true, align);
@@ -6428,7 +6436,10 @@ describePublications(const char *pattern)
if (has_pubviaroot)
printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
if (has_pubddl)
+ {
printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
+ printTableAddCell(&cont, PQgetvalue(res, i, 10), false, false);
+ }
if (!puballtables)
{
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 74b28d7350..467731c61a 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -66,6 +66,9 @@ CATALOG(pg_publication,6104,PublicationRelationId)
/* true if table ddls are published */
bool pubddl_table;
+
+ /* true if index ddls are published */
+ bool pubddl_index;
} FormData_pg_publication;
/* ----------------
@@ -85,6 +88,7 @@ typedef struct PublicationActions
bool pubdelete;
bool pubtruncate;
bool pubddl_table;
+ bool pubddl_index;
} PublicationActions;
typedef struct PublicationDesc
diff --git a/src/include/replication/ddlmessage.h b/src/include/replication/ddlmessage.h
index 77df6ea11a..1a4aca8dd5 100644
--- a/src/include/replication/ddlmessage.h
+++ b/src/include/replication/ddlmessage.h
@@ -26,7 +26,8 @@ typedef enum DeparsedCommandType
DCT_TableDropEnd,
DCT_TableAlter,
DCT_ObjectCreate,
- DCT_ObjectDrop
+ DCT_ObjectDropStart,
+ DCT_ObjectDropEnd
} DeparsedCommandType;
/*
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 1c6f33095c..3e6d2791c8 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -6223,9 +6223,9 @@ List of schemas
(0 rows)
\dRp "no.such.publication"
- List of publications
- Name | Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
-------+-------+------------+------------+---------+---------+---------+-----------+----------
+ List of publications
+ Name | Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+------+-------+------------+------------+------------+---------+---------+---------+-----------+----------
(0 rows)
\dRs "no.such.subscription"
diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out
index 7d86977b29..ebcff41c0c 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -30,20 +30,20 @@ ERROR: conflicting or redundant options
LINE 1: ...ub_xxx WITH (publish_via_partition_root = 'true', publish_vi...
^
\dRp
- List of publications
- Name | Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------+--------------------------+------------+------------+---------+---------+---------+-----------+----------
- testpib_ins_trunct | regress_publication_user | f | f | t | f | f | f | f
- testpub_default | regress_publication_user | f | f | f | t | f | f | f
+ List of publications
+ Name | Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ testpib_ins_trunct | regress_publication_user | f | f | f | t | f | f | f | f
+ testpub_default | regress_publication_user | f | f | 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 | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------+--------------------------+------------+------------+---------+---------+---------+-----------+----------
- testpib_ins_trunct | regress_publication_user | f | f | t | f | f | f | f
- testpub_default | regress_publication_user | f | f | t | t | t | f | f
+ List of publications
+ Name | Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ testpib_ins_trunct | regress_publication_user | f | f | f | t | f | f | f | f
+ testpub_default | regress_publication_user | f | f | f | t | t | t | f | f
(2 rows)
--- adding tables
@@ -87,10 +87,10 @@ RESET client_min_messages;
-- should be able to add schema to 'FOR TABLE' publication
ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test;
\dRp+ testpub_fortable
- Publication testpub_fortable
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortable
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_tbl1"
Tables from schemas:
@@ -99,20 +99,20 @@ Tables from schemas:
-- should be able to drop schema from 'FOR TABLE' publication
ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test;
\dRp+ testpub_fortable
- Publication testpub_fortable
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortable
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_tbl1"
-- should be able to set schema to 'FOR TABLE' publication
ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test;
\dRp+ testpub_fortable
- Publication testpub_fortable
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortable
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test"
@@ -123,10 +123,10 @@ CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test;
CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk;
RESET client_min_messages;
\dRp+ testpub_for_tbl_schema
- Publication testpub_for_tbl_schema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_for_tbl_schema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test.testpub_nopk"
Tables from schemas:
@@ -135,10 +135,10 @@ Tables from schemas:
-- should be able to add a table of the same schema to the schema publication
ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk;
\dRp+ testpub_forschema
- Publication testpub_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test.testpub_nopk"
Tables from schemas:
@@ -147,10 +147,10 @@ Tables from schemas:
-- should be able to drop the table
ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk;
\dRp+ testpub_forschema
- Publication testpub_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test"
@@ -161,10 +161,10 @@ ERROR: relation "testpub_nopk" is not part of the publication
-- should be able to set table to schema publication
ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk;
\dRp+ testpub_forschema
- Publication testpub_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test.testpub_nopk"
@@ -186,10 +186,10 @@ Publications:
"testpub_foralltables"
\dRp+ testpub_foralltables
- Publication testpub_foralltables
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | t | f | t | t | f | f | f
+ Publication testpub_foralltables
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | t | f | f | t | t | f | f | f
(1 row)
DROP TABLE testpub_tbl2;
@@ -201,19 +201,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 | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub3
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_tbl3"
"public.testpub_tbl3a"
\dRp+ testpub4
- Publication testpub4
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub4
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_tbl3"
@@ -234,10 +234,10 @@ UPDATE testpub_parted1 SET a = 1;
-- only parent is listed as being in publication, not the partition
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
\dRp+ testpub_forparted
- Publication testpub_forparted
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_forparted
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_parted"
@@ -252,10 +252,10 @@ ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1;
UPDATE testpub_parted1 SET a = 1;
ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true);
\dRp+ testpub_forparted
- Publication testpub_forparted
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | t
+ Publication testpub_forparted
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | t
Tables:
"public.testpub_parted"
@@ -284,10 +284,10 @@ SET client_min_messages = 'ERROR';
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
RESET client_min_messages;
\dRp+ testpub5
- Publication testpub5
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub5
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl1"
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
@@ -300,10 +300,10 @@ Tables:
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
\dRp+ testpub5
- Publication testpub5
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub5
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl1"
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
@@ -319,10 +319,10 @@ Publications:
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
\dRp+ testpub5
- Publication testpub5
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub5
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl1"
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
@@ -330,10 +330,10 @@ Tables:
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
\dRp+ testpub5
- Publication testpub5
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub5
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
@@ -366,10 +366,10 @@ SET client_min_messages = 'ERROR';
CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert');
RESET client_min_messages;
\dRp+ testpub_syntax1
- Publication testpub_syntax1
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub_syntax1
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl1"
"public.testpub_rf_tbl3" WHERE (e < 999)
@@ -379,10 +379,10 @@ SET client_min_messages = 'ERROR';
CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert');
RESET client_min_messages;
\dRp+ testpub_syntax2
- Publication testpub_syntax2
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | f | f
+ Publication testpub_syntax2
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | f | f
Tables:
"public.testpub_rf_tbl1"
"testpub_rf_schema1.testpub_rf_tbl5" WHERE (h < 999)
@@ -497,10 +497,10 @@ CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2;
ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99);
RESET client_min_messages;
\dRp+ testpub6
- Publication testpub6
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub6
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"testpub_rf_schema2.testpub_rf_tbl6" WHERE (i < 99)
Tables from schemas:
@@ -714,10 +714,10 @@ CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate');
RESET client_min_messages;
ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a); -- ok
\dRp+ testpub_table_ins
- Publication testpub_table_ins
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | f | f | t | f
+ Publication testpub_table_ins
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | f | f | t | f
Tables:
"public.testpub_tbl5" (a)
@@ -891,10 +891,10 @@ CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a,c));
ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey;
ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1);
\dRp+ testpub_both_filters
- Publication testpub_both_filters
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_both_filters
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"public.testpub_tbl_both_filters" (a, c) WHERE (c <> 1)
@@ -1099,10 +1099,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 | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortbl
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test.testpub_nopk"
"public.testpub_tbl1"
@@ -1140,10 +1140,10 @@ Publications:
"testpub_fortbl"
\dRp+ testpub_default
- Publication testpub_default
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | f | f
+ Publication testpub_default
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | f | f
Tables:
"pub_test.testpub_nopk"
"public.testpub_tbl1"
@@ -1221,10 +1221,10 @@ REVOKE CREATE ON DATABASE regression FROM regress_publication_user2;
DROP TABLE testpub_parted;
DROP TABLE testpub_tbl1;
\dRp+ testpub_default
- Publication testpub_default
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | f | f
+ Publication testpub_default
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | f | f
(1 row)
-- fail - must be owner of publication
@@ -1234,20 +1234,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 | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
--------------+--------------------------+------------+------------+---------+---------+---------+-----------+----------
- testpub_foo | regress_publication_user | f | f | t | t | t | f | f
+ List of publications
+ Name | Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+-------------+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ testpub_foo | regress_publication_user | f | f | 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 | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
------------------+---------------------------+------------+------------+---------+---------+---------+-----------+----------
- testpub_default | regress_publication_user2 | f | f | t | t | t | f | f
+ List of publications
+ Name | Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+-----------------+---------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ testpub_default | regress_publication_user2 | f | f | f | t | t | t | f | f
(1 row)
-- adding schemas and tables
@@ -1263,19 +1263,19 @@ CREATE TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"(id int);
SET client_min_messages = 'ERROR';
CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3;
\dRp+ testpub2_forschema
- Publication testpub2_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub2_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1289,44 +1289,44 @@ CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA", CUR
CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA";
RESET client_min_messages;
\dRp+ testpub3_forschema
- Publication testpub3_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub3_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"public"
\dRp+ testpub4_forschema
- Publication testpub4_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub4_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"CURRENT_SCHEMA"
\dRp+ testpub5_forschema
- Publication testpub5_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub5_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"CURRENT_SCHEMA"
"public"
\dRp+ testpub6_forschema
- Publication testpub6_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub6_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"CURRENT_SCHEMA"
"public"
\dRp+ testpub_fortable
- Publication testpub_fortable
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortable
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"CURRENT_SCHEMA.CURRENT_SCHEMA"
@@ -1360,10 +1360,10 @@ ERROR: schema "testpub_view" does not exist
-- dropping the schema should reflect the change in publication
DROP SCHEMA pub_test3;
\dRp+ testpub2_forschema
- Publication testpub2_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub2_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1371,20 +1371,20 @@ Tables from schemas:
-- renaming the schema should reflect the change in publication
ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed;
\dRp+ testpub2_forschema
- Publication testpub2_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub2_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1_renamed"
"pub_test2"
ALTER SCHEMA pub_test1_renamed RENAME to pub_test1;
\dRp+ testpub2_forschema
- Publication testpub2_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub2_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1392,10 +1392,10 @@ Tables from schemas:
-- alter publication add schema
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1404,10 +1404,10 @@ Tables from schemas:
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema;
ERROR: schema "non_existent_schema" does not exist
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1416,10 +1416,10 @@ Tables from schemas:
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1;
ERROR: schema "pub_test1" is already member of publication "testpub1_forschema"
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1427,10 +1427,10 @@ Tables from schemas:
-- alter publication drop schema
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
@@ -1438,10 +1438,10 @@ Tables from schemas:
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
ERROR: tables from schema "pub_test2" are not part of the publication
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
@@ -1449,29 +1449,29 @@ Tables from schemas:
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema;
ERROR: schema "non_existent_schema" does not exist
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
-- drop all schemas
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
(1 row)
-- alter publication set multiple schema
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1480,10 +1480,10 @@ Tables from schemas:
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema;
ERROR: schema "non_existent_schema" does not exist
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
"pub_test2"
@@ -1492,10 +1492,10 @@ Tables from schemas:
-- removing the duplicate schemas
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1;
\dRp+ testpub1_forschema
- Publication testpub1_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub1_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
@@ -1574,18 +1574,18 @@ SET client_min_messages = 'ERROR';
CREATE PUBLICATION testpub3_forschema;
RESET client_min_messages;
\dRp+ testpub3_forschema
- Publication testpub3_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub3_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
(1 row)
ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1;
\dRp+ testpub3_forschema
- Publication testpub3_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub3_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables from schemas:
"pub_test1"
@@ -1595,20 +1595,20 @@ CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TA
CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1;
RESET client_min_messages;
\dRp+ testpub_forschema_fortable
- Publication testpub_forschema_fortable
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_forschema_fortable
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test2.tbl1"
Tables from schemas:
"pub_test1"
\dRp+ testpub_fortable_forschema
- Publication testpub_fortable_forschema
- Owner | All tables | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root
---------------------------+------------+------------+---------+---------+---------+-----------+----------
- regress_publication_user | f | f | t | t | t | t | f
+ Publication testpub_fortable_forschema
+ Owner | All tables | Table DDLs | Index DDLs | Inserts | Updates | Deletes | Truncates | Via root
+--------------------------+------------+------------+------------+---------+---------+---------+-----------+----------
+ regress_publication_user | f | f | f | t | t | t | t | f
Tables:
"pub_test2.tbl1"
Tables from schemas:
--
2.30.0.windows.2