mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Rework the options syntax for logical replication commands
For CREATE/ALTER PUBLICATION/SUBSCRIPTION, use similar option style as other statements that use a WITH clause for options. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
@ -46,6 +46,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/varlena.h"
|
||||
|
||||
/* Same as MAXNUMMESSAGES in sinvaladt.c */
|
||||
#define MAX_RELCACHE_INVAL_MSGS 4096
|
||||
@ -58,18 +59,14 @@ static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
|
||||
|
||||
static void
|
||||
parse_publication_options(List *options,
|
||||
bool *publish_insert_given,
|
||||
bool *publish_given,
|
||||
bool *publish_insert,
|
||||
bool *publish_update_given,
|
||||
bool *publish_update,
|
||||
bool *publish_delete_given,
|
||||
bool *publish_delete)
|
||||
{
|
||||
ListCell *lc;
|
||||
|
||||
*publish_insert_given = false;
|
||||
*publish_update_given = false;
|
||||
*publish_delete_given = false;
|
||||
*publish_given = false;
|
||||
|
||||
/* Defaults are true */
|
||||
*publish_insert = true;
|
||||
@ -81,68 +78,54 @@ parse_publication_options(List *options,
|
||||
{
|
||||
DefElem *defel = (DefElem *) lfirst(lc);
|
||||
|
||||
if (strcmp(defel->defname, "publish insert") == 0)
|
||||
if (strcmp(defel->defname, "publish") == 0)
|
||||
{
|
||||
if (*publish_insert_given)
|
||||
char *publish;
|
||||
List *publish_list;
|
||||
ListCell *lc;
|
||||
|
||||
if (*publish_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
*publish_insert_given = true;
|
||||
*publish_insert = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "nopublish insert") == 0)
|
||||
{
|
||||
if (*publish_insert_given)
|
||||
/*
|
||||
* If publish option was given only the explicitly listed actions
|
||||
* should be published.
|
||||
*/
|
||||
*publish_insert = false;
|
||||
*publish_update = false;
|
||||
*publish_delete = false;
|
||||
|
||||
*publish_given = true;
|
||||
publish = defGetString(defel);
|
||||
|
||||
if (!SplitIdentifierString(publish, ',', &publish_list))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
errmsg("invalid publish list")));
|
||||
|
||||
*publish_insert_given = true;
|
||||
*publish_insert = !defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "publish update") == 0)
|
||||
{
|
||||
if (*publish_update_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
/* Process the option list. */
|
||||
foreach (lc, publish_list)
|
||||
{
|
||||
char *publish_opt = (char *)lfirst(lc);
|
||||
|
||||
*publish_update_given = true;
|
||||
*publish_update = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "nopublish update") == 0)
|
||||
{
|
||||
if (*publish_update_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
*publish_update_given = true;
|
||||
*publish_update = !defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "publish delete") == 0)
|
||||
{
|
||||
if (*publish_delete_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
*publish_delete_given = true;
|
||||
*publish_delete = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "nopublish delete") == 0)
|
||||
{
|
||||
if (*publish_delete_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
*publish_delete_given = true;
|
||||
*publish_delete = !defGetBoolean(defel);
|
||||
if (strcmp(publish_opt, "insert") == 0)
|
||||
*publish_insert = true;
|
||||
else if (strcmp(publish_opt, "update") == 0)
|
||||
*publish_update = true;
|
||||
else if (strcmp(publish_opt, "delete") == 0)
|
||||
*publish_delete = true;
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unrecognized \"publish\" value: \"%s\"", publish_opt)));
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "unrecognized option: %s", defel->defname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unrecognized publication parameter: %s", defel->defname)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,9 +141,7 @@ CreatePublication(CreatePublicationStmt *stmt)
|
||||
bool nulls[Natts_pg_publication];
|
||||
Datum values[Natts_pg_publication];
|
||||
HeapTuple tup;
|
||||
bool publish_insert_given;
|
||||
bool publish_update_given;
|
||||
bool publish_delete_given;
|
||||
bool publish_given;
|
||||
bool publish_insert;
|
||||
bool publish_update;
|
||||
bool publish_delete;
|
||||
@ -199,9 +180,8 @@ CreatePublication(CreatePublicationStmt *stmt)
|
||||
values[Anum_pg_publication_pubowner - 1] = ObjectIdGetDatum(GetUserId());
|
||||
|
||||
parse_publication_options(stmt->options,
|
||||
&publish_insert_given, &publish_insert,
|
||||
&publish_update_given, &publish_update,
|
||||
&publish_delete_given, &publish_delete);
|
||||
&publish_given, &publish_insert,
|
||||
&publish_update, &publish_delete);
|
||||
|
||||
values[Anum_pg_publication_puballtables - 1] =
|
||||
BoolGetDatum(stmt->for_all_tables);
|
||||
@ -253,40 +233,30 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
|
||||
bool nulls[Natts_pg_publication];
|
||||
bool replaces[Natts_pg_publication];
|
||||
Datum values[Natts_pg_publication];
|
||||
bool publish_insert_given;
|
||||
bool publish_update_given;
|
||||
bool publish_delete_given;
|
||||
bool publish_given;
|
||||
bool publish_insert;
|
||||
bool publish_update;
|
||||
bool publish_delete;
|
||||
ObjectAddress obj;
|
||||
|
||||
parse_publication_options(stmt->options,
|
||||
&publish_insert_given, &publish_insert,
|
||||
&publish_update_given, &publish_update,
|
||||
&publish_delete_given, &publish_delete);
|
||||
&publish_given, &publish_insert,
|
||||
&publish_update, &publish_delete);
|
||||
|
||||
/* Everything ok, form a new tuple. */
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(nulls, false, sizeof(nulls));
|
||||
memset(replaces, false, sizeof(replaces));
|
||||
|
||||
if (publish_insert_given)
|
||||
if (publish_given)
|
||||
{
|
||||
values[Anum_pg_publication_pubinsert - 1] =
|
||||
BoolGetDatum(publish_insert);
|
||||
values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(publish_insert);
|
||||
replaces[Anum_pg_publication_pubinsert - 1] = true;
|
||||
}
|
||||
if (publish_update_given)
|
||||
{
|
||||
values[Anum_pg_publication_pubupdate - 1] =
|
||||
BoolGetDatum(publish_update);
|
||||
|
||||
values[Anum_pg_publication_pubupdate - 1] = BoolGetDatum(publish_update);
|
||||
replaces[Anum_pg_publication_pubupdate - 1] = true;
|
||||
}
|
||||
if (publish_delete_given)
|
||||
{
|
||||
values[Anum_pg_publication_pubdelete - 1] =
|
||||
BoolGetDatum(publish_delete);
|
||||
|
||||
values[Anum_pg_publication_pubdelete - 1] = BoolGetDatum(publish_delete);
|
||||
replaces[Anum_pg_publication_pubdelete - 1] = true;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
{
|
||||
DefElem *defel = (DefElem *) lfirst(lc);
|
||||
|
||||
if (strcmp(defel->defname, "noconnect") == 0 && connect)
|
||||
if (strcmp(defel->defname, "connect") == 0 && connect)
|
||||
{
|
||||
if (connect_given)
|
||||
ereport(ERROR,
|
||||
@ -101,7 +101,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
connect_given = true;
|
||||
*connect = !defGetBoolean(defel);
|
||||
*connect = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "enabled") == 0 && enabled)
|
||||
{
|
||||
@ -113,17 +113,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
*enabled_given = true;
|
||||
*enabled = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "disabled") == 0 && enabled)
|
||||
{
|
||||
if (*enabled_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
*enabled_given = true;
|
||||
*enabled = !defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "create slot") == 0 && create_slot)
|
||||
else if (strcmp(defel->defname, "create_slot") == 0 && create_slot)
|
||||
{
|
||||
if (create_slot_given)
|
||||
ereport(ERROR,
|
||||
@ -133,17 +123,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
create_slot_given = true;
|
||||
*create_slot = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "nocreate slot") == 0 && create_slot)
|
||||
{
|
||||
if (create_slot_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
create_slot_given = true;
|
||||
*create_slot = !defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "slot name") == 0 && slot_name)
|
||||
else if (strcmp(defel->defname, "slot_name") == 0 && slot_name)
|
||||
{
|
||||
if (*slot_name_given)
|
||||
ereport(ERROR,
|
||||
@ -157,7 +137,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
if (strcmp(*slot_name, "none") == 0)
|
||||
*slot_name = NULL;
|
||||
}
|
||||
else if (strcmp(defel->defname, "copy data") == 0 && copy_data)
|
||||
else if (strcmp(defel->defname, "copy_data") == 0 && copy_data)
|
||||
{
|
||||
if (copy_data_given)
|
||||
ereport(ERROR,
|
||||
@ -167,16 +147,6 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
copy_data_given = true;
|
||||
*copy_data = defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "nocopy data") == 0 && copy_data)
|
||||
{
|
||||
if (copy_data_given)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options")));
|
||||
|
||||
copy_data_given = true;
|
||||
*copy_data = !defGetBoolean(defel);
|
||||
}
|
||||
else if (strcmp(defel->defname, "synchronous_commit") == 0 &&
|
||||
synchronous_commit)
|
||||
{
|
||||
@ -336,7 +306,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
* replication slot.
|
||||
*/
|
||||
if (create_slot)
|
||||
PreventTransactionChain(isTopLevel, "CREATE SUBSCRIPTION ... CREATE SLOT");
|
||||
PreventTransactionChain(isTopLevel, "CREATE SUBSCRIPTION ... WITH (create_slot = true)");
|
||||
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
|
@ -338,7 +338,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
database_name access_method_clause access_method attr_name
|
||||
name cursor_name file_name
|
||||
index_name opt_index_name cluster_index_specification
|
||||
def_key
|
||||
|
||||
%type <list> func_name handler_name qual_Op qual_all_Op subquery_Op
|
||||
opt_class opt_inline_handler opt_validator validator_clause
|
||||
@ -652,7 +651,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
|
||||
|
||||
NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NONE
|
||||
NOREFRESH NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
|
||||
NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
|
||||
NULLS_P NUMERIC
|
||||
|
||||
OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
|
||||
@ -5673,21 +5672,16 @@ def_list: def_elem { $$ = list_make1($1); }
|
||||
| def_list ',' def_elem { $$ = lappend($1, $3); }
|
||||
;
|
||||
|
||||
def_elem: def_key '=' def_arg
|
||||
def_elem: ColLabel '=' def_arg
|
||||
{
|
||||
$$ = makeDefElem($1, (Node *) $3, @1);
|
||||
}
|
||||
| def_key
|
||||
| ColLabel
|
||||
{
|
||||
$$ = makeDefElem($1, NULL, @1);
|
||||
}
|
||||
;
|
||||
|
||||
def_key:
|
||||
ColLabel { $$ = $1; }
|
||||
| ColLabel ColLabel { $$ = psprintf("%s %s", $1, $2); }
|
||||
;
|
||||
|
||||
/* Note: any simple identifier will be returned as a type name! */
|
||||
def_arg: func_type { $$ = (Node *)$1; }
|
||||
| reserved_keyword { $$ = (Node *)makeString(pstrdup($1)); }
|
||||
@ -9173,9 +9167,10 @@ publication_for_tables:
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ALTER PUBLICATION name [ WITH ] options
|
||||
* ALTER PUBLICATION name SET ( options )
|
||||
*
|
||||
* ALTER PUBLICATION name ADD TABLE table [, table2]
|
||||
*
|
||||
@ -9186,7 +9181,7 @@ publication_for_tables:
|
||||
*****************************************************************************/
|
||||
|
||||
AlterPublicationStmt:
|
||||
ALTER PUBLICATION name WITH definition
|
||||
ALTER PUBLICATION name SET definition
|
||||
{
|
||||
AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
|
||||
n->pubname = $3;
|
||||
@ -9254,12 +9249,12 @@ publication_name_item:
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ALTER SUBSCRIPTION name [ WITH ] options
|
||||
* ALTER SUBSCRIPTION name ...
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
AlterSubscriptionStmt:
|
||||
ALTER SUBSCRIPTION name WITH definition
|
||||
ALTER SUBSCRIPTION name SET definition
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
@ -9296,7 +9291,7 @@ AlterSubscriptionStmt:
|
||||
n->options = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list NOREFRESH
|
||||
| ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list SKIP REFRESH
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
@ -14758,7 +14753,6 @@ unreserved_keyword:
|
||||
| NEW
|
||||
| NEXT
|
||||
| NO
|
||||
| NOREFRESH
|
||||
| NOTHING
|
||||
| NOTIFY
|
||||
| NOWAIT
|
||||
|
@ -3460,6 +3460,7 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
|
||||
PQExpBuffer delq;
|
||||
PQExpBuffer query;
|
||||
PQExpBuffer labelq;
|
||||
bool first = true;
|
||||
|
||||
if (!(pubinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
|
||||
return;
|
||||
@ -3479,23 +3480,32 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
|
||||
if (pubinfo->puballtables)
|
||||
appendPQExpBufferStr(query, " FOR ALL TABLES");
|
||||
|
||||
appendPQExpBufferStr(query, " WITH (");
|
||||
appendPQExpBufferStr(query, " WITH (publish = '");
|
||||
if (pubinfo->pubinsert)
|
||||
appendPQExpBufferStr(query, "PUBLISH INSERT");
|
||||
else
|
||||
appendPQExpBufferStr(query, "NOPUBLISH INSERT");
|
||||
{
|
||||
appendPQExpBufferStr(query, "insert");
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (!first)
|
||||
appendPQExpBufferStr(query, ", ");
|
||||
|
||||
if (pubinfo->pubupdate)
|
||||
appendPQExpBufferStr(query, ", PUBLISH UPDATE");
|
||||
else
|
||||
appendPQExpBufferStr(query, ", NOPUBLISH UPDATE");
|
||||
{
|
||||
appendPQExpBufferStr(query, "update");
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (!first)
|
||||
appendPQExpBufferStr(query, ", ");
|
||||
|
||||
if (pubinfo->pubdelete)
|
||||
appendPQExpBufferStr(query, ", PUBLISH DELETE");
|
||||
else
|
||||
appendPQExpBufferStr(query, ", NOPUBLISH DELETE");
|
||||
{
|
||||
appendPQExpBufferStr(query, "delete");
|
||||
first = false;
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(query, ");\n");
|
||||
appendPQExpBufferStr(query, "');\n");
|
||||
|
||||
ArchiveEntry(fout, pubinfo->dobj.catId, pubinfo->dobj.dumpId,
|
||||
pubinfo->dobj.name,
|
||||
@ -3817,11 +3827,11 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
|
||||
appendPQExpBufferStr(publications, fmtId(pubnames[i]));
|
||||
}
|
||||
|
||||
appendPQExpBuffer(query, " PUBLICATION %s WITH (NOCONNECT, SLOT NAME = ", publications->data);
|
||||
appendPQExpBuffer(query, " PUBLICATION %s WITH (connect = false, slot_name = ", publications->data);
|
||||
appendStringLiteralAH(query, subinfo->subslotname, fout);
|
||||
|
||||
if (strcmp(subinfo->subsynccommit, "off") != 0)
|
||||
appendPQExpBuffer(query, ", SYNCHRONOUS_COMMIT = %s", fmtId(subinfo->subsynccommit));
|
||||
appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit));
|
||||
|
||||
appendPQExpBufferStr(query, ");\n");
|
||||
|
||||
|
@ -4351,7 +4351,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
||||
create_order => 50,
|
||||
create_sql => 'CREATE PUBLICATION pub1;',
|
||||
regexp => qr/^
|
||||
\QCREATE PUBLICATION pub1 WITH (PUBLISH INSERT, PUBLISH UPDATE, PUBLISH DELETE);\E
|
||||
\QCREATE PUBLICATION pub1 WITH (publish = 'insert, update, delete');\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -4384,11 +4384,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
||||
create_order => 50,
|
||||
create_sql => 'CREATE PUBLICATION pub2
|
||||
FOR ALL TABLES
|
||||
WITH (NOPUBLISH INSERT,
|
||||
NOPUBLISH UPDATE,
|
||||
NOPUBLISH DELETE);',
|
||||
WITH (publish = \'\');',
|
||||
regexp => qr/^
|
||||
\QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (NOPUBLISH INSERT, NOPUBLISH UPDATE, NOPUBLISH DELETE);\E
|
||||
\QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -4421,9 +4419,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
||||
create_order => 50,
|
||||
create_sql => 'CREATE SUBSCRIPTION sub1
|
||||
CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1
|
||||
WITH (NOCONNECT);',
|
||||
WITH (connect = false);',
|
||||
regexp => qr/^
|
||||
\QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (NOCONNECT, SLOT NAME = 'sub1');\E
|
||||
\QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub1');\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
|
@ -1504,28 +1504,27 @@ psql_completion(const char *text, int start, int end)
|
||||
COMPLETE_WITH_LIST6("WITH (", "ADD TABLE", "SET TABLE", "DROP TABLE",
|
||||
"OWNER TO", "RENAME TO");
|
||||
}
|
||||
/* ALTER PUBLICATION <name> .. WITH ( ... */
|
||||
else if (HeadMatches3("ALTER", "PUBLICATION",MatchAny) && TailMatches2("WITH", "("))
|
||||
/* ALTER PUBLICATION <name> .. SET ( ... */
|
||||
else if (HeadMatches3("ALTER", "PUBLICATION",MatchAny) && TailMatches2("SET", "("))
|
||||
{
|
||||
COMPLETE_WITH_LIST6("PUBLISH INSERT", "NOPUBLISH INSERT", "PUBLISH UPDATE",
|
||||
"NOPUBLISH UPDATE", "PUBLISH DELETE", "NOPUBLISH DELETE");
|
||||
COMPLETE_WITH_CONST("publish");
|
||||
}
|
||||
/* ALTER SUBSCRIPTION <name> ... */
|
||||
else if (Matches3("ALTER","SUBSCRIPTION",MatchAny))
|
||||
{
|
||||
COMPLETE_WITH_LIST8("WITH (", "CONNECTION", "SET PUBLICATION", "ENABLE",
|
||||
COMPLETE_WITH_LIST8("SET (", "CONNECTION", "SET PUBLICATION", "ENABLE",
|
||||
"DISABLE", "OWNER TO", "RENAME TO", "REFRESH PUBLICATION WITH (");
|
||||
}
|
||||
/* ALTER SUBSCRIPTION <name> REFRESH PUBLICATION WITH ( ... */
|
||||
else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
|
||||
TailMatches4("REFRESH", "PUBLICATION", "WITH", "("))
|
||||
{
|
||||
COMPLETE_WITH_LIST2("COPY DATA", "NOCOPY DATA");
|
||||
COMPLETE_WITH_CONST("copy_data");
|
||||
}
|
||||
/* ALTER SUBSCRIPTION <name> .. WITH ( ... */
|
||||
else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("WITH", "("))
|
||||
/* ALTER SUBSCRIPTION <name> .. SET ( ... */
|
||||
else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("SET", "("))
|
||||
{
|
||||
COMPLETE_WITH_CONST("SLOT NAME");
|
||||
COMPLETE_WITH_CONST("slot_name");
|
||||
}
|
||||
/* ALTER SCHEMA <name> */
|
||||
else if (Matches3("ALTER", "SCHEMA", MatchAny))
|
||||
@ -2349,9 +2348,7 @@ psql_completion(const char *text, int start, int end)
|
||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
|
||||
/* Complete "CREATE PUBLICATION <name> [...] WITH" */
|
||||
else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches2("WITH", "("))
|
||||
COMPLETE_WITH_LIST2("PUBLISH", "NOPUBLISH");
|
||||
else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches3("WITH", "(", MatchAny))
|
||||
COMPLETE_WITH_LIST3("INSERT", "UPDATE", "DELETE");
|
||||
COMPLETE_WITH_CONST("publish");
|
||||
|
||||
/* CREATE RULE */
|
||||
/* Complete "CREATE RULE <sth>" with "AS ON" */
|
||||
@ -2427,9 +2424,8 @@ psql_completion(const char *text, int start, int end)
|
||||
COMPLETE_WITH_CONST("WITH (");
|
||||
/* Complete "CREATE SUBSCRIPTION <name> ... WITH ( <opt>" */
|
||||
else if (HeadMatches2("CREATE", "SUBSCRIPTION") && TailMatches2("WITH", "("))
|
||||
COMPLETE_WITH_LIST8("ENABLED", "DISABLED", "CREATE SLOT",
|
||||
"NOCREATE SLOT", "SLOT NAME", "COPY DATA", "NOCOPY DATA",
|
||||
"NOCONNECT");
|
||||
COMPLETE_WITH_LIST5("enabled", "create_slot", "slot_name",
|
||||
"copy_data", "connect");
|
||||
|
||||
/* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */
|
||||
/* complete CREATE TRIGGER <name> with BEFORE,AFTER,INSTEAD OF */
|
||||
|
@ -259,7 +259,6 @@ PG_KEYWORD("new", NEW, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("next", NEXT, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("no", NO, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("none", NONE, COL_NAME_KEYWORD)
|
||||
PG_KEYWORD("norefresh", NOREFRESH, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("not", NOT, RESERVED_KEYWORD)
|
||||
PG_KEYWORD("nothing", NOTHING, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("notify", NOTIFY, UNRESERVED_KEYWORD)
|
||||
|
@ -69,7 +69,7 @@ CREATE SCHEMA dummy_seclabel_test;
|
||||
SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified'; -- OK
|
||||
SET client_min_messages = error;
|
||||
CREATE PUBLICATION dummy_pub;
|
||||
CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (NOCONNECT, SLOT NAME = NONE);
|
||||
CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (connect = false, slot_name = NONE);
|
||||
RESET client_min_messages;
|
||||
SECURITY LABEL ON PUBLICATION dummy_pub IS 'classified';
|
||||
SECURITY LABEL ON SUBSCRIPTION dummy_sub IS 'classified';
|
||||
|
@ -73,7 +73,7 @@ SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified'; -- OK
|
||||
|
||||
SET client_min_messages = error;
|
||||
CREATE PUBLICATION dummy_pub;
|
||||
CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (NOCONNECT, SLOT NAME = NONE);
|
||||
CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (connect = false, slot_name = NONE);
|
||||
RESET client_min_messages;
|
||||
SECURITY LABEL ON PUBLICATION dummy_pub IS 'classified';
|
||||
SECURITY LABEL ON SUBSCRIPTION dummy_sub IS 'classified';
|
||||
|
@ -37,7 +37,7 @@ CREATE TRANSFORM FOR int LANGUAGE SQL (
|
||||
FROM SQL WITH FUNCTION varchar_transform(internal),
|
||||
TO SQL WITH FUNCTION int4recv(internal));
|
||||
CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
|
||||
CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (NOCONNECT, SLOT NAME = NONE);
|
||||
CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE);
|
||||
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
|
||||
CREATE STATISTICS addr_nsp.gentable_stat ON (a,b) FROM addr_nsp.gentable;
|
||||
-- test some error cases
|
||||
|
@ -13,8 +13,13 @@ SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p;
|
||||
test publication
|
||||
(1 row)
|
||||
|
||||
CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update);
|
||||
ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
|
||||
CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert);
|
||||
ALTER PUBLICATION testpub_default SET (publish = update);
|
||||
-- error cases
|
||||
CREATE PUBLICATION testpub_xxx WITH (foo);
|
||||
ERROR: unrecognized publication parameter: foo
|
||||
CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
|
||||
ERROR: unrecognized "publish" value: "cluster"
|
||||
\dRp
|
||||
List of publications
|
||||
Name | Owner | Inserts | Updates | Deletes
|
||||
@ -23,7 +28,7 @@ ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
|
||||
testpub_default | regress_publication_user | f | t | f
|
||||
(2 rows)
|
||||
|
||||
ALTER PUBLICATION testpub_default WITH (publish insert, publish delete);
|
||||
ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
|
||||
\dRp
|
||||
List of publications
|
||||
Name | Owner | Inserts | Updates | Deletes
|
||||
@ -38,8 +43,8 @@ CREATE TABLE testpub_tbl1 (id serial primary key, data text);
|
||||
CREATE TABLE pub_test.testpub_nopk (foo int, bar int);
|
||||
CREATE VIEW testpub_view AS SELECT 1;
|
||||
CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a);
|
||||
CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (nopublish delete, nopublish update);
|
||||
ALTER PUBLICATION testpub_foralltables WITH (publish update);
|
||||
CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert');
|
||||
ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update');
|
||||
CREATE TABLE testpub_tbl2 (id serial primary key, data text);
|
||||
-- fail - can't add to for all tables publication
|
||||
ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2;
|
||||
|
@ -17,18 +17,18 @@ LINE 1: CREATE SUBSCRIPTION testsub PUBLICATION foo;
|
||||
^
|
||||
-- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block
|
||||
BEGIN;
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (CREATE SLOT);
|
||||
ERROR: CREATE SUBSCRIPTION ... CREATE SLOT cannot run inside a transaction block
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot);
|
||||
ERROR: CREATE SUBSCRIPTION ... WITH (create_slot = true) cannot run inside a transaction block
|
||||
COMMIT;
|
||||
-- fail - invalid connection string
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub;
|
||||
ERROR: invalid connection string syntax: missing "=" after "testconn" in connection info string
|
||||
|
||||
-- fail - duplicate publications
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false);
|
||||
ERROR: publication name "foo" used more than once
|
||||
-- ok
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
|
||||
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
|
||||
COMMENT ON SUBSCRIPTION testsub IS 'test subscription';
|
||||
SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
|
||||
@ -38,11 +38,11 @@ SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
|
||||
(1 row)
|
||||
|
||||
-- fail - name already exists
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
|
||||
ERROR: subscription "testsub" already exists
|
||||
-- fail - must be superuser
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user2';
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
|
||||
ERROR: must be superuser to create subscriptions
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
||||
-- fail - invalid connection string
|
||||
@ -56,9 +56,9 @@ ERROR: invalid connection string syntax: missing "=" after "foobar" in connecti
|
||||
testsub | regress_subscription_user | f | {testpub} | off | dbname=doesnotexist
|
||||
(1 row)
|
||||
|
||||
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
|
||||
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 SKIP REFRESH;
|
||||
ALTER SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist2';
|
||||
ALTER SUBSCRIPTION testsub WITH (SLOT NAME = 'newname');
|
||||
ALTER SUBSCRIPTION testsub SET (slot_name = 'newname');
|
||||
-- fail
|
||||
ALTER SUBSCRIPTION doesnotexist CONNECTION 'dbname=doesnotexist2';
|
||||
ERROR: subscription "doesnotexist" does not exist
|
||||
@ -93,8 +93,8 @@ ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy;
|
||||
ERROR: must be owner of subscription testsub
|
||||
RESET ROLE;
|
||||
ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
|
||||
ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = local);
|
||||
ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = foobar);
|
||||
ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = local);
|
||||
ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = foobar);
|
||||
ERROR: invalid value for parameter "synchronous_commit": "foobar"
|
||||
HINT: Available values: local, remote_write, remote_apply, on, off.
|
||||
\dRs+
|
||||
@ -118,7 +118,7 @@ BEGIN;
|
||||
DROP SUBSCRIPTION testsub;
|
||||
ERROR: DROP SUBSCRIPTION cannot run inside a transaction block
|
||||
COMMIT;
|
||||
ALTER SUBSCRIPTION testsub WITH (SLOT NAME = NONE);
|
||||
ALTER SUBSCRIPTION testsub SET (slot_name = NONE);
|
||||
-- now it works
|
||||
BEGIN;
|
||||
DROP SUBSCRIPTION testsub;
|
||||
|
@ -40,7 +40,7 @@ CREATE TRANSFORM FOR int LANGUAGE SQL (
|
||||
FROM SQL WITH FUNCTION varchar_transform(internal),
|
||||
TO SQL WITH FUNCTION int4recv(internal));
|
||||
CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
|
||||
CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (NOCONNECT, SLOT NAME = NONE);
|
||||
CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE);
|
||||
CREATE STATISTICS addr_nsp.gentable_stat ON (a,b) FROM addr_nsp.gentable;
|
||||
|
||||
-- test some error cases
|
||||
|
@ -11,13 +11,17 @@ CREATE PUBLICATION testpub_default;
|
||||
COMMENT ON PUBLICATION testpub_default IS 'test publication';
|
||||
SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p;
|
||||
|
||||
CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update);
|
||||
CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert);
|
||||
|
||||
ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
|
||||
ALTER PUBLICATION testpub_default SET (publish = update);
|
||||
|
||||
-- error cases
|
||||
CREATE PUBLICATION testpub_xxx WITH (foo);
|
||||
CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
|
||||
|
||||
\dRp
|
||||
|
||||
ALTER PUBLICATION testpub_default WITH (publish insert, publish delete);
|
||||
ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
|
||||
|
||||
\dRp
|
||||
|
||||
@ -28,8 +32,8 @@ CREATE TABLE pub_test.testpub_nopk (foo int, bar int);
|
||||
CREATE VIEW testpub_view AS SELECT 1;
|
||||
CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a);
|
||||
|
||||
CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (nopublish delete, nopublish update);
|
||||
ALTER PUBLICATION testpub_foralltables WITH (publish update);
|
||||
CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert');
|
||||
ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update');
|
||||
|
||||
CREATE TABLE testpub_tbl2 (id serial primary key, data text);
|
||||
-- fail - can't add to for all tables publication
|
||||
|
@ -15,27 +15,27 @@ CREATE SUBSCRIPTION testsub PUBLICATION foo;
|
||||
|
||||
-- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block
|
||||
BEGIN;
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (CREATE SLOT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot);
|
||||
COMMIT;
|
||||
|
||||
-- fail - invalid connection string
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub;
|
||||
|
||||
-- fail - duplicate publications
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false);
|
||||
|
||||
-- ok
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
|
||||
|
||||
COMMENT ON SUBSCRIPTION testsub IS 'test subscription';
|
||||
SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
|
||||
|
||||
-- fail - name already exists
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
|
||||
|
||||
-- fail - must be superuser
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user2';
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
|
||||
CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
|
||||
SET SESSION AUTHORIZATION 'regress_subscription_user';
|
||||
|
||||
-- fail - invalid connection string
|
||||
@ -43,9 +43,9 @@ ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
|
||||
|
||||
\dRs+
|
||||
|
||||
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
|
||||
ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 SKIP REFRESH;
|
||||
ALTER SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist2';
|
||||
ALTER SUBSCRIPTION testsub WITH (SLOT NAME = 'newname');
|
||||
ALTER SUBSCRIPTION testsub SET (slot_name = 'newname');
|
||||
|
||||
-- fail
|
||||
ALTER SUBSCRIPTION doesnotexist CONNECTION 'dbname=doesnotexist2';
|
||||
@ -69,8 +69,8 @@ ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy;
|
||||
RESET ROLE;
|
||||
|
||||
ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
|
||||
ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = local);
|
||||
ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = foobar);
|
||||
ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = local);
|
||||
ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = foobar);
|
||||
|
||||
\dRs+
|
||||
|
||||
@ -88,7 +88,7 @@ BEGIN;
|
||||
DROP SUBSCRIPTION testsub;
|
||||
COMMIT;
|
||||
|
||||
ALTER SUBSCRIPTION testsub WITH (SLOT NAME = NONE);
|
||||
ALTER SUBSCRIPTION testsub SET (slot_name = NONE);
|
||||
|
||||
-- now it works
|
||||
BEGIN;
|
||||
|
@ -40,7 +40,7 @@ my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION tap_pub");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"CREATE PUBLICATION tap_pub_ins_only WITH (nopublish delete, nopublish update)");
|
||||
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
@ -136,7 +136,7 @@ $node_publisher->poll_query_until('postgres',
|
||||
$oldpid = $node_publisher->safe_psql('postgres',
|
||||
"SELECT pid FROM pg_stat_replication WHERE application_name = '$appname';");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only REFRESH WITH (NOCOPY DATA)");
|
||||
"ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only REFRESH WITH (copy_data = false)");
|
||||
$node_publisher->poll_query_until('postgres',
|
||||
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';")
|
||||
or die "Timed out while waiting for apply to restart";
|
||||
@ -159,13 +159,13 @@ is($result, qq(20|-20|-1), 'check changes skipped after subscription publication
|
||||
|
||||
# check alter publication (relcache invalidation etc)
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"ALTER PUBLICATION tap_pub_ins_only WITH (publish delete)");
|
||||
"ALTER PUBLICATION tap_pub_ins_only SET (publish = 'insert, delete')");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_full");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"DELETE FROM tab_ins WHERE a > 0");
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION WITH (NOCOPY DATA)");
|
||||
"ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION WITH (copy_data = false)");
|
||||
$node_publisher->safe_psql('postgres',
|
||||
"INSERT INTO tab_full VALUES(0)");
|
||||
|
||||
|
@ -103,7 +103,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (SLOT NAME = tap_sub_slot)");
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (slot_name = tap_sub_slot)");
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
|
@ -34,7 +34,7 @@ $node_publisher->safe_psql('postgres',
|
||||
|
||||
my $appname = 'tap_sub';
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (NOCOPY DATA)");
|
||||
"CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)");
|
||||
|
||||
# Wait for subscriber to finish initialization
|
||||
my $caughtup_query =
|
||||
|
@ -82,7 +82,7 @@ is($result, qq(20), 'initial data synced for second sub');
|
||||
|
||||
# now check another subscription for the same node pair
|
||||
$node_subscriber->safe_psql('postgres',
|
||||
"CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (NOCOPY DATA)");
|
||||
"CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)");
|
||||
|
||||
# wait for it to start
|
||||
$node_subscriber->poll_query_until('postgres', "SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL")
|
||||
|
Reference in New Issue
Block a user