mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Logical replication support for initial data copy
Add functionality for a new subscription to copy the initial data in the tables and then sync with the ongoing apply process. For the copying, add a new internal COPY option to have the COPY source data provided by a callback function. The initial data copy works on the subscriber by receiving COPY data from the publisher and then providing it locally into a COPY that writes to the destination table. A WAL receiver can now execute full SQL commands. This is used here to obtain information about tables and publications. Several new options were added to CREATE and ALTER SUBSCRIPTION to control whether and when initial table syncing happens. Change pg_dump option --no-create-subscription-slots to --no-subscription-connect and use the new CREATE SUBSCRIPTION ... NOCONNECT option for that. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com> Tested-by: Erik Rijkers <er@xs4all.nl>
This commit is contained in:
@@ -651,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
|
||||
NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
|
||||
NOREFRESH NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
|
||||
NULLS_P NUMERIC
|
||||
|
||||
OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
|
||||
@@ -9095,6 +9095,7 @@ AlterSubscriptionStmt:
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_OPTIONS;
|
||||
n->subname = $3;
|
||||
n->options = $5;
|
||||
$$ = (Node *)n;
|
||||
@@ -9103,24 +9104,45 @@ AlterSubscriptionStmt:
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_CONNECTION;
|
||||
n->subname = $3;
|
||||
n->options = list_make1(makeDefElem("conninfo",
|
||||
(Node *)makeString($5), @1));
|
||||
n->conninfo = $5;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list
|
||||
| ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_REFRESH;
|
||||
n->subname = $3;
|
||||
n->options = list_make1(makeDefElem("publication",
|
||||
(Node *)$6, @1));
|
||||
n->options = $6;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list REFRESH opt_definition
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_PUBLICATION_REFRESH;
|
||||
n->subname = $3;
|
||||
n->publication = $6;
|
||||
n->options = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list NOREFRESH
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_PUBLICATION;
|
||||
n->subname = $3;
|
||||
n->publication = $6;
|
||||
n->options = NIL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER SUBSCRIPTION name ENABLE_P
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_ENABLED;
|
||||
n->subname = $3;
|
||||
n->options = list_make1(makeDefElem("enabled",
|
||||
(Node *)makeInteger(TRUE), @1));
|
||||
@@ -9130,11 +9152,13 @@ AlterSubscriptionStmt:
|
||||
{
|
||||
AlterSubscriptionStmt *n =
|
||||
makeNode(AlterSubscriptionStmt);
|
||||
n->kind = ALTER_SUBSCRIPTION_ENABLED;
|
||||
n->subname = $3;
|
||||
n->options = list_make1(makeDefElem("enabled",
|
||||
(Node *)makeInteger(FALSE), @1));
|
||||
$$ = (Node *)n;
|
||||
} ;
|
||||
}
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@@ -14548,6 +14572,7 @@ unreserved_keyword:
|
||||
| NEW
|
||||
| NEXT
|
||||
| NO
|
||||
| NOREFRESH
|
||||
| NOTHING
|
||||
| NOTIFY
|
||||
| NOWAIT
|
||||
|
||||
Reference in New Issue
Block a user