1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Add the notion of REPLICA IDENTITY for a table.

Pending patches for logical replication will use this to determine
which columns of a tuple ought to be considered as its candidate key.

Andres Freund, with minor, mostly cosmetic adjustments by me
This commit is contained in:
Robert Haas
2013-11-08 12:30:43 -05:00
parent b97ee66cc1
commit 07cacba983
23 changed files with 902 additions and 49 deletions

View File

@ -255,6 +255,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <ival> add_drop opt_asc_desc opt_nulls_order
%type <node> alter_table_cmd alter_type_cmd opt_collate_clause
replica_identity
%type <list> alter_table_cmds alter_type_cmds
%type <dbehavior> opt_drop_behavior
@ -2178,6 +2179,14 @@ alter_table_cmd:
n->def = (Node *)$2;
$$ = (Node *)n;
}
/* ALTER TABLE <name> REPLICA IDENTITY */
| REPLICA IDENTITY_P replica_identity
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_ReplicaIdentity;
n->def = $3;
$$ = (Node *)n;
}
| alter_generic_options
{
AlterTableCmd *n = makeNode(AlterTableCmd);
@ -2215,6 +2224,37 @@ alter_using:
| /* EMPTY */ { $$ = NULL; }
;
replica_identity:
NOTHING
{
ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
n->identity_type = REPLICA_IDENTITY_NOTHING;
n->name = NULL;
$$ = (Node *) n;
}
| FULL
{
ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
n->identity_type = REPLICA_IDENTITY_FULL;
n->name = NULL;
$$ = (Node *) n;
}
| DEFAULT
{
ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
n->identity_type = REPLICA_IDENTITY_DEFAULT;
n->name = NULL;
$$ = (Node *) n;
}
| USING INDEX name
{
ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
n->identity_type = REPLICA_IDENTITY_INDEX;
n->name = $3;
$$ = (Node *) n;
}
;
reloptions:
'(' reloption_list ')' { $$ = $2; }
;