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

@ -1336,7 +1336,7 @@ psql_completion(char *text, int start, int end)
static const char *const list_ALTER2[] =
{"ADD", "ALTER", "CLUSTER ON", "DISABLE", "DROP", "ENABLE", "INHERIT",
"NO INHERIT", "RENAME", "RESET", "OWNER TO", "SET",
"VALIDATE CONSTRAINT", NULL};
"VALIDATE CONSTRAINT", "REPLICA IDENTITY", NULL};
COMPLETE_WITH_LIST(list_ALTER2);
}
@ -1581,6 +1581,35 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_TABLEOPTIONS);
}
else if (pg_strcasecmp(prev4_wd, "REPLICA") == 0 &&
pg_strcasecmp(prev3_wd, "IDENTITY") == 0 &&
pg_strcasecmp(prev2_wd, "USING") == 0 &&
pg_strcasecmp(prev_wd, "INDEX") == 0)
{
completion_info_charp = prev5_wd;
COMPLETE_WITH_QUERY(Query_for_index_of_table);
}
else if (pg_strcasecmp(prev5_wd, "TABLE") == 0 &&
pg_strcasecmp(prev3_wd, "REPLICA") == 0 &&
pg_strcasecmp(prev2_wd, "IDENTITY") == 0 &&
pg_strcasecmp(prev_wd, "USING") == 0)
{
COMPLETE_WITH_CONST("INDEX");
}
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
pg_strcasecmp(prev2_wd, "REPLICA") == 0 &&
pg_strcasecmp(prev_wd, "IDENTITY") == 0)
{
static const char *const list_REPLICAID[] =
{"FULL", "NOTHING", "DEFAULT", "USING", NULL};
COMPLETE_WITH_LIST(list_REPLICAID);
}
else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
pg_strcasecmp(prev_wd, "REPLICA") == 0)
{
COMPLETE_WITH_CONST("IDENTITY");
}
/* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&