1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Logical replication

- Add PUBLICATION catalogs and DDL
- Add SUBSCRIPTION catalog and DDL
- Define logical replication protocol and output plugin
- Add logical replication workers

From: Petr Jelinek <petr@2ndquadrant.com>
Reviewed-by: Steve Singer <steve@ssinger.info>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
This commit is contained in:
Peter Eisentraut
2017-01-19 12:00:00 -05:00
parent ba61a04bc7
commit 665d1fad99
119 changed files with 13354 additions and 95 deletions

View File

@@ -4286,6 +4286,69 @@ _copyPartitionCmd(const PartitionCmd *from)
return newnode;
}
static CreatePublicationStmt *
_copyCreatePublicationStmt(const CreatePublicationStmt *from)
{
CreatePublicationStmt *newnode = makeNode(CreatePublicationStmt);
COPY_STRING_FIELD(pubname);
COPY_NODE_FIELD(options);
COPY_NODE_FIELD(tables);
COPY_SCALAR_FIELD(for_all_tables);
return newnode;
}
static AlterPublicationStmt *
_copyAlterPublicationStmt(const AlterPublicationStmt *from)
{
AlterPublicationStmt *newnode = makeNode(AlterPublicationStmt);
COPY_STRING_FIELD(pubname);
COPY_NODE_FIELD(options);
COPY_NODE_FIELD(tables);
COPY_SCALAR_FIELD(for_all_tables);
COPY_SCALAR_FIELD(tableAction);
return newnode;
}
static CreateSubscriptionStmt *
_copyCreateSubscriptionStmt(const CreateSubscriptionStmt *from)
{
CreateSubscriptionStmt *newnode = makeNode(CreateSubscriptionStmt);
COPY_STRING_FIELD(subname);
COPY_STRING_FIELD(conninfo);
COPY_NODE_FIELD(publication);
COPY_NODE_FIELD(options);
return newnode;
}
static AlterSubscriptionStmt *
_copyAlterSubscriptionStmt(const AlterSubscriptionStmt *from)
{
AlterSubscriptionStmt *newnode = makeNode(AlterSubscriptionStmt);
COPY_STRING_FIELD(subname);
COPY_NODE_FIELD(options);
return newnode;
}
static DropSubscriptionStmt *
_copyDropSubscriptionStmt(const DropSubscriptionStmt *from)
{
DropSubscriptionStmt *newnode = makeNode(DropSubscriptionStmt);
COPY_STRING_FIELD(subname);
COPY_SCALAR_FIELD(drop_slot);
COPY_SCALAR_FIELD(missing_ok);
return newnode;
}
/* ****************************************************************
* pg_list.h copy functions
* ****************************************************************
@@ -5086,6 +5149,21 @@ copyObject(const void *from)
case T_AlterPolicyStmt:
retval = _copyAlterPolicyStmt(from);
break;
case T_CreatePublicationStmt:
retval = _copyCreatePublicationStmt(from);
break;
case T_AlterPublicationStmt:
retval = _copyAlterPublicationStmt(from);
break;
case T_CreateSubscriptionStmt:
retval = _copyCreateSubscriptionStmt(from);
break;
case T_AlterSubscriptionStmt:
retval = _copyAlterSubscriptionStmt(from);
break;
case T_DropSubscriptionStmt:
retval = _copyDropSubscriptionStmt(from);
break;
case T_A_Expr:
retval = _copyAExpr(from);
break;

View File

@@ -2134,6 +2134,64 @@ _equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
return true;
}
static bool
_equalCreatePublicationStmt(const CreatePublicationStmt *a,
const CreatePublicationStmt *b)
{
COMPARE_STRING_FIELD(pubname);
COMPARE_NODE_FIELD(options);
COMPARE_NODE_FIELD(tables);
COMPARE_SCALAR_FIELD(for_all_tables);
return true;
}
static bool
_equalAlterPublicationStmt(const AlterPublicationStmt *a,
const AlterPublicationStmt *b)
{
COMPARE_STRING_FIELD(pubname);
COMPARE_NODE_FIELD(options);
COMPARE_NODE_FIELD(tables);
COMPARE_SCALAR_FIELD(for_all_tables);
COMPARE_SCALAR_FIELD(tableAction);
return true;
}
static bool
_equalCreateSubscriptionStmt(const CreateSubscriptionStmt *a,
const CreateSubscriptionStmt *b)
{
COMPARE_STRING_FIELD(subname);
COMPARE_STRING_FIELD(conninfo);
COMPARE_NODE_FIELD(publication);
COMPARE_NODE_FIELD(options);
return true;
}
static bool
_equalAlterSubscriptionStmt(const AlterSubscriptionStmt *a,
const AlterSubscriptionStmt *b)
{
COMPARE_STRING_FIELD(subname);
COMPARE_NODE_FIELD(options);
return true;
}
static bool
_equalDropSubscriptionStmt(const DropSubscriptionStmt *a,
const DropSubscriptionStmt *b)
{
COMPARE_STRING_FIELD(subname);
COMPARE_SCALAR_FIELD(drop_slot);
COMPARE_SCALAR_FIELD(missing_ok);
return true;
}
static bool
_equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
{
@@ -3349,6 +3407,21 @@ equal(const void *a, const void *b)
case T_AlterPolicyStmt:
retval = _equalAlterPolicyStmt(a, b);
break;
case T_CreatePublicationStmt:
retval = _equalCreatePublicationStmt(a, b);
break;
case T_AlterPublicationStmt:
retval = _equalAlterPublicationStmt(a, b);
break;
case T_CreateSubscriptionStmt:
retval = _equalCreateSubscriptionStmt(a, b);
break;
case T_AlterSubscriptionStmt:
retval = _equalAlterSubscriptionStmt(a, b);
break;
case T_DropSubscriptionStmt:
retval = _equalDropSubscriptionStmt(a, b);
break;
case T_A_Expr:
retval = _equalAExpr(a, b);
break;