diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2018-04-07 11:24:53 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2018-04-07 11:34:11 -0400 |
commit | 039eb6e92f20499ac36cc74f8a5cef7430b706f6 (patch) | |
tree | 2cf52aeafb59917d5c7ed396acb6d86325b4a8b0 /src/bin/psql/describe.c | |
parent | 5dfd1e5a6696b271a2cdee54143fbc209c88c02f (diff) | |
download | postgresql-039eb6e92f20499ac36cc74f8a5cef7430b706f6.tar.gz postgresql-039eb6e92f20499ac36cc74f8a5cef7430b706f6.zip |
Logical replication support for TRUNCATE
Update the built-in logical replication system to make use of the
previously added logical decoding for TRUNCATE support. Add the
required truncate callback to pgoutput and a new logical replication
protocol message.
Publications get a new attribute to determine whether to replicate
truncate actions. When updating a publication via pg_dump from an older
version, this is not set, thus preserving the previous behavior.
Author: Simon Riggs <simon@2ndquadrant.com>
Author: Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Author: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Diffstat (limited to 'src/bin/psql/describe.c')
-rw-r--r-- | src/bin/psql/describe.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 0c3be1f5046..75a1e42ceea 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -5187,7 +5187,7 @@ listPublications(const char *pattern) PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; - static const bool translate_columns[] = {false, false, false, false, false, false}; + static const bool translate_columns[] = {false, false, false, false, false, false, false}; if (pset.sversion < 100000) { @@ -5207,13 +5207,17 @@ listPublications(const char *pattern) " puballtables AS \"%s\",\n" " pubinsert AS \"%s\",\n" " pubupdate AS \"%s\",\n" - " pubdelete AS \"%s\"\n", + " pubdelete AS \"%s\"", gettext_noop("Name"), gettext_noop("Owner"), gettext_noop("All tables"), gettext_noop("Inserts"), gettext_noop("Updates"), gettext_noop("Deletes")); + if (pset.sversion >= 110000) + appendPQExpBuffer(&buf, + ",\n pubtruncate AS \"%s\"", + gettext_noop("Truncates")); appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_publication\n"); @@ -5254,6 +5258,7 @@ describePublications(const char *pattern) PQExpBufferData buf; int i; PGresult *res; + bool has_pubtruncate; if (pset.sversion < 100000) { @@ -5265,13 +5270,19 @@ describePublications(const char *pattern) return true; } + has_pubtruncate = (pset.sversion >= 110000); + initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "SELECT oid, pubname,\n" " pg_catalog.pg_get_userbyid(pubowner) AS owner,\n" - " puballtables, pubinsert, pubupdate, pubdelete\n" - "FROM pg_catalog.pg_publication\n"); + " puballtables, pubinsert, pubupdate, pubdelete"); + if (has_pubtruncate) + appendPQExpBuffer(&buf, + ", pubtruncate"); + appendPQExpBuffer(&buf, + "\nFROM pg_catalog.pg_publication\n"); processSQLNamePattern(pset.db, &buf, pattern, false, false, NULL, "pubname", NULL, @@ -5317,6 +5328,9 @@ describePublications(const char *pattern) printTableOpt myopt = pset.popt.topt; printTableContent cont; + if (has_pubtruncate) + ncols++; + initPQExpBuffer(&title); printfPQExpBuffer(&title, _("Publication %s"), pubname); printTableInit(&cont, &myopt, title.data, ncols, nrows); @@ -5326,12 +5340,16 @@ describePublications(const char *pattern) printTableAddHeader(&cont, gettext_noop("Inserts"), true, align); printTableAddHeader(&cont, gettext_noop("Updates"), true, align); printTableAddHeader(&cont, gettext_noop("Deletes"), true, align); + if (has_pubtruncate) + printTableAddHeader(&cont, gettext_noop("Truncates"), true, align); printTableAddCell(&cont, PQgetvalue(res, i, 2), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 4), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 6), false, false); + if (has_pubtruncate) + printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false); if (!puballtables) { |