From 25a0c997218cef5df368154d253f3f6b4ad45e80 Mon Sep 17 00:00:00 2001 From: Zhijie Hou Date: Wed, 2 Dec 2026 15:06:31 +0800 Subject: [PATCH 1/3] Top-up 1: Simplify describeSubscriptions() and preserve formatting. The base patch split describeSubscriptions() into two functions and duplicated all 21 column headers and server-version checks to populate printTable manually. That added ~300 lines of boilerplate, reintroduced pre-v10 version checks removed in commit 831bec4592, left-aligned the integer "Max retention duration" column, and ignored \pset null, display_true, and display_false in \dRs+. Simplify this by keeping a single describeSubscriptions(pattern, verbose) function, fetching conflict_log_table as a trailing internal column when verbose is set, and populating each subscription's printTable from the PGresult metadata (PQfname, PQftype, and column_type_alignment) while honoring \pset null, display_true, and display_false. Also check CancelRequested in the per-subscription loop. --- src/bin/psql/command.c | 5 +- src/bin/psql/describe.c | 443 +++++++-------------- src/bin/psql/describe.h | 5 +- src/test/regress/expected/subscription.out | 44 +- 4 files changed, 164 insertions(+), 333 deletions(-) diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 4b4e976580b..407d263fb20 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1219,10 +1219,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd) success = listPublications(pattern); break; case 's': - if (show_verbose) - success = describeSubscriptions(pattern); - else - success = listSubscriptions(pattern); + success = describeSubscriptions(pattern, show_verbose); break; default: status = PSQL_CMD_UNKNOWN; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index d446fbd1898..0e98043be10 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6763,246 +6763,138 @@ error_return: /* * \dRs - * Lists subscriptions. + * Describes subscriptions. * * Takes an optional regexp to select particular subscriptions */ bool -listSubscriptions(const char *pattern) +describeSubscriptions(const char *pattern, bool verbose) { PQExpBufferData buf; + PQExpBufferData title; PGresult *res; printQueryOpt myopt = pset.popt; + int clt_col; + int ncols; static const bool translate_columns[] = {false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); addQueryComment(&buf, "Get matching subscriptions"); - - /* Only display subscriptions in current database. */ appendPQExpBuffer(&buf, "SELECT subname AS \"%s\"\n" ", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n" ", subenabled AS \"%s\"\n" - ", subpublications AS \"%s\"\n" - "FROM pg_catalog.pg_subscription\n" - "WHERE subdbid = (SELECT oid\n" - " FROM pg_catalog.pg_database\n" - " WHERE datname = pg_catalog.current_database())", + ", subpublications AS \"%s\"\n", gettext_noop("Name"), gettext_noop("Owner"), gettext_noop("Enabled"), gettext_noop("Publication")); - if (!validateSQLNamePattern(&buf, pattern, true, false, - NULL, "subname", NULL, - NULL, - NULL, 1)) - { - termPQExpBuffer(&buf); - return false; - } - - appendPQExpBufferStr(&buf, "ORDER BY 1;"); - - res = PSQLexec(buf.data); - termPQExpBuffer(&buf); - if (!res) - return false; - - myopt.title = _("List of subscriptions"); - myopt.translate_header = true; - myopt.translate_columns = translate_columns; - myopt.n_translate_columns = lengthof(translate_columns); - - printQuery(res, &myopt, pset.queryFout, false, pset.logfile); - - PQclear(res); - - return true; -} - -/* - * \dRs+ - * Describes subscriptions. - * - * Takes an optional regexp to select particular subscriptions - */ -bool -describeSubscriptions(const char *pattern) -{ - PQExpBufferData buf; - int i; - PGresult *res; - int ncols; - int nrows = 1; - - PQExpBufferData title; - PQExpBufferData footer; - printTableContent cont; - - if (pset.sversion < 100000) + if (verbose) { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - - initPQExpBuffer(&buf); - initPQExpBuffer(&footer); - - addQueryComment(&buf, "Get matching subscriptions"); - appendPQExpBuffer(&buf, - "SELECT subname AS \"%s\"\n", - gettext_noop("Name")); - - /* - * The conflict log table is only shown in a footer, so it is fetched - * here, as a hidden column, and not with the displayed ones below. - */ - if (pset.sversion >= 200000) - appendPQExpBufferStr(&buf, - ", CASE WHEN subconflictlogrelid <> 0\n" - " THEN subconflictlogrelid::pg_catalog.regclass::pg_catalog.text\n" - " END AS conflict_log_table\n"); - else - appendPQExpBufferStr(&buf, - ", NULL::pg_catalog.text AS conflict_log_table\n"); - - appendPQExpBuffer(&buf, - ", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n" - ", subenabled AS \"%s\"\n" - ", subpublications AS \"%s\"\n", - gettext_noop("Owner"), - gettext_noop("Enabled"), - gettext_noop("Publication")); + /* Binary mode and streaming are only supported in v14 and higher */ + if (pset.sversion >= 140000) + { + appendPQExpBuffer(&buf, + ", subbinary AS \"%s\"\n", + gettext_noop("Binary")); - /* - * The subname and conflict_log_table columns are internal and not - * displayed, so only 3 visible columns. - */ - ncols = 3; + if (pset.sversion >= 160000) + appendPQExpBuffer(&buf, + ", (CASE substream\n" + " WHEN " CppAsString2(LOGICALREP_STREAM_OFF) " THEN 'off'\n" + " WHEN " CppAsString2(LOGICALREP_STREAM_ON) " THEN 'on'\n" + " WHEN " CppAsString2(LOGICALREP_STREAM_PARALLEL) " THEN 'parallel'\n" + " END) AS \"%s\"\n", + gettext_noop("Streaming")); + else + appendPQExpBuffer(&buf, + ", substream AS \"%s\"\n", + gettext_noop("Streaming")); + } - /* Binary mode and streaming are only supported in v14 and higher */ - if (pset.sversion >= 140000) - { - appendPQExpBuffer(&buf, - ", subbinary AS \"%s\"\n", - gettext_noop("Binary")); - ncols++; + /* Two_phase and disable_on_error are only supported in v15 and higher */ + if (pset.sversion >= 150000) + appendPQExpBuffer(&buf, + ", subtwophasestate AS \"%s\"\n" + ", subdisableonerr AS \"%s\"\n", + gettext_noop("Two-phase commit"), + gettext_noop("Disable on error")); if (pset.sversion >= 160000) appendPQExpBuffer(&buf, - ", (CASE substream\n" - " WHEN " CppAsString2(LOGICALREP_STREAM_OFF) " THEN 'off'\n" - " WHEN " CppAsString2(LOGICALREP_STREAM_ON) " THEN 'on'\n" - " WHEN " CppAsString2(LOGICALREP_STREAM_PARALLEL) " THEN 'parallel'\n" - " END) AS \"%s\"\n", - gettext_noop("Streaming")); - else + ", suborigin AS \"%s\"\n" + ", subpasswordrequired AS \"%s\"\n" + ", subrunasowner AS \"%s\"\n", + gettext_noop("Origin"), + gettext_noop("Password required"), + gettext_noop("Run as owner?")); + + if (pset.sversion >= 170000) appendPQExpBuffer(&buf, - ", substream AS \"%s\"\n", - gettext_noop("Streaming")); + ", subfailover AS \"%s\"\n", + gettext_noop("Failover")); + if (pset.sversion >= 190000) + { + appendPQExpBuffer(&buf, + ", (select srvname from pg_catalog.pg_foreign_server where oid=subserver) AS \"%s\"\n", + gettext_noop("Server")); - ncols++; - } + appendPQExpBuffer(&buf, + ", subretaindeadtuples AS \"%s\"\n", + gettext_noop("Retain dead tuples")); - /* Two_phase and disable_on_error are only supported in v15 and higher */ - if (pset.sversion >= 150000) - { - appendPQExpBuffer(&buf, - ", subtwophasestate AS \"%s\"\n" - ", subdisableonerr AS \"%s\"\n", - gettext_noop("Two-phase commit"), - gettext_noop("Disable on error")); - ncols += 2; - } + appendPQExpBuffer(&buf, + ", submaxretention AS \"%s\"\n", + gettext_noop("Max retention duration")); - if (pset.sversion >= 160000) - { - appendPQExpBuffer(&buf, - ", suborigin AS \"%s\"\n" - ", subpasswordrequired AS \"%s\"\n" - ", subrunasowner AS \"%s\"\n", - gettext_noop("Origin"), - gettext_noop("Password required"), - gettext_noop("Run as owner?")); - ncols += 3; - } + appendPQExpBuffer(&buf, + ", subretentionactive AS \"%s\"\n", + gettext_noop("Retention active")); + } - if (pset.sversion >= 170000) - { appendPQExpBuffer(&buf, - ", subfailover AS \"%s\"\n", - gettext_noop("Failover")); - ncols++; - } + ", subsynccommit AS \"%s\"\n" + ", subconninfo AS \"%s\"\n", + gettext_noop("Synchronous commit"), + gettext_noop("Conninfo")); - if (pset.sversion >= 190000) - { - appendPQExpBuffer(&buf, - ", (select srvname from pg_catalog.pg_foreign_server where oid=subserver) AS \"%s\"\n" - ", subretaindeadtuples AS \"%s\"\n" - ", submaxretention AS \"%s\"\n" - ", subretentionactive AS \"%s\"\n", - gettext_noop("Server"), - gettext_noop("Retain dead tuples"), - gettext_noop("Max retention duration"), - gettext_noop("Retention active")); - ncols += 4; - } + if (pset.sversion >= 190000) + appendPQExpBuffer(&buf, + ", subwalrcvtimeout AS \"%s\"\n", + gettext_noop("Receiver timeout")); - appendPQExpBuffer(&buf, - ", subsynccommit AS \"%s\"\n" - ", subconninfo AS \"%s\"\n", - gettext_noop("Synchronous commit"), - gettext_noop("Conninfo")); - ncols += 2; + /* Skip LSN is only supported in v15 and higher */ + if (pset.sversion >= 150000) + appendPQExpBuffer(&buf, + ", subskiplsn AS \"%s\"\n", + gettext_noop("Skip LSN")); - if (pset.sversion >= 190000) - { - appendPQExpBuffer(&buf, - ", subwalrcvtimeout AS \"%s\"\n", - gettext_noop("Receiver timeout")); - ncols++; - } + /* Conflict log destination is supported in v20 and higher */ + if (pset.sversion >= 200000) + appendPQExpBuffer(&buf, + ", subconflictlogdest AS \"%s\"\n", + gettext_noop("Conflict log destination")); - /* Skip LSN is only supported in v15 and higher */ - if (pset.sversion >= 150000) - { appendPQExpBuffer(&buf, - ", subskiplsn AS \"%s\"\n", - gettext_noop("Skip LSN")); - ncols++; - } + ", pg_catalog.obj_description(oid, 'pg_subscription') AS \"%s\"\n", + gettext_noop("Description")); - /* Conflict log destination is supported in v20 and higher */ - if (pset.sversion >= 200000) - { - appendPQExpBuffer(&buf, - ", subconflictlogdest AS \"%s\"\n", - gettext_noop("Conflict log destination")); - ncols++; + /* + * Fetch the conflict log table as a trailing internal column so it + * can be displayed in a footer rather than as a table column. + */ + if (pset.sversion >= 200000) + appendPQExpBufferStr(&buf, + ", CASE WHEN subconflictlogrelid <> 0\n" + " THEN subconflictlogrelid::pg_catalog.regclass::pg_catalog.text\n" + " END AS conflict_log_table\n"); + else + appendPQExpBufferStr(&buf, + ", NULL::pg_catalog.text AS conflict_log_table\n"); } - appendPQExpBuffer(&buf, - ", pg_catalog.obj_description(oid, 'pg_subscription') AS \"%s\"\n", - gettext_noop("Description")); - ncols++; - /* Only display subscriptions in current database. */ appendPQExpBufferStr(&buf, "FROM pg_catalog.pg_subscription\n" @@ -7016,18 +6908,27 @@ describeSubscriptions(const char *pattern) NULL, 1)) { termPQExpBuffer(&buf); - termPQExpBuffer(&footer); return false; } - appendPQExpBufferStr(&buf, "ORDER BY subname;"); + appendPQExpBufferStr(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); if (!res) - { - termPQExpBuffer(&footer); return false; + + if (!verbose) + { + myopt.title = _("List of subscriptions"); + myopt.translate_header = true; + myopt.translate_columns = translate_columns; + myopt.n_translate_columns = lengthof(translate_columns); + + printQuery(res, &myopt, pset.queryFout, false, pset.logfile); + + PQclear(res); + return true; } if (PQntuples(res) == 0) @@ -7041,133 +6942,69 @@ describeSubscriptions(const char *pattern) pg_log_error("Did not find any subscriptions."); } - termPQExpBuffer(&footer); PQclear(res); return false; } - for (i = 0; i < PQntuples(res); i++) - { - const char align = 'l'; - char *subname = PQgetvalue(res, i, 0); - char *conflict_log_table = PQgetvalue(res, i, 1); - int current_col = 2; - printTableOpt myopt = pset.popt.topt; - - /* Like \d, show only the footers, no row count. */ - myopt.default_footer = false; - - initPQExpBuffer(&title); - printfPQExpBuffer(&title, _("Subscription %s"), subname); - printTableInit(&cont, &myopt, title.data, ncols, nrows); - - printTableAddHeader(&cont, gettext_noop("Owner"), true, align); - printTableAddHeader(&cont, gettext_noop("Enabled"), true, align); - printTableAddHeader(&cont, gettext_noop("Publication"), true, align); - - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - if (pset.sversion >= 140000) - { - printTableAddHeader(&cont, gettext_noop("Binary"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + clt_col = PQnfields(res) - 1; + ncols = clt_col - 1; - printTableAddHeader(&cont, gettext_noop("Streaming"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } - - if (pset.sversion >= 150000) - { - printTableAddHeader(&cont, gettext_noop("Two-phase commit"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - printTableAddHeader(&cont, gettext_noop("Disable on error"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } - - if (pset.sversion >= 160000) - { - printTableAddHeader(&cont, gettext_noop("Origin"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + initPQExpBuffer(&title); - printTableAddHeader(&cont, gettext_noop("Password required"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + for (int i = 0; i < PQntuples(res); i++) + { + printTableOpt topt = pset.popt.topt; + printTableContent cont; - printTableAddHeader(&cont, gettext_noop("Run as owner?"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } + /* Like \d, show only the footers, no row count. */ + topt.default_footer = false; - if (pset.sversion >= 170000) - { - printTableAddHeader(&cont, gettext_noop("Failover"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } + printfPQExpBuffer(&title, _("Subscription %s"), + PQgetvalue(res, i, 0)); + printTableInit(&cont, &topt, title.data, ncols, 1); - if (pset.sversion >= 190000) + for (int j = 1; j < clt_col; j++) { - printTableAddHeader(&cont, gettext_noop("Server"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - printTableAddHeader(&cont, gettext_noop("Retain dead tuples"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - printTableAddHeader(&cont, gettext_noop("Max retention duration"), - true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - printTableAddHeader(&cont, gettext_noop("Retention active"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } + Oid ftype = PQftype(res, j); + char *val; - printTableAddHeader(&cont, gettext_noop("Synchronous commit"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + printTableAddHeader(&cont, PQfname(res, j), true, + column_type_alignment(ftype)); - printTableAddHeader(&cont, gettext_noop("Conninfo"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - - if (pset.sversion >= 190000) - { - printTableAddHeader(&cont, gettext_noop("Receiver timeout"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); - } + if (PQgetisnull(res, i, j)) + val = pset.popt.nullPrint ? pset.popt.nullPrint : ""; + else if (ftype == BOOLOID) + { + val = (PQgetvalue(res, i, j)[0] == 't' ? + (pset.popt.truePrint ? pset.popt.truePrint : "t") : + (pset.popt.falsePrint ? pset.popt.falsePrint : "f")); + } + else + val = PQgetvalue(res, i, j); - if (pset.sversion >= 150000) - { - printTableAddHeader(&cont, gettext_noop("Skip LSN"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + printTableAddCell(&cont, val, false, false); } - if (pset.sversion >= 200000) + if (!PQgetisnull(res, i, clt_col)) { - printTableAddHeader(&cont, gettext_noop("Conflict log destination"), - true, align); - - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), - false, false); - } - - printTableAddHeader(&cont, gettext_noop("Description"), true, align); - printTableAddCell(&cont, PQgetvalue(res, i, current_col++), false, false); + char *footer; - /* NULL (an empty string here) when there is no conflict log table */ - if (conflict_log_table[0] != '\0') - { printTableAddFooter(&cont, _("Conflict log table:")); - printfPQExpBuffer(&footer, " %s", conflict_log_table); - printTableAddFooter(&cont, footer.data); + footer = psprintf(" %s", PQgetvalue(res, i, clt_col)); + printTableAddFooter(&cont, footer); + pg_free(footer); } printTable(&cont, pset.queryFout, false, pset.logfile); printTableCleanup(&cont); - termPQExpBuffer(&title); + if (CancelRequested) + break; } - termPQExpBuffer(&footer); + termPQExpBuffer(&title); PQclear(res); - return true; + return !CancelRequested; } /* diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 15c6c685323..47fae5ceafb 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -126,10 +126,7 @@ bool listPublications(const char *pattern); bool describePublications(const char *pattern); /* \dRs */ -bool listSubscriptions(const char *pattern); - -/* \dRs+ */ -bool describeSubscriptions(const char *pattern); +bool describeSubscriptions(const char *pattern, bool verbose); /* \dAc */ extern bool listOperatorClasses(const char *access_method_pattern, diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index b4386ef9e0e..a140a9c7d4a 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -142,14 +142,14 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub4 Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | none | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | none | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub4 SET (origin = any); \dRs+ regress_testsub4 Subscription regress_testsub4 Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | DROP SUBSCRIPTION regress_testsub3; DROP SUBSCRIPTION regress_testsub4; @@ -278,7 +278,7 @@ ERROR: invalid connection string syntax: missing "=" after "foobar" in connecti Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | test subscription + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | test subscription ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false); ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2'; @@ -289,7 +289,7 @@ ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+------------------------------+------------------+------------+--------------------------+------------------- - regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | f | t | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00000000 | log | test subscription + regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | f | t | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00000000 | log | test subscription ALTER SUBSCRIPTION regress_testsub SET (password_required = true); ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false); @@ -307,7 +307,7 @@ ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345'); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+------------------------------+------------------+------------+--------------------------+------------------- - regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00012345 | log | test subscription + regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00012345 | log | test subscription -- ok - with lsn = NONE ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE); @@ -318,7 +318,7 @@ ERROR: invalid WAL location (LSN): 0/0 Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+------------------------------+------------------+------------+--------------------------+------------------- - regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00000000 | log | test subscription + regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist2 | -1 | 0/00000000 | log | test subscription BEGIN; ALTER SUBSCRIPTION regress_testsub ENABLE; @@ -356,7 +356,7 @@ ERROR: invalid value for parameter "wal_receiver_timeout": "foobar" Subscription regress_testsub_foo Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+------------------------------+------------------+------------+--------------------------+------------------- - regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | local | dbname=regress_doesnotexist2 | 80s | 0/00000000 | log | test subscription + regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | | f | 0 | f | local | dbname=regress_doesnotexist2 | 80s | 0/00000000 | log | test subscription -- rename back to keep the rest simple ALTER SUBSCRIPTION regress_testsub_foo RENAME TO regress_testsub; @@ -387,7 +387,7 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | t | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | t | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (binary = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -395,7 +395,7 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | DROP SUBSCRIPTION regress_testsub; -- fail - streaming must be boolean or 'parallel' @@ -409,14 +409,14 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel); \dRs+ Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (streaming = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -424,7 +424,7 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | -- fail - publication already exists ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub WITH (refresh = false); @@ -441,7 +441,7 @@ ERROR: publication "testpub1" is already in subscription "regress_testsub" Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | -- fail - publication used more than once ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub1 WITH (refresh = false); @@ -458,7 +458,7 @@ ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (ref Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | DROP SUBSCRIPTION regress_testsub; CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION mypub @@ -496,7 +496,7 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | -- we can alter streaming when two_phase enabled ALTER SUBSCRIPTION regress_testsub SET (streaming = true); @@ -504,7 +504,7 @@ ALTER SUBSCRIPTION regress_testsub SET (streaming = true); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; @@ -516,7 +516,7 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; @@ -531,14 +531,14 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true); \dRs+ Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | t | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | t | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; @@ -553,7 +553,7 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; @@ -572,7 +572,7 @@ HINT: To initiate replication, you must manually create the replication slot, e Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 1000 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 1000 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | -- fail - max_retention_duration must be non-negative ALTER SUBSCRIPTION regress_testsub SET (max_retention_duration = -1); @@ -583,7 +583,7 @@ ALTER SUBSCRIPTION regress_testsub SET (max_retention_duration = 0); Subscription regress_testsub Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Server | Retain dead tuples | Max retention duration | Retention active | Synchronous commit | Conninfo | Receiver timeout | Skip LSN | Conflict log destination | Description ---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------+--------------------+------------------------+------------------+--------------------+-----------------------------+------------------+------------+--------------------------+------------- - regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | + regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | | f | 0 | f | off | dbname=regress_doesnotexist | -1 | 0/00000000 | log | ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; -- 2.54.0 (Apple Git-157)