]> granicus.if.org Git - postgresql/commitdiff
psql: Fix display of whether table is part of publication
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 2 Jun 2017 01:13:40 +0000 (21:13 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 2 Jun 2017 01:17:01 +0000 (21:17 -0400)
If a FOR ALL TABLES publication was present, \d of a table would claim
for each table that it was part of the publication, even for tables that
are ignored for this purpose, such as system tables and unlogged tables.
Fix the query by using the function pg_get_publication_tables(), which
was intended for this purpose.

Reported-by: tushar <tushar.ahuja@enterprisedb.com>
Reviewed-by: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com>
src/bin/psql/describe.c

index 3e542f7b1d4bd99ed503d1474eb4f6227245afb4..f1c3d9b7e01caf8db657f0460c98d29a37557ee4 100644 (file)
@@ -2537,10 +2537,9 @@ describeOneTableDetails(const char *schemaname,
                {
                        printfPQExpBuffer(&buf,
                                                          "SELECT pub.pubname\n"
-                                                         " FROM pg_catalog.pg_publication pub\n"
-                                                         " LEFT JOIN pg_catalog.pg_publication_rel pr\n"
-                                                         "      ON (pr.prpubid = pub.oid)\n"
-                                                         "WHERE pr.prrelid = '%s' OR pub.puballtables\n"
+                                                         " FROM pg_catalog.pg_publication pub,\n"
+                                                         "      pg_catalog.pg_get_publication_tables(pub.pubname)\n"
+                                                         "WHERE relid = '%s'\n"
                                                          "ORDER BY 1;",
                                                          oid);