Commit 9dea962b authored by Tom Lane's avatar Tom Lane

Include publication owner's name in the output of \dRp+.

Without this, \dRp prints information that \dRp+ does not, which
seems pretty odd.

Daniel Gustafsson

Discussion: https://postgr.es/m/3641F19B-336A-431A-86CE-A80562505C5E@yesql.se
parent 3c163a7f
...@@ -5162,8 +5162,9 @@ describePublications(const char *pattern) ...@@ -5162,8 +5162,9 @@ describePublications(const char *pattern)
initPQExpBuffer(&buf); initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT oid, pubname, puballtables, pubinsert,\n" "SELECT oid, pubname,\n"
" pubupdate, pubdelete\n" " pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
" puballtables, pubinsert, pubupdate, pubdelete\n"
"FROM pg_catalog.pg_publication\n"); "FROM pg_catalog.pg_publication\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false, processSQLNamePattern(pset.db, &buf, pattern, false, false,
...@@ -5198,13 +5199,13 @@ describePublications(const char *pattern) ...@@ -5198,13 +5199,13 @@ describePublications(const char *pattern)
for (i = 0; i < PQntuples(res); i++) for (i = 0; i < PQntuples(res); i++)
{ {
const char align = 'l'; const char align = 'l';
int ncols = 4; int ncols = 5;
int nrows = 1; int nrows = 1;
int tables = 0; int tables = 0;
PGresult *tabres; PGresult *tabres;
char *pubid = PQgetvalue(res, i, 0); char *pubid = PQgetvalue(res, i, 0);
char *pubname = PQgetvalue(res, i, 1); char *pubname = PQgetvalue(res, i, 1);
bool puballtables = strcmp(PQgetvalue(res, i, 2), "t") == 0; bool puballtables = strcmp(PQgetvalue(res, i, 3), "t") == 0;
int j; int j;
PQExpBufferData title; PQExpBufferData title;
printTableOpt myopt = pset.popt.topt; printTableOpt myopt = pset.popt.topt;
...@@ -5214,6 +5215,7 @@ describePublications(const char *pattern) ...@@ -5214,6 +5215,7 @@ describePublications(const char *pattern)
printfPQExpBuffer(&title, _("Publication %s"), pubname); printfPQExpBuffer(&title, _("Publication %s"), pubname);
printTableInit(&cont, &myopt, title.data, ncols, nrows); printTableInit(&cont, &myopt, title.data, ncols, nrows);
printTableAddHeader(&cont, gettext_noop("Owner"), true, align);
printTableAddHeader(&cont, gettext_noop("All tables"), true, align); printTableAddHeader(&cont, gettext_noop("All tables"), true, align);
printTableAddHeader(&cont, gettext_noop("Inserts"), true, align); printTableAddHeader(&cont, gettext_noop("Inserts"), true, align);
printTableAddHeader(&cont, gettext_noop("Updates"), true, align); printTableAddHeader(&cont, gettext_noop("Updates"), true, align);
...@@ -5223,6 +5225,7 @@ describePublications(const char *pattern) ...@@ -5223,6 +5225,7 @@ describePublications(const char *pattern)
printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 4), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 4), false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 6), false, false);
if (!puballtables) if (!puballtables)
{ {
......
...@@ -76,10 +76,10 @@ Publications: ...@@ -76,10 +76,10 @@ Publications:
"testpub_foralltables" "testpub_foralltables"
\dRp+ testpub_foralltables \dRp+ testpub_foralltables
Publication testpub_foralltables Publication testpub_foralltables
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
t | t | t | f regress_publication_user | t | t | t | f
(1 row) (1 row)
DROP TABLE testpub_tbl2; DROP TABLE testpub_tbl2;
...@@ -89,19 +89,19 @@ CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3); ...@@ -89,19 +89,19 @@ CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3);
CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3; CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3;
CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3; CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
\dRp+ testpub3 \dRp+ testpub3
Publication testpub3 Publication testpub3
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
f | t | t | t regress_publication_user | f | t | t | t
Tables: Tables:
"public.testpub_tbl3" "public.testpub_tbl3"
"public.testpub_tbl3a" "public.testpub_tbl3a"
\dRp+ testpub4 \dRp+ testpub4
Publication testpub4 Publication testpub4
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
f | t | t | t regress_publication_user | f | t | t | t
Tables: Tables:
"public.testpub_tbl3" "public.testpub_tbl3"
...@@ -119,10 +119,10 @@ ERROR: relation "testpub_tbl1" is already member of publication "testpub_fortbl ...@@ -119,10 +119,10 @@ ERROR: relation "testpub_tbl1" is already member of publication "testpub_fortbl
CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1; CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1;
ERROR: publication "testpub_fortbl" already exists ERROR: publication "testpub_fortbl" already exists
\dRp+ testpub_fortbl \dRp+ testpub_fortbl
Publication testpub_fortbl Publication testpub_fortbl
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
f | t | t | t regress_publication_user | f | t | t | t
Tables: Tables:
"pub_test.testpub_nopk" "pub_test.testpub_nopk"
"public.testpub_tbl1" "public.testpub_tbl1"
...@@ -165,10 +165,10 @@ Publications: ...@@ -165,10 +165,10 @@ Publications:
"testpub_fortbl" "testpub_fortbl"
\dRp+ testpub_default \dRp+ testpub_default
Publication testpub_default Publication testpub_default
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
f | t | t | t regress_publication_user | f | t | t | t
Tables: Tables:
"pub_test.testpub_nopk" "pub_test.testpub_nopk"
"public.testpub_tbl1" "public.testpub_tbl1"
...@@ -210,10 +210,10 @@ DROP TABLE testpub_parted; ...@@ -210,10 +210,10 @@ DROP TABLE testpub_parted;
DROP VIEW testpub_view; DROP VIEW testpub_view;
DROP TABLE testpub_tbl1; DROP TABLE testpub_tbl1;
\dRp+ testpub_default \dRp+ testpub_default
Publication testpub_default Publication testpub_default
All tables | Inserts | Updates | Deletes Owner | All tables | Inserts | Updates | Deletes
------------+---------+---------+--------- --------------------------+------------+---------+---------+---------
f | t | t | t regress_publication_user | f | t | t | t
(1 row) (1 row)
-- fail - must be owner of publication -- fail - must be owner of publication
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment